• 0

    posted a message on [Tutorial] Making Inventories
    ok. glad you got it.
    Posted in: Tutorials
  • 1

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

    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[];
    }


    I need ItemBackpack.java not InventoryBackpack.java. The error is coming from the ItemBackpack at line 13 NullPointerException.

    @StrongJoshua I can definatly make one, but I'm still working on figuring out the GUI's and stuff. So far I know you'd need to edit at least 4 classes and make 2-3. So it may be a while. I will however take tutorial requests even during this time period.
    Posted in: Tutorials
  • 0

    posted a message on [ModLoader]Zid's Tutorials - Not Just ModLoader[12/04/2011]
    nevermind, you're not understanding it... one of the errors you were getting is "There is no such constructor ItemPickaxe(int i, net.minecraft.src.EnumMaterialEmerald" because ItemPickaxe, the constructor for ItemPickaxe can not take your enumerator.
    Posted in: Tutorials
  • 0

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

    mod_Emeralds:
    package net.minecraft.src;
    
    import java.util.Random;
    
    public class mod_Emeralds extends BaseMod
    {
       public static final Block emeraldOre = new BlockEmeraldOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("emeraldOre");
       public static final Block emeraldBlock = new BlockEmeraldBlock(98, 0).setHardness(1.5F).setResistance(5.0F).setBlockName("emeraldBlock");
       public static final Item emeraldItem = new Item(2000).setItemName("emeraldItem");
       public static final Item EmeraldPick = new ItemPickaxe(2001, EnumToolEmerald.EMERALD).setItemName("emeraldPick");
       public static final Item EmeraldShovel = new ItemSpade(2002, EnumToolEmerald.EMERALD).setItemName("emeraldShovel");
       public static final Item EmeraldAxe = new ItemAxe(2003, EnumToolEmerald.EMERALD).setItemName("emeraldAxe");
       public static final Item EmeraldHoe = new ItemHoe(2004, EnumToolEmerald.EMERALD).setItemName("emeraldHoe");
       public static final Item EmeraldSword = new ItemSword(2005, EnumToolEmerald.EMERALD).setItemName("emeraldSword");
       public static final Achievement achPickUpEBlock = new Achievement(3450, "achPickUpEBlock", 10, 2, emeraldOre, null).registerAchievement();
    
    public mod_Emeralds()
    {
       ModLoader.RegisterBlock(emeraldOre);
       ModLoader.RegisterBlock(emeraldBlock);
       emeraldOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/tutorial/emeraldore.png");
       emeraldBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/tutorial/emeraldblock.png");
       emeraldItem.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emerald.png");
       emeraldPick.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldPick.png");
       emeraldShovel.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldShovel.png");
       emeraldAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldAxe.png");
       emeraldHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldHoe.png");
       emeraldSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldSword.png");
       ModLoader.AddName(emeraldOre, "Emerald Ore");
       ModLoader.AddName(emeraldBlock, "Emerald Block");
       ModLoader.AddName(emeraldItem, "Emerald");
       ModLoader.AddName(emeraldPick, "Emerald Pickaxe");
       ModLoader.AddName(emeraldShovel, "Emerald Shovel");
       ModLoader.AddName(emeraldAxe, "Emerald Axe");
       ModLoader.AddName(emeraldHoe, "Emerald Hoe");
       ModLoader.AddName(emeraldSword, "Emerald Sword");
       ModLoader.AddRecipe(new ItemStack(emeraldItem, 9), new Object[] {
                "X", Character.valueOf('X'), mod_Emeralds.emeraldBlock
            });
       ModLoader.AddRecipe(new ItemStack(emeraldBlock, 1), new Object[] {
                "XXX", "XXX", "XXX", Character.valueOf('X'), mod_Emeralds.emeraldItem
            });
       ModLoader.AddRecipe(new ItemStack(emeraldPick, 1), new Object[] {
                "XXX", " | ", " | ", Character.valueOf('X'), mod_Emeralds.emeraldItem, Character.valueOf('|'), Item.stick
            });
       ModLoader.AddRecipe(new ItemStack(emeraldShovel, 1), new Object[] {
                " X ", " | ", " | ", Character.valueOf('X'), mod_Emeralds.emeraldItem, Character.valueOf('|'), Item.stick
            });
       ModLoader.AddRecipe(new ItemStack(emeraldAxe, 1), new Object[] {
                "XX ", "X| ", " | ", Character.valueOf('X'), mod_Emeralds.emeraldItem, Character.valueOf('|'), Item.stick
            });
       ModLoader.AddRecipe(new ItemStack(emeraldHoe, 1), new Object[] {
                "XX ", " | ", " | ", Character.valueOf('X'), mod_Emeralds.emeraldItem, Character.valueOf('|'), Item.stick
            });
       ModLoader.AddRecipe(new ItemStack(emeraldSword, 1), new Object[] {
                " X ", " X ", " | ", Character.valueOf('X'), mod_Emeralds.emeraldItem, Character.valueOf('|'), Item.stick
            });
    }
    
    public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
        {
            for(int i = 0; i < 17; i++)
            {
                int randPosX = chunkX + rand.nextInt(16);
                int randPosY = rand.nextInt(40);
                int randPosZ = chunkZ + rand.nextInt(16);
                (new WorldGenMinable(mod_Emeralds.emeraldOre.blockID, 7)).generate(world, rand, randPosX, randPosY, randPosZ);
            }
        }
    
    public void OnItemPickup(EntityPlayer entityplayer, ItemStack itemstack)
                    {
                            if(itemstack.itemID == emeraldOre.blockID)
                            {
                                    entityplayer.addStat(achPickUpEBlock, 1);
                            }
           
                    }
    	
     public String Version()
       {
       return "1.7_03";
       }
    
    }

    EnumToolEmerald:
    package net.minecraft.src;
    
    public enum EnumToolEmerald // this file is a replacement for EnumToolMaterial. you can name this file whatever you want but this name is easy to use.
    {
        EMERALD("EMERALD", 5, 3, 4150, 12F, 5);// if you have read ziddia's tutorial as i recomended you know what this means. if you have not read ziddia's tutorial read it now!!
    
        private EnumToolEmerald(String s, int i, int j, int k, float f, int l)
        {
            harvestLevel = j;
            maxUses = k;
            efficiencyOnProperMaterial = f;
            damageVsEntity = l;
        }
    
        public int getMaxUses()
        {
            return maxUses;
        }
    
        public float getEfficiencyOnProperMaterial()
        {
            return efficiencyOnProperMaterial;
        }
    
        public int getDamageVsEntity()
        {
            return damageVsEntity;
        }
    
        public int getHarvestLevel()
        {
            return harvestLevel;
        }
        private final int harvestLevel;
        private final int maxUses;
        private final float efficiencyOnProperMaterial;
        private final int damageVsEntity;
    }

    ItemEmeraldTool:
    package net.minecraft.src;
    
    public enum EnumToolEmerald // this file is a replacement for EnumToolMaterial. you can name this file whatever you want but this name is easy to use.
    {
        EMERALD("EMERALD", 5, 3, 4150, 12F, 5);// if you have read ziddia's tutorial as i recomended you know what this means. if you have not read ziddia's tutorial read it now!!
    
        private EnumToolEmerald(String s, int i, int j, int k, float f, int l)
        {
            harvestLevel = j;
            maxUses = k;
            efficiencyOnProperMaterial = f;
            damageVsEntity = l;
        }
    
        public int getMaxUses()
        {
            return maxUses;
        }
    
        public float getEfficiencyOnProperMaterial()
        {
            return efficiencyOnProperMaterial;
        }
    
        public int getDamageVsEntity()
        {
            return damageVsEntity;
        }
    
        public int getHarvestLevel()
        {
            return harvestLevel;
        }
        private final int harvestLevel;
        private final int maxUses;
        private final float efficiencyOnProperMaterial;
        private final int damageVsEntity;
    }

    Do you need any more files than this?


    Ok, for the third time, case sensitive, you are making a variable called EmeraldPick and then tryint to assign emeraldPick. make both of them the same case, because it does matter. Also, EnumToolEmerald can not be passed into the constructor because it's not the right class.

    When you define a method that takes a certain class as a parameter, only that class can be passed into that method. any classes extending that class are also considered that class, only different versions of it. If I made a class called Class1 and make another called Class2 and another called Class3 and another called Class4. On class 4 I make a method called something:

    public void something(Class1 instance){
    }


    it is looking for Class1, at this point if I tried to pass Class2 or Class3 into the method it would not work. However if I then made Class2 extend Class1:

    public class Class2 extends Class1{
    }


    then I can now pass Class2 into the method, but still not Class3 because it does not extend Class1.

    Unfortunatly Enumerators can not extend or implement a class. What you will have to do is go into ItemPickaxe, ItemShovel, ItemSword, ItemAxe, ItemHoe, etc... and add a new constructor, copy the old one and change the parameter type from EnumToolMaterial to EnumToolEmerald.

    That's one method, OR, instead of making your own enumerator you can add your material to EnumToolMaterial, just make it a different name, like IEMERALDS because EMERALD already exists, and if you change that you'll need to go througha LOT of files and change it.

    so you have two options, the easiest is to make a material in EnumToolMaterial
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    give code please? I wasnt to see what the NullPointerException is.
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    does it work then? I have tested it and it works for me, however I realized a problem. you can have 2 backpacks and they will have the same inventory, and even if you lose your backpack the item itself keeps the inventory. I'm working on a way to give the ItemStack itself an inventory, maybe make a new ItemStack class.
    Posted in: Tutorials
  • 0

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

    I've never heard of returns :/
    Anywho, i merely capitalised "Mod_" and it seems to have vanished, although now i have cannot find symbol errors :/


    that's because you were defineing a constructor, the constructor has to be exact same name and case as the class.

    Contructors should not return, becuase it's not a method and does not declare a return type. returns are for like if you was to use the method to get something example:

    public static double square(double d){
        return d*d;
    }
    public static void main(String[] args){
        double number = 5D+(1D/3D);//so I didn't have to write 5.333333...
        number = square(number);//square our number
        double result = 28D+(4D/9D);//so I didn't have to write 28.444444...
        if number==result;{
            System.out.println("success");
        }else{
            System.out.println("failed");
        }
    }


    at the way it is it would always print out success, but change only the value of the original number and it will print failed print failed.
    Posted in: Tutorials
  • 0

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

    Actually, I fixed that, but now I got 35 errors that I can't seem to fix. Just see above your post.
    It says cant find variable, and I have fixed it now...

    Just let me know if you need to see some of the files.


    Yeah I'd need to see the files. The errors are saying that they can not find something, you have not defined mod_enabled
    Posted in: Tutorials
  • 0

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

    But, I have defined it in the mod_Emeralds:
    package net.minecraft.src;
    
    import java.util.Random;
    
    public class mod_Emeralds extends BaseMod
    {
       public static final Block emeraldOre = new BlockEmeraldOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("emeraldOre");
       public static final Block emeraldBlock = new BlockEmeraldBlock(98, 0).setHardness(1.5F).setResistance(5.0F).setBlockName("emeraldBlock");
       public static final Item emeraldItem = new Item(2000).setItemName("emeraldItem");
       public static final Item EmeraldPick = new ItemPickaxe(2001, EnumToolEmerald.EMERALD).setItemName("emeraldPick");
       public static final Item EmeraldShovel = new ItemSpade(2002, EnumToolEmerald.EMERALD).setItemName("emeraldShovel");
       public static final Item EmeraldAxe = new ItemAxe(2003, EnumToolEmerald.EMERALD).setItemName("emeraldAxe");
       public static final Item EmeraldHoe = new ItemHoe(2004, EnumToolEmerald.EMERALD).setItemName("emeraldHoe");
       public static final Item EmeraldSword = new ItemSword(2005, EnumToolEmerald.EMERALD).setItemName("emeraldSword");
       public static final Achievement achPickUpEBlock = new Achievement(3450, "achPickUpEBlock", 10, 2, emeraldOre, null).registerAchievement();
    
    public mod_Emeralds()
    {
       ModLoader.RegisterBlock(emeraldOre);
       ModLoader.RegisterBlock(emeraldBlock);
       emeraldOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/tutorial/emeraldore.png");
       emeraldBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/tutorial/emeraldblock.png");
       emeraldItem.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emerald.png");
       emeraldPick.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldpick.png");
       emeraldShovel.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldshovel.png");
       emeraldAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldaxe.png");
       emeraldHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldhoe.png");
       emeraldSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldsword.png");
       ModLoader.AddName(emeraldOre, "Emerald Ore");
       ModLoader.AddName(emeraldBlock, "Emerald Block");
       ModLoader.AddName(emeraldItem, "Emerald");
       ModLoader.AddName(emeraldPick, "Emerald Pickaxe");
       ModLoader.AddName(emeraldShovel, "Emerald Shovel");
       ModLoader.AddName(emeraldAxe, "Emerald Axe");
       ModLoader.AddName(emeraldHoe, "Emerald Hoe");
       ModLoader.AddName(emeraldSword, "Emerald Sword");
       ModLoader.AddRecipe(new ItemStack(emeraldItem, 9), new Object[] {
                "X", Character.valueOf('X'), mod_Emeralds.emeraldBlock
            });
       ModLoader.AddRecipe(new ItemStack(emeraldBlock, 1), new Object[] {
                "XXX", "XXX", "XXX", Character.valueOf('X'), mod_Emeralds.emeraldItem
            });
       ModLoader.AddRecipe(new ItemStack(emeraldPick, 1), new Object[] {
                "XXX", " | ", " | ", Character.valueOf('X'), mod_Emeralds.emeraldItem, Character.valueOf('|'), Item.stick
            });
       ModLoader.AddRecipe(new ItemStack(emeraldShovel, 1), new Object[] {
                " X ", " | ", " | ", Character.valueOf('X'), mod_Emeralds.emeraldItem, Character.valueOf('|'), Item.stick
            });
       ModLoader.AddRecipe(new ItemStack(emeraldAxe, 1), new Object[] {
                "XX ", "X| ", " | ", Character.valueOf('X'), mod_Emeralds.emeraldItem, Character.valueOf('|'), Item.stick
            });
       ModLoader.AddRecipe(new ItemStack(emeraldHoe, 1), new Object[] {
                "XX ", " | ", " | ", Character.valueOf('X'), mod_Emeralds.emeraldItem, Character.valueOf('|'), Item.stick
            });
       ModLoader.AddRecipe(new ItemStack(emeraldSword, 1), new Object[] {
                " X ", " X ", " | ", Character.valueOf('X'), mod_Emeralds.emeraldItem, Character.valueOf('|'), Item.stick
            });
    }
    
    public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
        {
            for(int i = 0; i < 17; i++)
            {
                int randPosX = chunkX + rand.nextInt(16);
                int randPosY = rand.nextInt(40);
                int randPosZ = chunkZ + rand.nextInt(16);
                (new WorldGenMinable(mod_Emeralds.emeraldOre.blockID, 7)).generate(world, rand, randPosX, randPosY, randPosZ);
            }
        }
    
    public void OnItemPickup(EntityPlayer entityplayer, ItemStack itemstack)
                    {
                            if(itemstack.itemID == emeraldOre.blockID)
                            {
                                    entityplayer.addStat(achPickUpEBlock, 1);
                            }
           
                    }
    	
     public String Version()
       {
       return "1.7_03";
       }
    
    }



    It's case sensitive, you are looking for emeraldPick and have it as EmeraldPick, same with sword hoe axe and shovel.
    Posted in: Tutorials
  • 0

    posted a message on [ModLoader]Zid's Tutorials - Not Just ModLoader[12/04/2011]
    what cannot find symbol means that the variable is undefined, it seems you are trying to call emeraldSword but emeraldSword does not exist to the script.
    Posted in: Tutorials
  • 0

    posted a message on [Creating Mods] Modding Tutorials [May 19th 2011]
    Lolmewn, hi!!!!!
    Posted in: Tutorials
  • 0

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

    Hmmmm when running you exact code, for testing purposes, I get these 6 errors
    == ERRORS FOUND ==
    
    src/minecraft/net/minecraft/src/InventoryBackpack.java:5: net.minecraft.src.InventoryBackpack is not abstract and does not override abstract method canInteractWith(net.minecraft.src.EntityPlayer) in net.minecraft.src.IInventory
    public class InventoryBackpack implements IInventory
    ^
    
    src/minecraft/net/minecraft/src/InventoryBackpack.java:31: cannot find symbol
    symbol  : method onInventoryChanged()
    location: class net.minecraft.src.InventoryBackpack
    onInventoryChanged();
    ^
    
    src/minecraft/net/minecraft/src/InventoryBackpack.java:39: cannot find symbol
    symbol  : method onInventoryChanged()
    location: class net.minecraft.src.InventoryBackpack
    onInventoryChanged();
    ^
    
    src/minecraft/net/minecraft/src/InventoryBackpack.java:54: cannot find symbol
    symbol  : method onInventoryChanged()
    location: class net.minecraft.src.InventoryBackpack
    onInventoryChanged();
    ^
    
    src/minecraft/net/minecraft/src/InventoryBackpack.java:64: cannot find symbol
    symbol  : method readFromNBT(net.minecraft.src.NBTTagCompound)
    location: class java.lang.Object
    super.readFromNBT(nbttagcompound);
    ^
    
    src/minecraft/net/minecraft/src/InventoryBackpack.java:81: cannot find symbol
    symbol  : method writeToNBT(net.minecraft.src.NBTTagCompound)
    location: class java.lang.Object
    super.writeToNBT(nbttagcompound);
    ^
    
    6 errors
    ==================



    I can tel from the bottom two errors that you have not looked recently at t he tutorial, because in the tutorial I fixed these errors. the super.read/writeFrom/ToNBT should be deleted, look at the updated code. Also a method was missing. Please look at the tutorial again.
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    strange, try replacing onItemRightClick for onItemUse(), you'll need to change the arguments a little.
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    I take it it worked then?
    Posted in: Tutorials
  • 0

    posted a message on [Tutorial] Making Inventories
    I fixed that error, if you look at the code now it no longer has the super.writeToNBT or readFromNBT, those only apply to objects extending TileEntity which ours does not as seeing it's not a block, let alone with such a purpose. just remove those two lines. I thought it was a new error.
    Posted in: Tutorials
  • To post a comment, please .