Skip to content

Updating from 7.4.0 to 8.0.0

New Data Save/Sync System

A new system for saving and syncing object fields has been added. See this page for migration instructions.

Machine Refactor

Many aspects of the machine classes have been refactored and changed in order to streamline the machine system and remove legacy and unnecessary abstraction.

MetaMachine and MetaMachineBlockEntity merge

  • The MetaMachineBlockEntity(MMBE) class has been removed, and MetaMachine(MM) is now a BlockEntity.
  • Most methods and properties of MMBE have been moved onto MM.
  • The IMachineBlockEntity interface has been removed. Use MetaMachineBlock directly instead.
  • Many methods common to all block entities have been moved to the IGregtechBlockEntity interface.
  • Machine instance creation functions have signature (BlockEntityCreationInfo) -> MetaMachine instead of (IMachineBlockEntity) -> MetaMachine

References to MMBE can generally be replaced with references to MM:

/////// OLD
if (level.getBlockEntity(getPos()) instanceof MetaMachineBlockEntity mmbe) {
    MetaMachine machine = mmbe.getMetaMachine();
    ...
}

////// NEW
if (level.getBlockEntity(getPos()) instanceof MetaMachine machine) {
    ... 
} 

The IMachineBlockEntity holder argument in machine constructors has been replaced with BlockEntityCreationInfo info:

////// OLD
public MetaMachine(IMachineBlockEntity holder);
////// NEW
public MetaMachine(BlockEntityCreationInfo info);
A number of methods have been renamed across a number of different interfaces and classes to ensure consistency with default BlockEntity methods:

  • BlockPos getPipePos() -> BlockPos getBlockPos()
  • Level getPipeLevel() -> Level getLevel()
  • BlockPos getPos() -> BlockPos getBlockPos()
  • BlockState getState() -> BlockState getBlockState()
  • boolean isInvalid() -> boolean isRemoved()
  • void markAsDirty() -> void markAsChanged()

Machine constructor and trait initialisation changes

The constructors for a large number of machines have changed in order to simply machine instance creation. Additionally, methods for trait creation have also been removed and now form part of the machine constructor.

All Machines

  • Replace the first constructor argument IMachineBlockEntity holder with BlockEntityCreationInfo info

TieredEnergyMachine

  • Removed createEnergyContainer method
  • Constructor now has an optional Supplier<NotifiableEnergyContainer> argument

WorkableTieredMachine

  • Removed createRecipeLogic, createImportItemHandler, createExportItemHandler, createImportFluidHandler, createExportFluidHandler methods
  • Added a new constructor:
    • BlockEntityCreationInfo info
    • int tier
    • Supplier<RecipeLogic> recipeLogicSupplier Recipe logic supplier, defaults to the standard RecipeLogic class.
    • int importSlots Item import slots, defaults to the amount of slots in the machine's default recipe type.
    • int exportSlots Same as above, but for item export slots.
    • int fluidImportSlots As above, but for fluid import slots.
    • int fluidExportSlots As above, but for fluid export slots.
    • Int2IntFunction tankScalingFunction Fluid tank capacity scaling function.

WorkableMultiblockMachine, WorkableElectricMultiblockMachine and SteamWorkableMachine

  • Removed createRecipeLogic method
  • Constructor now has an optional Supplier<RecipeLogic> argument, defaults to the standard RecipeLogic class

Machine Trait Refactor

A new system for attaching traits and custom behaviour to machines has been added, and many machine interfaces and traits now use this new system.

New System Example

Example of the new AutoOutputTrait

public class CustomDrumMachine extends MetaMachine {

  protected final NotifiableFluidTank tank;
  public final AutoOutputTrait autoOutput;

  public DrumMachine(BlockEntityCreationInfo info, int capacity) {
    super(info);

    // Traits must be attached in the constructor.

    this.tank = new NotifiableFluidTank(this, 1, capacity, IO.BOTH);

    // Registers an auto output trait that provides fluid output behaviour for the given fluid tank.
    this.autoOutput = AutoOutputTrait.ofFluids(this, tank);

    autoOutput.setFluidOutputDirection(Direction.DOWN);
    autoOutput.setFluidOutputDirectionValidator(d -> d == Direction.DOWN);
  }

  // Any code can query traits from a machine 
  public static void queryTraits(MetaMachine machine) {

      // Returns a trait with the given type, or null.
      AutoOutputTrait autoOutputTrait = machine.getTraitHolder().getTrait(AutoOutputTrait.TYPE);

      Optional<RecipeLogic> recipeLogicOptional = machine.getTraitHolder().getTrait(RecipeLogic.TYPE);

      // Gets all traits with the specified type.
      List<NotifiableItemStackHandler> allItemStackHandlers = machine.getTraitHolder().getTraits(NotifiableItemStackHandler.TYPE);

  }
}

Removed interfaces

A large number of machine feature interfaces have been removed, and have had their functionality merged into the standard MetaMachine class, or now use the new machine trait system:

  • ITurbineMachine Use the LargeTurbineMachine class directly.
  • IRotorHolderMachine Use the RotorHolderMachine class directly.
  • IMultiController Use the MultiblockControllerMachine class directly.
  • IMufflerMachine Use the MufflerMachine class directly.
  • IMachineLife Override the MetaMachine::onMachinePlaced and MetaMachine::onMachineDestroyed.
  • IMachineModifyDrops Override MetaMachine::modifyDrops.
  • IInteractedMachine Override MetaMachine::onUse and MetaMachine::onLeftClick.
  • ICleanroomReceiver & ICleanroomProvider - Use CleanroomReceiverTrait and CleanroomProviderTrait.
  • IAutoOutputBoth, IAutoOutputFluid, IAutoOutputItem - Use AutoOutputTrait.
  • IExplosionMachine - Use EnvironmentalExplosionTrait, GTUtil::doExplosion, and GTUtil::setOnFire
  • IEnvironmentalHazardCleaner Use EnvironmentalHazardCleanerTrait
  • ILocalizedHazardEmitter - Use LocalizedHazardEmitterTrait
  • IExhaustVentMachine - Use ExhaustVentMachineTrait
  • IHPCAComponentHatch - Use HPCAComponentTrait
  • IHPCAComputationProvider - Use HPCAComputationProviderTrait
  • IHPCACoolantProvider - Use HPCACoolantProviderTrait

Other Changes

  • BlastingRecipeBuilder, CampfireRecipeBuilder, SmeltingRecipeBuilder and SmokingRecipeBuilder have been merged into SimpleCookingRecipeBuilder
    • Example usage: SimpleCookingRecipeBuilder.campfireCooking("cooking_chicken").input(new ItemStack(Items.CHICKEN)).output(new ItemStacks(Items.COOKED_CHICKEN)).cookingTime(100).experience(100).save(provider);
  • GTFluidImpl has been merged into GTFluid, use GTFluid.Flowing and GTFluid.Source instead of GTFluidImpl.Flowing and GTFluidImpl.Source.
  • Item behaviors have been moved to common/item/behavior, and some items have been moved from api/item to common/item.
  • Methods for processing machine interactions have changed, and all now take a single ExtendedUseOnContext argument.