Worked on the Alchemy Table - final push for -35

This commit is contained in:
WayofTime 2016-05-02 08:27:38 -04:00
parent bc7760b11b
commit 7116e3775e
9 changed files with 268 additions and 43 deletions

View file

@ -12,6 +12,10 @@ import WayofTime.bloodmagic.api.Constants;
@Getter
public class TileAlchemyTable extends TileInventory implements ISidedInventory, ITickable
{
public static final int orbSlot = 6;
public static final int toolSlot = 7;
public static final int outputSlot = 8;
public EnumFacing direction = EnumFacing.NORTH;
public boolean isSlave = false;
@ -19,7 +23,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
public TileAlchemyTable()
{
super(1, "alchemyTable");
super(9, "alchemyTable");
}
public void setInitialTableParameters(EnumFacing direction, boolean isSlave, BlockPos connectedPos)
@ -55,9 +59,9 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
tag.setBoolean("isSlave", isSlave);
tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
tag.setInteger(Constants.NBT.X_COORD, pos.getX());
tag.setInteger(Constants.NBT.Y_COORD, pos.getY());
tag.setInteger(Constants.NBT.Z_COORD, pos.getZ());
tag.setInteger(Constants.NBT.X_COORD, connectedPos.getX());
tag.setInteger(Constants.NBT.Y_COORD, connectedPos.getY());
tag.setInteger(Constants.NBT.Z_COORD, connectedPos.getZ());
}
@Override

View file

@ -0,0 +1,131 @@
package WayofTime.bloodmagic.tile.container;
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;
import WayofTime.bloodmagic.api.orb.IBloodOrb;
import WayofTime.bloodmagic.tile.TileAlchemyTable;
public class ContainerAlchemyTable extends Container
{
private final IInventory tileTable;
public ContainerAlchemyTable(InventoryPlayer inventoryPlayer, IInventory tileTable)
{
this.tileTable = tileTable;
this.addSlotToContainer(new Slot(tileTable, 0, 62, 15));
this.addSlotToContainer(new Slot(tileTable, 1, 80, 51));
this.addSlotToContainer(new Slot(tileTable, 2, 62, 87));
this.addSlotToContainer(new Slot(tileTable, 3, 26, 87));
this.addSlotToContainer(new Slot(tileTable, 4, 8, 51));
this.addSlotToContainer(new Slot(tileTable, 5, 26, 15));
this.addSlotToContainer(new Slot(tileTable, TileAlchemyTable.toolSlot, 152, 33));
this.addSlotToContainer(new SlotOrb(tileTable, TileAlchemyTable.orbSlot, 152, 69));
this.addSlotToContainer(new SlotOutput(tileTable, TileAlchemyTable.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, 123 + i * 18));
}
}
for (int i = 0; i < 9; i++)
{
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 181));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
ItemStack itemstack = null;
Slot slot = this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index == 8)
{
if (!this.mergeItemStack(itemstack1, 9, 9 + 36, true))
{
return null;
}
slot.onSlotChange(itemstack1, itemstack);
} else if (index > 8)
{
if (itemstack1.getItem() instanceof IBloodOrb)
{
if (!this.mergeItemStack(itemstack1, 7, 8, false)) //TODO: Add alchemy tools to list
{
return null;
}
} else if (!this.mergeItemStack(itemstack1, 0, 6, false))
{
return null;
}
} else if (!this.mergeItemStack(itemstack1, 9, 9 + 36, false))
{
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack(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.tileTable.isUseableByPlayer(playerIn);
}
private class SlotOrb extends Slot
{
public SlotOrb(IInventory inventory, int slotIndex, int x, int y)
{
super(inventory, slotIndex, x, y);
}
@Override
public boolean isItemValid(ItemStack itemStack)
{
return itemStack.getItem() instanceof IBloodOrb;
}
}
private class SlotOutput extends Slot
{
public SlotOutput(IInventory inventory, int slotIndex, int x, int y)
{
super(inventory, slotIndex, x, y);
}
@Override
public boolean isItemValid(ItemStack stack)
{
return false;
}
}
}