Working on getting the Calcinator working

This commit is contained in:
pahimar 2012-09-28 16:05:29 -04:00
parent f8786ceb5b
commit eccf3082b8
5 changed files with 220 additions and 16 deletions

View file

@ -54,7 +54,7 @@ public class BlockCalcinator extends BlockEE {
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
if (world.isRemote) {
if (!world.isRemote) {
TileCalcinator tileCalcinator = (TileCalcinator) world.getBlockTileEntity(x, y, z);
if (tileCalcinator != null) {

View file

@ -3,20 +3,121 @@ package ee3.common.container;
import ee3.common.tile.TileCalcinator;
import net.minecraft.src.Container;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.FurnaceRecipes;
import net.minecraft.src.InventoryPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Slot;
import net.minecraft.src.TileEntityFurnace;
public class ContainerCalcinator extends Container {
private TileCalcinator calcinator;
public ContainerCalcinator(InventoryPlayer inventoryPlayer, TileCalcinator calcinator) {
this.calcinator = calcinator;
// Set the instance of the TileCalcinator for the container
this.calcinator = calcinator;
// Add the calcinator "to be calcined" slot to the container
this.addSlotToContainer(new Slot(calcinator, 0, 56, 17));
// Add the calcinator fuel slot to the container
this.addSlotToContainer(new Slot(calcinator, 1, 56, 62));
// Add the calcined results slot to the container
// TODO Add a slot here
// Add the player's inventory slots to the container
for (int inventoryRowIndex = 0; inventoryRowIndex < 3; ++inventoryRowIndex)
{
for (int inventoryColumnIndex = 0; inventoryColumnIndex < 9; ++inventoryColumnIndex)
{
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 84 + inventoryRowIndex * 18));
}
}
// Add the player's action bar slots to the container
for (int actionBarSlotIndex = 0; actionBarSlotIndex < 9; ++actionBarSlotIndex)
{
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 142));
}
}
@Override
public boolean canInteractWith(EntityPlayer var1) {
// TODO Auto-generated method stub
return false;
public boolean canInteractWith(EntityPlayer player) {
//return calcinator.isUseableByPlayer(player);
return true;
}
// TODO Write our own version - this is taken from ContainerFurnace
public ItemStack transferStackInSlot(int par1)
{
ItemStack var2 = null;
Slot var3 = (Slot)this.inventorySlots.get(par1);
if (var3 != null && var3.getHasStack())
{
ItemStack var4 = var3.getStack();
var2 = var4.copy();
if (par1 == 2)
{
if (!this.mergeItemStack(var4, 3, 39, true))
{
return null;
}
var3.onSlotChange(var4, var2);
}
else if (par1 != 1 && par1 != 0)
{
if (FurnaceRecipes.smelting().getSmeltingResult(var4) != null)
{
if (!this.mergeItemStack(var4, 0, 1, false))
{
return null;
}
}
else if (TileEntityFurnace.isItemFuel(var4))
{
if (!this.mergeItemStack(var4, 1, 2, false))
{
return null;
}
}
else if (par1 >= 3 && par1 < 30)
{
if (!this.mergeItemStack(var4, 30, 39, false))
{
return null;
}
}
else if (par1 >= 30 && par1 < 39 && !this.mergeItemStack(var4, 3, 30, false))
{
return null;
}
}
else if (!this.mergeItemStack(var4, 3, 39, false))
{
return null;
}
if (var4.stackSize == 0)
{
var3.putStack((ItemStack)null);
}
else
{
var3.onSlotChanged();
}
if (var4.stackSize == var2.stackSize)
{
return null;
}
var3.onPickupFromSlot(var4);
}
return var2;
}
}

View file

@ -20,6 +20,7 @@ public class Reference {
public static final String VERSION = "1.0.0.0";
public static final String CHANNEL_NAME = MOD_ID;
public static final String LOGGER_PREFIX = "[" + MOD_ID + "] ";
public static final int SECOND_IN_TICKS = 20;
public static final int SHIFTED_ID_RANGE_CORRECTION = 256;
/* Configuration related constants */
@ -44,10 +45,12 @@ public class Reference {
public static final String GUI_SHEET_LOCATION = "/ee3/art/gui/";
public static final String ITEM_SPRITE_SHEET = "ee3_items.png";
public static final String BLOCK_SPRITE_SHEET = "ee3_blocks.png";
/* General Tile Entity related constants */
public static final String TE_GEN_OWNER_NBT_TAG_LABEL = "owner";
public static final String TE_GEN_STATE_NBT_TAG_LABEL = "state";
public static final String TE_GEN_DIRECTION_NBT_TAG_LABEL = "direction";
public static final int SECOND_IN_TICKS = 20;
// TODO: Find a better spot for these
public static final int BLOCK_RED_WATER_EFFECT_DURATION_BASE = 5;
public static final int BLOCK_RED_WATER_EFFECT_DURATION_MODIFIER = 2;

View file

@ -1,17 +1,64 @@
package ee3.common.tile;
import ee3.common.block.ModBlocks;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
public class TileCalcinator extends TileEE {
public class TileCalcinator extends TileEE implements IInventory {
/**
* The ItemStacks that hold the items currently being used in the Calcinator
*/
private ItemStack[] calcinatorItemStacks = new ItemStack[3];
public void readFromNBT(NBTTagCompound nbtTagCompound) {
super.readFromNBT(nbtTagCompound);
}
public void writeToNBT(NBTTagCompound nbtTagCompound) {
super.writeToNBT(nbtTagCompound);
}
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory() {
return this.calcinatorItemStacks.length;
}
/**
* Returns the stack in slot i
*/
public ItemStack getStackInSlot(int i) {
return this.calcinatorItemStacks[i];
}
public ItemStack decrStackSize(int i, int j) {
// TODO Auto-generated method stub
return null;
}
public ItemStack getStackInSlotOnClosing(int i) {
return null;
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
super.readFromNBT(par1NBTTagCompound);
public void setInventorySlotContents(int var1, ItemStack var2) {
// TODO Auto-generated method stub
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
super.writeToNBT(par1NBTTagCompound);
public String getInvName() {
return "container." + ModBlocks.CALCINATOR_NAME;
}
public int getInventoryStackLimit() {
return 64;
}
public void openChest() { }
public void closeChest() { }
}

View file

@ -1,7 +1,60 @@
package ee3.common.tile;
import ee3.common.lib.Reference;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.TileEntity;
public class TileEE extends TileEntity {
private byte direction;
private short state;
private String owner;
public byte getDirection() {
return direction;
}
public void setDirection(byte direction) {
this.direction = direction;
}
public short getState() {
return state;
}
public void setState(short state) {
this.state = state;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public boolean isUseableByPlayer(EntityPlayer player) {
return owner.equals(player.username);
}
public void readFromNBT(NBTTagCompound nbtTagCompound) {
super.readFromNBT(nbtTagCompound);
direction = nbtTagCompound.getByte(Reference.TE_GEN_DIRECTION_NBT_TAG_LABEL);
state = nbtTagCompound.getShort(Reference.TE_GEN_STATE_NBT_TAG_LABEL);
owner = nbtTagCompound.getString(Reference.TE_GEN_OWNER_NBT_TAG_LABEL);
}
public void writeToNBT(NBTTagCompound nbtTagCompound) {
super.writeToNBT(nbtTagCompound);
nbtTagCompound.setByte(Reference.TE_GEN_DIRECTION_NBT_TAG_LABEL, direction);
nbtTagCompound.setShort(Reference.TE_GEN_STATE_NBT_TAG_LABEL, state);
if(owner != null && owner != "") {
nbtTagCompound.setString(Reference.TE_GEN_OWNER_NBT_TAG_LABEL, owner);
}
}
}