work on wireless pattern terminal
This commit is contained in:
@@ -53,7 +53,7 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
protected SlotPatternTerm craftSlot;
|
||||
protected SlotRestrictedInput patternSlotIN;
|
||||
protected SlotRestrictedInput patternSlotOUT;
|
||||
private IRecipe currentRecipe;
|
||||
protected IRecipe currentRecipe;
|
||||
|
||||
protected SlotFakeCraftingMatrix[] craftingSlots;
|
||||
protected OptionalSlotFake[] outputSlots;
|
||||
@@ -128,7 +128,20 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
|
||||
if (inv == this.crafting) {
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
private void fixCraftingRecipes() {
|
||||
if (this.isCraftingMode()) {
|
||||
for (int x = 0; x < this.crafting.getSlots(); x++) {
|
||||
final ItemStack is = this.crafting.getStackInSlot(x);
|
||||
if (!is.isEmpty()) {
|
||||
is.setCount(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,7 +228,6 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
Optional<ItemStack> maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack(1);
|
||||
if (maybePattern.isPresent()) {
|
||||
output = maybePattern.get();
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,6 +251,8 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
encodedValue.setBoolean("substitute", this.isSubstitute());
|
||||
|
||||
output.setTagCompound(encodedValue);
|
||||
|
||||
patternSlotOUT.putStack(output);
|
||||
}
|
||||
|
||||
public void multiply(int multiple) {
|
||||
@@ -489,8 +503,9 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
void setCraftingMode(final boolean craftingMode) {
|
||||
public void setCraftingMode(final boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
|
||||
|
||||
@@ -518,7 +533,7 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
if (nbtTagCompound.hasKey("isCraftingMode")) {
|
||||
boolean crafting = nbtTagCompound.getBoolean("isCraftingMode");
|
||||
if (this.isCraftingMode() != crafting) {
|
||||
this.setCraftingMode(crafting);
|
||||
this.setCraftingMode(isCraftingMode());
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
} else {
|
||||
@@ -538,7 +553,7 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
if (nbtTagCompound.hasKey("isSubstitute")) {
|
||||
boolean crafting = nbtTagCompound.getBoolean("isSubstitute");
|
||||
if (this.isCraftingMode() != crafting) {
|
||||
this.setCraftingMode(crafting);
|
||||
this.setCraftingMode(!crafting);
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -27,15 +27,10 @@ import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.OptionalSlotFake;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.container.slot.SlotPatternOutputs;
|
||||
import appeng.container.slot.SlotPatternTerm;
|
||||
import appeng.container.slot.SlotPlayerHotBar;
|
||||
import appeng.container.slot.SlotPlayerInv;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
@@ -48,10 +43,8 @@ import appeng.util.item.AEItemStack;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.InventoryCraftResult;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
@@ -60,7 +53,7 @@ import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
|
||||
public class ContainerPatternTerm extends ContainerPatternEncoder {
|
||||
|
||||
|
||||
|
||||
public ContainerPatternTerm(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable, false);
|
||||
|
||||
+36
-15
@@ -35,20 +35,25 @@ import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import static appeng.helpers.PatternHelper.CRAFTING_GRID_DIMENSION;
|
||||
|
||||
|
||||
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;
|
||||
@@ -56,6 +61,10 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder {
|
||||
public ContainerWirelessPatternTerminal(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) {
|
||||
super(ip, gui, gui, false);
|
||||
|
||||
this.crafting = new AppEngInternalInventory(this, CRAFTING_GRID_DIMENSION * CRAFTING_GRID_DIMENSION);
|
||||
this.output = new AppEngInternalInventory(this, 3);
|
||||
this.pattern = new AppEngInternalInventory(this, 2);
|
||||
|
||||
this.craftingSlots = new SlotFakeCraftingMatrix[9];
|
||||
this.outputSlots = new OptionalSlotFake[3];
|
||||
|
||||
@@ -68,6 +77,9 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder {
|
||||
this.lockPlayerInventorySlot(ip.currentItem);
|
||||
}
|
||||
this.civ = gui;
|
||||
this.wirelessTerminalGUIObject = gui;
|
||||
|
||||
this.loadFromNBT();
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
@@ -76,7 +88,7 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder {
|
||||
}
|
||||
|
||||
this.addSlotToContainer(this.craftSlot = new SlotPatternTerm(ip.player, this.getActionSource(), this
|
||||
.getPowerSource(), gui, this.crafting, patternInv, this.cOut, 110, -76 + 18, this, 2, this));
|
||||
.getPowerSource(), gui, this.crafting, pattern, this.cOut, 110, -76 + 18, this, 2, this));
|
||||
this.craftSlot.setIIcon(-1);
|
||||
|
||||
for (int y = 0; y < this.outputSlots.length; y++) {
|
||||
@@ -86,20 +98,17 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder {
|
||||
}
|
||||
|
||||
this.addSlotToContainer(
|
||||
this.patternSlotIN = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, this
|
||||
this.patternSlotIN = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, pattern, 0, 147, -72 - 9, this
|
||||
.getInventoryPlayer()));
|
||||
this.addSlotToContainer(
|
||||
this.patternSlotOUT = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34, this
|
||||
this.patternSlotOUT = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, pattern, 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
|
||||
@@ -146,10 +155,19 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder {
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
boolean crafting = false;
|
||||
if (Platform.isServer()) {
|
||||
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
|
||||
if (nbtTagCompound != null) {
|
||||
if (nbtTagCompound.hasKey("isCraftingMode")) {
|
||||
crafting = nbtTagCompound.getBoolean("isCraftingMode");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (idx == 1) {
|
||||
return Platform.isServer() ? !this.getPart().isCraftingRecipe() : !this.isCraftingMode();
|
||||
return Platform.isServer() ? !crafting : !this.isCraftingMode();
|
||||
} else if (idx == 2) {
|
||||
return Platform.isServer() ? this.getPart().isCraftingRecipe() : this.isCraftingMode();
|
||||
return Platform.isServer() ? crafting : this.isCraftingMode();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -159,7 +177,10 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder {
|
||||
public void saveChanges() {
|
||||
if (Platform.isServer()) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.craftingGrid.writeToNBT(tag, "craftingGrid");
|
||||
((AppEngInternalInventory) crafting).writeToNBT(tag, "craftingGrid");
|
||||
|
||||
this.output.writeToNBT(tag, "output");
|
||||
this.pattern.writeToNBT(tag, "patterns");
|
||||
this.wirelessTerminalGUIObject.saveChanges(tag);
|
||||
}
|
||||
}
|
||||
@@ -167,15 +188,15 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder {
|
||||
private void loadFromNBT() {
|
||||
NBTTagCompound data = wirelessTerminalGUIObject.getItemStack().getTagCompound();
|
||||
if (data != null) {
|
||||
this.craftingGrid.readFromNBT(data, "craftingGrid");
|
||||
((AppEngInternalInventory) crafting).readFromNBT(data, "craftingGrid");
|
||||
this.output.readFromNBT(data, "output");
|
||||
this.pattern.readFromNBT(data, "patterns");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack) {
|
||||
if (inv == craftingGrid) {
|
||||
saveChanges();
|
||||
}
|
||||
super.onChangeInventory(inv, slot, mc, removedStack, newStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -130,10 +130,10 @@ public class PacketValueConfig extends AppEngPacket {
|
||||
final ContainerFluidLevelEmitter lvc = (ContainerFluidLevelEmitter) c;
|
||||
lvc.setLevel(Long.parseLong(this.Value), player);
|
||||
} else if (this.Name.startsWith("PatternTerminal.")) {
|
||||
if (c instanceof ContainerPatternTerm) {
|
||||
final ContainerPatternTerm cpt = (ContainerPatternTerm) c;
|
||||
if (c instanceof ContainerPatternEncoder) {
|
||||
final ContainerPatternEncoder cpt = (ContainerPatternEncoder) c;
|
||||
if (this.Name.equals("PatternTerminal.CraftMode")) {
|
||||
cpt.getPart().setCraftingRecipe(this.Value.equals("1"));
|
||||
cpt.setCraftingMode(this.Value.equals("1"));
|
||||
} else if (this.Name.equals("PatternTerminal.Encode")) {
|
||||
if (this.Value.equals("2")) {
|
||||
cpt.encodeAndMoveToInventory();
|
||||
@@ -159,31 +159,6 @@ public class PacketValueConfig extends AppEngPacket {
|
||||
} else if (this.Name.equals("PatternTerminal.Substitute")) {
|
||||
cpt.getPart().setSubstitution(this.Value.equals("1"));
|
||||
}
|
||||
} else if (c instanceof ContainerExpandedProcessingPatternTerm) {
|
||||
final ContainerExpandedProcessingPatternTerm cept = (ContainerExpandedProcessingPatternTerm) c;
|
||||
if (this.Name.equals("PatternTerminal.Encode")) {
|
||||
if (this.Value.equals("2")) {
|
||||
cept.encodeAndMoveToInventory();
|
||||
} else {
|
||||
cept.encode();
|
||||
}
|
||||
} else if (this.Name.equals("PatternTerminal.Clear")) {
|
||||
cept.clear();
|
||||
} else if (this.Name.equals("PatternTerminal.MultiplyByTwo")) {
|
||||
cept.multiply(2);
|
||||
} else if (this.Name.equals("PatternTerminal.MultiplyByThree")) {
|
||||
cept.multiply(3);
|
||||
} else if (this.Name.equals("PatternTerminal.DivideByTwo")) {
|
||||
cept.divide(2);
|
||||
} else if (this.Name.equals("PatternTerminal.DivideByThree")) {
|
||||
cept.divide(3);
|
||||
} else if (this.Name.equals("PatternTerminal.IncreaseByOne")) {
|
||||
cept.increase(1);
|
||||
} else if (this.Name.equals("PatternTerminal.DecreaseByOne")) {
|
||||
cept.decrease(1);
|
||||
} else if (this.Name.equals("PatternTerminal.MaximizeCount")) {
|
||||
cept.maximizeCount();
|
||||
}
|
||||
}
|
||||
} else if (this.Name.startsWith("StorageBus.")) {
|
||||
if (this.Name.equals("StorageBus.Action")) {
|
||||
|
||||
Reference in New Issue
Block a user