Avoid extending internal NMS classes

This commit is contained in:
filoghost 2023-03-19 16:44:40 +01:00
parent 70779348af
commit 27ebb9d2d8
111 changed files with 824 additions and 334 deletions

View File

@ -62,7 +62,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
// Entries are deserialized and saved into a field which is not used during the re-serialization, set as empty
packetByteBuffer.writeDataWatcherEntriesEnd();
Packet<?> rawPacket = writeData(new PacketPlayOutSpawnEntityLiving(), packetByteBuffer);
Packet<?> rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntityLiving());
return new Builder(rawPacket, PacketByteBuffer.get());
}

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = writeData(new PacketPlayOutEntityMetadata(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityMetadata());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = writeData(new PacketPlayOutMount(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutMount());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntity(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntity());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = writeData(new PacketPlayOutEntityTeleport(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityTeleport());
}
@Override

View File

@ -6,25 +6,57 @@
package me.filoghost.holographicdisplays.nms.v1_10_R1;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_10_R1.Packet;
import net.minecraft.server.v1_10_R1.PacketDataSerializer;
import java.io.IOException;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
int readableBytes() {
return serializer.readableBytes();
}
void readBytes(byte[] bytes) {
serializer.readBytes(bytes);
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -33,17 +65,31 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
void clear() {
serializer.clear();
}
<T extends Packet<?>> T writeDataTo(T packet) {
try {
packet.a(serializer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -10,8 +10,6 @@ import net.minecraft.server.v1_10_R1.Packet;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.io.IOException;
abstract class VersionNMSPacket implements PacketGroup {
@Override
@ -21,14 +19,4 @@ abstract class VersionNMSPacket implements PacketGroup {
abstract Packet<?> getRawPacket();
protected static <T extends Packet<?>> T writeData(T packet, PacketByteBuffer packetByteBuffer) {
try {
packet.a(packetByteBuffer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -62,7 +62,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
// Entries are deserialized and saved into a field which is not used during the re-serialization, set as empty
packetByteBuffer.writeDataWatcherEntriesEnd();
Packet<?> rawPacket = writeData(new PacketPlayOutSpawnEntityLiving(), packetByteBuffer);
Packet<?> rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntityLiving());
return new Builder(rawPacket, PacketByteBuffer.get());
}

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = writeData(new PacketPlayOutEntityMetadata(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityMetadata());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = writeData(new PacketPlayOutMount(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutMount());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntity(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntity());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = writeData(new PacketPlayOutEntityTeleport(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityTeleport());
}
@Override

View File

@ -6,25 +6,57 @@
package me.filoghost.holographicdisplays.nms.v1_11_R1;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_11_R1.Packet;
import net.minecraft.server.v1_11_R1.PacketDataSerializer;
import java.io.IOException;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
int readableBytes() {
return serializer.readableBytes();
}
void readBytes(byte[] bytes) {
serializer.readBytes(bytes);
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -33,17 +65,31 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
void clear() {
serializer.clear();
}
<T extends Packet<?>> T writeDataTo(T packet) {
try {
packet.a(serializer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -10,8 +10,6 @@ import net.minecraft.server.v1_11_R1.Packet;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.io.IOException;
abstract class VersionNMSPacket implements PacketGroup {
@Override
@ -21,14 +19,4 @@ abstract class VersionNMSPacket implements PacketGroup {
abstract Packet<?> getRawPacket();
protected static <T extends Packet<?>> T writeData(T packet, PacketByteBuffer packetByteBuffer) {
try {
packet.a(packetByteBuffer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -62,7 +62,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
// Entries are deserialized and saved into a field which is not used during the re-serialization, set as empty
packetByteBuffer.writeDataWatcherEntriesEnd();
Packet<?> rawPacket = writeData(new PacketPlayOutSpawnEntityLiving(), packetByteBuffer);
Packet<?> rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntityLiving());
return new Builder(rawPacket, PacketByteBuffer.get());
}

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = writeData(new PacketPlayOutEntityMetadata(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityMetadata());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = writeData(new PacketPlayOutMount(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutMount());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntity(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntity());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = writeData(new PacketPlayOutEntityTeleport(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityTeleport());
}
@Override

View File

@ -6,25 +6,57 @@
package me.filoghost.holographicdisplays.nms.v1_12_R1;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_12_R1.Packet;
import net.minecraft.server.v1_12_R1.PacketDataSerializer;
import java.io.IOException;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
int readableBytes() {
return serializer.readableBytes();
}
void readBytes(byte[] bytes) {
serializer.readBytes(bytes);
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -33,17 +65,31 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
void clear() {
serializer.clear();
}
<T extends Packet<?>> T writeDataTo(T packet) {
try {
packet.a(serializer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -10,8 +10,6 @@ import net.minecraft.server.v1_12_R1.Packet;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.io.IOException;
abstract class VersionNMSPacket implements PacketGroup {
@Override
@ -21,14 +19,4 @@ abstract class VersionNMSPacket implements PacketGroup {
abstract Packet<?> getRawPacket();
protected static <T extends Packet<?>> T writeData(T packet, PacketByteBuffer packetByteBuffer) {
try {
packet.a(packetByteBuffer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -62,7 +62,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
// Entries are deserialized and saved into a field which is not used during the re-serialization, set as empty
packetByteBuffer.writeDataWatcherEntriesEnd();
Packet<?> rawPacket = writeData(new PacketPlayOutSpawnEntityLiving(), packetByteBuffer);
Packet<?> rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntityLiving());
return new Builder(rawPacket, PacketByteBuffer.get());
}

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = writeData(new PacketPlayOutEntityMetadata(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityMetadata());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = writeData(new PacketPlayOutMount(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutMount());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntity(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntity());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = writeData(new PacketPlayOutEntityTeleport(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityTeleport());
}
@Override

View File

@ -6,25 +6,57 @@
package me.filoghost.holographicdisplays.nms.v1_13_R2;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_13_R2.Packet;
import net.minecraft.server.v1_13_R2.PacketDataSerializer;
import java.io.IOException;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
int readableBytes() {
return serializer.readableBytes();
}
void readBytes(byte[] bytes) {
serializer.readBytes(bytes);
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -33,17 +65,31 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
void clear() {
serializer.clear();
}
<T extends Packet<?>> T writeDataTo(T packet) {
try {
packet.a(serializer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -10,8 +10,6 @@ import net.minecraft.server.v1_13_R2.Packet;
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.io.IOException;
abstract class VersionNMSPacket implements PacketGroup {
@Override
@ -21,14 +19,4 @@ abstract class VersionNMSPacket implements PacketGroup {
abstract Packet<?> getRawPacket();
protected static <T extends Packet<?>> T writeData(T packet, PacketByteBuffer packetByteBuffer) {
try {
packet.a(packetByteBuffer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -62,7 +62,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
// Entries are deserialized and saved into a field which is not used during the re-serialization, set as empty
packetByteBuffer.writeDataWatcherEntriesEnd();
Packet<?> rawPacket = writeData(new PacketPlayOutSpawnEntityLiving(), packetByteBuffer);
Packet<?> rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntityLiving());
return new Builder(rawPacket, PacketByteBuffer.get());
}

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = writeData(new PacketPlayOutEntityMetadata(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityMetadata());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = writeData(new PacketPlayOutMount(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutMount());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntity(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntity());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = writeData(new PacketPlayOutEntityTeleport(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityTeleport());
}
@Override

View File

@ -6,25 +6,57 @@
package me.filoghost.holographicdisplays.nms.v1_14_R1;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_14_R1.Packet;
import net.minecraft.server.v1_14_R1.PacketDataSerializer;
import java.io.IOException;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
int readableBytes() {
return serializer.readableBytes();
}
void readBytes(byte[] bytes) {
serializer.readBytes(bytes);
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -33,17 +65,31 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
void clear() {
serializer.clear();
}
<T extends Packet<?>> T writeDataTo(T packet) {
try {
packet.a(serializer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -10,8 +10,6 @@ import net.minecraft.server.v1_14_R1.Packet;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.io.IOException;
abstract class VersionNMSPacket implements PacketGroup {
@Override
@ -21,14 +19,4 @@ abstract class VersionNMSPacket implements PacketGroup {
abstract Packet<?> getRawPacket();
protected static <T extends Packet<?>> T writeData(T packet, PacketByteBuffer packetByteBuffer) {
try {
packet.a(packetByteBuffer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -38,7 +38,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntityLiving(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntityLiving());
}
@Override

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = writeData(new PacketPlayOutEntityMetadata(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityMetadata());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = writeData(new PacketPlayOutMount(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutMount());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntity(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntity());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = writeData(new PacketPlayOutEntityTeleport(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityTeleport());
}
@Override

View File

@ -6,25 +6,49 @@
package me.filoghost.holographicdisplays.nms.v1_15_R1;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_15_R1.Packet;
import net.minecraft.server.v1_15_R1.PacketDataSerializer;
import java.io.IOException;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -33,17 +57,31 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
void clear() {
serializer.clear();
}
<T extends Packet<?>> T writeDataTo(T packet) {
try {
packet.a(serializer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -10,8 +10,6 @@ import net.minecraft.server.v1_15_R1.Packet;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.io.IOException;
abstract class VersionNMSPacket implements PacketGroup {
@Override
@ -21,14 +19,4 @@ abstract class VersionNMSPacket implements PacketGroup {
abstract Packet<?> getRawPacket();
protected static <T extends Packet<?>> T writeData(T packet, PacketByteBuffer packetByteBuffer) {
try {
packet.a(packetByteBuffer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -38,7 +38,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntityLiving(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntityLiving());
}
@Override

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = writeData(new PacketPlayOutEntityMetadata(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityMetadata());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = writeData(new PacketPlayOutMount(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutMount());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntity(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntity());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = writeData(new PacketPlayOutEntityTeleport(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityTeleport());
}
@Override

View File

@ -6,25 +6,50 @@
package me.filoghost.holographicdisplays.nms.v1_16_R1;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_16_R1.Packet;
import net.minecraft.server.v1_16_R1.PacketDataSerializer;
import java.io.IOException;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -33,17 +58,31 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
void clear() {
serializer.clear();
}
<T extends Packet<?>> T writeDataTo(T packet) {
try {
packet.a(serializer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -10,8 +10,6 @@ import net.minecraft.server.v1_16_R1.Packet;
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.io.IOException;
abstract class VersionNMSPacket implements PacketGroup {
@Override
@ -21,14 +19,4 @@ abstract class VersionNMSPacket implements PacketGroup {
abstract Packet<?> getRawPacket();
protected static <T extends Packet<?>> T writeData(T packet, PacketByteBuffer packetByteBuffer) {
try {
packet.a(packetByteBuffer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -38,7 +38,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntityLiving(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntityLiving());
}
@Override

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = writeData(new PacketPlayOutEntityMetadata(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityMetadata());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = writeData(new PacketPlayOutMount(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutMount());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntity(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntity());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = writeData(new PacketPlayOutEntityTeleport(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityTeleport());
}
@Override

View File

@ -6,25 +6,49 @@
package me.filoghost.holographicdisplays.nms.v1_16_R2;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_16_R2.Packet;
import net.minecraft.server.v1_16_R2.PacketDataSerializer;
import java.io.IOException;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -33,17 +57,31 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
void clear() {
serializer.clear();
}
<T extends Packet<?>> T writeDataTo(T packet) {
try {
packet.a(serializer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -10,8 +10,6 @@ import net.minecraft.server.v1_16_R2.Packet;
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.io.IOException;
abstract class VersionNMSPacket implements PacketGroup {
@Override
@ -21,14 +19,4 @@ abstract class VersionNMSPacket implements PacketGroup {
abstract Packet<?> getRawPacket();
protected static <T extends Packet<?>> T writeData(T packet, PacketByteBuffer packetByteBuffer) {
try {
packet.a(packetByteBuffer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -38,7 +38,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntityLiving(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntityLiving());
}
@Override

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = writeData(new PacketPlayOutEntityMetadata(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityMetadata());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = writeData(new PacketPlayOutMount(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutMount());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = writeData(new PacketPlayOutSpawnEntity(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntity());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = writeData(new PacketPlayOutEntityTeleport(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityTeleport());
}
@Override

View File

@ -6,25 +6,49 @@
package me.filoghost.holographicdisplays.nms.v1_16_R3;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_16_R3.Packet;
import net.minecraft.server.v1_16_R3.PacketDataSerializer;
import java.io.IOException;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -33,17 +57,31 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
void clear() {
serializer.clear();
}
<T extends Packet<?>> T writeDataTo(T packet) {
try {
packet.a(serializer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -10,8 +10,6 @@ import net.minecraft.server.v1_16_R3.Packet;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.io.IOException;
abstract class VersionNMSPacket implements PacketGroup {
@Override
@ -21,14 +19,4 @@ abstract class VersionNMSPacket implements PacketGroup {
abstract Packet<?> getRawPacket();
protected static <T extends Packet<?>> T writeData(T packet, PacketByteBuffer packetByteBuffer) {
try {
packet.a(packetByteBuffer);
return packet;
} catch (IOException e) {
// Never thrown by the implementations
throw new RuntimeException(e);
}
}
}

View File

@ -18,7 +18,7 @@ class EntityDestroyNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(entityID.getNumericID());
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -18,7 +18,7 @@ class EntityListDestroyNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarIntArray(entityID.getNumericID());
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer.getInternalSerializer());
}
EntityListDestroyNMSPacket(EntityID entityID1, EntityID entityID2) {
@ -26,7 +26,7 @@ class EntityListDestroyNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarIntArray(entityID1.getNumericID(), entityID2.getNumericID());
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -38,7 +38,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = new PacketPlayOutSpawnEntityLiving(packetByteBuffer);
this.rawPacket = new PacketPlayOutSpawnEntityLiving(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = new PacketPlayOutEntityMetadata(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityMetadata(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = new PacketPlayOutMount(packetByteBuffer);
this.rawPacket = new PacketPlayOutMount(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = new PacketPlayOutSpawnEntity(packetByteBuffer);
this.rawPacket = new PacketPlayOutSpawnEntity(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = new PacketPlayOutEntityTeleport(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityTeleport(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -10,21 +10,43 @@ import net.minecraft.network.PacketDataSerializer;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -39,17 +61,25 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
public PacketDataSerializer getInternalSerializer() {
return serializer;
}
void clear() {
serializer.clear();
}
}

View File

@ -18,7 +18,7 @@ class EntityDestroyNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarIntArray(entityID.getNumericID());
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer.getInternalSerializer());
}
EntityDestroyNMSPacket(EntityID entityID1, EntityID entityID2) {
@ -26,7 +26,7 @@ class EntityDestroyNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarIntArray(entityID1.getNumericID(), entityID2.getNumericID());
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -38,7 +38,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = new PacketPlayOutSpawnEntityLiving(packetByteBuffer);
this.rawPacket = new PacketPlayOutSpawnEntityLiving(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = new PacketPlayOutEntityMetadata(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityMetadata(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = new PacketPlayOutMount(packetByteBuffer);
this.rawPacket = new PacketPlayOutMount(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = new PacketPlayOutSpawnEntity(packetByteBuffer);
this.rawPacket = new PacketPlayOutSpawnEntity(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = new PacketPlayOutEntityTeleport(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityTeleport(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -10,21 +10,43 @@ import net.minecraft.network.PacketDataSerializer;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -39,17 +61,25 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
public PacketDataSerializer getInternalSerializer() {
return serializer;
}
void clear() {
serializer.clear();
}
}

View File

@ -18,7 +18,7 @@ class EntityDestroyNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarIntArray(entityID.getNumericID());
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer.getInternalSerializer());
}
EntityDestroyNMSPacket(EntityID entityID1, EntityID entityID2) {
@ -26,7 +26,7 @@ class EntityDestroyNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarIntArray(entityID1.getNumericID(), entityID2.getNumericID());
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -38,7 +38,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = new PacketPlayOutSpawnEntityLiving(packetByteBuffer);
this.rawPacket = new PacketPlayOutSpawnEntityLiving(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = new PacketPlayOutEntityMetadata(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityMetadata(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = new PacketPlayOutMount(packetByteBuffer);
this.rawPacket = new PacketPlayOutMount(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = new PacketPlayOutSpawnEntity(packetByteBuffer);
this.rawPacket = new PacketPlayOutSpawnEntity(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = new PacketPlayOutEntityTeleport(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityTeleport(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -10,21 +10,43 @@ import net.minecraft.network.PacketDataSerializer;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -39,17 +61,25 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
public PacketDataSerializer getInternalSerializer() {
return serializer;
}
void clear() {
serializer.clear();
}
}

View File

@ -18,7 +18,7 @@ class EntityDestroyNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarIntArray(entityID.getNumericID());
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer.getInternalSerializer());
}
EntityDestroyNMSPacket(EntityID entityID1, EntityID entityID2) {
@ -26,7 +26,7 @@ class EntityDestroyNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarIntArray(entityID1.getNumericID(), entityID2.getNumericID());
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = new PacketPlayOutEntityMetadata(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityMetadata(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = new PacketPlayOutMount(packetByteBuffer);
this.rawPacket = new PacketPlayOutMount(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = new PacketPlayOutSpawnEntity(packetByteBuffer);
this.rawPacket = new PacketPlayOutSpawnEntity(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = new PacketPlayOutEntityTeleport(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityTeleport(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -10,21 +10,43 @@ import net.minecraft.network.PacketDataSerializer;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -39,17 +61,25 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
public PacketDataSerializer getInternalSerializer() {
return serializer;
}
void clear() {
serializer.clear();
}
}

View File

@ -18,7 +18,7 @@ class EntityDestroyNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarIntArray(entityID.getNumericID());
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer.getInternalSerializer());
}
EntityDestroyNMSPacket(EntityID entityID1, EntityID entityID2) {
@ -26,7 +26,7 @@ class EntityDestroyNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarIntArray(entityID1.getNumericID(), entityID2.getNumericID());
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityDestroy(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = new PacketPlayOutEntityMetadata(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityMetadata(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -19,7 +19,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeVarInt(vehicleEntityID.getNumericID());
packetByteBuffer.writeVarIntArray(passengerEntityID.getNumericID());
this.rawPacket = new PacketPlayOutMount(packetByteBuffer);
this.rawPacket = new PacketPlayOutMount(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -42,7 +42,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeShort(0);
packetByteBuffer.writeShort(0);
this.rawPacket = new PacketPlayOutSpawnEntity(packetByteBuffer);
this.rawPacket = new PacketPlayOutSpawnEntity(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -31,7 +31,7 @@ class EntityTeleportNMSPacket extends VersionNMSPacket {
// On ground
packetByteBuffer.writeBoolean(false);
this.rawPacket = new PacketPlayOutEntityTeleport(packetByteBuffer);
this.rawPacket = new PacketPlayOutEntityTeleport(packetByteBuffer.getInternalSerializer());
}
@Override

View File

@ -10,21 +10,43 @@ import net.minecraft.network.PacketDataSerializer;
import java.util.UUID;
class PacketByteBuffer extends PacketDataSerializer {
class PacketByteBuffer {
private static final PacketByteBuffer INSTANCE = new PacketByteBuffer();
private final PacketDataSerializer serializer;
static PacketByteBuffer get() {
INSTANCE.clear();
return INSTANCE;
}
private PacketByteBuffer() {
super(Unpooled.buffer());
this.serializer = new PacketDataSerializer(Unpooled.buffer());
}
void writeBoolean(boolean flag) {
serializer.writeBoolean(flag);
}
void writeByte(int i) {
serializer.writeByte(i);
}
void writeShort(int i) {
serializer.writeShort(i);
}
void writeInt(int i) {
serializer.writeInt(i);
}
void writeDouble(double d) {
serializer.writeDouble(d);
}
void writeVarInt(int i) {
super.d(i);
serializer.d(i);
}
void writeVarIntArray(int i1) {
@ -39,17 +61,25 @@ class PacketByteBuffer extends PacketDataSerializer {
}
void writeUUID(UUID uuid) {
super.a(uuid);
serializer.a(uuid);
}
<T> void writeDataWatcherEntry(DataWatcherKey<T> key, T value) {
writeByte(key.getIndex());
serializer.writeByte(key.getIndex());
writeVarInt(key.getSerializerTypeID());
key.getSerializer().a(this, value);
key.getSerializer().a(serializer, value);
}
void writeDataWatcherEntriesEnd() {
writeByte(0xFF);
serializer.writeByte(0xFF);
}
public PacketDataSerializer getInternalSerializer() {
return serializer;
}
void clear() {
serializer.clear();
}
}

View File

@ -62,7 +62,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket {
// Entries are deserialized and saved into a field which is not used during the re-serialization, set as empty
packetByteBuffer.writeDataWatcherEntriesEnd();
Packet<?> rawPacket = writeData(new PacketPlayOutSpawnEntityLiving(), packetByteBuffer);
Packet<?> rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutSpawnEntityLiving());
return new Builder(rawPacket, PacketByteBuffer.get());
}

View File

@ -14,7 +14,7 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
private final Packet<?> rawPacket;
private EntityMetadataNMSPacket(PacketByteBuffer packetByteBuffer) {
this.rawPacket = writeData(new PacketPlayOutEntityMetadata(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutEntityMetadata());
}
@Override

View File

@ -21,7 +21,7 @@ class EntityMountNMSPacket extends VersionNMSPacket {
packetByteBuffer.writeByte(0); // Leash
this.rawPacket = writeData(new PacketPlayOutAttachEntity(), packetByteBuffer);
this.rawPacket = packetByteBuffer.writeDataTo(new PacketPlayOutAttachEntity());
}
@Override

Some files were not shown because too many files have changed in this diff Show More