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, andMetaMachine(MM) is now a BlockEntity. - Most methods and properties of MMBE have been moved onto MM.
- The
IMachineBlockEntityinterface has been removed. UseMetaMachineBlockdirectly instead. - Many methods common to all block entities have been moved to the
IGregtechBlockEntityinterface. - Machine instance creation functions have signature
(BlockEntityCreationInfo) -> MetaMachineinstead 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);
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 holderwithBlockEntityCreationInfo info
TieredEnergyMachine
- Removed
createEnergyContainermethod - Constructor now has an optional
Supplier<NotifiableEnergyContainer>argument
WorkableTieredMachine
- Removed
createRecipeLogic,createImportItemHandler,createExportItemHandler,createImportFluidHandler,createExportFluidHandlermethods - Added a new constructor:
BlockEntityCreationInfo infoint tierSupplier<RecipeLogic> recipeLogicSupplierRecipe logic supplier, defaults to the standardRecipeLogicclass.int importSlotsItem import slots, defaults to the amount of slots in the machine's default recipe type.int exportSlotsSame as above, but for item export slots.int fluidImportSlotsAs above, but for fluid import slots.int fluidExportSlotsAs above, but for fluid export slots.Int2IntFunction tankScalingFunctionFluid tank capacity scaling function.
WorkableMultiblockMachine, WorkableElectricMultiblockMachine and SteamWorkableMachine
- Removed
createRecipeLogicmethod - Constructor now has an optional
Supplier<RecipeLogic>argument, defaults to the standardRecipeLogicclass
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:
ITurbineMachineUse theLargeTurbineMachineclass directly.IRotorHolderMachineUse theRotorHolderMachineclass directly.IMultiControllerUse theMultiblockControllerMachineclass directly.IMufflerMachineUse theMufflerMachineclass directly.IMachineLifeOverride theMetaMachine::onMachinePlacedandMetaMachine::onMachineDestroyed.IMachineModifyDropsOverrideMetaMachine::modifyDrops.IInteractedMachineOverrideMetaMachine::onUseandMetaMachine::onLeftClick.ICleanroomReceiver&ICleanroomProvider- UseCleanroomReceiverTraitandCleanroomProviderTrait.IAutoOutputBoth,IAutoOutputFluid,IAutoOutputItem- UseAutoOutputTrait.IExplosionMachine- UseEnvironmentalExplosionTrait,GTUtil::doExplosion, andGTUtil::setOnFireIEnvironmentalHazardCleanerUseEnvironmentalHazardCleanerTraitILocalizedHazardEmitter- UseLocalizedHazardEmitterTraitIExhaustVentMachine- UseExhaustVentMachineTraitIHPCAComponentHatch- UseHPCAComponentTraitIHPCAComputationProvider- UseHPCAComputationProviderTraitIHPCACoolantProvider- UseHPCACoolantProviderTrait
Other Changes
BlastingRecipeBuilder,CampfireRecipeBuilder,SmeltingRecipeBuilderandSmokingRecipeBuilderhave been merged intoSimpleCookingRecipeBuilder- Example usage:
SimpleCookingRecipeBuilder.campfireCooking("cooking_chicken").input(new ItemStack(Items.CHICKEN)).output(new ItemStacks(Items.COOKED_CHICKEN)).cookingTime(100).experience(100).save(provider);
- Example usage:
GTFluidImplhas been merged intoGTFluid, useGTFluid.FlowingandGTFluid.Sourceinstead ofGTFluidImpl.FlowingandGTFluidImpl.Source.- Item behaviors have been moved to
common/item/behavior, and some items have been moved fromapi/itemtocommon/item. - Methods for processing machine interactions have changed, and all now take a single
ExtendedUseOnContextargument.