2011-01-08 12:18:05 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-23 13:23:13 +01:00
|
|
|
import org.bukkit.block.BlockFace;
|
|
|
|
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:29:17 +01:00
|
|
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
2011-01-23 13:23:13 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2011-01-08 12:18:05 +01:00
|
|
|
import org.bukkit.event.Event.Type;
|
|
|
|
import org.bukkit.event.player.PlayerItemEvent;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-08 12:18:05 +01:00
|
|
|
|
|
|
|
public class ItemSign extends Item {
|
|
|
|
|
|
|
|
public ItemSign(int i) {
|
|
|
|
super(i);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.durability = 64;
|
|
|
|
this.maxStackSize = 1;
|
2011-01-08 12:18:05 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
|
2011-01-08 12:18:05 +01:00
|
|
|
if (l == 0) {
|
|
|
|
return false;
|
2011-01-29 22:50:29 +01:00
|
|
|
} else if (!world.getMaterial(i, j, k).isBuildable()) {
|
2011-01-08 12:18:05 +01:00
|
|
|
return false;
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
|
|
|
// CraftBukkit start - store the clicked block
|
|
|
|
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
|
|
|
CraftServer craftServer = ((WorldServer) world).getServer();
|
|
|
|
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
|
2011-02-02 00:32:18 +01:00
|
|
|
// CraftBukkit end
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (l == 1) {
|
|
|
|
++j;
|
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (l == 2) {
|
|
|
|
--k;
|
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (l == 3) {
|
|
|
|
++k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 4) {
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 5) {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Block.SIGN_POST.a(world, i, j, k)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
// CraftBukkit start
|
|
|
|
// Signs
|
|
|
|
Type eventType = Type.PLAYER_ITEM;
|
|
|
|
Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
|
|
|
|
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
|
|
|
|
BlockFace blockface = CraftBlock.notchToBlockFace(1);
|
|
|
|
|
|
|
|
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
|
|
|
|
craftServer.getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
if (l == 1) {
|
|
|
|
world.b(i, j, k, Block.SIGN_POST.id, MathHelper.b((double) ((entityhuman.yaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15);
|
|
|
|
} else {
|
|
|
|
world.b(i, j, k, Block.WALL_SIGN.id, l);
|
|
|
|
}
|
|
|
|
|
|
|
|
--itemstack.count;
|
|
|
|
TileEntitySign tileentitysign = (TileEntitySign) world.getTileEntity(i, j, k);
|
|
|
|
|
|
|
|
if (tileentitysign != null) {
|
|
|
|
entityhuman.a(tileentitysign);
|
|
|
|
}
|
2011-01-08 12:18:05 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-08 12:18:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|