2011-01-08 14:33:54 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-23 13:23:13 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
2011-01-15 22:40:18 +01:00
|
|
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
2011-01-15 22:23:28 +01:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
2011-01-23 13:23:13 +01:00
|
|
|
import org.bukkit.entity.LivingEntity;
|
2011-01-08 14:33:54 +01:00
|
|
|
import org.bukkit.event.Event.Type;
|
|
|
|
import org.bukkit.event.block.BlockInteractEvent;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-08 14:33:54 +01:00
|
|
|
|
|
|
|
public class BlockFurnace extends BlockContainer {
|
|
|
|
|
|
|
|
private final boolean a;
|
|
|
|
|
|
|
|
protected BlockFurnace(int i, boolean flag) {
|
|
|
|
super(i, Material.d);
|
|
|
|
a = flag;
|
2011-01-14 14:31:10 +01:00
|
|
|
bh = 45;
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int a(int i, Random random) {
|
2011-01-14 14:31:10 +01:00
|
|
|
return Block.aB.bi;
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void e(World world, int i, int j, int k) {
|
|
|
|
super.e(world, i, j, k);
|
|
|
|
g(world, i, j, k);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void g(World world, int i, int j, int k) {
|
|
|
|
int l = world.a(i, j, k - 1);
|
|
|
|
int i1 = world.a(i, j, k + 1);
|
|
|
|
int j1 = world.a(i - 1, j, k);
|
|
|
|
int k1 = world.a(i + 1, j, k);
|
|
|
|
byte byte0 = 3;
|
|
|
|
|
|
|
|
if (Block.o[l] && !Block.o[i1]) {
|
|
|
|
byte0 = 3;
|
|
|
|
}
|
|
|
|
if (Block.o[i1] && !Block.o[l]) {
|
|
|
|
byte0 = 2;
|
|
|
|
}
|
|
|
|
if (Block.o[j1] && !Block.o[k1]) {
|
|
|
|
byte0 = 5;
|
|
|
|
}
|
|
|
|
if (Block.o[k1] && !Block.o[j1]) {
|
|
|
|
byte0 = 4;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
world.c(i, j, k, ((int) (byte0)));
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int a(int i) {
|
|
|
|
if (i == 1) {
|
2011-01-14 14:31:10 +01:00
|
|
|
return bh + 17;
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
if (i == 0) {
|
2011-01-14 14:31:10 +01:00
|
|
|
return bh + 17;
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
if (i == 3) {
|
2011-01-14 14:31:10 +01:00
|
|
|
return bh - 1;
|
2011-01-08 14:33:54 +01:00
|
|
|
} else {
|
2011-01-14 14:31:10 +01:00
|
|
|
return bh;
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) {
|
|
|
|
if (world.z) {
|
|
|
|
return true;
|
|
|
|
} else {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start - Interact Furnace
|
2011-01-23 13:23:13 +01:00
|
|
|
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
|
|
|
CraftServer server = ((WorldServer) world).getServer();
|
|
|
|
Type eventType = Type.BLOCK_INTERACT;
|
|
|
|
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
|
|
|
LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
|
|
|
|
|
|
|
|
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
|
|
|
|
server.getPluginManager().callEvent(bie);
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-01-23 13:23:13 +01:00
|
|
|
if (bie.isCancelled()) {
|
|
|
|
return true;
|
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.m(i, j, k);
|
2011-01-08 14:33:54 +01:00
|
|
|
|
|
|
|
entityplayer.a(tileentityfurnace);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void a(boolean flag, World world, int i, int j, int k) {
|
|
|
|
int l = world.b(i, j, k);
|
2011-01-14 14:31:10 +01:00
|
|
|
TileEntity tileentity = world.m(i, j, k);
|
2011-01-08 14:33:54 +01:00
|
|
|
|
|
|
|
if (flag) {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.e(i, j, k, Block.aC.bi);
|
2011-01-08 14:33:54 +01:00
|
|
|
} else {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.e(i, j, k, Block.aB.bi);
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
world.c(i, j, k, l);
|
2011-01-08 14:33:54 +01:00
|
|
|
world.a(i, j, k, tileentity);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected TileEntity a_() {
|
2011-01-11 09:25:13 +01:00
|
|
|
return ((TileEntity) (new TileEntityFurnace()));
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(World world, int i, int j, int k, EntityLiving entityliving) {
|
|
|
|
int l = MathHelper.b((double) ((entityliving.v * 4F) / 360F) + 0.5D) & 3;
|
|
|
|
|
|
|
|
if (l == 0) {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.c(i, j, k, 2);
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
if (l == 1) {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.c(i, j, k, 5);
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
if (l == 2) {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.c(i, j, k, 3);
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
if (l == 3) {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.c(i, j, k, 4);
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|