mirror of https://github.com/LOOHP/Limbo.git
Merge e3af7589bb into ba0f98b6c7
This commit is contained in:
commit
569cb2be5e
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ClientboundOpenBookPacket extends PacketOut {
|
||||||
|
|
||||||
|
private final int hand; // 0 = main hand, 1 = off hand
|
||||||
|
|
||||||
|
public ClientboundOpenBookPacket(int hand) {
|
||||||
|
this.hand = hand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHand() {
|
||||||
|
return hand;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] serializePacket() throws IOException {
|
||||||
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
DataOutputStream output = new DataOutputStream(buffer);
|
||||||
|
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||||
|
output.writeByte(hand);
|
||||||
|
|
||||||
|
return buffer.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -34,10 +34,12 @@ import com.loohp.limbo.events.player.PlayerTeleportEvent;
|
||||||
import com.loohp.limbo.inventory.Inventory;
|
import com.loohp.limbo.inventory.Inventory;
|
||||||
import com.loohp.limbo.inventory.InventoryHolder;
|
import com.loohp.limbo.inventory.InventoryHolder;
|
||||||
import com.loohp.limbo.inventory.InventoryView;
|
import com.loohp.limbo.inventory.InventoryView;
|
||||||
|
import com.loohp.limbo.inventory.ItemStack;
|
||||||
import com.loohp.limbo.inventory.TitledInventory;
|
import com.loohp.limbo.inventory.TitledInventory;
|
||||||
import com.loohp.limbo.location.Location;
|
import com.loohp.limbo.location.Location;
|
||||||
import com.loohp.limbo.network.ClientConnection;
|
import com.loohp.limbo.network.ClientConnection;
|
||||||
import com.loohp.limbo.network.protocol.packets.ClientboundClearTitlesPacket;
|
import com.loohp.limbo.network.protocol.packets.ClientboundClearTitlesPacket;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.ClientboundOpenBookPacket;
|
||||||
import com.loohp.limbo.network.protocol.packets.ClientboundSetActionBarTextPacket;
|
import com.loohp.limbo.network.protocol.packets.ClientboundSetActionBarTextPacket;
|
||||||
import com.loohp.limbo.network.protocol.packets.ClientboundSetSubtitleTextPacket;
|
import com.loohp.limbo.network.protocol.packets.ClientboundSetSubtitleTextPacket;
|
||||||
import com.loohp.limbo.network.protocol.packets.ClientboundSetTitleTextPacket;
|
import com.loohp.limbo.network.protocol.packets.ClientboundSetTitleTextPacket;
|
||||||
|
|
@ -53,6 +55,7 @@ import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerListHeaderFoo
|
||||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPositionAndLook;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPositionAndLook;
|
||||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutResourcePackSend;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutResourcePackSend;
|
||||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutRespawn;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutRespawn;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutSetSlot;
|
||||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutStopSound;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutStopSound;
|
||||||
import com.loohp.limbo.sounds.SoundEffect;
|
import com.loohp.limbo.sounds.SoundEffect;
|
||||||
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
|
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
|
||||||
|
|
@ -68,11 +71,15 @@ import net.kyori.adventure.sound.Sound.Emitter;
|
||||||
import net.kyori.adventure.sound.SoundStop;
|
import net.kyori.adventure.sound.SoundStop;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import net.kyori.adventure.title.Title;
|
import net.kyori.adventure.title.Title;
|
||||||
import net.kyori.adventure.title.Title.Times;
|
import net.kyori.adventure.title.Title.Times;
|
||||||
import net.kyori.adventure.title.TitlePart;
|
import net.kyori.adventure.title.TitlePart;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
import net.querz.nbt.tag.ListTag;
|
||||||
|
import net.querz.nbt.tag.StringTag;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
@ -82,7 +89,7 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class Player extends LivingEntity implements CommandSender, InventoryHolder {
|
public class Player extends LivingEntity implements CommandSender, InventoryHolder {
|
||||||
|
|
||||||
public static final String CHAT_DEFAULT_FORMAT = "<%name%> %message%";
|
public static final String CHAT_DEFAULT_FORMAT = "<%name%> %message%";
|
||||||
|
|
||||||
public final ClientConnection clientConnection;
|
public final ClientConnection clientConnection;
|
||||||
|
|
@ -95,20 +102,20 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
protected final PlayerInventory playerInventory;
|
protected final PlayerInventory playerInventory;
|
||||||
protected final InventoryView inventoryView;
|
protected final InventoryView inventoryView;
|
||||||
private final AtomicInteger containerIdCounter;
|
private final AtomicInteger containerIdCounter;
|
||||||
|
|
||||||
@WatchableField(MetadataIndex = 15, WatchableObjectType = WatchableObjectType.FLOAT)
|
@WatchableField(MetadataIndex = 15, WatchableObjectType = WatchableObjectType.FLOAT)
|
||||||
protected float additionalHearts = 0.0F;
|
protected float additionalHearts = 0.0F;
|
||||||
@WatchableField(MetadataIndex = 16, WatchableObjectType = WatchableObjectType.VARINT)
|
@WatchableField(MetadataIndex = 16, WatchableObjectType = WatchableObjectType.VARINT)
|
||||||
protected int score = 0;
|
protected int score = 0;
|
||||||
@WatchableField(MetadataIndex = 17, WatchableObjectType = WatchableObjectType.BYTE)
|
@WatchableField(MetadataIndex = 17, WatchableObjectType = WatchableObjectType.BYTE)
|
||||||
protected byte skinLayers = 0;
|
protected byte skinLayers = 0;
|
||||||
@WatchableField(MetadataIndex = 18, WatchableObjectType = WatchableObjectType.BYTE)
|
@WatchableField(MetadataIndex = 18, WatchableObjectType = WatchableObjectType.BYTE)
|
||||||
protected byte mainHand = 1;
|
protected byte mainHand = 1;
|
||||||
//@WatchableField(MetadataIndex = 19, WatchableObjectType = WatchableObjectType.NBT)
|
//@WatchableField(MetadataIndex = 19, WatchableObjectType = WatchableObjectType.NBT)
|
||||||
//protected Entity leftShoulder = null;
|
//protected Entity leftShoulder = null;
|
||||||
//@WatchableField(MetadataIndex = 20, WatchableObjectType = WatchableObjectType.NBT)
|
//@WatchableField(MetadataIndex = 20, WatchableObjectType = WatchableObjectType.NBT)
|
||||||
//protected Entity rightShoulder = null;
|
//protected Entity rightShoulder = null;
|
||||||
|
|
||||||
public Player(ClientConnection clientConnection, String username, UUID uuid, int entityId, Location location, PlayerInteractManager playerInteractManager) throws IllegalArgumentException, IllegalAccessException {
|
public Player(ClientConnection clientConnection, String username, UUID uuid, int entityId, Location location, PlayerInteractManager playerInteractManager) throws IllegalArgumentException, IllegalAccessException {
|
||||||
super(EntityType.PLAYER, entityId, uuid, location.getWorld(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
super(EntityType.PLAYER, entityId, uuid, location.getWorld(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||||
this.clientConnection = clientConnection;
|
this.clientConnection = clientConnection;
|
||||||
|
|
@ -159,7 +166,7 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
}
|
}
|
||||||
this.gamemode = gamemode;
|
this.gamemode = gamemode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected void setEntityId(int entityId) {
|
protected void setEntityId(int entityId) {
|
||||||
this.entityId = entityId;
|
this.entityId = entityId;
|
||||||
|
|
@ -196,20 +203,20 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
public void setMainHand(byte mainHand) {
|
public void setMainHand(byte mainHand) {
|
||||||
this.mainHand = mainHand;
|
this.mainHand = mainHand;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataWatcher getDataWatcher() {
|
public DataWatcher getDataWatcher() {
|
||||||
return watcher;
|
return watcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return Limbo.getInstance().getPlayers().contains(this);
|
return Limbo.getInstance().getPlayers().contains(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -234,7 +241,7 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String permission) {
|
public boolean hasPermission(String permission) {
|
||||||
return Limbo.getInstance().getPermissionsManager().hasPermission(this, permission);
|
return Limbo.getInstance().getPermissionsManager().hasPermission(this, permission);
|
||||||
|
|
@ -256,7 +263,7 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
} catch (IOException e) {}
|
} catch (IOException e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setLocation(Location location) {
|
protected void setLocation(Location location) {
|
||||||
super.teleport(location);
|
super.teleport(location);
|
||||||
}
|
}
|
||||||
|
|
@ -269,7 +276,7 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
public void sendPluginMessage(String channel, byte[] data) throws IOException {
|
public void sendPluginMessage(String channel, byte[] data) throws IOException {
|
||||||
clientConnection.sendPluginMessage(channel, data);
|
clientConnection.sendPluginMessage(channel, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(String message, UUID uuid) {
|
public void sendMessage(String message, UUID uuid) {
|
||||||
sendMessage(Identity.identity(uuid), LegacyComponentSerializer.legacySection().deserialize(message));
|
sendMessage(Identity.identity(uuid), LegacyComponentSerializer.legacySection().deserialize(message));
|
||||||
}
|
}
|
||||||
|
|
@ -284,7 +291,7 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
public void sendMessage(BaseComponent[] component, UUID uuid) {
|
public void sendMessage(BaseComponent[] component, UUID uuid) {
|
||||||
sendMessage(Identity.identity(uuid), BungeecordAdventureConversionUtils.toComponent(component));
|
sendMessage(Identity.identity(uuid), BungeecordAdventureConversionUtils.toComponent(component));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
sendMessage(LegacyComponentSerializer.legacySection().deserialize(message));
|
sendMessage(LegacyComponentSerializer.legacySection().deserialize(message));
|
||||||
}
|
}
|
||||||
|
|
@ -299,29 +306,29 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
public void sendMessage(BaseComponent[] component) {
|
public void sendMessage(BaseComponent[] component) {
|
||||||
sendMessage(BungeecordAdventureConversionUtils.toComponent(component));
|
sendMessage(BungeecordAdventureConversionUtils.toComponent(component));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
disconnect(Component.translatable("multiplayer.disconnect.kicked"));
|
disconnect(Component.translatable("multiplayer.disconnect.kicked"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(String reason) {
|
public void disconnect(String reason) {
|
||||||
disconnect(LegacyComponentSerializer.legacySection().deserialize(reason));
|
disconnect(LegacyComponentSerializer.legacySection().deserialize(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(Component reason) {
|
public void disconnect(Component reason) {
|
||||||
clientConnection.disconnect(reason);
|
clientConnection.disconnect(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void disconnect(BaseComponent reason) {
|
public void disconnect(BaseComponent reason) {
|
||||||
disconnect(new BaseComponent[] {reason});
|
disconnect(new BaseComponent[] {reason});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void disconnect(BaseComponent[] reason) {
|
public void disconnect(BaseComponent[] reason) {
|
||||||
disconnect(BungeecordAdventureConversionUtils.toComponent(reason));
|
disconnect(BungeecordAdventureConversionUtils.toComponent(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chat(String message) {
|
public void chat(String message) {
|
||||||
chat(message, false);
|
chat(message, false);
|
||||||
}
|
}
|
||||||
|
|
@ -329,7 +336,7 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
public void chat(String message, boolean verbose) {
|
public void chat(String message, boolean verbose) {
|
||||||
chat(message, verbose, null, Instant.now());
|
chat(message, verbose, null, Instant.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chat(String message, boolean verbose, MessageSignature saltSignature, Instant time) {
|
public void chat(String message, boolean verbose, MessageSignature saltSignature, Instant time) {
|
||||||
if (Limbo.getInstance().getServerProperties().isAllowChat()) {
|
if (Limbo.getInstance().getServerProperties().isAllowChat()) {
|
||||||
PlayerChatEvent event = Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, CHAT_DEFAULT_FORMAT, message, false));
|
PlayerChatEvent event = Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, CHAT_DEFAULT_FORMAT, message, false));
|
||||||
|
|
@ -352,11 +359,11 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResourcePack(String url, String hash, boolean forced) {
|
public void setResourcePack(String url, String hash, boolean forced) {
|
||||||
setResourcePack(url, hash, forced, (BaseComponent[]) null);
|
setResourcePack(url, hash, forced, (BaseComponent[]) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setResourcePack(String url, String hash, boolean forced, BaseComponent promptmessage) {
|
public void setResourcePack(String url, String hash, boolean forced, BaseComponent promptmessage) {
|
||||||
setResourcePack(url, hash, forced, promptmessage == null ? null : new BaseComponent[] {promptmessage});
|
setResourcePack(url, hash, forced, promptmessage == null ? null : new BaseComponent[] {promptmessage});
|
||||||
|
|
@ -366,7 +373,7 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
public void setResourcePack(String url, String hash, boolean forced, BaseComponent[] promptmessage) {
|
public void setResourcePack(String url, String hash, boolean forced, BaseComponent[] promptmessage) {
|
||||||
setResourcePack(url, hash, forced, promptmessage == null ? null : BungeecordAdventureConversionUtils.toComponent(promptmessage));
|
setResourcePack(url, hash, forced, promptmessage == null ? null : BungeecordAdventureConversionUtils.toComponent(promptmessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResourcePack(String url, String hash, boolean forced, Component promptmessage) {
|
public void setResourcePack(String url, String hash, boolean forced, Component promptmessage) {
|
||||||
try {
|
try {
|
||||||
PacketPlayOutResourcePackSend packsend = new PacketPlayOutResourcePackSend(url, hash, forced, promptmessage != null, promptmessage);
|
PacketPlayOutResourcePackSend packsend = new PacketPlayOutResourcePackSend(url, hash, forced, promptmessage != null, promptmessage);
|
||||||
|
|
@ -375,7 +382,7 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
|
public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
|
||||||
sendPlayerListHeaderAndFooter(header == null ? Component.empty() : BungeecordAdventureConversionUtils.toComponent(header), footer == null ? Component.empty() : BungeecordAdventureConversionUtils.toComponent(footer));
|
sendPlayerListHeaderAndFooter(header == null ? Component.empty() : BungeecordAdventureConversionUtils.toComponent(header), footer == null ? Component.empty() : BungeecordAdventureConversionUtils.toComponent(footer));
|
||||||
|
|
@ -385,55 +392,55 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
public void setPlayerListHeaderFooter(BaseComponent header, BaseComponent footer) {
|
public void setPlayerListHeaderFooter(BaseComponent header, BaseComponent footer) {
|
||||||
sendPlayerListHeaderAndFooter(header == null ? Component.empty() : BungeecordAdventureConversionUtils.toComponent(header), footer == null ? Component.empty() : BungeecordAdventureConversionUtils.toComponent(footer));
|
sendPlayerListHeaderAndFooter(header == null ? Component.empty() : BungeecordAdventureConversionUtils.toComponent(header), footer == null ? Component.empty() : BungeecordAdventureConversionUtils.toComponent(footer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerListHeaderFooter(String header, String footer) {
|
public void setPlayerListHeaderFooter(String header, String footer) {
|
||||||
sendPlayerListHeaderAndFooter(header == null ? Component.empty() : LegacyComponentSerializer.legacySection().deserialize(header), footer == null ? Component.empty() : LegacyComponentSerializer.legacySection().deserialize(footer));
|
sendPlayerListHeaderAndFooter(header == null ? Component.empty() : LegacyComponentSerializer.legacySection().deserialize(header), footer == null ? Component.empty() : LegacyComponentSerializer.legacySection().deserialize(footer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTitle(BaseComponent[] title) {
|
public void setTitle(BaseComponent[] title) {
|
||||||
sendTitlePart(TitlePart.TITLE, BungeecordAdventureConversionUtils.toComponent(title));
|
sendTitlePart(TitlePart.TITLE, BungeecordAdventureConversionUtils.toComponent(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTitle(BaseComponent title) {
|
public void setTitle(BaseComponent title) {
|
||||||
sendTitlePart(TitlePart.TITLE, BungeecordAdventureConversionUtils.toComponent(title));
|
sendTitlePart(TitlePart.TITLE, BungeecordAdventureConversionUtils.toComponent(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
sendTitlePart(TitlePart.TITLE, LegacyComponentSerializer.legacySection().deserialize(title));
|
sendTitlePart(TitlePart.TITLE, LegacyComponentSerializer.legacySection().deserialize(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setSubTitle(BaseComponent[] subTitle) {
|
public void setSubTitle(BaseComponent[] subTitle) {
|
||||||
sendTitlePart(TitlePart.SUBTITLE, BungeecordAdventureConversionUtils.toComponent(subTitle));
|
sendTitlePart(TitlePart.SUBTITLE, BungeecordAdventureConversionUtils.toComponent(subTitle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setSubTitle(BaseComponent subTitle) {
|
public void setSubTitle(BaseComponent subTitle) {
|
||||||
sendTitlePart(TitlePart.SUBTITLE, BungeecordAdventureConversionUtils.toComponent(subTitle));
|
sendTitlePart(TitlePart.SUBTITLE, BungeecordAdventureConversionUtils.toComponent(subTitle));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubTitle(String subTitle) {
|
public void setSubTitle(String subTitle) {
|
||||||
sendTitlePart(TitlePart.SUBTITLE, LegacyComponentSerializer.legacySection().deserialize(subTitle));
|
sendTitlePart(TitlePart.SUBTITLE, LegacyComponentSerializer.legacySection().deserialize(subTitle));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitleTimer(int fadeIn, int stay, int fadeOut) {
|
public void setTitleTimer(int fadeIn, int stay, int fadeOut) {
|
||||||
sendTitlePart(TitlePart.TIMES, Title.Times.times(Duration.ofMillis(fadeIn * 50), Duration.ofMillis(stay * 50), Duration.ofMillis(fadeOut * 50)));
|
sendTitlePart(TitlePart.TIMES, Title.Times.times(Duration.ofMillis(fadeIn * 50), Duration.ofMillis(stay * 50), Duration.ofMillis(fadeOut * 50)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTitleSubTitle(BaseComponent[] title, BaseComponent[] subTitle, int fadeIn, int stay, int fadeOut) {
|
public void setTitleSubTitle(BaseComponent[] title, BaseComponent[] subTitle, int fadeIn, int stay, int fadeOut) {
|
||||||
setTitleTimer(fadeIn, stay, fadeOut);
|
setTitleTimer(fadeIn, stay, fadeOut);
|
||||||
setTitle(title);
|
setTitle(title);
|
||||||
setSubTitle(subTitle);
|
setSubTitle(subTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTitleSubTitle(BaseComponent title, BaseComponent subTitle, int fadeIn, int stay, int fadeOut) {
|
public void setTitleSubTitle(BaseComponent title, BaseComponent subTitle, int fadeIn, int stay, int fadeOut) {
|
||||||
setTitleSubTitle(new BaseComponent[] {title}, new BaseComponent[] {subTitle}, fadeIn, stay, fadeOut);
|
setTitleSubTitle(new BaseComponent[] {title}, new BaseComponent[] {subTitle}, fadeIn, stay, fadeOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitleSubTitle(String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
public void setTitleSubTitle(String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||||
sendTitlePart(TitlePart.TIMES, Title.Times.times(Duration.ofMillis(fadeIn * 50), Duration.ofMillis(stay * 50), Duration.ofMillis(fadeOut * 50)));
|
sendTitlePart(TitlePart.TIMES, Title.Times.times(Duration.ofMillis(fadeIn * 50), Duration.ofMillis(stay * 50), Duration.ofMillis(fadeOut * 50)));
|
||||||
sendTitlePart(TitlePart.SUBTITLE, LegacyComponentSerializer.legacySection().deserialize(subTitle));
|
sendTitlePart(TitlePart.SUBTITLE, LegacyComponentSerializer.legacySection().deserialize(subTitle));
|
||||||
|
|
@ -469,7 +476,34 @@ public class Player extends LivingEntity implements CommandSender, InventoryHold
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openBook(Book book) {
|
public void openBook(Book book) {
|
||||||
throw new UnsupportedOperationException("This function has not been implemented yet.");
|
ItemStack item = new ItemStack(Key.key("minecraft:written_book"));
|
||||||
|
CompoundTag nbt = new CompoundTag();
|
||||||
|
nbt.putString("title", PlainTextComponentSerializer.plainText().serialize(book.title()));
|
||||||
|
nbt.putString("author", PlainTextComponentSerializer.plainText().serialize(book.author()));
|
||||||
|
ListTag<StringTag> pages = new ListTag<>(StringTag.class);
|
||||||
|
for (Component page : book.pages()) {
|
||||||
|
pages.add(new StringTag(PlainTextComponentSerializer.plainText().serialize(page)));
|
||||||
|
}
|
||||||
|
nbt.put("pages", pages);
|
||||||
|
item.nbt(nbt);
|
||||||
|
PacketPlayOutSetSlot setSlot = new PacketPlayOutSetSlot(0, 0,0, item);
|
||||||
|
try {
|
||||||
|
clientConnection.sendPacket(setSlot);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
ClientboundOpenBookPacket openBook = new ClientboundOpenBookPacket(0);
|
||||||
|
try {
|
||||||
|
clientConnection.sendPacket(openBook);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
PacketPlayOutSetSlot resetSlot = new PacketPlayOutSetSlot(0, 0,0, getInventory().getItemInMainHand());
|
||||||
|
try {
|
||||||
|
clientConnection.sendPacket(resetSlot);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@
|
||||||
"PacketPlayOutStopSound": "0x5F",
|
"PacketPlayOutStopSound": "0x5F",
|
||||||
"PacketPlayOutWindowItems": "0x10",
|
"PacketPlayOutWindowItems": "0x10",
|
||||||
"PacketPlayOutSetSlot": "0x12",
|
"PacketPlayOutSetSlot": "0x12",
|
||||||
|
"ClientboundOpenBookPacket": "0x2B",
|
||||||
"PacketPlayOutOpenWindow": "0x2C",
|
"PacketPlayOutOpenWindow": "0x2C",
|
||||||
"PacketPlayOutCloseWindow": "0x0F",
|
"PacketPlayOutCloseWindow": "0x0F",
|
||||||
"PacketPlayOutWindowData": "0x11"
|
"PacketPlayOutWindowData": "0x11"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue