drop duplicate block update

This commit is contained in:
Lulu13022002
2024-12-19 22:12:09 +01:00
parent 1f86b55302
commit 25a7793b9c
7 changed files with 18 additions and 21 deletions

View File

@@ -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
}
}

View File

@@ -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);
+ }

View File

@@ -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);

View File

@@ -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));
}