Skip to content

Commit

Permalink
Incorporate Amperage into Max Recipe Tier
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Aug 29, 2024
1 parent 1b21a77 commit 2fa87aa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.nomiceu.nomilabs.mixin.gregtech;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalLongRef;

import gregtech.api.capability.IEnergyContainer;
import gregtech.api.metatileentity.multiblock.MultiblockDisplayText;

/**
* Takes into account amperages when showing the Max EU/t of a Multiblock.
*/
@Mixin(value = MultiblockDisplayText.Builder.class, remap = false)
public class MultiblockDisplayTextBuilderMixin {

@Inject(method = "addEnergyUsageLine",
at = @At(value = "INVOKE_ASSIGN", target = "Ljava/lang/Math;max(JJ)J"),
require = 1,
locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private void accountAmperages(IEnergyContainer energyContainer,
CallbackInfoReturnable<MultiblockDisplayText.Builder> cir,
@Local LocalLongRef maxVoltage) {
maxVoltage.set(Math.max(energyContainer.getInputVoltage() * energyContainer.getInputAmperage(),
energyContainer.getOutputVoltage() * energyContainer.getOutputAmperage()));
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.nomilabs.gregtech.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"MetaTileEntityMEStockingBusMixin",
"MetaTileEntityMEStockingHatchMixin",
"MetaTileEntityProcessingArrayMixin",
"MultiblockDisplayTextBuilderMixin",
"MultiblockInfoCategoryMixin",
"MultiMapMultiblockControllerMixin",
"OreDictUnifierAccessor",
Expand Down

0 comments on commit 2fa87aa

Please sign in to comment.