wip
This commit is contained in:
@@ -25,7 +25,9 @@ import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerPatternEncoder;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.implementations.ContainerWirelessPatternTerminal;
|
||||
import appeng.container.interfaces.IJEIGhostIngredients;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotFake;
|
||||
@@ -35,6 +37,7 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import mezz.jei.api.gui.IGhostIngredientHandler.Target;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -60,7 +63,7 @@ public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredi
|
||||
private static final String CRAFTMODE_CRFTING = "1";
|
||||
private static final String CRAFTMODE_PROCESSING = "0";
|
||||
|
||||
private final ContainerPatternTerm container;
|
||||
private final ContainerPatternEncoder container;
|
||||
|
||||
private GuiTabButton tabCraftButton;
|
||||
private GuiTabButton tabProcessButton;
|
||||
@@ -83,6 +86,12 @@ public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredi
|
||||
this.setReservedSpace(81);
|
||||
}
|
||||
|
||||
public GuiPatternTerm(final InventoryPlayer inventoryPlayer, WirelessTerminalGuiObject te, final ContainerWirelessPatternTerminal wpt) {
|
||||
super(inventoryPlayer, te, wpt);
|
||||
this.container = (ContainerWirelessPatternTerminal) this.inventorySlots;
|
||||
this.setReservedSpace(81);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
@@ -19,18 +19,18 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.container.implementations.ContainerWirelessCraftingTerminal;
|
||||
import appeng.container.implementations.ContainerWirelessPatternTerminal;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
|
||||
public class GuiWirelessPatternTerminal extends GuiMEPortableCell {
|
||||
public class GuiWirelessPatternTerminal extends GuiPatternTerm {
|
||||
|
||||
public GuiWirelessPatternTerminal(final InventoryPlayer inventoryPlayer, final IPortableCell te) {
|
||||
super(inventoryPlayer, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMaxRows() {
|
||||
return this.defaultGetMaxRows();
|
||||
public GuiWirelessPatternTerminal(final InventoryPlayer inventoryPlayer, final WirelessTerminalGuiObject te) {
|
||||
super(inventoryPlayer, te, new ContainerWirelessPatternTerminal(inventoryPlayer, te));
|
||||
this.setReservedSpace(81);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package appeng.container.implementations;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
@@ -42,7 +43,9 @@ import static appeng.helpers.ItemStackHelper.stackWriteToNBT;
|
||||
|
||||
public abstract class ContainerPatternEncoder extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
|
||||
|
||||
private final AbstractPartEncoder patternTerminal;
|
||||
protected AbstractPartEncoder patternTerminal = null;
|
||||
|
||||
protected IGuiItemObject iGuiItemObject = null;
|
||||
|
||||
final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
|
||||
|
||||
@@ -70,6 +73,14 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
patternTerminal = (AbstractPartEncoder) monitorable;
|
||||
}
|
||||
|
||||
protected ContainerPatternEncoder(InventoryPlayer ip, ITerminalHost monitorable, IGuiItemObject iGuiItemObject, boolean bindInventory) {
|
||||
super(ip, monitorable, iGuiItemObject, bindInventory);
|
||||
if (monitorable instanceof AbstractPartEncoder) {
|
||||
patternTerminal = (AbstractPartEncoder) monitorable;
|
||||
}
|
||||
this.iGuiItemObject = iGuiItemObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
|
||||
if (Platform.isClient()) {
|
||||
@@ -99,7 +110,10 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
if (name.equals("player")) {
|
||||
return new PlayerInvWrapper(this.getInventoryPlayer());
|
||||
}
|
||||
return this.getPart().getInventoryByName(name);
|
||||
if (this.getPart() != null) {
|
||||
return this.getPart().getInventoryByName(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -492,12 +506,50 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
if (Platform.isServer()) {
|
||||
if (this.isCraftingMode() != this.getPart().isCraftingRecipe()) {
|
||||
this.setCraftingMode(this.getPart().isCraftingRecipe());
|
||||
this.updateOrderOfOutputSlots();
|
||||
if (getPart() != null) {
|
||||
if (this.isCraftingMode() != this.getPart().isCraftingRecipe()) {
|
||||
this.setCraftingMode(this.getPart().isCraftingRecipe());
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
}
|
||||
if (iGuiItemObject != null) {
|
||||
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
|
||||
if (nbtTagCompound != null) {
|
||||
if (nbtTagCompound.hasKey("isCraftingMode")) {
|
||||
boolean crafting = nbtTagCompound.getBoolean("isCraftingMode");
|
||||
if (this.isCraftingMode() != crafting) {
|
||||
this.setCraftingMode(crafting);
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
} else {
|
||||
nbtTagCompound.setBoolean("isCraftingMode", false);
|
||||
}
|
||||
} else {
|
||||
nbtTagCompound = new NBTTagCompound();
|
||||
nbtTagCompound.setBoolean("isCraftingMode", false);
|
||||
iGuiItemObject.getItemStack().setTagCompound(nbtTagCompound);
|
||||
}
|
||||
}
|
||||
if (getPart() != null) {
|
||||
this.substitute = this.getPart().isSubstitution();
|
||||
} else if (iGuiItemObject != null) {
|
||||
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
|
||||
if (nbtTagCompound != null) {
|
||||
if (nbtTagCompound.hasKey("isSubstitute")) {
|
||||
boolean crafting = nbtTagCompound.getBoolean("isSubstitute");
|
||||
if (this.isCraftingMode() != crafting) {
|
||||
this.setCraftingMode(crafting);
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
} else {
|
||||
nbtTagCompound.setBoolean("isSubstitute", false);
|
||||
}
|
||||
} else {
|
||||
nbtTagCompound = new NBTTagCompound();
|
||||
nbtTagCompound.setBoolean("isSubstitute", false);
|
||||
iGuiItemObject.getItemStack().setTagCompound(nbtTagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
this.substitute = this.getPart().isSubstitution();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotCraftingTerm;
|
||||
|
||||
+136
-3
@@ -19,25 +19,109 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
import appeng.container.slot.OptionalSlotFake;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.container.slot.SlotPatternOutputs;
|
||||
import appeng.container.slot.SlotPatternTerm;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
|
||||
public class ContainerWirelessPatternTerminal extends ContainerMEPortableCell {
|
||||
public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder {
|
||||
|
||||
private final WirelessTerminalGuiObject wirelessTerminalGUIObject;
|
||||
|
||||
private double powerMultiplier = 0.5;
|
||||
protected final IPortableCell civ;
|
||||
private int ticks = 0;
|
||||
private final int slot;
|
||||
private final AppEngInternalInventory craftingGrid = new AppEngInternalInventory(this, 9);
|
||||
|
||||
protected AppEngInternalInventory output;
|
||||
protected AppEngInternalInventory pattern;
|
||||
|
||||
public ContainerWirelessPatternTerminal(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) {
|
||||
super(ip, gui);
|
||||
super(ip, gui, gui, false);
|
||||
|
||||
this.craftingSlots = new SlotFakeCraftingMatrix[9];
|
||||
this.outputSlots = new OptionalSlotFake[3];
|
||||
|
||||
if (gui != null) {
|
||||
final int slotIndex = gui.getInventorySlot();
|
||||
this.lockPlayerInventorySlot(slotIndex);
|
||||
this.slot = slotIndex;
|
||||
} else {
|
||||
this.slot = -1;
|
||||
this.lockPlayerInventorySlot(ip.currentItem);
|
||||
}
|
||||
this.civ = gui;
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
this.addSlotToContainer(this.craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix(this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
this.addSlotToContainer(this.craftSlot = new SlotPatternTerm(ip.player, this.getActionSource(), this
|
||||
.getPowerSource(), gui, this.crafting, patternInv, this.cOut, 110, -76 + 18, this, 2, this));
|
||||
this.craftSlot.setIIcon(-1);
|
||||
|
||||
for (int y = 0; y < this.outputSlots.length; y++) {
|
||||
this.addSlotToContainer(this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1));
|
||||
this.outputSlots[y].setRenderDisabled(false);
|
||||
this.outputSlots[y].setIIcon(-1);
|
||||
}
|
||||
|
||||
this.addSlotToContainer(
|
||||
this.patternSlotIN = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, this
|
||||
.getInventoryPlayer()));
|
||||
this.addSlotToContainer(
|
||||
this.patternSlotOUT = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34, this
|
||||
.getInventoryPlayer()));
|
||||
|
||||
this.patternSlotOUT.setStackLimit(1);
|
||||
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
this.updateOrderOfOutputSlots();
|
||||
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
this.wirelessTerminalGUIObject = gui;
|
||||
this.loadFromNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot);
|
||||
|
||||
if (this.civ == null || currentItem.isEmpty()) {
|
||||
this.setValidContainer(false);
|
||||
} else if (this.civ != null && !this.civ.getItemStack().isEmpty() && currentItem != this.civ.getItemStack()) {
|
||||
if (ItemStack.areItemsEqual(this.civ.getItemStack(), currentItem)) {
|
||||
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.civ.getItemStack());
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
|
||||
// drain 1 ae t
|
||||
this.ticks++;
|
||||
if (this.ticks > 10) {
|
||||
this.civ.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
this.ticks = 0;
|
||||
}
|
||||
|
||||
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
|
||||
if (Platform.isServer() && this.isValidContainer()) {
|
||||
@@ -48,5 +132,54 @@ public class ContainerWirelessPatternTerminal extends ContainerMEPortableCell {
|
||||
} else {
|
||||
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
private double getPowerMultiplier() {
|
||||
return this.powerMultiplier;
|
||||
}
|
||||
|
||||
void setPowerMultiplier(final double powerMultiplier) {
|
||||
this.powerMultiplier = powerMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
if (idx == 1) {
|
||||
return Platform.isServer() ? !this.getPart().isCraftingRecipe() : !this.isCraftingMode();
|
||||
} else if (idx == 2) {
|
||||
return Platform.isServer() ? this.getPart().isCraftingRecipe() : this.isCraftingMode();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
if (Platform.isServer()) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.craftingGrid.writeToNBT(tag, "craftingGrid");
|
||||
this.wirelessTerminalGUIObject.saveChanges(tag);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFromNBT() {
|
||||
NBTTagCompound data = wirelessTerminalGUIObject.getItemStack().getTagCompound();
|
||||
if (data != null) {
|
||||
this.craftingGrid.readFromNBT(data, "craftingGrid");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack) {
|
||||
if (inv == craftingGrid) {
|
||||
saveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useRealItems() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ToolWirelessPatternTerminal extends AEBasePoweredItem implements IW
|
||||
|
||||
@Override
|
||||
public boolean canHandle(final ItemStack is) {
|
||||
return AEApi.instance().definitions().items().wirelessFluidTerminal().isSameAs(is);
|
||||
return AEApi.instance().definitions().items().wirelessPatternTerminal().isSameAs(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user