Condensed the Alchemical Chest GUI/inventory stuff

This commit is contained in:
pahimar 2014-01-05 19:41:27 -05:00
parent 5a580e9028
commit 7c20a2db99
12 changed files with 263 additions and 520 deletions

View file

@ -85,23 +85,9 @@ public class BlockAlchemicalChest extends BlockEE implements ITileEntityProvider
}
else
{
if (!world.isRemote)
if (!world.isRemote && world.getBlockTileEntity(x, y, z) instanceof TileAlchemicalChest)
{
if (world.getBlockTileEntity(x, y, z) instanceof TileAlchemicalChest)
{
if (world.getBlockMetadata(x, y, z) == 0)
{
player.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_CHEST_SMALL, world, x, y, z);
}
else if (world.getBlockMetadata(x, y, z) == 1)
{
player.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_CHEST_MEDIUM, world, x, y, z);
}
else if (world.getBlockMetadata(x, y, z) == 2)
{
player.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_CHEST_LARGE, world, x, y, z);
}
}
player.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_CHEST, world, x, y, z);
}
return true;

View file

@ -0,0 +1,80 @@
package com.pahimar.ee3.client.gui.inventory;
import com.pahimar.ee3.inventory.ContainerAlchemicalChest;
import com.pahimar.ee3.lib.Strings;
import com.pahimar.ee3.lib.Textures;
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
/**
* Equivalent-Exchange-3
* <p/>
* GuiAlchemicalChest
*
* @author pahimar
*/
@SideOnly(Side.CLIENT)
public class GuiAlchemicalChest extends GuiContainer
{
private TileAlchemicalChest tileAlchemicalChest;
public GuiAlchemicalChest(InventoryPlayer inventoryPlayer, TileAlchemicalChest alchemicalChest)
{
super(new ContainerAlchemicalChest(inventoryPlayer, alchemicalChest));
tileAlchemicalChest = alchemicalChest;
if (this.tileAlchemicalChest.getState() == 0)
{
xSize = 230;
ySize = 186;
}
else if (this.tileAlchemicalChest.getState() == 1)
{
xSize = 230;
ySize = 240;
}
else if (this.tileAlchemicalChest.getState() == 2)
{
xSize = 248;
ySize = 256;
}
}
@Override
protected void drawGuiContainerForegroundLayer(int x, int y)
{
if (tileAlchemicalChest.getState() == 0 || tileAlchemicalChest.getState() == 1)
{
fontRenderer.drawString(tileAlchemicalChest.isInvNameLocalized() ? tileAlchemicalChest.getInvName() : StatCollector.translateToLocal(tileAlchemicalChest.getInvName()), 8, 6, 4210752);
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 35, ySize - 95 + 2, 4210752);
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
if (tileAlchemicalChest.getState() == 0)
{
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_STORAGE_SMALL);
}
else if (tileAlchemicalChest.getState() == 1)
{
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_STORAGE_MEDIUM);
}
else if (tileAlchemicalChest.getState() == 2)
{
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_STORAGE_LARGE);
}
int xStart = (width - xSize) / 2;
int yStart = (height - ySize) / 2;
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
}
}

View file

@ -1,38 +0,0 @@
package com.pahimar.ee3.client.gui.inventory;
import com.pahimar.ee3.inventory.ContainerAlchemicalChestLarge;
import com.pahimar.ee3.lib.Textures;
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.opengl.GL11;
/**
* Equivalent-Exchange-3
* <p/>
* GuiAlchemicalChestLarge
*
* @author pahimar
*/
@SideOnly(Side.CLIENT)
public class GuiAlchemicalChestLarge extends GuiContainer
{
public GuiAlchemicalChestLarge(InventoryPlayer inventoryPlayer, TileAlchemicalChest alchemicalChest)
{
super(new ContainerAlchemicalChestLarge(inventoryPlayer, alchemicalChest));
xSize = 248;
ySize = 256;
}
@Override
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_STORAGE_LARGE);
int xStart = (width - xSize) / 2;
int yStart = (height - ySize) / 2;
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
}
}

View file

