Let's give the Research Station some loving, eh?

This commit is contained in:
Pahimar 2014-07-06 21:47:57 -04:00
parent 5bc742bb94
commit dc90ee2ada
16 changed files with 365 additions and 15 deletions

View file

@ -1,10 +1,13 @@
package com.pahimar.ee3.block;
import com.pahimar.ee3.EquivalentExchange3;
import com.pahimar.ee3.reference.GuiIds;
import com.pahimar.ee3.reference.Names;
import com.pahimar.ee3.reference.RenderIds;
import com.pahimar.ee3.tileentity.TileEntityResearchStation;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@ -40,4 +43,25 @@ public class BlockResearchStation extends BlockEE implements ITileEntityProvider
{
return RenderIds.researchStation;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
if (player.isSneaking())
{
return false;
}
else
{
if (!world.isRemote)
{
if (world.getTileEntity(x, y, z) instanceof TileEntityResearchStation)
{
player.openGui(EquivalentExchange3.instance, GuiIds.RESEARCH_STATION, world, x, y, z);
}
}
return true;
}
}
}

View file

@ -0,0 +1,45 @@
package com.pahimar.ee3.client.gui.inventory;
import com.pahimar.ee3.inventory.ContainerResearchStation;
import com.pahimar.ee3.reference.Names;
import com.pahimar.ee3.reference.Textures;
import com.pahimar.ee3.tileentity.TileEntityResearchStation;
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;
@SideOnly(Side.CLIENT)
public class GuiResearchStation extends GuiContainer
{
private TileEntityResearchStation tileEntityResearchStation;
public GuiResearchStation(InventoryPlayer inventoryPlayer, TileEntityResearchStation tileEntityResearchStation)
{
super(new ContainerResearchStation(inventoryPlayer, tileEntityResearchStation));
ySize = 176;
this.tileEntityResearchStation = tileEntityResearchStation;
}
@Override
protected void drawGuiContainerForegroundLayer(int x, int y)
{
String containerName = StatCollector.translateToLocal(tileEntityResearchStation.getInventoryName());
fontRendererObj.drawString(containerName, xSize / 2 - fontRendererObj.getStringWidth(containerName) / 2, 6, 4210752);
fontRendererObj.drawString(StatCollector.translateToLocal(Names.Containers.VANILLA_INVENTORY), 8, ySize - 96 + 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_RESEARCH_STATION);
int xStart = (width - xSize) / 2;
int yStart = (height - ySize) / 2;
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
}
}

View file

@ -3,10 +3,7 @@ package com.pahimar.ee3.handler;
import com.pahimar.ee3.client.gui.inventory.*;
import com.pahimar.ee3.inventory.*;
import com.pahimar.ee3.reference.GuiIds;
import com.pahimar.ee3.tileentity.TileEntityAlchemicalChest;
import com.pahimar.ee3.tileentity.TileEntityAludel;
import com.pahimar.ee3.tileentity.TileEntityCalcinator;
import com.pahimar.ee3.tileentity.TileEntityGlassBell;
import com.pahimar.ee3.tileentity.*;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
@ -40,6 +37,11 @@ public class GuiHandler implements IGuiHandler
TileEntityAludel tileEntityAludel = (TileEntityAludel) world.getTileEntity(x, y, z);
return new ContainerAludel(player.inventory, tileEntityAludel);
}
else if (id == GuiIds.RESEARCH_STATION)
{
TileEntityResearchStation tileEntityResearchStation = (TileEntityResearchStation) world.getTileEntity(x, y, z);
return new ContainerResearchStation(player.inventory, tileEntityResearchStation);
}
return null;
}
@ -71,6 +73,11 @@ public class GuiHandler implements IGuiHandler
TileEntityAludel tileEntityAludel = (TileEntityAludel) world.getTileEntity(x, y, z);
return new GuiAludel(player.inventory, tileEntityAludel);
}
else if (id == GuiIds.RESEARCH_STATION)
{
TileEntityResearchStation tileEntityResearchStation = (TileEntityResearchStation) world.getTileEntity(x, y, z);
return new GuiResearchStation(player.inventory, tileEntityResearchStation);
}
return null;
}

View file

@ -19,6 +19,7 @@ public class ModItems
public static final ItemEE chalk = new ItemChalk();
public static final ItemEE diviningRod = new ItemDiviningRod();
public static final ItemEE alchemicalTome = new ItemAlchemicalTome();
public static final ItemEE guide = new ItemGuide();
public static void init()
{
@ -33,5 +34,6 @@ public class ModItems
GameRegistry.registerItem(alchemicalUpgrade, Names.Items.ALCHEMICAL_UPGRADE);
GameRegistry.registerItem(diviningRod, Names.Items.DIVINING_ROD);
GameRegistry.registerItem(alchemicalTome, Names.Items.ALCHEMICAL_TOME);
GameRegistry.registerItem(guide, Names.Items.GUIDE);
}
}

View file

@ -180,7 +180,7 @@ public class ContainerAludel extends Container
}
@Override
public boolean canInteractWith(EntityPlayer var1)
public boolean canInteractWith(EntityPlayer entityPlayer)
{
return true;
}

View file

@ -0,0 +1,98 @@
package com.pahimar.ee3.inventory;
import com.pahimar.ee3.item.ItemAlchemicalTome;
import com.pahimar.ee3.tileentity.TileEntityResearchStation;
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;
public class ContainerResearchStation extends Container
{
private final int PLAYER_INVENTORY_ROWS = 3;
private final int PLAYER_INVENTORY_COLUMNS = 9;
private TileEntityResearchStation tileEntityResearchStation;
public ContainerResearchStation(InventoryPlayer inventoryPlayer, TileEntityResearchStation tileEntityResearchStation)
{
this.tileEntityResearchStation = tileEntityResearchStation;
this.addSlotToContainer(new Slot(tileEntityResearchStation, TileEntityResearchStation.ITEM_SLOT_INVENTORY_INDEX, 44, 41));
this.addSlotToContainer(new Slot(tileEntityResearchStation, TileEntityResearchStation.TOME_SLOT_INVENTORY_INDEX, 116, 41));
// 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, 8 + inventoryColumnIndex * 18, 94 + 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, 8 + actionBarSlotIndex * 18, 152));
}
}
@Override
public boolean canInteractWith(EntityPlayer entityPlayer)
{
return true;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
{
ItemStack itemStack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
if (slot != null && slot.getHasStack())
{
ItemStack slotItemStack = slot.getStack();
itemStack = slotItemStack.copy();
/**
* If we are shift-clicking an item out of the Aludel's container,
* attempt to put it in the first available slot in the player's
* inventory
*/
if (slotIndex < TileEntityResearchStation.INVENTORY_SIZE)
{
if (!this.mergeItemStack(slotItemStack, TileEntityResearchStation.INVENTORY_SIZE, inventorySlots.size(), false))
{
return null;
}
}
else
{
/**
* If the stack being shift-clicked into the Aludel's container
* is a fuel, first try to put it in the fuel slot. If it cannot
* be merged into the fuel slot, try to put it in the input
* slot.
*/
if (slotItemStack.getItem() instanceof ItemAlchemicalTome)
{
if (!this.mergeItemStack(slotItemStack, TileEntityResearchStation.TOME_SLOT_INVENTORY_INDEX, TileEntityResearchStation.INVENTORY_SIZE, false))
{
return null;
}
}
}
if (slotItemStack.stackSize == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
}
return itemStack;
}
}

View file

@ -0,0 +1,12 @@
package com.pahimar.ee3.item;
import com.pahimar.ee3.reference.Names;
public class ItemGuide extends ItemEE
{
public ItemGuide()
{
super();
this.setUnlocalizedName(Names.Items.GUIDE);
}
}

View file

@ -8,4 +8,5 @@ public final class GuiIds
public static final int ALCHEMICAL_CHEST = 3;
public static final int ALCHEMICAL_BAG = 4;
public static final int GLASS_BELL = 5;
public static final int RESEARCH_STATION = 6;
}

View file

@ -32,6 +32,7 @@ public class Names
public static final String[] ALCHEMICAL_UPGRADE_SUBTYPES = {"verdant", "azure", "minium"};
public static final String DIVINING_ROD = "diviningRod";
public static final String ALCHEMICAL_TOME = "alchemicalTome";
public static final String GUIDE = "guide";
}
public static final class NBT
@ -59,7 +60,7 @@ public class Names
public static final String ALCHEMICAL_CHEST = "container.ee3:" + Blocks.ALCHEMICAL_CHEST;
public static final String CALCINATOR = "container.ee3:" + Blocks.CALCINATOR;
public static final String ALUDEL = "container.ee3:" + Blocks.ALUDEL;
public static final String RESEARCH_STATION = "container.ee3:" + Blocks.RESEARCH_STATION;
public static final String GLASS_BELL = "container.ee3:" + Blocks.GLASS_BELL;
}

View file

@ -32,6 +32,8 @@ public final class Textures
public static final ResourceLocation GUI_ALCHEMICAL_CHEST_MEDIUM = ResourceLocationHelper.getResourceLocation(GUI_SHEET_LOCATION + "alchemicalChest_medium.png");
public static final ResourceLocation GUI_ALCHEMICAL_CHEST_LARGE = ResourceLocationHelper.getResourceLocation(GUI_SHEET_LOCATION + "alchemicalChest_large.png");
public static final ResourceLocation GUI_GLASS_BELL = ResourceLocationHelper.getResourceLocation(GUI_SHEET_LOCATION + "glassBell.png");
public static final ResourceLocation GUI_RESEARCH_STATION = ResourceLocationHelper.getResourceLocation(GUI_SHEET_LOCATION + "researchStation.png");
public static final String EFFECTS_LOCATION = "textures/effects/";
// Effect textures

View file

