13
0
geforkt von Mirrors/Paper

Only remove blocks when golem is successfully spawned. Fixes BUKKIT-1094

Dieser Commit ist enthalten in:
feildmaster 2012-03-10 23:01:39 -06:00 committet von EvilSeph
Ursprung 433efec68f
Commit 4545336fdf
2 geänderte Dateien mit 39 neuen und 28 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,7 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.util.BlockStateListPopulator;
import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
// CraftBukkit end // CraftBukkit end
@ -41,16 +42,20 @@ public class BlockPumpkin extends BlockDirectional {
if (world.suppressPhysics) return; // CraftBukkit 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.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 if (!world.isStatic && world.getServer().getServer().spawnAnimals) { // CraftBukkit - make snowmen obey spawning rules
world.setRawTypeId(i, j, k, 0); // CraftBukkit start - Use BlockStateListPopulator
world.setRawTypeId(i, j - 1, k, 0); BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld());
world.setRawTypeId(i, j - 2, k, 0);
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 entitysnowman = new EntitySnowman(world);
entitysnowman.setPositionRotation((double) i + 0.5D, (double) j - 1.95D, (double) k + 0.5D, 0.0F, 0.0F); 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 if (world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) {
world.update(i, j, k, 0); blockList.updateList();
world.update(i, j - 1, k, 0); }
world.update(i, j - 2, k, 0); // CraftBukkit end
} }
for (int l = 0; l < 120; ++l) { 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; 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) { if (flag || flag1) {
world.setRawTypeId(i, j, k, 0); // CraftBukkit start - Use BlockStateListPopulator
world.setRawTypeId(i, j - 1, k, 0); BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld());
world.setRawTypeId(i, j - 2, k, 0);
blockList.setTypeId(i, j, k, 0);
blockList.setTypeId(i, j - 1, k, 0);
blockList.setTypeId(i, j - 2, k, 0);
if (flag) { if (flag) {
world.setRawTypeId(i - 1, j - 1, k, 0); blockList.setTypeId(i - 1, j - 1, k, 0);
world.setRawTypeId(i + 1, j - 1, k, 0); blockList.setTypeId(i + 1, j - 1, k, 0);
} else { } else {
world.setRawTypeId(i, j - 1, k - 1, 0); blockList.setTypeId(i, j - 1, k - 1, 0);
world.setRawTypeId(i, j - 1, k + 1, 0); blockList.setTypeId(i, j - 1, k + 1, 0);
} }
EntityIronGolem entityirongolem = new EntityIronGolem(world); EntityIronGolem entityirongolem = new EntityIronGolem(world);
entityirongolem.b(true); entityirongolem.b(true);
entityirongolem.setPositionRotation((double) i + 0.5D, (double) j - 1.95D, (double) k + 0.5D, 0.0F, 0.0F); 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) { blockList.updateList();
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);
} }
// CraftBukkit end
} }
} }
} }

Datei anzeigen

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.util; package org.bukkit.craftbukkit.util;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -8,6 +9,10 @@ public class BlockStateListPopulator {
private final World world; private final World world;
private final List<BlockState> list; private final List<BlockState> list;
public BlockStateListPopulator(World world) {
this(world, new ArrayList<BlockState>());
}
public BlockStateListPopulator(World world, List<BlockState> list) { public BlockStateListPopulator(World world, List<BlockState> list) {
this.world = world; this.world = world;
this.list = list; this.list = list;
@ -19,6 +24,12 @@ public class BlockStateListPopulator {
list.add(state); list.add(state);
} }
public void updateList() {
for (BlockState state : list) {
state.update(true);
}
}
public List<BlockState> getList() { public List<BlockState> getList() {
return list; return list;
} }