Remap CraftBukkit to Mojang+Yarn Mappings

By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
CraftBukkit/Spigot
2024-12-11 22:26:55 +01:00
parent a265d64138
commit 30e4583dbe
1780 changed files with 44628 additions and 41274 deletions

View File

@@ -0,0 +1,27 @@
--- a/net/minecraft/network/protocol/PacketUtils.java
+++ b/net/minecraft/network/protocol/PacketUtils.java
@@ -6,10 +6,15 @@
import net.minecraft.CrashReportCategory;
import net.minecraft.ReportedException;
import net.minecraft.network.PacketListener;
+import org.slf4j.Logger;
+
+// CraftBukkit start
+import net.minecraft.server.MinecraftServer;
import net.minecraft.server.RunningOnDifferentThreadException;
import net.minecraft.server.level.ServerLevel;
+import net.minecraft.server.network.ServerCommonPacketListenerImpl;
+// CraftBukkit end
import net.minecraft.util.thread.BlockableEventLoop;
-import org.slf4j.Logger;
public class PacketUtils {
@@ -24,6 +29,7 @@
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T listener, BlockableEventLoop<?> engine) throws RunningOnDifferentThreadException {
if (!engine.isSameThread()) {
engine.executeIfPossible(() -> {
+ if (listener instanceof ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // CraftBukkit - Don't handle sync packets for kicked players
if (listener.shouldHandleMessage(packet)) {
try {
packet.handle(listener);

View File

@@ -1,22 +0,0 @@
--- a/net/minecraft/network/protocol/PlayerConnectionUtils.java
+++ b/net/minecraft/network/protocol/PlayerConnectionUtils.java
@@ -11,6 +11,11 @@
import net.minecraft.util.thread.IAsyncTaskHandler;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.network.ServerCommonPacketListenerImpl;
+// CraftBukkit end
+
public class PlayerConnectionUtils {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -24,6 +29,7 @@
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException {
if (!iasynctaskhandler.isSameThread()) {
iasynctaskhandler.executeIfPossible(() -> {
+ if (t0 instanceof ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // CraftBukkit - Don't handle sync packets for kicked players
if (t0.shouldHandleMessage(packet)) {
try {
packet.handle(t0);

View File

@@ -1,10 +1,18 @@
--- a/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
+++ b/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
@@ -16,8 +16,7 @@
@@ -2,7 +2,6 @@
import com.google.common.collect.Lists;
import java.util.List;
-import net.minecraft.Util;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.Packet;
@@ -16,8 +15,7 @@
private static final int MAX_PAYLOAD_SIZE = 32767;
public static final StreamCodec<PacketDataSerializer, ServerboundCustomPayloadPacket> STREAM_CODEC = CustomPacketPayload.codec((minecraftkey) -> {
public static final StreamCodec<FriendlyByteBuf, ServerboundCustomPayloadPacket> STREAM_CODEC = CustomPacketPayload.codec((minecraftkey) -> {
return DiscardedPayload.codec(minecraftkey, 32767);
- }, (List) SystemUtils.make(Lists.newArrayList(new CustomPacketPayload.c[]{new CustomPacketPayload.c<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC)}), (arraylist) -> {
- }, (List) Util.make(Lists.newArrayList(new CustomPacketPayload.TypeAndCodec[]{new CustomPacketPayload.TypeAndCodec<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC)}), (arraylist) -> {
- })).map(ServerboundCustomPayloadPacket::new, ServerboundCustomPayloadPacket::payload);
+ }, java.util.Collections.emptyList()).map(ServerboundCustomPayloadPacket::new, ServerboundCustomPayloadPacket::payload); // CraftBukkit - treat all packets the same

View File

@@ -2,23 +2,23 @@
+++ b/net/minecraft/network/protocol/common/custom/DiscardedPayload.java
@@ -4,16 +4,18 @@
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.resources.ResourceLocation;
-public record DiscardedPayload(MinecraftKey id) implements CustomPacketPayload {
+public record DiscardedPayload(MinecraftKey id, io.netty.buffer.ByteBuf data) implements CustomPacketPayload { // CraftBukkit - store data
-public record DiscardedPayload(ResourceLocation id) implements CustomPacketPayload {
+public record DiscardedPayload(ResourceLocation id, io.netty.buffer.ByteBuf data) implements CustomPacketPayload { // CraftBukkit - store data
public static <T extends PacketDataSerializer> StreamCodec<T, DiscardedPayload> codec(MinecraftKey minecraftkey, int i) {
public static <T extends FriendlyByteBuf> StreamCodec<T, DiscardedPayload> codec(ResourceLocation id, int maxBytes) {
return CustomPacketPayload.codec((discardedpayload, packetdataserializer) -> {
+ packetdataserializer.writeBytes(discardedpayload.data); // CraftBukkit - serialize
}, (packetdataserializer) -> {
int j = packetdataserializer.readableBytes();
if (j >= 0 && j <= i) {
if (j >= 0 && j <= maxBytes) {
- packetdataserializer.skipBytes(j);
- return new DiscardedPayload(minecraftkey);
- return new DiscardedPayload(id);
+ // CraftBukkit start
+ return new DiscardedPayload(minecraftkey, packetdataserializer.readBytes(j));
+ return new DiscardedPayload(id, packetdataserializer.readBytes(j));
+ // CraftBukkit end
} else {
throw new IllegalArgumentException("Payload may not be larger than " + i + " bytes");
throw new IllegalArgumentException("Payload may not be larger than " + maxBytes + " bytes");
}

View File

@@ -0,0 +1,15 @@
--- a/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java
@@ -30,8 +30,10 @@
}
public ClientboundInitializeBorderPacket(WorldBorder worldBorder) {
- this.newCenterX = worldBorder.getCenterX();
- this.newCenterZ = worldBorder.getCenterZ();
+ // CraftBukkit start - multiply out nether border
+ this.newCenterX = worldBorder.getCenterX() * worldBorder.world.dimensionType().coordinateScale();
+ this.newCenterZ = worldBorder.getCenterZ() * worldBorder.world.dimensionType().coordinateScale();
+ // CraftBukkit end
this.oldSize = worldBorder.getSize();
this.newSize = worldBorder.getLerpTarget();
this.lerpTime = worldBorder.getLerpRemainingTime();

View File

@@ -1,15 +0,0 @@
--- a/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java
@@ -30,8 +30,10 @@
}
public ClientboundInitializeBorderPacket(WorldBorder worldborder) {
- this.newCenterX = worldborder.getCenterX();
- this.newCenterZ = worldborder.getCenterZ();
+ // CraftBukkit start - multiply out nether border
+ this.newCenterX = worldborder.getCenterX() * worldborder.world.dimensionType().coordinateScale();
+ this.newCenterZ = worldborder.getCenterZ() * worldborder.world.dimensionType().coordinateScale();
+ // CraftBukkit end
this.oldSize = worldborder.getSize();
this.newSize = worldborder.getLerpTarget();
this.lerpTime = worldborder.getLerpRemainingTime();

View File

@@ -0,0 +1,23 @@
--- a/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
@@ -33,11 +33,19 @@
short short0 = (Short) shortiterator.next();
this.positions[j] = short0;
- this.states[j] = section.getBlockState(SectionPos.sectionRelativeX(short0), SectionPos.sectionRelativeY(short0), SectionPos.sectionRelativeZ(short0));
+ this.states[j] = (section != null) ? section.getBlockState(SectionPos.sectionRelativeX(short0), SectionPos.sectionRelativeY(short0), SectionPos.sectionRelativeZ(short0)) : net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified
}
}
+ // CraftBukkit start - Add constructor
+ public ClientboundSectionBlocksUpdatePacket(SectionPos sectionposition, ShortSet shortset, BlockState[] states) {
+ this.sectionPos = sectionposition;
+ this.positions = shortset.toShortArray();
+ this.states = states;
+ }
+ // CraftBukkit end
+
private ClientboundSectionBlocksUpdatePacket(FriendlyByteBuf buf) {
this.sectionPos = SectionPos.of(buf.readLong());
int i = buf.readVarInt();

View File

@@ -0,0 +1,15 @@
--- a/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java
@@ -13,8 +13,10 @@
private final double newCenterZ;
public ClientboundSetBorderCenterPacket(WorldBorder worldBorder) {
- this.newCenterX = worldBorder.getCenterX();
- this.newCenterZ = worldBorder.getCenterZ();
+ // CraftBukkit start - multiply out nether border
+ this.newCenterX = worldBorder.getCenterX() * (worldBorder.world != null ? worldBorder.world.dimensionType().coordinateScale() : 1.0);
+ this.newCenterZ = worldBorder.getCenterZ() * (worldBorder.world != null ? worldBorder.world.dimensionType().coordinateScale() : 1.0);
+ // CraftBukkit end
}
private ClientboundSetBorderCenterPacket(FriendlyByteBuf buf) {

View File

@@ -1,15 +0,0 @@
--- a/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java
@@ -13,8 +13,10 @@
private final double newCenterZ;
public ClientboundSetBorderCenterPacket(WorldBorder worldborder) {
- this.newCenterX = worldborder.getCenterX();
- this.newCenterZ = worldborder.getCenterZ();
+ // CraftBukkit start - multiply out nether border
+ this.newCenterX = worldborder.getCenterX() * (worldborder.world != null ? worldborder.world.dimensionType().coordinateScale() : 1.0);
+ this.newCenterZ = worldborder.getCenterZ() * (worldborder.world != null ? worldborder.world.dimensionType().coordinateScale() : 1.0);
+ // CraftBukkit end
}
private ClientboundSetBorderCenterPacket(PacketDataSerializer packetdataserializer) {

View File

@@ -1,7 +0,0 @@
--- a/net/minecraft/network/protocol/game/PacketPlayInBlockPlace.java
+++ b/net/minecraft/network/protocol/game/PacketPlayInBlockPlace.java
@@ -1,3 +1,4 @@
+// mc-dev import
package net.minecraft.network.protocol.game;
import net.minecraft.network.PacketDataSerializer;

View File

@@ -1,7 +0,0 @@
--- a/net/minecraft/network/protocol/game/PacketPlayInUseItem.java
+++ b/net/minecraft/network/protocol/game/PacketPlayInUseItem.java
@@ -1,3 +1,4 @@
+// mc-dev import
package net.minecraft.network.protocol.game;
import net.minecraft.network.PacketDataSerializer;

View File

@@ -1,23 +0,0 @@
--- a/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.java
+++ b/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.java
@@ -33,11 +33,19 @@
short short0 = (Short) shortiterator.next();
this.positions[j] = short0;
- this.states[j] = chunksection.getBlockState(SectionPosition.sectionRelativeX(short0), SectionPosition.sectionRelativeY(short0), SectionPosition.sectionRelativeZ(short0));
+ this.states[j] = (chunksection != null) ? chunksection.getBlockState(SectionPosition.sectionRelativeX(short0), SectionPosition.sectionRelativeY(short0), SectionPosition.sectionRelativeZ(short0)) : net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified
}
}
+ // CraftBukkit start - Add constructor
+ public PacketPlayOutMultiBlockChange(SectionPosition sectionposition, ShortSet shortset, IBlockData[] states) {
+ this.sectionPos = sectionposition;
+ this.positions = shortset.toShortArray();
+ this.states = states;
+ }
+ // CraftBukkit end
+
private PacketPlayOutMultiBlockChange(PacketDataSerializer packetdataserializer) {
this.sectionPos = SectionPosition.of(packetdataserializer.readLong());
int i = packetdataserializer.readVarInt();

View File

@@ -0,0 +1,7 @@
--- a/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java
+++ b/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java
@@ -1,3 +1,4 @@
+// mc-dev import
package net.minecraft.network.protocol.game;
import net.minecraft.network.FriendlyByteBuf;

View File

@@ -0,0 +1,7 @@
--- a/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java
+++ b/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java
@@ -1,3 +1,4 @@
+// mc-dev import
package net.minecraft.network.protocol.game;
import net.minecraft.network.FriendlyByteBuf;

View File

@@ -0,0 +1,7 @@
--- a/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java
+++ b/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java
@@ -1,3 +1,4 @@
+// mc-dev import
package net.minecraft.network.protocol.handshake;
import net.minecraft.network.FriendlyByteBuf;

View File

@@ -1,7 +0,0 @@
--- a/net/minecraft/network/protocol/handshake/PacketHandshakingInSetProtocol.java
+++ b/net/minecraft/network/protocol/handshake/PacketHandshakingInSetProtocol.java
@@ -1,3 +1,4 @@
+// mc-dev import
package net.minecraft.network.protocol.handshake;
import net.minecraft.network.PacketDataSerializer;