Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2ae6445
add trait type logic
gustovafing Jan 6, 2026
12d52f4
add missing type param
gustovafing Jan 6, 2026
68bc679
rename trait onMachineUnload
gustovafing Jan 7, 2026
346c193
change the way trait types work
gustovafing Jan 7, 2026
0cbb6d9
machine trait probe providers
gustovafing Jan 16, 2026
b7177de
impl trait ifaces
gustovafing Jan 16, 2026
4845469
spotless, minor changes
gustovafing Jan 17, 2026
f7a1272
annotation changes
gustovafing Jan 17, 2026
a8afcef
remove Optional<T>
gustovafing Jan 17, 2026
951dc38
add trait type method to all traits
gustovafing Jan 18, 2026
c65a06a
change comments to jdoc
gustovafing Jan 18, 2026
a7444e3
move trait logic to seperate class
gustovafing Jan 18, 2026
bf4cd0e
rename some methods and add comments
gustovafing Jan 18, 2026
b71bd03
jdoc
gustovafing Jan 18, 2026
2db65da
spotless
gustovafing Jan 18, 2026
493c8ea
small code order change
gustovafing Jan 20, 2026
cf806d5
apply review changes
gustovafing Jan 22, 2026
b051d63
Update MachineTraitHolder.java
gustovafing Jan 22, 2026
5be7a03
small organisation changes
gustovafing Jan 22, 2026
e510118
Merge branch 'gus/machine-refactor-pt2' of https://github.com/GregTec…
gustovafing Jan 22, 2026
ce2fc60
fix type bound
gustovafing Jan 22, 2026
b1d4180
spotless
gustovafing Jan 22, 2026
c18b3b2
fix trait onUse handling
gustovafing Jan 25, 2026
cf34d3c
Merge branch '1.20.1-v8.0.0' into gus/machine-refactor-pt2
gustovafing Jan 25, 2026
a4c4e41
add some package files
gustovafing Jan 25, 2026
64f71d2
source retention
gustovafing Jan 25, 2026
a799f81
documented
gustovafing Jan 25, 2026
d819bec
switch to the jetbrains annotation
gustovafing Jan 26, 2026
bf7ab19
spotless
gustovafing Jan 26, 2026
9532417
remove recipe logic capability
gustovafing Jan 20, 2026
65d56a3
remove turbine machine capability
gustovafing Jan 20, 2026
24d87a9
remove central monitor capability
gustovafing Jan 20, 2026
a4ebef7
implement cleanroom machine traits
gustovafing Jan 20, 2026
286ffca
port cleanroom to new system
gustovafing Jan 20, 2026
19bf0d3
remove turbine machine interface & spotless
gustovafing Jan 20, 2026
5501ab3
spotless
gustovafing Jan 21, 2026
90abcbe
Merge branch '1.20.1-v8.0.0' into gus/machine-refactor-pt2
gustovafing Jan 26, 2026
93cc9a8
spotless
gustovafing Jan 26, 2026
9f824e5
Merge branch 'gus/machine-refactor-pt2' of https://github.com/GregTec…
gustovafing Jan 26, 2026
a637715
small fixes
gustovafing Jan 29, 2026
20c1dcd
small tweaks to method names & formatting
gustovafing Jan 29, 2026
a1d4932
spotless
gustovafing Jan 29, 2026
01cbd9f
Merge branch '1.20.1-v8.0.0' into gus/machine-refactor-pt2
gustovafing Feb 4, 2026
d7a9e6d
small formatting fixes
gustovafing Feb 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ public ResourceTexture getPipeTexture(boolean isBlock) {
}

