From cdbf9dd0c074211d788619173902f22c1c11449c Mon Sep 17 00:00:00 2001 From: Cryptite Date: Mon, 28 Feb 2022 08:53:17 -0600 Subject: [PATCH] Patch work --- .gitignore | 2 + ...2-Set-BlockData-without-light-update.patch | 39 ++++ ...3-Set-BlockData-without-light-update.patch | 177 ++++++++++++++++++ ...ment-updates-if-only-durability-chan.patch | 19 ++ .../0005-Allow-opening-covered-chests.patch | 43 +++++ ...packets-if-player-has-Fire-Resistanc.patch | 23 +++ 6 files changed, 303 insertions(+) create mode 100644 patches/api/0002-Set-BlockData-without-light-update.patch create mode 100644 patches/server/0003-Set-BlockData-without-light-update.patch create mode 100644 patches/server/0004-Don-t-send-equipment-updates-if-only-durability-chan.patch create mode 100644 patches/server/0005-Allow-opening-covered-chests.patch create mode 100644 patches/server/0006-Don-t-send-fire-packets-if-player-has-Fire-Resistanc.patch diff --git a/.gitignore b/.gitignore index a1fc39c07..837cb6223 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .gradle /build/ +.idea +run # Ignore Gradle GUI config gradle-app.setting diff --git a/patches/api/0002-Set-BlockData-without-light-update.patch b/patches/api/0002-Set-BlockData-without-light-update.patch new file mode 100644 index 000000000..02bbae461 --- /dev/null +++ b/patches/api/0002-Set-BlockData-without-light-update.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tom +Date: Mon, 28 Feb 2022 08:40:41 -0600 +Subject: [PATCH] Set BlockData without light update + + +diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java +index 3e980c630452c8ea72227bc4cd92c605253cd41b..fe23d144175b3bd55564a4a266b98cd2fc70a08a 100644 +--- a/src/main/java/org/bukkit/block/Block.java ++++ b/src/main/java/org/bukkit/block/Block.java +@@ -297,6 +297,28 @@ public interface Block extends Metadatable, net.kyori.adventure.translation.Tran + */ + void setBlockData(@NotNull BlockData data, boolean applyPhysics); + ++ /** ++ * Sets the complete data for this block ++ * ++ *
++ * Note that applyPhysics = false is not in general safe. It should only be ++ * used when you need to avoid triggering a physics update of neighboring ++ * blocks, for example when creating a {@link Bisected} block. If you are ++ * using a custom populator, then this parameter may also be required to ++ * prevent triggering infinite chunk loads on border blocks. This method ++ * should NOT be used to "hack" physics by placing blocks in impossible ++ * locations. Such blocks are liable to be removed on various events such as ++ * world upgrades. Furthermore setting large amounts of such blocks in close ++ * proximity may overload the server physics engine if an update is ++ * triggered at a later point. If this occurs, the resulting behavior is ++ * undefined. ++ * ++ * @param data new block specific data ++ * @param applyPhysics false to cancel physics from the changed block ++ * @param checkLight false to prevent a light-check update ++ */ ++ void setBlockData(@NotNull BlockData data, boolean applyPhysics, boolean checkLight); ++ + /** + * Sets the type of this block + * diff --git a/patches/server/0003-Set-BlockData-without-light-update.patch b/patches/server/0003-Set-BlockData-without-light-update.patch new file mode 100644 index 000000000..f8f63b7be --- /dev/null +++ b/patches/server/0003-Set-BlockData-without-light-update.patch @@ -0,0 +1,177 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tom +Date: Mon, 28 Feb 2022 08:40:41 -0600 +Subject: [PATCH] Set BlockData without light update + + +diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java +index 9b25d36fe5230e287d81b99be31b9eddd8e76002..2477b1edc73f295414dd67acfd16e17c100e4260 100644 +--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java ++++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java +@@ -226,7 +226,7 @@ public class WorldGenRegion implements WorldGenLevel { + Block.dropResources(iblockdata, this.level, pos, tileentity, breakingEntity, ItemStack.EMPTY); + } + +- return this.setBlock(pos, Blocks.AIR.defaultBlockState(), 3, maxUpdateDepth); ++ return this.setBlock(pos, Blocks.AIR.defaultBlockState(), 3, maxUpdateDepth, true); + } + } + +@@ -292,7 +292,7 @@ public class WorldGenRegion implements WorldGenLevel { + } + + @Override +- public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) { ++ public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, boolean checkLight) { + if (!this.ensureCanWrite(pos)) { + return false; + } else { +diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java +index 11e146241a01ab9ec206b9d3f39aebf5c201a16e..fb283572b11ed6e482ada401c44d40c9c5e37367 100644 +--- a/src/main/java/net/minecraft/world/level/Level.java ++++ b/src/main/java/net/minecraft/world/level/Level.java +@@ -538,12 +538,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + } + + @Override +- public final boolean setBlock(BlockPos pos, BlockState state, int flags) { // Paper - final for inline +- return this.setBlock(pos, state, flags, 512); ++ public final boolean setBlock(BlockPos pos, BlockState state, int flags, boolean checkLight) { // Paper - final for inline ++ return this.setBlock(pos, state, flags, 512, checkLight); + } + + @Override +- public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) { ++ public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, boolean checkLight) { + // CraftBukkit start - tree generation + if (this.captureTreeGeneration) { + // Paper start +@@ -590,7 +590,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + } else { + BlockState iblockdata2 = this.getBlockState(pos); + +- if ((flags & 128) == 0 && iblockdata2 != iblockdata1 && (iblockdata2.getLightBlock(this, pos) != iblockdata1.getLightBlock(this, pos) || iblockdata2.getLightEmission() != iblockdata1.getLightEmission() || iblockdata2.useShapeForLightOcclusion() || iblockdata1.useShapeForLightOcclusion())) { ++ if (checkLight && (flags & 128) == 0 && iblockdata2 != iblockdata1 && (iblockdata2.getLightBlock(this, pos) != iblockdata1.getLightBlock(this, pos) || iblockdata2.getLightEmission() != iblockdata1.getLightEmission() || iblockdata2.useShapeForLightOcclusion() || iblockdata1.useShapeForLightOcclusion())) { + this.getProfiler().push("queueCheckLight"); + this.getChunkSource().getLightEngine().checkBlock(pos); + this.getProfiler().pop(); +@@ -737,7 +737,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + Block.dropResources(iblockdata, this, pos, tileentity, breakingEntity, ItemStack.EMPTY); + } + +- boolean flag1 = this.setBlock(pos, fluid.createLegacyBlock(), 3, maxUpdateDepth); ++ boolean flag1 = this.setBlock(pos, fluid.createLegacyBlock(), 3, maxUpdateDepth, true); + + if (flag1) { + this.gameEvent(breakingEntity, GameEvent.BLOCK_DESTROY, pos); +diff --git a/src/main/java/net/minecraft/world/level/LevelWriter.java b/src/main/java/net/minecraft/world/level/LevelWriter.java +index 134e5ec79bf2dddd4e31930f8a7cb2c02fa29518..fd72d278a2719911a46b6bc9e7da2dc24bbe681e 100644 +--- a/src/main/java/net/minecraft/world/level/LevelWriter.java ++++ b/src/main/java/net/minecraft/world/level/LevelWriter.java +@@ -7,10 +7,14 @@ import net.minecraft.world.level.block.state.BlockState; + + public interface LevelWriter { + +- boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth); ++ boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, boolean checkLight); + + default boolean setBlock(BlockPos pos, BlockState state, int flags) { +- return this.setBlock(pos, state, flags, 512); ++ return this.setBlock(pos, state, flags, 512, true); ++ } ++ ++ default boolean setBlock(BlockPos pos, BlockState state, int flags, boolean checkLight) { ++ return this.setBlock(pos, state, flags, 512, checkLight); + } + + boolean removeBlock(BlockPos pos, boolean move); +diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java +index ab5b9f00123e2ede2931ffc520684e482aac49b4..e88e46aac3fa07a330c9f686f563c6d5fbfa3d70 100644 +--- a/src/main/java/net/minecraft/world/level/block/Block.java ++++ b/src/main/java/net/minecraft/world/level/block/Block.java +@@ -195,7 +195,7 @@ public class Block extends BlockBehaviour implements ItemLike { + world.destroyBlock(pos, (flags & 32) == 0, (Entity) null, maxUpdateDepth); + } + } else { +- world.setBlock(pos, newState, flags & -33, maxUpdateDepth); ++ world.setBlock(pos, newState, flags & -33, maxUpdateDepth, true); + } + } + +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +index abd9429ece67fc1649750a77045c8157c57309a1..2c83041140b455d57ec09a59ba59bc436e726dab 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +@@ -263,7 +263,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { + BlockPos pos = new BlockPos(x, y, z); + net.minecraft.world.level.block.state.BlockState old = this.getHandle().getBlockState(pos); + +- CraftBlock.setTypeAndData(world, pos, old, ((CraftBlockData) blockData).getState(), true); ++ CraftBlock.setTypeAndData(world, pos, old, ((CraftBlockData) blockData).getState(), true, true); + } + + @Override +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +index 5ea2fdbd2c762e0e632093fc07294327eb061ada..01b904b8cc32bcb1e665db773dafa0adfb4c5b55 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +@@ -178,15 +178,20 @@ public class CraftBlock implements Block { + + @Override + public void setBlockData(BlockData data, boolean applyPhysics) { ++ setBlockData(data, applyPhysics, true); ++ } ++ ++ @Override ++ public void setBlockData(BlockData data, boolean applyPhysics, boolean checkLight) { + Preconditions.checkArgument(data != null, "BlockData cannot be null"); +- this.setTypeAndData(((CraftBlockData) data).getState(), applyPhysics); ++ this.setTypeAndData(((CraftBlockData) data).getState(), applyPhysics, checkLight); + } + +- boolean setTypeAndData(final net.minecraft.world.level.block.state.BlockState blockData, final boolean applyPhysics) { +- return CraftBlock.setTypeAndData(this.world, this.position, this.getNMS(), blockData, applyPhysics); ++ boolean setTypeAndData(final net.minecraft.world.level.block.state.BlockState blockData, final boolean applyPhysics, boolean checkLight) { ++ return CraftBlock.setTypeAndData(this.world, this.position, this.getNMS(), blockData, applyPhysics, checkLight); + } + +- public static boolean setTypeAndData(LevelAccessor world, BlockPos position, net.minecraft.world.level.block.state.BlockState old, net.minecraft.world.level.block.state.BlockState blockData, boolean applyPhysics) { ++ public static boolean setTypeAndData(LevelAccessor world, BlockPos position, net.minecraft.world.level.block.state.BlockState old, net.minecraft.world.level.block.state.BlockState blockData, boolean applyPhysics, boolean checkLight) { + // SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup + if (old.hasBlockEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes + // SPIGOT-4612: faster - just clear tile +@@ -200,7 +205,7 @@ public class CraftBlock implements Block { + if (applyPhysics) { + return world.setBlock(position, blockData, 3); + } else { +- boolean success = world.setBlock(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom) ++ boolean success = world.setBlock(position, blockData, 2 | 16 | 1024, checkLight); // NOTIFY | NO_OBSERVER | NO_PLACE (custom) + if (success && world instanceof net.minecraft.world.level.Level) { + world.getMinecraftWorld().sendBlockUpdated( + position, +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +index 966ac60daebb7bb211ab8096fc0c5f33db67320a..d68b046e30d0f3d186ed90b7c36086ccd889de1f 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +@@ -213,7 +213,7 @@ public class CraftBlockState implements BlockState { + } + + net.minecraft.world.level.block.state.BlockState newBlock = this.data; +- block.setTypeAndData(newBlock, applyPhysics); ++ block.setTypeAndData(newBlock, applyPhysics, true); + if (access instanceof net.minecraft.world.level.Level) { + this.world.getHandle().sendBlockUpdated( + position, +diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +index 4c6cbfbcb5a7876e6b556b59c54e9a4cedf7843e..0cec147b0c291ab92b1fc93df40bf39c473d862a 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +@@ -245,7 +245,7 @@ public class DummyGeneratorAccess implements WorldGenLevel { + } + + @Override +- public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) { ++ public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, boolean checkLight) { + return false; + } + diff --git a/patches/server/0004-Don-t-send-equipment-updates-if-only-durability-chan.patch b/patches/server/0004-Don-t-send-equipment-updates-if-only-durability-chan.patch new file mode 100644 index 000000000..565b24438 --- /dev/null +++ b/patches/server/0004-Don-t-send-equipment-updates-if-only-durability-chan.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cryptite +Date: Mon, 28 Feb 2022 08:43:22 -0600 +Subject: [PATCH] Don't send equipment updates if only durability changed + + +diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java +index 9822d163a9e4d6ac8240c18a7082e911788d0948..1d17ba9aa5f6de7e6f14f0a2aeb7f322f74ce90f 100644 +--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java ++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +@@ -3028,7 +3028,7 @@ public abstract class LivingEntity extends Entity { + + ItemStack itemstack1 = this.getItemBySlot(enumitemslot); + +- if (!ItemStack.matches(itemstack1, itemstack)) { ++ if (!ItemStack.isSameIgnoreDurability(itemstack1, itemstack)) { + // Paper start - PlayerArmorChangeEvent + if (this instanceof ServerPlayer && enumitemslot.getType() == EquipmentSlot.Type.ARMOR) { + final org.bukkit.inventory.ItemStack oldItem = CraftItemStack.asBukkitCopy(itemstack); diff --git a/patches/server/0005-Allow-opening-covered-chests.patch b/patches/server/0005-Allow-opening-covered-chests.patch new file mode 100644 index 000000000..58e7a32be --- /dev/null +++ b/patches/server/0005-Allow-opening-covered-chests.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cryptite +Date: Mon, 28 Feb 2022 08:45:30 -0600 +Subject: [PATCH] Allow opening covered chests + + +diff --git a/src/main/java/net/minecraft/world/level/block/ChestBlock.java b/src/main/java/net/minecraft/world/level/block/ChestBlock.java +index db726697b00afdee6078849fd224263483349912..cc415e4dd2093aa658817589f4f286c1a3ee63ad 100644 +--- a/src/main/java/net/minecraft/world/level/block/ChestBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/ChestBlock.java +@@ -356,9 +356,10 @@ public class ChestBlock extends AbstractChestBlock implements + } + + private static boolean isBlockedChestByBlock(BlockGetter world, BlockPos pos) { +- BlockPos blockposition1 = pos.above(); +- +- return world.getBlockState(blockposition1).isRedstoneConductor(world, blockposition1); ++ return false; ++// BlockPos blockposition1 = pos.above(); ++// ++// return world.getBlockState(blockposition1).isRedstoneConductor(world, blockposition1); + } + + private static boolean isCatSittingOnChest(LevelAccessor world, BlockPos pos) { +diff --git a/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java b/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java +index 16d677234616daec24e7250ff3e93aa3a83e9715..ee12ef106fa2dcbbac0161d96f383efbdd96bf94 100644 +--- a/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java +@@ -77,10 +77,10 @@ public class EnderChestBlock extends AbstractChestBlock i + PlayerEnderChestContainer playerEnderChestContainer = player.getEnderChestInventory(); + BlockEntity blockEntity = world.getBlockEntity(pos); + if (playerEnderChestContainer != null && blockEntity instanceof EnderChestBlockEntity) { +- BlockPos blockPos = pos.above(); +- if (world.getBlockState(blockPos).isRedstoneConductor(world, blockPos)) { +- return InteractionResult.sidedSuccess(world.isClientSide); +- } else if (world.isClientSide) { ++// BlockPos blockPos = pos.above(); ++// if (world.getBlockState(blockPos).isRedstoneConductor(world, blockPos)) { ++// return InteractionResult.sidedSuccess(world.isClientSide); ++ if (world.isClientSide) { + return InteractionResult.SUCCESS; + } else { + EnderChestBlockEntity enderChestBlockEntity = (EnderChestBlockEntity)blockEntity; diff --git a/patches/server/0006-Don-t-send-fire-packets-if-player-has-Fire-Resistanc.patch b/patches/server/0006-Don-t-send-fire-packets-if-player-has-Fire-Resistanc.patch new file mode 100644 index 000000000..de2bafe97 --- /dev/null +++ b/patches/server/0006-Don-t-send-fire-packets-if-player-has-Fire-Resistanc.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cryptite +Date: Mon, 28 Feb 2022 08:46:13 -0600 +Subject: [PATCH] Don't send fire packets if player has Fire Resistance + + +diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java +index 9ca080e2745686fc2e39485965ec54c5de0bae6e..d0daee81837fe64ac766e615d0a0bbb891de3306 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -776,7 +776,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i + + this.checkOutOfWorld(); + if (!this.level.isClientSide) { +- this.setSharedFlagOnFire(this.remainingFireTicks > 0); ++ if (this instanceof net.minecraft.world.entity.LivingEntity livingEntity) { ++ this.setSharedFlagOnFire(this.remainingFireTicks > 0 && !livingEntity.hasEffect(net.minecraft.world.effect.MobEffects.FIRE_RESISTANCE)); ++ } else { ++ this.setSharedFlagOnFire(this.remainingFireTicks > 0); ++ } + } + + this.firstTick = false;