Fix BlockPlace
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user