|
| 1 | +package uk.co.hexeption.aeinfinitybooster.mixins; |
| 2 | + |
| 3 | +import appeng.client.gui.AEBaseScreen; |
| 4 | +import appeng.client.gui.implementations.WirelessAccessPointScreen; |
| 5 | +import appeng.client.gui.style.ScreenStyle; |
| 6 | +import appeng.core.localization.GuiText; |
| 7 | +import appeng.menu.implementations.WirelessAccessPointMenu; |
| 8 | +import appeng.util.Platform; |
| 9 | +import net.minecraft.network.chat.Component; |
| 10 | +import net.minecraft.world.entity.player.Inventory; |
| 11 | +import org.spongepowered.asm.mixin.Mixin; |
| 12 | +import org.spongepowered.asm.mixin.injection.At; |
| 13 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 14 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 15 | + |
| 16 | +@Mixin(value = WirelessAccessPointScreen.class, remap = false) |
| 17 | +public class MixinWirelessAccessPointScreen extends AEBaseScreen<WirelessAccessPointMenu> { |
| 18 | + |
| 19 | + public MixinWirelessAccessPointScreen(WirelessAccessPointMenu menu, Inventory playerInventory, Component title, ScreenStyle style) { |
| 20 | + |
| 21 | + super(menu, playerInventory, title, style); |
| 22 | + } |
| 23 | + |
| 24 | + @Inject(method = "updateBeforeRender", at = @At("HEAD"), cancellable = true) |
| 25 | + private void updateBeforeRender(CallbackInfo ci) { |
| 26 | + super.updateBeforeRender(); |
| 27 | + |
| 28 | + Component rangeText = Component.empty(); |
| 29 | + Component energyUseText = Component.empty(); |
| 30 | + if (menu.getRange() > 0) { |
| 31 | + double rangeBlocks = menu.getRange() / 10.0; |
| 32 | + rangeText = GuiText.WirelessRange.text(rangeBlocks); |
| 33 | + energyUseText = GuiText.PowerUsageRate.text(Platform.formatPowerLong(menu.getDrain(), true)); |
| 34 | + } |
| 35 | + |
| 36 | + if(menu.getRange() == Long.MAX_VALUE) { |
| 37 | + rangeText = GuiText.WirelessRange.text("∞"); |
| 38 | + energyUseText = GuiText.PowerUsageRate.text(Platform.formatPowerLong(menu.getDrain(), true)); |
| 39 | + } |
| 40 | + |
| 41 | + setTextContent("range", rangeText); |
| 42 | + setTextContent("energy_use", energyUseText); |
| 43 | + |
| 44 | + ci.cancel(); |
| 45 | + } |
| 46 | +} |
0 commit comments