Advertisement
Camellias_

inputEnergy() method

Nov 8th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. public void inputEnergy()
  2. {
  3. for(EnumFacing dir : EnumFacing.values())
  4. {
  5. TileEntity tile = world.getTileEntity(pos.offset(dir));
  6.  
  7. if(tile == null)
  8. {
  9. continue;
  10. }
  11.  
  12. IEnergyStorage energyCapability = tile.getCapability(CapabilityEnergy.ENERGY, null);
  13.  
  14. if(energyCapability == null)
  15. {
  16. continue;
  17. }
  18.  
  19. int otherEnergy = energyCapability.getEnergyStored();
  20. int otherEnergyCap = energyCapability.getMaxEnergyStored();
  21.  
  22.  
  23.  
  24. if(energy <= (capacity - maxInput) && otherEnergy >= maxInput)
  25. {
  26. energyCapability.receiveEnergy(maxInput, false);
  27. energy += maxInput;
  28. }
  29.  
  30. if(energy > (capacity - maxInput) && otherEnergy < maxInput)
  31. {
  32. energyCapability.receiveEnergy(otherEnergy, false);
  33. energy += otherEnergy;
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement