diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch new file mode 100644 index 0000000000..0ff164615d --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch @@ -0,0 +1,117 @@ +--- a/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java +@@ -1,5 +1,6 @@ + package net.minecraft.network.protocol.game; + ++import it.unimi.dsi.fastutil.shorts.ShortIterator; + import it.unimi.dsi.fastutil.shorts.ShortSet; + import java.util.function.BiConsumer; + import net.minecraft.core.BlockPos; +@@ -7,40 +8,55 @@ + import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.network.protocol.Packet; + import net.minecraft.world.level.block.Block; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.chunk.LevelChunkSection; + + public class ClientboundSectionBlocksUpdatePacket implements Packet<ClientGamePacketListener> { ++ + private static final int POS_IN_SECTION_BITS = 12; + private final SectionPos sectionPos; + private final short[] positions; +- private final BlockState[] states; ++ private final IBlockData[] states; + + public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, ShortSet positions, LevelChunkSection section) { + this.sectionPos = sectionPos; +- int size = positions.size(); +- this.positions = new short[size]; +- this.states = new BlockState[size]; +- int i = 0; ++ int i = positions.size(); + +- for (short s : positions) { +- this.positions[i] = s; +- this.states[i] = section.getBlockState(SectionPos.sectionRelativeX(s), SectionPos.sectionRelativeY(s), SectionPos.sectionRelativeZ(s)); +- i++; ++ this.positions = new short[i]; ++ this.states = new IBlockData[i]; ++ int j = 0; ++ ++ for (ShortIterator shortiterator = positions.iterator(); shortiterator.hasNext(); ++j) { ++ short short0 = (Short) shortiterator.next(); ++ ++ this.positions[j] = 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, IBlockData[] states) { ++ this.sectionPos = sectionposition; ++ this.positions = shortset.toShortArray(); ++ this.states = states; ++ } ++ // CraftBukkit end ++ + public ClientboundSectionBlocksUpdatePacket(FriendlyByteBuf buffer) { + this.sectionPos = SectionPos.of(buffer.readLong()); +- int varInt = buffer.readVarInt(); +- this.positions = new short[varInt]; +- this.states = new BlockState[varInt]; ++ int i = buffer.readVarInt(); + +- for (int i = 0; i < varInt; i++) { +- long varLong = buffer.readVarLong(); +- this.positions[i] = (short)((int)(varLong & 4095L)); +- this.states[i] = Block.BLOCK_STATE_REGISTRY.byId((int)(varLong >>> 12)); ++ this.positions = new short[i]; ++ this.states = new IBlockData[i]; ++ ++ for (int j = 0; j < i; ++j) { ++ long k = buffer.readVarLong(); ++ ++ this.positions[j] = (short) ((int) (k & 4095L)); ++ this.states[j] = (IBlockData) Block.BLOCK_STATE_REGISTRY.byId((int) (k >>> 12)); + } ++ + } + + @Override +@@ -48,23 +64,25 @@ + buffer.writeLong(this.sectionPos.asLong()); + buffer.writeVarInt(this.positions.length); + +- for (int i = 0; i < this.positions.length; i++) { +- buffer.writeVarLong((long)Block.getId(this.states[i]) << 12 | (long)this.positions[i]); ++ for (int i = 0; i < this.positions.length; ++i) { ++ buffer.writeVarLong((long) Block.getId(this.states[i]) << 12 | (long) this.positions[i]); + } ++ + } + +- @Override + public void handle(ClientGamePacketListener handler) { + handler.handleChunkBlocksUpdate(this); + } + +- public void runUpdates(BiConsumer<BlockPos, BlockState> consumer) { +- BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); ++ public void runUpdates(BiConsumer<BlockPos, IBlockData> consumer) { ++ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); + +- for (int i = 0; i < this.positions.length; i++) { +- short s = this.positions[i]; +- mutableBlockPos.set(this.sectionPos.relativeToBlockX(s), this.sectionPos.relativeToBlockY(s), this.sectionPos.relativeToBlockZ(s)); +- consumer.accept(mutableBlockPos, this.states[i]); ++ for (int i = 0; i < this.positions.length; ++i) { ++ short short0 = this.positions[i]; ++ ++ blockposition_mutableblockposition.set(this.sectionPos.relativeToBlockX(short0), this.sectionPos.relativeToBlockY(short0), this.sectionPos.relativeToBlockZ(short0)); ++ consumer.accept(blockposition_mutableblockposition, this.states[i]); + } ++ + } + } |