Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1eec160b74 | |||
| de23b62493 | |||
| 2b6299f2b0 | |||
| b495c972c4 | |||
| 7722dcc720 | |||
| c4d5add5f1 | |||
| 348e6436b8 | |||
| 92457ac680 | |||
| 9e53737635 | |||
| 0e0729166f | |||
| 15a1e8f150 | |||
| b443f1ce57 | |||
| 486a68d06b | |||
| 9b263c5501 | |||
| daf4910548 | |||
| 4f5bdfefe8 | |||
| c9f1387098 | |||
| 1f1d6d041a | |||
| 403a6e8b4a | |||
| 0a0c23c190 | |||
| d28cd798e9 | |||
| 3dedb7eefb | |||
| ae3295d3c9 | |||
| 4bac5f43db | |||
| 2e9a5dc8ea | |||
| 9ac4ea4e6e | |||
| 601faf5087 | |||
| 88e3df897e | |||
| f57a8cefda | |||
| d3fdac2b81 |
+1
-1
@@ -4,7 +4,7 @@ aebuild=7
|
||||
aegroup=appeng
|
||||
aebasename=appliedenergistics2
|
||||
extended=extended_life
|
||||
extendedversion=v0.53.8
|
||||
extendedversion=v0.54.2
|
||||
#########################################################
|
||||
# Versions #
|
||||
#########################################################
|
||||
|
||||
@@ -60,8 +60,16 @@ task sourceJar(type: Jar, overwrite: true) {
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
task devJar(type: Jar, overwrite: true) {
|
||||
from sourceSets.api.output
|
||||
from sourceSets.main.output
|
||||
|
||||
classifier = 'dev'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives apiJar
|
||||
archives javadocJar
|
||||
archives sourceJar
|
||||
archives devJar
|
||||
}
|
||||
@@ -19,6 +19,15 @@
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
||||
maven {
|
||||
url "https://cursemaven.com"
|
||||
}
|
||||
|
||||
maven {
|
||||
name = "CurseForge"
|
||||
url = "https://minecraft.curseforge.com/api/maven/"
|
||||
}
|
||||
|
||||
maven {
|
||||
name "Mobius"
|
||||
url "http://mobiusstrip.eu/maven"
|
||||
@@ -29,11 +38,6 @@ repositories {
|
||||
url "http://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
|
||||
maven {
|
||||
name = "Tesla repo"
|
||||
url "https://maven.mcmoddev.com"
|
||||
}
|
||||
|
||||
maven {
|
||||
name "Ellpeck"
|
||||
url "https://maven.ellpeck.de"
|
||||
@@ -68,11 +72,6 @@ repositories {
|
||||
// name 'modmaven'
|
||||
// url "https://modmaven.k-4u.nl/"
|
||||
//}
|
||||
|
||||
maven {
|
||||
name = "CurseForge"
|
||||
url = "https://minecraft.curseforge.com/api/maven/"
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
@@ -80,15 +79,22 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile "gregtechce:gregtech:1.12.2:1.15.1.735"
|
||||
// deobfCompile "gregtechce:gregtech:1.12.2:1.15.1.735"
|
||||
// installable runtime dependencies
|
||||
mods "mcp.mobius.waila:Hwyla:${hwyla_version}"
|
||||
deobfCompile "curse.maven:gregtechceu-557242:3949406"
|
||||
|
||||
//mods "mcp.mobius.waila:Hwyla:${hwyla_version}"
|
||||
mods "curse.maven:hwyla-253449:2568751"
|
||||
mods "net.industrial-craft:industrialcraft-2:${ic2_version}:dev"
|
||||
mods "mcjty.theoneprobe:TheOneProbe-${minecraft_version}:${top_version}"
|
||||
|
||||
|
||||
// compile against provided APIs
|
||||
compileOnly "mezz.jei:jei_${minecraft_version}:${jei_version}:api"
|
||||
compileOnly "mcp.mobius.waila:Hwyla:${hwyla_version}"
|
||||
//compileOnly "mcp.mobius.waila:Hwyla:${hwyla_version}"
|
||||
compileOnly "curse.maven:hwyla-253449:2568751"
|
||||
//Code chicken lib, GTCE dependency
|
||||
deobfCompile "curse.maven:CCL-242818:2779848"
|
||||
|
||||
compileOnly "net.darkhax.tesla:Tesla-1.12.2:${tesla_version}"
|
||||
compileOnly "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
|
||||
compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${top_version}:api"
|
||||
|
||||
@@ -301,7 +301,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntity
|
||||
final NBTTagCompound data = memoryCard.getData(heldItem);
|
||||
|
||||
if (this.getUnlocalizedName().equals(savedName)) {
|
||||
tileEntity.uploadSettings(SettingsFrom.MEMORY_CARD, data);
|
||||
tileEntity.uploadSettings(SettingsFrom.MEMORY_CARD, data, player);
|
||||
memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_LOADED);
|
||||
} else {
|
||||
memoryCard.notifyUser(player, MemoryCardMessages.INVALID_MACHINE);
|
||||
|
||||
@@ -40,6 +40,7 @@ import appeng.fluids.client.render.FluidStackSizeRenderer;
|
||||
import appeng.fluids.container.slots.IMEFluidSlot;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -66,11 +67,13 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import yalter.mousetweaks.api.IMTModGuiContainer2;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
@@ -720,8 +723,14 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
|
||||
if (slot instanceof SlotFake) {
|
||||
final ItemStack stack = slot.getStack();
|
||||
if (stack != ItemStack.EMPTY) {
|
||||
InventoryAction direction = wheel > 0 ? InventoryAction.PLACE_SINGLE : InventoryAction.PICKUP_SINGLE;
|
||||
final PacketInventoryAction p = new PacketInventoryAction(direction, slot.slotNumber, 0);
|
||||
final PacketInventoryAction p;
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) {
|
||||
InventoryAction direction = wheel > 0 ? InventoryAction.DOUBLE : InventoryAction.HALVE;
|
||||
p = new PacketInventoryAction(direction, slot.slotNumber, 0);
|
||||
} else {
|
||||
InventoryAction direction = wheel > 0 ? InventoryAction.PLACE_SINGLE : InventoryAction.PICKUP_SINGLE;
|
||||
p = new PacketInventoryAction(direction, slot.slotNumber, 0);
|
||||
}
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
}
|
||||
}
|
||||
@@ -887,10 +896,28 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
|
||||
this.itemRender.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
if (s instanceof AppEngSlot) {
|
||||
((AppEngSlot) s).setDisplay(true);
|
||||
if (s instanceof SlotPlayerInv || s instanceof SlotPlayerHotBar) {
|
||||
super.drawSlot(s);
|
||||
} else if (s instanceof AppEngSlot) {
|
||||
AppEngSlot appEngSlot = ((AppEngSlot) s);
|
||||
appEngSlot.setDisplay(true);
|
||||
appEngSlot.setReturnAsSingleStack(true);
|
||||
|
||||
this.zLevel = 100.0F;
|
||||
this.itemRender.zLevel = 100.0F;
|
||||
|
||||
if (!this.isPowered()) {
|
||||
drawRect(s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111);
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
this.itemRender.zLevel = 0.0F;
|
||||
|
||||
// Annoying but easier than trying to splice into render item
|
||||
super.drawSlot(s);
|
||||
|
||||
this.stackSizeRenderer.renderStackSize(this.fontRenderer, AEItemStack.fromItemStack(appEngSlot.getDisplayStack()), s.xPos, s.yPos);
|
||||
return;
|
||||
} else {
|
||||
super.drawSlot(s);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ package appeng.client.gui;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotPlayerHotBar;
|
||||
import appeng.container.slot.SlotPlayerInv;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -43,11 +46,12 @@ public abstract class AEBaseMEGui extends AEBaseGui {
|
||||
protected void renderToolTip(final ItemStack stack, final int x, final int y) {
|
||||
final Slot s = this.getSlot(x, y);
|
||||
|
||||
final int bigNumber = AEConfig.instance().useTerminalUseLargeFont() ? 999 : 9999;
|
||||
final List<String> currentToolTip = this.getItemToolTip(stack);
|
||||
|
||||
if (s instanceof SlotME && !stack.isEmpty()) {
|
||||
final int bigNumber = AEConfig.instance().useTerminalUseLargeFont() ? 999 : 9999;
|
||||
|
||||
IAEItemStack myStack = null;
|
||||
final List<String> currentToolTip = this.getItemToolTip(stack);
|
||||
|
||||
try {
|
||||
final SlotME theSlotField = (SlotME) s;
|
||||
@@ -56,7 +60,7 @@ public abstract class AEBaseMEGui extends AEBaseGui {
|
||||
}
|
||||
|
||||
if (myStack != null) {
|
||||
if (myStack.getStackSize() > bigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged())) {
|
||||
if (myStack.getStackSize() > 1) {
|
||||
final String local = ButtonToolTips.ItemsStored.getLocal();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(myStack.getStackSize());
|
||||
final String format = String.format(local, formattedAmount);
|
||||
@@ -86,6 +90,15 @@ public abstract class AEBaseMEGui extends AEBaseGui {
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (s instanceof AppEngSlot) {
|
||||
if (!(s instanceof SlotPlayerInv) && !(s instanceof SlotPlayerHotBar)) {
|
||||
if (!s.getStack().isEmpty()) {
|
||||
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(s.getStack().getCount());
|
||||
currentToolTip.add(TextFormatting.GRAY + formattedAmount);
|
||||
this.drawHoveringText(currentToolTip, x, y, this.fontRenderer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.renderToolTip(stack, x, y);
|
||||
|
||||
@@ -81,6 +81,7 @@ public class GuiCraftConfirm extends AEBaseGui {
|
||||
this.setScrollBar(scrollbar);
|
||||
|
||||
this.ccc = (ContainerCraftConfirm) this.inventorySlots;
|
||||
this.ccc.setGui(this);
|
||||
|
||||
if (te instanceof WirelessTerminalGuiObject) {
|
||||
this.OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
|
||||
@@ -95,6 +95,7 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource {
|
||||
protected GuiCraftingCPU(final ContainerCraftingCPU container) {
|
||||
super(container);
|
||||
this.craftingCpu = container;
|
||||
this.craftingCpu.setGui(this);
|
||||
this.ySize = GUI_HEIGHT;
|
||||
this.xSize = GUI_WIDTH;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.core.localization.GuiText;
|
||||
@@ -81,4 +82,8 @@ public class GuiCraftingTerm extends GuiMEMonitorable {
|
||||
protected String getBackground() {
|
||||
return "guis/crafting.png";
|
||||
}
|
||||
|
||||
public ItemRepo getRepo() {
|
||||
return this.repo;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-8
@@ -19,10 +19,8 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiCustomSlot;
|
||||
@@ -89,6 +87,7 @@ public class GuiFluidInterfaceConfigurationTerminal extends AEBaseGui implements
|
||||
private final ArrayList<String> names = new ArrayList<>();
|
||||
private final ArrayList<Object> lines = new ArrayList<>();
|
||||
private final Set<Object> matchedStacks = new HashSet<>();
|
||||
private final Set<ClientDCInternalFluidInv> matchedInterfaces = new HashSet<ClientDCInternalFluidInv>();
|
||||
|
||||
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
|
||||
|
||||
@@ -157,12 +156,14 @@ public class GuiFluidInterfaceConfigurationTerminal extends AEBaseGui implements
|
||||
|
||||
for (int row = 0; row < 1 + extraLines && linesDraw < LINES_ON_PAGE; ++row) {
|
||||
for (int z = 0; z < 5; z++) {
|
||||
GuiFluidTank tankSlot = new GuiFluidTank(inv.getInventory(), z + (row * 5), z + (row * 5), (z * 18 + 22), offset, 16, 16);
|
||||
GuiFluidTank tankSlot;
|
||||
if (!matchedInterfaces.contains(inv) && !this.matchedStacks.contains(inv.getInventory().getFluidInSlot(z + (row * 5)))) {
|
||||
tankSlot = new GuiFluidTank(inv.getInventory(), z + (row * 5), z + (row * 5), (z * 18 + 22), offset, 16, 16, true);
|
||||
} else {
|
||||
tankSlot = new GuiFluidTank(inv.getInventory(), z + (row * 5), z + (row * 5), (z * 18 + 22), offset, 16, 16);
|
||||
}
|
||||
this.guiSlots.add(tankSlot);
|
||||
guiFluidTankClientDCInternalFluidInvMap.put(tankSlot, inv);
|
||||
if (this.matchedStacks.contains(inv.getInventory().getFluidInSlot(z + (row * 5)))) {
|
||||
drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x2A00FF00);
|
||||
}
|
||||
}
|
||||
linesDraw++;
|
||||
offset += 18;
|
||||
@@ -321,6 +322,7 @@ public class GuiFluidInterfaceConfigurationTerminal extends AEBaseGui implements
|
||||
this.byName.clear();
|
||||
this.buttonList.clear();
|
||||
this.matchedStacks.clear();
|
||||
this.matchedInterfaces.clear();
|
||||
|
||||
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
|
||||
|
||||
@@ -352,8 +354,12 @@ public class GuiFluidInterfaceConfigurationTerminal extends AEBaseGui implements
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
if (searchFieldInputs.isEmpty() || entry.getName().toLowerCase().contains(searchFieldInputs)) {
|
||||
this.matchedInterfaces.add(entry);
|
||||
found = true;
|
||||
}
|
||||
// if found, filter skipped or machine name matching the search term, add it
|
||||
if (found || entry.getName().toLowerCase().contains(searchFieldInputs)) {
|
||||
if (found) {
|
||||
this.byName.put(entry.getName(), entry);
|
||||
cachedSearch.add(entry);
|
||||
} else {
|
||||
@@ -441,7 +447,7 @@ public class GuiFluidInterfaceConfigurationTerminal extends AEBaseGui implements
|
||||
ClientDCInternalFluidInv o = this.byId.get(id);
|
||||
|
||||
if (o == null) {
|
||||
this.byId.put(id, o = new ClientDCInternalFluidInv(5, id, sortBy, string, 64));
|
||||
this.byId.put(id, o = new ClientDCInternalFluidInv(5, id, sortBy, string, 1000));
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
|
||||
+25
-6
@@ -52,6 +52,7 @@ import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -77,6 +78,7 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI
|
||||
private final ArrayList<String> names = new ArrayList<>();
|
||||
private final ArrayList<Object> lines = new ArrayList<>();
|
||||
private final Set<Object> matchedStacks = new HashSet<>();
|
||||
private final Set<ClientDCInternalInv> matchedInterfaces = new HashSet<>();
|
||||
|
||||
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
|
||||
|
||||
@@ -147,7 +149,9 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI
|
||||
for (int z = 0; z < 9; z++) {
|
||||
this.inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z + (row * 9), (z * 18 + 22), offset));
|
||||
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z + (row * 9)))) {
|
||||
drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x2A00FF00);
|
||||
drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x8A00FF00);
|
||||
} else if (!matchedInterfaces.contains(inv)) {
|
||||
drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x6A000000);
|
||||
}
|
||||
}
|
||||
linesDraw++;
|
||||
@@ -213,8 +217,14 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI
|
||||
if (slot instanceof SlotDisconnected) {
|
||||
final ItemStack stack = slot.getStack();
|
||||
if (stack != ItemStack.EMPTY) {
|
||||
InventoryAction direction = wheel > 0 ? InventoryAction.PLACE_SINGLE : InventoryAction.PICKUP_SINGLE;
|
||||
final PacketInventoryAction p = new PacketInventoryAction(direction, slot.getSlotIndex(), ((SlotDisconnected) slot).getSlot().getId());
|
||||
final PacketInventoryAction p;
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) {
|
||||
InventoryAction direction = wheel > 0 ? InventoryAction.DOUBLE : InventoryAction.HALVE;
|
||||
p = new PacketInventoryAction(direction, slot.getSlotIndex(), ((SlotDisconnected) slot).getSlot().getId());
|
||||
} else {
|
||||
InventoryAction direction = wheel > 0 ? InventoryAction.PLACE_SINGLE : InventoryAction.PICKUP_SINGLE;
|
||||
p = new PacketInventoryAction(direction, slot.getSlotIndex(), ((SlotDisconnected) slot).getSlot().getId());
|
||||
}
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
}
|
||||
} else {
|
||||
@@ -289,7 +299,11 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI
|
||||
for (int x = 0; x < current.getInventory().getSlots(); x++) {
|
||||
final String which = Integer.toString(x);
|
||||
if (invData.hasKey(which)) {
|
||||
current.getInventory().setStackInSlot(x, new ItemStack(invData.getCompoundTag(which)));
|
||||
NBTTagCompound tag = invData.getCompoundTag(which);
|
||||
current.getInventory().setStackInSlot(x, new ItemStack(tag));
|
||||
if (tag.hasKey("stackSize")) {
|
||||
current.getInventory().getStackInSlot(x).setCount(tag.getInteger("stackSize"));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final NumberFormatException ignored) {
|
||||
@@ -314,6 +328,7 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI
|
||||
this.byName.clear();
|
||||
this.buttonList.clear();
|
||||
this.matchedStacks.clear();
|
||||
this.matchedInterfaces.clear();
|
||||
|
||||
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
|
||||
|
||||
@@ -345,7 +360,11 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI
|
||||
}
|
||||
}
|
||||
// if found, filter skipped or machine name matching the search term, add it
|
||||
if (found || entry.getName().toLowerCase().contains(searchFieldInputs)) {
|
||||
if (searchFieldInputs.isEmpty() || entry.getName().toLowerCase().contains(searchFieldInputs)) {
|
||||
this.matchedInterfaces.add(entry);
|
||||
found = true;
|
||||
}
|
||||
if (found) {
|
||||
this.byName.put(entry.getName(), entry);
|
||||
cachedSearch.add(entry);
|
||||
} else {
|
||||
@@ -435,7 +454,7 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI
|
||||
ClientDCInternalInv o = this.byId.get(id);
|
||||
|
||||
if (o == null) {
|
||||
this.byId.put(id, o = new ClientDCInternalInv(DualityInterface.NUMBER_OF_CONFIG_SLOTS, id, sortBy, string, 64));
|
||||
this.byId.put(id, o = new ClientDCInternalInv(DualityInterface.NUMBER_OF_CONFIG_SLOTS, id, sortBy, string, 512));
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
private final ArrayList<String> names = new ArrayList<>();
|
||||
private final ArrayList<Object> lines = new ArrayList<>();
|
||||
private final Set<Object> matchedStacks = new HashSet<>();
|
||||
|
||||
private final Set<ClientDCInternalInv> matchedInterfaces = new HashSet<>();
|
||||
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
|
||||
|
||||
private boolean refreshList = false;
|
||||
@@ -155,7 +155,9 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
for (int z = 0; z < 9; z++) {
|
||||
this.inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z + (row * 9), (z * 18 + 22), offset));
|
||||
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z + (row * 9)))) {
|
||||
drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x2A00FF00);
|
||||
drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x8A00FF00);
|
||||
} else if (!matchedInterfaces.contains(inv)) {
|
||||
drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x6A000000);
|
||||
}
|
||||
}
|
||||
linesDraw++;
|
||||
@@ -344,6 +346,7 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
this.byName.clear();
|
||||
this.buttonList.clear();
|
||||
this.matchedStacks.clear();
|
||||
this.matchedInterfaces.clear();
|
||||
|
||||
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
|
||||
final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase();
|
||||
@@ -393,7 +396,13 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
}
|
||||
}
|
||||
// if found, filter skipped or machine name matching the search term, add it
|
||||
if (found || (entry.getName().toLowerCase().contains(searchFieldInputs) && entry.getName().toLowerCase().contains(searchFieldOutputs))) {
|
||||
if ((searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty()) ||
|
||||
!searchFieldInputs.isEmpty() && entry.getName().toLowerCase().contains(searchFieldInputs) ||
|
||||
(!searchFieldOutputs.isEmpty() && entry.getName().toLowerCase().contains(searchFieldOutputs))) {
|
||||
this.matchedInterfaces.add(entry);
|
||||
found = true;
|
||||
}
|
||||
if (found) {
|
||||
if (!partInterfaceTerminal.onlyInterfacesWithFreeSlots) {
|
||||
this.byName.put(entry.getName(), entry);
|
||||
cachedSearch.add(entry);
|
||||
|
||||
@@ -31,7 +31,11 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.widgets.*;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.client.me.SlotME;
|
||||
@@ -73,7 +77,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
private static int craftingGridOffsetY;
|
||||
|
||||
private static String memoryText = "";
|
||||
private final ItemRepo repo;
|
||||
protected final ItemRepo repo;
|
||||
private final int offsetX = 9;
|
||||
private final int lowerTextureOffset = 0;
|
||||
private final IConfigManager configSrc;
|
||||
|
||||
@@ -51,6 +51,7 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
|
||||
|
||||
private final ItemRepo repo;
|
||||
private final int rows = 4;
|
||||
private final ContainerNetworkStatus cns;
|
||||
private GuiImgButton units;
|
||||
private int tooltip = -1;
|
||||
|
||||
@@ -65,6 +66,9 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
|
||||
this.ySize = 153;
|
||||
this.xSize = 195;
|
||||
this.repo.setRowSize(5);
|
||||
|
||||
this.cns = (ContainerNetworkStatus) this.inventorySlots;
|
||||
this.cns.setGui(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -227,8 +227,10 @@ public class ItemRepo {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
searchTask.cancel(true);
|
||||
searchTask = null;
|
||||
if (searchTask != null) {
|
||||
searchTask.cancel(true);
|
||||
searchTask = null;
|
||||
}
|
||||
this.list.resetStatus();
|
||||
}
|
||||
|
||||
@@ -266,4 +268,8 @@ public class ItemRepo {
|
||||
this.updateJEI(this.searchString);
|
||||
}
|
||||
}
|
||||
|
||||
public IItemList<IAEItemStack> getList() {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ import appeng.helpers.InventoryAction;
|
||||
import appeng.me.helpers.PlayerSource;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
import appeng.util.inv.WrapperCursorItemHandler;
|
||||
import appeng.util.item.AEItemStack;
|
||||
@@ -387,10 +388,7 @@ public abstract class AEBaseContainer extends Container {
|
||||
|
||||
if (Platform.itemComparisons().isSameItem(tis, t)) // t.isItemEqual(tis))
|
||||
{
|
||||
int maxSize = t.getMaxStackSize();
|
||||
if (maxSize > d.getSlotStackLimit()) {
|
||||
maxSize = d.getSlotStackLimit();
|
||||
}
|
||||
int maxSize = d.getSlotStackLimit();
|
||||
|
||||
int placeAble = maxSize - t.getCount();
|
||||
|
||||
@@ -406,9 +404,7 @@ public abstract class AEBaseContainer extends Container {
|
||||
if (tis.getCount() <= 0) {
|
||||
clickSlot.putStack(ItemStack.EMPTY);
|
||||
d.onSlotChanged();
|
||||
|
||||
// if ( hasMETiles ) updateClient();
|
||||
|
||||
|
||||
this.updateSlot(clickSlot);
|
||||
this.updateSlot(d);
|
||||
return ItemStack.EMPTY;
|
||||
@@ -545,23 +541,20 @@ public abstract class AEBaseContainer extends Container {
|
||||
|
||||
switch (action) {
|
||||
case PICKUP_OR_SET_DOWN:
|
||||
|
||||
if (hand.isEmpty()) {
|
||||
s.putStack(ItemStack.EMPTY);
|
||||
} else {
|
||||
s.putStack(hand.copy());
|
||||
}
|
||||
|
||||
break;
|
||||
case PLACE_SINGLE:
|
||||
|
||||
if (!hand.isEmpty()) {
|
||||
final ItemStack is = hand.copy();
|
||||
is.setCount(1);
|
||||
s.putStack(is);
|
||||
} else {
|
||||
final ItemStack is = s.getStack().copy();
|
||||
if (is.getCount() < is.getMaxStackSize())
|
||||
if (is.getCount() < is.getMaxStackSize() * 8)
|
||||
is.grow(1);
|
||||
s.putStack(is);
|
||||
}
|
||||
@@ -575,7 +568,6 @@ public abstract class AEBaseContainer extends Container {
|
||||
}
|
||||
break;
|
||||
case SPLIT_OR_PLACE_SINGLE:
|
||||
|
||||
ItemStack is = s.getStack();
|
||||
if (!is.isEmpty()) {
|
||||
if (hand.isEmpty()) {
|
||||
@@ -586,14 +578,26 @@ public abstract class AEBaseContainer extends Container {
|
||||
is = hand.copy();
|
||||
is.setCount(1);
|
||||
}
|
||||
|
||||
s.putStack(is);
|
||||
} else if (!hand.isEmpty()) {
|
||||
is = hand.copy();
|
||||
is.setCount(1);
|
||||
s.putStack(is);
|
||||
}
|
||||
|
||||
break;
|
||||
case HALVE:
|
||||
if (s.getStack().getCount() > 1) {
|
||||
ItemStack halved = s.getStack().copy();
|
||||
halved.setCount(s.getStack().getCount() / 2);
|
||||
s.putStack(halved);
|
||||
}
|
||||
break;
|
||||
case DOUBLE:
|
||||
ItemStack doubled = s.getStack().copy();
|
||||
if (s.getStack().getCount() * 2 > 0) {
|
||||
doubled.setCount(Math.min(s.getSlotStackLimit(), s.getStack().getCount() * 2));
|
||||
s.putStack(doubled);
|
||||
}
|
||||
break;
|
||||
case CREATIVE_DUPLICATE:
|
||||
case MOVE_REGION:
|
||||
@@ -606,9 +610,9 @@ public abstract class AEBaseContainer extends Container {
|
||||
if (action == InventoryAction.MOVE_REGION) {
|
||||
final List<Slot> from = new ArrayList<>();
|
||||
|
||||
for (final Object j : this.inventorySlots) {
|
||||
if (j instanceof Slot && j.getClass() == s.getClass() && !(j instanceof SlotCraftingTerm)) {
|
||||
from.add((Slot) j);
|
||||
for (final Slot j : this.inventorySlots) {
|
||||
if (j != null && j.getClass() == s.getClass() && !(j instanceof SlotCraftingTerm)) {
|
||||
from.add(j);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.core.AELog;
|
||||
@@ -61,6 +62,7 @@ import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
|
||||
@@ -85,6 +87,7 @@ public class ContainerCraftConfirm extends AEBaseContainer {
|
||||
public boolean noCPU = true;
|
||||
@GuiSync(7)
|
||||
public String myName = "";
|
||||
private GuiCraftConfirm guiCraftConfirm;
|
||||
|
||||
public ContainerCraftConfirm(final InventoryPlayer ip, final ITerminalHost te) {
|
||||
super(ip, te);
|
||||
@@ -403,4 +406,12 @@ public class ContainerCraftConfirm extends AEBaseContainer {
|
||||
public void setJob(final Future<ICraftingJob> job) {
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
|
||||
this.guiCraftConfirm.postUpdate(list, ref);
|
||||
}
|
||||
|
||||
public void setGui(GuiCraftConfirm guiCraftConfirm) {
|
||||
this.guiCraftConfirm = guiCraftConfirm;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
import appeng.client.gui.implementations.GuiCraftingCPU;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.core.AELog;
|
||||
@@ -47,6 +49,7 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorHandlerReceiver<IAEItemStack>, ICustomNameObject {
|
||||
@@ -58,6 +61,7 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
||||
|
||||
@GuiSync(0)
|
||||
public long eta = -1;
|
||||
private GuiCraftingCPU guiCraftingCPU;
|
||||
|
||||
public ContainerCraftingCPU(final InventoryPlayer ip, final Object te) {
|
||||
super(ip, te);
|
||||
@@ -232,4 +236,12 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
||||
private void setNetwork(final IGrid network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
|
||||
this.guiCraftingCPU.postUpdate(list, ref);
|
||||
}
|
||||
|
||||
public void setGui(GuiCraftingCPU guiCraftingCPU) {
|
||||
this.guiCraftingCPU = guiCraftingCPU;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,10 @@ import appeng.container.ContainerNull;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotCraftingTerm;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.parts.reporting.AbstractPartTerminal;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
|
||||
+12
-404
@@ -1,55 +1,33 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.slot.*;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.parts.reporting.PartExpandedProcessingPatternTerminal;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import appeng.container.slot.OptionalSlotFake;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.container.slot.SlotPatternOutputs;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static appeng.helpers.PatternHelper.PROCESSING_INPUT_LIMIT;
|
||||
import static appeng.helpers.PatternHelper.PROCESSING_OUTPUT_LIMIT;
|
||||
|
||||
|
||||
public class ContainerExpandedProcessingPatternTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
|
||||
private final IItemHandler crafting;
|
||||
private final SlotFakeCraftingMatrix[] gridSlots = new SlotFakeCraftingMatrix[PROCESSING_INPUT_LIMIT];
|
||||
private final OptionalSlotFake[] outputSlots = new OptionalSlotFake[PROCESSING_OUTPUT_LIMIT];
|
||||
private final SlotRestrictedInput patternSlotIN;
|
||||
private final SlotRestrictedInput patternSlotOUT;
|
||||
private final PartExpandedProcessingPatternTerminal expandedProcessingPatternTerminal;
|
||||
public class ContainerExpandedProcessingPatternTerm extends ContainerPatternEncoder {
|
||||
|
||||
public ContainerExpandedProcessingPatternTerm(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
super(ip, monitorable, false);
|
||||
|
||||
this.expandedProcessingPatternTerminal = (PartExpandedProcessingPatternTerminal) monitorable;
|
||||
this.craftingSlots = new SlotFakeCraftingMatrix[PROCESSING_INPUT_LIMIT];
|
||||
this.outputSlots = new OptionalSlotFake[PROCESSING_OUTPUT_LIMIT];
|
||||
|
||||
final IItemHandler patternInv = this.getExpandedPatternTerminal().getInventoryByName("pattern");
|
||||
final IItemHandler output = this.getExpandedPatternTerminal().getInventoryByName("output");
|
||||
final IItemHandler patternInv = this.getPart().getInventoryByName("pattern");
|
||||
final IItemHandler output = this.getPart().getInventoryByName("output");
|
||||
|
||||
this.crafting = this.getExpandedPatternTerminal().getInventoryByName("crafting");
|
||||
this.crafting = this.getPart().getInventoryByName("crafting");
|
||||
|
||||
for (int y = 0; y < 4; y++) {
|
||||
for (int x = 0; x < 4; x++) {
|
||||
this.addSlotToContainer(this.gridSlots[x + y * 4] = new SlotFakeCraftingMatrix(this.crafting, x + y * 4, 4 + x * 18, -85 + y * 18));
|
||||
this.addSlotToContainer(this.craftingSlots[x + y * 4] = new SlotFakeCraftingMatrix(this.crafting, x + y * 4, 4 + x * 18, -85 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,124 +45,7 @@ public class ContainerExpandedProcessingPatternTerm extends ContainerMEMonitorab
|
||||
this.patternSlotOUT.setStackLimit(1);
|
||||
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
|
||||
if (Platform.isClient()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (this.inventorySlots.get(idx) instanceof SlotPlayerInv || this.inventorySlots.get(idx) instanceof SlotPlayerHotBar) {
|
||||
final AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx); // require AE SLots!
|
||||
ItemStack itemStack = clickSlot.getStack();
|
||||
if (AEApi.instance().definitions().materials().blankPattern().isSameAs(itemStack)) {
|
||||
IItemHandler patternInv = this.getExpandedPatternTerminal().getInventoryByName("pattern");
|
||||
ItemStack remainder = patternInv.insertItem(0, itemStack, false);
|
||||
clickSlot.putStack(remainder);
|
||||
}
|
||||
}
|
||||
return super.transferStackInSlot(p, idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack) {
|
||||
|
||||
}
|
||||
|
||||
public void encodeAndMoveToInventory() {
|
||||
encode();
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
if (!output.isEmpty()) {
|
||||
if (!getPlayerInv().addItemStackToInventory(output)) {
|
||||
getPlayerInv().player.dropItem(output, false);
|
||||
}
|
||||
this.patternSlotOUT.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
public void encode() {
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
|
||||
final ItemStack[] in = this.getInputs();
|
||||
final ItemStack[] out = this.getOutputs();
|
||||
|
||||
// if there is no input, this would be silly.
|
||||
if (in == null || out == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// first check the output slots, should either be null, or a pattern
|
||||
if (!output.isEmpty() && !this.isPattern(output)) {
|
||||
return;
|
||||
} // if nothing is there we should snag a new pattern.
|
||||
else if (output.isEmpty()) {
|
||||
output = this.patternSlotIN.getStack();
|
||||
if (output.isEmpty() || !this.isPattern(output)) {
|
||||
return; // no blanks.
|
||||
}
|
||||
|
||||
// remove one, and clear the input slot.
|
||||
output.setCount(output.getCount() - 1);
|
||||
if (output.getCount() == 0) {
|
||||
this.patternSlotIN.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
// add a new encoded pattern.
|
||||
Optional<ItemStack> maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack(1);
|
||||
if (maybePattern.isPresent()) {
|
||||
output = maybePattern.get();
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
}
|
||||
|
||||
// encode the slot.
|
||||
final NBTTagCompound encodedValue = new NBTTagCompound();
|
||||
|
||||
final NBTTagList tagIn = new NBTTagList();
|
||||
final NBTTagList tagOut = new NBTTagList();
|
||||
|
||||
for (final ItemStack i : in) {
|
||||
tagIn.appendTag(this.createItemTag(i));
|
||||
}
|
||||
|
||||
for (final ItemStack i : out) {
|
||||
tagOut.appendTag(this.createItemTag(i));
|
||||
}
|
||||
|
||||
encodedValue.setTag("in", tagIn);
|
||||
encodedValue.setTag("out", tagOut);
|
||||
encodedValue.setBoolean("crafting", false);
|
||||
encodedValue.setBoolean("substitute", false);
|
||||
|
||||
output.setTagCompound(encodedValue);
|
||||
}
|
||||
|
||||
boolean isPattern(final ItemStack output) {
|
||||
if (output.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
boolean isPattern = definitions.items().encodedPattern().isSameAs(output);
|
||||
isPattern |= definitions.materials().blankPattern().isSameAs(output);
|
||||
|
||||
return isPattern;
|
||||
}
|
||||
|
||||
NBTBase createItemTag(final ItemStack i) {
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if (!i.isEmpty()) {
|
||||
i.writeToNBT(c);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,261 +53,8 @@ public class ContainerExpandedProcessingPatternTerm extends ContainerMEMonitorab
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ItemStack[] getInputs() {
|
||||
final ItemStack[] input = new ItemStack[16];
|
||||
boolean hasValue = false;
|
||||
|
||||
for (int x = 0; x < this.gridSlots.length; x++) {
|
||||
input[x] = this.gridSlots[x].getStack();
|
||||
if (!input[x].isEmpty()) {
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasValue) {
|
||||
return input;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ItemStack[] getOutputs() {
|
||||
final List<ItemStack> list = new ArrayList<>(3);
|
||||
boolean hasValue = false;
|
||||
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
|
||||
if (!out.isEmpty() && out.getCount() > 0) {
|
||||
list.add(out);
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasValue) {
|
||||
return list.toArray(new ItemStack[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (final Slot s : this.gridSlots) {
|
||||
s.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
for (final Slot s : this.outputSlots) {
|
||||
s.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName(final String name) {
|
||||
if (name.equals("player")) {
|
||||
return new PlayerInvWrapper(this.getInventoryPlayer());
|
||||
}
|
||||
return this.getExpandedPatternTerminal().getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useRealItems() {
|
||||
public boolean isCraftingMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public PartExpandedProcessingPatternTerminal getExpandedPatternTerminal() {
|
||||
return this.expandedProcessingPatternTerminal;
|
||||
}
|
||||
|
||||
public void multiply(int multiple) {
|
||||
ItemStack[] input = new ItemStack[gridSlots.length];
|
||||
boolean canMultiplyInputs = true;
|
||||
boolean canMultiplyOutputs = true;
|
||||
|
||||
for (int x = 0; x < this.gridSlots.length; x++) {
|
||||
input[x] = this.gridSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getCount() * multiple > input[x].getMaxStackSize()) {
|
||||
canMultiplyInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (!out.isEmpty() && out.getCount() * multiple > out.getMaxStackSize()) {
|
||||
canMultiplyOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canMultiplyInputs && canMultiplyOutputs) {
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.gridSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
craftingSlot.getStack().setCount(stack.getCount() * multiple);
|
||||
}
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
outputSlot.getStack().setCount(stack.getCount() * multiple);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void divide(int divide) {
|
||||
ItemStack[] input = new ItemStack[gridSlots.length];
|
||||
boolean canDivideInputs = true;
|
||||
boolean canDivideOutputs = true;
|
||||
|
||||
for (int x = 0; x < this.gridSlots.length; x++) {
|
||||
input[x] = this.gridSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getCount() % divide != 0) {
|
||||
canDivideInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (!out.isEmpty() && out.getCount() % divide != 0) {
|
||||
canDivideOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canDivideInputs && canDivideOutputs) {
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.gridSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
craftingSlot.getStack().setCount(stack.getCount() / divide);
|
||||
}
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
outputSlot.getStack().setCount(stack.getCount() / divide);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void increase(int increase) {
|
||||
ItemStack[] input = new ItemStack[gridSlots.length];
|
||||
boolean canIncreaseInputs = true;
|
||||
boolean canIncreaseOutputs = true;
|
||||
|
||||
for (int x = 0; x < this.gridSlots.length; x++) {
|
||||
input[x] = this.gridSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getCount() + increase > input[x].getMaxStackSize()) {
|
||||
canIncreaseInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (!out.isEmpty() && out.getCount() + increase > out.getMaxStackSize()) {
|
||||
canIncreaseOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canIncreaseInputs && canIncreaseOutputs) {
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.gridSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
craftingSlot.getStack().setCount(stack.getCount() + increase);
|
||||
}
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
outputSlot.getStack().setCount(stack.getCount() + increase);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void decrease(int decrease) {
|
||||
ItemStack[] input = new ItemStack[gridSlots.length];
|
||||
boolean canDecreaseInputs = true;
|
||||
boolean canDecreaseOutputs = true;
|
||||
|
||||
for (int x = 0; x < this.gridSlots.length; x++) {
|
||||
input[x] = this.gridSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getCount() - decrease < 1) {
|
||||
canDecreaseInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (!out.isEmpty() && out.getCount() - decrease < 1) {
|
||||
canDecreaseOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canDecreaseInputs && canDecreaseOutputs) {
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.gridSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
craftingSlot.getStack().setCount(stack.getCount() - decrease);
|
||||
}
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
outputSlot.getStack().setCount(stack.getCount() - decrease);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void maximizeCount() {
|
||||
ItemStack[] input = new ItemStack[gridSlots.length];
|
||||
boolean canGrowInputs = true;
|
||||
boolean canGrowOutputs = true;
|
||||
int maxInputStackGrowth = 0;
|
||||
int maxOutputStackGrowth = 0;
|
||||
|
||||
for (int x = 0; x < this.gridSlots.length; x++) {
|
||||
input[x] = this.gridSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getMaxStackSize() - input[x].getCount() > maxInputStackGrowth) {
|
||||
maxInputStackGrowth = input[x].getMaxStackSize() - input[x].getCount();
|
||||
}
|
||||
if (!input[x].isEmpty() && input[x].getCount() + maxInputStackGrowth > input[x].getMaxStackSize()) {
|
||||
canGrowInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
{
|
||||
maxOutputStackGrowth = out.getMaxStackSize() - out.getCount();
|
||||
}
|
||||
if (!out.isEmpty() && out.getCount() + maxOutputStackGrowth > out.getMaxStackSize()) {
|
||||
canGrowOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canGrowInputs && canGrowOutputs) {
|
||||
int maxStackGrowth = Math.min(maxInputStackGrowth, maxOutputStackGrowth);
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.gridSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
craftingSlot.getStack().setCount(stack.getCount() + maxStackGrowth);
|
||||
}
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
outputSlot.getStack().setCount(stack.getCount() + maxStackGrowth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(final Slot s) {
|
||||
if (s == this.patternSlotOUT && Platform.isServer()) {
|
||||
for (final IContainerListener listener : this.listeners) {
|
||||
for (final Slot slot : this.inventorySlots) {
|
||||
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
|
||||
listener.sendSlotContents(this, slot.slotNumber, slot.getStack());
|
||||
}
|
||||
}
|
||||
if (listener instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) listener).isChangingQuantityOnly = false;
|
||||
}
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-1
@@ -184,7 +184,7 @@ public final class ContainerInterfaceConfigurationTerminal extends AEBaseContain
|
||||
}
|
||||
break;
|
||||
case PLACE_SINGLE:
|
||||
if (inSlot.getMaxStackSize() > inSlot.getCount()) {
|
||||
if (inSlot.getCount() < inSlot.getMaxStackSize() * 8) {
|
||||
inSlot.grow(1);
|
||||
ItemHandlerUtil.setStackInSlot(theSlot, 0, inSlot);
|
||||
}
|
||||
@@ -222,6 +222,18 @@ public final class ContainerInterfaceConfigurationTerminal extends AEBaseContain
|
||||
ItemHandlerUtil.setStackInSlot(theSlot, 0, player.inventory.getItemStack().copy());
|
||||
}
|
||||
|
||||
break;
|
||||
case HALVE:
|
||||
if (inSlot.getCount() > 1) {
|
||||
ItemStack halved = inSlot.copy();
|
||||
halved.setCount(inSlot.getCount() / 2);
|
||||
ItemHandlerUtil.setStackInSlot(theSlot, 0, halved);
|
||||
}
|
||||
break;
|
||||
case DOUBLE:
|
||||
ItemStack doubled = inSlot.copy();
|
||||
doubled.setCount(Math.min(512, inSlot.getCount() * 2));
|
||||
ItemHandlerUtil.setStackInSlot(theSlot, 0, doubled);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
@@ -299,6 +311,9 @@ public final class ContainerInterfaceConfigurationTerminal extends AEBaseContain
|
||||
|
||||
if (!is.isEmpty()) {
|
||||
is.writeToNBT(itemNBT);
|
||||
if (is.getCount() > is.getMaxStackSize()) {
|
||||
itemNBT.setInteger("stackSize", is.getCount());
|
||||
}
|
||||
}
|
||||
|
||||
tag.setTag(Integer.toString(x + offset), itemNBT);
|
||||
|
||||
@@ -42,6 +42,7 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.gui.implementations.GuiMEMonitorable;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
@@ -64,13 +65,14 @@ import net.minecraftforge.fml.common.Loader;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack> {
|
||||
|
||||
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
|
||||
private final IMEMonitor<IAEItemStack> monitor;
|
||||
private final IItemList<IAEItemStack> items = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
public final IItemList<IAEItemStack> items = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
private final IConfigManager clientCM;
|
||||
private final ITerminalHost host;
|
||||
@GuiSync(99)
|
||||
@@ -357,11 +359,19 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
this.hasPower = isPowered;
|
||||
}
|
||||
|
||||
private IConfigManagerHost getGui() {
|
||||
public IConfigManagerHost getGui() {
|
||||
return this.gui;
|
||||
}
|
||||
|
||||
public void setGui(@Nonnull final IConfigManagerHost gui) {
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
public IItemList<IAEItemStack> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list) {
|
||||
((GuiMEMonitorable) this.gui).postUpdate(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.client.gui.implementations.GuiNetworkStatus;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
@@ -42,6 +43,7 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ContainerNetworkStatus extends AEBaseContainer {
|
||||
@@ -56,6 +58,7 @@ public class ContainerNetworkStatus extends AEBaseContainer {
|
||||
public long maxPower;
|
||||
private IGrid network;
|
||||
private int delay = 40;
|
||||
private GuiNetworkStatus guiNetworkStatus;
|
||||
|
||||
public ContainerNetworkStatus(final InventoryPlayer ip, final INetworkTool te) {
|
||||
super(ip, null, null);
|
||||
@@ -160,4 +163,12 @@ public class ContainerNetworkStatus extends AEBaseContainer {
|
||||
private void setPowerUsage(final long powerUsage) {
|
||||
this.powerUsage = powerUsage;
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list) {
|
||||
this.guiNetworkStatus.postUpdate(list);
|
||||
}
|
||||
|
||||
public void setGui(GuiNetworkStatus guiNetworkStatus) {
|
||||
this.guiNetworkStatus = guiNetworkStatus;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,550 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
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.SlotPatternTerm;
|
||||
import appeng.container.slot.SlotPlayerHotBar;
|
||||
import appeng.container.slot.SlotPlayerInv;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.parts.reporting.AbstractPartEncoder;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
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.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class ContainerPatternEncoder extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
|
||||
|
||||
private final AbstractPartEncoder patternTerminal;
|
||||
|
||||
final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
|
||||
|
||||
protected IItemHandler crafting;
|
||||
protected SlotPatternTerm craftSlot;
|
||||
protected SlotRestrictedInput patternSlotIN;
|
||||
protected SlotRestrictedInput patternSlotOUT;
|
||||
private IRecipe currentRecipe;
|
||||
|
||||
protected SlotFakeCraftingMatrix[] craftingSlots;
|
||||
protected OptionalSlotFake[] outputSlots;
|
||||
|
||||
@GuiSync(97)
|
||||
public boolean craftingMode = true;
|
||||
@GuiSync(96)
|
||||
public boolean substitute = false;
|
||||
|
||||
public ContainerPatternEncoder(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
super(ip, monitorable);
|
||||
patternTerminal = (AbstractPartEncoder) monitorable;
|
||||
}
|
||||
|
||||
protected ContainerPatternEncoder(InventoryPlayer ip, ITerminalHost monitorable, boolean bindInventory) {
|
||||
super(ip, monitorable, bindInventory);
|
||||
patternTerminal = (AbstractPartEncoder) monitorable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
|
||||
if (Platform.isClient()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (this.inventorySlots.get(idx) instanceof SlotPlayerInv || this.inventorySlots.get(idx) instanceof SlotPlayerHotBar) {
|
||||
final AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx); // require AE SLots!
|
||||
ItemStack itemStack = clickSlot.getStack();
|
||||
if (AEApi.instance().definitions().materials().blankPattern().isSameAs(itemStack)) {
|
||||
IItemHandler patternInv = this.getPart().getInventoryByName("pattern");
|
||||
ItemStack remainder = patternInv.insertItem(0, itemStack, false);
|
||||
clickSlot.putStack(remainder);
|
||||
}
|
||||
}
|
||||
return super.transferStackInSlot(p, idx);
|
||||
}
|
||||
|
||||
public AbstractPartEncoder getPart() {
|
||||
return this.patternTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean isSlotEnabled(int idx);
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName(String name) {
|
||||
if (name.equals("player")) {
|
||||
return new PlayerInvWrapper(this.getInventoryPlayer());
|
||||
}
|
||||
return this.getPart().getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useRealItems() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStackInSlot(int slotID, ItemStack stack) {
|
||||
super.putStackInSlot(slotID, stack);
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
|
||||
protected void updateOrderOfOutputSlots() {
|
||||
if (!this.isCraftingMode()) {
|
||||
if (craftSlot != null) {
|
||||
this.craftSlot.xPos = -9000;
|
||||
}
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
this.outputSlots[y].xPos = this.outputSlots[y].getX();
|
||||
}
|
||||
} else {
|
||||
if (craftSlot != null) {
|
||||
this.craftSlot.xPos = this.craftSlot.getX();
|
||||
}
|
||||
for (int y = 0; y < 3; y++) {
|
||||
this.outputSlots[y].xPos = -9000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(final Slot s) {
|
||||
if (s == this.patternSlotOUT && Platform.isServer()) {
|
||||
for (final IContainerListener listener : this.listeners) {
|
||||
for (final Slot slot : this.inventorySlots) {
|
||||
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
|
||||
listener.sendSlotContents(this, slot.slotNumber, slot.getStack());
|
||||
}
|
||||
}
|
||||
if (listener instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) listener).isChangingQuantityOnly = false;
|
||||
}
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void encodeAndMoveToInventory() {
|
||||
encode();
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
if (!output.isEmpty()) {
|
||||
if (!getPlayerInv().addItemStackToInventory(output)) {
|
||||
getPlayerInv().player.dropItem(output, false);
|
||||
}
|
||||
this.patternSlotOUT.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
public void encode() {
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
|
||||
final ItemStack[] in = this.getInputs();
|
||||
final ItemStack[] out = this.getOutputs();
|
||||
|
||||
// if there is no input, this would be silly.
|
||||
if (in == null || out == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// first check the output slots, should either be null, or a pattern
|
||||
if (!output.isEmpty() && !this.isPattern(output)) {
|
||||
return;
|
||||
} // if nothing is there we should snag a new pattern.
|
||||
else if (output.isEmpty()) {
|
||||
output = this.patternSlotIN.getStack();
|
||||
if (output.isEmpty() || !this.isPattern(output)) {
|
||||
return; // no blanks.
|
||||
}
|
||||
|
||||
// remove one, and clear the input slot.
|
||||
output.setCount(output.getCount() - 1);
|
||||
if (output.getCount() == 0) {
|
||||
this.patternSlotIN.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
// add a new encoded pattern.
|
||||
Optional<ItemStack> maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack(1);
|
||||
if (maybePattern.isPresent()) {
|
||||
output = maybePattern.get();
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
}
|
||||
|
||||
// encode the slot.
|
||||
final NBTTagCompound encodedValue = new NBTTagCompound();
|
||||
|
||||
final NBTTagList tagIn = new NBTTagList();
|
||||
final NBTTagList tagOut = new NBTTagList();
|
||||
|
||||
for (final ItemStack i : in) {
|
||||
tagIn.appendTag(this.createItemTag(i));
|
||||
}
|
||||
|
||||
for (final ItemStack i : out) {
|
||||
tagOut.appendTag(this.createItemTag(i));
|
||||
}
|
||||
|
||||
encodedValue.setTag("in", tagIn);
|
||||
encodedValue.setTag("out", tagOut);
|
||||
encodedValue.setBoolean("crafting", this.isCraftingMode());
|
||||
encodedValue.setBoolean("substitute", this.isSubstitute());
|
||||
|
||||
output.setTagCompound(encodedValue);
|
||||
}
|
||||
|
||||
public void multiply(int multiple) {
|
||||
ItemStack[] input = new ItemStack[craftingSlots.length];
|
||||
boolean canMultiplyInputs = true;
|
||||
boolean canMultiplyOutputs = true;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getCount() * multiple < 1) {
|
||||
canMultiplyInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (!out.isEmpty() && out.getCount() * multiple < 1) {
|
||||
canMultiplyOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canMultiplyInputs && canMultiplyOutputs) {
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.craftingSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
craftingSlot.getStack().setCount(stack.getCount() * multiple);
|
||||
}
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
outputSlot.getStack().setCount(stack.getCount() * multiple);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void divide(int divide) {
|
||||
ItemStack[] input = new ItemStack[craftingSlots.length];
|
||||
boolean canDivideInputs = true;
|
||||
boolean canDivideOutputs = true;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getCount() % divide != 0) {
|
||||
canDivideInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (!out.isEmpty() && out.getCount() % divide != 0) {
|
||||
canDivideOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canDivideInputs && canDivideOutputs) {
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.craftingSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
craftingSlot.getStack().setCount(stack.getCount() / divide);
|
||||
}
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
outputSlot.getStack().setCount(stack.getCount() / divide);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void increase(int increase) {
|
||||
ItemStack[] input = new ItemStack[craftingSlots.length];
|
||||
boolean canIncreaseInputs = true;
|
||||
boolean canIncreaseOutputs = true;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getCount() + increase < 1) {
|
||||
canIncreaseInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (!out.isEmpty() && out.getCount() + increase < 1) {
|
||||
canIncreaseOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canIncreaseInputs && canIncreaseOutputs) {
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.craftingSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
craftingSlot.getStack().setCount(stack.getCount() + increase);
|
||||
}
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
outputSlot.getStack().setCount(stack.getCount() + increase);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void decrease(int decrease) {
|
||||
ItemStack[] input = new ItemStack[craftingSlots.length];
|
||||
boolean canDecreaseInputs = true;
|
||||
boolean canDecreaseOutputs = true;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getCount() - decrease < 1) {
|
||||
canDecreaseInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (!out.isEmpty() && out.getCount() - decrease < 1) {
|
||||
canDecreaseOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canDecreaseInputs && canDecreaseOutputs) {
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.craftingSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
craftingSlot.getStack().setCount(stack.getCount() - decrease);
|
||||
}
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
outputSlot.getStack().setCount(stack.getCount() - decrease);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void maximizeCount() {
|
||||
ItemStack[] input = new ItemStack[craftingSlots.length];
|
||||
boolean canGrowInputs = true;
|
||||
boolean canGrowOutputs = true;
|
||||
int maxInputStackGrowth = 0;
|
||||
int maxOutputStackGrowth = 0;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getMaxStackSize() - input[x].getCount() > maxInputStackGrowth) {
|
||||
maxInputStackGrowth = input[x].getMaxStackSize() - input[x].getCount();
|
||||
}
|
||||
if (!input[x].isEmpty() && input[x].getCount() + maxInputStackGrowth > input[x].getMaxStackSize()) {
|
||||
canGrowInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
{
|
||||
maxOutputStackGrowth = out.getMaxStackSize() - out.getCount();
|
||||
}
|
||||
if (!out.isEmpty() && out.getCount() + maxOutputStackGrowth > out.getMaxStackSize()) {
|
||||
canGrowOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canGrowInputs && canGrowOutputs) {
|
||||
int maxStackGrowth = Math.min(maxInputStackGrowth, maxOutputStackGrowth);
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.craftingSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
craftingSlot.getStack().setCount(stack.getCount() + maxStackGrowth);
|
||||
}
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
outputSlot.getStack().setCount(stack.getCount() + maxStackGrowth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemStack[] getInputs() {
|
||||
final ItemStack[] input = new ItemStack[craftingSlots.length];
|
||||
boolean hasValue = false;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (!input[x].isEmpty()) {
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasValue) {
|
||||
return input;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ItemStack[] getOutputs() {
|
||||
if (this.isCraftingMode()) {
|
||||
final ItemStack out = this.getAndUpdateOutput();
|
||||
|
||||
if (!out.isEmpty() && out.getCount() > 0) {
|
||||
return new ItemStack[]{out};
|
||||
}
|
||||
} else {
|
||||
final List<ItemStack> list = new ArrayList<>(outputSlots.length);
|
||||
boolean hasValue = false;
|
||||
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
|
||||
if (!out.isEmpty() && out.getCount() > 0) {
|
||||
list.add(out);
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasValue) {
|
||||
return list.toArray(new ItemStack[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ItemStack getAndUpdateOutput() {
|
||||
final World world = this.getPlayerInv().player.world;
|
||||
final InventoryCrafting ic = new InventoryCrafting(this, 3, 3);
|
||||
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++) {
|
||||
ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
|
||||
}
|
||||
|
||||
if (this.currentRecipe == null || !this.currentRecipe.matches(ic, world)) {
|
||||
this.currentRecipe = CraftingManager.findMatchingRecipe(ic, world);
|
||||
}
|
||||
|
||||
final ItemStack is;
|
||||
|
||||
if (this.currentRecipe == null) {
|
||||
is = ItemStack.EMPTY;
|
||||
} else {
|
||||
is = this.currentRecipe.getCraftingResult(ic);
|
||||
}
|
||||
|
||||
this.cOut.setStackInSlot(0, is);
|
||||
return is;
|
||||
}
|
||||
|
||||
public boolean isCraftingMode() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
void setCraftingMode(final boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
}
|
||||
|
||||
|
||||
boolean isSubstitute() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
public void setSubstitute(final boolean substitute) {
|
||||
this.substitute = substitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
if (Platform.isServer()) {
|
||||
if (this.isCraftingMode() != this.getPart().isCraftingRecipe()) {
|
||||
this.setCraftingMode(this.getPart().isCraftingRecipe());
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
|
||||
this.substitute = this.getPart().isSubstitution();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
|
||||
super.onUpdate(field, oldValue, newValue);
|
||||
|
||||
if (field.equals("craftingMode")) {
|
||||
this.getAndUpdateOutput();
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
}
|
||||
|
||||
boolean isPattern(final ItemStack output) {
|
||||
if (output.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
boolean isPattern = definitions.items().encodedPattern().isSameAs(output);
|
||||
isPattern |= definitions.materials().blankPattern().isSameAs(output);
|
||||
|
||||
return isPattern;
|
||||
}
|
||||
|
||||
NBTBase createItemTag(final ItemStack i) {
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if (!i.isEmpty()) {
|
||||
i.writeToNBT(c);
|
||||
if (i.getCount() > i.getMaxStackSize()) {
|
||||
c.setInteger("stackSize", i.getCount());
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (final Slot s : this.craftingSlots) {
|
||||
s.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
for (final Slot s : this.outputSlots) {
|
||||
s.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ package appeng.container.implementations;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
@@ -29,64 +28,50 @@ 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.*;
|
||||
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.helpers.IContainerCraftingPacket;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperCursorItemHandler;
|
||||
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.*;
|
||||
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;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
|
||||
public class ContainerPatternTerm extends ContainerPatternEncoder {
|
||||
|
||||
private final PartPatternTerminal patternTerminal;
|
||||
private final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
|
||||
private final IItemHandler crafting;
|
||||
private final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[9];
|
||||
private final OptionalSlotFake[] outputSlots = new OptionalSlotFake[3];
|
||||
private final SlotPatternTerm craftSlot;
|
||||
private final SlotRestrictedInput patternSlotIN;
|
||||
private final SlotRestrictedInput patternSlotOUT;
|
||||
|
||||
private IRecipe currentRecipe;
|
||||
@GuiSync(97)
|
||||
public boolean craftingMode = true;
|
||||
@GuiSync(96)
|
||||
public boolean substitute = false;
|
||||
|
||||
public ContainerPatternTerm(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable, false);
|
||||
this.patternTerminal = (PartPatternTerminal) monitorable;
|
||||
|
||||
final IItemHandler patternInv = this.getPatternTerminal().getInventoryByName("pattern");
|
||||
final IItemHandler output = this.getPatternTerminal().getInventoryByName("output");
|
||||
this.craftingSlots = new SlotFakeCraftingMatrix[9];
|
||||
this.outputSlots = new OptionalSlotFake[3];
|
||||
|
||||
this.crafting = this.getPatternTerminal().getInventoryByName("crafting");
|
||||
final IItemHandler patternInv = this.getPart().getInventoryByName("pattern");
|
||||
final IItemHandler output = this.getPart().getInventoryByName("output");
|
||||
|
||||
this.crafting = this.getPart().getInventoryByName("crafting");
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
@@ -98,7 +83,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
.getPowerSource(), monitorable, this.crafting, patternInv, this.cOut, 110, -76 + 18, this, 2, this));
|
||||
this.craftSlot.setIIcon(-1);
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
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);
|
||||
@@ -117,388 +102,13 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
|
||||
if (Platform.isClient()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (this.inventorySlots.get(idx) instanceof SlotPlayerInv || this.inventorySlots.get(idx) instanceof SlotPlayerHotBar) {
|
||||
final AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx); // require AE SLots!
|
||||
ItemStack itemStack = clickSlot.getStack();
|
||||
if (AEApi.instance().definitions().materials().blankPattern().isSameAs(itemStack)) {
|
||||
IItemHandler patternInv = this.getPatternTerminal().getInventoryByName("pattern");
|
||||
ItemStack remainder = patternInv.insertItem(0, itemStack, false);
|
||||
clickSlot.putStack(remainder);
|
||||
}
|
||||
}
|
||||
return super.transferStackInSlot(p, idx);
|
||||
}
|
||||
|
||||
|
||||
private void updateOrderOfOutputSlots() {
|
||||
if (!this.isCraftingMode()) {
|
||||
this.craftSlot.xPos = -9000;
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
this.outputSlots[y].xPos = this.outputSlots[y].getX();
|
||||
}
|
||||
} else {
|
||||
this.craftSlot.xPos = this.craftSlot.getX();
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
this.outputSlots[y].xPos = -9000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStackInSlot(int slotID, ItemStack stack) {
|
||||
super.putStackInSlot(slotID, stack);
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
|
||||
protected ItemStack getAndUpdateOutput() {
|
||||
final World world = this.getPlayerInv().player.world;
|
||||
final InventoryCrafting ic = new InventoryCrafting(this, 3, 3);
|
||||
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++) {
|
||||
ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
|
||||
}
|
||||
|
||||
if (this.currentRecipe == null || !this.currentRecipe.matches(ic, world)) {
|
||||
this.currentRecipe = CraftingManager.findMatchingRecipe(ic, world);
|
||||
}
|
||||
|
||||
final ItemStack is;
|
||||
|
||||
if (this.currentRecipe == null) {
|
||||
is = ItemStack.EMPTY;
|
||||
} else {
|
||||
is = this.currentRecipe.getCraftingResult(ic);
|
||||
}
|
||||
|
||||
this.cOut.setStackInSlot(0, is);
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack) {
|
||||
|
||||
}
|
||||
|
||||
public void encodeAndMoveToInventory() {
|
||||
encode();
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
if (!output.isEmpty()) {
|
||||
if (!getPlayerInv().addItemStackToInventory(output)) {
|
||||
getPlayerInv().player.dropItem(output, false);
|
||||
}
|
||||
this.patternSlotOUT.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
public void encode() {
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
|
||||
final ItemStack[] in = this.getInputs();
|
||||
final ItemStack[] out = this.getOutputs();
|
||||
|
||||
// if there is no input, this would be silly.
|
||||
if (in == null || out == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// first check the output slots, should either be null, or a pattern
|
||||
if (!output.isEmpty() && !this.isPattern(output)) {
|
||||
return;
|
||||
} // if nothing is there we should snag a new pattern.
|
||||
else if (output.isEmpty()) {
|
||||
output = this.patternSlotIN.getStack();
|
||||
if (output.isEmpty() || !this.isPattern(output)) {
|
||||
return; // no blanks.
|
||||
}
|
||||
|
||||
// remove one, and clear the input slot.
|
||||
output.setCount(output.getCount() - 1);
|
||||
if (output.getCount() == 0) {
|
||||
this.patternSlotIN.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
// add a new encoded pattern.
|
||||
Optional<ItemStack> maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack(1);
|
||||
if (maybePattern.isPresent()) {
|
||||
output = maybePattern.get();
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
}
|
||||
|
||||
// encode the slot.
|
||||
final NBTTagCompound encodedValue = new NBTTagCompound();
|
||||
|
||||
final NBTTagList tagIn = new NBTTagList();
|
||||
final NBTTagList tagOut = new NBTTagList();
|
||||
|
||||
for (final ItemStack i : in) {
|
||||
tagIn.appendTag(this.createItemTag(i));
|
||||
}
|
||||
|
||||
for (final ItemStack i : out) {
|
||||
tagOut.appendTag(this.createItemTag(i));
|
||||
}
|
||||
|
||||
encodedValue.setTag("in", tagIn);
|
||||
encodedValue.setTag("out", tagOut);
|
||||
encodedValue.setBoolean("crafting", this.isCraftingMode());
|
||||
encodedValue.setBoolean("substitute", this.isSubstitute());
|
||||
|
||||
output.setTagCompound(encodedValue);
|
||||
}
|
||||
|
||||
public void multiply(int multiple) {
|
||||
ItemStack[] input = new ItemStack[9];
|
||||
boolean canMultiplyInputs = true;
|
||||
boolean canMultiplyOutputs = true;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getCount() * multiple > input[x].getMaxStackSize()) {
|
||||
canMultiplyInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (!out.isEmpty() && out.getCount() * multiple > out.getMaxStackSize()) {
|
||||
canMultiplyOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canMultiplyInputs && canMultiplyOutputs) {
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.craftingSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty())
|
||||
craftingSlot.getStack().setCount(stack.getCount() * multiple);
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty())
|
||||
outputSlot.getStack().setCount(stack.getCount() * multiple);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void divide(int divide) {
|
||||
ItemStack[] input = new ItemStack[9];
|
||||
boolean canDivideInputs = true;
|
||||
boolean canDivideOutputs = true;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getCount() % divide != 0) {
|
||||
canDivideInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (!out.isEmpty() && out.getCount() % divide != 0) {
|
||||
canDivideOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canDivideInputs && canDivideOutputs) {
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.craftingSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty())
|
||||
craftingSlot.getStack().setCount(stack.getCount() / divide);
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty())
|
||||
outputSlot.getStack().setCount(stack.getCount() / divide);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void increase(int increase) {
|
||||
ItemStack[] input = new ItemStack[9];
|
||||
boolean canIncreaseInputs = true;
|
||||
boolean canIncreaseOutputs = true;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getCount() + increase > input[x].getMaxStackSize()) {
|
||||
canIncreaseInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (!out.isEmpty() && out.getCount() + increase > out.getMaxStackSize()) {
|
||||
canIncreaseOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canIncreaseInputs && canIncreaseOutputs) {
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.craftingSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty())
|
||||
craftingSlot.getStack().setCount(stack.getCount() + increase);
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty())
|
||||
outputSlot.getStack().setCount(stack.getCount() + increase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void decrease(int decrease) {
|
||||
ItemStack[] input = new ItemStack[9];
|
||||
boolean canDecreaseInputs = true;
|
||||
boolean canDecreaseOutputs = true;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getCount() - decrease < 1) {
|
||||
canDecreaseInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (!out.isEmpty() && out.getCount() - decrease < 1) {
|
||||
canDecreaseOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canDecreaseInputs && canDecreaseOutputs) {
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.craftingSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty())
|
||||
craftingSlot.getStack().setCount(stack.getCount() - decrease);
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty())
|
||||
outputSlot.getStack().setCount(stack.getCount() - decrease);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void maximizeCount() {
|
||||
ItemStack[] input = new ItemStack[9];
|
||||
boolean canGrowInputs = true;
|
||||
boolean canGrowOutputs = true;
|
||||
int maxInputStackGrowth = 0;
|
||||
int maxOutputStackGrowth = 0;
|
||||
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (!input[x].isEmpty() && input[x].getMaxStackSize() - input[x].getCount() > maxInputStackGrowth) {
|
||||
maxInputStackGrowth = input[x].getMaxStackSize() - input[x].getCount();
|
||||
}
|
||||
if (!input[x].isEmpty() && input[x].getCount() + maxInputStackGrowth > input[x].getMaxStackSize()) {
|
||||
canGrowInputs = false;
|
||||
}
|
||||
}
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
{
|
||||
maxOutputStackGrowth = out.getMaxStackSize() - out.getCount();
|
||||
}
|
||||
if (!out.isEmpty() && out.getCount() + maxOutputStackGrowth > out.getMaxStackSize()) {
|
||||
canGrowOutputs = false;
|
||||
}
|
||||
}
|
||||
if (canGrowInputs && canGrowOutputs) {
|
||||
int maxStackGrowth = Math.min(maxInputStackGrowth, maxOutputStackGrowth);
|
||||
for (SlotFakeCraftingMatrix craftingSlot : this.craftingSlots) {
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if (!stack.isEmpty())
|
||||
craftingSlot.getStack().setCount(stack.getCount() + maxStackGrowth);
|
||||
}
|
||||
for (OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if (!stack.isEmpty())
|
||||
outputSlot.getStack().setCount(stack.getCount() + maxStackGrowth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemStack[] getInputs() {
|
||||
final ItemStack[] input = new ItemStack[9];
|
||||
boolean hasValue = false;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (!input[x].isEmpty()) {
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasValue) {
|
||||
return input;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ItemStack[] getOutputs() {
|
||||
if (this.isCraftingMode()) {
|
||||
final ItemStack out = this.getAndUpdateOutput();
|
||||
|
||||
if (!out.isEmpty() && out.getCount() > 0) {
|
||||
return new ItemStack[]{out};
|
||||
}
|
||||
} else {
|
||||
final List<ItemStack> list = new ArrayList<>(3);
|
||||
boolean hasValue = false;
|
||||
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
|
||||
if (!out.isEmpty() && out.getCount() > 0) {
|
||||
list.add(out);
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasValue) {
|
||||
return list.toArray(new ItemStack[list.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean isPattern(final ItemStack output) {
|
||||
if (output.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
boolean isPattern = definitions.items().encodedPattern().isSameAs(output);
|
||||
isPattern |= definitions.materials().blankPattern().isSameAs(output);
|
||||
|
||||
return isPattern;
|
||||
}
|
||||
|
||||
NBTBase createItemTag(final ItemStack i) {
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if (!i.isEmpty()) {
|
||||
i.writeToNBT(c);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
if (idx == 1) {
|
||||
return Platform.isServer() ? !this.getPatternTerminal().isCraftingRecipe() : !this.isCraftingMode();
|
||||
return Platform.isServer() ? !this.getPart().isCraftingRecipe() : !this.isCraftingMode();
|
||||
} else if (idx == 2) {
|
||||
return Platform.isServer() ? this.getPatternTerminal().isCraftingRecipe() : this.isCraftingMode();
|
||||
return Platform.isServer() ? this.getPart().isCraftingRecipe() : this.isCraftingMode();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -543,7 +153,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
return;
|
||||
}
|
||||
|
||||
final IMEMonitor<IAEItemStack> storage = this.getPatternTerminal()
|
||||
final IMEMonitor<IAEItemStack> storage = this.getPart()
|
||||
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
final IItemList<IAEItemStack> all = storage.getStorageList();
|
||||
|
||||
@@ -585,107 +195,10 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
if (!failed.isEmpty()) {
|
||||
this.getCellInventory()
|
||||
.injectItems(AEItemStack.fromItemStack(failed), Actionable.MODULATE,
|
||||
new MachineSource(this.getPatternTerminal()));
|
||||
new MachineSource(this.getPart()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
if (Platform.isServer()) {
|
||||
if (this.isCraftingMode() != this.getPatternTerminal().isCraftingRecipe()) {
|
||||
this.setCraftingMode(this.getPatternTerminal().isCraftingRecipe());
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
|
||||
this.substitute = this.patternTerminal.isSubstitution();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
|
||||
super.onUpdate(field, oldValue, newValue);
|
||||
|
||||
if (field.equals("craftingMode")) {
|
||||
this.getAndUpdateOutput();
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(final Slot s) {
|
||||
if (s == this.patternSlotOUT && Platform.isServer()) {
|
||||
for (final IContainerListener listener : this.listeners) {
|
||||
for (final Slot slot : this.inventorySlots) {
|
||||
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
|
||||
listener.sendSlotContents(this, slot.slotNumber, slot.getStack());
|
||||
}
|
||||
}
|
||||
if (listener instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) listener).isChangingQuantityOnly = false;
|
||||
}
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
if (s == this.craftSlot && Platform.isClient()) {
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (final Slot s : this.craftingSlots) {
|
||||
s.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
for (final Slot s : this.outputSlots) {
|
||||
s.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName(final String name) {
|
||||
if (name.equals("player")) {
|
||||
return new PlayerInvWrapper(this.getInventoryPlayer());
|
||||
}
|
||||
return this.getPatternTerminal().getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useRealItems() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void toggleSubstitute() {
|
||||
this.substitute = !this.substitute;
|
||||
|
||||
this.detectAndSendChanges();
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
|
||||
public boolean isCraftingMode() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
private void setCraftingMode(final boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
}
|
||||
|
||||
public PartPatternTerminal getPatternTerminal() {
|
||||
return this.patternTerminal;
|
||||
}
|
||||
|
||||
boolean isSubstitute() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
public void setSubstitute(final boolean substitute) {
|
||||
this.substitute = substitute;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
|
||||
this.securityBox = (TileSecurityStation) monitorable;
|
||||
|
||||
this.addSlotToContainer(this.configSlot = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.BIOMETRIC_CARD, this.securityBox
|
||||
.getConfigSlot(), 0, 37, -33 + jeiOffset, ip));
|
||||
.getConfigSlot(), 0, 37, -33, ip));
|
||||
|
||||
this.addSlotToContainer(
|
||||
this.wirelessIn = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODABLE_ITEM, this.wirelessEncoder, 0, 212, 10 + jeiOffset, ip));
|
||||
|
||||
@@ -46,6 +46,7 @@ public class AppEngSlot extends Slot {
|
||||
private int IIcon = -1;
|
||||
private hasCalculatedValidness isValid;
|
||||
private boolean isDisplay = false;
|
||||
private boolean returnAsSingleStack;
|
||||
|
||||
public AppEngSlot(final IItemHandler inv, final int idx, final int x, final int y) {
|
||||
super(emptyInventory, idx, x, y);
|
||||
@@ -94,14 +95,29 @@ public class AppEngSlot extends Slot {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
|
||||
if (this.isDisplay()) {
|
||||
this.setDisplay(false);
|
||||
if (this.returnAsSingleStack()) {
|
||||
setReturnAsSingleStack(false);
|
||||
ItemStack ret = this.getDisplayStack().copy();
|
||||
ret.setCount(1);
|
||||
return ret;
|
||||
}
|
||||
return this.getDisplayStack();
|
||||
}
|
||||
|
||||
return this.itemHandler.getStackInSlot(this.index);
|
||||
}
|
||||
|
||||
private boolean returnAsSingleStack() {
|
||||
return this.returnAsSingleStack;
|
||||
}
|
||||
|
||||
public void setReturnAsSingleStack(boolean returnAsSingleStack) {
|
||||
this.returnAsSingleStack = returnAsSingleStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(final ItemStack stack) {
|
||||
if (this.isSlotEnabled()) {
|
||||
|
||||
@@ -62,6 +62,11 @@ public class OptionalSlotFake extends SlotFake implements IOptionalSlot {
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRenderDisabled() {
|
||||
return this.renderDisabled;
|
||||
|
||||
@@ -27,4 +27,9 @@ public class SlotFakeCraftingMatrix extends SlotFake {
|
||||
public SlotFakeCraftingMatrix(final IItemHandler inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public enum PlayerMessages {
|
||||
DeviceNotLinked,
|
||||
StationCanNotBeLocated,
|
||||
SettingCleared,
|
||||
;
|
||||
MissingPatternsToEncode;
|
||||
|
||||
public ITextComponent get() {
|
||||
return new TextComponentTranslation(this.getName());
|
||||
|
||||
@@ -20,19 +20,18 @@ package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
import appeng.client.gui.implementations.GuiCraftingCPU;
|
||||
import appeng.client.gui.implementations.GuiMEMonitorable;
|
||||
import appeng.client.gui.implementations.GuiNetworkStatus;
|
||||
import appeng.container.implementations.ContainerCraftConfirm;
|
||||
import appeng.container.implementations.ContainerCraftingCPU;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.container.implementations.ContainerNetworkStatus;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -132,22 +131,22 @@ public class PacketMEInventoryUpdate extends AppEngPacket {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final AppEngPacket packet, final EntityPlayer player) {
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
final Container c = player.openContainer;
|
||||
|
||||
if (gs instanceof GuiCraftConfirm) {
|
||||
((GuiCraftConfirm) gs).postUpdate(this.list, this.ref);
|
||||
if (c instanceof ContainerCraftConfirm) {
|
||||
((ContainerCraftConfirm) c).postUpdate(this.list, this.ref);
|
||||
}
|
||||
|
||||
if (gs instanceof GuiCraftingCPU) {
|
||||
((GuiCraftingCPU) gs).postUpdate(this.list, this.ref);
|
||||
if (c instanceof ContainerCraftingCPU) {
|
||||
((ContainerCraftingCPU) c).postUpdate(this.list, this.ref);
|
||||
}
|
||||
|
||||
if (gs instanceof GuiMEMonitorable) {
|
||||
((GuiMEMonitorable) gs).postUpdate(this.list);
|
||||
if (c instanceof ContainerMEMonitorable) {
|
||||
((ContainerMEMonitorable) c).postUpdate(this.list);
|
||||
}
|
||||
|
||||
if (gs instanceof GuiNetworkStatus) {
|
||||
((GuiNetworkStatus) gs).postUpdate(this.list);
|
||||
if (c instanceof ContainerNetworkStatus) {
|
||||
((ContainerNetworkStatus) c).postUpdate(this.list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ public class PacketValueConfig extends AppEngPacket {
|
||||
if (c instanceof ContainerPatternTerm) {
|
||||
final ContainerPatternTerm cpt = (ContainerPatternTerm) c;
|
||||
if (this.Name.equals("PatternTerminal.CraftMode")) {
|
||||
cpt.getPatternTerminal().setCraftingRecipe(this.Value.equals("1"));
|
||||
cpt.getPart().setCraftingRecipe(this.Value.equals("1"));
|
||||
} else if (this.Name.equals("PatternTerminal.Encode")) {
|
||||
if (this.Value.equals("2")) {
|
||||
cpt.encodeAndMoveToInventory();
|
||||
@@ -157,7 +157,7 @@ public class PacketValueConfig extends AppEngPacket {
|
||||
} else if (this.Name.equals("PatternTerminal.MaximizeCount")) {
|
||||
cpt.maximizeCount();
|
||||
} else if (this.Name.equals("PatternTerminal.Substitute")) {
|
||||
cpt.getPatternTerminal().setSubstitution(this.Value.equals("1"));
|
||||
cpt.getPart().setSubstitution(this.Value.equals("1"));
|
||||
}
|
||||
} else if (c instanceof ContainerExpandedProcessingPatternTerm) {
|
||||
final ContainerExpandedProcessingPatternTerm cept = (ContainerExpandedProcessingPatternTerm) c;
|
||||
|
||||
@@ -41,6 +41,7 @@ public class GuiFluidTank extends GuiCustomSlot implements ITooltip {
|
||||
private final int slot;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private boolean darkened = false;
|
||||
|
||||
public GuiFluidTank(IAEFluidTank tank, int slot, int id, int x, int y, int w, int h) {
|
||||
super(id, x, y);
|
||||
@@ -50,6 +51,15 @@ public class GuiFluidTank extends GuiCustomSlot implements ITooltip {
|
||||
this.height = h;
|
||||
}
|
||||
|
||||
public GuiFluidTank(IAEFluidTank tank, int slot, int id, int x, int y, int w, int h, boolean darkened) {
|
||||
super(id, x, y);
|
||||
this.tank = tank;
|
||||
this.slot = slot;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.darkened = darkened;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawContent(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
|
||||
final IAEFluidStack fs = this.getFluidStack();
|
||||
@@ -66,10 +76,16 @@ public class GuiFluidTank extends GuiCustomSlot implements ITooltip {
|
||||
float red = (fluid.getFluid().getColor() >> 16 & 255) / 255.0F;
|
||||
float green = (fluid.getFluid().getColor() >> 8 & 255) / 255.0F;
|
||||
float blue = (fluid.getFluid().getColor() & 255) / 255.0F;
|
||||
if (darkened) {
|
||||
red = red * 0.4F;
|
||||
green = green * 0.4F;
|
||||
blue = blue * 0.4F;
|
||||
}
|
||||
GlStateManager.color(red, green, blue);
|
||||
|
||||
TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite(fluid.getFluid().getStill().toString());
|
||||
final int scaledHeight = (int) (this.height * ((float) fluid.getStackSize() / this.tank.getTankProperties()[this.slot].getCapacity()));
|
||||
int scaledHeight = (int) (this.height * ((float) fluid.getStackSize() / this.tank.getTankProperties()[this.slot].getCapacity()));
|
||||
scaledHeight = Math.min(this.height, scaledHeight);
|
||||
|
||||
int iconHeightRemainder = scaledHeight % 16;
|
||||
if (iconHeightRemainder > 0) {
|
||||
|
||||
@@ -234,9 +234,4 @@ public class ContainerFluidInterface extends ContainerFluidConfigurable implemen
|
||||
public int availableUpgrades() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasToolbox() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,6 +528,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
this.tanks.readFromNBT(data, "storage");
|
||||
this.priority = data.getInteger("priority");
|
||||
this.upgrades.readFromNBT(data, "upgrades");
|
||||
this.tanks.setCapacity((int) (Math.pow(4, this.getInstalledUpgrades(Upgrades.CAPACITY) + 1) * Fluid.BUCKET_VOLUME));
|
||||
this.readConfig();
|
||||
}
|
||||
|
||||
|
||||
@@ -114,8 +114,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
private final IActionSource mySource;
|
||||
private final IActionSource interfaceRequestSource;
|
||||
private final ConfigManager cm = new ConfigManager(this);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, NUMBER_OF_CONFIG_SLOTS);
|
||||
private final AppEngInternalInventory storage = new AppEngInternalInventory(this, NUMBER_OF_STORAGE_SLOTS);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, NUMBER_OF_CONFIG_SLOTS, 512);
|
||||
private final AppEngInternalInventory storage = new AppEngInternalInventory(this, NUMBER_OF_STORAGE_SLOTS, 512);
|
||||
private final AppEngInternalInventory patterns = new AppEngInternalInventory(this, NUMBER_OF_PATTERN_SLOTS);
|
||||
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>(new NullInventory<IAEItemStack>(), AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>(new NullInventory<IAEFluidStack>(), AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
|
||||
@@ -749,7 +749,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
// make sure strange things didn't happen...
|
||||
// TODO: check if OK
|
||||
final ItemStack canExtract = adaptor.simulateRemove((int) diff, toStore.getDefinition(), null);
|
||||
if (canExtract.isEmpty() || canExtract.getCount() != diff) {
|
||||
if (canExtract.isEmpty()) {
|
||||
changed = true;
|
||||
throw new GridAccessException();
|
||||
}
|
||||
@@ -766,8 +766,6 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
final ItemStack removed = adaptor.removeItems((int) diff, ItemStack.EMPTY, null);
|
||||
if (removed.isEmpty()) {
|
||||
throw new IllegalStateException("bad attempt at managing inventory. ( removeItems )");
|
||||
} else if (removed.getCount() != diff) {
|
||||
throw new IllegalStateException("bad attempt at managing inventory. ( removeItems )");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,5 +43,7 @@ public enum InventoryAction {
|
||||
ROLL_DOWN,
|
||||
AUTO_CRAFT,
|
||||
PLACE_SINGLE,
|
||||
DOUBLE,
|
||||
HALVE,
|
||||
PLACE_JEI_GHOST_ITEM
|
||||
}
|
||||
|
||||
@@ -43,12 +43,12 @@ import java.util.*;
|
||||
|
||||
public class PatternHelper implements ICraftingPatternDetails, Comparable<PatternHelper> {
|
||||
|
||||
private static final int CRAFTING_GRID_DIMENSION = 3;
|
||||
public static final int CRAFTING_GRID_DIMENSION = 3;
|
||||
private static final int CRAFTING_INPUT_LIMIT = CRAFTING_GRID_DIMENSION * CRAFTING_GRID_DIMENSION;
|
||||
public static final int PROCESSING_INPUT_HEIGHT = 4;
|
||||
public static final int PROCESSING_INPUT_WIDTH = 4;
|
||||
public static final int PROCESSING_INPUT_LIMIT = PROCESSING_INPUT_HEIGHT * PROCESSING_INPUT_WIDTH;
|
||||
private static final int CRAFTING_OUTPUT_LIMIT = 1;
|
||||
public static final int CRAFTING_OUTPUT_LIMIT = 1;
|
||||
public static final int PROCESSING_OUTPUT_LIMIT = 6;
|
||||
|
||||
private final ItemStack patternItem;
|
||||
@@ -93,6 +93,10 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
NBTTagCompound ingredient = inTag.getCompoundTagAt(x);
|
||||
final ItemStack gs = new ItemStack(ingredient);
|
||||
|
||||
if (ingredient.hasKey("stackSize")) {
|
||||
gs.setCount(ingredient.getInteger("stackSize"));
|
||||
}
|
||||
|
||||
if (!ingredient.hasNoTags() && gs.isEmpty()) {
|
||||
throw new IllegalArgumentException("No pattern here!");
|
||||
}
|
||||
@@ -124,6 +128,10 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
NBTTagCompound resultItemTag = outTag.getCompoundTagAt(x);
|
||||
final ItemStack gs = new ItemStack(resultItemTag);
|
||||
|
||||
if (resultItemTag.hasKey("stackSize")) {
|
||||
gs.setCount(resultItemTag.getInteger("stackSize"));
|
||||
}
|
||||
|
||||
if (!resultItemTag.hasNoTags() && gs.isEmpty()) {
|
||||
throw new IllegalArgumentException("No pattern here!");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import mezz.jei.api.gui.ITooltipCallback;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CraftableCallBack implements ITooltipCallback<ItemStack> {
|
||||
private final IItemList<IAEItemStack> list;
|
||||
private final Container container;
|
||||
private final Stopwatch lastClicked = Stopwatch.createStarted();
|
||||
|
||||
|
||||
public CraftableCallBack(Container container, IItemList<IAEItemStack> ir) {
|
||||
this.list = ir;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTooltip(int slotIndex, boolean input, ItemStack ingredient, List<String> tooltip) {
|
||||
if (!input) return;
|
||||
if (list != null) {
|
||||
IAEItemStack found = list.findPrecise(AEItemStack.fromItemStack(ingredient));
|
||||
if (found != null) {
|
||||
if (found.getStackSize() == 0) {
|
||||
String line = "§c[" + I18n.translateToLocalFormatted("gui.appliedenergistics2.Missing") + "]";
|
||||
tooltip.add(line);
|
||||
}
|
||||
if (found.isCraftable()) {
|
||||
String line = "§1[" + I18n.translateToLocalFormatted("gui.tooltips.appliedenergistics2.Craftable") + "]";
|
||||
tooltip.add(line);
|
||||
if (Mouse.isButtonDown(2) && this.lastClicked.elapsed(TimeUnit.MILLISECONDS) > 200) {
|
||||
this.lastClicked.reset().start();
|
||||
((AEBaseContainer) container).setTargetStack(found);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.AUTO_CRAFT, container.getInventory().size(), 0);
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String line = "§c[" + I18n.translateToLocalFormatted("gui.appliedenergistics2.Missing") + "]";
|
||||
tooltip.add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.implementations.GuiCraftingTerm;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import mezz.jei.api.gui.IGuiIngredient;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.gui.recipes.RecipeLayout;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static mezz.jei.api.recipe.transfer.IRecipeTransferError.Type.USER_FACING;
|
||||
|
||||
public class JEIMissingItem implements IRecipeTransferError {
|
||||
|
||||
private boolean errored;
|
||||
|
||||
JEIMissingItem(Container container, @Nonnull IRecipeLayout recipeLayout) {
|
||||
if (container instanceof ContainerCraftingTerm) {
|
||||
ContainerCraftingTerm craftingTerm = (ContainerCraftingTerm) container;
|
||||
GuiCraftingTerm g = (GuiCraftingTerm) craftingTerm.getGui();
|
||||
|
||||
IItemList<IAEItemStack> ir = g.getRepo().getList();
|
||||
boolean found;
|
||||
this.errored = false;
|
||||
recipeLayout.getItemStacks().addTooltipCallback(new CraftableCallBack(container, ir));
|
||||
|
||||
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
||||
found = false;
|
||||
if (i.isInput() && i.getAllIngredients().size() > 0) {
|
||||
List<?> allIngredients = i.getAllIngredients();
|
||||
for (Object allIngredient : allIngredients) {
|
||||
if (allIngredient instanceof ItemStack) {
|
||||
ItemStack stack = (ItemStack) allIngredient;
|
||||
if (!stack.isEmpty()) {
|
||||
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
||||
Collection<IAEItemStack> fuzzy = ir.findFuzzy(AEItemStack.fromItemStack(stack), FuzzyMode.IGNORE_ALL);
|
||||
if (fuzzy.size() > 0) {
|
||||
for (IAEItemStack itemStack : fuzzy) {
|
||||
if (itemStack.getStackSize() > 0) {
|
||||
if (itemStack.fuzzyComparison(AEItemStack.fromItemStack(stack), FuzzyMode.IGNORE_ALL)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IAEItemStack ext = ir.findPrecise(AEItemStack.fromItemStack(stack));
|
||||
if (ext != null) {
|
||||
IAEItemStack usedStack = used.findPrecise(ext);
|
||||
if (ext.getStackSize() > 0 && (usedStack == null || ext.getStackSize() > usedStack.getStackSize())) {
|
||||
used.add(ext.copy().setStackSize(1));
|
||||
found = true;
|
||||
} else {
|
||||
found = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
this.errored = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Type getType() {
|
||||
return USER_FACING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(Minecraft minecraft, int mouseX, int mouseY, @Nonnull IRecipeLayout recipeLayout, int recipeX, int recipeY) {
|
||||
Container c = minecraft.player.openContainer;
|
||||
if (c instanceof ContainerCraftingTerm) {
|
||||
ContainerCraftingTerm craftingTerm = (ContainerCraftingTerm) c;
|
||||
|
||||
GuiCraftingTerm g = (GuiCraftingTerm) craftingTerm.getGui();
|
||||
IItemList<IAEItemStack> ir = g.getRepo().getList();
|
||||
boolean found;
|
||||
boolean craftable;
|
||||
int currentSlot = 0;
|
||||
this.errored = false;
|
||||
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
|
||||
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
||||
found = false;
|
||||
craftable = false;
|
||||
List<ItemStack> valid = new ArrayList<>();
|
||||
if (i.isInput() && i.getAllIngredients().size() > 0) {
|
||||
List<?> allIngredients = i.getAllIngredients();
|
||||
for (Object allIngredient : allIngredients) {
|
||||
if (allIngredient instanceof ItemStack) {
|
||||
ItemStack stack = (ItemStack) allIngredient;
|
||||
if (!stack.isEmpty()) {
|
||||
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
||||
Collection<IAEItemStack> fuzzy = ir.findFuzzy(AEItemStack.fromItemStack(stack), FuzzyMode.IGNORE_ALL);
|
||||
if (fuzzy.size() > 0) {
|
||||
for (IAEItemStack itemStack : fuzzy) {
|
||||
if (itemStack.getStackSize() > 0) {
|
||||
if (itemStack.fuzzyComparison(AEItemStack.fromItemStack(stack), FuzzyMode.IGNORE_ALL)) {
|
||||
found = true;
|
||||
used.add(itemStack.copy().setStackSize(1));
|
||||
valid.addAll(fuzzy.stream().map(IAEItemStack::createItemStack).collect(Collectors.toList()));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (itemStack.isCraftable()) {
|
||||
craftable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IAEItemStack ext = ir.findPrecise(AEItemStack.fromItemStack(stack));
|
||||
if (ext != null) {
|
||||
IAEItemStack usedStack = used.findPrecise(ext);
|
||||
if (ext.getStackSize() > 0 && (usedStack == null || usedStack.getStackSize() < ext.getStackSize())) {
|
||||
used.add(ext.copy().setStackSize(1));
|
||||
if (craftable) {
|
||||
valid.clear();
|
||||
}
|
||||
valid.add(ext.copy().setStackSize(1).createItemStack());
|
||||
found = true;
|
||||
break;
|
||||
} else if (ext.isCraftable()) {
|
||||
valid.add(ext.copy().setStackSize(1).createItemStack());
|
||||
craftable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
if (craftable) {
|
||||
i.drawHighlight(minecraft, new Color(0.0f, 0.0f, 1.0f, 0.4f), recipeX, recipeY);
|
||||
recipeLayout.getItemStacks().set(currentSlot, valid);
|
||||
} else {
|
||||
i.drawHighlight(minecraft, new Color(1.0f, 0.0f, 0.0f, 0.4f), recipeX, recipeY);
|
||||
}
|
||||
this.errored = true;
|
||||
} else {
|
||||
recipeLayout.getItemStacks().set(currentSlot, valid);
|
||||
this.errored = false;
|
||||
}
|
||||
}
|
||||
currentSlot++;
|
||||
}
|
||||
if (!this.errored) {
|
||||
((RecipeLayout) recipeLayout).getRecipeTransferButton().init(Minecraft.getMinecraft().player.openContainer, Minecraft.getMinecraft().player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean errored() {
|
||||
return this.errored;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
@@ -40,6 +41,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -62,7 +64,7 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IRecipeTransferError transferRecipe(T container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
|
||||
public IRecipeTransferError transferRecipe(@Nonnull T container, IRecipeLayout recipeLayout, @Nonnull EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
|
||||
final String recipeType = recipeLayout.getRecipeCategory().getUid();
|
||||
|
||||
if (recipeType.equals(VanillaRecipeCategoryUid.INFORMATION) || recipeType.equals(VanillaRecipeCategoryUid.FUEL)) {
|
||||
@@ -70,6 +72,11 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
|
||||
}
|
||||
|
||||
if (!doTransfer) {
|
||||
if (container instanceof ContainerCraftingTerm && recipeType.equals(VanillaRecipeCategoryUid.CRAFTING)) {
|
||||
JEIMissingItem error = new JEIMissingItem(container, recipeLayout);
|
||||
if (error.errored())
|
||||
return error;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -639,9 +639,10 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
|
||||
itemList = new ArrayList<>(1);
|
||||
|
||||
final IAEItemStack item = this.inventory.getItemList().findPrecise(input[x]);
|
||||
|
||||
if (item != null) {
|
||||
itemList.add(item);
|
||||
} else if (input[x].getDefinition().getItem().isDamageable() || Platform.isGTDamageableItem(input[x].getDefinition().getItem())) {
|
||||
itemList.addAll(this.inventory.getItemList().findFuzzy(input[x], FuzzyMode.IGNORE_ALL));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
* @param from source of settings
|
||||
* @param compound compound of source
|
||||
*/
|
||||
private void uploadSettings(final SettingsFrom from, final NBTTagCompound compound) {
|
||||
public void uploadSettings(final SettingsFrom from, final NBTTagCompound compound, EntityPlayer player) {
|
||||
if (compound != null) {
|
||||
final IConfigManager cm = this.getConfigManager();
|
||||
if (cm != null) {
|
||||
@@ -359,7 +359,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
* @param from source of settings
|
||||
* @return compound of source
|
||||
*/
|
||||
private NBTTagCompound downloadSettings(final SettingsFrom from) {
|
||||
protected NBTTagCompound downloadSettings(final SettingsFrom from) {
|
||||
final NBTTagCompound output = new NBTTagCompound();
|
||||
|
||||
final IConfigManager cm = this.getConfigManager();
|
||||
@@ -428,7 +428,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
final String storedName = memoryCard.getSettingsName(memCardIS);
|
||||
final NBTTagCompound data = memoryCard.getData(memCardIS);
|
||||
if (name.equals(storedName)) {
|
||||
this.uploadSettings(SettingsFrom.MEMORY_CARD, data);
|
||||
this.uploadSettings(SettingsFrom.MEMORY_CARD, data, player);
|
||||
memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_LOADED);
|
||||
} else {
|
||||
memoryCard.notifyUser(player, MemoryCardMessages.INVALID_MACHINE);
|
||||
|
||||
@@ -113,4 +113,5 @@ public abstract class PartBasicState extends AEBasePart implements IPowerChannel
|
||||
private void setClientFlags(final int clientFlags) {
|
||||
this.clientFlags = clientFlags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.parts.misc;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
@@ -42,15 +43,19 @@ import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.inv.InvOperation;
|
||||
@@ -66,6 +71,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
@@ -275,4 +281,60 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
public GuiBridge getGuiBridge() {
|
||||
return GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound downloadSettings(SettingsFrom from) {
|
||||
NBTTagCompound output = super.downloadSettings(from);
|
||||
if (from == SettingsFrom.MEMORY_CARD) {
|
||||
final IItemHandler inv = this.getInventoryByName("patterns");
|
||||
if (inv instanceof AppEngInternalInventory) {
|
||||
((AppEngInternalInventory) inv).writeToNBT(output, "patterns");
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadSettings(SettingsFrom from, NBTTagCompound compound, EntityPlayer player) {
|
||||
super.uploadSettings(from, compound, player);
|
||||
final IItemHandler inv = this.getInventoryByName("patterns");
|
||||
if (inv instanceof AppEngInternalInventory) {
|
||||
final AppEngInternalInventory target = (AppEngInternalInventory) inv;
|
||||
AppEngInternalInventory tmp = new AppEngInternalInventory(null, target.getSlots());
|
||||
tmp.readFromNBT(compound, "patterns");
|
||||
PlayerMainInvWrapper playerInv = new PlayerMainInvWrapper(player.inventory);
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
int missingPatternsToEncode = 0;
|
||||
|
||||
for (int i = 0; i < inv.getSlots(); i++) {
|
||||
if (target.getStackInSlot(i).getItem() instanceof ItemEncodedPattern) {
|
||||
ItemStack blank = materials.blankPattern().maybeStack(target.getStackInSlot(i).getCount()).get();
|
||||
if (!player.addItemStackToInventory(blank)) {
|
||||
player.dropItem(blank, true);
|
||||
}
|
||||
target.setStackInSlot(i, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < tmp.getSlots(); x++) {
|
||||
if (!tmp.getStackInSlot(x).isEmpty()) {
|
||||
boolean found = false;
|
||||
for (int i = 0; i < playerInv.getSlots(); i++) {
|
||||
if (materials.blankPattern().isSameAs(playerInv.getStackInSlot(i))) {
|
||||
target.setStackInSlot(x, tmp.getStackInSlot(x));
|
||||
playerInv.getStackInSlot(i).shrink(1);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
missingPatternsToEncode++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Platform.isServer() && missingPatternsToEncode > 0) {
|
||||
player.sendMessage(PlayerMessages.MissingPatternsToEncode.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractPartEncoder extends AbstractPartTerminal {
|
||||
|
||||
protected AppEngInternalInventory crafting;
|
||||
protected AppEngInternalInventory output;
|
||||
protected AppEngInternalInventory pattern;
|
||||
|
||||
protected boolean craftingMode = true;
|
||||
protected boolean substitute = false;
|
||||
|
||||
public AbstractPartEncoder(ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
|
||||
for (final ItemStack is : this.pattern) {
|
||||
if (!is.isEmpty()) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
this.pattern.readFromNBT(data, "pattern");
|
||||
this.output.readFromNBT(data, "outputList");
|
||||
this.crafting.readFromNBT(data, "crafting");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
this.pattern.writeToNBT(data, "pattern");
|
||||
this.output.writeToNBT(data, "outputList");
|
||||
this.crafting.writeToNBT(data, "crafting");
|
||||
}
|
||||
|
||||
@Override
|
||||
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.getHost().getTile().getWorld());
|
||||
if (details != null) {
|
||||
this.setCraftingRecipe(details.isCraftable());
|
||||
this.setSubstitution(details.canSubstitute());
|
||||
|
||||
for (int x = 0; x < this.crafting.getSlots() && x < details.getInputs().length; x++) {
|
||||
final IAEItemStack item = details.getInputs()[x];
|
||||
this.crafting.setStackInSlot(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());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (inv == this.crafting) {
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
private void fixCraftingRecipes() {
|
||||
if (this.isCraftingRecipe()) {
|
||||
for (int x = 0; x < this.crafting.getSlots(); x++) {
|
||||
final ItemStack is = this.crafting.getStackInSlot(x);
|
||||
if (!is.isEmpty()) {
|
||||
is.setCount(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCraftingRecipe() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
public void setCraftingRecipe(final boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
|
||||
public boolean isSubstitution() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
public void setSubstitution(final boolean canSubstitute) {
|
||||
this.substitute = canSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName(final String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
if (name.equals("pattern")) {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
return super.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui(final EntityPlayer p) {
|
||||
int x = (int) p.posX;
|
||||
int y = (int) p.posY;
|
||||
int z = (int) p.posZ;
|
||||
if (this.getHost().getTile() != null) {
|
||||
x = this.getTile().getPos().getX();
|
||||
y = this.getTile().getPos().getY();
|
||||
z = this.getTile().getPos().getZ();
|
||||
}
|
||||
|
||||
if (getGuiBridge().hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
|
||||
return getGuiBridge();
|
||||
}
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
abstract public GuiBridge getGuiBridge();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
abstract public IPartModel getStaticModels();
|
||||
}
|
||||
@@ -1,29 +1,22 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static appeng.helpers.PatternHelper.PROCESSING_INPUT_LIMIT;
|
||||
import static appeng.helpers.PatternHelper.PROCESSING_OUTPUT_LIMIT;
|
||||
|
||||
|
||||
public class PartExpandedProcessingPatternTerminal extends AbstractPartTerminal {
|
||||
public class PartExpandedProcessingPatternTerminal extends AbstractPartEncoder {
|
||||
@PartModels
|
||||
public static final ResourceLocation MODEL_OFF = new ResourceLocation(AppEng.MOD_ID, "part/expanded_processing_pattern_terminal_off");
|
||||
@PartModels
|
||||
@@ -33,96 +26,31 @@ public class PartExpandedProcessingPatternTerminal extends AbstractPartTerminal
|
||||
public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_ON);
|
||||
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL);
|
||||
|
||||
private final AppEngInternalInventory crafting = new AppEngInternalInventory(this, PROCESSING_INPUT_LIMIT);
|
||||
|
||||
private final AppEngInternalInventory output = new AppEngInternalInventory(this, PROCESSING_OUTPUT_LIMIT);
|
||||
private final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
|
||||
|
||||
@Reflected
|
||||
public PartExpandedProcessingPatternTerminal(final ItemStack is) {
|
||||
super(is);
|
||||
this.crafting = new AppEngInternalInventory(this, PROCESSING_INPUT_LIMIT);
|
||||
this.output = new AppEngInternalInventory(this, PROCESSING_OUTPUT_LIMIT);
|
||||
this.pattern = new AppEngInternalInventory(this, 2);
|
||||
this.craftingMode = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
|
||||
for (final ItemStack is : this.pattern) {
|
||||
if (!is.isEmpty()) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
public boolean isCraftingRecipe() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
this.crafting.readFromNBT(data, "processingGrid");
|
||||
this.pattern.readFromNBT(data, "pattern");
|
||||
this.output.readFromNBT(data, "outputList");
|
||||
public void setCraftingRecipe(final boolean craftingMode) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
this.crafting.writeToNBT(data, "processingGrid");
|
||||
this.pattern.writeToNBT(data, "pattern");
|
||||
this.output.writeToNBT(data, "outputList");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui(final EntityPlayer p) {
|
||||
int x = (int) p.posX;
|
||||
int y = (int) p.posY;
|
||||
int z = (int) p.posZ;
|
||||
if (this.getHost().getTile() != null) {
|
||||
x = this.getTile().getPos().getX();
|
||||
y = this.getTile().getPos().getY();
|
||||
z = this.getTile().getPos().getZ();
|
||||
}
|
||||
|
||||
if (GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
|
||||
return GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL;
|
||||
}
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
@Override
|
||||
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.getHost().getTile().getWorld());
|
||||
if (details != null) {
|
||||
for (int x = 0; x < this.crafting.getSlots() && x < details.getInputs().length; x++) {
|
||||
final IAEItemStack item = details.getInputs()[x];
|
||||
this.crafting.setStackInSlot(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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName(final String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
if (name.equals("pattern")) {
|
||||
return this.pattern;
|
||||
}
|
||||
return super.getInventoryByName(name);
|
||||
public GuiBridge getGuiBridge() {
|
||||
return GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IPartModel getStaticModels() {
|
||||
return this.selectModel(MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL);
|
||||
|
||||
@@ -19,27 +19,24 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static appeng.helpers.PatternHelper.CRAFTING_GRID_DIMENSION;
|
||||
import static appeng.helpers.PatternHelper.CRAFTING_OUTPUT_LIMIT;
|
||||
|
||||
|
||||
public class PartPatternTerminal extends AbstractPartTerminal {
|
||||
public class PartPatternTerminal extends AbstractPartEncoder {
|
||||
|
||||
@PartModels
|
||||
public static final ResourceLocation MODEL_OFF = new ResourceLocation(AppEng.MOD_ID, "part/pattern_terminal_off");
|
||||
@@ -50,25 +47,12 @@ public class PartPatternTerminal extends AbstractPartTerminal {
|
||||
public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_ON);
|
||||
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL);
|
||||
|
||||
private final AppEngInternalInventory crafting = new AppEngInternalInventory(this, 9);
|
||||
private final AppEngInternalInventory output = new AppEngInternalInventory(this, 3);
|
||||
private final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
|
||||
|
||||
private boolean craftingMode = true;
|
||||
private boolean substitute = false;
|
||||
|
||||
@Reflected
|
||||
public PartPatternTerminal(final ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
|
||||
for (final ItemStack is : this.pattern) {
|
||||
if (!is.isEmpty()) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
this.crafting = new AppEngInternalInventory(this, CRAFTING_GRID_DIMENSION * CRAFTING_GRID_DIMENSION);
|
||||
this.output = new AppEngInternalInventory(this, 3);
|
||||
this.pattern = new AppEngInternalInventory(this, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,9 +60,6 @@ public class PartPatternTerminal extends AbstractPartTerminal {
|
||||
super.readFromNBT(data);
|
||||
this.setCraftingRecipe(data.getBoolean("craftingMode"));
|
||||
this.setSubstitution(data.getBoolean("substitute"));
|
||||
this.pattern.readFromNBT(data, "pattern");
|
||||
this.output.readFromNBT(data, "outputList");
|
||||
this.crafting.readFromNBT(data, "craftingGrid");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,102 +67,14 @@ public class PartPatternTerminal extends AbstractPartTerminal {
|
||||
super.writeToNBT(data);
|
||||
data.setBoolean("craftingMode", this.craftingMode);
|
||||
data.setBoolean("substitute", this.substitute);
|
||||
this.pattern.writeToNBT(data, "pattern");
|
||||
this.output.writeToNBT(data, "outputList");
|
||||
this.crafting.writeToNBT(data, "craftingGrid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui(final EntityPlayer p) {
|
||||
int x = (int) p.posX;
|
||||
int y = (int) p.posY;
|
||||
int z = (int) p.posZ;
|
||||
if (this.getHost().getTile() != null) {
|
||||
x = this.getTile().getPos().getX();
|
||||
y = this.getTile().getPos().getY();
|
||||
z = this.getTile().getPos().getZ();
|
||||
}
|
||||
|
||||
if (GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
|
||||
return GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
@Override
|
||||
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.getHost().getTile().getWorld());
|
||||
if (details != null) {
|
||||
this.setCraftingRecipe(details.isCraftable());
|
||||
this.setSubstitution(details.canSubstitute());
|
||||
|
||||
for (int x = 0; x < this.crafting.getSlots() && x < details.getInputs().length; x++) {
|
||||
final IAEItemStack item = details.getInputs()[x];
|
||||
this.crafting.setStackInSlot(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());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (inv == this.crafting) {
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
private void fixCraftingRecipes() {
|
||||
if (this.craftingMode) {
|
||||
for (int x = 0; x < this.crafting.getSlots(); x++) {
|
||||
final ItemStack is = this.crafting.getStackInSlot(x);
|
||||
if (!is.isEmpty()) {
|
||||
is.setCount(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCraftingRecipe() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
public void setCraftingRecipe(final boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
|
||||
public boolean isSubstitution() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
public void setSubstitution(final boolean canSubstitute) {
|
||||
this.substitute = canSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName(final String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
if (name.equals("pattern")) {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
return super.getInventoryByName(name);
|
||||
public GuiBridge getGuiBridge() {
|
||||
return GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IPartModel getStaticModels() {
|
||||
return this.selectModel(MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL);
|
||||
|
||||
@@ -38,6 +38,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
@@ -301,7 +302,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
|
||||
public void onPlacement(final ItemStack stack, final EntityPlayer player, final EnumFacing side) {
|
||||
if (stack.hasTagCompound()) {
|
||||
this.uploadSettings(SettingsFrom.DISMANTLE_ITEM, stack.getTagCompound());
|
||||
this.uploadSettings(SettingsFrom.DISMANTLE_ITEM, stack.getTagCompound(), player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +312,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
* @param from source of settings
|
||||
* @param compound compound of source
|
||||
*/
|
||||
public void uploadSettings(final SettingsFrom from, final NBTTagCompound compound) {
|
||||
public void uploadSettings(final SettingsFrom from, final NBTTagCompound compound, EntityPlayer player) {
|
||||
if (compound != null && this instanceof IConfigurableObject) {
|
||||
final IConfigManager cm = ((IConfigurableObject) this).getConfigManager();
|
||||
if (cm != null) {
|
||||
|
||||
@@ -52,6 +52,13 @@ public class AppEngInternalAEInventory implements IItemHandlerModifiable, Iterab
|
||||
this.inv = new IAEItemStack[s];
|
||||
}
|
||||
|
||||
public AppEngInternalAEInventory(final IAEAppEngInventory te, final int s, int stackSize) {
|
||||
this.te = te;
|
||||
this.size = s;
|
||||
this.maxStack = stackSize;
|
||||
this.inv = new IAEItemStack[s];
|
||||
}
|
||||
|
||||
public void setMaxStackSize(final int s) {
|
||||
this.maxStack = s;
|
||||
}
|
||||
@@ -216,7 +223,7 @@ public class AppEngInternalAEInventory implements IItemHandlerModifiable, Iterab
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
return this.maxStack > 64 ? 64 : this.maxStack;
|
||||
return this.maxStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,9 @@ import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -84,7 +87,38 @@ public class AppEngInternalInventory extends ItemStackHandler implements Iterabl
|
||||
if (!simulate) {
|
||||
this.previousStack = this.getStackInSlot(slot).copy();
|
||||
}
|
||||
return super.insertItem(slot, stack, simulate);
|
||||
|
||||
if (stack.isEmpty())
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
validateSlotIndex(slot);
|
||||
|
||||
ItemStack existing = this.stacks.get(slot);
|
||||
|
||||
int limit = maxStack[slot];
|
||||
|
||||
if (!existing.isEmpty()) {
|
||||
if (!ItemHandlerHelper.canItemStacksStack(stack, existing))
|
||||
return stack;
|
||||
|
||||
limit -= existing.getCount();
|
||||
}
|
||||
|
||||
if (limit <= 0)
|
||||
return stack;
|
||||
|
||||
boolean reachedLimit = stack.getCount() > limit;
|
||||
|
||||
if (!simulate) {
|
||||
if (existing.isEmpty()) {
|
||||
this.stacks.set(slot, reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack);
|
||||
} else {
|
||||
existing.grow(reachedLimit ? limit : stack.getCount());
|
||||
}
|
||||
onContentsChanged(slot);
|
||||
}
|
||||
|
||||
return reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - limit) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,7 +131,30 @@ public class AppEngInternalInventory extends ItemStackHandler implements Iterabl
|
||||
if (!simulate) {
|
||||
this.previousStack = this.getStackInSlot(slot).copy();
|
||||
}
|
||||
return super.extractItem(slot, amount, simulate);
|
||||
if (amount == 0)
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
validateSlotIndex(slot);
|
||||
|
||||
ItemStack existing = this.stacks.get(slot);
|
||||
|
||||
if (existing.isEmpty())
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
if (existing.getCount() <= amount) {
|
||||
if (!simulate) {
|
||||
this.stacks.set(slot, ItemStack.EMPTY);
|
||||
onContentsChanged(slot);
|
||||
}
|
||||
return existing;
|
||||
} else {
|
||||
if (!simulate) {
|
||||
this.stacks.set(slot, ItemHandlerHelper.copyStackWithSize(existing, existing.getCount() - amount));
|
||||
onContentsChanged(slot);
|
||||
}
|
||||
|
||||
return ItemHandlerHelper.copyStackWithSize(existing, amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,6 +209,27 @@ public class AppEngInternalInventory extends ItemStackHandler implements Iterabl
|
||||
data.setTag(name, this.serializeNBT());
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serializeNBT() {
|
||||
NBTTagList nbtTagList = new NBTTagList();
|
||||
for (int i = 0; i < stacks.size(); i++) {
|
||||
ItemStack is = stacks.get(i);
|
||||
if (!is.isEmpty()) {
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
itemTag.setInteger("Slot", i);
|
||||
if (is.getCount() > is.getMaxStackSize()) {
|
||||
itemTag.setInteger("stackSize", stacks.get(i).getCount());
|
||||
}
|
||||
stacks.get(i).writeToNBT(itemTag);
|
||||
nbtTagList.appendTag(itemTag);
|
||||
}
|
||||
}
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setTag("Items", nbtTagList);
|
||||
nbt.setInteger("Size", stacks.size());
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void readFromNBT(final NBTTagCompound data, final String name) {
|
||||
final NBTTagCompound c = data.getCompoundTag(name);
|
||||
if (c != null) {
|
||||
@@ -163,6 +241,24 @@ public class AppEngInternalInventory extends ItemStackHandler implements Iterabl
|
||||
this.deserializeNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(NBTTagCompound nbt) {
|
||||
setSize(nbt.hasKey("Size", Constants.NBT.TAG_INT) ? nbt.getInteger("Size") : stacks.size());
|
||||
NBTTagList tagList = nbt.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
NBTTagCompound itemTags = tagList.getCompoundTagAt(i);
|
||||
int slot = itemTags.getInteger("Slot");
|
||||
if (slot >= 0 && slot < stacks.size()) {
|
||||
stacks.set(slot, new ItemStack(itemTags));
|
||||
if (itemTags.hasKey("stackSize")) {
|
||||
int stackSize = itemTags.getInteger("stackSize");
|
||||
stacks.get(slot).setCount(stackSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
onLoad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ItemStack> iterator() {
|
||||
return Collections.unmodifiableList(super.stacks).iterator();
|
||||
|
||||
@@ -22,6 +22,8 @@ package appeng.tile.misc;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
@@ -37,16 +39,23 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -56,6 +65,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
|
||||
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
@@ -308,4 +319,61 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, II
|
||||
public GuiBridge getGuiBridge() {
|
||||
return GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound downloadSettings(SettingsFrom from) {
|
||||
NBTTagCompound output = super.downloadSettings(from);
|
||||
if (from == SettingsFrom.MEMORY_CARD) {
|
||||
final IItemHandler inv = this.getInventoryByName("patterns");
|
||||
if (inv instanceof AppEngInternalInventory) {
|
||||
((AppEngInternalInventory) inv).writeToNBT(output, "patterns");
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadSettings(SettingsFrom from, NBTTagCompound compound, EntityPlayer player) {
|
||||
super.uploadSettings(from, compound, player);
|
||||
final IItemHandler inv = this.getInventoryByName("patterns");
|
||||
if (inv instanceof AppEngInternalInventory) {
|
||||
final AppEngInternalInventory target = (AppEngInternalInventory) inv;
|
||||
AppEngInternalInventory tmp = new AppEngInternalInventory(null, target.getSlots());
|
||||
tmp.readFromNBT(compound, "patterns");
|
||||
PlayerMainInvWrapper playerInv = new PlayerMainInvWrapper(player.inventory);
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
int missingPatternsToEncode = 0;
|
||||
|
||||
for (int i = 0; i < inv.getSlots(); i++) {
|
||||
if (target.getStackInSlot(i).getItem() instanceof ItemEncodedPattern) {
|
||||
ItemStack blank = materials.blankPattern().maybeStack(target.getStackInSlot(i).getCount()).get();
|
||||
if (!player.addItemStackToInventory(blank)) {
|
||||
player.dropItem(blank, true);
|
||||
}
|
||||
target.setStackInSlot(i, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int x = 0; x < tmp.getSlots(); x++) {
|
||||
if (!tmp.getStackInSlot(x).isEmpty()) {
|
||||
boolean found = false;
|
||||
for (int i = 0; i < playerInv.getSlots(); i++) {
|
||||
if (materials.blankPattern().isSameAs(playerInv.getStackInSlot(i))) {
|
||||
target.setStackInSlot(x, tmp.getStackInSlot(x));
|
||||
playerInv.getStackInSlot(i).shrink(1);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
missingPatternsToEncode++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Platform.isServer() && missingPatternsToEncode > 0) {
|
||||
player.sendMessage(PlayerMessages.MissingPatternsToEncode.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import appeng.block.networking.BlockEnergyCell;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.SettingsFrom;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
||||
@@ -106,7 +107,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadSettings(final SettingsFrom from, final NBTTagCompound compound) {
|
||||
public void uploadSettings(final SettingsFrom from, final NBTTagCompound compound, EntityPlayer player) {
|
||||
if (from == SettingsFrom.DISMANTLE_ITEM) {
|
||||
this.internalCurrentPower = compound.getDouble("internalCurrentPower");
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ tile.appliedenergistics2.sky_stone_slab.name=Sky Stone Slabs
|
||||
// Chat Messages
|
||||
chat.appliedenergistics2.ChestCannotReadStorageCell=ME Chest cannot read storage cell.
|
||||
chat.appliedenergistics2.SettingCleared=Memory card cleared.
|
||||
chat.appliedenergistics2.MissingPatternsToEncode=Not enough patterns to finish copying
|
||||
chat.appliedenergistics2.OutOfRange=Wireless Out Of Range.
|
||||
chat.appliedenergistics2.InvalidMachine=Invalid Machine.
|
||||
chat.appliedenergistics2.LoadedSettings=Loaded device configuration from memory card.
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 14 KiB |
Reference in New Issue
Block a user