refresh status if a encoded pattern is put in the output slot
This commit is contained in:
@@ -133,7 +133,7 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fixCraftingRecipes() {
|
void fixCraftingRecipes() {
|
||||||
if (this.isCraftingMode()) {
|
if (this.isCraftingMode()) {
|
||||||
for (int x = 0; x < this.crafting.getSlots(); x++) {
|
for (int x = 0; x < this.crafting.getSlots(); x++) {
|
||||||
final ItemStack is = this.crafting.getStackInSlot(x);
|
final ItemStack is = this.crafting.getStackInSlot(x);
|
||||||
@@ -505,7 +505,18 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
|||||||
|
|
||||||
public void setCraftingMode(final boolean craftingMode) {
|
public void setCraftingMode(final boolean craftingMode) {
|
||||||
this.craftingMode = craftingMode;
|
this.craftingMode = craftingMode;
|
||||||
this.fixCraftingRecipes();
|
if (getPart() != null) {
|
||||||
|
getPart().setCraftingRecipe(craftingMode);
|
||||||
|
} else if (iGuiItemObject != null) {
|
||||||
|
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
|
||||||
|
if (nbtTagCompound != null) {
|
||||||
|
nbtTagCompound.setBoolean("isCraftingMode", craftingMode);
|
||||||
|
this.updateOrderOfOutputSlots();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (craftingMode) {
|
||||||
|
this.fixCraftingRecipes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -526,14 +537,15 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
|||||||
this.setCraftingMode(this.getPart().isCraftingRecipe());
|
this.setCraftingMode(this.getPart().isCraftingRecipe());
|
||||||
this.updateOrderOfOutputSlots();
|
this.updateOrderOfOutputSlots();
|
||||||
}
|
}
|
||||||
|
this.substitute = this.getPart().isSubstitution();
|
||||||
}
|
}
|
||||||
if (iGuiItemObject != null) {
|
else if (iGuiItemObject != null) {
|
||||||
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
|
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
|
||||||
if (nbtTagCompound != null) {
|
if (nbtTagCompound != null) {
|
||||||
if (nbtTagCompound.hasKey("isCraftingMode")) {
|
if (nbtTagCompound.hasKey("isCraftingMode")) {
|
||||||
boolean crafting = nbtTagCompound.getBoolean("isCraftingMode");
|
boolean crafting = nbtTagCompound.getBoolean("isCraftingMode");
|
||||||
if (this.isCraftingMode() != crafting) {
|
if (this.isCraftingMode() != crafting) {
|
||||||
this.setCraftingMode(isCraftingMode());
|
this.setCraftingMode(crafting);
|
||||||
this.updateOrderOfOutputSlots();
|
this.updateOrderOfOutputSlots();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -544,17 +556,12 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
|||||||
nbtTagCompound.setBoolean("isCraftingMode", false);
|
nbtTagCompound.setBoolean("isCraftingMode", false);
|
||||||
iGuiItemObject.getItemStack().setTagCompound(nbtTagCompound);
|
iGuiItemObject.getItemStack().setTagCompound(nbtTagCompound);
|
||||||
}
|
}
|
||||||
}
|
nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
|
||||||
if (getPart() != null) {
|
|
||||||
this.substitute = this.getPart().isSubstitution();
|
|
||||||
} else if (iGuiItemObject != null) {
|
|
||||||
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
|
|
||||||
if (nbtTagCompound != null) {
|
if (nbtTagCompound != null) {
|
||||||
if (nbtTagCompound.hasKey("isSubstitute")) {
|
if (nbtTagCompound.hasKey("isSubstitute")) {
|
||||||
boolean crafting = nbtTagCompound.getBoolean("isSubstitute");
|
boolean substitute = nbtTagCompound.getBoolean("isSubstitute");
|
||||||
if (this.isCraftingMode() != crafting) {
|
if (this.isSubstitute() != substitute) {
|
||||||
this.setCraftingMode(!crafting);
|
this.setSubstitute(substitute);
|
||||||
this.updateOrderOfOutputSlots();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nbtTagCompound.setBoolean("isSubstitute", false);
|
nbtTagCompound.setBoolean("isSubstitute", false);
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ package appeng.container.implementations;
|
|||||||
|
|
||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
import appeng.api.config.PowerMultiplier;
|
import appeng.api.config.PowerMultiplier;
|
||||||
|
import appeng.api.implementations.ICraftingPatternItem;
|
||||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||||
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.container.interfaces.IInventorySlotAware;
|
import appeng.container.interfaces.IInventorySlotAware;
|
||||||
import appeng.container.slot.OptionalSlotFake;
|
import appeng.container.slot.OptionalSlotFake;
|
||||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||||
@@ -30,9 +33,11 @@ import appeng.container.slot.SlotPatternTerm;
|
|||||||
import appeng.container.slot.SlotRestrictedInput;
|
import appeng.container.slot.SlotRestrictedInput;
|
||||||
import appeng.core.AEConfig;
|
import appeng.core.AEConfig;
|
||||||
import appeng.core.localization.PlayerMessages;
|
import appeng.core.localization.PlayerMessages;
|
||||||
|
import appeng.helpers.ItemStackHelper;
|
||||||
import appeng.helpers.WirelessTerminalGuiObject;
|
import appeng.helpers.WirelessTerminalGuiObject;
|
||||||
import appeng.tile.inventory.AppEngInternalInventory;
|
import appeng.tile.inventory.AppEngInternalInventory;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
import appeng.util.helpers.ItemHandlerUtil;
|
||||||
import appeng.util.inv.InvOperation;
|
import appeng.util.inv.InvOperation;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
@@ -196,6 +201,27 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack) {
|
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack) {
|
||||||
|
if (inv == this.pattern && slot == 1) {
|
||||||
|
final ItemStack is = this.pattern.getStackInSlot(1);
|
||||||
|
if (!is.isEmpty() && is.getItem() instanceof ICraftingPatternItem) {
|
||||||
|
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
|
||||||
|
final ICraftingPatternDetails details = pattern.getPatternForItem(is, this.getPlayerInv().player.world);
|
||||||
|
if (details != null) {
|
||||||
|
this.setCraftingMode(details.isCraftable());
|
||||||
|
this.setSubstitute(details.canSubstitute());
|
||||||
|
|
||||||
|
for (int x = 0; x < this.crafting.getSlots() && x < details.getInputs().length; x++) {
|
||||||
|
final IAEItemStack item = details.getInputs()[x];
|
||||||
|
ItemHandlerUtil.setStackInSlot(this.crafting, x, item == null ? ItemStack.EMPTY : item.createItemStack());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int x = 0; x < this.output.getSlots() && x < details.getOutputs().length; x++) {
|
||||||
|
final IAEItemStack item = details.getOutputs()[x];
|
||||||
|
this.output.setStackInSlot(x, item == null ? ItemStack.EMPTY : item.createItemStack());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
super.onChangeInventory(inv, slot, mc, removedStack, newStack);
|
super.onChangeInventory(inv, slot, mc, removedStack, newStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user