3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-18 05:50:04 +01:00
Paper/src/main/java/net/minecraft/server/BlockFurnace.java

127 Zeilen
3.4 KiB
Java

2011-01-08 14:33:54 +01:00
package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
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;
// 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) {
2011-01-29 22:50:29 +01:00
super(i, Material.STONE);
this.a = flag;
this.textureId = 45;
2011-01-08 14:33:54 +01:00
}
public int a(int i, Random random) {
2011-01-29 22:50:29 +01:00
return Block.FURNACE.id;
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);
2011-01-29 22:50:29 +01:00
this.g(world, i, j, k);
2011-01-08 14:33:54 +01:00
}
private void g(World world, int i, int j, int k) {
2011-01-29 22:50:29 +01:00
int l = world.getTypeId(i, j, k - 1);
int i1 = world.getTypeId(i, j, k + 1);
int j1 = world.getTypeId(i - 1, j, k);
int k1 = world.getTypeId(i + 1, j, k);
byte b0 = 3;
2011-01-08 14:33:54 +01:00
if (Block.o[l] && !Block.o[i1]) {
2011-01-29 22:50:29 +01:00
b0 = 3;
2011-01-08 14:33:54 +01:00
}
2011-01-29 22:50:29 +01:00
2011-01-08 14:33:54 +01:00
if (Block.o[i1] && !Block.o[l]) {
2011-01-29 22:50:29 +01:00
b0 = 2;
2011-01-08 14:33:54 +01:00
}
2011-01-29 22:50:29 +01:00
2011-01-08 14:33:54 +01:00
if (Block.o[j1] && !Block.o[k1]) {
2011-01-29 22:50:29 +01:00
b0 = 5;
2011-01-08 14:33:54 +01:00
}
2011-01-29 22:50:29 +01:00
2011-01-08 14:33:54 +01:00
if (Block.o[k1] && !Block.o[j1]) {
2011-01-29 22:50:29 +01:00
b0 = 4;
2011-01-08 14:33:54 +01:00
}
2011-01-29 22:50:29 +01:00
world.c(i, j, k, b0);
2011-01-08 14:33:54 +01:00
}
public int a(int i) {
2011-01-29 22:50:29 +01:00
return i == 1 ? this.textureId + 17 : (i == 0 ? this.textureId + 17 : (i == 3 ? this.textureId - 1 : this.textureId));
2011-01-08 14:33:54 +01:00
}
2011-01-29 22:50:29 +01:00
public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.isStatic) {
2011-01-08 14:33:54 +01:00
return true;
} else {
// CraftBukkit start - Interact Furnace
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
2011-01-29 22:50:29 +01:00
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(event);
2011-01-29 22:50:29 +01:00
if (event.isCancelled()) {
return true;
}
// CraftBukkit end
2011-01-29 22:50:29 +01:00
TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.getTileEntity(i, j, k);
2011-01-08 14:33:54 +01:00
2011-01-29 22:50:29 +01:00
entityhuman.a(tileentityfurnace);
2011-01-08 14:33:54 +01:00
return true;
}
}
public static void a(boolean flag, World world, int i, int j, int k) {
2011-01-29 22:50:29 +01:00
int l = world.getData(i, j, k);
TileEntity tileentity = world.getTileEntity(i, j, k);
2011-01-08 14:33:54 +01:00
if (flag) {
2011-01-29 22:50:29 +01:00
world.e(i, j, k, Block.BURNING_FURNACE.id);
2011-01-08 14:33:54 +01:00
} else {
2011-01-29 22:50:29 +01:00
world.e(i, j, k, Block.FURNACE.id);
2011-01-08 14:33:54 +01:00
}
2011-01-29 22:50:29 +01:00
2011-01-14 14:31:10 +01:00
world.c(i, j, k, l);
2011-01-29 22:50:29 +01:00
world.setTileEntity(i, j, k, tileentity);
2011-01-08 14:33:54 +01:00
}
protected TileEntity a_() {
2011-01-29 22:50:29 +01:00
return new TileEntityFurnace();
2011-01-08 14:33:54 +01:00
}
public void a(World world, int i, int j, int k, EntityLiving entityliving) {
2011-01-29 22:50:29 +01:00
int l = MathHelper.b((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3;
2011-01-08 14:33:54 +01:00
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
}
2011-01-29 22:50:29 +01:00
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
}
2011-01-29 22:50:29 +01:00
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
}
2011-01-29 22:50:29 +01:00
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
}
}
}