@ -42,6 +42,13 @@ public class TileEntityCalcinator extends TileEntityEE implements ISidedInventor
inventory = new ItemStack[INVENTORY_SIZE];
}
public static boolean suckInItems(TileEntityCalcinator tileEntityCalcinator)
{
EntityItem entityitem = TileEntityHopper.func_145897_a(tileEntityCalcinator.getWorldObj(), tileEntityCalcinator.xCoord, tileEntityCalcinator.yCoord + 1.0D, tileEntityCalcinator.zCoord);
return entityitem != null && TileEntityHopper.func_145898_a(tileEntityCalcinator, entityitem);
}
@Override
public int[] getAccessibleSlotsFromSide(int side)
{
@ -178,7 +185,7 @@ public class TileEntityCalcinator extends TileEntityEE implements ISidedInventor
}
@Override
public boolean isItemValidForSlot(int var1, ItemStack var2)
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack)
{
return false;
}
@ -468,13 +475,6 @@ public class TileEntityCalcinator extends TileEntityEE implements ISidedInventor
}
}
public static boolean suckInItems(TileEntityCalcinator tileEntityCalcinator)
{
EntityItem entityitem = TileEntityHopper.func_145897_a(tileEntityCalcinator.getWorldObj(), tileEntityCalcinator.xCoord, tileEntityCalcinator.yCoord + 1.0D, tileEntityCalcinator.zCoord);
return entityitem != null && TileEntityHopper.func_145898_a(tileEntityCalcinator, entityitem);
}
private void addItemStackToOutput(ItemStack alchemicalDustStack)
{
int maxStackSize = Math.min(getInventoryStackLimit(), alchemicalDustStack.getMaxStackSize());

View file

@ -1,5 +1,162 @@
package com.pahimar.ee3.tileentity;
public class TileEntityResearchStation extends TileEntityEE
import com.pahimar.ee3.reference.Names;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class TileEntityResearchStation extends TileEntityEE implements IInventory
{
public static final int INVENTORY_SIZE = 2;
public static final int ITEM_SLOT_INVENTORY_INDEX = 0;
public static final int TOME_SLOT_INVENTORY_INDEX = 1;
/**
* The ItemStacks that hold the items currently being used in the Glass Bell
*/
private ItemStack[] inventory;
public TileEntityResearchStation()
{
inventory = new ItemStack[INVENTORY_SIZE];
}
@Override
public int getSizeInventory()
{
return inventory.length;
}
@Override
public ItemStack getStackInSlot(int slotIndex)
{
return inventory[slotIndex];
}
@Override
public ItemStack decrStackSize(int slotIndex, int decrementAmount)
{
ItemStack itemStack = getStackInSlot(slotIndex);
if (itemStack != null)
{
if (itemStack.stackSize <= decrementAmount)
{
setInventorySlotContents(slotIndex, null);
}
else
{
itemStack = itemStack.splitStack(decrementAmount);
if (itemStack.stackSize == 0)
{
setInventorySlotContents(slotIndex, null);
}
}
}
return itemStack;
}
@Override
public ItemStack getStackInSlotOnClosing(int slotIndex)
{
ItemStack itemStack = getStackInSlot(slotIndex);
if (itemStack != null)
{
setInventorySlotContents(slotIndex, null);
}
return itemStack;
}
@Override
public void setInventorySlotContents(int slotIndex, ItemStack itemStack)
{
inventory[slotIndex] = itemStack;
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit())
{
itemStack.stackSize = getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return this.hasCustomName() ? this.getCustomName() : Names.Containers.RESEARCH_STATION;
}
@Override
public boolean hasCustomInventoryName()
{
return this.hasCustomName();
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer)
{
return true;
}
@Override
public void openInventory()
{
// NOOP
}
@Override
public void closeInventory()
{
// NOOP
}
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack)
{
return false;
}
@Override
public void writeToNBT(NBTTagCompound nbtTagCompound)
{
super.writeToNBT(nbtTagCompound);
// Write the ItemStacks in the inventory to NBT
NBTTagList tagList = new NBTTagList();
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex)
{
if (inventory[currentIndex] != null)
{
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setByte("Slot", (byte) currentIndex);
inventory[currentIndex].writeToNBT(tagCompound);
tagList.appendTag(tagCompound);
}
}
nbtTagCompound.setTag("Items", tagList);
}
@Override
public void readFromNBT(NBTTagCompound nbtTagCompound)
{
super.readFromNBT(nbtTagCompound);
// Read in the ItemStacks in the inventory from NBT
NBTTagList tagList = nbtTagCompound.getTagList("Items", 10);
inventory = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < tagList.tagCount(); ++i)
{
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
byte slotIndex = tagCompound.getByte("Slot");
if (slotIndex >= 0 && slotIndex < inventory.length)
{
inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
}
}
}
}

View file

@ -24,6 +24,7 @@ item.ee3:alchemicalUpgrade.verdant.name=Verdant Upgrade
item.ee3:alchemicalUpgrade.azure.name=Azure Upgrade
item.ee3:alchemicalUpgrade.minium.name=Minium Upgrade
item.ee3:alchemicalTome.name=Tome of Alchemical Knowledge [WIP]
item.ee3:guide.name=Guide To Alchemy [WIP]
# Block localizations
tile.ee3:alchemicalChest.name=Alchemical Chest

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB