Updated the Filtered Item Routing Nodes' GUI so that it behaved less like ass. Also added the necessary nbt porting code.
This commit is contained in:
parent
7d690ad598
commit
413b150142
|
@ -6,6 +6,8 @@ Version 2.0.4-57
|
|||
- Fixed Elytra upgrade
|
||||
- Added the Mimics - the real ones
|
||||
- Implemented a bit of framework for some T5 shenanigans.
|
||||
- Fixed the Incense Altar so it properly detected the south sides of the altar.
|
||||
- Updated the Filtered Item Routing Nodes' GUI so that it behaved less like ass. Also added the necessary nbt porting code.
|
||||
|
||||
------------------------------------------------------
|
||||
Version 2.0.4-56
|
||||
|
|
|
@ -83,6 +83,7 @@ public class GuiItemRoutingNode extends GuiContainer
|
|||
BloodMagicPacketHandler.INSTANCE.sendToServer(new ItemRouterButtonPacketProcessor(button.id, inventory.getPos(), inventory.getWorld()));
|
||||
if (button.id < 6)
|
||||
{
|
||||
inventory.currentActiveSlot = button.id;
|
||||
enableAllDirectionalButtons();
|
||||
button.enabled = false;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import WayofTime.bloodmagic.util.helper.TextHelper;
|
|||
public class TileInventory extends TileEntity implements IInventory
|
||||
{
|
||||
protected int[] syncedSlots = new int[0];
|
||||
private ItemStack[] inventory;
|
||||
protected ItemStack[] inventory;
|
||||
private int size;
|
||||
private String name;
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class TileInventory extends TileEntity implements IInventory
|
|||
initializeItemHandlers();
|
||||
}
|
||||
|
||||
private boolean isSyncedSlot(int slot)
|
||||
protected boolean isSyncedSlot(int slot)
|
||||
{
|
||||
for (int s : this.syncedSlots)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package WayofTime.bloodmagic.tile.container;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import WayofTime.bloodmagic.item.inventory.ItemInventory;
|
||||
import WayofTime.bloodmagic.item.routing.IItemFilterProvider;
|
||||
import WayofTime.bloodmagic.tile.routing.TileFilteredRoutingNode;
|
||||
import WayofTime.bloodmagic.util.GhostItemHelper;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -18,12 +21,15 @@ public class ContainerItemRoutingNode extends Container
|
|||
private final ItemInventory itemInventory;
|
||||
private int slotsOccupied;
|
||||
|
||||
private final TileFilteredRoutingNode inventory;
|
||||
|
||||
public ContainerItemRoutingNode(InventoryPlayer inventoryPlayer, IInventory tileItemRoutingNode)
|
||||
{
|
||||
this.tileItemRoutingNode = tileItemRoutingNode;
|
||||
inventory = (TileFilteredRoutingNode) tileItemRoutingNode;
|
||||
|
||||
this.addSlotToContainer(new SlotItemFilter(this, tileItemRoutingNode, 0, 8, 33));
|
||||
ItemStack masterStack = tileItemRoutingNode.getStackInSlot(0);
|
||||
ItemStack masterStack = tileItemRoutingNode.getStackInSlot(inventory.currentActiveSlot);
|
||||
itemInventory = new ItemInventory(masterStack, 9, "");
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
|
@ -211,11 +217,13 @@ public class ContainerItemRoutingNode extends Container
|
|||
private class SlotItemFilter extends Slot
|
||||
{
|
||||
public ContainerItemRoutingNode container;
|
||||
public TileFilteredRoutingNode inventory;
|
||||
|
||||
public SlotItemFilter(ContainerItemRoutingNode container, IInventory inventory, int slotIndex, int x, int y)
|
||||
{
|
||||
super(inventory, slotIndex, x, y);
|
||||
this.container = container;
|
||||
this.inventory = (TileFilteredRoutingNode) inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -235,6 +243,30 @@ public class ContainerItemRoutingNode extends Container
|
|||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
return this.inventory.getStackInSlot(getActiveSlot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(@Nullable ItemStack stack)
|
||||
{
|
||||
this.inventory.setInventorySlotContents(getActiveSlot(), stack);
|
||||
this.onSlotChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int amount)
|
||||
{
|
||||
return this.inventory.decrStackSize(getActiveSlot(), amount);
|
||||
}
|
||||
|
||||
public int getActiveSlot()
|
||||
{
|
||||
return inventory.currentActiveSlot;
|
||||
}
|
||||
}
|
||||
|
||||
private class SlotGhostItem extends Slot
|
||||
|
|
|
@ -4,6 +4,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
|
||||
|
@ -20,13 +21,8 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn
|
|||
public ItemStack getFilterStack(EnumFacing side)
|
||||
{
|
||||
int index = side.getIndex();
|
||||
if (currentActiveSlot == index)
|
||||
{
|
||||
return getStackInSlot(0);
|
||||
} else
|
||||
{
|
||||
return getStackInSlot(index + 1);
|
||||
}
|
||||
|
||||
return getStackInSlot(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,6 +41,28 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn
|
|||
{
|
||||
priorities = new int[6];
|
||||
}
|
||||
|
||||
if (!tag.getBoolean("updated"))
|
||||
{
|
||||
NBTTagList tags = tag.getTagList("Items", 10);
|
||||
inventory = new ItemStack[getSizeInventory()];
|
||||
for (int i = 0; i < tags.tagCount(); i++)
|
||||
{
|
||||
if (!isSyncedSlot(i))
|
||||
{
|
||||
NBTTagCompound data = tags.getCompoundTagAt(i);
|
||||
byte j = data.getByte("Slot");
|
||||
|
||||
if (j == 0)
|
||||
{
|
||||
inventory[currentActiveSlot] = ItemStack.loadItemStackFromNBT(data);
|
||||
} else if (j >= 1 && j < inventory.length + 1)
|
||||
{
|
||||
inventory[j - 1] = ItemStack.loadItemStackFromNBT(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,14 +71,12 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn
|
|||
super.writeToNBT(tag);
|
||||
tag.setInteger("currentSlot", currentActiveSlot);
|
||||
tag.setIntArray(Constants.NBT.ROUTING_PRIORITY, priorities);
|
||||
tag.setBoolean("updated", true);
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void swapFilters(int requestedSlot)
|
||||
{
|
||||
this.setInventorySlotContents(currentActiveSlot + 1, this.getStackInSlot(0));
|
||||
this.setInventorySlotContents(0, this.getStackInSlot(requestedSlot + 1));
|
||||
this.setInventorySlotContents(requestedSlot + 1, null);
|
||||
currentActiveSlot = requestedSlot;
|
||||
this.markDirty();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue