예제 #1
0
 @Override
 public void updateEntity() {
   super.updateEntity();
   if (worldObj.isRemote) return;
   int d = tanks.getAmount(0) - lastAmount;
   if ((d != 0 && (tanks.getAmount(0) == 0 || lastAmount == 0)) || d * d > 250000) {
     lastAmount = tanks.getAmount(0);
     worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
   }
 }
예제 #2
0
 @Override
 public void updateEntity() {
   super.updateEntity();
   if (worldObj.isRemote) return;
   int add = 0;
   netData.floats[0] = (float) energy.getEnergy(0, 1);
   int max = (int) Math.floor(netData.floats[0] / forceEnergy);
   if (netData.ints[0] > max) {
     add -= netData.ints[0] - max;
   }
   if (inventory.items[0] != null) {
     if (inventory.items[0].getItem() instanceof ItemBlock)
       add += inventory.items[0].stackSize * blockWeight;
     else add += inventory.items[0].stackSize * itemWeight;
     inventory.items[0] = null;
   }
   if (tanks.getAmount(0) > 0) {
     add +=
         tanks.getAmount(0)
             * Math.max(netData.fluids[0].getFluid().getDensity(netData.fluids[0]), 1)
             / 1000;
     tanks.setFluid(0, null);
   }
   if (add != 0) {
     max = (int) Math.floor(energy.getEnergy(0, 1) / energyCost);
     if (add > max) add = max;
     netData.ints[0] += add;
     energy.addEnergy(-add * energyCost);
   }
   netData.ints[1] = 0;
   if (inventory.items[1] != null) {
     GCRecipe rcp = AutomationRecipes.getRecipeFor(inventory.items[1]);
     if (rcp != null) {
       netData.ints[1] = rcp.matter;
       if (netData.ints[0] >= netData.ints[1]
           && (inventory.items[2] == null
               || (Utils.itemsEqual(rcp.output, inventory.items[2])
                   && rcp.output.stackSize + inventory.items[2].stackSize
                       <= rcp.output.getMaxStackSize()))) {
         netData.ints[0] -= netData.ints[1];
         inventory.items[1].stackSize -= rcp.input.stackSize;
         if (inventory.items[1].stackSize <= 0) inventory.items[1] = null;
         if (inventory.items[2] == null) inventory.items[2] = rcp.output.copy();
         else inventory.items[2].stackSize += rcp.output.stackSize;
       }
     }
   }
 }
예제 #3
0
 @Override
 public void readFromNBT(NBTTagCompound nbt) {
   super.readFromNBT(nbt);
   netData.ints[0] = nbt.getInteger("matter");
 }
예제 #4
0
 @Override
 public void writeToNBT(NBTTagCompound nbt) {
   super.writeToNBT(nbt);
   nbt.setInteger("matter", netData.ints[0]);
 }