Skip to content

Remove unnecessary interfaces & port more traits#4560

Closed
gustovafing wants to merge 9 commits into1.20.1-v8.0.0from
gus/machine-refactor
Closed

Remove unnecessary interfaces & port more traits#4560
gustovafing wants to merge 9 commits into1.20.1-v8.0.0from
gus/machine-refactor

Conversation

@gustovafing
Copy link
Copy Markdown
Member

What

  • removes IMachineLife, IInteractedMachine and IMachineModifyDrops and refactors their functionality into metamachine
  • removes IExplosionMachine & creates explodable machine trait
  • removes unnecessary callbacks from machine definition
  • removes HPCA interfaces and ports HPCA to machine traits

@gustovafing gustovafing requested a review from a team as a code owner February 7, 2026 07:31
@github-actions github-actions bot added 1.20.1 Tests: Failed Game Tests have failed on this PR labels Feb 7, 2026
Comment on lines +190 to +196
} else if (held.isEmpty()) {
var drained = cache.extractItem(0, player.isShiftKeyDown() ? stored.getMaxStackSize() : 1, false);
if (!drained.isEmpty()) {
if (!player.addItem(drained)) {
Block.popResourceFromFace(world, getBlockPos(), getFrontFacing(), drained);
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to be on left click?

}

@SubscribeEvent
public static void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What replaced this functionality?

Comment on lines +117 to +121
public void setOnFire() {
setOnFire(getLevel(), getBlockPos(), fireChance);
}

private static void setOnFire(Level level, BlockPos pos, double additionalFireChance) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge together into public void setOnFire()

Comment on lines +106 to +110
public void doExplosion(float power) {
doExplosion(getLevel(), getBlockPos(), power);
}

public static void doExplosion(Level level, BlockPos pos, float explosionPower) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge into public void doExplosion(float explosionPower).

if (side == null || inputsEnergy(side)) {
if (voltage > getInputVoltage()) {
machine.doExplosion(GTUtil.getExplosionPower(voltage));
ExplodableMachineTrait.doExplosion(getLevel(), getBlockPos(), GTUtil.getExplosionPower(voltage));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should get the trait and do the explosion via that. Don't use a static method.

this.upkeepEUt = upkeepEUt;
this.maxEUt = maxEUt;
this.canBeDamaged = canBeDamaged;
this.isDamaged = false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unneeded assignment.

Comment on lines +52 to +55
public <T extends MachineTrait> Optional<T> getTraitOptional(MachineTraitType<T> type) {
return Optional.ofNullable(getTrait(type));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to be using Optional. Remove.

this.advanced = advanced;
}

public static HPCAComponentTrait createHPCATrait(HPCAComponentPartMachine machine, boolean isAdvanced) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

@Override
public boolean canBeDamaged() {
return false;
public static HPCAComponentTrait createHPCATrait(HPCAComponentPartMachine machine, boolean isAdvanced) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

Comment on lines +654 to +661
public static void doExplosion(Level level, BlockPos pos, float explosionPower) {
level.removeBlock(pos, false);
level.explode(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
explosionPower, ConfigHolder.INSTANCE.machines.doesExplosionDamagesTerrain ?
Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.NONE);
}

public static void setOnFire(Level level, BlockPos pos, double additionalFireChance) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are ok to exist external to the trait, but GT should never be calling them when a trait is accessible.

@gustovafing gustovafing closed this Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.20.1 Tests: Failed Game Tests have failed on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants