Paper/nms-patches/BlockWitherSkull.patch
2020-06-25 10:00:00 +10:00

65 lines
3.5 KiB
Diff

--- 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 {
@Nullable
@@ -26,6 +31,7 @@
}
public static void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) {
+ if (world.captureBlockStates) return; // CraftBukkit
if (!world.isClientSide) {
IBlockData iblockdata = tileentityskull.getBlock();
boolean flag = iblockdata.a(Blocks.WITHER_SKELETON_SKULL) || iblockdata.a(Blocks.WITHER_SKELETON_WALL_SKULL);
@@ -35,12 +41,14 @@
ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition);
if (shapedetector_shapedetectorcollection != null) {
+ // CraftBukkit start - Use BlockStateListPopulator
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world);
for (int i = 0; i < shapedetector.c(); ++i) {
for (int j = 0; j < shapedetector.b(); ++j) {
ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(i, j, 0);
- world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2);
- world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a()));
+ blockList.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
+ // world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); // CraftBukkit
}
}
@@ -50,6 +58,15 @@
entitywither.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F);
entitywither.aH = shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F;
entitywither.beginSpawnSequence();
+ // CraftBukkit start
+ if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
+ return;
+ }
+ for (BlockPosition pos : blockList.getBlocks()) {
+ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos)));
+ }
+ blockList.updateList();
+ // CraftBukkit end
Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator();
while (iterator.hasNext()) {
@@ -58,7 +75,7 @@
CriterionTriggers.n.a(entityplayer, (Entity) entitywither);
}
- world.addEntity(entitywither);
+ // world.addEntity(entitywither); // CraftBukkit - moved up
for (int k = 0; k < shapedetector.c(); ++k) {
for (int l = 0; l < shapedetector.b(); ++l) {