summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockPumpkin.patch
blob: 27c335cca9af60ffc1afe1f991afbd7375623aa7 (plain)
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
--- a/net/minecraft/server/BlockPumpkin.java
+++ b/net/minecraft/server/BlockPumpkin.java
@@ -3,6 +3,12 @@
 import com.google.common.base.Predicate;
 import javax.annotation.Nullable;
 
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.block.BlockRedstoneEvent;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
 public class BlockPumpkin extends BlockFacingHorizontal {
 
     private ShapeDetector snowGolemPart;
@@ -40,18 +46,25 @@
         int i;
         int j;
 
+        BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); // CraftBukkit - Use BlockStateListPopulator
         if (shapedetector_shapedetectorcollection != null) {
             for (i = 0; i < this.getDetectorSnowGolem().b(); ++i) {
                 ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(0, i, 0);
 
-                world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2);
+                // CraftBukkit start
+                // world.setTypeAndData(shapedetectorblock.d(), Blocks.AIR.getBlockData(), 2);
+                BlockPosition pos = shapedetectorblock.getPosition();
+                blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0);
+                // CraftBukkit end
             }
 
             EntitySnowman entitysnowman = new EntitySnowman(world);
             BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(0, 2, 0).getPosition();
 
             entitysnowman.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.05D, (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F);
-            world.addEntity(entitysnowman);
+            // CraftBukkit start
+            if (world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) {
+                blockList.updateList();
 
             for (j = 0; j < 120; ++j) {
                 world.addParticle(EnumParticle.SNOW_SHOVEL, (double) blockposition1.getX() + world.random.nextDouble(), (double) blockposition1.getY() + world.random.nextDouble() * 2.5D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]);
@@ -62,12 +75,17 @@
 
                 world.update(shapedetectorblock1.getPosition(), Blocks.AIR);
             }
+            } // CraftBukkit end
         } else {
             shapedetector_shapedetectorcollection = this.getDetectorIronGolem().a(world, blockposition);
             if (shapedetector_shapedetectorcollection != null) {
                 for (i = 0; i < this.getDetectorIronGolem().c(); ++i) {
                     for (int k = 0; k < this.getDetectorIronGolem().b(); ++k) {
-                        world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, k, 0).getPosition(), Blocks.AIR.getBlockData(), 2);
+                        // CraftBukkit start
+                        // world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, k, 0).getPosition(), Blocks.AIR.getBlockData(), 2);
+                        BlockPosition pos = shapedetector_shapedetectorcollection.a(i, k, 0).getPosition();
+                        blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0);
+                        // CraftBukkit end
                     }
                 }
 
@@ -76,7 +94,9 @@
 
                 entityirongolem.setPlayerCreated(true);
                 entityirongolem.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F);
-                world.addEntity(entityirongolem);
+            // CraftBukkit start
+            if (world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) {
+                blockList.updateList();
 
                 for (j = 0; j < 120; ++j) {
                     world.addParticle(EnumParticle.SNOWBALL, (double) blockposition2.getX() + world.random.nextDouble(), (double) blockposition2.getY() + world.random.nextDouble() * 3.9D, (double) blockposition2.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]);
@@ -90,6 +110,7 @@
                     }
                 }
             }
+            } // CraftBukkit end
         }
 
     }