@ -1,50 +0,0 @@
package com.pahimar.ee3.client.gui.inventory;
import com.pahimar.ee3.inventory.ContainerAlchemicalChestMedium;
import com.pahimar.ee3.lib.Strings;
import com.pahimar.ee3.lib.Textures;
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
/**
* Equivalent-Exchange-3
* <p/>
* GuiAlchemicalChestLarge
*
* @author pahimar
*/
@SideOnly(Side.CLIENT)
public class GuiAlchemicalChestMedium extends GuiContainer
{
private TileAlchemicalChest tileAlchemicalChest;
public GuiAlchemicalChestMedium(InventoryPlayer inventoryPlayer, TileAlchemicalChest alchemicalChest)
{
super(new ContainerAlchemicalChestMedium(inventoryPlayer, alchemicalChest));
tileAlchemicalChest = alchemicalChest;
xSize = 230;
ySize = 240;
}
@Override
protected void drawGuiContainerForegroundLayer(int x, int y)
{
fontRenderer.drawString(tileAlchemicalChest.isInvNameLocalized() ? tileAlchemicalChest.getInvName() : StatCollector.translateToLocal(tileAlchemicalChest.getInvName()), 8, 6, 4210752);
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 45, ySize - 89 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_STORAGE_MEDIUM);
int xStart = (width - xSize) / 2;
int yStart = (height - ySize) / 2;
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
}
}

View file

@ -1,46 +0,0 @@
package com.pahimar.ee3.client.gui.inventory;
import com.pahimar.ee3.inventory.ContainerAlchemicalChestSmall;
import com.pahimar.ee3.lib.Strings;
import com.pahimar.ee3.lib.Textures;
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
/**
* Created by pahimar on 04/01/14.
*/
@SideOnly(Side.CLIENT)
public class GuiAlchemicalChestSmall extends GuiContainer
{
private TileAlchemicalChest tileAlchemicalChest;
public GuiAlchemicalChestSmall(InventoryPlayer inventoryPlayer, TileAlchemicalChest alchemicalChest)
{
super(new ContainerAlchemicalChestSmall(inventoryPlayer, alchemicalChest));
tileAlchemicalChest = alchemicalChest;
xSize = 230;
ySize = 186;
}
@Override
protected void drawGuiContainerForegroundLayer(int x, int y)
{
fontRenderer.drawString(tileAlchemicalChest.isInvNameLocalized() ? tileAlchemicalChest.getInvName() : StatCollector.translateToLocal(tileAlchemicalChest.getInvName()), 8, 6, 4210752);
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 45, ySize - 89 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_STORAGE_SMALL);
int xStart = (width - xSize) / 2;
int yStart = (height - ySize) / 2;
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
}
}

View file

@ -1,7 +1,6 @@
package com.pahimar.ee3.handler;
import com.pahimar.ee3.client.gui.inventory.*;
import com.pahimar.ee3.helper.LogHelper;
import com.pahimar.ee3.inventory.*;
import com.pahimar.ee3.lib.GuiIds;
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
@ -27,23 +26,10 @@ public class GuiHandler implements IGuiHandler
TileCalcinator tileCalcinator = (TileCalcinator) world.getBlockTileEntity(x, y, z);
return new ContainerCalcinator(player.inventory, tileCalcinator);
}
else if (ID == GuiIds.ALCHEMICAL_CHEST_SMALL)
else if (ID == GuiIds.ALCHEMICAL_CHEST)
{
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getBlockTileEntity(x, y, z);
LogHelper.debug("State: " + tileAlchemicalChest.getState());
return new ContainerAlchemicalChestSmall(player.inventory, tileAlchemicalChest);
}
else if (ID == GuiIds.ALCHEMICAL_CHEST_MEDIUM)
{
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getBlockTileEntity(x, y, z);
LogHelper.debug("State: " + tileAlchemicalChest.getState());
return new ContainerAlchemicalChestMedium(player.inventory, tileAlchemicalChest);
}
else if (ID == GuiIds.ALCHEMICAL_CHEST_LARGE)
{
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getBlockTileEntity(x, y, z);
LogHelper.debug("State: " + tileAlchemicalChest.getState());
return new ContainerAlchemicalChestLarge(player.inventory, tileAlchemicalChest);
return new ContainerAlchemicalChest(player.inventory, tileAlchemicalChest);
}
else if (ID == GuiIds.ALCHEMICAL_BAG)
// TODO Alchemical Bag inventory work is incomplete
@ -77,20 +63,10 @@ public class GuiHandler implements IGuiHandler
TileCalcinator tileCalcinator = (TileCalcinator) world.getBlockTileEntity(x, y, z);
return new GuiCalcinator(player.inventory, tileCalcinator);
}
else if (ID == GuiIds.ALCHEMICAL_CHEST_SMALL)
else if (ID == GuiIds.ALCHEMICAL_CHEST)
{
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getBlockTileEntity(x, y, z);
return new GuiAlchemicalChestSmall(player.inventory, tileAlchemicalChest);
}
else if (ID == GuiIds.ALCHEMICAL_CHEST_MEDIUM)
{
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getBlockTileEntity(x, y, z);
return new GuiAlchemicalChestMedium(player.inventory, tileAlchemicalChest);
}
else if (ID == GuiIds.ALCHEMICAL_CHEST_LARGE)
{
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getBlockTileEntity(x, y, z);
return new GuiAlchemicalChestLarge(player.inventory, tileAlchemicalChest);
return new GuiAlchemicalChest(player.inventory, tileAlchemicalChest);
}
else if (ID == GuiIds.ALCHEMICAL_BAG)
// TODO Alchemical Bag inventory work is incomplete

