• 0

    posted a message on Custom furnace source code?
    I'm working on a custom furnace in forge and have asked for help before but I still can't seem to figure it out. If someone would be so kind as to post some source code for a simple custom furnace without any special features or anything that I could use as a reference, I would be very happy. I will not copy this code, just compare it to mine to see what I did wrong.
    Posted in: Modification Development
  • 0

    posted a message on Cubeaism - A Minecraft Religion
    Cool idea! One thing that's bugging me, "prodigy’s" isn't possessive, so it should be spelled prodigies.
    Posted in: Discussion
  • 0

    posted a message on [1.4.5][Forge] Container-Based Gui Tutorial
    Fixed the tags. And no error, I just can't get my gui to open, when I right click, it plays the hit anim but does nothing.
    Posted in: Tutorials
  • 0

    posted a message on [1.4.5][Forge] Container-Based Gui Tutorial
    Quote from drinfernoo

    It shouldn't matter that your package is different, as long as your imports are all good. It sort of looks like you have the method defined twice, or possibly it isn't overriding it for some reason...

    Any way you could post your code, or link to it? If you post it, please use code tags and spoilers.


    Well, I sort of gave up on that and I'm trying a hybrid approach, I changed everything to the furnace code but now I'm having trouble getting my gui to open. The furnace also switches to the actual furnace and disregards my code when I start to smelt something. Here's my code (I have to import everything for some reason, not bad, just annoying):
    TheBlock

    package tutorials;
    
    import java.util.Random;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockContainer;
    import net.minecraft.block.material.Material;
    import net.minecraft.entity.EntityLiving;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.tileentity.TileEntityFurnace;
    import net.minecraft.util.MathHelper;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    
    public class TheBlock extends BlockContainer
    {
    /**
    * Is the random generator used by furnace to drop the inventory contents in random directions.
    */
    private Random furnaceRand = new Random();
    
    /** True if this is an active furnace, false if idle */
    private final boolean isActive;
    
    /**
    * This flag is used to prevent the furnace inventory to be dropped upon block removal, is used internally when the
    * furnace block changes from idle to active and vice-versa.
    */
    private static boolean keepFurnaceInventory = false;
    
    protected TheBlock(int par1, boolean par2)
    {
    super(par1, Material.rock);
    this.isActive = par2;
    this.blockIndexInTexture = 45;
    }
    
    /**
    * Returns the ID of the items to drop on destruction.
    */
    public int idDropped(int par1, Random par2Random, int par3)
    {
    return TutorialMod.tutorialBlock.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);
    this.setDefaultDirection(par1World, par2, par3, par4);
    }
    
    /**
    * set a blocks direction
    */
    private void setDefaultDirection(World par1World, int par2, int par3, int par4)
    {
    if (!par1World.isRemote)
    {
    int var5 = par1World.getBlockId(par2, par3, par4 - 1);
    int var6 = par1World.getBlockId(par2, par3, par4 + 1);
    int var7 = par1World.getBlockId(par2 - 1, par3, par4);
    int var8 = par1World.getBlockId(par2 + 1, par3, par4);
    byte var9 = 3;
    
    if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
    {
    var9 = 3;
    }
    
    if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
    {
    var9 = 2;
    }
    
    if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
    {
    var9 = 5;
    }
    
    if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
    {
    var9 = 4;
    }
    
    par1World.setBlockMetadataWithNotify(par2, par3, par4, var9);
    }
    }
    
    @SideOnly(Side.CLIENT)
    
    /**
    * 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 this.blockIndexInTexture + 17;
    }
    else if (par5 == 0)
    {
    return this.blockIndexInTexture + 17;
    }
    else
    {
    int var6 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
    return par5 != var6 ? this.blockIndexInTexture : (this.isActive ? this.blockIndexInTexture + 16 : this.blockIndexInTexture - 1);
    }
    }
    
    @SideOnly(Side.CLIENT)
    
    /**
    * 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 (this.isActive)
    {
    int var6 = par1World.getBlockMetadata(par2, par3, par4);
    float var7 = (float)par2 + 0.5F;
    float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
    float var9 = (float)par4 + 0.5F;
    float var10 = 0.52F;
    float var11 = par5Random.nextFloat() * 0.6F - 0.3F;
    
    if (var6 == 4)
    {
    par1World.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
    par1World.spawnParticle("flame", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
    }
    else if (var6 == 5)
    {
    par1World.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
    par1World.spawnParticle("flame", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
    }
    else if (var6 == 2)
    {
    par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
    par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
    }
    else if (var6 == 3)
    {
    par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
    par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
    }
    }
    }
    
    /**
    * Returns the block texture based on the side being looked at. Args: side
    */
    public int getBlockTextureFromSide(int par1)
    {
    return par1 == 1 ? this.blockIndexInTexture + 17 : (par1 == 0 ? this.blockIndexInTexture + 17 : (par1 == 3 ? this.blockIndexInTexture - 1 : this.blockIndexInTexture));
    }
    
    /**
    * Called upon block activation (right click on the block.)
    */
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float g, float t){
    // Just making an instance of the TileEntity that the player clicked on
    TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
    
    // Checking if the TileEntity is nothing or if the player is sneaking
    if(tile_entity == null || player.isSneaking()){
    // Returns false so it doesn't update anything
    return false;
    }
    // opens the UI if the later is not met, the method player.openGui() has 6 params
    // @param TutorialMod.instance, is just the instance of the TutorialMod
    // @param 0, this is the UI id, this can be changed in the GUI handler, and will open a different UI if chosen to do so
    // @param x, y, z, the players current player x, y, z coords
    player.openGui(TutorialMod.instance, 0, world, x, y, z);
    // Returns true to force an update
    return true;
    }
    
    /**
    * Update which block ID the furnace is using depending on whether or not it is burning
    */
    public static void updateFurnaceBlockState(boolean par0, World par1World, int par2, int par3, int par4)
    {
    int var5 = par1World.getBlockMetadata(par2, par3, par4);
    TileEntity var6 = par1World.getBlockTileEntity(par2, par3, par4);
    keepFurnaceInventory = true;
    
    
    
    keepFurnaceInventory = false;
    par1World.setBlockMetadataWithNotify(par2, par3, par4, var5);
    
    if (var6 != null)
    {
    var6.validate();
    par1World.setBlockTileEntity(par2, par3, par4, var6);
    }
    }
    
    /**
    * Returns a new instance of a block's tile entity class. Called on placing the block.
    */
    public TileEntity createNewTileEntity(World par1World)
    {
    return new TileEntityFurnace();
    }
    
    /**
    * Called when the block is placed in the world.
    */
    public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
    {
    int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    
    if (var6 == 0)
    {
    par1World.setBlockMetadataWithNotify(par2, par3, par4, 2);
    }
    
    if (var6 == 1)
    {
    par1World.setBlockMetadataWithNotify(par2, par3, par4, 5);
    }
    
    if (var6 == 2)
    {
    par1World.setBlockMetadataWithNotify(par2, par3, par4, 3);
    }
    
    if (var6 == 3)
    {
    par1World.setBlockMetadataWithNotify(par2, par3, par4, 4);
    }
    }
    
    /**
    * ejects contained items into the world, and notifies neighbours of an update, as appropriate
    */
    public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
    {
    if (!keepFurnaceInventory)
    {
    TileEntityFurnace var7 = (TileEntityFurnace)par1World.getBlockTileEntity(par2, par3, par4);
    
    if (var7 != null)
    {
    for (int var8 = 0; var8 < var7.getSizeInventory(); ++var8)
    {
    ItemStack var9 = var7.getStackInSlot(var8);
    
    if (var9 != null)
    {
    float var10 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
    float var11 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
    float var12 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
    
    while (var9.stackSize > 0)
    {
    int var13 = this.furnaceRand.nextInt(21) + 10;
    
    if (var13 > var9.stackSize)
    {
    var13 = var9.stackSize;
    }
    
    var9.stackSize -= var13;
    EntityItem var14 = new EntityItem(par1World, (double)((float)par2 + var10), (double)((float)par3 + var11), (double)((float)par4 + var12), new ItemStack(var9.itemID, var13, var9.getItemDamage()));
    
    if (var9.hasTagCompound())
    {
    var14.func_92014_d().setTagCompound((NBTTagCompound)var9.getTagCompound().copy());
    }
    
    float var15 = 0.05F;
    var14.motionX = (double)((float)this.furnaceRand.nextGaussian() * var15);
    var14.motionY = (double)((float)this.furnaceRand.nextGaussian() * var15 + 0.2F);
    var14.motionZ = (double)((float)this.furnaceRand.nextGaussian() * var15);
    par1World.spawnEntityInWorld(var14);
    }
    }
    }
    }
    }
    
    super.breakBlock(par1World, par2, par3, par4, par5, par6);
    }
    }


    TutorialMod

    package tutorials;
    
    import net.minecraft.block.Block;
    import net.minecraft.item.ItemStack;
    import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.Mod.Init;
    import cpw.mods.fml.common.Mod.Instance;
    import cpw.mods.fml.common.SidedProxy;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.network.NetworkMod;
    import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
    import cpw.mods.fml.common.network.NetworkRegistry;
    import cpw.mods.fml.common.registry.GameRegistry;
    import cpw.mods.fml.common.registry.LanguageRegistry;
    
    
    @Mod(modid = "mod", name = "The Tutorial Mod", version = "0.0")
    
    @NetworkMod(clientSideRequired=true, serverSideRequired=false, clientPacketHandlerSpec = @SidedPacketHandler(channels = {"TutorialMod" }, packetHandler = ClientPacketHandler.class),
    serverPacketHandlerSpec =@SidedPacketHandler(channels = {"TutorialMod" }, packetHandler = ServerPacketHandler.class))
    
    public class TutorialMod {
    
    @Instance
    public static TutorialMod instance = new TutorialMod();
    
    private GuiHandler guiHandler = new GuiHandler();
    
    public static Block tutorialBlock;
    
    
    
    @SidedProxy(clientSide = "tutorials.ClientProxy", serverSide = "tutorials.CommonProxy")
    public static CommonProxy proxy;
    
    @Init
    public void load(FMLInitializationEvent event){
    
    tutorialBlock = new TheBlock(243, false).setBlockName("blockTutorial");
    
    
    GameRegistry.registerTileEntity(TileTutorial.class, "tileEntityTutorial");
    
    
    GameRegistry.registerBlock(tutorialBlock);
    
    
    
    
    GameRegistry.addRecipe(new ItemStack(this.tutorialBlock, 1), new Object[]{
    " ", " X ", " ", Character.valueOf('X'), Block.obsidian
    });
    
    
    proxy.registerRenderThings();
    LanguageRegistry.addName(tutorialBlock, "Tutorial Block");
    NetworkRegistry.instance().registerGuiHandler(this, guiHandler);
    }
    
    }


    TileTutorial

    package tutorials;
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockFurnace;
    import net.minecraft.block.material.Material;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemBlock;
    import net.minecraft.item.ItemHoe;
    import net.minecraft.item.ItemStack;
    import net.minecraft.item.ItemSword;
    import net.minecraft.item.ItemTool;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.item.crafting.FurnaceRecipes;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.nbt.NBTTagList;
    import net.minecraftforge.common.ForgeDirection;
    import net.minecraftforge.common.ISidedInventory;
    import cpw.mods.fml.common.registry.GameRegistry;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    
    public class TileTutorial extends TileEntity implements IInventory, ISidedInventory
    {
    /**
    * The ItemStacks that hold the items currently being used in the furnace
    */
    private ItemStack[] furnaceItemStacks = new ItemStack[3];
    
    /** The number of ticks that the furnace will keep burning */
    public int furnaceBurnTime = 0;
    
    /**
    * The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
    */
    public int currentItemBurnTime = 0;
    
    /** The number of ticks that the current item has been cooking for */
    public int furnaceCookTime = 0;
    
    /**
    * Returns the number of slots in the inventory.
    */
    public int getSizeInventory()
    {
    return this.furnaceItemStacks.length;
    }
    
    /**
    * Returns the stack in slot i
    */
    public ItemStack getStackInSlot(int par1)
    {
    return this.furnaceItemStacks[par1];
    }
    
    /**
    * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
    * new stack.
    */
    public ItemStack decrStackSize(int par1, int par2)
    {
    if (this.furnaceItemStacks[par1] != null)
    {
    ItemStack var3;
    
    if (this.furnaceItemStacks[par1].stackSize <= par2)
    {
    var3 = this.furnaceItemStacks[par1];
    this.furnaceItemStacks[par1] = null;
    return var3;
    }
    else
    {
    var3 = this.furnaceItemStacks[par1].splitStack(par2);
    
    if (this.furnaceItemStacks[par1].stackSize == 0)
    {
    this.furnaceItemStacks[par1] = null;
    }
    
    return var3;
    }
    }
    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 (this.furnaceItemStacks[par1] != null)
    {
    ItemStack var2 = this.furnaceItemStacks[par1];
    this.furnaceItemStacks[par1] = null;
    return var2;
    }
    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)
    {
    this.furnaceItemStacks[par1] = par2ItemStack;
    
    if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
    {
    par2ItemStack.stackSize = this.getInventoryStackLimit();
    }
    }
    
    /**
    * Returns the name of the inventory.
    */
    public String getInvName()
    {
    return "container.furnace";
    }
    
    /**
    * Reads a tile entity from NBT.
    */
    public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    {
    super.readFromNBT(par1NBTTagCompound);
    NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
    this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];
    
    for (int var3 = 0; var3 < var2.tagCount(); ++var3)
    {
    NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
    byte var5 = var4.getByte("Slot");
    
    if (var5 >= 0 && var5 < this.furnaceItemStacks.length)
    {
    this.furnaceItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
    }
    }
    
    this.furnaceBurnTime = par1NBTTagCompound.getShort("BurnTime");
    this.furnaceCookTime = par1NBTTagCompound.getShort("CookTime");
    this.currentItemBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);
    }
    
    /**
    * Writes a tile entity to NBT.
    */
    public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    {
    super.writeToNBT(par1NBTTagCompound);
    par1NBTTagCompound.setShort("BurnTime", (short)this.furnaceBurnTime);
    par1NBTTagCompound.setShort("CookTime", (short)this.furnaceCookTime);
    NBTTagList var2 = new NBTTagList();
    
    for (int var3 = 0; var3 < this.furnaceItemStacks.length; ++var3)
    {
    if (this.furnaceItemStacks[var3] != null)
    {
    NBTTagCompound var4 = new NBTTagCompound();
    var4.setByte("Slot", (byte)var3);
    this.furnaceItemStacks[var3].writeToNBT(var4);
    var2.appendTag(var4);
    }
    }
    
    par1NBTTagCompound.setTag("Items", var2);
    }
    
    /**
    * 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;
    }
    
    @SideOnly(Side.CLIENT)
    
    /**
    * Returns an integer between 0 and the passed value representing how close the current item is to being completely
    * cooked
    */
    public int getCookProgressScaled(int par1)
    {
    return this.furnaceCookTime * par1 / 200;
    }
    
    @SideOnly(Side.CLIENT)
    
    /**
    * Returns an integer between 0 and the passed value representing how much burn 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 getBurnTimeRemainingScaled(int par1)
    {
    if (this.currentItemBurnTime == 0)
    {
    this.currentItemBurnTime = 200;
    }
    
    return this.furnaceBurnTime * par1 / this.currentItemBurnTime;
    }
    
    /**
    * Returns true if the furnace is currently burning
    */
    public boolean isBurning()
    {
    return this.furnaceBurnTime > 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 var1 = this.furnaceBurnTime > 0;
    boolean var2 = false;
    
    if (this.furnaceBurnTime > 0)
    {
    --this.furnaceBurnTime;
    }
    
    if (!this.worldObj.isRemote)
    {
    if (this.furnaceBurnTime == 0 && this.canSmelt())
    {
    this.currentItemBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);
    
    if (this.furnaceBurnTime > 0)
    {
    var2 = true;
    
    if (this.furnaceItemStacks[1] != null)
    {
    --this.furnaceItemStacks[1].stackSize;
    
    if (this.furnaceItemStacks[1].stackSize == 0)
    {
    this.furnaceItemStacks[1] = this.furnaceItemStacks[1].getItem().getContainerItemStack(furnaceItemStacks[1]);
    }
    }
    }
    }
    
    if (this.isBurning() && this.canSmelt())
    {
    ++this.furnaceCookTime;
    
    if (this.furnaceCookTime == 200)
    {
    this.furnaceCookTime = 0;
    this.smeltItem();
    var2 = true;
    }
    }
    else
    {
    this.furnaceCookTime = 0;
    }
    
    if (var1 != this.furnaceBurnTime > 0)
    {
    var2 = true;
    //TheBlock.updateFurnaceBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
    }
    }
    
    if (var2)
    {
    this.onInventoryChanged();
    }
    }
    
    /**
    * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
    */
    private boolean canSmelt()
    {
    if (this.furnaceItemStacks[0] == null)
    {
    return false;
    }
    else
    {
    ItemStack var1 = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
    if (var1 == null) return false;
    if (this.furnaceItemStacks[2] == null) return true;
    if (!this.furnaceItemStacks[2].isItemEqual(var1)) return false;
    int result = furnaceItemStacks[2].stackSize + var1.stackSize;
    return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize());
    }
    }
    
    /**
    * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
    */
    public void smeltItem()
    {
    if (this.canSmelt())
    {
    ItemStack var1 = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
    
    if (this.furnaceItemStacks[2] == null)
    {
    this.furnaceItemStacks[2] = var1.copy();
    }
    else if (this.furnaceItemStacks[2].isItemEqual(var1))
    {
    furnaceItemStacks[2].stackSize += var1.stackSize;
    }
    
    --this.furnaceItemStacks[0].stackSize;
    
    if (this.furnaceItemStacks[0].stackSize <= 0)
    {
    this.furnaceItemStacks[0] = null;
    }
    }
    }
    
    /**
    * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
    * fuel
    */
    public static int getItemBurnTime(ItemStack par0ItemStack)
    {
    if (par0ItemStack == null)
    {
    return 0;
    }
    else
    {
    int var1 = par0ItemStack.getItem().shiftedIndex;
    Item var2 = par0ItemStack.getItem();
    
    if (par0ItemStack.getItem() instanceof ItemBlock && Block.blocksList[var1] != null)
    {
    Block var3 = Block.blocksList[var1];
    
    if (var3 == Block.woodSingleSlab)
    {
    return 150;
    }
    
    if (var3.blockMaterial == Material.wood)
    {
    return 300;
    }
    }
    
    if (var2 instanceof ItemTool && ((ItemTool) var2).getToolMaterialName().equals("WOOD")) return 200;
    if (var2 instanceof ItemSword && ((ItemSword) var2).func_77825_f().equals("WOOD")) return 200;
    if (var2 instanceof ItemHoe && ((ItemHoe) var2).func_77842_f().equals("WOOD")) return 200;
    if (var1 == Item.stick.shiftedIndex) return 100;
    if (var1 == Item.coal.shiftedIndex) return 1600;
    if (var1 == Item.bucketLava.shiftedIndex) return 20000;
    if (var1 == Block.sapling.blockID) return 100;
    if (var1 == Item.blazeRod.shiftedIndex) return 2400;
    return GameRegistry.getFuelValue(par0ItemStack);
    }
    }
    
    /**
    * Return true if item is a fuel source (getItemBurnTime() > 0).
    */
    public static boolean isItemFuel(ItemStack par0ItemStack)
    {
    return getItemBurnTime(par0ItemStack) > 0;
    }
    
    /**
    * Do not make give this method the name canInteractWith because it clashes with Container
    */
    public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
    {
    return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
    }
    
    public void openChest() {}
    
    public void closeChest() {}
    
    @Override
    public int getStartInventorySide(ForgeDirection side)
    {
    if (side == ForgeDirection.DOWN) return 1;
    if (side == ForgeDirection.UP) return 0;
    return 2;
    }
    
    @Override
    public int getSizeInventorySide(ForgeDirection side)
    {
    return 1;
    }
    }


    GuiHandler

    // This is my package declaration, do not mess with the standard (package net.minecraft.src;) like I did,
    // Because I know what Im doing in this part, If you don't know what your doing keep it the normal (package net.minecraft.src;)
    package tutorials;
    
    // These are all the imports you will need
    import cpw.mods.fml.common.network.IGuiHandler;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.src.*;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.world.World;
    
    // Create a class and implement IGuiHandler
    public class GuiHandler implements IGuiHandler{
    // This is a required method to open you Gui and has 6 params
    // @param int id, this is the Gui Id
    // @param EntityPlayer, this is the player declaration
    // @param World, this is the world declaration
    // @param int x, y, z this is the players current x, y, z coords
    @Override
    public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z){
    // This gets the TileEntity the player is currently activating
    TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
    // This checks if the TileEntity is the TileTutorial
    if(tile_entity instanceof TileTutorial){
    // If it is it returns a new ContainerTutorial instance
    return new ContainerTutorial(player.inventory, (TileTutorial) tile_entity);
    }
    
    // Returns null if not
    return null;
    }
    
    // This is another required method to open the Gui and has 6 params
    // @param int id, this is the Gui Id
    // @param EntityPlayer, this is the player declaration
    // @param World, this is the world declaration,
    // @param int x, y, z this is the players current x, y, z coords
    @Override
    public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z){
    // This gets the TIleEntity the player is currently activating
    TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
    
    // This checks if the TileEntity is the TileTutorial
    if(tile_entity instanceof TileTutorial){
    // If it is it returns a new GuiTutorial instance
    return new GuiTutorial(player.inventory, (TileTutorial) tile_entity);
    }
    
    // Returns null if not
    return null;
    }
    }


    GuiTutorial


    package tutorials;
    
    import net.minecraft.client.gui.inventory.GuiContainer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.inventory.ContainerFurnace;
    import net.minecraft.tileentity.TileEntityFurnace;
    import net.minecraft.util.StatCollector;
    
    import org.lwjgl.opengl.GL11;
    
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    
    @SideOnly(Side.CLIENT)
    public class GuiTutorial extends GuiContainer
    {
    private TileTutorial furnaceInventory;
    
    public GuiTutorial(InventoryPlayer par1InventoryPlayer, TileTutorial par2TileEntityFurnace)
    {
    super(new ContainerTutorial(par1InventoryPlayer, par2TileEntityFurnace));
    this.furnaceInventory = par2TileEntityFurnace;
    }
    
    /**
    * Draw the foreground layer for the GuiContainer (everything in front of the items)
    */
    protected void drawGuiContainerForegroundLayer(int par1, int par2)
    {
    //this.fontRenderer.drawString(StatCollector.translateToLocal("container.furnace"), 60, 6, 4210752);
    //this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
    }
    
    /**
    * Draw the background layer for the GuiContainer (everything behind the items)
    */
    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
    {
    int var4 = this.mc.renderEngine.getTexture("/gui/furnace.png");
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    this.mc.renderEngine.bindTexture(var4);
    int var5 = (this.width - this.xSize) / 2;
    int var6 = (this.height - this.ySize) / 2;
    this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
    int var7;
    
    if (this.furnaceInventory.isBurning())
    {
    var7 = this.furnaceInventory.getBurnTimeRemainingScaled(12);
    this.drawTexturedModalRect(var5 + 56, var6 + 36 + 12 - var7, 176, 12 - var7, 14, var7 + 2);
    }
    
    var7 = this.furnaceInventory.getCookProgressScaled(24);
    this.drawTexturedModalRect(var5 + 79, var6 + 34, 176, 14, var7 + 1, 16);
    }
    }



    Thanks for the help!
    Posted in: Tutorials
  • 0

    posted a message on [1.4.5][Forge] Container-Based Gui Tutorial
    Sorry for the late post, but I have an issue with a part of the code:

    This line:
    public boolean isUseableByPlayer(EntityPlayer player){

    gets this error in eclipse:


    Multiple markers at this line
    - implements net.minecraft.inventory.IInventory.isUseableByPlayer
    - Duplicate method isUseableByPlayer(EntityPlayer) in type
    TileEntityBoiler


    Any ideas?

    My package is
    package flaxbeard.steamcraft.common:
    does that matter?
    Posted in: Tutorials
  • 0

    posted a message on Mob not spawning?
    Quote from Ravenclaw572

    This sounds weird, but make a hole, try to spawn your creature, and shoot at it with a bow. If it drops, I had the same error with Forge earlier, and if not, sorry, I have no idea.
    No luck
    Posted in: Modification Development
  • 0

    posted a message on Mob not spawning?
    Quote from Ravenclaw572

    Are there any errors? I may be able to help if there are any. I had trouble with entities too in 1.3.2.
    I did see this in the code:
    /**
    * How large the spider should be scaled.
    */
    public float spiderScaleAmount()
    {
    return 1.0F;
    }

    No idea as to what that does, but it could cause it to get two render sizes and make it not work.

    no errors, worked fine in 1.4.5, I didn'tt change a thing.
    Posted in: Modification Development
  • 0

    posted a message on Mob not spawning?
    I had made a hedgehog mod for 1.4.5 and it worked fine. When I updated to 1.4.6, it stopped spawning and the spawn egg does nothing. Here's my code:

    mod_Hedgehog

    package net.minecraft.src;
    import java.util.Map;
    import java.awt.Color;
    public class mod_Hedgehog extends BaseMod{
    @Override
    public String getVersion() {
    return "1.4.5";
    }
    
    public void addRenderer(Map map)
    {
    map.put(EntityHedgehog.class, new RenderHedgehog(new ModelHedgehog(), 0.5F));
    }
    
    @Override
    public void load() {
    ModLoader.registerEntityID(EntityHedgehog.class, "Hedgehog",-58, 0xA68064, 0x545454);
    
    ModLoader.addSpawn(EntityHedgehog.class, 50, 12, 15, EnumCreatureType.creature);
    ModLoader.addLocalization("entity.Hedgehog.name", "Hedgehog");//adds Mob name on the spawn egg
    
    }
    }



    EntityHedgehog


    package net.minecraft.src;
    
    public class EntityHedgehog extends EntityMob
    {
    public EntityHedgehog(World par1World)
    {
    super(par1World);
    this.texture = "/hedgehog/Hedgehog.png";
    this.setSize(0.2F, 0.5F);
    this.moveSpeed = 0.25F;
    }
    
    protected void entityInit()
    {
    super.entityInit();
    this.dataWatcher.addObject(16, new Byte((byte)0));
    }
    
    /**
    * Called to update the entity's position/logic.
    */
    public void onUpdate()
    {
    super.onUpdate();
    
    if (!this.worldObj.isRemote)
    {
    this.setBesideClimbableBlock(this.isCollidedHorizontally);
    }
    }
    
    public int getMaxHealth()
    {
    return 999999;
    }
    
    /**
    * Returns the Y offset from the entity's position for any entity riding this one.
    */
    public double getMountedYOffset()
    {
    return (double)this.height * 0.75D - 0.5D;
    }
    
    /**
    * Finds the closest player within 16 blocks to attack, or null if this Entity isn't interested in attacking
    * (Animals, Spiders at day, peaceful PigZombies).
    */
    protected Entity findPlayerToAttack()
    {
    
    double var2 = 0.5D;
    return this.worldObj.getClosestVulnerablePlayerToEntity(this, var2);
    
    }
    
    /**
    * Returns the sound this mob makes while it's alive.
    */
    protected String getLivingSound()
    {
    return null;
    }
    
    /**
    * Returns the sound this mob makes when it is hurt.
    */
    protected String getHurtSound()
    {
    return null;
    }
    
    /**
    * Returns the sound this mob makes on death.
    */
    protected String getDeathSound()
    {
    return null;
    }
    
    /**
    * Plays step sound at given x, y, z for the entity
    */
    protected void playStepSound(int par1, int par2, int par3, int par4)
    {
    
    }
    
    /**
    * Basic mob attack. Default to touch of death in EntityCreature. Overridden by each mob to define their attack.
    */
    protected void attackEntity(Entity par1Entity, float par2)
    {
    
    EntityPlayer var1 = this.worldObj.getClosestVulnerablePlayerToEntity(this, 1.0D);
    if (var1==null)
    {
    this.entityToAttack = null;
    
    }
    else
    {
    super.attackEntity(par1Entity, par2);
    }
    
    }
    
    
    
    /**
    * Returns the item ID for the item the mob drops on death.
    */
    protected int getDropItemId()
    {
    return -1;
    }
    
    /**
    * Drop 0-2 items of this living's type
    */
    protected void dropFewItems(boolean par1, int par2)
    {
    super.dropFewItems(par1, par2);
    
    
    }
    
    /**
    * returns true if this entity is by a ladder, false otherwise
    */
    public boolean isOnLadder()
    {
    return this.isBesideClimbableBlock();
    }
    
    /**
    * Sets the Entity inside a web block.
    */
    public void setInWeb() {}
    
    /**
    * How large the spider should be scaled.
    */
    public float spiderScaleAmount()
    {
    return 1.0F;
    }
    
    /**
    * Get this Entity's EnumCreatureAttribute
    */
    
    
    
    /**
    * Returns true if the WatchableObject (Byte) is 0x01 otherwise returns false. The WatchableObject is updated using
    * setBesideClimableBlock.
    */
    public boolean isBesideClimbableBlock()
    {
    return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0;
    }
    
    /**
    * Updates the WatchableObject (Byte) created in entityInit(), setting it to 0x01 if par1 is true or 0x00 if it is
    * false.
    */
    public void setBesideClimbableBlock(boolean par1)
    {
    byte var2 = this.dataWatcher.getWatchableObjectByte(16);
    
    if (par1)
    {
    var2 = (byte)(var2 | 1);
    }
    else
    {
    var2 &= -2;
    }
    
    this.dataWatcher.updateObject(16, Byte.valueOf(var2));
    }
    
    /**
    * Initialize this creature.
    */
    public void initCreature()
    {
    
    }
    }


    RenderHedgehog


    package net.minecraft.src;
    
    public class RenderHedgehog extends RenderLiving
    {
    public RenderHedgehog(ModelBase par1ModelBase, float par2)
    {
    super(par1ModelBase, par2);
    }
    
    public void renderHedgehog(EntityHedgehog par1EntityHedgehog, double par2, double par4, double par6, float par8, float par9)
    {
    super.doRenderLiving(par1EntityHedgehog, par2, par4, par6, par8, par9);
    }
    
    public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)
    {
    this.renderHedgehog((EntityHedgehog)par1EntityLiving, par2, par4, par6, par8, par9);
    }
    
    /**
    * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
    * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
    * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
    * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
    */
    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
    this.renderHedgehog((EntityHedgehog)par1Entity, par2, par4, par6, par8, par9);
    }
    }



    ModelHedgehog


    // Date: 12/10/2012 6:54:06 AM
    // Template version 1.1
    // Java generated by Techne
    // Keep in mind that you still need to fill in some blanks
    // - ZeuX
    
    
    
    
    
    
    package net.minecraft.src;
    
    public class ModelHedgehog extends ModelBase
    {
    //fields
    ModelRenderer Body1;
    ModelRenderer Nose1;
    ModelRenderer Nose2;
    ModelRenderer Body2;
    ModelRenderer LegLF;
    ModelRenderer LegLB;
    ModelRenderer LegRF;
    ModelRenderer LegRB;
    
    public ModelHedgehog()
    {
    textureWidth = 32;
    textureHeight = 32;
    
    Body1 = new ModelRenderer(this, 0, 0);
    Body1.addBox(-2F, 0F, -2F, 4, 2, 5);
    Body1.setRotationPoint(0F, 21F, 0F);
    Body1.setTextureSize(32, 32);
    setRotation(Body1, 0F, 0F, 0F);
    Nose1 = new ModelRenderer(this, 0, 13);
    Nose1.addBox(-2F, 0F, -2F, 3, 2, 1);
    Nose1.setRotationPoint(0.5F, 20.5F, -1F);
    Nose1.setTextureSize(32, 32);
    setRotation(Nose1, 0F, 0F, 0F);
    Nose2 = new ModelRenderer(this, 0, 16);
    Nose2.addBox(-2F, 0F, -2F, 1, 1, 1);
    Nose2.setRotationPoint(1.5F, 21.5F, -2F);
    Nose2.setTextureSize(32, 32);
    setRotation(Nose2, 0F, 0F, 0F);
    Body2 = new ModelRenderer(this, 0, 7);
    Body2.addBox(-2F, 0F, -2F, 3, 1, 5);
    Body2.setRotationPoint(0.5F, 20F, 0F);
    Body2.setTextureSize(32, 32);
    setRotation(Body2, 0F, 0F, 0F);
    
    LegLF = new ModelRenderer(this, 21, 0);
    LegLF.addBox(0F, 0F, 0F, 1, 1, 1);
    LegLF.setRotationPoint(0.5F, 23F, -1.5F);
    LegLF.setTextureSize(32, 32);
    
    setRotation(LegLF, 0F, 0F, 0F);
    LegLB = new ModelRenderer(this, 21, 0);
    LegLB.addBox(0F, 0F, 0F, 1, 1, 1);
    LegLB.setRotationPoint(0.5F, 23F, 1.5F);
    LegLB.setTextureSize(32, 32);
    setRotation(LegLB, 0F, 0F, 0F);
    LegRF = new ModelRenderer(this, 21, 0);
    LegRF.addBox(0F, 0F, 0F, 1, 1, 1);
    LegRF.setRotationPoint(-1.5F, 23F, -1.5F);
    LegRF.setTextureSize(32, 32);
    setRotation(LegRF, 0F, 0F, 0F);
    LegRB = new ModelRenderer(this, 21, 0);
    LegRB.addBox(0F, 0F, 0F, 1, 1, 1);
    LegRB.setRotationPoint(-1.5F, 23F, 1.5F);
    LegRB.setTextureSize(32, 32);
    setRotation(LegRB, 0F, 0F, 0F);
    }
    
    public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
    {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5);
    Body1.render(f5);
    Nose1.render(f5);
    Nose2.render(f5);
    Body2.render(f5);
    LegLF.render(f5);
    LegLB.render(f5);
    LegRF.render(f5);
    LegRB.render(f5);
    }
    
    private void setRotation(ModelRenderer model, float x, float y, float z)
    {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
    }
    
    public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
    {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, null);
    LegLF.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.0F * f1;
    LegRF.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.0F * f1;
    LegRB.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.0F * f1;
    LegLB.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.0F * f1;
    }
    
    }


    Thanks in advance!
    Posted in: Modification Development
  • 0

    posted a message on Starting out with forge - Packages?
    Quote from RyanTheAllmighty

    With the new Minecraft Forge there is no longer a common folder

    All your packages will go into this folder

    mcp/src/minecraft

    Must they be called anything special?
    Posted in: Modification Development
  • 0

    posted a message on Starting out with forge - Packages?
    I've just started delving into forge, but how do I make a new package? I don't see a src/common directory? And I made that folder and made another folder like this guide told me:
    To help organize your mod files and keep them separate from vanilla Minecraft files, you can put them in their own package. Create a folder in MCP's src/common/ folder. For the purpose of this example, lets call it derp. If you did it right, the folder should now contain cpw, net, org, and derp.


    I don't see cpw, net, or org.
    Posted in: Modification Development
  • 0

    posted a message on Thaumcraft 3.0.5i (Outdated)
    Is there a way to regenerate vilalges to possibly add wizards?
    Posted in: Minecraft Mods
  • 0

    posted a message on Thaumcraft 3.0.5i (Outdated)
    There needs to be a better source of Aura. I've chopped up all my dead shrubs and my chicken farm...
    Posted in: Minecraft Mods
  • 0

    posted a message on Mob development?
    Sorry, alright, my response was uncalled for. Mob making is just uncharted territory for me. How the Minecraft source works is still confusing for me, not Java.
    Posted in: Modification Development
  • 0

    posted a message on Mob development?
    The mob egg isn't working for me, it just disappears when I use it.

    Also, how do you change shadow size?
    Posted in: Modification Development
  • 0

    posted a message on The Palette Project (Chroma Control In The Makings)
    Well, I'm no pro but I'd be happy to try to help. Your idea sounds interesting. Can you explain more about Chroma and what it will do?
    Posted in: Mods Discussion
  • To post a comment, please .