diff --git a/src/main/java/net/minecraft/server/BlockPumpkin.java b/src/main/java/net/minecraft/server/BlockPumpkin.java index 6c34d3dab2..cb7824e53d 100644 --- a/src/main/java/net/minecraft/server/BlockPumpkin.java +++ b/src/main/java/net/minecraft/server/BlockPumpkin.java @@ -1,6 +1,7 @@ package net.minecraft.server; // CraftBukkit start +import org.bukkit.craftbukkit.util.BlockStateListPopulator; import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit end @@ -41,16 +42,20 @@ public class BlockPumpkin extends BlockDirectional { if (world.suppressPhysics) return; // CraftBukkit if (world.getTypeId(i, j - 1, k) == Block.SNOW_BLOCK.id && world.getTypeId(i, j - 2, k) == Block.SNOW_BLOCK.id) { if (!world.isStatic && world.getServer().getServer().spawnAnimals) { // CraftBukkit - make snowmen obey spawning rules - world.setRawTypeId(i, j, k, 0); - world.setRawTypeId(i, j - 1, k, 0); - world.setRawTypeId(i, j - 2, k, 0); + // CraftBukkit start - Use BlockStateListPopulator + BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); + + blockList.setTypeId(i, j, k, 0); + blockList.setTypeId(i, j - 1, k, 0); + blockList.setTypeId(i, j - 2, k, 0); + EntitySnowman entitysnowman = new EntitySnowman(world); entitysnowman.setPositionRotation((double) i + 0.5D, (double) j - 1.95D, (double) k + 0.5D, 0.0F, 0.0F); - world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN); // CraftBukkit - world.update(i, j, k, 0); - world.update(i, j - 1, k, 0); - world.update(i, j - 2, k, 0); + if (world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) { + blockList.updateList(); + } + // CraftBukkit end } for (int l = 0; l < 120; ++l) { @@ -61,37 +66,32 @@ public class BlockPumpkin extends BlockDirectional { boolean flag1 = world.getTypeId(i, j - 1, k - 1) == Block.IRON_BLOCK.id && world.getTypeId(i, j - 1, k + 1) == Block.IRON_BLOCK.id; if (flag || flag1) { - world.setRawTypeId(i, j, k, 0); - world.setRawTypeId(i, j - 1, k, 0); - world.setRawTypeId(i, j - 2, k, 0); + // CraftBukkit start - Use BlockStateListPopulator + BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); + + blockList.setTypeId(i, j, k, 0); + blockList.setTypeId(i, j - 1, k, 0); + blockList.setTypeId(i, j - 2, k, 0); if (flag) { - world.setRawTypeId(i - 1, j - 1, k, 0); - world.setRawTypeId(i + 1, j - 1, k, 0); + blockList.setTypeId(i - 1, j - 1, k, 0); + blockList.setTypeId(i + 1, j - 1, k, 0); } else { - world.setRawTypeId(i, j - 1, k - 1, 0); - world.setRawTypeId(i, j - 1, k + 1, 0); + blockList.setTypeId(i, j - 1, k - 1, 0); + blockList.setTypeId(i, j - 1, k + 1, 0); } EntityIronGolem entityirongolem = new EntityIronGolem(world); entityirongolem.b(true); entityirongolem.setPositionRotation((double) i + 0.5D, (double) j - 1.95D, (double) k + 0.5D, 0.0F, 0.0F); - world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM); + if (world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) { + for (int i1 = 0; i1 < 120; ++i1) { + world.a("snowballpoof", (double) i + world.random.nextDouble(), (double) (j - 2) + world.random.nextDouble() * 3.9D, (double) k + world.random.nextDouble(), 0.0D, 0.0D, 0.0D); + } - for (int i1 = 0; i1 < 120; ++i1) { - world.a("snowballpoof", (double) i + world.random.nextDouble(), (double) (j - 2) + world.random.nextDouble() * 3.9D, (double) k + world.random.nextDouble(), 0.0D, 0.0D, 0.0D); - } - - world.update(i, j, k, 0); - world.update(i, j - 1, k, 0); - world.update(i, j - 2, k, 0); - if (flag) { - world.update(i - 1, j - 1, k, 0); - world.update(i + 1, j - 1, k, 0); - } else { - world.update(i, j - 1, k - 1, 0); - world.update(i, j - 1, k + 1, 0); + blockList.updateList(); } + // CraftBukkit end } } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java b/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java index eb83172e86..2c27517386 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java +++ b/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.util; +import java.util.ArrayList; import java.util.List; import org.bukkit.World; import org.bukkit.block.BlockState; @@ -8,6 +9,10 @@ public class BlockStateListPopulator { private final World world; private final List list; + public BlockStateListPopulator(World world) { + this(world, new ArrayList()); + } + public BlockStateListPopulator(World world, List list) { this.world = world; this.list = list; @@ -19,6 +24,12 @@ public class BlockStateListPopulator { list.add(state); } + public void updateList() { + for (BlockState state : list) { + state.update(true); + } + } + public List getList() { return list; }