@Override
public Pair<GTToolType, InteractionResult> onToolClick(Set<GTToolType> toolTypes, ItemStack itemStack,
UseOnContext context) {
public Pair<@Nullable GTToolType, InteractionResult> onToolClick(Set<GTToolType> toolTypes, ItemStack itemStack,
UseOnContext context) {
// the side hit from the machine grid
var playerIn = context.getPlayer();
if (playerIn == null) return Pair.of(null, InteractionResult.PASS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.gregtechceu.gtceu.api.capability.forge.GTCapability;
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMaintenanceMachine;
import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -70,11 +69,6 @@ public static IControllable getControllable(Level level, BlockPos pos, @Nullable
return getBlockEntityCapability(GTCapability.CAPABILITY_CONTROLLABLE, level, pos, side);
}

@Nullable
public static RecipeLogic getRecipeLogic(Level level, BlockPos pos, @Nullable Direction side) {
return getBlockEntityCapability(GTCapability.CAPABILITY_RECIPE_LOGIC, level, pos, side);
}

@Nullable
public static IEnergyStorage getForgeEnergy(Level level, BlockPos pos, @Nullable Direction side) {
if (level.getBlockState(pos).hasBlockEntity()) {
Expand All @@ -86,11 +80,6 @@ public static IEnergyStorage getForgeEnergy(Level level, BlockPos pos, @Nullable
return null;
}

@Nullable
public static ICleanroomReceiver getCleanroomReceiver(Level level, BlockPos pos, @Nullable Direction side) {
return getBlockEntityCapability(GTCapability.CAPABILITY_CLEANROOM_RECEIVER, level, pos, side);
}

@Nullable
public static IMaintenanceMachine getMaintenanceMachine(Level level, BlockPos pos, @Nullable Direction side) {
return getBlockEntityCapability(GTCapability.CAPABILITY_MAINTENANCE_MACHINE, level, pos, side);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.gregtechceu.gtceu.api.capability.*;
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMaintenanceMachine;
import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic;

import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager;
Expand All @@ -20,16 +19,10 @@ public class GTCapability {
public static final Capability<IWorkable> CAPABILITY_WORKABLE = CapabilityManager.get(new CapabilityToken<>() {});
public static final Capability<IControllable> CAPABILITY_CONTROLLABLE = CapabilityManager
.get(new CapabilityToken<>() {});
public static final Capability<RecipeLogic> CAPABILITY_RECIPE_LOGIC = CapabilityManager
.get(new CapabilityToken<>() {});
public static final Capability<IElectricItem> CAPABILITY_ELECTRIC_ITEM = CapabilityManager
.get(new CapabilityToken<>() {});
public static final Capability<ICleanroomReceiver> CAPABILITY_CLEANROOM_RECEIVER = CapabilityManager
.get(new CapabilityToken<>() {});
public static final Capability<IMaintenanceMachine> CAPABILITY_MAINTENANCE_MACHINE = CapabilityManager
.get(new CapabilityToken<>() {});
public static final Capability<ITurbineMachine> CAPABILITY_TURBINE_MACHINE = CapabilityManager
.get(new CapabilityToken<>() {});
public static final Capability<ILaserContainer> CAPABILITY_LASER = CapabilityManager
.get(new CapabilityToken<>() {});
public static final Capability<IOpticalComputationProvider> CAPABILITY_COMPUTATION_PROVIDER = CapabilityManager
Expand All @@ -40,8 +33,6 @@ public class GTCapability {
.get(new CapabilityToken<>() {});
public static final Capability<IMonitorComponent> CAPABILITY_MONITOR_COMPONENT = CapabilityManager
.get(new CapabilityToken<>() {});
public static final Capability<ICentralMonitor> CAPABILITY_CENTRAL_MONITOR = CapabilityManager
.get(new CapabilityToken<>() {});

public static final Capability<IMedicalConditionTracker> CAPABILITY_MEDICAL_CONDITION_TRACKER = CapabilityManager
.get(new CapabilityToken<>() {});
Expand All @@ -53,17 +44,13 @@ public static void register(RegisterCapabilitiesEvent event) {
event.register(IToolable.class);
event.register(IWorkable.class);
event.register(IControllable.class);
event.register(RecipeLogic.class);
event.register(IElectricItem.class);
event.register(ICleanroomReceiver.class);
event.register(IMaintenanceMachine.class);
event.register(ITurbineMachine.class);
event.register(ILaserContainer.class);
event.register(IOpticalComputationProvider.class);
event.register(IDataAccessHatch.class);
event.register(IMedicalConditionTracker.class);
event.register(IHazardParticleContainer.class);
event.register(IMonitorComponent.class);
event.register(ICentralMonitor.class);
}
}
32 changes: 4 additions & 28 deletions src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.gregtechceu.gtceu.api.machine.property.GTMachineModelProperties;
import com.gregtechceu.gtceu.api.machine.trait.MachineTrait;
import com.gregtechceu.gtceu.api.machine.trait.MachineTraitHolder;
import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic;
import com.gregtechceu.gtceu.api.machine.trait.feature.IFrontFacingTrait;
import com.gregtechceu.gtceu.api.machine.trait.feature.IInteractionTrait;
import com.gregtechceu.gtceu.api.machine.trait.feature.IRenderingTrait;
Expand Down Expand Up @@ -290,8 +289,9 @@ private void executeTick() {
* animations will be played
*/
@Override
public final Pair<GTToolType, InteractionResult> onToolClick(Set<GTToolType> toolType, ItemStack itemStack,
UseOnContext context) {
public final Pair<@Nullable GTToolType, InteractionResult> onToolClick(Set<GTToolType> toolType,
ItemStack itemStack,
UseOnContext context) {
// the side hit from the machine grid
var playerIn = context.getPlayer();
if (playerIn == null) return Pair.of(null, InteractionResult.PASS);
Expand All @@ -303,7 +303,7 @@ public final Pair<GTToolType, InteractionResult> onToolClick(Set<GTToolType> too
CoverBehavior coverBehavior = gridSide == null ? null : coverContainer.getCoverAtSide(gridSide);
if (gridSide == null) gridSide = hitResult.getDirection();

Pair<GTToolType, InteractionResult> result = null;
Pair<@Nullable GTToolType, InteractionResult> result = null;

// Prioritize covers where they apply (Screwdriver, Soft Mallet)
if (toolType.isEmpty() && playerIn.isShiftKeyDown()) {
Expand Down Expand Up @@ -970,12 +970,6 @@ private static <T> List<T> getCapabilitiesFromTraits(List<MachineTrait> traits,
return GTCapability.CAPABILITY_CONTROLLABLE.orEmpty(cap, LazyOptional.of(() -> controllable));
}
}
} else if (cap == GTCapability.CAPABILITY_RECIPE_LOGIC) {
for (MachineTrait trait : machine.traitHolder.getAllTraits()) {
if (trait instanceof RecipeLogic recipeLogic) {
return GTCapability.CAPABILITY_RECIPE_LOGIC.orEmpty(cap, LazyOptional.of(() -> recipeLogic));
}
}
} else if (cap == GTCapability.CAPABILITY_ENERGY_CONTAINER) {
if (machine instanceof IEnergyContainer energyContainer) {
return GTCapability.CAPABILITY_ENERGY_CONTAINER.orEmpty(cap, LazyOptional.of(() -> energyContainer));
Expand All @@ -995,21 +989,11 @@ private static <T> List<T> getCapabilitiesFromTraits(List<MachineTrait> traits,
return GTCapability.CAPABILITY_ENERGY_INFO_PROVIDER.orEmpty(cap,
LazyOptional.of(() -> list.size() == 1 ? list.get(0) : new EnergyInfoProviderList(list)));
}
} else if (cap == GTCapability.CAPABILITY_CLEANROOM_RECEIVER) {
if (machine instanceof ICleanroomReceiver cleanroomReceiver) {
return GTCapability.CAPABILITY_CLEANROOM_RECEIVER.orEmpty(cap,
LazyOptional.of(() -> cleanroomReceiver));
}
} else if (cap == GTCapability.CAPABILITY_MAINTENANCE_MACHINE) {
if (machine instanceof IMaintenanceMachine maintenanceMachine) {
return GTCapability.CAPABILITY_MAINTENANCE_MACHINE.orEmpty(cap,
LazyOptional.of(() -> maintenanceMachine));
}
} else if (cap == GTCapability.CAPABILITY_TURBINE_MACHINE) {
if (machine instanceof ITurbineMachine turbineMachine) {
return GTCapability.CAPABILITY_TURBINE_MACHINE.orEmpty(cap,
LazyOptional.of(() -> turbineMachine));
}
} else if (cap == ForgeCapabilities.ITEM_HANDLER) {
var handler = machine.getItemHandlerCap(side, true);
if (handler != null) {
Expand Down Expand Up @@ -1064,14 +1048,6 @@ private static <T> List<T> getCapabilitiesFromTraits(List<MachineTrait> traits,
if (!list.isEmpty()) {
return GTCapability.CAPABILITY_MONITOR_COMPONENT.orEmpty(cap, LazyOptional.of(() -> list.get(0)));
}
} else if (cap == GTCapability.CAPABILITY_CENTRAL_MONITOR) {
if (machine instanceof ICentralMonitor centralMonitor) {
return GTCapability.CAPABILITY_CENTRAL_MONITOR.orEmpty(cap, LazyOptional.of(() -> centralMonitor));
}
var list = getCapabilitiesFromTraits(machine.traitHolder.getAllTraits(), side, ICentralMonitor.class);
if (!list.isEmpty()) {
return GTCapability.CAPABILITY_CENTRAL_MONITOR.orEmpty(cap, LazyOptional.of(() -> list.get(0)));
}
}
if (GTCEu.Mods.isAE2Loaded()) {
LazyOptional<?> opt = AE2CallWrapper.getGridNodeHostCapability(cap, machine, side);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import lombok.Setter;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.VisibleForTesting;

import java.util.*;
Expand All @@ -40,10 +39,8 @@ public abstract class WorkableTieredMachine extends TieredEnergyMachine implemen
@Setter
@SaveField
public int activeRecipeType;
@Nullable
@Getter
@Setter
private ICleanroomProvider cleanroom;
protected final CleanroomReceiverTrait cleanroomReceiver;
@SaveField
public final NotifiableItemStackHandler importItems, exportItems;
@SaveField
Expand Down Expand Up @@ -75,6 +72,7 @@ public WorkableTieredMachine(BlockEntityCreationInfo info, int tier,
this.capabilitiesProxy = new EnumMap<>(IO.class);
this.capabilitiesFlat = new EnumMap<>(IO.class);
this.traitSubscriptions = new ArrayList<>();
this.cleanroomReceiver = new CleanroomReceiverTrait(this);
this.recipeLogic = recipeLogicSupplier.apply(this);
this.importItems = new NotifiableItemStackHandler(this, importSlots, IO.IN, IO.BOTH);
this.exportItems = new NotifiableItemStackHandler(this, exportSlots, IO.OUT);
Expand All @@ -94,6 +92,7 @@ public WorkableTieredMachine(BlockEntityCreationInfo info, int tier, Int2IntFunc
this.capabilitiesProxy = new EnumMap<>(IO.class);
this.capabilitiesFlat = new EnumMap<>(IO.class);
this.traitSubscriptions = new ArrayList<>();
this.cleanroomReceiver = new CleanroomReceiverTrait(this);
this.recipeLogic = new RecipeLogic(this);
this.importItems = new NotifiableItemStackHandler(this, getRecipeType().getMaxInputs(ItemRecipeCapability.CAP),
IO.IN);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.gregtechceu.gtceu.api.machine.feature;

import com.gregtechceu.gtceu.api.capability.ICleanroomReceiver;
import com.gregtechceu.gtceu.api.capability.IWorkable;
import com.gregtechceu.gtceu.api.capability.recipe.IRecipeCapabilityHolder;
import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic;
Expand All @@ -16,8 +15,7 @@
/**
* A machine can handle recipes.
*/
public interface IRecipeLogicMachine extends IRecipeCapabilityHolder, IMachineFeature, IWorkable, ICleanroomReceiver,
IVoidable {
public interface IRecipeLogicMachine extends IRecipeCapabilityHolder, IMachineFeature, IWorkable, IVoidable {

/**
* RecipeType held
Expand Down

This file was deleted.

Loading