From 2fa87aa22248094b6c258f5fa2198fccda5af045 Mon Sep 17 00:00:00 2001 From: Integer Limit <103940576+IntegerLimit@users.noreply.github.com> Date: Thu, 29 Aug 2024 22:39:26 +1000 Subject: [PATCH] Incorporate Amperage into Max Recipe Tier --- .../MultiblockDisplayTextBuilderMixin.java | 31 +++++++++++++++++++ .../resources/mixins.nomilabs.gregtech.json | 1 + 2 files changed, 32 insertions(+) create mode 100644 src/main/java/com/nomiceu/nomilabs/mixin/gregtech/MultiblockDisplayTextBuilderMixin.java diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/gregtech/MultiblockDisplayTextBuilderMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/gregtech/MultiblockDisplayTextBuilderMixin.java new file mode 100644 index 0000000..df6ea5b --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/mixin/gregtech/MultiblockDisplayTextBuilderMixin.java @@ -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 cir, + @Local LocalLongRef maxVoltage) { + maxVoltage.set(Math.max(energyContainer.getInputVoltage() * energyContainer.getInputAmperage(), + energyContainer.getOutputVoltage() * energyContainer.getOutputAmperage())); + } +} diff --git a/src/main/resources/mixins.nomilabs.gregtech.json b/src/main/resources/mixins.nomilabs.gregtech.json index 8c28390..e966138 100644 --- a/src/main/resources/mixins.nomilabs.gregtech.json +++ b/src/main/resources/mixins.nomilabs.gregtech.json @@ -22,6 +22,7 @@ "MetaTileEntityMEStockingBusMixin", "MetaTileEntityMEStockingHatchMixin", "MetaTileEntityProcessingArrayMixin", + "MultiblockDisplayTextBuilderMixin", "MultiblockInfoCategoryMixin", "MultiMapMultiblockControllerMixin", "OreDictUnifierAccessor",