View file

@ -0,0 +1,170 @@
package com.pahimar.ee3.inventory;
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
/**
* Equivalent-Exchange-3
* <p/>
* ContainerAlchemicalChest
*
* @author pahimar
*/
public class ContainerAlchemicalChest extends Container
{
private TileAlchemicalChest tileAlchemicalChest;
private int chestInventoryRows;
private int chestInventoryColumns;
// Small Chest
public static final int SMALL_CHEST_INVENTORY_ROWS = 4;
public static final int SMALL_CHEST_INVENTORY_COLUMNS = 12;
// Medium Chest
public static final int MEDIUM_CHEST_INVENTORY_ROWS = 7;
public static final int MEDIUM_CHEST_INVENTORY_COLUMNS = 12;
// Large Chest
public static final int LARGE_CHEST_INVENTORY_ROWS = 9;
public static final int LARGE_CHEST_INVENTORY_COLUMNS = 13;
// Player Inventory
private final int PLAYER_INVENTORY_ROWS = 3;
private final int PLAYER_INVENTORY_COLUMNS = 9;
public ContainerAlchemicalChest(InventoryPlayer inventoryPlayer, TileAlchemicalChest tileAlchemicalChest)
{
this.tileAlchemicalChest = tileAlchemicalChest;
tileAlchemicalChest.openChest();
if (this.tileAlchemicalChest.getState() == 0)
{
chestInventoryRows = SMALL_CHEST_INVENTORY_ROWS;
chestInventoryColumns = SMALL_CHEST_INVENTORY_COLUMNS;
}
else if (this.tileAlchemicalChest.getState() == 1)
{
chestInventoryRows = MEDIUM_CHEST_INVENTORY_ROWS;
chestInventoryColumns = MEDIUM_CHEST_INVENTORY_COLUMNS;
}
else if (this.tileAlchemicalChest.getState() == 2)
{
chestInventoryRows = LARGE_CHEST_INVENTORY_ROWS;
chestInventoryColumns = LARGE_CHEST_INVENTORY_COLUMNS;
}
// Add the Alchemical Chest slots to the container
for (int chestRowIndex = 0; chestRowIndex < chestInventoryRows; ++chestRowIndex)
{
for (int chestColumnIndex = 0; chestColumnIndex < chestInventoryColumns; ++chestColumnIndex)
{
if (this.tileAlchemicalChest.getState() == 0)
{
this.addSlotToContainer(new Slot(tileAlchemicalChest, chestColumnIndex + chestRowIndex * chestInventoryColumns, 8 + chestColumnIndex * 18, 18 + chestRowIndex * 18));
}
else if (this.tileAlchemicalChest.getState() == 1)
{
this.addSlotToContainer(new Slot(tileAlchemicalChest, chestColumnIndex + chestRowIndex * chestInventoryColumns, 8 + chestColumnIndex * 18, 18 + chestRowIndex * 18));
}
else if (this.tileAlchemicalChest.getState() == 2)
{
this.addSlotToContainer(new Slot(tileAlchemicalChest, chestColumnIndex + chestRowIndex * chestInventoryColumns, 8 + chestColumnIndex * 18, 8 + chestRowIndex * 18));
}
}
}
// Add the player's inventory slots to the container
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
{
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
{
if (this.tileAlchemicalChest.getState() == 0)
{
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 104 + inventoryRowIndex * 18));
}
else if (this.tileAlchemicalChest.getState() == 1)
{
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 158 + inventoryRowIndex * 18));
}
else if (this.tileAlchemicalChest.getState() == 2)
{
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18));
}
}
}
// Add the player's action bar slots to the container
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
{
if (this.tileAlchemicalChest.getState() == 0)
{
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 162));
}
else if (this.tileAlchemicalChest.getState() == 1)
{
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 216));
}
else if (this.tileAlchemicalChest.getState() == 2)
{
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232));
}
}
}
@Override
public boolean canInteractWith(EntityPlayer var1)
{
return true;
}
/**
* Callback for when the crafting gui is closed.
*/
@Override
public void onContainerClosed(EntityPlayer entityPlayer)
{
super.onContainerClosed(entityPlayer);
tileAlchemicalChest.closeChest();
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
{
ItemStack newItemStack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
if (slot != null && slot.getHasStack())
{
ItemStack itemStack = slot.getStack();
newItemStack = itemStack.copy();
if (slotIndex < chestInventoryRows * chestInventoryColumns)
{
if (!this.mergeItemStack(itemStack, chestInventoryRows * chestInventoryColumns, inventorySlots.size(), false))
{
return null;
}
}
else if (!this.mergeItemStack(itemStack, 0, chestInventoryRows * chestInventoryColumns, false))
{
return null;
}
if (itemStack.stackSize == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
}
return newItemStack;
}
}

View file

@ -1,110 +0,0 @@
package com.pahimar.ee3.inventory;
import com.pahimar.ee3.helper.LogHelper;
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
/**
* Equivalent-Exchange-3
* <p/>
* ContainerAlchemicalChestLarge
*
* @author pahimar
*/
public class ContainerAlchemicalChestLarge extends Container
{
private TileAlchemicalChest tileAlchemicalChest;
private final int CHEST_INVENTORY_ROWS = 9;
private final int CHEST_INVENTORY_COLUMNS = 13;
private final int PLAYER_INVENTORY_ROWS = 3;
private final int PLAYER_INVENTORY_COLUMNS = 9;
public ContainerAlchemicalChestLarge(InventoryPlayer inventoryPlayer, TileAlchemicalChest tileAlchemicalChest)
{
this.tileAlchemicalChest = tileAlchemicalChest;
LogHelper.debug("State: " + this.tileAlchemicalChest.getState() + ", Inventory size: " + this.tileAlchemicalChest.getSizeInventory());
tileAlchemicalChest.openChest();
// Add the Alchemical Chest slots to the container
for (int chestRowIndex = 0; chestRowIndex < CHEST_INVENTORY_ROWS; ++chestRowIndex)
{
for (int chestColumnIndex = 0; chestColumnIndex < CHEST_INVENTORY_COLUMNS; ++chestColumnIndex)
{
this.addSlotToContainer(new Slot(tileAlchemicalChest, chestColumnIndex + chestRowIndex * CHEST_INVENTORY_COLUMNS, 8 + chestColumnIndex * 18, 8 + chestRowIndex * 18));
}
}
// Add the player's inventory slots to the container
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
{
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
{
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18));
}
}
// Add the player's action bar slots to the container
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
{
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232));
}
}
@Override
public boolean canInteractWith(EntityPlayer var1)
{
return true;
}
/**
* Callback for when the crafting gui is closed.
*/
@Override
public void onContainerClosed(EntityPlayer entityPlayer)
{
super.onContainerClosed(entityPlayer);
tileAlchemicalChest.closeChest();
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
{
ItemStack newItemStack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
if (slot != null && slot.getHasStack())
{
ItemStack itemStack = slot.getStack();
newItemStack = itemStack.copy();
if (slotIndex < CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS)
{
if (!this.mergeItemStack(itemStack, CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS, inventorySlots.size(), false))
{
return null;
}
}
else if (!this.mergeItemStack(itemStack, 0, CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS, false))
{
return null;
}
if (itemStack.stackSize == 0)
{
slot.putStack((ItemStack) null);
}
else
{
slot.onSlotChanged();
}
}
return newItemStack;
}
}

