@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/NetworkManager.java
|
||||
+++ b/net/minecraft/network/NetworkManager.java
|
||||
@@ -105,6 +105,7 @@
|
||||
@@ -114,6 +114,7 @@
|
||||
private volatile IChatBaseComponent delayedDisconnect;
|
||||
@Nullable
|
||||
BandwidthDebugMonitor bandwidthDebugMonitor;
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
public NetworkManager(EnumProtocolDirection enumprotocoldirection) {
|
||||
this.receiving = enumprotocoldirection;
|
||||
@@ -194,7 +195,7 @@
|
||||
@@ -197,7 +198,7 @@
|
||||
}
|
||||
|
||||
private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener packetlistener) {
|
||||
@@ -16,8 +16,8 @@
|
||||
+ packet.handle((T) packetlistener); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public void suspendInboundAfterProtocolChange() {
|
||||
@@ -421,7 +422,7 @@
|
||||
private void validateListener(ProtocolInfo<?> protocolinfo, PacketListener packetlistener) {
|
||||
@@ -457,7 +458,7 @@
|
||||
}
|
||||
|
||||
if (this.isConnected()) {
|
||||
@@ -26,3 +26,12 @@
|
||||
this.disconnectedReason = ichatbasecomponent;
|
||||
}
|
||||
|
||||
@@ -525,7 +526,7 @@
|
||||
}
|
||||
|
||||
public void configurePacketHandler(ChannelPipeline channelpipeline) {
|
||||
- channelpipeline.addLast("hackfix", new ChannelOutboundHandlerAdapter(this) {
|
||||
+ channelpipeline.addLast("hackfix", new ChannelOutboundHandlerAdapter() { // CraftBukkit - decompile error
|
||||
public void write(ChannelHandlerContext channelhandlercontext, Object object, ChannelPromise channelpromise) throws Exception {
|
||||
super.write(channelhandlercontext, object, channelpromise);
|
||||
}
|
||||
|
||||
@@ -1,33 +1,24 @@
|
||||
--- a/net/minecraft/network/PacketDataSerializer.java
|
||||
+++ b/net/minecraft/network/PacketDataSerializer.java
|
||||
@@ -81,6 +81,8 @@
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
@@ -139,7 +139,7 @@
|
||||
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
|
||||
+
|
||||
public class PacketDataSerializer extends ByteBuf {
|
||||
|
||||
public static final int DEFAULT_NBT_QUOTA = 2097152;
|
||||
@@ -205,7 +207,7 @@
|
||||
|
||||
public <T, C extends Collection<T>> C readCollection(IntFunction<C> intfunction, PacketDataSerializer.a<T> packetdataserializer_a) {
|
||||
public <T, C extends Collection<T>> C readCollection(IntFunction<C> intfunction, StreamDecoder<? super PacketDataSerializer, T> streamdecoder) {
|
||||
int i = this.readVarInt();
|
||||
- C c0 = (Collection) intfunction.apply(i);
|
||||
+ C c0 = intfunction.apply(i); // CraftBukkit - decompile error
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
c0.add(packetdataserializer_a.apply(this));
|
||||
@@ -216,7 +218,7 @@
|
||||
c0.add(streamdecoder.decode(this));
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
public <T> void writeCollection(Collection<T> collection, PacketDataSerializer.b<T> packetdataserializer_b) {
|
||||
public <T> void writeCollection(Collection<T> collection, StreamEncoder<? super PacketDataSerializer, T> streamencoder) {
|
||||
this.writeVarInt(collection.size());
|
||||
- Iterator iterator = collection.iterator();
|
||||
+ Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -243,12 +245,12 @@
|
||||
@@ -177,12 +177,12 @@
|
||||
|
||||
public void writeIntIdList(IntList intlist) {
|
||||
this.writeVarInt(intlist.size());
|
||||
@@ -35,14 +26,14 @@
|
||||
+ intlist.forEach((java.util.function.IntConsumer) this::writeVarInt); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public <K, V, M extends Map<K, V>> M readMap(IntFunction<M> intfunction, PacketDataSerializer.a<K> packetdataserializer_a, PacketDataSerializer.a<V> packetdataserializer_a1) {
|
||||
public <K, V, M extends Map<K, V>> M readMap(IntFunction<M> intfunction, StreamDecoder<? super PacketDataSerializer, K> streamdecoder, StreamDecoder<? super PacketDataSerializer, V> streamdecoder1) {
|
||||
int i = this.readVarInt();
|
||||
- M m0 = (Map) intfunction.apply(i);
|
||||
+ M m0 = intfunction.apply(i); // CraftBukkit - decompile error
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
K k0 = packetdataserializer_a.apply(this);
|
||||
@@ -282,7 +284,7 @@
|
||||
K k0 = streamdecoder.decode(this);
|
||||
@@ -216,7 +216,7 @@
|
||||
}
|
||||
|
||||
public <E extends Enum<E>> void writeEnumSet(EnumSet<E> enumset, Class<E> oclass) {
|
||||
@@ -51,7 +42,7 @@
|
||||
BitSet bitset = new BitSet(ae.length);
|
||||
|
||||
for (int i = 0; i < ae.length; ++i) {
|
||||
@@ -293,7 +295,7 @@
|
||||
@@ -227,7 +227,7 @@
|
||||
}
|
||||
|
||||
public <E extends Enum<E>> EnumSet<E> readEnumSet(Class<E> oclass) {
|
||||
@@ -60,7 +51,7 @@
|
||||
BitSet bitset = this.readFixedBitSet(ae.length);
|
||||
EnumSet<E> enumset = EnumSet.noneOf(oclass);
|
||||
|
||||
@@ -529,7 +531,7 @@
|
||||
@@ -482,7 +482,7 @@
|
||||
}
|
||||
|
||||
public <T extends Enum<T>> T readEnum(Class<T> oclass) {
|
||||
@@ -69,33 +60,12 @@
|
||||
}
|
||||
|
||||
public PacketDataSerializer writeEnum(Enum<?> oenum) {
|
||||
@@ -584,7 +586,7 @@
|
||||
@@ -549,7 +549,7 @@
|
||||
|
||||
try {
|
||||
NBTCompressedStreamTools.writeAnyTag((NBTBase) nbtbase, new ByteBufOutputStream(this));
|
||||
return this;
|
||||
NBTCompressedStreamTools.writeAnyTag((NBTBase) nbtbase, new ByteBufOutputStream(bytebuf));
|
||||
- } catch (IOException ioexception) {
|
||||
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
|
||||
throw new EncoderException(ioexception);
|
||||
}
|
||||
}
|
||||
@@ -612,7 +614,7 @@
|
||||
}
|
||||
|
||||
public PacketDataSerializer writeItem(ItemStack itemstack) {
|
||||
- if (itemstack.isEmpty()) {
|
||||
+ if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
|
||||
this.writeBoolean(false);
|
||||
} else {
|
||||
this.writeBoolean(true);
|
||||
@@ -641,6 +643,11 @@
|
||||
ItemStack itemstack = new ItemStack(item, b0);
|
||||
|
||||
itemstack.setTag(this.readNbt());
|
||||
+ // CraftBukkit start
|
||||
+ if (itemstack.getTag() != null) {
|
||||
+ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/protocol/PlayerConnectionUtils.java
|
||||
+++ b/net/minecraft/network/protocol/PlayerConnectionUtils.java
|
||||
@@ -9,6 +9,11 @@
|
||||
@@ -10,6 +10,11 @@
|
||||
import net.minecraft.util.thread.IAsyncTaskHandler;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
public class PlayerConnectionUtils {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -22,6 +27,7 @@
|
||||
@@ -23,6 +28,7 @@
|
||||
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException {
|
||||
if (!iasynctaskhandler.isSameThread()) {
|
||||
iasynctaskhandler.executeIfPossible(() -> {
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
--- a/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
|
||||
+++ b/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
|
||||
@@ -12,7 +12,7 @@
|
||||
public record ServerboundCustomPayloadPacket(CustomPacketPayload payload) implements Packet<ServerCommonPacketListener> {
|
||||
|
||||
private static final int MAX_PAYLOAD_SIZE = 32767;
|
||||
- private static final Map<MinecraftKey, PacketDataSerializer.a<? extends CustomPacketPayload>> KNOWN_TYPES = ImmutableMap.builder().put(BrandPayload.ID, BrandPayload::new).build();
|
||||
+ private static final Map<MinecraftKey, PacketDataSerializer.a<? extends CustomPacketPayload>> KNOWN_TYPES = ImmutableMap.<MinecraftKey, PacketDataSerializer.a<? extends CustomPacketPayload>>builder().build(); // CraftBukkit - no special handling
|
||||
|
||||
public ServerboundCustomPayloadPacket(PacketDataSerializer packetdataserializer) {
|
||||
this(readPayload(packetdataserializer.readResourceLocation(), packetdataserializer));
|
||||
@@ -24,12 +24,13 @@
|
||||
return (CustomPacketPayload) (packetdataserializer_a != null ? (CustomPacketPayload) packetdataserializer_a.apply(packetdataserializer) : readUnknownPayload(minecraftkey, packetdataserializer));
|
||||
}
|
||||
|
||||
- private static DiscardedPayload readUnknownPayload(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) {
|
||||
+ private static UnknownPayload readUnknownPayload(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { // CraftBukkit
|
||||
int i = packetdataserializer.readableBytes();
|
||||
|
||||
if (i >= 0 && i <= 32767) {
|
||||
- packetdataserializer.skipBytes(i);
|
||||
- return new DiscardedPayload(minecraftkey);
|
||||
+ // CraftBukkit start
|
||||
+ return new UnknownPayload(minecraftkey, packetdataserializer.readBytes(i));
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
throw new IllegalArgumentException("Payload may not be larger than 32767 bytes");
|
||||
}
|
||||
@@ -44,4 +45,14 @@
|
||||
public void handle(ServerCommonPacketListener servercommonpacketlistener) {
|
||||
servercommonpacketlistener.handleCustomPayload(this);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public record UnknownPayload(MinecraftKey id, io.netty.buffer.ByteBuf data) implements CustomPacketPayload {
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(PacketDataSerializer packetdataserializer) {
|
||||
+ packetdataserializer.writeBytes(data);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
--- a/net/minecraft/network/protocol/common/custom/DiscardedPayload.java
|
||||
+++ b/net/minecraft/network/protocol/common/custom/DiscardedPayload.java
|
||||
@@ -4,16 +4,18 @@
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
|
||||
-public record DiscardedPayload(MinecraftKey id) implements CustomPacketPayload {
|
||||
+public record DiscardedPayload(MinecraftKey id, io.netty.buffer.ByteBuf data) implements CustomPacketPayload { // CraftBukkit - store data
|
||||
|
||||
public static <T extends PacketDataSerializer> StreamCodec<T, DiscardedPayload> codec(MinecraftKey minecraftkey, int i) {
|
||||
return CustomPacketPayload.codec((discardedpayload, packetdataserializer) -> {
|
||||
+ packetdataserializer.writeBytes(discardedpayload.data); // CraftBukkit - serialize
|
||||
}, (packetdataserializer) -> {
|
||||
int j = packetdataserializer.readableBytes();
|
||||
|
||||
if (j >= 0 && j <= i) {
|
||||
- packetdataserializer.skipBytes(j);
|
||||
- return new DiscardedPayload(minecraftkey);
|
||||
+ // CraftBukkit start
|
||||
+ return new DiscardedPayload(minecraftkey, packetdataserializer.readBytes(j));
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
throw new IllegalArgumentException("Payload may not be larger than " + i + " bytes");
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java
|
||||
+++ b/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java
|
||||
@@ -27,8 +27,10 @@
|
||||
@@ -30,8 +30,10 @@
|
||||
}
|
||||
|
||||
public ClientboundInitializeBorderPacket(WorldBorder worldborder) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java
|
||||
+++ b/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java
|
||||
@@ -10,8 +10,10 @@
|
||||
@@ -13,8 +13,10 @@
|
||||
private final double newCenterZ;
|
||||
|
||||
public ClientboundSetBorderCenterPacket(WorldBorder worldborder) {
|
||||
@@ -12,4 +12,4 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public ClientboundSetBorderCenterPacket(PacketDataSerializer packetdataserializer) {
|
||||
private ClientboundSetBorderCenterPacket(PacketDataSerializer packetdataserializer) {
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
+// mc-dev import
|
||||
package net.minecraft.network.protocol.game;
|
||||
|
||||
import net.minecraft.network.PacketDataSerializer;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.java
|
||||
+++ b/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.java
|
||||
@@ -30,11 +30,19 @@
|
||||
@@ -33,11 +33,19 @@
|
||||
short short0 = (Short) shortiterator.next();
|
||||
|
||||
this.positions[j] = short0;
|
||||
@@ -18,6 +18,6 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public PacketPlayOutMultiBlockChange(PacketDataSerializer packetdataserializer) {
|
||||
private PacketPlayOutMultiBlockChange(PacketDataSerializer packetdataserializer) {
|
||||
this.sectionPos = SectionPosition.of(packetdataserializer.readLong());
|
||||
int i = packetdataserializer.readVarInt();
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
+// mc-dev import
|
||||
package net.minecraft.network.protocol.handshake;
|
||||
|
||||
import net.minecraft.network.EnumProtocol;
|
||||
import net.minecraft.network.PacketDataSerializer;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/syncher/DataWatcher.java
|
||||
+++ b/net/minecraft/network/syncher/DataWatcher.java
|
||||
@@ -24,6 +24,11 @@
|
||||
@@ -14,6 +14,11 @@
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -12,7 +12,16 @@
|
||||
public class DataWatcher {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -146,6 +151,13 @@
|
||||
@@ -51,7 +56,7 @@
|
||||
}
|
||||
|
||||
private <T> DataWatcher.Item<T> getItem(DataWatcherObject<T> datawatcherobject) {
|
||||
- return this.itemsById[datawatcherobject.id()];
|
||||
+ return (DataWatcher.Item<T>) this.itemsById[datawatcherobject.id()]; // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public <T> T get(DataWatcherObject<T> datawatcherobject) {
|
||||
@@ -74,6 +79,13 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -26,40 +35,12 @@
|
||||
public boolean isDirty() {
|
||||
return this.isDirty;
|
||||
}
|
||||
@@ -227,7 +239,7 @@
|
||||
if (!Objects.equals(datawatcher_b.serializer(), datawatcher_item.accessor.getSerializer())) {
|
||||
throw new IllegalStateException(String.format(Locale.ROOT, "Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.getId(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_b.value, datawatcher_b.value.getClass()));
|
||||
@@ -140,7 +152,7 @@
|
||||
if (!Objects.equals(datawatcher_c.serializer(), datawatcher_item.accessor.serializer())) {
|
||||
throw new IllegalStateException(String.format(Locale.ROOT, "Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.id(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_c.value, datawatcher_c.value.getClass()));
|
||||
} else {
|
||||
- datawatcher_item.setValue(datawatcher_b.value);
|
||||
+ datawatcher_item.setValue((T) datawatcher_b.value); // CraftBukkit - decompile error
|
||||
- datawatcher_item.setValue(datawatcher_c.value);
|
||||
+ datawatcher_item.setValue((T) datawatcher_c.value); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,6 +247,18 @@
|
||||
return this.itemsById.isEmpty();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void refresh(EntityPlayer to) {
|
||||
+ if (!this.isEmpty()) {
|
||||
+ List<DataWatcher.b<?>> list = this.getNonDefaultValues();
|
||||
+
|
||||
+ if (list != null) {
|
||||
+ to.connection.send(new PacketPlayOutEntityMetadata(this.entity.getId(), list));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static class Item<T> {
|
||||
|
||||
final DataWatcherObject<T> accessor;
|
||||
@@ -277,7 +301,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- public static record b<T> (int id, DataWatcherSerializer<T> serializer, T value) {
|
||||
+ public static record b<T>(int id, DataWatcherSerializer<T> serializer, T value) { // CraftBukkit - decompile error
|
||||
|
||||
public static <T> DataWatcher.b<T> create(DataWatcherObject<T> datawatcherobject, T t0) {
|
||||
DataWatcherSerializer<T> datawatcherserializer = datawatcherobject.getSerializer();
|
||||
|
||||
Reference in New Issue
Block a user