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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
--- a/net/minecraft/world/level/block/VineBlock.java
+++ b/net/minecraft/world/level/block/VineBlock.java
@@ -24,6 +24,7 @@
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
public class VineBlock extends Block {
public static final MapCodec<VineBlock> CODEC = simpleCodec(VineBlock::new);
@@ -188,19 +194,23 @@
BlockPos blockPos = pos.above();
if (random1.getAxis().isHorizontal() && !state.getValue(getPropertyForFace(random1))) {
if (this.canSpread(level, pos)) {
- BlockPos blockPos1 = pos.relative(random1);
- BlockState blockState = level.getBlockState(blockPos1);
- if (blockState.isAir()) {
- Direction clockWise = random1.getClockWise();
- Direction counterClockWise = random1.getCounterClockWise();
- boolean flag = state.getValue(getPropertyForFace(clockWise));
- boolean flag1 = state.getValue(getPropertyForFace(counterClockWise));
- BlockPos blockPos2 = blockPos1.relative(clockWise);
- BlockPos blockPos3 = blockPos1.relative(counterClockWise);
- if (flag && isAcceptableNeighbour(level, blockPos2, clockWise)) {
- level.setBlock(blockPos1, this.defaultBlockState().setValue(getPropertyForFace(clockWise), Boolean.valueOf(true)), 2);
- } else if (flag1 && isAcceptableNeighbour(level, blockPos3, counterClockWise)) {
- level.setBlock(blockPos1, this.defaultBlockState().setValue(getPropertyForFace(counterClockWise), Boolean.valueOf(true)), 2);
+ blockposition2 = pos.relative(enumdirection);
+ iblockdata1 = level.getBlockState(blockposition2);
+ if (iblockdata1.isAir()) {
+ enumdirection1 = enumdirection.getClockWise();
+ Direction enumdirection2 = enumdirection.getCounterClockWise();
+ boolean flag = (Boolean) state.getValue(getPropertyForFace(enumdirection1));
+ boolean flag1 = (Boolean) state.getValue(getPropertyForFace(enumdirection2));
+ BlockPos blockposition3 = blockposition2.relative(enumdirection1);
+ BlockPos blockposition4 = blockposition2.relative(enumdirection2);
+
+ // CraftBukkit start - Call BlockSpreadEvent
+ BlockPos source = pos;
+
+ if (flag && isAcceptableNeighbour(level, blockposition3, enumdirection1)) {
+ CraftEventFactory.handleBlockSpreadEvent(level, source, blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection1), true), 2);
+ } else if (flag1 && isAcceptableNeighbour(level, blockposition4, enumdirection2)) {
+ CraftEventFactory.handleBlockSpreadEvent(level, source, blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection2), true), 2);
} else {
Direction opposite = random1.getOpposite();
if (flag && level.isEmptyBlock(blockPos2) && isAcceptableNeighbour(level, pos.relative(clockWise), opposite)) {
@@ -210,15 +221,16 @@
} else if ((double)random.nextFloat() < 0.05 && isAcceptableNeighbour(level, blockPos1.above(), Direction.UP)) {
level.setBlock(blockPos1, this.defaultBlockState().setValue(UP, Boolean.valueOf(true)), 2);
}
+ // CraftBukkit end
}
- } else if (isAcceptableNeighbour(level, blockPos1, random1)) {
- level.setBlock(pos, state.setValue(getPropertyForFace(random1), Boolean.valueOf(true)), 2);
+ } else if (isAcceptableNeighbour(level, blockposition2, enumdirection)) {
+ CraftEventFactory.handleBlockGrowEvent(level, pos, (IBlockData) state.setValue(getPropertyForFace(enumdirection), true), 2); // CraftBukkit
}
}
} else {
- if (random1 == Direction.UP && pos.getY() < level.getMaxBuildHeight() - 1) {
- if (this.canSupportAtFace(level, pos, random1)) {
- level.setBlock(pos, state.setValue(UP, Boolean.valueOf(true)), 2);
+ if (enumdirection == Direction.UP && pos.getY() < level.getMaxBuildHeight() - 1) {
+ if (this.canSupportAtFace(level, pos, enumdirection)) {
+ CraftEventFactory.handleBlockGrowEvent(level, pos, (IBlockData) state.setValue(VineBlock.UP, true), 2); // CraftBukkit
return;
}
@@ -235,8 +250,8 @@
}
}
- if (this.hasHorizontalConnection(blockState1)) {
- level.setBlock(blockPos, blockState1, 2);
+ if (this.hasHorizontalConnection(iblockdata2)) {
+ CraftEventFactory.handleBlockSpreadEvent(level, pos, blockposition1, iblockdata2, 2); // CraftBukkit
}
return;
@@ -244,13 +259,14 @@
}
if (pos.getY() > level.getMinBuildHeight()) {
- BlockPos blockPos1 = pos.below();
- BlockState blockState = level.getBlockState(blockPos1);
- if (blockState.isAir() || blockState.is(this)) {
- BlockState blockState2 = blockState.isAir() ? this.defaultBlockState() : blockState;
- BlockState blockState3 = this.copyRandomFaces(state, blockState2, random);
- if (blockState2 != blockState3 && this.hasHorizontalConnection(blockState3)) {
- level.setBlock(blockPos1, blockState3, 2);
+ blockposition2 = pos.below();
+ iblockdata1 = level.getBlockState(blockposition2);
+ if (iblockdata1.isAir() || iblockdata1.is((Block) this)) {
+ IBlockData iblockdata3 = iblockdata1.isAir() ? this.defaultBlockState() : iblockdata1;
+ IBlockData iblockdata4 = this.copyRandomFaces(state, iblockdata3, random);
+
+ if (iblockdata3 != iblockdata4 && this.hasHorizontalConnection(iblockdata4)) {
+ CraftEventFactory.handleBlockSpreadEvent(level, pos, blockposition2, iblockdata4, 2); // CraftBukkit
}
}
}
|