forked from BLOCKFANTASY/LOOHP-Limbo
Minecraft 1.21
This commit is contained in:
@@ -43,7 +43,6 @@ import com.loohp.limbo.inventory.ItemStack;
|
||||
import com.loohp.limbo.location.Location;
|
||||
import com.loohp.limbo.network.protocol.packets.ClientboundFinishConfigurationPacket;
|
||||
import com.loohp.limbo.network.protocol.packets.ClientboundRegistryDataPacket;
|
||||
import com.loohp.limbo.network.protocol.packets.Packet;
|
||||
import com.loohp.limbo.network.protocol.packets.PacketHandshakingIn;
|
||||
import com.loohp.limbo.network.protocol.packets.PacketIn;
|
||||
import com.loohp.limbo.network.protocol.packets.PacketLoginInLoginStart;
|
||||
@@ -99,6 +98,7 @@ import com.loohp.limbo.network.protocol.packets.ServerboundLoginAcknowledgedPack
|
||||
import com.loohp.limbo.player.Player;
|
||||
import com.loohp.limbo.player.PlayerInteractManager;
|
||||
import com.loohp.limbo.player.PlayerInventory;
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.registry.RegistryCustom;
|
||||
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
|
||||
import com.loohp.limbo.utils.CheckedBiConsumer;
|
||||
@@ -288,26 +288,7 @@ public class ClientConnection extends Thread {
|
||||
DataInput input = read.getDataInput();
|
||||
int size = read.getSize();
|
||||
int packetId = read.getPacketId();
|
||||
Class<? extends PacketIn> packetType;
|
||||
switch (state) {
|
||||
case HANDSHAKE:
|
||||
packetType = Packet.getHandshakeIn().get(packetId);
|
||||
break;
|
||||
case STATUS:
|
||||
packetType = Packet.getStatusIn().get(packetId);
|
||||
break;
|
||||
case LOGIN:
|
||||
packetType = Packet.getLoginIn().get(packetId);
|
||||
break;
|
||||
case CONFIGURATION:
|
||||
packetType = Packet.getConfigurationIn().get(packetId);
|
||||
break;
|
||||
case PLAY:
|
||||
packetType = Packet.getPlayIn().get(packetId);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Illegal ClientState!");
|
||||
}
|
||||
Class<? extends PacketIn> packetType = PacketRegistry.getPacketClass(packetId, PacketRegistry.NetworkPhase.fromClientState(state), PacketRegistry.PacketBound.SERVERBOUND);
|
||||
if (packetType == null) {
|
||||
input.skipBytes(size - DataTypeIO.getVarIntLength(packetId));
|
||||
return null;
|
||||
@@ -569,22 +550,10 @@ public class ClientConnection extends Thread {
|
||||
|
||||
TimeUnit.MILLISECONDS.sleep(500);
|
||||
|
||||
ClientboundRegistryDataPacket registryDataPacket1 = new ClientboundRegistryDataPacket(RegistryCustom.WORLDGEN_BIOME);
|
||||
sendPacket(registryDataPacket1);
|
||||
ClientboundRegistryDataPacket registryDataPacket2 = new ClientboundRegistryDataPacket(RegistryCustom.CHAT_TYPE);
|
||||
sendPacket(registryDataPacket2);
|
||||
ClientboundRegistryDataPacket registryDataPacket3 = new ClientboundRegistryDataPacket(RegistryCustom.TRIM_PATTERN);
|
||||
sendPacket(registryDataPacket3);
|
||||
ClientboundRegistryDataPacket registryDataPacket4 = new ClientboundRegistryDataPacket(RegistryCustom.TRIM_MATERIAL);
|
||||
sendPacket(registryDataPacket4);
|
||||
ClientboundRegistryDataPacket registryDataPacket5 = new ClientboundRegistryDataPacket(RegistryCustom.WOLF_VARIANT);
|
||||
sendPacket(registryDataPacket5);
|
||||
ClientboundRegistryDataPacket registryDataPacket6 = new ClientboundRegistryDataPacket(RegistryCustom.DIMENSION_TYPE);
|
||||
sendPacket(registryDataPacket6);
|
||||
ClientboundRegistryDataPacket registryDataPacket7 = new ClientboundRegistryDataPacket(RegistryCustom.DAMAGE_TYPE);
|
||||
sendPacket(registryDataPacket7);
|
||||
ClientboundRegistryDataPacket registryDataPacket8 = new ClientboundRegistryDataPacket(RegistryCustom.BANNER_PATTERN);
|
||||
sendPacket(registryDataPacket8);
|
||||
for (RegistryCustom registryCustom : RegistryCustom.getRegistries()) {
|
||||
ClientboundRegistryDataPacket registryDataPacket = new ClientboundRegistryDataPacket(registryCustom);
|
||||
sendPacket(registryDataPacket);
|
||||
}
|
||||
|
||||
ClientboundFinishConfigurationPacket clientboundFinishConfigurationPacket = new ClientboundFinishConfigurationPacket();
|
||||
sendPacket(clientboundFinishConfigurationPacket);
|
||||
|
||||
@@ -29,16 +29,18 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerConnection extends Thread {
|
||||
|
||||
|
||||
private final String ip;
|
||||
private final int port;
|
||||
private final boolean silent;
|
||||
private ServerSocket serverSocket;
|
||||
private List<ClientConnection> clients;
|
||||
private String ip;
|
||||
private int port;
|
||||
|
||||
public ServerConnection(String ip, int port) {
|
||||
clients = new ArrayList<ClientConnection>();
|
||||
public ServerConnection(String ip, int port, boolean silent) {
|
||||
this.clients = new ArrayList<>();
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
this.silent = silent;
|
||||
start();
|
||||
}
|
||||
|
||||
@@ -46,7 +48,9 @@ public class ServerConnection extends Thread {
|
||||
public void run() {
|
||||
try {
|
||||
serverSocket = new ServerSocket(port, 50, InetAddress.getByName(ip));
|
||||
Limbo.getInstance().getConsole().sendMessage("Limbo server listening on /" + serverSocket.getInetAddress().getHostName() + ":" + serverSocket.getLocalPort());
|
||||
if (!silent) {
|
||||
Limbo.getInstance().getConsole().sendMessage("Limbo server listening on /" + serverSocket.getInetAddress().getHostName() + ":" + serverSocket.getLocalPort());
|
||||
}
|
||||
while (true) {
|
||||
Socket connection = serverSocket.accept();
|
||||
ClientConnection sc = new ClientConnection(connection);
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -42,7 +43,7 @@ public class ClientboundChunkBatchFinishedPacket extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
DataTypeIO.writeVarInt(output, batchSize);
|
||||
|
||||
|
||||
+3
-1
@@ -19,6 +19,8 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -33,7 +35,7 @@ public class ClientboundChunkBatchStartPacket extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
|
||||
+4
-2
@@ -19,13 +19,15 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ClientboundClearTitlesPacket extends PacketOut {
|
||||
|
||||
private boolean reset;
|
||||
private final boolean reset;
|
||||
|
||||
public ClientboundClearTitlesPacket(boolean reset) {
|
||||
this.reset = reset;
|
||||
@@ -40,7 +42,7 @@ public class ClientboundClearTitlesPacket extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
output.writeBoolean(reset);
|
||||
|
||||
return buffer.toByteArray();
|
||||
|
||||
+3
-1
@@ -19,6 +19,8 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -33,7 +35,7 @@ public class ClientboundFinishConfigurationPacket extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getConfigurationOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
|
||||
+12
-11
@@ -20,6 +20,7 @@
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.BuiltInRegistries;
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.BitsUtils;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import com.loohp.limbo.world.Environment;
|
||||
@@ -40,16 +41,16 @@ import java.util.List;
|
||||
|
||||
public class ClientboundLevelChunkWithLightPacket extends PacketOut {
|
||||
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
private Chunk chunk;
|
||||
private Environment environment;
|
||||
private long[] skyLightBitMasks;
|
||||
private long[] blockLightBitMasks;
|
||||
private long[] skyLightBitMasksEmpty;
|
||||
private long[] blockLightBitMasksEmpty;
|
||||
private List<Byte[]> skylightArrays;
|
||||
private List<Byte[]> blocklightArrays;
|
||||
private final int chunkX;
|
||||
private final int chunkZ;
|
||||
private final Chunk chunk;
|
||||
private final Environment environment;
|
||||
private final long[] skyLightBitMasks;
|
||||
private final long[] blockLightBitMasks;
|
||||
private final long[] skyLightBitMasksEmpty;
|
||||
private final long[] blockLightBitMasksEmpty;
|
||||
private final List<Byte[]> skylightArrays;
|
||||
private final List<Byte[]> blocklightArrays;
|
||||
|
||||
public ClientboundLevelChunkWithLightPacket(int chunkX, int chunkZ, Chunk chunk, Environment environment, List<Byte[]> skylightArrays, List<Byte[]> blocklightArrays) {
|
||||
this.chunkX = chunkX;
|
||||
@@ -115,7 +116,7 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
output.writeInt(chunkX);
|
||||
output.writeInt(chunkZ);
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.registry.RegistryCustom;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.key.Key;
|
||||
@@ -47,7 +48,7 @@ public class ClientboundRegistryDataPacket extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getConfigurationOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
DataTypeIO.writeString(output, registry.getIdentifier().asString(), StandardCharsets.UTF_8);
|
||||
DataTypeIO.writeVarInt(output, registry.getEntries().size());
|
||||
|
||||
+2
-2
@@ -19,9 +19,9 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -75,7 +75,7 @@ public class ClientboundResourcePackPushPacket extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeUUID(output, id);
|
||||
DataTypeIO.writeString(output, url, StandardCharsets.UTF_8);
|
||||
DataTypeIO.writeString(output, hash, StandardCharsets.UTF_8);
|
||||
|
||||
+3
-2
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@@ -28,7 +29,7 @@ import java.io.IOException;
|
||||
|
||||
public class ClientboundSetActionBarTextPacket extends PacketOut {
|
||||
|
||||
private Component actionBar;
|
||||
private final Component actionBar;
|
||||
|
||||
public ClientboundSetActionBarTextPacket(Component actionBar) {
|
||||
this.actionBar = actionBar;
|
||||
@@ -43,7 +44,7 @@ public class ClientboundSetActionBarTextPacket extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeComponent(output, actionBar);
|
||||
|
||||
return buffer.toByteArray();
|
||||
|
||||
+3
-2
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@@ -28,7 +29,7 @@ import java.io.IOException;
|
||||
|
||||
public class ClientboundSetSubtitleTextPacket extends PacketOut {
|
||||
|
||||
private Component subTitle;
|
||||
private final Component subTitle;
|
||||
|
||||
public ClientboundSetSubtitleTextPacket(Component subTitle) {
|
||||
this.subTitle = subTitle;
|
||||
@@ -43,7 +44,7 @@ public class ClientboundSetSubtitleTextPacket extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeComponent(output, subTitle);
|
||||
|
||||
return buffer.toByteArray();
|
||||
|
||||
+3
-2
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@@ -28,7 +29,7 @@ import java.io.IOException;
|
||||
|
||||
public class ClientboundSetTitleTextPacket extends PacketOut {
|
||||
|
||||
private Component titleText;
|
||||
private final Component titleText;
|
||||
|
||||
public ClientboundSetTitleTextPacket(Component titleText) {
|
||||
this.titleText = titleText;
|
||||
@@ -43,7 +44,7 @@ public class ClientboundSetTitleTextPacket extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeComponent(output, titleText);
|
||||
|
||||
return buffer.toByteArray();
|
||||
|
||||
+6
-4
@@ -19,15 +19,17 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ClientboundSetTitlesAnimationPacket extends PacketOut {
|
||||
|
||||
private int fadeIn;
|
||||
private int stay;
|
||||
private int fadeOut;
|
||||
private final int fadeIn;
|
||||
private final int stay;
|
||||
private final int fadeOut;
|
||||
|
||||
public ClientboundSetTitlesAnimationPacket(int fadeIn, int stay, int fadeOut) {
|
||||
this.fadeIn = fadeIn;
|
||||
@@ -52,7 +54,7 @@ public class ClientboundSetTitlesAnimationPacket extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
output.writeInt(fadeIn);
|
||||
output.writeInt(stay);
|
||||
|
||||
+4
-3
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@@ -28,8 +29,8 @@ import java.io.IOException;
|
||||
|
||||
public class ClientboundSystemChatPacket extends PacketOut {
|
||||
|
||||
private Component message;
|
||||
private boolean overlay;
|
||||
private final Component message;
|
||||
private final boolean overlay;
|
||||
|
||||
public ClientboundSystemChatPacket(Component message, boolean overlay) {
|
||||
this.message = message;
|
||||
@@ -49,7 +50,7 @@ public class ClientboundSystemChatPacket extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeComponent(output, message);
|
||||
output.writeBoolean(overlay);
|
||||
|
||||
|
||||
@@ -20,112 +20,12 @@
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.network.ClientConnection;
|
||||
|
||||
import java.util.Map;
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
public abstract class Packet {
|
||||
|
||||
private static Map<Integer, Class<? extends PacketIn>> handshakeIn;
|
||||
|
||||
private static Map<Integer, Class<? extends PacketIn>> statusIn;
|
||||
private static Map<Class<? extends PacketOut>, Integer> statusOut;
|
||||
|
||||
private static Map<Integer, Class<? extends PacketIn>> loginIn;
|
||||
private static Map<Class<? extends PacketOut>, Integer> loginOut;
|
||||
|
||||
private static Map<Integer, Class<? extends PacketIn>> configurationIn;
|
||||
private static Map<Class<? extends PacketOut>, Integer> configurationOut;
|
||||
|
||||
private static Map<Integer, Class<? extends PacketIn>> playIn;
|
||||
private static Map<Class<? extends PacketOut>, Integer> playOut;
|
||||
|
||||
public static Map<Integer, Class<? extends PacketIn>> getHandshakeIn() {
|
||||
return handshakeIn;
|
||||
}
|
||||
|
||||
public static void setHandshakeIn(Map<Integer, Class<? extends PacketIn>> handshakeIn) {
|
||||
Packet.handshakeIn = handshakeIn;
|
||||
}
|
||||
|
||||
public static Map<Integer, Class<? extends PacketIn>> getStatusIn() {
|
||||
return statusIn;
|
||||
}
|
||||
|
||||
public static void setStatusIn(Map<Integer, Class<? extends PacketIn>> statusIn) {
|
||||
Packet.statusIn = statusIn;
|
||||
}
|
||||
|
||||
public static Map<Class<? extends PacketOut>, Integer> getStatusOut() {
|
||||
return statusOut;
|
||||
}
|
||||
|
||||
public static void setStatusOut(Map<Class<? extends PacketOut>, Integer> statusOut) {
|
||||
Packet.statusOut = statusOut;
|
||||
}
|
||||
|
||||
public static Map<Integer, Class<? extends PacketIn>> getLoginIn() {
|
||||
return loginIn;
|
||||
}
|
||||
|
||||
public static void setLoginIn(Map<Integer, Class<? extends PacketIn>> loginIn) {
|
||||
Packet.loginIn = loginIn;
|
||||
}
|
||||
|
||||
public static Map<Class<? extends PacketOut>, Integer> getLoginOut() {
|
||||
return loginOut;
|
||||
}
|
||||
|
||||
public static void setLoginOut(Map<Class<? extends PacketOut>, Integer> loginOut) {
|
||||
Packet.loginOut = loginOut;
|
||||
}
|
||||
|
||||
public static Map<Integer, Class<? extends PacketIn>> getConfigurationIn() {
|
||||
return configurationIn;
|
||||
}
|
||||
|
||||
public static void setConfigurationIn(Map<Integer, Class<? extends PacketIn>> configurationIn) {
|
||||
Packet.configurationIn = configurationIn;
|
||||
}
|
||||
|
||||
public static Map<Class<? extends PacketOut>, Integer> getConfigurationOut() {
|
||||
return configurationOut;
|
||||
}
|
||||
|
||||
public static void setConfigurationOut(Map<Class<? extends PacketOut>, Integer> configurationOut) {
|
||||
Packet.configurationOut = configurationOut;
|
||||
}
|
||||
|
||||
public static Map<Integer, Class<? extends PacketIn>> getPlayIn() {
|
||||
return playIn;
|
||||
}
|
||||
|
||||
public static void setPlayIn(Map<Integer, Class<? extends PacketIn>> playIn) {
|
||||
Packet.playIn = playIn;
|
||||
}
|
||||
|
||||
public static Map<Class<? extends PacketOut>, Integer> getPlayOut() {
|
||||
return playOut;
|
||||
}
|
||||
|
||||
public static void setPlayOut(Map<Class<? extends PacketOut>, Integer> playOut) {
|
||||
Packet.playOut = playOut;
|
||||
}
|
||||
|
||||
public ClientConnection.ClientState getPacketState() {
|
||||
Class<? extends Packet> type = getClass();
|
||||
if (handshakeIn.containsValue(type)) {
|
||||
return ClientConnection.ClientState.HANDSHAKE;
|
||||
} else if (statusIn.containsValue(type) || statusOut.containsKey(type)) {
|
||||
return ClientConnection.ClientState.STATUS;
|
||||
} else if (loginIn.containsValue(type) || loginOut.containsKey(type)) {
|
||||
return ClientConnection.ClientState.LOGIN;
|
||||
} else if (configurationIn.containsValue(type) || configurationOut.containsKey(type)) {
|
||||
return ClientConnection.ClientState.CONFIGURATION;
|
||||
} else if (playIn.containsValue(type) || playOut.containsKey(type)) {
|
||||
return ClientConnection.ClientState.PLAY;
|
||||
} else {
|
||||
throw new IllegalStateException("This packet of class " + type + " is not registered!");
|
||||
}
|
||||
return PacketRegistry.getPacketInfo(getClass()).getNetworkPhase().getClientState();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,10 +54,10 @@ public class PacketHandshakingIn extends PacketIn {
|
||||
|
||||
//==============================
|
||||
|
||||
private int protocolVersion;
|
||||
private String serverAddress;
|
||||
private int serverPort;
|
||||
private HandshakeType handshakeType;
|
||||
private final int protocolVersion;
|
||||
private final String serverAddress;
|
||||
private final int serverPort;
|
||||
private final HandshakeType handshakeType;
|
||||
|
||||
public PacketHandshakingIn(int protocolVersion, String serverAddress, int serverPort, HandshakeType handshakeType) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
|
||||
+3
-3
@@ -27,9 +27,9 @@ import java.util.Optional;
|
||||
|
||||
public class PacketLoginInPluginMessaging extends PacketIn {
|
||||
|
||||
private int messageId;
|
||||
private boolean successful;
|
||||
private Optional<byte[]> data;
|
||||
private final int messageId;
|
||||
private final boolean successful;
|
||||
private final Optional<byte[]> data;
|
||||
|
||||
public PacketLoginInPluginMessaging(int messageId, boolean successful, byte[] data) {
|
||||
this.messageId = messageId;
|
||||
|
||||
+3
-2
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@@ -28,7 +29,7 @@ import java.io.IOException;
|
||||
|
||||
public class PacketLoginOutDisconnect extends PacketOut {
|
||||
|
||||
private Component reason;
|
||||
private final Component reason;
|
||||
|
||||
public PacketLoginOutDisconnect(Component reason) {
|
||||
this.reason = reason;
|
||||
@@ -43,7 +44,7 @@ public class PacketLoginOutDisconnect extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getLoginOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeComponent(output, reason);
|
||||
|
||||
return buffer.toByteArray();
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -56,7 +57,7 @@ public class PacketLoginOutLoginSuccess extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getLoginOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeUUID(output, uuid);
|
||||
DataTypeIO.writeString(output, username, StandardCharsets.UTF_8);
|
||||
DataTypeIO.writeVarInt(output, 0);
|
||||
|
||||
+5
-4
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.key.Key;
|
||||
|
||||
@@ -29,9 +30,9 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class PacketLoginOutPluginMessaging extends PacketOut {
|
||||
|
||||
private int messageId;
|
||||
private Key channel;
|
||||
private byte[] data;
|
||||
private final int messageId;
|
||||
private final Key channel;
|
||||
private final byte[] data;
|
||||
|
||||
public PacketLoginOutPluginMessaging(int messageId, Key channel) {
|
||||
this(messageId, channel, null);
|
||||
@@ -60,7 +61,7 @@ public class PacketLoginOutPluginMessaging extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getLoginOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeVarInt(output, messageId);
|
||||
DataTypeIO.writeString(output, channel.toString(), StandardCharsets.UTF_8);
|
||||
if (data != null) {
|
||||
|
||||
@@ -40,10 +40,10 @@ public class PacketPlayInBlockDig extends PacketIn {
|
||||
|
||||
}
|
||||
|
||||
private PlayerDigType action;
|
||||
private BlockPosition pos;
|
||||
private BlockFace direction;
|
||||
private int sequence;
|
||||
private final PlayerDigType action;
|
||||
private final BlockPosition pos;
|
||||
private final BlockFace direction;
|
||||
private final int sequence;
|
||||
|
||||
public PacketPlayInBlockDig(PlayerDigType action, BlockPosition pos, BlockFace direction, int sequence) {
|
||||
this.action = action;
|
||||
|
||||
@@ -27,8 +27,8 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayInBlockPlace extends PacketIn {
|
||||
|
||||
private EquipmentSlot hand;
|
||||
private int sequence;
|
||||
private final EquipmentSlot hand;
|
||||
private final int sequence;
|
||||
|
||||
public PacketPlayInBlockPlace(EquipmentSlot hand, int sequence) {
|
||||
this.hand = hand;
|
||||
|
||||
@@ -30,11 +30,11 @@ import java.time.Instant;
|
||||
|
||||
public class PacketPlayInChat extends PacketIn {
|
||||
|
||||
private String message;
|
||||
private Instant time;
|
||||
private long salt;
|
||||
private MessageSignature signature;
|
||||
private LastSeenMessages.b lastSeenMessages;
|
||||
private final String message;
|
||||
private final Instant time;
|
||||
private final long salt;
|
||||
private final MessageSignature signature;
|
||||
private final LastSeenMessages.b lastSeenMessages;
|
||||
|
||||
public PacketPlayInChat(String message, Instant time, long salt, MessageSignature signature, LastSeenMessages.b lastSeenMessages) {
|
||||
this.message = message;
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayInCloseWindow extends PacketIn {
|
||||
|
||||
private int containerId;
|
||||
private final int containerId;
|
||||
|
||||
public PacketPlayInCloseWindow(int containerId) {
|
||||
this.containerId = containerId;
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayInHeldItemChange extends PacketIn {
|
||||
|
||||
private short slot;
|
||||
private final short slot;
|
||||
|
||||
public PacketPlayInHeldItemChange(short slot) {
|
||||
this.slot = slot;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class PacketPlayInItemName extends PacketIn {
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
public PacketPlayInItemName(String name) {
|
||||
this.name = name;
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayInKeepAlive extends PacketIn {
|
||||
|
||||
private long payload;
|
||||
private final long payload;
|
||||
|
||||
public PacketPlayInKeepAlive(long payload) {
|
||||
this.payload = payload;
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayInPickItem extends PacketIn {
|
||||
|
||||
private int slot;
|
||||
private final int slot;
|
||||
|
||||
public PacketPlayInPickItem(int slot) {
|
||||
this.slot = slot;
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class PacketPlayInPluginMessaging extends PacketIn {
|
||||
|
||||
private String channel;
|
||||
private byte[] data;
|
||||
private final String channel;
|
||||
private final byte[] data;
|
||||
|
||||
public PacketPlayInPluginMessaging(String channel, byte[] data) {
|
||||
this.channel = channel;
|
||||
|
||||
@@ -24,10 +24,10 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayInPosition extends PacketIn {
|
||||
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private boolean onGround;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final boolean onGround;
|
||||
|
||||
public PacketPlayInPosition(double x, double y, double z, boolean onGround) {
|
||||
this.x = x;
|
||||
|
||||
+6
-6
@@ -24,12 +24,12 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayInPositionAndLook extends PacketIn {
|
||||
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
private boolean onGround;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final float yaw;
|
||||
private final float pitch;
|
||||
private final boolean onGround;
|
||||
|
||||
public PacketPlayInPositionAndLook(double x, double y, double z, float yaw, float pitch, boolean onGround) {
|
||||
this.x = x;
|
||||
|
||||
@@ -24,9 +24,9 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayInRotation extends PacketIn {
|
||||
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
private boolean onGround;
|
||||
private final float yaw;
|
||||
private final float pitch;
|
||||
private final boolean onGround;
|
||||
|
||||
public PacketPlayInRotation(float yaw, float pitch, boolean onGround) {
|
||||
this.yaw = yaw;
|
||||
|
||||
@@ -27,8 +27,8 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class PacketPlayInTabComplete extends PacketIn {
|
||||
|
||||
private int id;
|
||||
private String text;
|
||||
private final int id;
|
||||
private final String text;
|
||||
|
||||
public PacketPlayInTabComplete(int id, String text) {
|
||||
this.id = id;
|
||||
|
||||
@@ -28,9 +28,9 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayInUseItem extends PacketIn {
|
||||
|
||||
private EquipmentSlot hand;
|
||||
private MovingObjectPositionBlock blockHit;
|
||||
private int sequence;
|
||||
private final EquipmentSlot hand;
|
||||
private final MovingObjectPositionBlock blockHit;
|
||||
private final int sequence;
|
||||
|
||||
public PacketPlayInUseItem(EquipmentSlot hand, MovingObjectPositionBlock blockHit, int sequence) {
|
||||
this.hand = hand;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.bossbar.KeyedBossBar;
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
|
||||
@@ -52,8 +53,8 @@ public class PacketPlayOutBoss extends PacketOut {
|
||||
return i;
|
||||
}
|
||||
|
||||
private KeyedBossBar bossBar;
|
||||
private BossBarAction action;
|
||||
private final KeyedBossBar bossBar;
|
||||
private final BossBarAction action;
|
||||
|
||||
public PacketPlayOutBoss(KeyedBossBar bossBar, BossBarAction action) {
|
||||
this.bossBar = bossBar;
|
||||
@@ -73,7 +74,7 @@ public class PacketPlayOutBoss extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
DataTypeIO.writeUUID(output, bossBar.getUniqueId());
|
||||
DataTypeIO.writeVarInt(output, action.ordinal());
|
||||
|
||||
+4
-2
@@ -19,13 +19,15 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutCloseWindow extends PacketOut {
|
||||
|
||||
private int containerId;
|
||||
private final int containerId;
|
||||
|
||||
public PacketPlayOutCloseWindow(int containerId) {
|
||||
this.containerId = containerId;
|
||||
@@ -40,7 +42,7 @@ public class PacketPlayOutCloseWindow extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
output.writeByte(containerId);
|
||||
|
||||
|
||||
+4
-2
@@ -19,13 +19,15 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutDeclareCommands extends PacketOut {
|
||||
|
||||
private byte[] data;
|
||||
private final byte[] data;
|
||||
|
||||
public PacketPlayOutDeclareCommands(byte[] data) {
|
||||
this.data = data;
|
||||
@@ -40,7 +42,7 @@ public class PacketPlayOutDeclareCommands extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
output.write(data);
|
||||
|
||||
return buffer.toByteArray();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@@ -28,7 +29,7 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutDisconnect extends PacketOut {
|
||||
|
||||
private Component reason;
|
||||
private final Component reason;
|
||||
|
||||
public PacketPlayOutDisconnect(Component reason) {
|
||||
this.reason = reason;
|
||||
@@ -43,7 +44,7 @@ public class PacketPlayOutDisconnect extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeComponent(output, reason);
|
||||
|
||||
return buffer.toByteArray();
|
||||
|
||||
+3
-2
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -27,7 +28,7 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutEntityDestroy extends PacketOut {
|
||||
|
||||
private int[] entityIds;
|
||||
private final int[] entityIds;
|
||||
|
||||
public PacketPlayOutEntityDestroy(int... entityIds) {
|
||||
this.entityIds = entityIds;
|
||||
@@ -42,7 +43,7 @@ public class PacketPlayOutEntityDestroy extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeVarInt(output, entityIds.length);
|
||||
for (int entityId : entityIds) {
|
||||
DataTypeIO.writeVarInt(output, entityId);
|
||||
|
||||
+5
-4
@@ -23,6 +23,7 @@ import com.loohp.limbo.entity.DataWatcher.WatchableObject;
|
||||
import com.loohp.limbo.entity.DataWatcher.WatchableObjectType;
|
||||
import com.loohp.limbo.entity.Entity;
|
||||
import com.loohp.limbo.entity.Pose;
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import com.loohp.limbo.utils.Rotation3f;
|
||||
import com.loohp.limbo.world.BlockPosition;
|
||||
@@ -45,9 +46,9 @@ public class PacketPlayOutEntityMetadata extends PacketOut {
|
||||
|
||||
public static final int END_OFF_METADATA = 0xff;
|
||||
|
||||
private Entity entity;
|
||||
public boolean allFields;
|
||||
public Field[] fields;
|
||||
private final Entity entity;
|
||||
public final boolean allFields;
|
||||
public final Field[] fields;
|
||||
|
||||
public PacketPlayOutEntityMetadata(Entity entity, boolean allFields, Field... fields) {
|
||||
this.entity = entity;
|
||||
@@ -68,7 +69,7 @@ public class PacketPlayOutEntityMetadata extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeVarInt(output, entity.getEntityId());
|
||||
Collection<WatchableObject> watches;
|
||||
if (allFields) {
|
||||
|
||||
+5
-3
@@ -19,6 +19,8 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -52,8 +54,8 @@ public class PacketPlayOutGameStateChange extends PacketOut {
|
||||
}
|
||||
}
|
||||
|
||||
private GameStateChangeEvent event;
|
||||
private float value;
|
||||
private final GameStateChangeEvent event;
|
||||
private final float value;
|
||||
|
||||
public PacketPlayOutGameStateChange(GameStateChangeEvent event, float value) {
|
||||
this.event = event;
|
||||
@@ -72,7 +74,7 @@ public class PacketPlayOutGameStateChange extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
output.writeByte(event.getId());
|
||||
output.writeFloat(value);
|
||||
|
||||
|
||||
+3
-1
@@ -19,6 +19,8 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -40,7 +42,7 @@ public class PacketPlayOutHeldItemChange extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
output.writeByte(slot);
|
||||
|
||||
return buffer.toByteArray();
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutKeepAlive extends PacketOut {
|
||||
|
||||
private long payload;
|
||||
private final long payload;
|
||||
|
||||
public PacketPlayOutKeepAlive(long payload) {
|
||||
this.payload = payload;
|
||||
@@ -40,7 +42,7 @@ public class PacketPlayOutKeepAlive extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
output.writeLong(payload);
|
||||
|
||||
return buffer.toByteArray();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.registry.RegistryCustom;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import com.loohp.limbo.utils.GameMode;
|
||||
@@ -145,7 +146,7 @@ public class PacketPlayOutLogin extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
output.writeInt(entityId);
|
||||
output.writeBoolean(isHardcore);
|
||||
DataTypeIO.writeVarInt(output, worlds.size());
|
||||
|
||||
+10
-9
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.sounds.SoundEffect;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
@@ -31,14 +32,14 @@ import java.util.Optional;
|
||||
|
||||
public class PacketPlayOutNamedSoundEffect extends PacketOut {
|
||||
|
||||
private SoundEffect sound;
|
||||
private Sound.Source source;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private float volume;
|
||||
private float pitch;
|
||||
private long seed;
|
||||
private final SoundEffect sound;
|
||||
private final Sound.Source source;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
private final float volume;
|
||||
private final float pitch;
|
||||
private final long seed;
|
||||
|
||||
public PacketPlayOutNamedSoundEffect(SoundEffect sound, Sound.Source source, double x, double y, double z, float volume, float pitch, long seed) {
|
||||
this.sound = sound;
|
||||
@@ -88,7 +89,7 @@ public class PacketPlayOutNamedSoundEffect extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
DataTypeIO.writeVarInt(output, 0);
|
||||
DataTypeIO.writeString(output, sound.getSound().toString(), StandardCharsets.UTF_8);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.BuiltInRegistries;
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -30,9 +31,9 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutOpenWindow extends PacketOut {
|
||||
|
||||
private int containerId;
|
||||
private Key type;
|
||||
private Component title;
|
||||
private final int containerId;
|
||||
private final Key type;
|
||||
private final Component title;
|
||||
|
||||
public PacketPlayOutOpenWindow(int containerId, Key type, Component title) {
|
||||
this.containerId = containerId;
|
||||
@@ -57,7 +58,7 @@ public class PacketPlayOutOpenWindow extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
DataTypeIO.writeVarInt(output, containerId);
|
||||
DataTypeIO.writeVarInt(output, BuiltInRegistries.MENU_REGISTRY.getId(type));
|
||||
|
||||
+6
-4
@@ -19,6 +19,8 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -42,9 +44,9 @@ public class PacketPlayOutPlayerAbilities extends PacketOut {
|
||||
}
|
||||
}
|
||||
|
||||
private PlayerAbilityFlags[] flags;
|
||||
private float flySpeed;
|
||||
private float fieldOfField;
|
||||
private final PlayerAbilityFlags[] flags;
|
||||
private final float flySpeed;
|
||||
private final float fieldOfField;
|
||||
|
||||
public PacketPlayOutPlayerAbilities(float flySpeed, float fieldOfField, PlayerAbilityFlags... flags) {
|
||||
this.flags = flags;
|
||||
@@ -69,7 +71,7 @@ public class PacketPlayOutPlayerAbilities extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
byte value = 0;
|
||||
for (PlayerAbilityFlags flag : flags) {
|
||||
value = (byte) (value | flag.getValue());
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo.PlayerInfoData.PlayerInfoDataAddPlayer;
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import com.loohp.limbo.utils.GameMode;
|
||||
|
||||
@@ -42,9 +43,9 @@ public class PacketPlayOutPlayerInfo extends PacketOut {
|
||||
UPDATE_DISPLAY_NAME;
|
||||
}
|
||||
|
||||
private EnumSet<PlayerInfoAction> actions;
|
||||
private UUID uuid;
|
||||
private PlayerInfoData data;
|
||||
private final EnumSet<PlayerInfoAction> actions;
|
||||
private final UUID uuid;
|
||||
private final PlayerInfoData data;
|
||||
|
||||
public PacketPlayOutPlayerInfo(EnumSet<PlayerInfoAction> actions, UUID uuid, PlayerInfoData data) {
|
||||
this.actions = actions;
|
||||
@@ -69,7 +70,7 @@ public class PacketPlayOutPlayerInfo extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
DataTypeIO.writeEnumSet(output, actions, PlayerInfoAction.class);
|
||||
DataTypeIO.writeVarInt(output, 1);
|
||||
|
||||
+4
-3
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@@ -28,8 +29,8 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutPlayerListHeaderFooter extends PacketOut{
|
||||
|
||||
private Component header;
|
||||
private Component footer;
|
||||
private final Component header;
|
||||
private final Component footer;
|
||||
|
||||
public PacketPlayOutPlayerListHeaderFooter(Component header, Component footer) {
|
||||
this.header = header;
|
||||
@@ -50,7 +51,7 @@ public class PacketPlayOutPlayerListHeaderFooter extends PacketOut{
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeComponent(output, header);
|
||||
DataTypeIO.writeComponent(output, footer);
|
||||
return buffer.toByteArray();
|
||||
|
||||
+4
-3
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -28,8 +29,8 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class PacketPlayOutPluginMessaging extends PacketOut {
|
||||
|
||||
private String channel;
|
||||
private byte[] data;
|
||||
private final String channel;
|
||||
private final byte[] data;
|
||||
|
||||
public PacketPlayOutPluginMessaging(String channel, byte[] data) {
|
||||
this.channel = channel;
|
||||
@@ -49,7 +50,7 @@ public class PacketPlayOutPluginMessaging extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeString(output, channel, StandardCharsets.UTF_8);
|
||||
output.write(data);
|
||||
|
||||
|
||||
+9
-8
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -48,13 +49,13 @@ public class PacketPlayOutPositionAndLook extends PacketOut {
|
||||
}
|
||||
}
|
||||
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
private Set<PlayerTeleportFlags> flags;
|
||||
private int teleportId;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final float yaw;
|
||||
private final float pitch;
|
||||
private final Set<PlayerTeleportFlags> flags;
|
||||
private final int teleportId;
|
||||
|
||||
public PacketPlayOutPositionAndLook(double x, double y, double z, float yaw, float pitch, int teleportId, PlayerTeleportFlags... flags) {
|
||||
this.x = x;
|
||||
@@ -99,7 +100,7 @@ public class PacketPlayOutPositionAndLook extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
output.writeDouble(x);
|
||||
output.writeDouble(y);
|
||||
output.writeDouble(z);
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.registry.RegistryCustom;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import com.loohp.limbo.utils.GameMode;
|
||||
import com.loohp.limbo.world.Environment;
|
||||
import com.loohp.limbo.world.World;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
import net.querz.nbt.tag.ListTag;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -35,13 +34,13 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class PacketPlayOutRespawn extends PacketOut {
|
||||
|
||||
private Environment dimension;
|
||||
private World world;
|
||||
private long hashedSeed;
|
||||
private GameMode gamemode;
|
||||
private boolean isDebug;
|
||||
private boolean isFlat;
|
||||
private boolean copyMetaData;
|
||||
private final Environment dimension;
|
||||
private final World world;
|
||||
private final long hashedSeed;
|
||||
private final GameMode gamemode;
|
||||
private final boolean isDebug;
|
||||
private final boolean isFlat;
|
||||
private final boolean copyMetaData;
|
||||
|
||||
public PacketPlayOutRespawn(World world, long hashedSeed, GameMode gamemode, boolean isDebug, boolean isFlat, boolean copyMetaData) {
|
||||
this.dimension = world.getEnvironment();
|
||||
@@ -86,7 +85,7 @@ public class PacketPlayOutRespawn extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
DataTypeIO.writeVarInt(output, RegistryCustom.DIMENSION_TYPE.indexOf(world.getEnvironment().getKey()));
|
||||
DataTypeIO.writeString(output, Key.key(world.getName()).toString(), StandardCharsets.UTF_8);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.inventory.ItemStack;
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -61,7 +62,7 @@ public class PacketPlayOutSetSlot extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
output.writeByte(containerId);
|
||||
DataTypeIO.writeVarInt(output, stateId);
|
||||
|
||||
+15
-14
@@ -20,6 +20,7 @@
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.entity.EntityType;
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -29,19 +30,19 @@ import java.util.UUID;
|
||||
|
||||
public class PacketPlayOutSpawnEntity extends PacketOut {
|
||||
|
||||
private int entityId;
|
||||
private UUID uuid;
|
||||
private EntityType type;
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private float pitch;
|
||||
private float yaw;
|
||||
private float headYaw;
|
||||
private int data;
|
||||
private short velocityX;
|
||||
private short velocityY;
|
||||
private short velocityZ;
|
||||
private final int entityId;
|
||||
private final UUID uuid;
|
||||
private final EntityType type;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final float pitch;
|
||||
private final float yaw;
|
||||
private final float headYaw;
|
||||
private final int data;
|
||||
private final short velocityX;
|
||||
private final short velocityY;
|
||||
private final short velocityZ;
|
||||
|
||||
public PacketPlayOutSpawnEntity(int entityId, UUID uuid, EntityType type, double x, double y, double z, float pitch, float yaw, float headYaw, int data, short velocityX, short velocityY, short velocityZ) {
|
||||
this.entityId = entityId;
|
||||
@@ -116,7 +117,7 @@ public class PacketPlayOutSpawnEntity extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeVarInt(output, entityId);
|
||||
DataTypeIO.writeUUID(output, uuid);
|
||||
DataTypeIO.writeVarInt(output, type.getTypeId());
|
||||
|
||||
+4
-3
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import com.loohp.limbo.world.BlockPosition;
|
||||
|
||||
@@ -28,8 +29,8 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutSpawnPosition extends PacketOut {
|
||||
|
||||
private BlockPosition position;
|
||||
private float angle;
|
||||
private final BlockPosition position;
|
||||
private final float angle;
|
||||
|
||||
public PacketPlayOutSpawnPosition(BlockPosition position, float angle) {
|
||||
this.position = position;
|
||||
@@ -48,7 +49,7 @@ public class PacketPlayOutSpawnPosition extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeBlockPosition(output, position);
|
||||
output.writeFloat(angle);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
@@ -30,8 +31,8 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class PacketPlayOutStopSound extends PacketOut {
|
||||
|
||||
private Key sound;
|
||||
private Sound.Source source;
|
||||
private final Key sound;
|
||||
private final Sound.Source source;
|
||||
|
||||
public PacketPlayOutStopSound(Key sound, Sound.Source source) {
|
||||
this.sound = sound;
|
||||
@@ -51,7 +52,7 @@ public class PacketPlayOutStopSound extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
if (source != null) {
|
||||
if (sound != null) {
|
||||
|
||||
+6
-5
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@@ -30,10 +31,10 @@ import java.util.Optional;
|
||||
|
||||
public class PacketPlayOutTabComplete extends PacketOut {
|
||||
|
||||
private int id;
|
||||
private int start;
|
||||
private int length;
|
||||
private TabCompleteMatches[] matches;
|
||||
private final int id;
|
||||
private final int start;
|
||||
private final int length;
|
||||
private final TabCompleteMatches[] matches;
|
||||
|
||||
public PacketPlayOutTabComplete(int id, int start, int length, TabCompleteMatches... matches) {
|
||||
this.id = id;
|
||||
@@ -63,7 +64,7 @@ public class PacketPlayOutTabComplete extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeVarInt(output, id);
|
||||
DataTypeIO.writeVarInt(output, start);
|
||||
DataTypeIO.writeVarInt(output, length);
|
||||
|
||||
+5
-3
@@ -19,14 +19,16 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutUnloadChunk extends PacketOut {
|
||||
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
private final int chunkX;
|
||||
private final int chunkZ;
|
||||
|
||||
public PacketPlayOutUnloadChunk(int chunkX, int chunkZ) {
|
||||
this.chunkX = chunkX;
|
||||
@@ -46,7 +48,7 @@ public class PacketPlayOutUnloadChunk extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
output.writeInt(chunkX);
|
||||
output.writeInt(chunkZ);
|
||||
|
||||
|
||||
+4
-3
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -27,8 +28,8 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutUpdateViewPosition extends PacketOut {
|
||||
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
private final int chunkX;
|
||||
private final int chunkZ;
|
||||
|
||||
public PacketPlayOutUpdateViewPosition(int chunkX, int chunkZ) {
|
||||
this.chunkX = chunkX;
|
||||
@@ -48,7 +49,7 @@ public class PacketPlayOutUpdateViewPosition extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeVarInt(output, chunkX);
|
||||
DataTypeIO.writeVarInt(output, chunkZ);
|
||||
|
||||
|
||||
@@ -19,15 +19,17 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutWindowData extends PacketOut {
|
||||
|
||||
private int containerId;
|
||||
private int id;
|
||||
private int value;
|
||||
private final int containerId;
|
||||
private final int id;
|
||||
private final int value;
|
||||
|
||||
public PacketPlayOutWindowData(int containerId, int id, int value) {
|
||||
this.containerId = containerId;
|
||||
@@ -52,7 +54,7 @@ public class PacketPlayOutWindowData extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
output.writeByte(containerId);
|
||||
output.writeShort(id);
|
||||
|
||||
+6
-5
@@ -20,6 +20,7 @@
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.inventory.ItemStack;
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -29,10 +30,10 @@ import java.util.List;
|
||||
|
||||
public class PacketPlayOutWindowItems extends PacketOut {
|
||||
|
||||
private int containerId;
|
||||
private int stateId;
|
||||
private List<ItemStack> items;
|
||||
private ItemStack carriedItem;
|
||||
private final int containerId;
|
||||
private final int stateId;
|
||||
private final List<ItemStack> items;
|
||||
private final ItemStack carriedItem;
|
||||
|
||||
public PacketPlayOutWindowItems(int containerId, int stateId, List<ItemStack> items, ItemStack carriedItem) {
|
||||
this.containerId = containerId;
|
||||
@@ -62,7 +63,7 @@ public class PacketPlayOutWindowItems extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
|
||||
output.writeByte(containerId);
|
||||
DataTypeIO.writeVarInt(output, stateId);
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.io.IOException;
|
||||
|
||||
public class PacketStatusInPing extends PacketIn {
|
||||
|
||||
private long payload;
|
||||
private final long payload;
|
||||
|
||||
public PacketStatusInPing(long payload) {
|
||||
this.payload = payload;
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.io.DataInputStream;
|
||||
public class PacketStatusInRequest extends PacketIn {
|
||||
|
||||
public PacketStatusInRequest() {
|
||||
|
||||
}
|
||||
|
||||
public PacketStatusInRequest(DataInputStream in) {
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketStatusOutPong extends PacketOut {
|
||||
|
||||
private long payload;
|
||||
private final long payload;
|
||||
|
||||
public PacketStatusOutPong(long payload) {
|
||||
this.payload = payload;
|
||||
@@ -40,7 +42,7 @@ public class PacketStatusOutPong extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getStatusOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
output.writeLong(payload);
|
||||
|
||||
return buffer.toByteArray();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.registry.PacketRegistry;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -28,7 +29,7 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class PacketStatusOutResponse extends PacketOut {
|
||||
|
||||
private String json;
|
||||
private final String json;
|
||||
|
||||
public PacketStatusOutResponse(String json) {
|
||||
this.json = json;
|
||||
@@ -43,7 +44,7 @@ public class PacketStatusOutResponse extends PacketOut {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getStatusOut().get(getClass()));
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeString(output, json, StandardCharsets.UTF_8);
|
||||
|
||||
return buffer.toByteArray();
|
||||
|
||||
Reference in New Issue
Block a user