• 0

    posted a message on [Tutorial] Making Inventories
    Quote from 13BR3TT13

    I have these 6 errors, Any ideas?

    Error:

    == ERRORS FOUND ==

    src\minecraft\net\minecraft\src\ItemBackpack.java:12: illegal start of expressio
    n
    public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
    layer)
    ^

    src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
    public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
    layer)
    ^

    src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
    public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
    layer)
    ^

    src\minecraft\net\minecraft\src\ItemBackpack.java:12: not a statement
    public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
    layer)
    ^

    src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
    public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
    layer)
    ^

    src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
    public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
    layer)
    ^

    6 errors
    ==================

    > Done in 6.58 seconds
    > Recompiling server...
    !! Can not find server sources !!
    Press any key to continue . . .

    ItemBackpack.java
    package net.minecraft.src;

    public class ItemBackpack extends Item{

    private HashMap<ItemStack, InventoryBackpack> inv;

    protected ItemBackpack(int ID) {
    super(ID);
    maxStackSize=1;
    inv = new HashMap<ItemStack, InventoryBackpack>();

    public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityplayer)
    {
    entityplayer.displayGUIChest(inv.get(itemstack));
    return itemstack;
    }
    }
    }

    InventoryBackpack.java
    package net.minecraft.src;

    public class InventoryBackpack implements IInventory
    {

    public InventoryBackpack()
    {
    packContents = new ItemStack[36];
    }

    public int getSizeInventory()
    {
    return 27;
    }

    public boolean canInteractWith(EntityPlayer entityplayer)
    {
    return !entityplayer.isDead;
    }

    public void onInventoryChanged()
    {
    }

    public ItemStack getStackInSlot(int i)
    {
    return packContents[i];
    }

    public ItemStack decrStackSize(int i, int j)
    {
    if(packContents[i] != null)
    {
    if(packContents[i].stackSize <= j)
    {
    ItemStack itemstack = packContents[i];
    packContents[i] = null;
    onInventoryChanged();
    return itemstack;
    }
    ItemStack itemstack1 = packContents[i].splitStack(j);
    if(packContents[i].stackSize == 0)
    {
    packContents[i] = null;
    }
    onInventoryChanged();
    return itemstack1;
    } else
    {
    return null;
    }
    }

    public void setInventorySlotContents(int i, ItemStack itemstack)
    {
    packContents[i] = itemstack;
    if(itemstack != null && itemstack.stackSize > getInventoryStackLimit())
    {
    itemstack.stackSize = getInventoryStackLimit();
    }
    onInventoryChanged();
    }

    public String getInvName()
    {
    return "Backpack";
    }

    public void readFromNBT(NBTTagCompound nbttagcompound)
    {
    NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
    packContents = new ItemStack[getSizeInventory()];
    for(int i = 0; i < nbttaglist.tagCount(); i++)
    {
    NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
    int j = nbttagcompound1.getByte("Slot") & 0xff;
    if(j >= 0 && j < packContents.length)
    {
    packContents[j] = new ItemStack(nbttagcompound1);
    }
    }

    }

    public void writeToNBT(NBTTagCompound nbttagcompound)
    {
    NBTTagList nbttaglist = new NBTTagList();
    for(int i = 0; i < packContents.length; i++)
    {
    if(packContents[i] != null)
    {
    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
    nbttagcompound1.setByte("Slot", (byte)i);
    packContents[i].writeToNBT(nbttagcompound1);
    nbttaglist.setTag(nbttagcompound1);
    }
    }

    nbttagcompound.setTag("Items", nbttaglist);
    }

    public int getInventoryStackLimit()
    {
    return 64;
    }
    private ItemStack packContents[];
    }


    you never ended your constructor, add another } after inv=new HashMap<ItemStack, InventoryBackpack>();

    package net.minecraft.src;
    
    public class ItemBackpack extends Item{
    	
    	private HashMap<ItemStack, InventoryBackpack> inv;
    	
    	protected ItemBackpack(int ID) {
     		super(ID);
     		maxStackSize=1;
    		inv = new HashMap<ItemStack, InventoryBackpack>();
    	}
    				
    	public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityplayer)
    	{
    		entityplayer.displayGUIChest(inv.get(itemstack));
    		return itemstack;
    	}
    }
    Posted in: Tutorials
  • 0

    posted a message on [help] Growing block like grass
    can you post the error?

    edit!

    nevermind, I take it it's the error you're getting with your Tankite bomb that you posted in a different thread. am I right?
    Posted in: Tutorials
  • 0

    posted a message on [help] Minecraft crashes NO MATTER WHAT!
    I am thinking there is an error in the code, as you are getting a null pointer exception. If you could post the code where your tankite bomb creates the particles, also including any lines of script that define things like variables methods etc.
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    Quote from FiveRings

    Sorry to be a bother again, but I was playing around with your new code, and got a triad of errors.


    2011-07-14 21:41 - commands.recompile - ERROR - javac.exe -g -verbose -classpath "lib/;lib/*;jars/bin/minecraft.jar;jars/bin/jinput.jar;jars/bin/lwjgl.jar;jars/bin/lwjgl_util.jar" -sourcepath src/minecraft -d bin/minecraft src/minecraft\net\minecraft\client\*.java src/minecraft\net\minecraft\isom\*.java src/minecraft\net\minecraft\src\*.java conf/patches/*.java failed.
    2011-07-14 21:41 - commands.recompile - ERROR - Return code : 1
    2011-07-14 21:41 - commands.recompile - ERROR -
    2011-07-14 21:41 - commands.recompile - ERROR - == ERRORS FOUND ==
    2011-07-14 21:41 - commands.recompile - ERROR -
    2011-07-14 21:41 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:10: ';' expected
    2011-07-14 21:41 - commands.recompile - ERROR - inv = HashMap <ItemStack, InventoryBackpack>;
    2011-07-14 21:41 - commands.recompile - ERROR - ^
    2011-07-14 21:41 - commands.recompile - ERROR -
    2011-07-14 21:41 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:10: illegal start of expression
    2011-07-14 21:41 - commands.recompile - ERROR - inv = HashMap <ItemStack, InventoryBackpack>;
    2011-07-14 21:41 - commands.recompile - ERROR - ^
    2011-07-14 21:41 - commands.recompile - ERROR -
    2011-07-14 21:41 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:10: not a statement
    2011-07-14 21:41 - commands.recompile - ERROR - inv = HashMap <ItemStack, InventoryBackpack>;
    2011-07-14 21:41 - commands.recompile - ERROR - ^
    2011-07-14 21:41 - commands.recompile - ERROR -
    2011-07-14 21:41 - commands.recompile - ERROR - 3 errors
    2011-07-14 21:41 - commands.recompile - ERROR - ==================
    2011-07-14 21:41 - commands.recompile - ERROR -

    ItemBackpack
    package net.minecraft.src;
    
    public class ItemBackpack extends Item{
            
        private HashMap<ItemStack, InventoryBackpack> inv;
            
        protected ItemBackpack(int ID) {
            super(ID);
            maxStackSize=1;
            inv = HashMap <ItemStack, InventoryBackpack>();
        }
    
    
        public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityplayer){
    	entityplayer.displayGUIChest(inv.get(itemstack));
    	return itemstack;
        }	
    } 

    From my understanding, two of those errors usually point to a semi-colon or curly brace out of place, but that looks good to my eye.

    Am I missing something obvious?


    first off don't be sorry for asking for support. If i did not expect people to reply with questions or need help I would not have posted this.

    yes, when setting a hashmap you need to use new HashMap<Param1, Param2>() so:

    inv = new HashMap <ItemStack, InventoryBackpack>();


    Quote from cowmonkey

    is this modloader compatible? because it doesn't look like it is :0


    Lol, in fact it is ModLoader compatible, all you need to do is register your item with ModLoader instead of the Item.java, everything else will not affect ModLoader at all because we are making new classes and not editing anything.
    Posted in: Tutorials
  • 0

    posted a message on [ModLoader]Zid's Tutorials - Not Just ModLoader[12/04/2011]
    Quote from forceofthegrim

    Here it is:
    mod_lantern.java:
    package net.minecraft.src;
    
    import java.util.Random;
    
    public class mod_lantern extends BaseMod
    {
    	public static final Block lantern = new BlockLantern(100,196).setHardness(0.0F).setResistance(0.0F).setLightValue(1.0F).setBlockName("lantern");
    	public static final Block WoodLantern = new BlockWoodLantern(101,197).setHardness(0.0F).setResistance(0.0F).setLightValue(1.0F).setBlockName("woodenLantern");
    	public static final Block StoneLantern = new BlockStoneLantern(102,198).setHardness(0.0F).setResistance(0.0F).setLightValue(1.0F).setBlockName("stoneLantern");
    	public static final Block IronLantern = new BlockIronLantern(103,199).setHardness(0.0F).setResistance(0.0F).setLightValue(1.0F).setBlockName("ironLantern");
    	public static final Block GoldLantern = new BlockGoldLantern(104,200).setHardness(0.0F).setResistance(0.0F).setLightValue(1.0F).setBlockName("goldLantern");
    	public static final Block DiamondLantern = new BlockDiamondLantern(105,201).setHardness(0.0F).setResistance(0.0F).setLightValue(1.0F).setBlockName("diamondLantern");
    	public static final Item casing = new Item(2000).setItemName("lanternCasing");
    	public static final Item WoodCasing = new Item(2001).setItemName("woodCasing");
    	public static final Item StoneCasing = new Item(2002).setItemName("stoneCasing");
    	public static final Item IronCasing = new Item(2003).setItemName("ironCasing");
    	public static final Item GoldCasing = new Item(2004).setItemName("goldCasing");
    	public static final Item DiamondCasing = new Item(2005).setItemName("diamondCasing");
    	public static final Item chain = new Item(2006).setItemName("ItemChain");
    	public static final Item rope = new Item(2007).setItemName("ItemRope");
    	
    	public mod_lantern()
    	{
    		ModLoader.RegisterBlock(lantern);
    		ModLoader.RegisterBlock(WoodLantern);
    		ModLoader.RegisterBlock(StoneLantern);
    		ModLoader.RegisterBlock(IronLantern);
    		ModLoader.RegisterBlock(GoldLantern);
    		ModLoader.RegisterBlock(DiamondLantern);
    		lantern.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/force/lantern.png");
    		WoodLantern.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/force/lanternWood.png");
    		StoneLantern.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/force/lanternStone.png");
    		IronLantern.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/force/lanternIron.png");
    		GoldLantern.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/force/lanternGold.png");
    		DiamondLantern.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/force/lanternDiamond.png");
    		Item.iconIndex = ModLoader.addOverride("/gui/items.png", "/force/ItemLanternCasing.png");
    		Item.iconIndex = ModLoader.addOverride("/gui/items.png", "/force/ItemChain.png");
    		Item.iconIndex = ModLoader.addOverride("/gui/items.png", "/force/ItemRope.png");
    		Item.iconIndex = ModLoader.addOverride("/gui/items.png", "/force/ItemWoodCasing.png");
    		Item.iconIndex = ModLoader.addOverride("/gui/items.png", "/force/ItemStoneCasing.png");
    		Item.iconIndex = ModLoader.addOverride("/gui/items.png", "/force/ItemIronCasing.png");
    		Item.iconIndex = ModLoader.addOverride("/gui/items.png", "/force/ItemGoldCasing.png");
    		Item.iconIndex = ModLoader.addOverride("/gui/items.png", "/force/ItemDiamondCasing.png");
    		ModLoader.AddName(chain, "Chain");
    		ModLoader.AddName(lantern, "Lantern");
    		ModLoader.AddName(casing, "Casing");
    		ModLoader.AddName(WoodCasing, "Wooden Case");
    		ModLoader.AddName(StoneCasing, "Stone Case");
    		ModLoader.AddName(IronCasing, "Iron Case");
    		ModLoader.AddName(GoldCasing, "Gold Case");
    		ModLoader.AddName(DiamondCasing, "Diamond Case");
    		ModLoader.AddName(WoodLantern, "Wooden Lantern");
    		ModLoader.AddName(StoneLantern, "Stone Lantern");
    		ModLoader.AddName(IronLantern, "Iron Lantern");
    		ModLoader.AddName(GoldLantern, "Golden Lantern");
    		ModLoader.AddName(DiamondLantern, "Diamond Lantern");
    		ModLoader.AddName(rope, "Rope");
    		ModLoader.AddRecipe(new ItemStack(chain, 1), new Object[] {
    			"  X", " X ", "X  ", Character.valueOf('X'), Item.ingotIron
    		});
    		ModLoader.AddRecipe(new ItemStack(casing, 1), new Object[] {
    			"AAA", "BCB", "AAA", Character.valueOf('A'), Item.ingotIron, Character.valueOf('B'), Block.glass, Character.valueOf('C'), Block.torchWood
    		});
    		ModLoader.AddRecipe(new ItemStack(lantern, 4), new Object[] {
    			" X ", " X ", " Y ", Character.valueOf('X'), chain, Character.valueOf('Y'), casing
    		});
    		ModLoader.AddRecipe(new ItemStack(rope, 4), new Object[] {
    			"  X", " X ", "X  ", Character.valueOf('X'), Item.silk
    		});
    		ModLoader.AddRecipe(new ItemStack(WoodCasing, 1), new Object[] {
    			"AAA", "BCB", "AAA", Character.valueOf('A'), Block.planks, Character.valueOf('B'), Block.glass, Character.valueOf('C'), Block.torchWood
    		});
    		ModLoader.AddRecipe(new ItemStack(StoneCasing, 1), new Object[] {
    			"AAA", "BCB", "AAA", Character.valueOf('A'), Block.cobblestone, Character.valueOf('B'), Block.glass, Character.valueOf('C'), Block.torchWood
    		});
    		ModLoader.AddRecipe(new ItemStack(IronCasing, 1), new Object[] {
    			"AAA", "BCB", "AAA", Character.valueOf('A'), Item.ingotIron, Character.valueOf('B'), Block.glass, Character.valueOf('C'), Block.torchWood
    		});
    		ModLoader.AddRecipe(new ItemStack(GoldCasing, 1), new Object[] {
    			"AAA", "BCB", "AAA", Character.valueOf('A'), Item.ingotGold, Character.valueOf('B'), Block.glass, Character.valueOf('C'), Block.torchWood
    		});
    		ModLoader.AddRecipe(new ItemStack(DiamondCasing, 4), new Object[] {
    			"AAA", "BCB", "AAA", Character.valueOf('A'), Item.diamond, Character.valueOf('B'), Block.glass, Character.valueOf('C'), Block.torchWood
    		});
    		ModLoader.AddRecipe(new ItemStack(WoodLantern, 1), new Object[] {
    			" X ", " X ", " Y ", Character.valueOf('X'), rope, Character.valueOf('Y'), WoodCasing
    		});
    		ModLoader.AddRecipe(new ItemStack(StoneLantern, 1), new Object[] {
    			" X ", " X ", " Y ", Character.valueOf('X'), chain, Character.valueOf('Y'), StoneCasing
    		});
    		ModLoader.AddRecipe(new ItemStack(IronLantern, 4), new Object[] {
    			" X ", " X ", " Y ", Character.valueOf('X'), chain, Character.valueOf('Y'), IronCasing
    		});
    		ModLoader.AddRecipe(new ItemStack(GoldLantern, 5), new Object[] {
    			" X ", " X ", " Y ", Character.valueOf('X'), chain, Character.valueOf('Y'), GoldCasing
    		});
    		ModLoader.AddRecipe(new ItemStack(DiamondLantern, 8), new Object[] {
    			" X ", " X ", " Y ", Character.valueOf('X'), chain, Character.valueOf('Y'), DiamondCasing
    		});
    		ModLoader.AddRecipe(new ItemStack(Item.ingotIron, 64), new Object[] {			//TEST RECIPE! REMOVE BEFORE RECOMPILE!
    			"X", Character.valueOf('X'), Block.cobblestone
    		});
    		ModLoader.AddRecipe(new ItemStack(Block.glass, 64), new Object[] {				//TEST RECIPE! REMOVE BEFORE RECOMPILE!
    			"XX", Character.valueOf('X'), Block.cobblestone
    		});
    		ModLoader.AddRecipe(new ItemStack(Item.diamond, 64), new Object[] {				//TEST RECIPE! REMOVE BEFORE RECOMPILE!
    			"X", Character.valueOf('X'), Block.dirt
    		});
    		ModLoader.AddRecipe(new ItemStack(Item.ingotGold, 64), new Object[] {           //TEST RECIPE! REMOVE BEFORE RECOMPILE!
      			"X", Character.valueOf('X'), Item.stick
    		});
    		ModLoader.AddRecipe(new ItemStack(Item.silk, 64), new Object[] {				//TEST RECIPE! REMOVE BEFORE RECOMPILE!
    			"XX", Character.valueOf('X'), Block.dirt
    		});
    		
    		
    	}
    	public String Version()
    	{
    		return "1.7.3";
    	}
    }



    First off you're setting Item's texture index, not the index of your own item, if you set a variable to something, then change it to something again it will be the last one you changed it to. use youritem.iconIndex and set the index for each item individually.
    Posted in: Tutorials
  • 0

    posted a message on [help] Growing block like grass
    When registering your block in Block.java did you happen to use:

    setTickOnLoad(true)


    ? because if not it will never do the updateTick()
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    TUTORIAL UPDATED!

    Update:
    • Made Each Item Have Its Own Inventory!
    • Added Some More Detailed Descriptions!
    • Added Q&A!
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    Quote from Stronghold257

    ItemBackpack.java


    package net.minecraft.src; 
     
    public class ItemBackpack extends Item{ 
             
            private IInventory inv; 
             
            protected ItemBackpack(int ID) { 
                    super(ID); 
                    maxStackSize=1; 
                    inv = new InventoryBackpack(); 
            } 
    }
    
    public ItemStack onItemRightClick(ItemStack itemstack, World world,EntityPlayer entityplayer){ 
            entityplayer.displayGUIChest(inv); 
            return itemstack; 
    }


    InventoryBackpack.java


    package net.minecraft.src; 
     
    public class InventoryBackpack implements IInventory 
    { 
     
        public InventoryBackpack() 
        { 
            packContents = new ItemStack[36]; 
        } 
     
        public int getSizeInventory() 
        { 
            return 27; 
        } 
         
        public boolean canInteractWith(EntityPlayer entityplayer) 
        { 
            return !entityplayer.isDead; 
        } 
     
        public void onInventoryChanged() 
        { 
        } 
         
        public ItemStack getStackInSlot(int i) 
        { 
            return packContents[i]; 
        } 
     
        public ItemStack decrStackSize(int i, int j) 
        { 
            if(packContents[i] != null) 
            { 
                if(packContents[i].stackSize <= j) 
                { 
                    ItemStack itemstack = packContents[i]; 
                    packContents[i] = null; 
                    onInventoryChanged(); 
                    return itemstack; 
                } 
                ItemStack itemstack1 = packContents[i].splitStack(j); 
                if(packContents[i].stackSize == 0) 
                { 
                    packContents[i] = null; 
                } 
                onInventoryChanged(); 
                return itemstack1; 
            } else 
            { 
                return null; 
            } 
        } 
     
        public void setInventorySlotContents(int i, ItemStack itemstack) 
        { 
            packContents[i] = itemstack; 
            if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) 
            { 
                itemstack.stackSize = getInventoryStackLimit(); 
            } 
            onInventoryChanged(); 
        } 
     
        public String getInvName() 
        { 
            return "Backpack"; 
        } 
     
        public void readFromNBT(NBTTagCompound nbttagcompound) 
        { 
            NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); 
            packContents = new ItemStack[getSizeInventory()]; 
            for(int i = 0; i < nbttaglist.tagCount(); i++) 
            { 
                NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i); 
                int j = nbttagcompound1.getByte("Slot") & 0xff; 
                if(j >= 0 && j < packContents.length) 
                { 
                    packContents[j] = new ItemStack(nbttagcompound1); 
                } 
            } 
     
        } 
     
        public void writeToNBT(NBTTagCompound nbttagcompound) 
        { 
            NBTTagList nbttaglist = new NBTTagList(); 
            for(int i = 0; i < packContents.length; i++) 
            { 
                if(packContents[i] != null) 
                { 
                    NBTTagCompound nbttagcompound1 = new NBTTagCompound(); 
                    nbttagcompound1.setByte("Slot", (byte)i); 
                    packContents[i].writeToNBT(nbttagcompound1); 
                    nbttaglist.setTag(nbttagcompound1); 
                } 
            } 
     
            nbttagcompound.setTag("Items", nbttaglist); 
        } 
     
        public int getInventoryStackLimit() 
        { 
            return 64; 
        } 
        private ItemStack packContents[]; 
    }


    Item.java


    public static Item backPack = (new ItemBackpack(197)).setIconCoord(5, 15).setItemName("backpack");


    CraftingManager.java


    addRecipe(new ItemStack(Item.backPack, 1), new Object[] {
    "LC ", "L C", "LC ", Character.valueOf('L'), Item.leather, Character.valueOf('C'), Item.clay



    lol, no wonder, you have your method outside of your class. you see how you leave the class and then make onItemRightClick(), well that needs to be inside of your class.
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    Quote from Stronghold257

    Ok, three errors after looking at tutorial and copying+pasting again :/


    == MCP v4.2 ==
    > Recompiling client...
    "C:\Program Files\Java\jdk1.7.0\bin\javac.exe" -g -verbose -classpath "lib/;lib/
    *;jars/bin/minecraft.jar;jars/bin/jinput.jar;jars/bin/lwjgl.jar;jars/bin/lwjgl_u
    til.jar" -sourcepath src/minecraft -d bin/minecraft src/minecraft\net\minecraft\
    client\*.java src/minecraft\net\minecraft\isom\*.java src/minecraft\net\minecraf
    t\src\*.java  conf/patches/*.java failed.
    Return code : 1
    
    == ERRORS FOUND ==
    
    src\minecraft\net\minecraft\src\ItemBackpack.java:14: class, interface, or enum
    expected
    public ItemStack onItemRightClick(ItemStack itemstack, World world,EntityPlayer
    entityplayer){
    ^
    
    src\minecraft\net\minecraft\src\ItemBackpack.java:16: class, interface, or enum
    expected
    return itemstack;
    ^
    
    src\minecraft\net\minecraft\src\ItemBackpack.java:17: class, interface, or enum
    expected
    }
    ^
    
    3 errors
    ==================
    
    > Done in 17.59 seconds
    > Recompiling server...
    !! Can not find server sources !!
    Press any key to continue . . .


    Help?


    Really no idea, those errors should not even have a chance of happening. can you post some of your scripts? I have one idea what may be going on.
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    Quote from jbond98

    Okay, now it works, but each backpack doesn't have it's own storage, they are all just like portals to one big backpack that stores everything. So if i put dirt in one backpack I can take that out using another backpack. Is this supposed to happen? Is there a way to make this so that they are like chests and each have their own storage?
    -Thanks, jbond98


    If you read up more you'll find a post where I said "I found a bug that all of the backpacks do not have separate inventories"

    I'm still working on a solution.

    BTW,nice image, that will be perfect for it.
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    Quote from FiveRings

    Thanks for the reply. net\minecraft\src\ is where I have been putting my files, which I hope is the correct directory. And Item and IInventory classes are present, as well as the backpack classes. Is there any other cause you might reckon? I been poking at it for hours and am out of ideas.


    No, there is not that I can think of. You do have the package at the top of your class right? the first line of all java files should be:

    package net.minecraft.src;
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    Quote from jbond98

    Oh :tongue.gif: Ok, I'll do that :biggrin.gif:


    wow, fast reply
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    Quote from FiveRings

    First I wanted to say darn good tutorial, it really cleared up some of the confusion I had about inventories, and once I can get these issues solved, be one step closer to making the mod of my dreams. That being said, I'm having some pretty strange errors when I try to recompile.

    Error Report

    2011-07-13 22:33 - commands.recompile - ERROR - javac.exe -g -verbose -classpath "lib/;lib/*;jars/bin/minecraft.jar;jars/bin/jinput.jar;jars/bin/lwjgl.jar;jars/bin/lwjgl_util.jar" -sourcepath src/minecraft -d bin/minecraft src/minecraft\net\minecraft\client\*.java src/minecraft\net\minecraft\isom\*.java src/minecraft\net\minecraft\src\*.java conf/patches/*.java failed.
    2011-07-13 22:33 - commands.recompile - ERROR - Return code : 1
    2011-07-13 22:33 - commands.recompile - ERROR -
    2011-07-13 22:33 - commands.recompile - ERROR - == ERRORS FOUND ==
    2011-07-13 22:33 - commands.recompile - ERROR -
    2011-07-13 22:33 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:3: cannot find symbol
    2011-07-13 22:33 - commands.recompile - ERROR - symbol: class Item
    2011-07-13 22:33 - commands.recompile - ERROR - public class ItemBackpack extends Item{
    2011-07-13 22:33 - commands.recompile - ERROR - ^
    2011-07-13 22:33 - commands.recompile - ERROR -
    2011-07-13 22:33 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:6: cannot find symbol
    2011-07-13 22:33 - commands.recompile - ERROR - symbol : class IInventory
    2011-07-13 22:33 - commands.recompile - ERROR - location: class net.mincraft.src.ItemBackpack
    2011-07-13 22:33 - commands.recompile - ERROR - private IInventory inv;
    2011-07-13 22:33 - commands.recompile - ERROR - ^
    2011-07-13 22:33 - commands.recompile - ERROR -
    2011-07-13 22:33 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:15: cannot find symbol
    2011-07-13 22:33 - commands.recompile - ERROR - symbol : class ItemStack
    2011-07-13 22:33 - commands.recompile - ERROR - location: class net.mincraft.src.ItemBackpack
    2011-07-13 22:33 - commands.recompile - ERROR - public ItemStack onItemRightClick(ItemStack itemstack, World world,EntityPlayer entityplayer){
    2011-07-13 22:33 - commands.recompile - ERROR - ^
    2011-07-13 22:33 - commands.recompile - ERROR -
    2011-07-13 22:33 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:15: cannot find symbol
    2011-07-13 22:33 - commands.recompile - ERROR - symbol : class World
    2011-07-13 22:33 - commands.recompile - ERROR - location: class net.mincraft.src.ItemBackpack
    2011-07-13 22:33 - commands.recompile - ERROR - public ItemStack onItemRightClick(ItemStack itemstack, World world,EntityPlayer entityplayer){
    2011-07-13 22:33 - commands.recompile - ERROR - ^
    2011-07-13 22:33 - commands.recompile - ERROR -
    2011-07-13 22:33 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:15: cannot find symbol
    2011-07-13 22:33 - commands.recompile - ERROR - symbol : class EntityPlayer
    2011-07-13 22:33 - commands.recompile - ERROR - location: class net.mincraft.src.ItemBackpack
    2011-07-13 22:33 - commands.recompile - ERROR - public ItemStack onItemRightClick(ItemStack itemstack, World world,EntityPlayer entityplayer){
    2011-07-13 22:33 - commands.recompile - ERROR - ^
    2011-07-13 22:33 - commands.recompile - ERROR -
    2011-07-13 22:33 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:15: cannot find symbol
    2011-07-13 22:33 - commands.recompile - ERROR - symbol : class ItemStack
    2011-07-13 22:33 - commands.recompile - ERROR - location: class net.mincraft.src.ItemBackpack
    2011-07-13 22:33 - commands.recompile - ERROR - public ItemStack onItemRightClick(ItemStack itemstack, World world,EntityPlayer entityplayer){
    2011-07-13 22:33 - commands.recompile - ERROR - ^
    2011-07-13 22:33 - commands.recompile - ERROR -
    2011-07-13 22:33 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:12: cannot find symbol
    2011-07-13 22:33 - commands.recompile - ERROR - symbol : variable maxStackSize
    2011-07-13 22:33 - commands.recompile - ERROR - location: class net.mincraft.src.ItemBackpack
    2011-07-13 22:33 - commands.recompile - ERROR - maxStackSize =1;
    2011-07-13 22:33 - commands.recompile - ERROR - ^
    2011-07-13 22:33 - commands.recompile - ERROR -
    2011-07-13 22:33 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:13: cannot find symbol
    2011-07-13 22:33 - commands.recompile - ERROR - symbol : class InventoryBackpack
    2011-07-13 22:33 - commands.recompile - ERROR - location: class net.mincraft.src.ItemBackpack
    2011-07-13 22:33 - commands.recompile - ERROR - inv = new InventoryBackpack();
    2011-07-13 22:33 - commands.recompile - ERROR - ^
    2011-07-13 22:33 - commands.recompile - ERROR -
    2011-07-13 22:33 - commands.recompile - ERROR - 8 errors
    2011-07-13 22:33 - commands.recompile - ERROR - ==================
    2011-07-13 22:33 - commands.recompile - ERROR -

    And these are my code thus far.

    InventoryBackpack

    package net.minecraft.src;

    public class InventoryBackpack implements IInventory
    {

    public InventoryBackpack()
    {
    packContents = new ItemStack[36];
    }

    public int getSizeInventory()
    {
    return 27;
    }

    public boolean canInteractWith(EntityPlayer entityplayer)
    {
    return !entityplayer.isDead;
    }

    public void onInventoryChanged()
    {
    }

    public ItemStack getStackInSlot(int i)
    {
    return packContents[i];
    }

    public ItemStack decrStackSize(int i, int j)
    {
    if(packContents[i] != null)
    {
    if(packContents[i].stackSize <= j)
    {
    ItemStack itemstack = packContents[i];
    packContents[i] = null;
    onInventoryChanged();
    return itemstack;
    }
    ItemStack itemstack1 = packContents[i].splitStack(j);
    if(packContents[i].stackSize == 0)
    {
    packContents[i] = null;
    }
    onInventoryChanged();
    return itemstack1;
    } else
    {
    return null;
    }
    }

    public void setInventorySlotContents(int i, ItemStack itemstack)
    {
    packContents[i] = itemstack;
    if(itemstack != null && itemstack.stackSize > getInventoryStackLimit())
    {
    itemstack.stackSize = getInventoryStackLimit();
    }
    onInventoryChanged();
    }

    public String getInvName()
    {
    return "Backpack";
    }

    public void readFromNBT(NBTTagCompound nbttagcompound)
    {
    NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
    packContents = new ItemStack[getSizeInventory()];
    for(int i = 0; i < nbttaglist.tagCount(); i++)
    {
    NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
    int j = nbttagcompound1.getByte("Slot") & 0xff;
    if(j >= 0 && j < packContents.length)
    {
    packContents[j] = new ItemStack(nbttagcompound1);
    }
    }

    }

    public void writeToNBT(NBTTagCompound nbttagcompound)
    {
    NBTTagList nbttaglist = new NBTTagList();
    for(int i = 0; i < packContents.length; i++)
    {
    if(packContents[i] != null)
    {
    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
    nbttagcompound1.setByte("Slot", (byte)i);
    packContents[i].writeToNBT(nbttagcompound1);
    nbttaglist.setTag(nbttagcompound1);
    }
    }

    nbttagcompound.setTag("Items", nbttaglist);
    }

    public int getInventoryStackLimit()
    {
    return 64;
    }
    private ItemStack packContents[];
    }

    ItemBackpack

    package net.mincraft.src;

    public class ItemBackpack extends Item{


    private IInventory inv;


    protected ItemBackpack (int ID)
    {
    super (ID);
    maxStackSize =1;
    inv = new InventoryBackpack();
    }
    public ItemStack onItemRightClick(ItemStack itemstack, World world,EntityPlayer entityplayer){
    entityplayer.displayGUIChest(inv);
    return itemstack;
    }



    }

    Now, I'm just beginning to learn java, but I think its telling me, amongst other things, that the compiler cant find the Items and IInventory classes. Which just doesn't make any bloody sense. Their sitting there in the \src\ . I do have ModLoader installed, and the backpack item is registered with modloader. I don't think thats the issue, but what do I know. I have tried registering it with item.java instead, but there was no change.
    So, any help would be very appreciated.


    what seems to be your problem is that a class in not found, most likely cause, the directory you are putting your scripts to recompile them does not have ALL of the other classes. And ModLoader would not matter.
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    Quote from jbond98

    Nope, that didn't work either :sad.gif: Here are all of my classes:

    ItemBackpack

    package net.minecraft.src; 
    
    public class ItemBackpack extends Item{ 
    
    private IInventory inv; 
    
    protected ItemBackpack(int ID) { 
    super(ID); 
    maxStackSize=1; 
    }
    
    public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityplayer){
    entityplayer.displayGUIChest(inv);
    return itemstack; 
    }
    
    
    }





    InventoryBackpack

    package net.minecraft.src;
    
    public class InventoryBackpack implements IInventory
    {
    
        public InventoryBackpack()
        {
            packContents = new ItemStack[36];
        }
    
        public int getSizeInventory()
        {
            return 27;
        }
        
        public boolean canInteractWith(EntityPlayer entityplayer)
        {
            return !entityplayer.isDead;
        }
    
        public void onInventoryChanged()
        {
        }
        
        public ItemStack getStackInSlot(int i)
        {
            return packContents[i];
        }
    
        public ItemStack decrStackSize(int i, int j)
        {
            if(packContents[i] != null)
            {
                if(packContents[i].stackSize <= j)
                {
                    ItemStack itemstack = packContents[i];
                    packContents[i] = null;
                    onInventoryChanged();
                    return itemstack;
                }
                ItemStack itemstack1 = packContents[i].splitStack(j);
                if(packContents[i].stackSize == 0)
                {
                    packContents[i] = null;
                }
                onInventoryChanged();
                return itemstack1;
            } else
            {
                return null;
            }
        }
    
        public void setInventorySlotContents(int i, ItemStack itemstack)
        {
            packContents[i] = itemstack;
            if(itemstack != null && itemstack.stackSize > getInventoryStackLimit())
            {
                itemstack.stackSize = getInventoryStackLimit();
            }
            onInventoryChanged();
        }
    
        public String getInvName()
        {
            return "Backpack";
        }
    
        public void readFromNBT(NBTTagCompound nbttagcompound)
        {
            NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
            packContents = new ItemStack[getSizeInventory()];
            for(int i = 0; i < nbttaglist.tagCount(); i++)
            {
                NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
                int j = nbttagcompound1.getByte("Slot") & 0xff;
                if(j >= 0 && j < packContents.length)
                {
                    packContents[j] = new ItemStack(nbttagcompound1);
                }
            }
    
        }
    
        public void writeToNBT(NBTTagCompound nbttagcompound)
        {
            NBTTagList nbttaglist = new NBTTagList();
            for(int i = 0; i < packContents.length; i++)
            {
                if(packContents[i] != null)
                {
                    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                    nbttagcompound1.setByte("Slot", (byte)i);
                    packContents[i].writeToNBT(nbttagcompound1);
                    nbttaglist.setTag(nbttagcompound1);
                }
            }
    
            nbttagcompound.setTag("Items", nbttaglist);
        }
    
        public int getInventoryStackLimit()
        {
            return 64;
        }
        private ItemStack packContents[];
    }




    And this is the little snippet I used in Item.java

    public static Item backpack = (new ItemBackpack(104)).setIconCoord(5, 6).setItemName("backpack");



    lol, you still never set inv, so it remains null. try this:

    package net.minecraft.src; 
    
    public class ItemBackpack extends Item{ 
    
        private IInventory inv; 
    
        protected ItemBackpack(int ID) { 
            super(ID); 
            maxStackSize=1; 
            inv=new InventoryBackpack();//Here is what should be added
        }
    
        public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityplayer){
            entityplayer.displayGUIChest(inv);
            return itemstack; 
        }
    }
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    Try replacing onItemRightClick with OnItemUse
    Posted in: Tutorials
  • To post a comment, please .