fix #2883, #2882, packager GUI issues

This commit is contained in:
Adrian 2015-07-12 15:40:28 +02:00
parent 45384e0a53
commit 7c5d4b0d42
4 changed files with 24 additions and 81 deletions

View file

@ -20,12 +20,10 @@ import buildcraft.BuildCraftSilicon;
import buildcraft.api.core.BCLog;
import buildcraft.api.core.IInvSlot;
import buildcraft.core.lib.block.TileBuildCraft;
import buildcraft.core.lib.inventory.InventoryConcatenator;
import buildcraft.core.lib.inventory.InventoryIterator;
import buildcraft.core.lib.inventory.SimpleInventory;
import buildcraft.core.lib.inventory.StackHelper;
import buildcraft.core.lib.utils.NBTUtils;
import buildcraft.core.lib.utils.Utils;
public class TilePackager extends TileBuildCraft implements ISidedInventory {
private class Requirement {
@ -65,11 +63,12 @@ public class TilePackager extends TileBuildCraft implements ISidedInventory {
return location.hashCode() + (slot * 17);
}
}
private static final int[] SLOTS = Utils.createSlotArray(0, 12);
// Slot 10 is currently missing. Left in for backwards compat.
private static final int[] SLOTS = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11};
public SimpleInventory inventoryPublic = new SimpleInventory(12, "Packager", 64);
public SimpleInventory inventoryPattern = new SimpleInventory(9, "Packager", 64);
public IInventory visibleInventory = InventoryConcatenator.make().add(inventoryPublic).add(inventoryPattern);
private Requirement[] requirements = new Requirement[9];
private int patternsSet;
@ -406,27 +405,27 @@ public class TilePackager extends TileBuildCraft implements ISidedInventory {
@Override
public int getSizeInventory() {
return visibleInventory.getSizeInventory();
return inventoryPublic.getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int slot) {
return visibleInventory.getStackInSlot(slot);
return inventoryPublic.getStackInSlot(slot);
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
return visibleInventory.decrStackSize(slot, amount);
return inventoryPublic.decrStackSize(slot, amount);
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return visibleInventory.getStackInSlotOnClosing(slot);
return inventoryPublic.getStackInSlotOnClosing(slot);
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
visibleInventory.setInventorySlotContents(slot, stack);
inventoryPublic.setInventorySlotContents(slot, stack);
}
@Override
@ -446,17 +445,17 @@ public class TilePackager extends TileBuildCraft implements ISidedInventory {
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return visibleInventory.isUseableByPlayer(player);
return inventoryPublic.isUseableByPlayer(player);
}
@Override
public void openInventory() {
visibleInventory.openInventory();
inventoryPublic.openInventory();
}
@Override
public void closeInventory() {
visibleInventory.closeInventory();
inventoryPublic.closeInventory();
}
@Override
@ -464,7 +463,7 @@ public class TilePackager extends TileBuildCraft implements ISidedInventory {
if (slot == 9) {
return stack == null || stack.getItem() == Items.paper || stack.getItem() instanceof ItemPackage;
}
return visibleInventory.isItemValidForSlot(slot, stack);
return inventoryPublic.isItemValidForSlot(slot, stack);
}
@Override

View file

@ -10,7 +10,6 @@ package buildcraft.silicon.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
@ -21,7 +20,6 @@ import buildcraft.silicon.TilePackager;
public class ContainerPackager extends BuildCraftContainer {
private final TilePackager tile;
// private int lastProgress;
public ContainerPackager(InventoryPlayer inventoryplayer, TilePackager t) {
super(t.getSizeInventory());
@ -38,14 +36,13 @@ public class ContainerPackager extends BuildCraftContainer {
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
addSlotToContainer(new SlotPackager(tile, 12 + x + y * 3, 30 + x * 18, 17 + y * 18));
addSlotToContainer(new SlotPackager(tile.inventoryPattern, x + y * 3, 30 + x * 18, 17 + y * 18));
}
}
// addSlotToContainer(new Slot(tile, 10, 108, 31));
addSlotToContainer(new SlotOutput(tile, 11, 123, 59));
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 9; x++) {
addSlotToContainer(new Slot(inventoryplayer, x + y * 9 + 9, 8 + x * 18, 115 + y * 18));
@ -59,48 +56,13 @@ public class ContainerPackager extends BuildCraftContainer {
onCraftMatrixChanged(tile);
}
@Override
public void addCraftingToCrafters(ICrafting icrafting) {
super.addCraftingToCrafters(icrafting);
//icrafting.sendProgressBarUpdate(this, 0, tile.progress);
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
/*for (int i = 0; i < crafters.size(); i++) {
ICrafting icrafting = (ICrafting) crafters.get(i);
if (lastProgress != tile.progress) {
icrafting.sendProgressBarUpdate(this, 0, tile.progress);
}
}
ItemStack output = craftResult.getStackInSlot(0);
if (output != prevOutput) {
prevOutput = output;
onCraftMatrixChanged(tile.craftMatrix);
}
lastProgress = tile.progress;*/
}
@Override
public void updateProgressBar(int id, int data) {
/*switch (id) {
case 0:
tile.progress = data;
break;
}*/
}
@Override
public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) {
ItemStack out = super.slotClick(slotNum, mouseButton, modifier, player);
Slot slot = slotNum < 0 ? null : (Slot) this.inventorySlots.get(slotNum);
ItemStack out = super.slotClick(slotNum, mouseButton, slot instanceof SlotPackager ? 0 : modifier, player);
if (slot instanceof SlotPackager) {
int idx = slot.getSlotIndex() - 12;
int idx = slot.getSlotIndex();
ItemStack stack = player != null && player.inventory != null ? player.inventory.getItemStack() : null;
if (stack == null) {
tile.setPatternSlot(idx, !tile.isPatternSlotSet(idx));

View file

@ -46,9 +46,5 @@ public class GuiPackager extends GuiBuildCraft {
}
}
}
/*if (bench.progress > 0) {
int progress = bench.getProgressScaled(23);
drawTexturedModalRect(guiLeft + 89, guiTop + 45, 176, 0, progress + 1, 12);
}*/
}
}

View file

@ -13,10 +13,8 @@ import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import buildcraft.api.gates.IGate;
import buildcraft.api.statements.IStatementContainer;
@ -95,30 +93,18 @@ public class TriggerPipeContents extends BCStatement implements ITriggerInternal
} else if (pipe.transport instanceof PipeTransportFluids) {
PipeTransportFluids transportFluids = (PipeTransportFluids) pipe.transport;
FluidStack searchedFluid = null;
if (parameter != null && parameter.getItemStack() != null) {
searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack());
}
if (kind == PipeContents.empty) {
for (FluidTankInfo b : transportFluids.getTankInfo(ForgeDirection.UNKNOWN)) {
if (b.fluid != null && b.fluid.amount != 0) {
return false;
}
}
return true;
return transportFluids.fluidType == null;
} else {
for (FluidTankInfo b : transportFluids.getTankInfo(ForgeDirection.UNKNOWN)) {
if (b.fluid != null && b.fluid.amount != 0) {
if (searchedFluid == null || searchedFluid.isFluidEqual(b.fluid)) {
return true;
}
}
}
if (parameter != null && parameter.getItemStack() != null) {
FluidStack searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack());
return false;
if (searchedFluid != null) {
return transportFluids.fluidType != null && searchedFluid.isFluidEqual(transportFluids.fluidType);
}
} else {
return transportFluids.fluidType != null;
}
}
} else if (pipe.transport instanceof PipeTransportPower) {
PipeTransportPower transportPower = (PipeTransportPower) pipe.transport;