Class LimitingEnergyHandler

java.lang.Object
net.neoforged.neoforge.transfer.energy.DelegatingEnergyHandler
net.neoforged.neoforge.transfer.energy.LimitingEnergyHandler
All Implemented Interfaces:
EnergyHandler

public class LimitingEnergyHandler extends DelegatingEnergyHandler
An energy handler that will apply additional per-insert and per-extract limits to another handler.
  • Field Details

    • maxInsert

      protected int maxInsert
    • maxExtract

      protected int maxExtract
  • Constructor Details

  • Method Details

    • insert

      public int insert(int amount, TransactionContext transaction)
      Description copied from interface: EnergyHandler
      Inserts up to the given amount of energy into the handler.

      Changes to the handler are made in the context of a transaction.

      Specified by:
      insert in interface EnergyHandler
      Overrides:
      insert in class DelegatingEnergyHandler
      Parameters:
      amount - The maximum amount of energy to insert. Must be non-negative.
      transaction - The transaction that this operation is part of.
      Returns:
      The amount that was inserted. Between 0 (inclusive, nothing was inserted) and amount (inclusive, everything was inserted).
    • extract

      public int extract(int amount, TransactionContext transaction)
      Description copied from interface: EnergyHandler
      Extracts up to the given amount of energy from the handler.

      Changes to the handler are made in the context of a transaction.

      Specified by:
      extract in interface EnergyHandler
      Overrides:
      extract in class DelegatingEnergyHandler
      Parameters:
      amount - The maximum amount of energy to extract. Must be non-negative.
      transaction - The transaction that this operation is part of.
      Returns:
      The amount that was extracted. Between 0 (inclusive, nothing was extracted) and amount (inclusive, everything was extracted).