Skip to content

Commit

Permalink
Remove a superfluous interface method
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Jul 6, 2024
1 parent ae2fb8c commit 44aa08b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
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;

import gripe._90.appliede.me.misc.TransmutationTerminalHost;

public class WTTMenuHost extends WTMenuHost implements IViewCellStorage, TransmutationTerminalHost {
private final IGrid targetGrid;
private boolean shiftToTransmute;

public WTTMenuHost(
Expand All @@ -26,7 +23,6 @@ public WTTMenuHost(
ItemStack is,
BiConsumer<Player, ISubMenu> returnToMainMenu) {
super(player, inventorySlot, is, returnToMainMenu);
targetGrid = ((WirelessTerminalItem) is.getItem()).getLinkedGrid(is, player.level(), null);
readFromNbt();
}

Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ public void handle(Supplier<NetworkEvent.Context> 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;
Expand All @@ -47,7 +52,7 @@ public void handle(Supplier<NetworkEvent.Context> 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()));
});
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 44aa08b

Please sign in to comment.