View file

@ -1,110 +0,0 @@
package com.pahimar.ee3.inventory;
import com.pahimar.ee3.helper.LogHelper;
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
/**
* Equivalent-Exchange-3
* <p/>
* ContainerAlchemicalChestLarge
*
* @author pahimar
*/
public class ContainerAlchemicalChestMedium extends Container
{
private TileAlchemicalChest tileAlchemicalChest;
private final int CHEST_INVENTORY_ROWS = 7;
private final int CHEST_INVENTORY_COLUMNS = 12;
private final int PLAYER_INVENTORY_ROWS = 3;
private final int PLAYER_INVENTORY_COLUMNS = 9;
public ContainerAlchemicalChestMedium(InventoryPlayer inventoryPlayer, TileAlchemicalChest tileAlchemicalChest)
{
this.tileAlchemicalChest = tileAlchemicalChest;
LogHelper.debug("State: " + this.tileAlchemicalChest.getState() + ", Inventory size: " + this.tileAlchemicalChest.getSizeInventory());
tileAlchemicalChest.openChest();
// Add the Alchemical Chest slots to the container
for (int chestRowIndex = 0; chestRowIndex < CHEST_INVENTORY_ROWS; ++chestRowIndex)
{
for (int chestColumnIndex = 0; chestColumnIndex < CHEST_INVENTORY_COLUMNS; ++chestColumnIndex)
{
this.addSlotToContainer(new Slot(tileAlchemicalChest, chestColumnIndex + chestRowIndex * CHEST_INVENTORY_COLUMNS, 8 + chestColumnIndex * 18, 8 + chestRowIndex * 18));
}
}
// Add the player's inventory slots to the container
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
{
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
{
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18));
}
}
// Add the player's action bar slots to the container
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
{
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232));
}
}
@Override
public boolean canInteractWith(EntityPlayer var1)
{
return true;
}
/**
* Callback for when the crafting gui is closed.
*/
@Override
public void onContainerClosed(EntityPlayer entityPlayer)
{
super.onContainerClosed(entityPlayer);
tileAlchemicalChest.closeChest();
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
{
ItemStack newItemStack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
if (slot != null && slot.getHasStack())
{
ItemStack itemStack = slot.getStack();
newItemStack = itemStack.copy();
if (slotIndex < CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS)
{
if (!this.mergeItemStack(itemStack, CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS, inventorySlots.size(), false))
{
return null;
}
}
else if (!this.mergeItemStack(itemStack, 0, CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS, false))
{
return null;
}
if (itemStack.stackSize == 0)
{
slot.putStack((ItemStack) null);
}
else
{
slot.onSlotChanged();
}
}
return newItemStack;
}
}

View file

@ -1,110 +0,0 @@
package com.pahimar.ee3.inventory;
import com.pahimar.ee3.helper.LogHelper;
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
/**
* Equivalent-Exchange-3
* <p/>
* ContainerAlchemicalChestLarge
*
* @author pahimar
*/
public class ContainerAlchemicalChestSmall extends Container
{
private TileAlchemicalChest tileAlchemicalChest;
private final int CHEST_INVENTORY_ROWS = 4;
private final int CHEST_INVENTORY_COLUMNS = 12;
private final int PLAYER_INVENTORY_ROWS = 3;
private final int PLAYER_INVENTORY_COLUMNS = 9;
public ContainerAlchemicalChestSmall(InventoryPlayer inventoryPlayer, TileAlchemicalChest tileAlchemicalChest)
{
this.tileAlchemicalChest = tileAlchemicalChest;
LogHelper.debug("State: " + this.tileAlchemicalChest.getState() + ", Inventory size: " + this.tileAlchemicalChest.getSizeInventory());
tileAlchemicalChest.openChest();
// Add the Alchemical Chest slots to the container
for (int chestRowIndex = 0; chestRowIndex < CHEST_INVENTORY_ROWS; ++chestRowIndex)
{
for (int chestColumnIndex = 0; chestColumnIndex < CHEST_INVENTORY_COLUMNS; ++chestColumnIndex)
{
this.addSlotToContainer(new Slot(tileAlchemicalChest, chestColumnIndex + chestRowIndex * CHEST_INVENTORY_COLUMNS, 8 + chestColumnIndex * 18, 8 + chestRowIndex * 18));
}
}
// Add the player's inventory slots to the container
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
{
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
{
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18));
}
}
// Add the player's action bar slots to the container
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
{
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232));
}
}
@Override
public boolean canInteractWith(EntityPlayer var1)
{
return true;
}
/**
* Callback for when the crafting gui is closed.
*/
@Override
public void onContainerClosed(EntityPlayer entityPlayer)
{
super.onContainerClosed(entityPlayer);
tileAlchemicalChest.closeChest();
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
{
ItemStack newItemStack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
if (slot != null && slot.getHasStack())
{
ItemStack itemStack = slot.getStack();
newItemStack = itemStack.copy();
if (slotIndex < CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS)
{
if (!this.mergeItemStack(itemStack, CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS, inventorySlots.size(), false))
{
return null;
}
}
else if (!this.mergeItemStack(itemStack, 0, CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS, false))
{
return null;
}
if (itemStack.stackSize == 0)
{
slot.putStack((ItemStack) null);
}
else
{
slot.onSlotChanged();
}
}
return newItemStack;
}
}

