diff options
author | Erik Broes <erikbroes@grum.nl> | 2011-03-21 00:25:26 +0100 |
---|---|---|
committer | Erik Broes <erikbroes@grum.nl> | 2011-03-21 00:31:13 +0100 |
commit | 324efa8224818aa04402203b1ccbb9839b44061e (patch) | |
tree | 8f5550f37a671bf2bce48f318354e518570bb97b /src/main/java/net/minecraft/server/ItemSign.java | |
parent | 0d2dc3902c1341be9bb1c51ab7e2be1a925788e3 (diff) | |
download | craftbukkit-324efa8224818aa04402203b1ccbb9839b44061e.tar craftbukkit-324efa8224818aa04402203b1ccbb9839b44061e.tar.gz craftbukkit-324efa8224818aa04402203b1ccbb9839b44061e.tar.lz craftbukkit-324efa8224818aa04402203b1ccbb9839b44061e.tar.xz craftbukkit-324efa8224818aa04402203b1ccbb9839b44061e.zip |
Fix BlockPlace
Diffstat (limited to 'src/main/java/net/minecraft/server/ItemSign.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ItemSign.java | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/src/main/java/net/minecraft/server/ItemSign.java b/src/main/java/net/minecraft/server/ItemSign.java index d2e6bcaa..959522c5 100644 --- a/src/main/java/net/minecraft/server/ItemSign.java +++ b/src/main/java/net/minecraft/server/ItemSign.java @@ -1,14 +1,10 @@ package net.minecraft.server; // CraftBukkit start -import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.craftbukkit.block.CraftBlock; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.entity.Player; -import org.bukkit.event.Event.Type; -import org.bukkit.event.player.PlayerItemEvent; +import org.bukkit.block.BlockState; +import org.bukkit.craftbukkit.block.CraftBlockState; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.block.BlockPlaceEvent; // CraftBukkit end public class ItemSign extends Item { @@ -25,11 +21,7 @@ public class ItemSign extends Item { } else if (!world.getMaterial(i, j, k).isBuildable()) { return false; } 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); - // CraftBukkit end + int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit; if (l == 1) { ++j; @@ -54,20 +46,7 @@ public class ItemSign extends Item { 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(l); - - PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface); - craftServer.getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return false; - } - // CraftBukkit end + BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit 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); @@ -75,6 +54,15 @@ public class ItemSign extends Item { world.b(i, j, k, Block.WALL_SIGN.id, l); } + // CraftBukkit start - sign + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, l == 1 ? Block.SIGN_POST : Block.WALL_SIGN); + + if (event.isCancelled() || !event.canBuild()) { + event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); + return false; + } + // CraftBukkit end + --itemstack.count; TileEntitySign tileentitysign = (TileEntitySign) world.getTileEntity(i, j, k); |