Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixin into most multiblocks to allow laser hatches on them #74

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 50 additions & 0 deletions src/main/java/com/zorbatron/zbgt/mixin/RMMCLaserMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.zorbatron.zbgt.mixin;

import static gregtech.api.metatileentity.multiblock.MultiblockControllerBase.abilities;

import java.util.ArrayList;
import java.util.List;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;

import gregtech.api.capability.IEnergyContainer;
import gregtech.api.capability.impl.EnergyContainerList;
import gregtech.api.metatileentity.multiblock.MultiblockAbility;
import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController;
import gregtech.api.pattern.TraceabilityPredicate;

@Mixin(value = RecipeMapMultiblockController.class, remap = false)
public abstract class RMMCLaserMixin {

@Shadow
protected IEnergyContainer energyContainer;

@Inject(method = "initializeAbilities", at = @At(value = "RETURN"))
private void allowExtraAbilities(CallbackInfo ci) {
RecipeMapMultiblockController controller = (RecipeMapMultiblockController) (Object) this;
List<IEnergyContainer> energyInputs = new ArrayList<>();

energyInputs.addAll(controller.getAbilities(MultiblockAbility.INPUT_ENERGY));
energyInputs.addAll(controller.getAbilities(MultiblockAbility.SUBSTATION_INPUT_ENERGY));
energyInputs.addAll(controller.getAbilities(MultiblockAbility.INPUT_LASER));

energyContainer = new EnergyContainerList(energyInputs);
}

@WrapOperation(method = "autoAbilities(ZZZZZZZ)Lgregtech/api/pattern/TraceabilityPredicate;",
at = @At(value = "INVOKE",
target = "Lgregtech/api/metatileentity/multiblock/RecipeMapMultiblockController;abilities([Lgregtech/api/metatileentity/multiblock/MultiblockAbility;)Lgregtech/api/pattern/TraceabilityPredicate;",
ordinal = 0))
private TraceabilityPredicate allowExtraHatches(MultiblockAbility<?>[] multiblockAbilities,
Operation<TraceabilityPredicate> original) {
return abilities(MultiblockAbility.INPUT_ENERGY, MultiblockAbility.SUBSTATION_INPUT_ENERGY,
MultiblockAbility.INPUT_LASER);
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.zbgt.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"PSSMixin",
"RMMCLaserMixin",
"WorldGenRegistryMixin"
],
"client": [],
Expand Down