From 44aa08b5bd83e9fcaaf275207b34d337218a9aff Mon Sep 17 00:00:00 2001 From: 90 Date: Sat, 6 Jul 2024 21:53:54 +0100 Subject: [PATCH] Remove a superfluous interface method --- .../appliede/integration/ae2wtlib/WTTMenuHost.java | 14 ++------------ .../_90/appliede/me/misc/LearnAllItemsPacket.java | 11 ++++++++--- .../me/misc/TransmutationTerminalHost.java | 8 +------- .../appliede/menu/TransmutationTerminalMenu.java | 8 +++++++- .../appliede/part/TransmutationTerminalPart.java | 13 ++----------- 5 files changed, 20 insertions(+), 34 deletions(-) diff --git a/src/main/java/gripe/_90/appliede/integration/ae2wtlib/WTTMenuHost.java b/src/main/java/gripe/_90/appliede/integration/ae2wtlib/WTTMenuHost.java index 8e53bfb..3dc1fdc 100644 --- a/src/main/java/gripe/_90/appliede/integration/ae2wtlib/WTTMenuHost.java +++ b/src/main/java/gripe/_90/appliede/integration/ae2wtlib/WTTMenuHost.java @@ -8,8 +8,6 @@ import net.minecraft.world.item.ItemStack; import appeng.api.implementations.blockentities.IViewCellStorage; -import appeng.api.networking.IGrid; -import appeng.items.tools.powered.WirelessTerminalItem; import appeng.menu.ISubMenu; import de.mari_023.ae2wtlib.terminal.WTMenuHost; @@ -17,7 +15,6 @@ import gripe._90.appliede.me.misc.TransmutationTerminalHost; public class WTTMenuHost extends WTMenuHost implements IViewCellStorage, TransmutationTerminalHost { - private final IGrid targetGrid; private boolean shiftToTransmute; public WTTMenuHost( @@ -26,7 +23,6 @@ public WTTMenuHost( ItemStack is, BiConsumer returnToMainMenu) { super(player, inventorySlot, is, returnToMainMenu); - targetGrid = ((WirelessTerminalItem) is.getItem()).getLinkedGrid(is, player.level(), null); readFromNbt(); } @@ -53,14 +49,8 @@ public boolean getShiftToTransmute() { } @Override - public void setShiftToTransmute(boolean toggle) { - shiftToTransmute = toggle; + public void setShiftToTransmute(boolean shift) { + shiftToTransmute = shift; saveChanges(); } - - @Nullable - @Override - public IGrid getGrid() { - return targetGrid; - } } diff --git a/src/main/java/gripe/_90/appliede/me/misc/LearnAllItemsPacket.java b/src/main/java/gripe/_90/appliede/me/misc/LearnAllItemsPacket.java index 1ed4719..e8f2c1d 100644 --- a/src/main/java/gripe/_90/appliede/me/misc/LearnAllItemsPacket.java +++ b/src/main/java/gripe/_90/appliede/me/misc/LearnAllItemsPacket.java @@ -20,8 +20,13 @@ public void handle(Supplier context) { return; } - var host = menu.getHost(); - var grid = host.getGrid(); + var node = menu.getHost().getActionableNode(); + + if (node == null) { + return; + } + + var grid = node.getGrid(); if (grid == null) { return; @@ -47,7 +52,7 @@ public void handle(Supplier context) { menu::showLearned); var me = storage.getInventory(); - me.extract(item, learned, Actionable.MODULATE, IActionSource.ofMachine(host)); + me.extract(item, learned, Actionable.MODULATE, IActionSource.ofMachine(menu.getHost())); }); } }); diff --git a/src/main/java/gripe/_90/appliede/me/misc/TransmutationTerminalHost.java b/src/main/java/gripe/_90/appliede/me/misc/TransmutationTerminalHost.java index 4e18dd0..02df0e8 100644 --- a/src/main/java/gripe/_90/appliede/me/misc/TransmutationTerminalHost.java +++ b/src/main/java/gripe/_90/appliede/me/misc/TransmutationTerminalHost.java @@ -1,16 +1,10 @@ package gripe._90.appliede.me.misc; -import org.jetbrains.annotations.Nullable; - -import appeng.api.networking.IGrid; import appeng.api.networking.security.IActionHost; import appeng.api.storage.ITerminalHost; public interface TransmutationTerminalHost extends ITerminalHost, IActionHost { boolean getShiftToTransmute(); - void setShiftToTransmute(boolean toggle); - - @Nullable - IGrid getGrid(); + void setShiftToTransmute(boolean shift); } diff --git a/src/main/java/gripe/_90/appliede/menu/TransmutationTerminalMenu.java b/src/main/java/gripe/_90/appliede/menu/TransmutationTerminalMenu.java index 7e4a9e5..c4a26f1 100644 --- a/src/main/java/gripe/_90/appliede/menu/TransmutationTerminalMenu.java +++ b/src/main/java/gripe/_90/appliede/menu/TransmutationTerminalMenu.java @@ -68,7 +68,13 @@ public void doAction(ServerPlayer player, InventoryAction action, int slot, long private int transmuteItem(ItemStack stack, boolean singleItem, Player player) { if (!stack.isEmpty()) { - var grid = host.getGrid(); + var node = host.getActionableNode(); + + if (node == null) { + return 0; + } + + var grid = node.getGrid(); if (grid == null) { return 0; diff --git a/src/main/java/gripe/_90/appliede/part/TransmutationTerminalPart.java b/src/main/java/gripe/_90/appliede/part/TransmutationTerminalPart.java index 5c346fe..bf009d3 100644 --- a/src/main/java/gripe/_90/appliede/part/TransmutationTerminalPart.java +++ b/src/main/java/gripe/_90/appliede/part/TransmutationTerminalPart.java @@ -1,13 +1,10 @@ package gripe._90.appliede.part; -import org.jetbrains.annotations.Nullable; - import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.MenuType; -import appeng.api.networking.IGrid; import appeng.api.parts.IPartItem; import appeng.api.parts.IPartModel; import appeng.items.parts.PartModels; @@ -41,17 +38,11 @@ public boolean getShiftToTransmute() { } @Override - public void setShiftToTransmute(boolean toggle) { - shiftToTransmute = toggle; + public void setShiftToTransmute(boolean shift) { + shiftToTransmute = shift; saveChanges(); } - @Nullable - @Override - public IGrid getGrid() { - return getMainNode().getGrid(); - } - @Override public void readFromNBT(CompoundTag data) { super.readFromNBT(data);