Advertisement
Guest User

IEnergySink implementation mistake?

a guest
Jan 27th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1.     @Override
  2.     public int injectEnergy(Direction directionFrom, int amount) {
  3.         if (!directionFrom.equals(Direction.YP)) {
  4.             if (Energy >= 10000) {
  5.                 this.Energy = 10000;
  6.                 return amount;
  7.             } else {
  8.                 int left = amount - 4;
  9.                 Energy += (amount > 4) ? 4 : amount;
  10.                 if (Energy > 10000) {
  11.                     left += Energy - 10000;
  12.                     Energy = 10000;
  13.                 }
  14.                 return left;
  15.             }
  16.         }
  17.         return amount;
  18.     }
  19.  
  20.     @Override
  21.     public int getMaxSafeInput() {
  22.         return Integer.MAX_VALUE;
  23.     }
  24.  
  25.     @Override
  26.     public boolean acceptsEnergyFrom(TileEntity emitter, Direction direction) {
  27.         if (this.Energy >= 10000) {
  28.             this.Energy = 10000;
  29.             return false;
  30.         }
  31.         if (direction.equals(Direction.YN)) {
  32.             return true;
  33.         }
  34.         return false;
  35.     }
  36.  
  37.     @Override
  38.     public boolean isAddedToEnergyNet() {
  39.         return inEnergyNet;
  40.     }
  41.     @Override
  42.     public int demandsEnergy() {
  43.         return (Energy < 10000) ? 4 : 0;
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement