Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void inputEnergy()
- {
- for(EnumFacing dir : EnumFacing.values())
- {
- TileEntity tile = world.getTileEntity(pos.offset(dir));
- if(tile == null)
- {
- continue;
- }
- IEnergyStorage energyCapability = tile.getCapability(CapabilityEnergy.ENERGY, dir.getOpposite());
- if(energyCapability == null)
- {
- continue;
- }
- int otherEnergy = energyCapability.getEnergyStored();
- int otherEnergyCap = energyCapability.getMaxEnergyStored();
- if(energyCapability.canExtract() && otherEnergy > 0)
- {
- if(energy <= (capacity - maxInput) && otherEnergy >= maxInput && energy < capacity)
- {
- energyCapability.receiveEnergy(maxInput, false);
- energy += maxInput;
- }
- if(energy > (capacity - maxInput) && energy < capacity)
- {
- energyCapability.receiveEnergy(capacity - maxInput, false);
- energy += (capacity - maxInput);
- }
- if(otherEnergy < maxInput && energy < capacity)
- {
- energyCapability.receiveEnergy(otherEnergy, false);
- energy += otherEnergy;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment