StrongJoshua, thank you for the excellent 'new furnace' tutorial. I've successfully made my own without any issue except one.
The items in the output slot will not stack. When the new furnace smelts an item when there is already an item in the output slot, the newly smelted item dissapears and isn't added to the item stack. These items normally stack in the inventory, so I'm not seeing the issue.
Do you know what could be causing this?
Also, do you know how to make it so that if you are say, smelting a bucket of water, the actual bucket is not smelted along with the water?
Hey is there a way to update the furnace's light value without a new block id? I tried this and used the tile entity to store the light value, but the light value function seems to get updated randomly. Is there a way to fix this?
I read the Furnace Tutorial and then i tried to create a Workbench. I copied the Workbench files. But if i click on the new Workbench the Gui dont open...
Ya, I'm trying to make a furnace but the same thing happens to me. Stupid furnace doesn't like me.
Hey StrongJoshua, I used your custom furnace tutorial and it worked a charm - thank you, and have a green arrow thing for it :).
However, I ran into an issue when I moved everything to use Forge (for the extended sprite indexes) - in the Forge version (where the code for the furnace files is identical to the non-Forge version), I crash when I try to open the GUI ... Do you have any idea why that is?
Thanks for the amazing tutorials and keep up the good work. If you have any thoughts as to why using Forge means it doesn't work, then it would be very much appreciated!
Hello StrongJoshua,
I am looking for assistance with my custom gui. It is working fine, except for when I open it in game. It just gives me a big block saying MISSING as the texture. If I move my mouse around I can find the slots. This is an issue with the texturing. It is looking for the texture in /gui/furnace.png. Halp?!
Works perfectly!
Using this i managed to make a furnace with 10 inputs (1 fuel, 9 resource) and 2 outputs! Awesome!
I would love it if you made more tuts
@Eriottosan Mine uses forge to, but it works perfectly, i don't know what your problem could be, sorry
I'm making a new furnace, but when recompiling I get errors on almost every line of code implying "error: class, interface, or enum expected". There's also some other errors, but of minor importance.
The error I get:
for(int l = 0; l < tileentitycokeoven.getSizeInventory()
; l++)
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:147: error: class, interface,
or enum expected
for(int l = 0; l < tileentitycokeoven.getSizeInventory()
; l++)
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:150: error: class, interface,
or enum expected
if(itemstack == null)
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:153: error: class, interface,
or enum expected
}
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:155: error: class, interface,
or enum expected
float f1 = cokeovenRand.nextFloat() * 0.8F + 0.1
F;
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:156: error: class, interface,
or enum expected
float f2 = cokeovenRand.nextFloat() * 0.8F + 0.1
F;
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:157: error: class, interface,
or enum expected
do
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:162: error: class, interface,
or enum expected
}
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:164: error: class, interface,
or enum expected
if(i1 > itemstack.stackSize)
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:167: error: class, interface,
or enum expected
}
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:169: error: class, interface,
or enum expected
EntityItem entityitem = new EntityItem(w
orld, (float)i + f, (float)j + f1, (float)k + f2, new ItemStack(itemstack.itemID
, i1, itemstack.getItemDamage()));
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:170: error: class, interface,
or enum expected
float f3 = 0.05F;
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:171: error: class, interface,
or enum expected
entityitem.motionX = (float)cokeovenRand
.nextGaussian() * f3;
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:172: error: class, interface,
or enum expected
entityitem.motionY = (float)cokeovenRand
.nextGaussian() * f3 + 0.2F;
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:173: error: class, interface,
or enum expected
entityitem.motionZ = (float)cokeovenRand
.nextGaussian() * f3;
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:174: error: class, interface,
or enum expected
world.entityJoinedWorld(entityitem);
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:175: error: class, interface,
or enum expected
} while(true);
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:176: error: class, interface,
or enum expected
}
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:179: error: class, interface,
or enum expected
}
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:181: error: class, interface,
or enum expected
private final boolean isActive;
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:182: error: class, interface,
or enum expected
private static boolean keepCokeovenInventory = false;
^
src\minecraft\net\minecraft\src\BlockCokeoven.java:183: error: class, interface,
or enum expected
}
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:9: error: class, interfac
e, or enum expected
{
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:10: error: class, interfa
ce, or enum expected
public ContainerCokeoven(InventoryPlayer inventoryplayer, TileEntityCoke
oven tileentitycokeoven)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:13: error: class, interfa
ce, or enum expected
cookingTime = 0;
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:14: error: class, interfa
ce, or enum expected
itemCookTime = 0;
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:15: error: class, interfa
ce, or enum expected
cokeoven = tileentitycokeoven;
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:16: error: class, interfa
ce, or enum expected
addSlot(new Slot(tileentitycokeoven, 0, 56, 17));
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:17: error: class, interfa
ce, or enum expected
addSlot(new Slot(tileentitycokeoven, 1, 56, 53));
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:18: error: class, interfa
ce, or enum expected
addSlot(new SlotCokeoven(inventoryplayer.player, tileentitycokeo
ven, 2, 116, 35));
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:19: error: class, interfa
ce, or enum expected
for(int i = 0; i < 3; i++)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:19: error: class, interfa
ce, or enum expected
for(int i = 0; i < 3; i++)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:19: error: class, interfa
ce, or enum expected
for(int i = 0; i < 3; i++)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:21: error: class, interfa
ce, or enum expected
for(int k = 0; k < 9; k++)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:21: error: class, interfa
ce, or enum expected
for(int k = 0; k < 9; k++)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:24: error: class, interfa
ce, or enum expected
}
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:26: error: class, interfa
ce, or enum expected
for(int j = 0; j < 9; j++)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:26: error: class, interfa
ce, or enum expected
for(int j = 0; j < 9; j++)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:29: error: class, interfa
ce, or enum expected
}
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:31: error: class, interfa
ce, or enum expected
public void updateCraftingResults()
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:34: error: class, interfa
ce, or enum expected
for(int i = 0; i < inventorySlots.size(); i++)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:34: error: class, interfa
ce, or enum expected
for(int i = 0; i < inventorySlots.size(); i++)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:34: error: class, interfa
ce, or enum expected
for(int i = 0; i < inventorySlots.size(); i++)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:37: error: class, interfa
ce, or enum expected
if(coolTime != cokeoven.cokeovenCoolTime)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:40: error: class, interfa
ce, or enum expected
}
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:44: error: class, interfa
ce, or enum expected
}
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:48: error: class, interfa
ce, or enum expected
}
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:51: error: class, interfa
ce, or enum expected
cookTime = cokeoven.cokeovenCookTime;
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:52: error: class, interfa
ce, or enum expected
itemCookTime = cokeoven.currentItemCoolTime;
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:53: error: class, interfa
ce, or enum expected
}
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:54: error: class, interfa
ce, or enum expected
public void func_20112_a(int i, int j)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:59: error: class, interfa
ce, or enum expected
}
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:63: error: class, interfa
ce, or enum expected
}
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:67: error: class, interfa
ce, or enum expected
}
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:69: error: class, interfa
ce, or enum expected
public boolean canInteractWith(EntityPlayer entityplayer)
^
src\minecraft\net\minecraft\src\ContainerCokeoven.java:72: error: class, interfa
ce, or enum expected
}
^
100 errors
==================
== Recompiling server ==
> Cleaning bin
> Recompiling
- Done in 6.45 seconds
I would like help soon please. I cannot get my furnace to change texture when active. I want the top and bottom of this furnace to change texture, and also I would like it to produce particles. I have been working for hours on this and have waited hours for a response elsewhere. Please help.
Block
package net.minecraft.src;
import java.util.Random;
public class EmundiasPurifier extends BlockContainer
{
/**
* Is the random generator used by Purifier to drop the inventory contents in random directions.
*/
private Random PurifierRand;
/** True if this is an active Purifier, false if idle */
private final boolean isActive;
/**
* This flag is used to prevent the Purifier inventory to be dropped upon block removal, is used internally when the
* Purifier block changes from idle to active and vice-versa.
*/
private static boolean keepPurifierInventory = false;
protected EmundiasPurifier(int par1, boolean par2)
{
super(par1, Material.iron);
PurifierRand = new Random();
isActive = par2;
blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/SpiritCraftT/Purifier1.png");
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3)
{
return mod_SoulCraft.EmundiasPurifier.blockID;
}
/**
* Called whenever the block is added into the world. Args: world, x, y, z
*/
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
super.onBlockAdded(par1World, par2, par3, par4);
setDefaultDirection(par1World, par2, par3, par4);
}
/**
* set a blocks direction
*/
private void setDefaultDirection(World par1World, int par2, int par3, int par4)
{
if (par1World.isRemote)
{
return;
}
int i = par1World.getBlockId(par2, par3, par4 - 1);
int j = par1World.getBlockId(par2, par3, par4 + 1);
int k = par1World.getBlockId(par2 - 1, par3, par4);
int l = par1World.getBlockId(par2 + 1, par3, par4);
byte byte0 = 3;
if (Block.opaqueCubeLookup[i] && !Block.opaqueCubeLookup[j])
{
byte0 = 3;
}
if (Block.opaqueCubeLookup[j] && !Block.opaqueCubeLookup[i])
{
byte0 = 2;
}
if (Block.opaqueCubeLookup[k] && !Block.opaqueCubeLookup[l])
{
byte0 = 5;
}
if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[k])
{
byte0 = 4;
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, byte0);
}
/**
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
*/
public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
if (par5 == 1)
{
return mod_SoulCraft.Purifiertop;
}
if (par5 == 0)
{
return mod_SoulCraft.Purifierside;
}
int i = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
if (par5 != i)
{
return mod_SoulCraft.Purifierside;
}
if (isActive)
{
return mod_SoulCraft.PurifierfrontON;
}
else
{
return mod_SoulCraft.Purifierfront;
}
}
/**
* A randomly called display update to be able to add particles or other items for display
*/
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
if (!isActive)
{
return;
}
int i = par1World.getBlockMetadata(par2, par3, par4);
float f = (float)par2 + 0.5F;
float f1 = (float)par3 + 0.0F + (par5Random.nextFloat() * 6F) / 16F;
float f2 = (float)par4 + 0.5F;
float f3 = 0.52F;
float f4 = par5Random.nextFloat() * 0.6F - 0.3F;
if (i == 4)
{
par1World.spawnParticle("reddust", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
}
else if (i == 5)
{
par1World.spawnParticle("reddust", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
}
else if (i == 2)
{
par1World.spawnParticle("reddust", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
}
else if (i == 3)
{
par1World.spawnParticle("reddust", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
}
}
/**
* Returns the block texture based on the side being looked at. Args: side
*/
public int getBlockTextureFromSide(int par1)
{
if (par1 == 1)
{
return mod_SoulCraft.Purifiertop;
}
if (par1 == 0)
{
return mod_SoulCraft.Purifierside;
}
if (par1 == 3)
{
return mod_SoulCraft.Purifierfront;
}
else
{
return mod_SoulCraft.Purifierside;
}
}
/**
* Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the
* block.
*/
public boolean blockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
{
if (par1World.isRemote)
{
return true;
}
TileEntityPurifier tileentitypurifier = (TileEntityPurifier)par1World.getBlockTileEntity(par2, par3, par4);
if (tileentitypurifier != null)
{
ModLoader.openGUI(par5EntityPlayer, new GuiPurifier(par5EntityPlayer.inventory, tileentitypurifier));
}
return true;
}
/**
* Update which block ID the Purifier is using depending on whether or not it is burning
*/
public static void updatePurifierBlockState(boolean par0, World par1World, int par2, int par3, int par4)
{
int i = par1World.getBlockMetadata(par2, par3, par4);
TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4);
keepPurifierInventory = true;
if (par0)
{
par1World.setBlockWithNotify(par2, par3, par4, mod_SoulCraft.EmundiasPurifierOn.blockID);
}
else
{
par1World.setBlockWithNotify(par2, par3, par4, mod_SoulCraft.EmundiasPurifier.blockID);
}
keepPurifierInventory = false;
par1World.setBlockMetadataWithNotify(par2, par3, par4, i);
if (tileentity != null)
{
tileentity.validate();
par1World.setBlockTileEntity(par2, par3, par4, tileentity);
}
}
/**
* Returns the TileEntity used by this block.
*/
public TileEntity getBlockEntity()
{
return new TileEntityPurifier();
}
/**
* Called when the block is placed in the world.
*/
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int i = MathHelper.floor_double((double)((par5EntityLiving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
if (i == 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 2);
}
if (i == 1)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 5);
}
if (i == 2)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3);
}
if (i == 3)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 4);
}
}
/**
* Called whenever the block is removed.
*/
public void onBlockRemoval(World par1World, int par2, int par3, int par4)
{
if (!keepPurifierInventory)
{
TileEntityPurifier tileentityPurifier = (TileEntityPurifier)par1World.getBlockTileEntity(par2, par3, par4);
if (tileentityPurifier != null)
{
label0:
for (int i = 0; i < tileentityPurifier.getSizeInventory(); i++)
{
ItemStack itemstack = tileentityPurifier.getStackInSlot(i);
if (itemstack == null)
{
continue;
}
float f = PurifierRand.nextFloat() * 0.8F + 0.1F;
float f1 = PurifierRand.nextFloat() * 0.8F + 0.1F;
float f2 = PurifierRand.nextFloat() * 0.8F + 0.1F;
do
{
if (itemstack.stackSize <= 0)
{
continue label0;
}
int j = PurifierRand.nextInt(21) + 10;
if (j > itemstack.stackSize)
{
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(par1World, (float)par2 + f, (float)par3 + f1, (float)par4 + f2, new ItemStack(itemstack.itemID, j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound())
{
entityitem.item.setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (float)PurifierRand.nextGaussian() * f3;
entityitem.motionY = (float)PurifierRand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float)PurifierRand.nextGaussian() * f3;
par1World.spawnEntityInWorld(entityitem);
}
while (true);
}
}
}
super.onBlockRemoval(par1World, par2, par3, par4);
}
}
Tile Entity
package net.minecraft.src;
public class TileEntityPurifier extends TileEntity implements IInventory
{
private ItemStack PurifierItemStacks[];
/** The number of ticks that the Purifier will keep Useing */
public int PurifierUseTime;
/**
* The number of ticks that a fresh copy of the currently-Useing item would keep the Purifier Useing for
*/
public int currentItemUseTime;
/** The number of ticks that the current item has been Pureing for */
public int PurifierPureTime;
public TileEntityPurifier()
{
PurifierItemStacks = new ItemStack[3];
PurifierUseTime = 0;
currentItemUseTime = 0;
PurifierPureTime = 0;
}
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
{
return PurifierItemStacks.length;
}
/**
* Returns the stack in slot i
*/
public ItemStack getStackInSlot(int par1)
{
return PurifierItemStacks[par1];
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
* stack.
*/
public ItemStack decrStackSize(int par1, int par2)
{
if (PurifierItemStacks[par1] != null)
{
if (PurifierItemStacks[par1].stackSize <= par2)
{
ItemStack itemstack = PurifierItemStacks[par1];
PurifierItemStacks[par1] = null;
return itemstack;
}
ItemStack itemstack1 = PurifierItemStacks[par1].splitStack(par2);
if (PurifierItemStacks[par1].stackSize == 0)
{
PurifierItemStacks[par1] = null;
}
return itemstack1;
}
else
{
return null;
}
}
/**
* When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
* like when you close a workbench GUI.
*/
public ItemStack getStackInSlotOnClosing(int par1)
{
if (PurifierItemStacks[par1] != null)
{
ItemStack itemstack = PurifierItemStacks[par1];
PurifierItemStacks[par1] = null;
return itemstack;
}
else
{
return null;
}
}
/**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
*/
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
PurifierItemStacks[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > getInventoryStackLimit())
{
par2ItemStack.stackSize = getInventoryStackLimit();
}
}
/**
* Returns the name of the inventory.
*/
public String getInvName()
{
return "Purifier";
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items");
PurifierItemStacks = new ItemStack[getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); i++)
{
NBTTagCompound nbttagcompound = (NBTTagCompound)nbttaglist.tagAt(i);
byte byte0 = nbttagcompound.getByte("Slot");
if (byte0 >= 0 && byte0 < PurifierItemStacks.length)
{
PurifierItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound);
}
}
PurifierUseTime = par1NBTTagCompound.getShort("UseTime");
PurifierPureTime = par1NBTTagCompound.getShort("PureTime");
currentItemUseTime = getItemUseTime(PurifierItemStacks[1]);
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("UseTime", (short)PurifierUseTime);
par1NBTTagCompound.setShort("PureTime", (short)PurifierPureTime);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < PurifierItemStacks.length; i++)
{
if (PurifierItemStacks[i] != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
PurifierItemStacks[i].writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
}
}
par1NBTTagCompound.setTag("Items", nbttaglist);
}
/**
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't
* this more of a set than a get?*
*/
public int getInventoryStackLimit()
{
return 64;
}
/**
* Returns an integer between 0 and the passed value representing how close the current item is to being completely
* Pureed
*/
public int getPureProgressScaled(int par1)
{
return (PurifierPureTime * par1) / 400;
}
/**
* Returns an integer between 0 and the passed value representing how much Use time is left on the current fuel
* item, where 0 means that the item is exhausted and the passed value means that the item is fresh
*/
public int getUseTimeRemainingScaled(int par1)
{
if (currentItemUseTime == 0)
{
currentItemUseTime = 400;
}
return (PurifierUseTime * par1) / currentItemUseTime;
}
/**
* Returns true if the Purifier is currently Useing
*/
public boolean isUseing()
{
return PurifierUseTime > 0;
}
/**
* Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
* ticks and creates a new spawn inside its implementation.
*/
public void updateEntity()
{
boolean flag = PurifierUseTime > 0;
boolean flag1 = false;
if (PurifierUseTime > 0)
{
PurifierUseTime--;
}
if (!worldObj.isRemote)
{
if (PurifierUseTime == 0 && canSmelt())
{
currentItemUseTime = PurifierUseTime = getItemUseTime(PurifierItemStacks[1]);
if (PurifierUseTime > 0)
{
flag1 = true;
if (PurifierItemStacks[1] != null)
{
if (PurifierItemStacks[1].getItem().func_46056_k())
{
PurifierItemStacks[1] = new ItemStack(PurifierItemStacks[1].getItem().setFull3D());
}
else
{
PurifierItemStacks[1].stackSize--;
}
if (PurifierItemStacks[1].stackSize == 0)
{
PurifierItemStacks[1] = null;
}
}
}
}
if (isUseing() && canSmelt())
{
PurifierPureTime++;
if (PurifierPureTime == 400)
{
PurifierPureTime = 0;
smeltItem();
flag1 = true;
}
}
else
{
PurifierPureTime = 0;
}
if (flag != (PurifierUseTime > 0))
{
flag1 = true;
EmundiasPurifier.updatePurifierBlockState(PurifierUseTime > 0, worldObj, xCoord, yCoord, zCoord);
}
}
if (flag1)
{
onInventoryChanged();
}
}
/**
* Returns true if the Purifier can smelt an item, i.e. has a source item, destination stack isn't full, etc.
*/
private boolean canSmelt()
{
if (PurifierItemStacks[0] == null)
{
return false;
}
ItemStack itemstack = PurifierRecipes.Purify().getPurifyResult(PurifierItemStacks[0].getItem().shiftedIndex);
if (itemstack == null)
{
return false;
}
if (PurifierItemStacks[2] == null)
{
return true;
}
if (!PurifierItemStacks[2].isItemEqual(itemstack))
{
return false;
}
if (PurifierItemStacks[2].stackSize < getInventoryStackLimit() && PurifierItemStacks[2].stackSize < PurifierItemStacks[2].getMaxStackSize())
{
return true;
}
return PurifierItemStacks[2].stackSize < itemstack.getMaxStackSize();
}
/**
* Turn one item from the Purifier source stack into the appropriate smelted item in the Purifier result stack
*/
public void smeltItem()
{
if (!canSmelt())
{
return;
}
ItemStack itemstack = PurifierRecipes.Purify().getPurifyResult(PurifierItemStacks[0].getItem().shiftedIndex);
if (PurifierItemStacks[2] == null)
{
PurifierItemStacks[2] = itemstack.copy();
}
else if (PurifierItemStacks[2].itemID == itemstack.itemID)
{
PurifierItemStacks[2].stackSize += itemstack.stackSize;
}
if (PurifierItemStacks[0].getItem().func_46056_k())
{
PurifierItemStacks[0] = new ItemStack(PurifierItemStacks[0].getItem().setFull3D());
}
else
{
PurifierItemStacks[0].stackSize--;
}
if (PurifierItemStacks[0].stackSize <= 0)
{
PurifierItemStacks[0] = null;
}
}
/**
* Returns the number of ticks that the supplied fuel item will keep the Purifier Useing, or 0 if the item isn't
* fuel
*/
public static int getItemUseTime(ItemStack par1ItemStack)
{
if (par1ItemStack == null)
{
return 0;
}
int i = par1ItemStack.getItem().shiftedIndex;
if (i == mod_SoulCraftItems.SOrb.shiftedIndex)
{
return 1600;
}
if (i == mod_SoulCraftItems.HolyFuel.shiftedIndex)
{
return 6400;
}
else
{
return 0;// ModLoader.addAllFuel(par1ItemStack.itemID, par1ItemStack.getItemDamage());
}
}
public static boolean func_52005_b(ItemStack par0ItemStack)
{
return getItemUseTime(par0ItemStack) > 0;
}
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*/
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
{
if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this)
{
return false;
}
return par1EntityPlayer.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64D;
}
public void openChest()
{
}
public void closeChest()
{
}
}
EDIT: I have looked online and there is no tutorial about this, it isn't explained in your tutorial and it seems that furnace tutorials are rare, especially ones that explain in depth how to use many of the functions that are already in vanilla. I would like a response please.
EDIT 2: Purifier1 is the texture for the furnace while it is turned on, Purifier1a is while it is off. I have a texture for the top of the furnace for when it is on as well, except obviously didn't know what to do with it.
The items in the output slot will not stack. When the new furnace smelts an item when there is already an item in the output slot, the newly smelted item dissapears and isn't added to the item stack. These items normally stack in the inventory, so I'm not seeing the issue.
Do you know what could be causing this?
Also, do you know how to make it so that if you are say, smelting a bucket of water, the actual bucket is not smelted along with the water?
Thank you for all your help.
Can you make a furnace tutorial with a top?
Hey is there a way to update the furnace's light value without a new block id? I tried this and used the tile entity to store the light value, but the light value function seems to get updated randomly. Is there a way to fix this?
Just out of curiosity, do you have severe OCD?
-Nicolas Negroponte
Oh I found out a way on how to do it using the Tile Entity. Also apparently it doesn't update the light value when you do this:
But it does when you do this:
Ya, I'm trying to make a furnace but the same thing happens to me. Stupid furnace doesn't like me.
However, I ran into an issue when I moved everything to use Forge (for the extended sprite indexes) - in the Forge version (where the code for the furnace files is identical to the non-Forge version), I crash when I try to open the GUI ... Do you have any idea why that is?
I've started a thread with the error codes here.
Thanks for the amazing tutorials and keep up the good work. If you have any thoughts as to why using Forge means it doesn't work, then it would be very much appreciated!
Thanks
Eriotto
I am looking for assistance with my custom gui. It is working fine, except for when I open it in game. It just gives me a big block saying MISSING as the texture. If I move my mouse around I can find the slots. This is an issue with the texturing. It is looking for the texture in /gui/furnace.png. Halp?!
Using this i managed to make a furnace with 10 inputs (1 fuel, 9 resource) and 2 outputs! Awesome!
I would love it if you made more tuts
@Eriottosan Mine uses forge to, but it works perfectly, i don't know what your problem could be, sorry
The error I get:
ContainerCokeoven.java
I'd appreciate if anyone knew what this error could be caused by.
Block
Tile Entity
EDIT: I have looked online and there is no tutorial about this, it isn't explained in your tutorial and it seems that furnace tutorials are rare, especially ones that explain in depth how to use many of the functions that are already in vanilla. I would like a response please.
EDIT 2: Purifier1 is the texture for the furnace while it is turned on, Purifier1a is while it is off. I have a texture for the top of the furnace for when it is on as well, except obviously didn't know what to do with it.
Hey! Check out my Zelda Adventure map above!