• 0

    posted a message on A few questions about variables

    Hi, I read your question a couple of times to make sure that I understood it.

    To ease this I will answer the first question in this post, if I manage to sus out the answer to the other questions, they may go in other posts.

    So you want the value contained in one variable to affect the name of another.
    Assumption: what you want is


    I can see what you are trying to say and do, but I dont see why, if you do this, you will have issues refering to the variable in the future if the int changes.

    eg,
    int testing = 1;
    
    //therefore variables name is storage1.
    storage1 = "word"
    
    testing = 2;

    At this point, how will you know what the variable name is in order to refer to it.

    I think it is possible you are refering to arrays, if so, say yes, and I will reply with help on how to do these.


    The first example you provided is what I'm going for.

    What I'm working on is a block that will drop a random item a random amount of times. I plan on putting the above code within a for loop to do so because if I use:
    EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack(Item.ingotIron));
    EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack(Item.ingotIron));


    I get an error when recompiling that states "entityitem" has already been defined. For each item drop I have to have a different variable from entityitem, if that makes sense.

    Also in regards to my 3rd question would something like this work.
    String variableA = Item.coal;
    
    EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack( + variableA + ));


    Sorry if what I'm saying is confusing, I'm trying my best to describe what I'm trying to accomplish.
    Posted in: Modification Development
  • 0

    posted a message on Blocks that drop multiple items
    Quote from IX iTzRogue XI

    Would you mind posting how you did it? A lot of people have wanted this in the past :rolleyes:


    Don't worry I plan on making a tutorial once I understand 100% of it. I'll hopefully have it out in the next couple of days. That was the first thought in my head when I figured it out.
    Posted in: Modification Development
  • 0

    posted a message on Cake House, Minature House, and Colorful Minetrack
    Quote from Napa1m

    I <3 the minetrack. How long did it take you to make it?


    It took over a week, as for the specific time I'm not a 100% sure because it's been a while. But one thing I should note is when I made this there were no shears(or maybe there were and I just didn't know about them) so breaking wool blocks by hand was a pain. I think I would of rather mined obsidian with a wooden shovel :rolleyes: .
    Posted in: Screenshots
  • 1

    posted a message on Cake House, Minature House, and Colorful Minetrack
    So I made these a while ago and just recently joined this community so I decided to show them off here. If anyone is going to appreciate Minecraft related things I figure it would be you guys. All of these are in the form of videos. Just a heads up some of the Minetrack involved using a Map Editor, and most of it was done by hand(It mostly depended on my mood for the day). Sadly no downloads...

    Cake House

    Miniature House

    My Minetrack

    Edit: Decided to add my video that's a how to play connect 4 in Minecraft.

    Edit 2: I just realized there was a video section, I feel very stupid now posting this in the screenshot section and I apologize:\.
    Posted in: Screenshots
  • 0

    posted a message on Minecraft Mod Help
    Quote from Gigs135

    Thanks man, :biggrin.gif: I just have one question, I don't believe i saw it in their but will the animation follow or is this a whole new line in itself?


    Yes the animation will be apart of the food, your pretty much making a copy of ItemFood so everything that file does this file will do.

    Just remember when testing you have to have a depleted health bar in order to eat food, when I first made one I didn't get why I couldn't eat the food then I realized I needed to lose some of the health bar before being able to eat.
    Posted in: Modification Development
  • 1

    posted a message on Minecraft Mod Help
    I'm just going to copy and paste a tutorial I made regarding the subject. Keep in mind you don't need any extra java files when using this, all you need is your mod_NameHere.java file. Also this is for ModLoader which I hope your using.

    Tutorial for ModLoder

    So I had a hard time finding one so I decided to create a tutorial on creating a new food item for 1.8.1.

    Create a new file called mod_Food.java with this code:
    package net.minecraft.src
    
    public class mod_Food extends BaseMod
    {
    	public mod_Food()
    	{
    	}
    	
    	public String Version()
    	{
    		return "Food Mod for 1.8.1";
    	}
    }


    Now we need to first create the food, we do so by adding the following line within the mod_Food class:
    public static final Item DirtPie = new ItemFood(601, 6, false).setItemName("DirtPie");

    The 601 is the ID for the new food item.
    The 6 is how many "hunger bar slots" it will fill. 1 would be half of a "hunger bar slot", 2 would be a whole "hunger bar slot". The maximum number is 20 (or 10 "hunger bar slots"). Just for reference:
    1 = ½ "hunger bar slot"
    2 = 1 "hunger bar slot"
    3 = 1 ½ "hunger bar slots"
    4 = 2 "hunger bar slots"
    etc.
    The false represents whether or not a Wolf can eat it to heal. Put true if you want Wolfs to be able to heal with the new food item.

    Now we need to set the food items texture and name, place the following code within the mod_Food constructor:
    DirtPie.iconIndex = ModLoader.addOverride("/gui/items.png", "/Food/DirtPie.png");
    ModLoader.AddName(DirtPie, "Dirt Pie");

    All this does is set the DirtPie's icon to "/Food/DirtPie.png" and then assigns the in-game name "Dirt Pie" to the new food item.

    Last, we'll make a quick recipe so we can craft the new food item.
    Add the following code within the mod_Food constructor:
    ModLoader.AddRecipe(new ItemStack(DirtPie, 1), new Object[]
    { "###", "###", "###", Character.valueOf('#'), Block.dirt});


    Now your mod_Food.java file should look just like the one below:
    public class mod_Food extends BaseMod
    {
    	
    	public static final Item DirtPie = new ItemFood(601, 6, false).setItemName("DirtPie");
    	
    	public mod_Food()
    	{
    		DirtPie.iconIndex = ModLoader.addOverride("/gui/items.png", "/Food/DirtPie.png");
    		ModLoader.AddName(DirtPie, "Dirt Pie");
    		
    		ModLoader.AddRecipe(new ItemStack(DirtPie, 1), new Object[]
    		{ "###", "###", "###", Character.valueOf('#'), Block.dirt});
    	}
    	
    	public String Version()
    	{
    		return "Food Mod for 1.8.1";
    	}
    }


    Congrats, we just created a new food item that restores 3 "hunger bar slots" upon eating.

    Just as a reference, when I say "hunger bar slots" I mean these:


    Hopefully I helped and if your having any problems I'll do my best to help.
    Posted in: Modification Development
  • 0

    posted a message on A few questions about variables
    I have a few questions about variables, I would of searched via google but I can't think of a simpler terms of putting it in so hopefully someone here can help me.

    1) How can I add the value of a variable onto the name of another variable.
    For instance, I have this line of code
    EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack(Item.ingotIron));

    and this variable that will always be a number
    private int numberA;


    I would like to add the value of numberA onto entityitem. So if numberA was 1 entityitem would become entityitem1.

    2) What is the best variable type to store things like Item.coal, Item.diamond, Item.ingotIron etc? I tried string but the compiler just kept tossing errors at me.

    3) Using the same code above:
    EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack(Item.ingotIron));


    How could I use a variable's value where Item.ingotIron is? I tried some different things but the compiler threw "ItemStack doesn't exist" or some error along those lines at me.

    For instance if variableA's value is Item.coal, how could I use that variables value where Item.ingotIron is.
    EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack(variableA));


    I appreciate your help if you choose to help me or even linking me to something I can read that will answer my question will be sufficient. Thanks ahead of time.
    Posted in: Modification Development
  • 0

    posted a message on i got a error! plz help me
    Quote from BayliTechtalk

    src/minecraft/net/minecraft/src/mod_Ore.java:14: <identifier> expected
    public void GenerateSurface(World world. Random rand, int chunkX, int chunkZ);
    ^


    this is the error plz help me thanks :biggrin.gif:



    You have to provide the code that's withing the mod_Ore.java file, otherwise helping you is just a guessing game.
    Posted in: Modification Development
  • 0

    posted a message on Modding A Custom Workbench?
    Yea I've been in search of the same thing and no luck. The best you can do is check out the original files that make up the workbench and play around with the coding.
    Posted in: Mods Discussion
  • 0

    posted a message on Screwed Up A Mod Install
    Quote from Bachiavelli

    I wish all customer service was this quick and effective. :tongue.gif:

    Thanks guys.


    Future reference, before installing mods always backup minecraft.jar. It'll make things a little easier in the long run.
    Posted in: Mods Discussion
  • 0

    posted a message on [Help] Little Question
    Quote from Cilerba

    Oh cool, thanks. And out of curiosity, how would I go about adding poisonous items?


    I'm not a 100% sure, but put a - in front of the "heal amount". So for the example I gave you instead of 6 it would be -6.
    Posted in: Modification Development
  • 0

    posted a message on [Help] Little Question
    There is a easier way of adding food and this should solve your problem with wanting to fill the hunger bar. Delete ItemBurger.java. Now open up mod_Burger.java.

    Replace
    public static final Item itemBurger = new ItemBurger(2000).setItemName("burg");


    with this

    public static final Item itemBurger = new ItemFood(601, 6, false).setItemName("itemBurger");


    The 601 is the ID for the new food item.
    The 6 is how many "hunger bar slots" it will fill. 1 would be half of a "hunger bar slot", 2 would be a whole "hunger bar slot". The maximum number is 20 (or 10 "hunger bar slots"). Just for reference:
    1 = ½ "hunger bar slot"
    2 = 1 "hunger bar slot"
    3 = 1 ½ "hunger bar slots"
    4 = 2 "hunger bar slots"
    etc.
    The false represents whether or not a Wolf can eat it to heal. Put true if you want Wolfs to be able to heal with the new food item.

    Now it should work the way you want it, adjust the values as needed and this will reduce a huge build up a class files by removing unneeded files.
    Posted in: Modification Development
  • 0

    posted a message on Blocks that drop multiple items
    Never mind guys I figured it out.
    Posted in: Modification Development
  • 0

    posted a message on Blocks that drop multiple items
    Quote from Rabisu

    You're not passing your method 'entityplayer' for starters... You'll need to find a way to get the instance of the player so that you can pass it as a method argument.


    No I realized that, I merely provided that as proof that I've been attempting to figure it out myself. The method won't work because there isn't a way to pass the instance into the method without modifying a bunch of files.

    I've been looking at the BlockCrops file because I know a fully grown crop yields a wheat and 2 seeds, but I'm not entirely sure what all of the code does within the method that executes that action.

        public void dropBlockAsItemWithChance(World world, int i, int j, int k, int l, float f)
        {
            super.dropBlockAsItemWithChance(world, i, j, k, l, f);
            if(world.multiplayerWorld)
            {
                return;
            }
            for(int i1 = 0; i1 < 3; i1++)
            {
                if(world.rand.nextInt(15) <= l)
                {
                    float f1 = 0.7F;
                    float f2 = world.rand.nextFloat() * f1 + (1.0F - f1) * 0.5F;
                    float f3 = world.rand.nextFloat() * f1 + (1.0F - f1) * 0.5F;
                    float f4 = world.rand.nextFloat() * f1 + (1.0F - f1) * 0.5F;
                    EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack(Item.seeds));
                    entityitem.delayBeforeCanPickup = 10;
                    world.entityJoinedWorld(entityitem);
                }
            }


    This is from BlockCrop.java
    Posted in: Modification Development
  • 0

    posted a message on Blocks that drop multiple items
    So I've been fiddling around with this and was wondering if someone could give me a hand.

    I have a block and when this block is mined I would like it to drop more then 1 type of item. I've been snooping around the Minecraft source and so far haven't found anything to help.

    At one point I was looking through ContainerWorkbench and found the code that drops items left on the crafting table and attempted to create a method using a similar method with no luck.

    package net.minecraft.src;
    import java.util.Random;
    
    public class BlockTest extends Block
    {
    	public BlockTest(int i, int j)
    	{
    		super(i,j,Material.ground);
    	}
    	public int idDropped(int i, Random random)
    	{
    		Test();
    		return mod_Test.Test.blockID;
    	}
    	public int quantityDropped(Random random)
    	{
    		return 1;
    	}
    	public void Test(EntityPlayer entityplayer)
    	{
    		entityplayer.dropPlayerItem(Item.coal);
    		entityplayer.dropPlayerItem(Item.stick);
    	}
    }


    I know pretty much why this won't work, but it was worth a try.

    So any light someone can shed on this subject is greatly appreciated, even pointing me in the right direction would be awesome.
    Posted in: Modification Development
  • To post a comment, please or register a new account.