readd chorus flower events

This commit is contained in:
Lulu13022002 2024-12-15 16:48:03 +01:00
parent 46eccd8c7d
commit da1947b2ad
No known key found for this signature in database
GPG key ID: 491C8F0B8ACDEB01

View file

@ -11,7 +11,7 @@
} else if (ageValue < 4) {
int i = random.nextInt(4);
if (flag1) {
@@ -112,8 +_,10 @@
@@ -112,18 +_,28 @@
if (level.isEmptyBlock(blockPos1)
&& level.isEmptyBlock(blockPos1.below())
&& allNeighborsEmpty(level, blockPos1, randomDirection.getOpposite())) {
@ -22,3 +22,33 @@
}
}
if (flag2) {
level.setBlock(pos, ChorusPlantBlock.getStateWithConnections(level, pos, this.plant.defaultBlockState()), 2);
} else {
+ // CraftBukkit start - add event
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, this.defaultBlockState().setValue(ChorusFlowerBlock.AGE, Integer.valueOf(5)), 2)) {
this.placeDeadFlower(level, pos);
+ }
+ // CraftBukkit end
}
} else {
+ // CraftBukkit start - add event
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, this.defaultBlockState().setValue(ChorusFlowerBlock.AGE, Integer.valueOf(5)), 2)) {
this.placeDeadFlower(level, pos);
+ }
+ // CraftBukkit end
}
}
}
@@ -261,6 +_,11 @@
protected void onProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile) {
BlockPos blockPos = hit.getBlockPos();
if (level instanceof ServerLevel serverLevel && projectile.mayInteract(serverLevel, blockPos) && projectile.mayBreak(serverLevel)) {
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, blockPos, state.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state
+ return;
+ }
+ // CraftBukkit end
level.destroyBlock(blockPos, true, projectile);
}
}