mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-16 04:33:56 -07:00
Port to new mc-dev format.
This commit is contained in:
@@ -15,68 +15,75 @@ public class ItemSign extends Item {
|
||||
|
||||
public ItemSign(int i) {
|
||||
super(i);
|
||||
bc = 64;
|
||||
bb = 1;
|
||||
this.durability = 64;
|
||||
this.maxStackSize = 1;
|
||||
}
|
||||
|
||||
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
|
||||
public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
|
||||
if (l == 0) {
|
||||
return false;
|
||||
}
|
||||
if (!world.c(i, j, k).a()) {
|
||||
} else if (!world.getMaterial(i, j, k).isBuildable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// CraftBukkit - store the clicked block
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer craftServer = ((WorldServer) world).getServer();
|
||||
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
|
||||
|
||||
if (l == 1) {
|
||||
j++;
|
||||
}
|
||||
if (l == 2) {
|
||||
k--;
|
||||
}
|
||||
if (l == 3) {
|
||||
k++;
|
||||
}
|
||||
if (l == 4) {
|
||||
i--;
|
||||
}
|
||||
if (l == 5) {
|
||||
i++;
|
||||
}
|
||||
if (!Block.aD.a(world, i, j, k)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
// Signs
|
||||
Type eventType = Type.PLAYER_ITEM;
|
||||
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
|
||||
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
BlockFace blockface = CraftBlock.notchToBlockFace(1);
|
||||
|
||||
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
|
||||
craftServer.getPluginManager().callEvent(pie);
|
||||
|
||||
if (pie.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
if (l == 1) {
|
||||
world.b(i, j, k, Block.aD.bi, MathHelper.b((double) (((entityplayer.v + 180F) * 16F) / 360F) + 0.5D) & 0xf);
|
||||
} else {
|
||||
world.b(i, j, k, Block.aI.bi, l);
|
||||
}
|
||||
itemstack.a--;
|
||||
TileEntitySign tileentitysign = (TileEntitySign) world.m(i, j, k);
|
||||
// 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);
|
||||
//CraftBukkit end
|
||||
|
||||
if (tileentitysign != null) {
|
||||
entityplayer.a(tileentitysign);
|
||||
if (l == 1) {
|
||||
++j;
|
||||
}
|
||||
|
||||
if (l == 2) {
|
||||
--k;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user