View file

@ -12,9 +12,7 @@ public class GuiIds
public static final int PORTABLE_CRAFTING = 0;
public static final int CALCINATOR = 1;
public static final int ALUDEL = 2;
public static final int ALCHEMICAL_CHEST_SMALL = 3;
public static final int ALCHEMICAL_CHEST_MEDIUM = 4;
public static final int ALCHEMICAL_CHEST_LARGE = 5;
public static final int ALCHEMICAL_BAG = 6;
public static final int GLASS_BELL = 7;
public static final int ALCHEMICAL_CHEST = 3;
public static final int ALCHEMICAL_BAG = 4;
public static final int GLASS_BELL = 5;
}

View file

@ -1,7 +1,7 @@
package com.pahimar.ee3.tileentity;
import com.pahimar.ee3.block.ModBlocks;
import com.pahimar.ee3.helper.LogHelper;
import com.pahimar.ee3.inventory.ContainerAlchemicalChest;
import com.pahimar.ee3.lib.Sounds;
import com.pahimar.ee3.lib.Strings;
import net.minecraft.block.Block;
@ -39,11 +39,9 @@ public class TileAlchemicalChest extends TileEE implements IInventory
*/
private int ticksSinceSync;
public static final int INVENTORY_SIZE = 13 * 9;
public static final int SMALL_INVENTORY_SIZE = 12 * 4;
public static final int MEDIUM_INVENTORY_SIZE = 12 * 7;
public static final int LARGE_INVENTORY_SIZE = 13 * 9;
public static final int SMALL_INVENTORY_SIZE = ContainerAlchemicalChest.SMALL_CHEST_INVENTORY_ROWS * ContainerAlchemicalChest.SMALL_CHEST_INVENTORY_COLUMNS;
public static final int MEDIUM_INVENTORY_SIZE = ContainerAlchemicalChest.MEDIUM_CHEST_INVENTORY_ROWS * ContainerAlchemicalChest.MEDIUM_CHEST_INVENTORY_COLUMNS;
public static final int LARGE_INVENTORY_SIZE = ContainerAlchemicalChest.LARGE_CHEST_INVENTORY_ROWS * ContainerAlchemicalChest.LARGE_CHEST_INVENTORY_COLUMNS;
/**
* The ItemStacks that hold the items currently being used in the Alchemical Chest
@ -79,7 +77,6 @@ public class TileAlchemicalChest extends TileEE implements IInventory
@Override
public ItemStack getStackInSlot(int slotIndex)
{
LogHelper.debug(inventory.length);
return inventory[slotIndex];
}