Ejemplo n.º 1
0
 public static void transferItem(
     TileEntityItemStorableMachineBase inventory, int start, int end, int requireEnergy) {
   for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
     if (inventory.getStored() < requireEnergy) {
       break;
     }
     TileEntity tileEntity =
         inventory.worldObj.getBlockTileEntity(
             inventory.xCoord + dir.offsetX,
             inventory.yCoord + dir.offsetY,
             inventory.zCoord + dir.offsetZ);
     if (tileEntity != null && tileEntity instanceof IInventory) {
       for (int i = start; i < end; i++) {
         ItemStack target = inventory.getStackInSlot(i);
         if (target != null) {
           ItemStack result = Util.insertItem((IInventory) tileEntity, target, false);
           inventory.setInventorySlotContents(i, result);
           if (result == null || target.stackSize != result.stackSize) {
             inventory.useEnergy(requireEnergy);
           }
         }
       }
     }
   }
 }
Ejemplo n.º 2
0
 public static List<TileEntityActivatorModule> getActivatorModules(
     TileEntityItemStorableMachineBase tileEntity,
     int smartPhoneSlot,
     Class<? extends TileEntityMachineBase> klass) {
   ItemStack smartPhone = tileEntity.getStackInSlot(smartPhoneSlot);
   if (smartPhone != null && smartPhone.itemID == ItemSmartPhone.getInstance().itemID) {
     List<TileEntityActivatorModule> modules =
         ItemSmartPhone.getActivatorModules(
             Vec3.createVectorHelper(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord),
             tileEntity.worldObj,
             smartPhone,
             klass);
     if (modules != null) {
       return modules;
     }
   }
   return Collections.emptyList();
 }