mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Call BlockGrowEvent for missing blocks
Call the event for pitcher crops and sniffer egg
This commit is contained in:
parent
f1735f4440
commit
8ad0899aca
2 changed files with 18 additions and 3 deletions
|
@ -17,3 +17,12 @@
|
|||
if (bl) {
|
||||
this.grow(world, state, pos, 1);
|
||||
}
|
||||
@@ -141,7 +142,7 @@
|
||||
int i = Math.min(state.getValue(AGE) + amount, 4);
|
||||
if (this.canGrow(world, pos, state, i)) {
|
||||
BlockState blockState = state.setValue(AGE, Integer.valueOf(i));
|
||||
- world.setBlock(pos, blockState, 2);
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, pos, blockState, 2)) return; // Paper
|
||||
if (isDouble(i)) {
|
||||
world.setBlock(pos.above(), blockState.setValue(HALF, DoubleBlockHalf.UPPER), 3);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/net/minecraft/world/level/block/SnifferEggBlock.java
|
||||
+++ b/net/minecraft/world/level/block/SnifferEggBlock.java
|
||||
@@ -61,12 +61,26 @@
|
||||
@@ -61,12 +61,31 @@
|
||||
return this.getHatchLevel(state) == 2;
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,14 @@
|
|||
@Override
|
||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
if (!this.isReadyToHatch(state)) {
|
||||
+ // Paper start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, pos, state.setValue(HATCH, Integer.valueOf(this.getHatchLevel(state) + 1)), 2)) {
|
||||
+ this.rescheduleTick(world, pos);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
world.playSound(null, pos, SoundEvents.SNIFFER_EGG_CRACK, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
|
||||
world.setBlock(pos, state.setValue(HATCH, Integer.valueOf(this.getHatchLevel(state) + 1)), 2);
|
||||
- world.setBlock(pos, state.setValue(HATCH, Integer.valueOf(this.getHatchLevel(state) + 1)), 2);
|
||||
} else {
|
||||
+ // Paper start - Call BlockFadeEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, state.getFluidState().createLegacyBlock()).isCancelled()) {
|
||||
|
@ -27,7 +33,7 @@
|
|||
world.playSound(null, pos, SoundEvents.SNIFFER_EGG_HATCH, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
|
||||
world.destroyBlock(pos, false);
|
||||
Sniffer sniffer = EntityType.SNIFFER.create(world, EntitySpawnReason.BREEDING);
|
||||
@@ -74,7 +88,7 @@
|
||||
@@ -74,7 +93,7 @@
|
||||
Vec3 vec3 = pos.getCenter();
|
||||
sniffer.setBaby(true);
|
||||
sniffer.moveTo(vec3.x(), vec3.y(), vec3.z(), Mth.wrapDegrees(world.random.nextFloat() * 360.0F), 0.0F);
|
||||
|
|
Loading…
Reference in a new issue