public void onBlockPlacedBy( World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { TileEntity te = world.getTileEntity(x, y, z); if (te != null && te instanceof TileEntityMannequin) { int l = MathHelper.floor_double((double) (player.rotationYaw * 16.0F / 360.0F) + 0.5D) & 15; ((TileEntityMannequin) te).setRotation(l); if (stack.hasTagCompound()) { NBTTagCompound compound = stack.getTagCompound(); GameProfile gameProfile = null; if (compound.hasKey(TAG_OWNER, 10)) { gameProfile = NBTUtil.func_152459_a(compound.getCompoundTag(TAG_OWNER)); ((TileEntityMannequin) te).setGameProfile(gameProfile); } } } }
@Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { ItemStack stack = new ItemStack(ModBlocks.doll, 1); int meta = world.getBlockMetadata(x, y, z); int yOffset = 0; if (meta == 1) { yOffset = -1; } TileEntity te = world.getTileEntity(x, y + yOffset, z); ; if (te != null && te instanceof TileEntityMannequin) { TileEntityMannequin teMan = (TileEntityMannequin) te; if (teMan.getGameProfile() != null) { NBTTagCompound profileTag = new NBTTagCompound(); NBTUtil.func_152460_a(profileTag, teMan.getGameProfile()); stack.setTagCompound(new NBTTagCompound()); stack.getTagCompound().setTag(TAG_OWNER, profileTag); } } return stack; }
@Override public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { if (world.isRemote) { return false; } TileEntity te = world.getTileEntity(x, y, z); if (te != null && te instanceof TileEntityMannequin) { int rotation = ((TileEntityMannequin) te).getRotation(); rotation++; if (rotation > 15) { rotation = 0; } ((TileEntityMannequin) te).setRotation(rotation); } return true; }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int side, float xHit, float yHit, float zHit) { if (!player.canPlayerEdit(x, y, z, side, player.getCurrentEquippedItem())) { return false; } if (!world.isRemote) { ItemStack stack = player.getCurrentEquippedItem(); if (stack != null && stack.getItem() == ModItems.mannequinTool) { return false; } if (stack != null && stack.getItem() == Items.name_tag) { TileEntity te = world.getTileEntity(x, y, z); ; if (te != null && te instanceof TileEntityMannequin) { if (stack.getItem() == Items.name_tag) { ((TileEntityMannequin) te).setOwner(player.getCurrentEquippedItem()); } } } else { FMLNetworkHandler.openGui( player, ArmourersWorkshop.instance, LibGuiIds.MANNEQUIN, world, x, y, z); } } if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() == ModItems.mannequinTool) { return false; } return true; }