Camellias_

Untitled

Nov 9th, 2018
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 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, dir.getOpposite());
  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(energyCapability.canExtract() && otherEnergy > 0)
  25.             {
  26.                 if(energy <= (capacity - maxInput) && otherEnergy >= maxInput && energy < capacity)
  27.                 {
  28.                     energyCapability.receiveEnergy(maxInput, false);
  29.                     energy += maxInput;
  30.                 }
  31.                
  32.                 if(energy > (capacity - maxInput) && energy < capacity)
  33.                 {
  34.                     energyCapability.receiveEnergy(capacity - maxInput, false);
  35.                     energy += (capacity - maxInput);
  36.                 }
  37.                
  38.                 if(otherEnergy < maxInput && energy < capacity)
  39.                 {
  40.                     energyCapability.receiveEnergy(otherEnergy, false);
  41.                     energy += otherEnergy;
  42.                 }
  43.             }
  44.         }
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment