1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
--- a/net/minecraft/world/level/block/StemBlock.java
+++ b/net/minecraft/world/level/block/StemBlock.java
@@ -26,6 +26,7 @@
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
public class StemBlock extends BushBlock implements BonemealableBlock {
public static final MapCodec<StemBlock> CODEC = RecordCodecBuilder.mapCodec(
@@ -84,8 +79,8 @@
if (random.nextInt((int)(25.0F / growthSpeed) + 1) == 0) {
int i = state.getValue(AGE);
if (i < 7) {
- state = state.setValue(AGE, Integer.valueOf(i + 1));
- level.setBlock(pos, state, 2);
+ state = (IBlockData) state.setValue(StemBlock.AGE, i + 1);
+ CraftEventFactory.handleBlockGrowEvent(level, pos, state, 2); // CraftBukkit
} else {
Direction randomDirection = Direction.Plane.HORIZONTAL.getRandomDirection(random);
BlockPos blockPos = pos.relative(randomDirection);
@@ -95,8 +92,12 @@
Optional<Block> optional = registry.getOptional(this.fruit);
Optional<Block> optional1 = registry.getOptional(this.attachedStem);
if (optional.isPresent() && optional1.isPresent()) {
- level.setBlockAndUpdate(blockPos, optional.get().defaultBlockState());
- level.setBlockAndUpdate(pos, optional1.get().defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, randomDirection));
+ // CraftBukkit start
+ if (!CraftEventFactory.handleBlockGrowEvent(level, blockposition1, ((Block) optional.get()).defaultBlockState())) {
+ return;
+ }
+ // CraftBukkit end
+ level.setBlockAndUpdate(pos, (IBlockData) ((Block) optional1.get()).defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, enumdirection));
}
}
}
@@ -120,12 +122,13 @@
}
@Override
- public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
- int min = Math.min(7, state.getValue(AGE) + Mth.nextInt(level.random, 2, 5));
- BlockState blockState = state.setValue(AGE, Integer.valueOf(min));
- level.setBlock(pos, blockState, 2);
- if (min == 7) {
- blockState.randomTick(level, pos, level.random);
+ public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, IBlockData state) {
+ int i = Math.min(7, (Integer) state.getValue(StemBlock.AGE) + Mth.nextInt(level.random, 2, 5));
+ IBlockData iblockdata1 = (IBlockData) state.setValue(StemBlock.AGE, i);
+
+ CraftEventFactory.handleBlockGrowEvent(level, pos, iblockdata1, 2); // CraftBukkit
+ if (i == 7) {
+ iblockdata1.randomTick(level, pos, level.random);
}
}
|