コード例 #1
0
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer entityPlayer,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    if (!world.isRemote) {
      if (entityPlayer.isSneaking())
        entityPlayer.openGui(
            ShadowCraftEvolved.instance, IDs.GuiIDs.Land_Mine.ordinal(), world, x, y, z);

      TileEntityLandMineMk3 te = (TileEntityLandMineMk3) 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);
        world.spawnEntityInWorld(itemEntity);
      } else {
        ItemStack playerItem = entityPlayer.getCurrentEquippedItem();

        if (playerItem != null) {
          ItemStack camoStack = playerItem.splitStack(1);
          te.setCamouflage(camoStack, side);
        }
      }
    }

    return true;
  }
コード例 #2
0
 @SideOnly(Side.CLIENT)
 public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
   TileEntityLandMineMk3 te = (TileEntityLandMineMk3) 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);
   }
 }