Implemented ghost items for the inventory - will be adjusted.
This commit is contained in:
parent
ec7676a69c
commit
ac919c7882
|
@ -91,6 +91,8 @@ public class Constants
|
||||||
public static final String ROUTING_MASTER_GENERAL = "generalList";
|
public static final String ROUTING_MASTER_GENERAL = "generalList";
|
||||||
public static final String ROUTING_MASTER_INPUT = "inputList";
|
public static final String ROUTING_MASTER_INPUT = "inputList";
|
||||||
public static final String ROUTING_MASTER_OUTPUT = "outputList";
|
public static final String ROUTING_MASTER_OUTPUT = "outputList";
|
||||||
|
|
||||||
|
public static final String GHOST_STACK_SIZE = "stackSize";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Mod
|
public static class Mod
|
||||||
|
@ -106,6 +108,7 @@ public class Constants
|
||||||
{
|
{
|
||||||
public static final int TELEPOSER_GUI = 0;
|
public static final int TELEPOSER_GUI = 0;
|
||||||
public static final int SOUL_FORGE_GUI = 1;
|
public static final int SOUL_FORGE_GUI = 1;
|
||||||
|
public static final int ROUTING_NODE_GUI = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Compat
|
public static class Compat
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package WayofTime.bloodmagic.block;
|
package WayofTime.bloodmagic.block;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -12,10 +10,8 @@ import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
import WayofTime.bloodmagic.routing.IMasterRoutingNode;
|
|
||||||
import WayofTime.bloodmagic.routing.IRoutingNode;
|
import WayofTime.bloodmagic.routing.IRoutingNode;
|
||||||
import WayofTime.bloodmagic.tile.routing.TileOutputRoutingNode;
|
import WayofTime.bloodmagic.tile.routing.TileOutputRoutingNode;
|
||||||
import WayofTime.bloodmagic.util.ChatUtil;
|
|
||||||
|
|
||||||
public class BlockOutputRoutingNode extends BlockContainer
|
public class BlockOutputRoutingNode extends BlockContainer
|
||||||
{
|
{
|
||||||
|
@ -57,30 +53,37 @@ public class BlockOutputRoutingNode extends BlockContainer
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
if (world.isRemote)
|
if (world.getTileEntity(pos) instanceof TileOutputRoutingNode)
|
||||||
{
|
{
|
||||||
return false;
|
player.openGui(BloodMagic.instance, Constants.Gui.ROUTING_NODE_GUI, world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
return true;
|
||||||
IRoutingNode node = (IRoutingNode) tile;
|
|
||||||
ChatUtil.sendChat(player, "Master: " + node.getMasterPos().toString());
|
|
||||||
for (BlockPos connPos : node.getConnected())
|
|
||||||
{
|
|
||||||
ChatUtil.sendChat(player, "Connected to: " + connPos.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockPos masterPos = node.getMasterPos();
|
// if (world.isRemote)
|
||||||
TileEntity testTile = world.getTileEntity(masterPos);
|
// {
|
||||||
if (testTile instanceof IMasterRoutingNode)
|
// return false;
|
||||||
{
|
// }
|
||||||
IMasterRoutingNode master = (IMasterRoutingNode) testTile;
|
//
|
||||||
if (master.isConnected(new LinkedList<BlockPos>(), pos))
|
// TileEntity tile = world.getTileEntity(pos);
|
||||||
{
|
// IRoutingNode node = (IRoutingNode) tile;
|
||||||
ChatUtil.sendChat(player, "Can find the path to the master");
|
// ChatUtil.sendChat(player, "Master: " + node.getMasterPos().toString());
|
||||||
}
|
// for (BlockPos connPos : node.getConnected())
|
||||||
}
|
// {
|
||||||
|
// ChatUtil.sendChat(player, "Connected to: " + connPos.toString());
|
||||||
return false;
|
// }
|
||||||
|
//
|
||||||
|
// BlockPos masterPos = node.getMasterPos();
|
||||||
|
// TileEntity testTile = world.getTileEntity(masterPos);
|
||||||
|
// if (testTile instanceof IMasterRoutingNode)
|
||||||
|
// {
|
||||||
|
// IMasterRoutingNode master = (IMasterRoutingNode) testTile;
|
||||||
|
// if (master.isConnected(new LinkedList<BlockPos>(), pos))
|
||||||
|
// {
|
||||||
|
// ChatUtil.sendChat(player, "Can find the path to the master");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,10 @@ import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
import WayofTime.bloodmagic.tile.TileSoulForge;
|
import WayofTime.bloodmagic.tile.TileSoulForge;
|
||||||
import WayofTime.bloodmagic.tile.TileTeleposer;
|
import WayofTime.bloodmagic.tile.TileTeleposer;
|
||||||
|
import WayofTime.bloodmagic.tile.container.ContainerItemRoutingNode;
|
||||||
import WayofTime.bloodmagic.tile.container.ContainerSoulForge;
|
import WayofTime.bloodmagic.tile.container.ContainerSoulForge;
|
||||||
import WayofTime.bloodmagic.tile.container.ContainerTeleposer;
|
import WayofTime.bloodmagic.tile.container.ContainerTeleposer;
|
||||||
|
import WayofTime.bloodmagic.tile.routing.TileOutputRoutingNode;
|
||||||
|
|
||||||
public class GuiHandler implements IGuiHandler
|
public class GuiHandler implements IGuiHandler
|
||||||
{
|
{
|
||||||
|
@ -24,6 +26,8 @@ public class GuiHandler implements IGuiHandler
|
||||||
return new ContainerTeleposer(player.inventory, (TileTeleposer) world.getTileEntity(pos));
|
return new ContainerTeleposer(player.inventory, (TileTeleposer) world.getTileEntity(pos));
|
||||||
case Constants.Gui.SOUL_FORGE_GUI:
|
case Constants.Gui.SOUL_FORGE_GUI:
|
||||||
return new ContainerSoulForge(player.inventory, (TileSoulForge) world.getTileEntity(pos));
|
return new ContainerSoulForge(player.inventory, (TileSoulForge) world.getTileEntity(pos));
|
||||||
|
case Constants.Gui.ROUTING_NODE_GUI:
|
||||||
|
return new ContainerItemRoutingNode(player.inventory, (TileOutputRoutingNode) world.getTileEntity(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -42,6 +46,8 @@ public class GuiHandler implements IGuiHandler
|
||||||
return new GuiTeleposer(player.inventory, (TileTeleposer) world.getTileEntity(pos));
|
return new GuiTeleposer(player.inventory, (TileTeleposer) world.getTileEntity(pos));
|
||||||
case Constants.Gui.SOUL_FORGE_GUI:
|
case Constants.Gui.SOUL_FORGE_GUI:
|
||||||
return new GuiSoulForge(player.inventory, (TileSoulForge) world.getTileEntity(pos));
|
return new GuiSoulForge(player.inventory, (TileSoulForge) world.getTileEntity(pos));
|
||||||
|
case Constants.Gui.ROUTING_NODE_GUI:
|
||||||
|
return new GuiItemRoutingNode(player.inventory, (TileOutputRoutingNode) world.getTileEntity(pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package WayofTime.bloodmagic.client.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
import WayofTime.bloodmagic.tile.container.ContainerItemRoutingNode;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class GuiItemRoutingNode extends GuiContainer
|
||||||
|
{
|
||||||
|
public GuiItemRoutingNode(InventoryPlayer playerInventory, IInventory tileRoutingNode)
|
||||||
|
{
|
||||||
|
super(new ContainerItemRoutingNode(playerInventory, tileRoutingNode));
|
||||||
|
this.xSize = 176;
|
||||||
|
this.ySize = 169;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
// this.fontRendererObj.drawString(TextHelper.localize("tile.BloodMagic.soulForge.name"), 8, 5, 4210752);
|
||||||
|
// this.fontRendererObj.drawString(TextHelper.localize("container.inventory"), 8, 111, 4210752);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
ResourceLocation soulForgeGuiTextures = new ResourceLocation(Constants.Mod.MODID + ":textures/gui/routingNode.png");
|
||||||
|
this.mc.getTextureManager().bindTexture(soulForgeGuiTextures);
|
||||||
|
int i = (this.width - this.xSize) / 2;
|
||||||
|
int j = (this.height - this.ySize) / 2;
|
||||||
|
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,14 +3,11 @@ package WayofTime.bloodmagic.routing;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.util.ITickable;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
@ -30,36 +27,36 @@ public class TileMasterRoutingNode extends TileEntity implements IMasterRoutingN
|
||||||
@Override
|
@Override
|
||||||
public void update()
|
public void update()
|
||||||
{
|
{
|
||||||
if (worldObj.isRemote || worldObj.getTotalWorldTime() % tickRate != 0) //Temporary tick rate solver
|
// if (worldObj.isRemote || worldObj.getTotalWorldTime() % tickRate != 0) //Temporary tick rate solver
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Map<Integer, List<IItemFilter>> outputMap = new HashMap<Integer, List<IItemFilter>>();
|
// Map<Integer, List<IItemFilter>> outputMap = new HashMap<Integer, List<IItemFilter>>();
|
||||||
|
//
|
||||||
for (BlockPos outputPos : outputNodeList)
|
// for (BlockPos outputPos : outputNodeList)
|
||||||
{
|
// {
|
||||||
TileEntity outputTile = worldObj.getTileEntity(outputPos);
|
// TileEntity outputTile = worldObj.getTileEntity(outputPos);
|
||||||
if (outputTile instanceof TileOutputRoutingNode && this.isConnected(new LinkedList<BlockPos>(), outputPos))
|
// if (outputTile instanceof TileOutputRoutingNode && this.isConnected(new LinkedList<BlockPos>(), outputPos))
|
||||||
{
|
// {
|
||||||
TileOutputRoutingNode outputNode = (TileOutputRoutingNode) outputTile;
|
// TileOutputRoutingNode outputNode = (TileOutputRoutingNode) outputTile;
|
||||||
|
//
|
||||||
for (EnumFacing facing : EnumFacing.VALUES)
|
// for (EnumFacing facing : EnumFacing.VALUES)
|
||||||
{
|
// {
|
||||||
if (!outputNode.isInventoryConnectedToSide(facing))
|
// if (!outputNode.isInventoryConnectedToSide(facing))
|
||||||
{
|
// {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
TileEntity tile = worldObj.getTileEntity(outputPos.offset(facing));
|
// TileEntity tile = worldObj.getTileEntity(outputPos.offset(facing));
|
||||||
if (!(tile instanceof IInventory))
|
// if (!(tile instanceof IInventory))
|
||||||
{
|
// {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,226 @@
|
||||||
|
package WayofTime.bloodmagic.tile.container;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.util.GhostItemHelper;
|
||||||
|
import WayofTime.bloodmagic.util.Utils;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class ContainerItemRoutingNode extends Container
|
||||||
|
{
|
||||||
|
private final IInventory tileItemRoutingNode;
|
||||||
|
private int slotsOccupied;
|
||||||
|
|
||||||
|
public ContainerItemRoutingNode(InventoryPlayer inventoryPlayer, IInventory tileItemRoutingNode)
|
||||||
|
{
|
||||||
|
this.tileItemRoutingNode = tileItemRoutingNode;
|
||||||
|
// this.addSlotToContainer(new Slot(tileItemRoutingNode, 0, 8, 15));
|
||||||
|
// this.addSlotToContainer(new Slot(tileItemRoutingNode, 1, 80, 15));
|
||||||
|
// this.addSlotToContainer(new Slot(tileItemRoutingNode, 2, 80, 87));
|
||||||
|
// this.addSlotToContainer(new Slot(tileItemRoutingNode, 3, 8, 87));
|
||||||
|
this.addSlotToContainer(new SlotGhostItem(tileItemRoutingNode, 0, 8, 33));
|
||||||
|
slotsOccupied = 1;
|
||||||
|
// this.addSlotToContainer(new SlotOutput(tileItemRoutingNode, TileSoulForge.outputSlot, 44, 51));
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 9; j++)
|
||||||
|
{
|
||||||
|
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 87 + i * 18));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 9; i++)
|
||||||
|
{
|
||||||
|
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 145));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridden in order to handle ghost item slots.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player)
|
||||||
|
{
|
||||||
|
InventoryPlayer inventoryPlayer = player.inventory;
|
||||||
|
if (!player.worldObj.isRemote)
|
||||||
|
{
|
||||||
|
if (slotId >= 0)
|
||||||
|
{
|
||||||
|
Slot slot = (Slot) this.inventorySlots.get(slotId);
|
||||||
|
|
||||||
|
if (slot instanceof SlotGhostItem) //TODO: make the slot clicking work!
|
||||||
|
{
|
||||||
|
if ((mode == 0 || mode == 1) && (clickedButton == 0 || clickedButton == 1))
|
||||||
|
{
|
||||||
|
System.out.println("Clicked button: " + clickedButton + ", mode: " + mode);
|
||||||
|
|
||||||
|
ItemStack slotStack = slot.getStack();
|
||||||
|
ItemStack heldStack = inventoryPlayer.getItemStack();
|
||||||
|
|
||||||
|
if (mode == 0)
|
||||||
|
{
|
||||||
|
if (clickedButton == 0)
|
||||||
|
{
|
||||||
|
if (heldStack == null && slotStack != null)
|
||||||
|
{
|
||||||
|
GhostItemHelper.incrementGhostAmout(slotStack, 1);
|
||||||
|
slot.putStack(slotStack);
|
||||||
|
} else if (heldStack != null)
|
||||||
|
{
|
||||||
|
if (slotStack != null && Utils.canCombine(slotStack, heldStack))
|
||||||
|
{
|
||||||
|
GhostItemHelper.incrementGhostAmout(slotStack, heldStack.stackSize);
|
||||||
|
slot.putStack(slotStack);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
ItemStack copyStack = heldStack.copy();
|
||||||
|
GhostItemHelper.setItemGhostAmount(copyStack, copyStack.stackSize);
|
||||||
|
copyStack.stackSize = 1;
|
||||||
|
slot.putStack(copyStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if (slotStack != null)
|
||||||
|
{
|
||||||
|
GhostItemHelper.setItemGhostAmount(slotStack, GhostItemHelper.getItemGhostAmount(slotStack) / 2);
|
||||||
|
if (GhostItemHelper.getItemGhostAmount(slotStack) <= 0)
|
||||||
|
{
|
||||||
|
slot.putStack(null);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
slot.putStack(slotStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if (clickedButton == 0)
|
||||||
|
{
|
||||||
|
if (slotStack != null)
|
||||||
|
{
|
||||||
|
GhostItemHelper.decrementGhostAmout(slotStack, 1);
|
||||||
|
if (GhostItemHelper.getItemGhostAmount(slotStack) < 0)
|
||||||
|
{
|
||||||
|
slot.putStack(null);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
slot.putStack(slotStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
slot.putStack(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.slotClick(slotId, clickedButton, mode, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detectAndSendChanges()
|
||||||
|
{
|
||||||
|
super.detectAndSendChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = null;
|
||||||
|
Slot slot = (Slot) this.inventorySlots.get(index);
|
||||||
|
|
||||||
|
if (slot != null && slot.getHasStack())
|
||||||
|
{
|
||||||
|
ItemStack itemstack1 = slot.getStack();
|
||||||
|
itemstack = itemstack1.copy();
|
||||||
|
|
||||||
|
if (index == 0)
|
||||||
|
{
|
||||||
|
if (!this.mergeItemStack(itemstack1, slotsOccupied, slotsOccupied + 36, true))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot.onSlotChange(itemstack1, itemstack);
|
||||||
|
} else if (index > 0)
|
||||||
|
{
|
||||||
|
// return null;
|
||||||
|
if (true) // Change to check item is a filter
|
||||||
|
{
|
||||||
|
if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (!this.mergeItemStack(itemstack1, 0 + slotsOccupied, 36 + slotsOccupied, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemstack1.stackSize == 0)
|
||||||
|
{
|
||||||
|
slot.putStack((ItemStack) null);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
slot.onSlotChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemstack1.stackSize == itemstack.stackSize)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot.onPickupFromSlot(playerIn, itemstack1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInteractWith(EntityPlayer playerIn)
|
||||||
|
{
|
||||||
|
return this.tileItemRoutingNode.isUseableByPlayer(playerIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SlotItemFilter extends Slot
|
||||||
|
{
|
||||||
|
public SlotItemFilter(IInventory inventory, int slotIndex, int x, int y)
|
||||||
|
{
|
||||||
|
super(inventory, slotIndex, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isItemValid(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
return true; //TODO: Create a new Item that holds the filter.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SlotGhostItem extends Slot
|
||||||
|
{
|
||||||
|
public SlotGhostItem(IInventory inventory, int slotIndex, int x, int y)
|
||||||
|
{
|
||||||
|
super(inventory, slotIndex, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isItemValid(ItemStack stack)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canTakeStack(EntityPlayer playerIn)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,5 +2,8 @@ package WayofTime.bloodmagic.tile.routing;
|
||||||
|
|
||||||
public class TileInputRoutingNode extends TileRoutingNode
|
public class TileInputRoutingNode extends TileRoutingNode
|
||||||
{
|
{
|
||||||
|
public TileInputRoutingNode()
|
||||||
|
{
|
||||||
|
super(1, "inputNode");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,8 @@ package WayofTime.bloodmagic.tile.routing;
|
||||||
|
|
||||||
public class TileOutputRoutingNode extends TileRoutingNode
|
public class TileOutputRoutingNode extends TileRoutingNode
|
||||||
{
|
{
|
||||||
|
public TileOutputRoutingNode()
|
||||||
|
{
|
||||||
|
super(1, "outputNode");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,15 @@ import WayofTime.bloodmagic.routing.IItemFilter;
|
||||||
import WayofTime.bloodmagic.routing.IItemRoutingNode;
|
import WayofTime.bloodmagic.routing.IItemRoutingNode;
|
||||||
import WayofTime.bloodmagic.routing.IMasterRoutingNode;
|
import WayofTime.bloodmagic.routing.IMasterRoutingNode;
|
||||||
import WayofTime.bloodmagic.routing.IRoutingNode;
|
import WayofTime.bloodmagic.routing.IRoutingNode;
|
||||||
|
import WayofTime.bloodmagic.tile.TileInventory;
|
||||||
|
|
||||||
public class TileRoutingNode extends TileEntity implements IRoutingNode, IItemRoutingNode
|
public class TileRoutingNode extends TileInventory implements IRoutingNode, IItemRoutingNode
|
||||||
{
|
{
|
||||||
|
public TileRoutingNode(int size, String name)
|
||||||
|
{
|
||||||
|
super(size, name);
|
||||||
|
}
|
||||||
|
|
||||||
private BlockPos masterPos = BlockPos.ORIGIN;
|
private BlockPos masterPos = BlockPos.ORIGIN;
|
||||||
private List<BlockPos> connectionList = new LinkedList<BlockPos>();
|
private List<BlockPos> connectionList = new LinkedList<BlockPos>();
|
||||||
|
|
||||||
|
|
50
src/main/java/WayofTime/bloodmagic/util/GhostItemHelper.java
Normal file
50
src/main/java/WayofTime/bloodmagic/util/GhostItemHelper.java
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
package WayofTime.bloodmagic.util;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||||
|
|
||||||
|
public class GhostItemHelper
|
||||||
|
{
|
||||||
|
public static void setItemGhostAmount(ItemStack stack, int amount)
|
||||||
|
{
|
||||||
|
NBTHelper.checkNBT(stack);
|
||||||
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
|
|
||||||
|
tag.setInteger(Constants.NBT.GHOST_STACK_SIZE, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getItemGhostAmount(ItemStack stack)
|
||||||
|
{
|
||||||
|
NBTHelper.checkNBT(stack);
|
||||||
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
|
|
||||||
|
return tag.getInteger(Constants.NBT.GHOST_STACK_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasGhostAmount(ItemStack stack)
|
||||||
|
{
|
||||||
|
if (!stack.hasTagCompound())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
|
return tag.hasKey(Constants.NBT.GHOST_STACK_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void incrementGhostAmout(ItemStack stack, int value)
|
||||||
|
{
|
||||||
|
int amount = getItemGhostAmount(stack);
|
||||||
|
amount += value;
|
||||||
|
setItemGhostAmount(stack, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void decrementGhostAmout(ItemStack stack, int value)
|
||||||
|
{
|
||||||
|
int amount = getItemGhostAmount(stack);
|
||||||
|
amount -= value;
|
||||||
|
setItemGhostAmount(stack, amount);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,31 @@
|
||||||
package WayofTime.bloodmagic.util.handler;
|
package WayofTime.bloodmagic.util.handler;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import WayofTime.bloodmagic.util.GhostItemHelper;
|
||||||
|
|
||||||
public class ClientEventHandler
|
public class ClientEventHandler
|
||||||
{
|
{
|
||||||
// @SubscribeEvent
|
@SubscribeEvent
|
||||||
// public void onFOVUpdate(FOVUpdateEvent event)
|
public void onTooltipEvent(ItemTooltipEvent event)
|
||||||
// {
|
{
|
||||||
// event.newfov = event.fov;
|
ItemStack stack = event.itemStack;
|
||||||
// }
|
if (stack == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GhostItemHelper.hasGhostAmount(stack))
|
||||||
|
{
|
||||||
|
int amount = GhostItemHelper.getItemGhostAmount(stack);
|
||||||
|
if (amount == 0)
|
||||||
|
{
|
||||||
|
event.toolTip.add("Everything");
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
event.toolTip.add("Ghost item amount: " + amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in a new issue