From 25a7793b9c3c07da9307d0d36af4d9bd15fde302 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:12:09 +0100 Subject: [PATCH] drop duplicate block update --- .../0006-Entity-Activation-Range-2.0.patch | 4 ++-- ...014-Check-distance-in-entity-interactions.patch | 4 ++-- .../features/0022-Lag-compensation-ticks.patch | 14 +++++++------- .../minecraft/world/entity/LivingEntity.java.patch | 8 +++----- .../level/block/BuddingAmethystBlock.java.patch | 2 +- .../world/level/block/CactusBlock.java.patch | 4 ++-- .../level/block/SweetBerryBushBlock.java.patch | 3 +-- 7 files changed, 18 insertions(+), 21 deletions(-) diff --git a/paper-server/patches/features/0006-Entity-Activation-Range-2.0.patch b/paper-server/patches/features/0006-Entity-Activation-Range-2.0.patch index a949aa3137..e4ddc69055 100644 --- a/paper-server/patches/features/0006-Entity-Activation-Range-2.0.patch +++ b/paper-server/patches/features/0006-Entity-Activation-Range-2.0.patch @@ -529,10 +529,10 @@ index 61b779fc48d88a2ba0cb7c289e7c031877bac61b..32ca912230a5999ea244cdf1c5c54855 movement = this.maybeBackOffFromEdge(movement, type); Vec3 vec3 = this.collide(movement); diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index fa67721bc0aa2d5b920d691f34d81d0a1feec202..c853c5ff5a9422b9a17be34102f80348ca89cad6 100644 +index e76889ab9766294e64afa2b89006d2efd218027c..9bf5addb07f40cc50e80a46c0ee7944e938620fb 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3089,6 +3089,14 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3086,6 +3086,14 @@ public abstract class LivingEntity extends Entity implements Attackable { return false; } diff --git a/paper-server/patches/features/0014-Check-distance-in-entity-interactions.patch b/paper-server/patches/features/0014-Check-distance-in-entity-interactions.patch index 45b999e2f7..39272633a7 100644 --- a/paper-server/patches/features/0014-Check-distance-in-entity-interactions.patch +++ b/paper-server/patches/features/0014-Check-distance-in-entity-interactions.patch @@ -17,7 +17,7 @@ index ae1d53cefb9cede1c93cb8b22122a4a2d2d9a40c..80a7a85e1a03a1ca406259207e1ae3b9 public static Collector, ?, Map> toMap() { return Collectors.toMap(Entry::getKey, Entry::getValue); diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 9de400977ec33e485e87cdf1cf145588527e1e10..c83aeaf4e50dd7290c608dfe260a3bd2404b6004 100644 +index 9bf5addb07f40cc50e80a46c0ee7944e938620fb..635e6e49483194c43b0ab47b5e1bacfe84613c3a 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -1385,7 +1385,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -44,7 +44,7 @@ index 9de400977ec33e485e87cdf1cf145588527e1e10..c83aeaf4e50dd7290c608dfe260a3bd2 this.knockback(0.4F, d, d1, damageSource.getDirectEntity(), damageSource.getDirectEntity() == null ? io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.DAMAGE : io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events if (!flag) { -@@ -2345,7 +2353,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2342,7 +2350,7 @@ public abstract class LivingEntity extends Entity implements Attackable { this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING)); Entity entity = damageSource.getDirectEntity(); diff --git a/paper-server/patches/features/0022-Lag-compensation-ticks.patch b/paper-server/patches/features/0022-Lag-compensation-ticks.patch index 1d23e4ff9d..65659dc68f 100644 --- a/paper-server/patches/features/0022-Lag-compensation-ticks.patch +++ b/paper-server/patches/features/0022-Lag-compensation-ticks.patch @@ -49,7 +49,7 @@ index 4d20bda4cba578c47216d450c99389b744a59008..47b7d487467225505e3f20cea92e1143 + // Paper end - lag compensation } diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java -index 9fdb825be2b04a5806bbb3d39948bad0863e7ae5..261445152f741b68f91cd8fc1eac17275ee52427 100644 +index fd7ad2b1bffe3880def0f0c9a7ed8de5088ecd71..e753849002b48d4a498dc93349e331bc26d39aff 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java @@ -111,7 +111,7 @@ public class ServerPlayerGameMode { @@ -62,10 +62,10 @@ index 9fdb825be2b04a5806bbb3d39948bad0863e7ae5..261445152f741b68f91cd8fc1eac1727 BlockState blockState = this.level.getBlockStateIfLoaded(this.delayedDestroyPos); // Paper - Don't allow digging into unloaded chunks if (blockState == null || blockState.isAir()) { // Paper - Don't allow digging into unloaded chunks diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 228ceecd5ab9040dcc6710d1cdd0feda2f901016..884e1f8f72cc31520ba0c54af17be3879918a5d3 100644 +index 635e6e49483194c43b0ab47b5e1bacfe84613c3a..195e1151f7b2a32d6c4eb67edd1952e38f58b266 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3831,6 +3831,10 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3828,6 +3828,10 @@ public abstract class LivingEntity extends Entity implements Attackable { this.resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer); } // Paper end - Properly cancel usable items @@ -76,7 +76,7 @@ index 228ceecd5ab9040dcc6710d1cdd0feda2f901016..884e1f8f72cc31520ba0c54af17be387 private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3844,7 +3848,12 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3841,7 +3845,12 @@ public abstract class LivingEntity extends Entity implements Attackable { protected void updateUsingItem(ItemStack usingItem) { usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -90,7 +90,7 @@ index 228ceecd5ab9040dcc6710d1cdd0feda2f901016..884e1f8f72cc31520ba0c54af17be387 this.completeUsingItem(); } } -@@ -3878,7 +3887,10 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3875,7 +3884,10 @@ public abstract class LivingEntity extends Entity implements Attackable { ItemStack itemInHand = this.getItemInHand(hand); if (!itemInHand.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack this.useItem = itemInHand; @@ -102,7 +102,7 @@ index 228ceecd5ab9040dcc6710d1cdd0feda2f901016..884e1f8f72cc31520ba0c54af17be387 if (!this.level().isClientSide) { this.setLivingEntityFlag(1, true); this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND); -@@ -3902,7 +3914,10 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3899,7 +3911,10 @@ public abstract class LivingEntity extends Entity implements Attackable { } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -114,7 +114,7 @@ index 228ceecd5ab9040dcc6710d1cdd0feda2f901016..884e1f8f72cc31520ba0c54af17be387 } } } -@@ -4026,7 +4041,10 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -4023,7 +4038,10 @@ public abstract class LivingEntity extends Entity implements Attackable { } this.useItem = ItemStack.EMPTY; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index ea57a78e0b..df1aedb289 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -692,7 +692,7 @@ if (killCredit != null) { killCredit.awardKillScore(this, damageSource); } -@@ -1373,68 +_,145 @@ +@@ -1373,68 +_,142 @@ } if (!this.level().isClientSide && this.hasCustomName()) { @@ -764,11 +764,9 @@ BlockPos blockPos = this.blockPosition(); BlockState blockState = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level().getBlockState(blockPos).isAir() && blockState.canSurvive(this.level(), blockPos)) { - this.level().setBlock(blockPos, blockState, 3); +- this.level().setBlock(blockPos, blockState, 3); - var6 = true; -+ // CraftBukkit start - call EntityBlockFormEvent for Wither Rose -+ var6 = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level(), blockPos, blockState, 3, this); -+ // CraftBukkit end ++ var6 = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level(), blockPos, blockState, 3, this); // CraftBukkit - call EntityBlockFormEvent for Wither Rose } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BuddingAmethystBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BuddingAmethystBlock.java.patch index e6ad3e837b..81ceb891c5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BuddingAmethystBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BuddingAmethystBlock.java.patch @@ -7,7 +7,7 @@ - level.setBlockAndUpdate(blockPos, blockState1); + // Paper start - Have Amethyst throw both spread and grow events + if (block == Blocks.SMALL_AMETHYST_BUD) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, blockState1); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, blockState1, 3); // CraftBukkit + } else { + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, blockPos, blockState1); + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch index 05f47c53f7..af19e96da9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CactusBlock.java +++ b/net/minecraft/world/level/block/CactusBlock.java -@@ -56,14 +_,17 @@ +@@ -56,14 +_,16 @@ i++; } @@ -8,11 +8,11 @@ + if (i < level.paperConfig().maxGrowthHeight.cactus) { // Paper - Configurable cactus/bamboo/reed growth height int ageValue = state.getValue(AGE); - if (ageValue == 15) { +- level.setBlockAndUpdate(blockPos, this.defaultBlockState()); + + int modifier = level.spigotConfig.cactusModifier; // Spigot - SPIGOT-7159: Better modifier resolution + if (ageValue >= 15 || (modifier != 100 && random.nextFloat() < (modifier / (100.0f * 16)))) { // Spigot - SPIGOT-7159: Better modifier + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, blockPos, this.defaultBlockState()); // CraftBukkit - level.setBlockAndUpdate(blockPos, this.defaultBlockState()); BlockState blockState = state.setValue(AGE, Integer.valueOf(0)); level.setBlock(pos, blockState, 4); level.neighborChanged(blockState, blockPos, this, null, false); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch index 8b96fa4a77..a228885132 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SweetBerryBushBlock.java +++ b/net/minecraft/world/level/block/SweetBerryBushBlock.java -@@ -68,15 +_,17 @@ +@@ -68,15 +_,16 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { int ageValue = state.getValue(AGE); @@ -8,7 +8,6 @@ + if (ageValue < 3 && random.nextFloat() < (level.spigotConfig.sweetBerryModifier / (100.0f * 5)) && level.getRawBrightness(pos.above(), 0) >= 9) { // Spigot - SPIGOT-7159: Better modifier resolution BlockState blockState = state.setValue(AGE, Integer.valueOf(ageValue + 1)); - level.setBlock(pos, blockState, 2); -+ // level.setBlock(pos, blockState, 2); + if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, blockState, 2)) return; // CraftBukkit level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(blockState)); }