summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockWitherSkull.patch
blob: bc921119faec1c4ad4dde738ead81502ef3603f0 (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
--- a/net/minecraft/server/BlockWitherSkull.java
+++ b/net/minecraft/server/BlockWitherSkull.java
@@ -3,6 +3,11 @@
 import java.util.Iterator;
 import javax.annotation.Nullable;
 
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
 public class BlockWitherSkull extends BlockSkull {
 
     private static ShapeDetector c;
@@ -23,6 +28,7 @@
     }
 
     public static void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) {
+        if (world.captureBlockStates) return; // CraftBukkit
         Block block = tileentityskull.getBlock().getBlock();
         boolean flag = block == Blocks.WITHER_SKELETON_SKULL || block == Blocks.WITHER_SKELETON_WALL_SKULL;
 
@@ -31,6 +37,8 @@
             ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition);
 
             if (shapedetector_shapedetectorcollection != null) {
+                // CraftBukkit start - Use BlockStateListPopulator
+                BlockStateListPopulator blockList = new BlockStateListPopulator(world);
                 int i;
 
                 for (i = 0; i < 3; ++i) {
@@ -39,7 +47,7 @@
 
                 for (i = 0; i < shapedetector.c(); ++i) {
                     for (int j = 0; j < shapedetector.b(); ++j) {
-                        world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, j, 0).getPosition(), Blocks.AIR.getBlockData(), 2);
+                        blockList.setTypeAndData(shapedetector_shapedetectorcollection.a(i, j, 0).getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
                     }
                 }
 
@@ -50,6 +58,16 @@
                 entitywither.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.55D, (double) blockposition2.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F);
                 entitywither.aQ = shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F;
                 entitywither.l();
+                // CraftBukkit start
+                if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
+                    // Restore drop status from above
+                    for (i = 0; i < 3; ++i) {
+                        TileEntitySkull.setShouldDrop(world, shapedetector_shapedetectorcollection.a(i, 0, 0).getPosition(), true);
+                    }
+                    return;
+                }
+                blockList.updateList();
+                // CraftBukkit end
                 Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator();
 
                 while (iterator.hasNext()) {
@@ -58,7 +76,7 @@
                     CriterionTriggers.n.a(entityplayer, (Entity) entitywither);
                 }
 
-                world.addEntity(entitywither);
+                // world.addEntity(entitywither); // CraftBukkit - moved up
 
                 int k;