mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
add Wireless Pattern Terminal Ex
This commit is contained in:
1 parent
95f34a7c29
commit
5ada5ddec3
11 files changed
+423
-10
No files matched your search
@@ -56,6 +56,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -75,6 +76,16 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
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"));
|
||||
@@ -121,6 +132,8 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
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);
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public class ContainerFluidPatternExWireless extends ContainerFluidPatternTerminalEx {
|
||||
|
||||
private double powerMultiplier = 0.5;
|
||||
private final IWirelessTerminal civ;
|
||||
private int ticks = 0;
|
||||
private final int slot;
|
||||
|
||||
public ContainerFluidPatternExWireless(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;
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,7 @@ import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.WirelessCraftingTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.*;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
@@ -52,6 +49,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_ULTRA_TERMINAL).toString());
|
||||
guis.add(GuiType.WIRELESS_CRAFTING_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX);
|
||||
guis.add(GuiType.WIRELESS_FLUID_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
if (ModAndClassUtil.ThE) {
|
||||
@@ -97,8 +95,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
}
|
||||
if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL) {
|
||||
return new WirelessPatternTerminalInventory(stack, x, gridNode, player);
|
||||
}
|
||||
if (gui == GuiType.WIRELESS_CRAFTING_TERMINAL) {
|
||||
} else if (gui == GuiType.WIRELESS_CRAFTING_TERMINAL) {
|
||||
return new WirelessCraftingTerminalInventory(stack, x, gridNode, player);
|
||||
} else if (ModAndClassUtil.ThE && gui == GuiType.WIRELESS_ESSENTIA_TERMINAL) {
|
||||
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
|
||||
@@ -106,6 +103,8 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
|
||||
} else if (gui == GuiType.WIRELESS_INTERFACE_TERMINAL) {
|
||||
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
|
||||
} else if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX) {
|
||||
return new WirelessPatternTerminalExInventory(stack, x, gridNode, player);
|
||||
} else {
|
||||
this.setMode(GuiType.WIRELESS_FLUID_TERMINAL, stack); // set as default mode
|
||||
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
|
||||
|
||||
@@ -247,6 +247,18 @@ public enum GuiType {
|
||||
return new GuiFluidPatternWireless(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
WIRELESS_FLUID_PATTERN_TERMINAL_EX(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new ContainerFluidPatternExWireless(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new GuiFluidPatternExWireless(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
WIRELESS_INTERFACE_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
|
||||
|
||||
@Override
|
||||
|
||||
+328
@@ -0,0 +1,328 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.MEMonitorHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.items.contents.WirelessTerminalViewCells;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
|
||||
import com.glodblock.github.inventory.WirelessFluidPatternTerminalPatterns;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItemStack>
|
||||
implements IWirelessPatternTerminal {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
private final AppEngInternalInventory viewCell;
|
||||
private final StorageChannel channel;
|
||||
private final IGridNode grid;
|
||||
|
||||
protected AppEngInternalInventory crafting;
|
||||
protected AppEngInternalInventory output;
|
||||
protected final WirelessFluidPatternTerminalPatterns pattern;
|
||||
|
||||
protected boolean craftingMode = false;
|
||||
protected boolean substitute = false;
|
||||
protected boolean combine = false;
|
||||
protected boolean prioritize = false;
|
||||
protected boolean inverted = false;
|
||||
protected boolean beSubstitute = false;
|
||||
protected int activePage = 0;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public WirelessPatternTerminalExInventory(final ItemStack is, final int slot, IGridNode gridNode,
|
||||
EntityPlayer player) {
|
||||
super(
|
||||
(IMEInventoryHandler<IAEItemStack>) Objects
|
||||
.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.ITEMS)));
|
||||
this.ips = (ToolWirelessTerminal) is.getItem();
|
||||
this.grid = gridNode;
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
this.viewCell = new WirelessTerminalViewCells(is);
|
||||
this.channel = StorageChannel.ITEMS;
|
||||
this.pattern = new WirelessFluidPatternTerminalPatterns(is);
|
||||
this.crafting = new ItemBiggerAppEngInventory(is, "crafting_ex", 32);
|
||||
this.output = new ItemBiggerAppEngInventory(is, "output_ex", 32);
|
||||
}
|
||||
|
||||
public StorageChannel getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
|
||||
amt = usePowerMultiplier.multiply(amt);
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
|
||||
}
|
||||
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void readFromNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
this.setSubstitution(data.getBoolean("substitute"));
|
||||
this.setCombineMode(data.getBoolean("combine"));
|
||||
this.setBeSubstitute(data.getBoolean("beSubstitute"));
|
||||
this.setPrioritization(data.getBoolean("priorization"));
|
||||
this.setInverted(data.getBoolean("inverted"));
|
||||
this.setActivePage(data.getInteger("activePage"));
|
||||
}
|
||||
|
||||
public void writeToNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
data.setBoolean("substitute", this.substitute);
|
||||
data.setBoolean("combine", this.combine);
|
||||
data.setBoolean("beSubstitute", this.beSubstitute);
|
||||
data.setBoolean("priorization", this.prioritize);
|
||||
data.setBoolean("inverted", this.inverted);
|
||||
data.setInteger("activePage", this.activePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
|
||||
final NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
manager.writeToNBT(data);
|
||||
});
|
||||
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
|
||||
this.readFromNBT();
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getViewCellStorage() {
|
||||
return this.viewCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir) {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak() {
|
||||
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
ItemStack newStack) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
private void fixCraftingRecipes() {
|
||||
if (this.craftingMode) {
|
||||
for (int x = 0; x < this.crafting.getSizeInventory(); x++) {
|
||||
final ItemStack is = this.crafting.getStackInSlot(x);
|
||||
if (is != null) {
|
||||
is.stackSize = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInverted() {
|
||||
return this.inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
if (name.equals("pattern")) {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeSubstitute() {
|
||||
return this.beSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritize() {
|
||||
return this.prioritize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubstitution() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombine() {
|
||||
return this.combine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
|
||||
IInventory crafting = this.getInventoryByName("crafting");
|
||||
IInventory output = this.getInventoryByName("output");
|
||||
if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) {
|
||||
for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) {
|
||||
final IAEItemStack item = newCrafting[x];
|
||||
crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
|
||||
final IAEItemStack item = newOutput[x];
|
||||
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCraftingRecipe(boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubstitution(boolean canSubstitute) {
|
||||
this.substitute = canSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeSubstitute(boolean canBeSubstitute) {
|
||||
this.beSubstitute = canBeSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCombineMode(boolean shouldCombine) {
|
||||
this.combine = shouldCombine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrioritization(boolean canPrioritize) {
|
||||
this.prioritize = canPrioritize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInverted(boolean inverted) {
|
||||
this.inverted = inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActivePage() {
|
||||
return this.activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivePage(int activePage) {
|
||||
this.activePage = activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCraftingRecipe() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortCraftingItems() {
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
List<ItemStack> fluids = new ArrayList<ItemStack>();
|
||||
for (ItemStack is : this.crafting) {
|
||||
if (is == null) continue;
|
||||
if (is.getItem() instanceof ItemFluidPacket) {
|
||||
fluids.add(is);
|
||||
} else {
|
||||
items.add(is);
|
||||
}
|
||||
}
|
||||
if (this.prioritize) {
|
||||
fluids.addAll(items);
|
||||
items.clear();
|
||||
} else {
|
||||
items.addAll(fluids);
|
||||
fluids.clear();
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
if (this.crafting.getStackInSlot(i) == null) break;
|
||||
if (items.isEmpty()) {
|
||||
this.crafting.setInventorySlotContents(i, fluids.get(i));
|
||||
} else {
|
||||
this.crafting.setInventorySlotContents(i, items.get(i));
|
||||
}
|
||||
}
|
||||
saveChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSettings() {
|
||||
this.writeToNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode() {
|
||||
return this.grid;
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,7 @@ import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiFluidCraftingWireless;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminalEx;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternWireless;
|
||||
import com.glodblock.github.client.gui.*;
|
||||
import com.glodblock.github.nei.recipes.FluidRecipe;
|
||||
|
||||
public class NEI_FC_Config implements IConfigureNEI {
|
||||
@@ -25,6 +22,10 @@ public class NEI_FC_Config implements IConfigureNEI {
|
||||
GuiFluidPatternWireless.class,
|
||||
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
|
||||
identifier);
|
||||
API.registerGuiOverlayHandler(
|
||||
GuiFluidPatternExWireless.class,
|
||||
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
|
||||
identifier);
|
||||
API.registerGuiOverlayHandler(
|
||||
GuiFluidPatternTerminal.class,
|
||||
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
|
||||
|
||||
Reference in new issue
Block a user