Skip to content

Commit

Permalink
Merge pull request #79 from asdflj/master
Browse files Browse the repository at this point in the history
Universal wireless terminal support processing pattern terminal mode
  • Loading branch information
GlodBlock authored Feb 10, 2023
2 parents 2812153 + e92cffd commit 45e0dcb
Show file tree
Hide file tree
Showing 26 changed files with 723 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public GuiFCImgButton(final int x, final int y, final String idx, final String v
this.registerApp(12, "PATTERN_TEM", "YES", "pattern_terminal_w");
this.registerApp(13, "ESSENTIA_TEM", "YES", "essentia_terminal_w");
this.registerApp(14, "INTERFACE_TEM", "YES", "interface_terminal_w");
this.registerApp(15, "PATTERN_EX_TEM", "YES", "pattern_terminal_ex_w");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.glodblock.github.client.gui;

import net.minecraft.entity.player.InventoryPlayer;

import com.glodblock.github.inventory.item.IWirelessTerminal;

public class GuiFluidPatternExWireless extends GuiFluidPatternTerminalEx {

public GuiFluidPatternExWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
protected GuiFCImgButton PatternTerminal;
protected GuiFCImgButton EssentiaTerminal;
protected GuiFCImgButton InterfaceTerminal;
protected GuiFCImgButton PatternTerminaleEx;
protected List<GuiFCImgButton> termBtns = new ArrayList<>();
protected boolean drawSwitchGuiBtn;

Expand Down Expand Up @@ -75,6 +76,16 @@ protected void drawSwitchGuiBtns() {
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.PatternTerminal);
}
if (!(this instanceof GuiFluidPatternExWireless)) {
this.buttonList.add(
this.PatternTerminaleEx = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"PATTERN_EX_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.PatternTerminaleEx);
}
if (!(this instanceof GuiFluidPortableCell)) {
this.buttonList.add(
this.FluidTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "FLUID_TEM", "YES"));
Expand Down Expand Up @@ -121,6 +132,8 @@ protected void actionPerformed(final GuiButton btn) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
} else if (btn == this.InterfaceTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_INTERFACE_TERMINAL);
} else if (btn == this.PatternTerminaleEx) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX);
}
}
super.actionPerformed(btn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,17 @@

import com.glodblock.github.inventory.item.IWirelessCraftTerminal;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.Util;

public class ContainerCraftingWireless extends ContainerItemMonitor
implements IAEAppEngInventory, IContainerCraftingPacket {

private final IWirelessCraftTerminal it;
private final SlotCraftingMatrix[] craftingSlots = new SlotCraftingMatrix[9];
private final SlotCraftingTerm outputSlot;
private final int slot;
private int ticks = 0;
private double powerMultiplier = 0.5;

public ContainerCraftingWireless(final InventoryPlayer ip, final IWirelessTerminal monitorable) {
super(ip, monitorable, false);
this.it = (IWirelessCraftTerminal) monitorable;
final int slotIndex = monitorable.getInventorySlot();
this.lockPlayerInventorySlot(slotIndex);
this.slot = slotIndex;
final IInventory crafting = this.it.getInventoryByName("crafting");
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
Expand Down Expand Up @@ -63,14 +56,9 @@ public ContainerCraftingWireless(final InventoryPlayer ip, final IWirelessTermin
this.onCraftMatrixChanged(crafting);
}

public void detectAndSendChanges() {
this.ticks = Util
.drainItemPower(this, this.getPlayerInv(), this.slot, this.ticks, this.getPowerMultiplier(), this.it);
super.detectAndSendChanges();
}

private double getPowerMultiplier() {
return this.powerMultiplier;
@Override
protected boolean isWirelessTerminal() {
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,9 @@ public void postChange(Iterable<IAEFluidStack> change, ItemStack fluidContainer,
protected boolean isEssentiaMode() {
return false;
}

@Override
protected boolean isWirelessTerminal() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.glodblock.github.client.gui.container;

import net.minecraft.entity.player.InventoryPlayer;

import com.glodblock.github.inventory.item.IWirelessTerminal;

public class ContainerFluidPatternExWireless extends ContainerFluidPatternTerminalEx {

public ContainerFluidPatternExWireless(InventoryPlayer ip, IWirelessTerminal monitorable) {
super(ip, monitorable);
}

@Override
protected boolean isWirelessTerminal() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,15 @@
import net.minecraft.entity.player.InventoryPlayer;

import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.Util;

public class ContainerFluidPatternWireless extends ContainerFluidPatternTerminal {

private double powerMultiplier = 0.5;
private final IWirelessTerminal civ;
private int ticks = 0;
private final int slot;

public ContainerFluidPatternWireless(InventoryPlayer ip, IWirelessTerminal monitorable) {
super(ip, monitorable);
if (monitorable != null) {
final int slotIndex = monitorable.getInventorySlot();
this.lockPlayerInventorySlot(slotIndex);
this.slot = slotIndex;
} else {
this.slot = -1;
this.lockPlayerInventorySlot(ip.currentItem);
}
this.civ = monitorable;
}

public void detectAndSendChanges() {
this.ticks = Util
.drainItemPower(this, this.getPlayerInv(), this.slot, this.ticks, this.getPowerMultiplier(), this.civ);
super.detectAndSendChanges();
}

private double getPowerMultiplier() {
return this.powerMultiplier;
}

void setPowerMultiplier(final double powerMultiplier) {
this.powerMultiplier = powerMultiplier;
@Override
protected boolean isWirelessTerminal() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,17 @@
import net.minecraft.entity.player.InventoryPlayer;

import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.util.Util;

public class ContainerFluidPortableCell extends ContainerFluidMonitor {

private double powerMultiplier = 0.5;
private final IFluidPortableCell civ;
private int ticks = 0;
private final int slot;

public ContainerFluidPortableCell(final InventoryPlayer ip, final IFluidPortableCell monitorable) {
super(ip, monitorable, false);
if (monitorable != null) {
final int slotIndex = monitorable.getInventorySlot();
this.lockPlayerInventorySlot(slotIndex);
this.slot = slotIndex;
} else {
this.slot = -1;
this.lockPlayerInventorySlot(ip.currentItem);
}
this.civ = monitorable;
this.bindPlayerInventory(ip, 0, 0);
}

@Override
public void detectAndSendChanges() {
this.ticks = Util
.drainItemPower(this, this.getPlayerInv(), this.slot, this.ticks, this.getPowerMultiplier(), this.civ);
super.detectAndSendChanges();
}

private double getPowerMultiplier() {
return this.powerMultiplier;
protected boolean isWirelessTerminal() {
return true;
}

void setPowerMultiplier(final double powerMultiplier) {
this.powerMultiplier = powerMultiplier;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.IActionHost;
import appeng.container.AEBaseContainer;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketCompressedNBT;
import appeng.helpers.DualityInterface;
Expand All @@ -33,15 +32,14 @@
import appeng.util.inv.ItemSlot;
import appeng.util.inv.WrapperInvSlot;

import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.item.IWirelessInterfaceTerminal;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.Util;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;

public class ContainerInterfaceWireless extends AEBaseContainer {
public class ContainerInterfaceWireless extends FCBaseContainer {

/**
* this stuff is all server side..
Expand All @@ -50,20 +48,12 @@ public class ContainerInterfaceWireless extends AEBaseContainer {

private final Multimap<IInterfaceHost, ContainerInterfaceWireless.InvTracker> diList = HashMultimap.create();
private final Map<Long, ContainerInterfaceWireless.InvTracker> byId = new HashMap<Long, ContainerInterfaceWireless.InvTracker>();
private final IWirelessInterfaceTerminal it;
// private final Map<Long, InvTracker> byId = new HashMap<>();
private IGrid grid;
private NBTTagCompound data = new NBTTagCompound();
private int ticks;
private final int slot;
private double powerMultiplier = 0.5;

public ContainerInterfaceWireless(final InventoryPlayer ip, final IWirelessTerminal monitorable) {
super(ip, monitorable);
this.it = (IWirelessInterfaceTerminal) monitorable;
final int slotIndex = monitorable.getInventorySlot();
this.lockPlayerInventorySlot(slotIndex);
this.slot = slotIndex;
if (Platform.isServer()) {
this.grid = monitorable.getActionableNode().getGrid();
}
Expand All @@ -81,17 +71,11 @@ private Set<IGridNode> getMachineNodes() {
return union;
}

private double getPowerMultiplier() {
return this.powerMultiplier;
}

@Override
public void detectAndSendChanges() {
if (Platform.isClient()) {
return;
}
this.ticks = Util
.drainItemPower(this, this.getPlayerInv(), this.slot, this.ticks, this.getPowerMultiplier(), this.it);
super.detectAndSendChanges();

if (this.grid == null) {
Expand Down Expand Up @@ -300,6 +284,11 @@ private void regenList(final NBTTagCompound data) {
}
}

@Override
protected boolean isWirelessTerminal() {
return true;
}

private boolean isDifferent(final ItemStack a, final ItemStack b) {
if (a == null && b == null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,9 @@ public void postChange(final IBaseMonitor<IAEItemStack> monitor, final Iterable<
this.items.add(is);
}
}

@Override
protected boolean isWirelessTerminal() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.glodblock.github.client.gui.container.base;

import net.minecraft.entity.player.InventoryPlayer;

import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;

import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.util.Util;

public abstract class FCBaseContainer extends AEBaseContainer {

private int ticks;
private final double powerMultiplier = 0.5;
private IFluidPortableCell host;
private int slot = -1;
private final InventoryPlayer ip;

public FCBaseContainer(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
this.ip = ip;
if (isWirelessTerminal()) {
host = (IFluidPortableCell) monitorable;
this.slot = lockSlot();
}
}

private int lockSlot() {
if (isWirelessTerminal()) {
if (this.host != null) {
final int slotIndex = this.host.getInventorySlot();
this.lockPlayerInventorySlot(slotIndex);
return slotIndex;
} else {
this.lockPlayerInventorySlot(ip.currentItem);
}
}
return -1;
}

protected abstract boolean isWirelessTerminal();

public void detectAndSendChanges() {
if (isWirelessTerminal()) {
this.ticks = Util.drainItemPower(
this,
this.getPlayerInv(),
this.slot,
this.ticks,
this.getPowerMultiplier(),
this.host);
}
super.detectAndSendChanges();
}

public double getPowerMultiplier() {
return this.powerMultiplier;
}

}
Loading

0 comments on commit 45e0dcb

Please sign in to comment.