private void distributeEnergy() { for (INetworkPart part : network.networkParts) if (part instanceof TileNetworkEnergyInterface) { TileNetworkEnergyInterface tile = (TileNetworkEnergyInterface) part; boolean simulate = false; if (tile.getTile() instanceof IEnergyReceiver) { int maxReceive = ((IEnergyReceiver) tile.getTile()) .receiveEnergy(tile.tileFace.getOpposite(), 1000, true); ((IEnergyReceiver) tile.getTile()) .receiveEnergy( tile.tileFace.getOpposite(), energy.extractEnergy(maxReceive, simulate), simulate); } else if (tile.getTile() != null && tile.getTile().hasCapability(CapabilityEnergy.ENERGY, tile.tileFace.getOpposite())) { int maxReceive = tile.getTile() .getCapability(CapabilityEnergy.ENERGY, tile.tileFace.getOpposite()) .receiveEnergy(1000, true); tile.getTile() .getCapability(CapabilityEnergy.ENERGY, tile.tileFace.getOpposite()) .receiveEnergy(energy.extractEnergy(maxReceive, simulate), simulate); } } }
@Override public int getMaxEnergyStored(EnumFacing from) { return energy.getMaxEnergyStored(); }
@Override public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) { if (worldObj.getTotalWorldTime() % 4 == 0) markForSync(); return energy.receiveEnergy(maxReceive, simulate); }
@Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { NBTHelper.setInt(compound, "energy", energy.getEnergyStored()); return super.writeToNBT(compound); }
@Override public void readFromNBT(NBTTagCompound compound) { energy.setEnergyStored(NBTHelper.getInt(compound, "energy")); super.readFromNBT(compound); }