2011-03-07 19:52:25 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-03-09 03:57:46 +01:00
|
|
|
// CraftBukkit start
|
2012-03-11 06:01:39 +01:00
|
|
|
import org.bukkit.craftbukkit.util.BlockStateListPopulator;
|
2012-03-09 03:57:46 +01:00
|
|
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
|
|
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|
|
|
// CraftBukkit end
|
2011-03-07 19:52:25 +01:00
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
public class BlockPumpkin extends BlockDirectional {
|
2011-03-07 19:52:25 +01:00
|
|
|
|
|
|
|
private boolean a;
|
|
|
|
|
|
|
|
protected BlockPumpkin(int i, int j, boolean flag) {
|
|
|
|
super(i, Material.PUMPKIN);
|
|
|
|
this.textureId = j;
|
|
|
|
this.a(true);
|
|
|
|
this.a = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(int i, int j) {
|
|
|
|
if (i == 1) {
|
|
|
|
return this.textureId;
|
|
|
|
} else if (i == 0) {
|
|
|
|
return this.textureId;
|
|
|
|
} else {
|
|
|
|
int k = this.textureId + 1 + 16;
|
|
|
|
|
|
|
|
if (this.a) {
|
|
|
|
++k;
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
return j == 2 && i == 2 ? k : (j == 3 && i == 5 ? k : (j == 0 && i == 3 ? k : (j == 1 && i == 4 ? k : this.textureId + 16)));
|
2011-03-07 19:52:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(int i) {
|
|
|
|
return i == 1 ? this.textureId : (i == 0 ? this.textureId : (i == 3 ? this.textureId + 1 + 16 : this.textureId + 16));
|
|
|
|
}
|
|
|
|
|
2012-01-28 07:59:59 +01:00
|
|
|
public void onPlace(World world, int i, int j, int k) {
|
|
|
|
super.onPlace(world, i, j, k);
|
2012-02-09 00:30:59 +01:00
|
|
|
if (world.suppressPhysics) return; // CraftBukkit
|
2011-11-20 09:01:14 +01:00
|
|
|
if (world.getTypeId(i, j - 1, k) == Block.SNOW_BLOCK.id && world.getTypeId(i, j - 2, k) == Block.SNOW_BLOCK.id) {
|
2012-03-11 11:28:03 +01:00
|
|
|
if (!world.isStatic) {
|
2012-03-11 06:01:39 +01:00
|
|
|
// 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);
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
EntitySnowman entitysnowman = new EntitySnowman(world);
|
|
|
|
|
|
|
|
entitysnowman.setPositionRotation((double) i + 0.5D, (double) j - 1.95D, (double) k + 0.5D, 0.0F, 0.0F);
|
2012-03-11 06:01:39 +01:00
|
|
|
if (world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) {
|
|
|
|
blockList.updateList();
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int l = 0; l < 120; ++l) {
|
|
|
|
world.a("snowshovel", (double) i + world.random.nextDouble(), (double) (j - 2) + world.random.nextDouble() * 2.5D, (double) k + world.random.nextDouble(), 0.0D, 0.0D, 0.0D);
|
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
} else if (world.getTypeId(i, j - 1, k) == Block.IRON_BLOCK.id && world.getTypeId(i, j - 2, k) == Block.IRON_BLOCK.id) {
|
|
|
|
boolean flag = world.getTypeId(i - 1, j - 1, k) == Block.IRON_BLOCK.id && world.getTypeId(i + 1, j - 1, k) == 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) {
|
2012-03-11 06:01:39 +01:00
|
|
|
// 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);
|
2012-03-01 11:49:23 +01:00
|
|
|
if (flag) {
|
2012-03-11 06:01:39 +01:00
|
|
|
blockList.setTypeId(i - 1, j - 1, k, 0);
|
|
|
|
blockList.setTypeId(i + 1, j - 1, k, 0);
|
2012-03-01 11:49:23 +01:00
|
|
|
} else {
|
2012-03-11 06:01:39 +01:00
|
|
|
blockList.setTypeId(i, j - 1, k - 1, 0);
|
|
|
|
blockList.setTypeId(i, j - 1, k + 1, 0);
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2012-03-11 06:01:39 +01:00
|
|
|
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);
|
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2012-03-11 06:01:39 +01:00
|
|
|
blockList.updateList();
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
2012-03-11 06:01:39 +01:00
|
|
|
// CraftBukkit end
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-03-07 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean canPlace(World world, int i, int j, int k) {
|
2011-03-07 19:52:25 +01:00
|
|
|
int l = world.getTypeId(i, j, k);
|
|
|
|
|
2011-06-30 00:02:25 +02:00
|
|
|
return (l == 0 || Block.byId[l].material.isReplacable()) && world.e(i, j - 1, k);
|
2011-03-07 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
|
2011-04-20 22:47:26 +02:00
|
|
|
int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 2.5D) & 3;
|
2011-03-07 19:52:25 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
world.setData(i, j, k, l);
|
2011-03-07 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start
|
2011-04-20 19:05:14 +02:00
|
|
|
public void doPhysics(World world, int i, int j, int k, int l) {
|
|
|
|
if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].isPowerSource()) {
|
2011-06-27 00:25:01 +02:00
|
|
|
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
|
2011-03-07 19:52:25 +01:00
|
|
|
int power = block.getBlockPower();
|
2011-03-31 22:40:00 +02:00
|
|
|
|
2011-03-07 19:52:25 +01:00
|
|
|
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, power, power);
|
2011-06-27 00:25:01 +02:00
|
|
|
world.getServer().getPluginManager().callEvent(eventRedstone);
|
2011-03-07 19:52:25 +01:00
|
|
|
}
|
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit end
|
2011-03-07 19:52:25 +01:00
|
|
|
}
|