From 10ad1bebe600c57ff775aca996ee414809d345ed Mon Sep 17 00:00:00 2001 From: Samsuik Date: Thu, 22 Aug 2024 20:35:35 +0100 Subject: [PATCH] Fix pressure plates using entity count when powering The entity count should only be used when recalculating the power. --- .../server/0018-Merge-Cannon-Entities.patch | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/patches/server/0018-Merge-Cannon-Entities.patch b/patches/server/0018-Merge-Cannon-Entities.patch index 41cd929..e607872 100644 --- a/patches/server/0018-Merge-Cannon-Entities.patch +++ b/patches/server/0018-Merge-Cannon-Entities.patch @@ -519,16 +519,54 @@ index 829a21a6da2de36f38cae9e1a3920fcc732eac0e..557472039d6451d5a8471ff56609ce49 protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura - sakura configuration files // Paper - create paper world config; Async-Anti-Xray: Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot +diff --git a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java +index 8b33e35c843e5c0b8988a2ef2a38a2673035292f..fa9fd01ec5b4c6bed86d49d8d24f05345687c8d2 100644 +--- a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java +@@ -89,7 +89,7 @@ public abstract class BasePressurePlateBlock extends Block { + } + + private void checkPressed(@Nullable Entity entity, Level world, BlockPos pos, BlockState state, int output) { +- int j = this.getSignalStrength(world, pos); ++ int j = this.getSignalStrength(world, pos, output == 0); // Sakura - cannon entity merging + boolean flag = output > 0; + boolean flag1 = j > 0; + +@@ -171,6 +171,12 @@ public abstract class BasePressurePlateBlock extends Block { + })); // CraftBukkit + } + ++ // Sakura start - cannon entity merging ++ protected int getSignalStrength(Level world, BlockPos pos, boolean entityInside) { ++ return this.getSignalStrength(world, pos); ++ } ++ // Sakura end - cannon entity merging ++ + protected abstract int getSignalStrength(Level world, BlockPos pos); + + protected abstract int getSignalForState(BlockState state); diff --git a/src/main/java/net/minecraft/world/level/block/WeightedPressurePlateBlock.java b/src/main/java/net/minecraft/world/level/block/WeightedPressurePlateBlock.java -index 05bf23bd9ec951840ffceb68638458de02ad0063..9a66120109e7be5620b36bbf7baa733aed1e44d1 100644 +index 05bf23bd9ec951840ffceb68638458de02ad0063..ade85fb5a26da9272d392f24318ce6360ceb6414 100644 --- a/src/main/java/net/minecraft/world/level/block/WeightedPressurePlateBlock.java +++ b/src/main/java/net/minecraft/world/level/block/WeightedPressurePlateBlock.java -@@ -57,7 +57,7 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock { +@@ -42,6 +42,11 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock { + + @Override + protected int getSignalStrength(Level world, BlockPos pos) { ++ // Sakura start - cannon entity merging ++ return this.getSignalStrength(world, pos, false); ++ } ++ protected final int getSignalStrength(Level world, BlockPos pos, boolean entityInside) { ++ // Sakura end - cannon entity merging + // CraftBukkit start + // int i = Math.min(getEntityCount(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class), this.maxWeight); + int i = 0; +@@ -57,7 +62,7 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock { // We only want to block turning the plate on if all events are cancelled if (!cancellable.isCancelled()) { - i++; -+ i += entity.getStacked(); // Sakura - cannon entity merging ++ i += !entityInside ? entity.getStacked() : 1; // Sakura - cannon entity merging } }