示例#1
0
 /** Called upon block activation (right click on the block.) */
 @Override
 public boolean onBlockActivated(
     World world,
     int x,
     int y,
     int z,
     EntityPlayer player,
     int side,
     float hitX,
     float hitY,
     float hitZ) {
   if (!world.isRemote) {
     if (player.isSneaking()) {
       player.openGui(FullPower.instance, GuiHandler.GuiIDs.CAMO_MINE.ordinal(), world, x, y, z);
     }
     TileEntityCamoMine te = (TileEntityCamoMine) world.getTileEntity(x, y, z);
     if (te.getCamouflage(side) != null) {
       ItemStack camoStack = te.getCamouflage(side);
       te.setCamouflage(null, side);
       EntityItem itemEntity = new EntityItem(world, x, y, z, camoStack);
       LogHelper.info("StackSize=" + camoStack.stackSize);
       // Tell world this item needs to be spawned
       world.spawnEntityInWorld(itemEntity);
     } else {
       ItemStack playerItem = player.getCurrentEquippedItem();
       if (playerItem != null) {
         ItemStack camoStack = playerItem.splitStack(1); // Remove 1 from stack
         ChatHelper.send(camoStack.toString());
         te.setCamouflage(camoStack, side);
       }
     }
   }
   return true;
 }
示例#2
0
 @SideOnly(Side.CLIENT)
 public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
   TileEntityCamoMine te = (TileEntityCamoMine) world.getTileEntity(x, y, z);
   ItemStack stack = te.getCamouflage(side);
   if (stack != null && stack.getItem() instanceof ItemBlock) {
     Block block = ((ItemBlock) stack.getItem()).field_150939_a;
     return block.getIcon(side, stack.getItemDamage());
   } else {
     return super.getIcon(world, x, y, z, side);
   }
 }