Beispiel #1
0
  @Override
  public boolean removedByPlayer(
      World world, EntityPlayer player, int x, int y, int z, boolean harvested) {
    if (!world.isRemote) {
      TileEntity te = world.getTileEntity(x, y, z);
      if (te instanceof TileEnchanter) {
        TileEnchanter enchanter = (TileEnchanter) te;
        if (!player.capabilities.isCreativeMode) {
          ItemStack itemStack = new ItemStack(this);
          float f = 0.7F;
          double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
          double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
          double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
          EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, itemStack);
          entityitem.delayBeforeCanPickup = 10;
          world.spawnEntityInWorld(entityitem);

          if (enchanter.getStackInSlot(0) != null) {
            Util.dropItems(world, enchanter.getStackInSlot(0), x, y, z, true);
          }
          if (enchanter.getStackInSlot(1) != null) {
            Util.dropItems(world, enchanter.getStackInSlot(1), x, y, z, true);
          }
        }
      }
    }
    return super.removedByPlayer(world, player, x, y, z, harvested);
  }
Beispiel #2
0
 @Override
 public boolean isValidTarget(ItemStack target) {
   if (target == null) {
     return false;
   }
   Block blk = Util.getBlockFromItemId(target.itemID);
   return blk instanceof BlockHalfSlab;
 }
 @Override
 public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
   if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
     TileEntity te = world.getBlockTileEntity(x, y, z);
     if (!(te instanceof TileCapacitorBank)) {
       super.breakBlock(world, x, y, z, par5, par6);
       return;
     }
     TileCapacitorBank cb = (TileCapacitorBank) te;
     Util.dropItems(world, cb, x, y, z, true);
   }
   world.removeBlockTileEntity(x, y, z);
 }