Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 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
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 @@ -8,8 +8,10 @@

import org.jetbrains.annotations.Nullable;

/// @deprecated Use normal Block class instead - replace `AppearanceBlock::getBlockAppearance` with
/// `Block::getAppearance`
/**
* @deprecated Use normal Block class instead - replace {@code AppearanceBlock::getBlockAppearance} with
* {@code Block::getAppearance}
*/
@Deprecated(forRemoval = true)
public class AppearanceBlock extends Block implements IAppearance {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.gregtechceu.gtceu.api.machine.MetaMachine;
import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition;
import com.gregtechceu.gtceu.api.machine.feature.*;
import com.gregtechceu.gtceu.api.machine.trait.feature.IInteractionTrait;
import com.gregtechceu.gtceu.common.data.GTItems;
import com.gregtechceu.gtceu.common.machine.owner.MachineOwner;
import com.gregtechceu.gtceu.syncsystem.ManagedSyncBlockEntity;
Expand Down Expand Up @@ -246,13 +247,8 @@ public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState
if (pState.hasBlockEntity()) {
if (!pState.is(pNewState.getBlock())) { // new block
MetaMachine machine = MetaMachine.getMachine(pLevel, pPos);
if (machine instanceof IMachineLife machineLife) {
machineLife.onMachineRemoved();
}
if (machine != null) {
for (Direction direction : GTUtil.DIRECTIONS) {
machine.getCoverContainer().removeCover(direction, null);
}
machine.onRemoved();
}

pLevel.updateNeighbourForOutputSignal(pPos, this);
Expand All @@ -274,16 +270,16 @@ public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
BlockHitResult hit) {
var machine = MetaMachine.getMachine(world, pos);
if (machine == null) return InteractionResult.FAIL;
ItemStack itemStack = player.getItemInHand(hand);
boolean shouldOpenUi = true;

if (machine != null && machine.getOwnerUUID() == null && player instanceof ServerPlayer sPlayer) {
if (machine.getOwnerUUID() == null && player instanceof ServerPlayer sPlayer) {
machine.setOwnerUUID(sPlayer.getUUID());
}

Set<GTToolType> types = ToolHelper.getToolTypes(itemStack);
if (machine != null &&
(!types.isEmpty() && ToolHelper.canUse(itemStack) || types.isEmpty() && player.isShiftKeyDown())) {
if (!types.isEmpty() && ToolHelper.canUse(itemStack) || types.isEmpty() && player.isShiftKeyDown()) {
var result = machine.onToolClick(types, itemStack, new UseOnContext(player, hand, hit));
if (result.getSecond() == InteractionResult.CONSUME && player instanceof ServerPlayer serverPlayer) {
ToolHelper.playToolSound(result.getFirst(), serverPlayer);
Expand All @@ -303,6 +299,13 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player
shouldOpenUi = gtToolItem.definition$shouldOpenUIAfterUse(new UseOnContext(player, hand, hit));
}

for (var trait : machine.getTraitHolder().getAllTraits()) {
if (trait instanceof IInteractionTrait interactionTrait) {
InteractionResult result = interactionTrait.onUse(state, world, pos, player, hand, hit);
if (result != InteractionResult.PASS) return result;
}
}

if (machine instanceof IInteractedMachine interactedMachine) {
var result = interactedMachine.onUse(state, world, pos, player, hand, hit);
if (result != InteractionResult.PASS) return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class MachineCoverContainer implements ICoverable, ISyncManaged {
@SyncToClient
@SaveField
@RerenderOnChanged
private CoverBehavior up, down, north, south, west, east;
private @Nullable CoverBehavior up, down, north, south, west, east;

public MachineCoverContainer(MetaMachine machine) {
this.machine = machine;
Expand Down Expand Up @@ -67,7 +67,7 @@ public boolean shouldRenderBackSide() {
}

@Override
public CoverBehavior getCoverAtSide(Direction side) {
public @Nullable CoverBehavior getCoverAtSide(Direction side) {
return switch (side) {
case UP -> up;
case SOUTH -> south;
Expand All @@ -92,12 +92,12 @@ public void setCoverAtSide(@Nullable CoverBehavior coverBehavior, Direction side
}

@Override
public IItemHandlerModifiable getItemHandlerCap(@Nullable Direction side, boolean useCoverCapability) {
public @Nullable IItemHandlerModifiable getItemHandlerCap(@Nullable Direction side, boolean useCoverCapability) {
return machine.getItemHandlerCap(side, useCoverCapability);
}

@Override
public IFluidHandlerModifiable getFluidHandlerCap(@Nullable Direction side, boolean useCoverCapability) {
public @Nullable IFluidHandlerModifiable getFluidHandlerCap(@Nullable Direction side, boolean useCoverCapability) {
return machine.getFluidHandlerCap(side, useCoverCapability);
}
}
Loading