Who here makes their own mods?

A place to talk to other users about the mod.
User avatar
Kitty
Posts: 23
Joined: Tue Jul 05, 2011 12:19 pm

Re: Who here makes their own mods?

Post by Kitty »

Well last night I managed to sort my Eclipse and MCP stuff and got it all set up correctly so next I'll be following the tutorials through - it's very exciting!!
User avatar
SterlingRed
Posts: 1466
Joined: Tue Jul 05, 2011 11:02 am

Re: Who here makes their own mods?

Post by SterlingRed »

BinoAl wrote:I've done a bit of modding, but the only language im at all decent is is visual basic, which is really only good for learning non-object oriented programming :p I'm enrolled in college for a major in computer science with a focus on game design, but i start in the fall, and my first term is all basic shit, like teaching us how to use the internet. lul.
Yeah pretty much the first year to year and a half of college is like that. Push back a few of your core general classes and toss in the first programming class. I think most colleges start CS majors with c++. It might have a math/logic pre-req but that should be it.

OT: I'd really like to play around with modding/learning a little java. Unfortunately I don't really have the time right now and my free time is absorbed by a different project. Perhaps I'll get into it this fall.
User avatar
darahalian
Posts: 578
Joined: Mon Jul 04, 2011 9:57 pm

Re: Who here makes their own mods?

Post by darahalian »

SirSnapback wrote:Lmao i still cant get my texture override working. :l
I need help with it, any coders wanna help? xD
You already talked with Flower about this same thing on the original thread. He told you to use the getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) function to have textures on other sides. I don't know exactly how it all works, but getBlockTextureFromSide(int i) is basically the same function somehow. FlowerChild explained this on the same page a little lower down, but I'll quote it here.
FlowerChild wrote:
darahalian wrote: I guess I can assume that getBlockTextureFromSide is just a kind of shortcut to the function you mentioned, or something like that.
Nah, getBlockTextureFromSide() is that function :)

It's defined in the Block base class. By overriding it in the class for your own block, you basically specify how your block behaves when that function gets called from other parts of the code. Specifically, that function gets called by the rendering code for the game, when it gets to rendering your block.

So, you just return whatever texture index you want, depending on the side that gets passed in as a parameter. A few lines of code, and off you go :)
I haven't created a block with multiple textures myself, but I'll try to explain how it should work from existing code examples, particularly BlockSandstone. The method that was used here was as follows. Sandstone is initially assigned a texture slot, just like any other block. This texture is the one you see on the sides of sandstone. But the getBlockTextureFromSide() function was used in BlockSandStone to assign different textures to the top and bottom of sandstone.

Code: Select all

    public int getBlockTextureFromSide(int i)
    {
        if(i == 1)
        {
            return blockIndexInTexture - 16;
        }
        if(i == 0)
        {
            return blockIndexInTexture + 16;
        } else
        {
            return blockIndexInTexture;
        }
    }
(I don't think that posting this small snippet of code should be a problem, but if it is, someone tell me and I'll do something else.)

From this example, I was able to tell that 1 is the top of a block, and 0 is the bottom. The other sides are represented by the numbers 2-5, though I'm not sure which order they're in.

So, in this example we can see that for the top of the block, blockIndexInTexture - 16 is returned, and for the bottom, blockIndexInTexture + 16 is returned. For all the other sides, blockIndexInTexture itself is returned. blockIndexInTexture is the value that was already assigned to the sandstone earlier on in the usual way, namely 192. 192-16=176, which is the value of the texture that you see on the top of sandstone, and 192+16=208, which is the texture you see on the bottom. Since the terrain.png grid is 16x16, adding or subtracting 16 from one texture will give you the texture slot directly above or below it. I'm sure they could've just said "return 176" and "return 208" in these places instead, and it would've worked, but I since the sandstone textures are in a column in terrain.png, I guess Mojang just decided to do it this way instead.

If you want want to use one of your own textures, than follow these instructions from hooktail154:
hooktail154 wrote:If you're using ModLoader, you add texture overrides by calling:

int texID = ModLoader.addOverride("/terrain.png","/path/to/yourfile.png");

You will have to insert yourfile.png in the right spot in the jar in MCP/jars/bin/minecraft.jar like you would install a mod.

To make a block use the texture, return the int texID in the texture functions mentioned above. You can set the int as an (idk what they're called in java) variable at the bottom of your mod_name.java file, outside any function:

public int texID;

Then, you can call this in your BlockName.java file in one of the texture functions:

return mod_name.texID;

That'll give it that particular texture.

Hope it's not too incoherent and ramble. I might post parts of my stuff here later so you can get a better idea.
So basically, after you define the integer texID (or whatever you want to call it) with the ModLoader override, you can return that integer instead of a texture slot number in the getBlockTextureFromSide() function, and the side you specified will have your custom texture.


I hope that helped. I have now tested this, but if you encounter problems, tell me, and I'll try to help.
Last edited by darahalian on Wed Jul 06, 2011 6:51 pm, edited 2 times in total.
FlowerChild wrote:Remain ever vigilant against the groth menace my friends. Early detection is crucial in avoiding a full-blown groth epidemic.
User avatar
RegularX
Posts: 44
Joined: Tue Jul 05, 2011 11:35 am

Re: Who here makes their own mods?

Post by RegularX »

Kitty wrote:Well last night I managed to sort my Eclipse and MCP stuff and got it all set up correctly so next I'll be following the tutorials through - it's very exciting!!
Is this based on just the MCP site or are there other tutorials people have found?
User avatar
SirSnapback
Posts: 30
Joined: Tue Jul 05, 2011 12:29 am

Re: Who here makes their own mods?

Post by SirSnapback »

darahalian wrote:
SirSnapback wrote:Lmao i still cant get my texture override working. :l
I need help with it, any coders wanna help? xD
You already talked with Flower about this same thing on the original thread. He told you to use the getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) function to have textures on other sides. I don't know exactly how it all works, but getBlockTextureFromSide(int i) is basically the same function somehow. FlowerChild explained this on the same page a little lower down, but I'll quote it here.

Nah, getBlockTextureFromSide() is that function :)

It's defined in the Block base class. By overriding it in the class for your own block, you basically specify how your block behaves when that function gets called from other parts of the code. Specifically, that function gets called by the rendering code for the game, when it gets to rendering your block.

So, you just return whatever texture index you want, depending on the side that gets passed in as a parameter. A few lines of code, and off you go :)
I haven't created a block with multiple textures myself, but I'll try to explain how it should work from existing code examples, particularly BlockSandstone. The method that was used here was as follows. Sandstone is initially assigned a texture slot, just like any other block. This texture is the one you see on the sides of sandstone. But the getBlockTextureFromSide() function was used in BlockSandStone to assign different textures to the top and bottom of sandstone.

Code: Select all

    public int getBlockTextureFromSide(int i)
    {
        if(i == 1)
        {
            return blockIndexInTexture - 16;
        }
        if(i == 0)
        {
            return blockIndexInTexture + 16;
        } else
        {
            return blockIndexInTexture;
        }
    }
(I don't think that posting this small snippet of code should be a problem, but if it is, someone tell me and I'll do something else.)

From this example, I was able to tell that 1 is the top of a block, and 0 is the bottom. I don't know what numbers correspond to the other sides, but I'm sure you could look that up in another example or online somewhere.

So, in this example we can see that for the top of the block, blockIndexInTexture - 16 is returned, and for the bottom, blockIndexInTexture + 16 is returned. For all the other sides, blockIndexInTexture itself is returned. blockIndexInTexture is the value that was already assigned to the sandstone earlier on in the usual way, namely 192. 192-16=176, which is the value of the texture that you see on the top of sandstone, and 192+16=208, which is the texture you see on the bottom. Since the terrain.png grid is 16x16, adding or subtracting 16 from one texture will give you the texture slot directly above or below it. I'm sure they could've just said "return 176" and "return 208" in these places instead, and it would've worked, but I since the sandstone textures are in a column in terrain.png, I guess Mojang just decided to do it this way instead.

If you want to use one of your own textures, all you have to do is return ModLoader.addOverride("/terrain.png", "/path/to/texture.png" instead of a texture slot number.

I hope that helped. I haven't tested this out myself yet, but it should work. If you encounter problems, tell me. In the meantime, I will try to do this on my own, just to confirm that it works.

Damn, I need to soak all that in. Mabey read it slower xD Thats super helpful though O: Thanks x1000! :)
Ill try it out as soon as i get my 1.7.2 server going (its a hamachi server). Your welcome to join if you want to? Im thinking about starting a video series on youtube with some people on the server, if you have skype thats a plus too. :)
FlowerChild do i have permission to use this as my signature? Just wondering. (look below)

Image
User avatar
SirSnapback
Posts: 30
Joined: Tue Jul 05, 2011 12:29 am

Re: Who here makes their own mods?

Post by SirSnapback »

HAMACHI Server name(case sensitive) - Snapbacks Server
Password - betterthanwolves
FlowerChild do i have permission to use this as my signature? Just wondering. (look below)

Image
User avatar
Cale
Posts: 2
Joined: Mon Jul 04, 2011 11:39 pm

Re: Who here makes their own mods?

Post by Cale »

Fracture wrote:Experienced with coding in Java, but no experience in mod-making beyond the old xml editing haha. I want to learn, but for some reason none of my editors will allow me to open up minecraft's code. Thinking of getting MCP and seeing how it works, though.
I found that using notepad++ easy and free. It is made to be a code editor.
User avatar
Creepig
Posts: 71
Joined: Tue Jul 05, 2011 10:19 pm

Re: Who here makes their own mods?

Post by Creepig »

Cale wrote:
Fracture wrote:Experienced with coding in Java, but no experience in mod-making beyond the old xml editing haha. I want to learn, but for some reason none of my editors will allow me to open up minecraft's code. Thinking of getting MCP and seeing how it works, though.
I found that using notepad++ easy and free. It is made to be a code editor.
It isn't going to help you read bytecode very well, though. Java bytecode is... confusing.
User avatar
Kitty
Posts: 23
Joined: Tue Jul 05, 2011 12:19 pm

Re: Who here makes their own mods?

Post by Kitty »

Is this based on just the MCP site or are there other tutorials people have found?
I used this http://www.minecraftforum.net/topic/264 ... -beginner/ information to sort MCP and set it all up correctly in Eclipse aswell as the MCP wiki info :) I'm very much a beginner though - as I say I taught myself some C++ and played around in VB for a couple of months before adopting Minecraft modding as a new pet project.
User avatar
RegularX
Posts: 44
Joined: Tue Jul 05, 2011 11:35 am

Re: Who here makes their own mods?

Post by RegularX »

Kitty wrote:
Is this based on just the MCP site or are there other tutorials people have found?
I used this http://www.minecraftforum.net/topic/264 ... -beginner/ information to sort MCP and set it all up correctly in Eclipse aswell as the MCP wiki info :) I'm very much a beginner though - as I say I taught myself some C++ and played around in VB for a couple of months before adopting Minecraft modding as a new pet project.
Excellent, thank you much. I may have to translate some of that into Mac-speak ... but was the kind of information that was leaving me a bit head scratching from just staring at the MCP site.

Now I just need free time :{
User avatar
cheechako
Posts: 114
Joined: Mon Jul 04, 2011 11:40 pm

Re: Who here makes their own mods?

Post by cheechako »

Notepad++ (and others) - WAY, WAY better than Notepad. But it is NOT an IDE. Trust me, grab Eclipse and learn that. For a while, MCP has been including a workspace, making it easier to get up and running. You can build and launch right from Eclipse with one click.

Just a few Eclipse benefits:

Start a new block (or whatever) by typing in the usual public MyBlock extends Block {} - Eclipse will warn you that some basic elements are missing from the class and allow you to instert stubs with one click.

Want to look at the original Block class or the original getBlockTextureFromSide() - just highlight the word, right click, and Open Declaration - it will take you to the right file and location.

Eclipse tracks the various names and labels you give to things. (In the code, not the Minecraft name.) So if you type MyBlock in one file but MyBolck in another, Eclipse will warn you.

Eclipse also understands function arguments and returns. Notepad++ will simply highlight something like String s = getBlockTextureFromSide(MyBlock);,
while Eclipse will let you know the function takes and returns integers.

Eclipse also can suggest things as you type. Start a file with: package net.m As soon as you hit the 'm', you will see a list of choices. For example, I often start a new file by typing that, hitting the up arrow to loop to the bottom, and then hitting Enter and a semi-colon. Of course, you can just cut and paste this part, but these suggestions work in many situations. (Basically any place you'll hit a dot.)

That's a simplification in laymen terms of some of the reasons to use an IDE - in the case of MC, Eclipse.
"That's the nice thing about mods. There's something for everyone. Some of us like to build functional elevators, while others want to run around with a bunny on their head."
User avatar
darahalian
Posts: 578
Joined: Mon Jul 04, 2011 9:57 pm

Re: Who here makes their own mods?

Post by darahalian »

@Snapback

I've found another example that should be helpful with multiple textures: BlockPumpkin

Since the pumpkin has three different textures on it, it's an example that's a little more extensive than Sandstone. Another thing about the pumpkin is that because you can make it face different directions, it needs to make a different side have the face texture depending on the block's metadata. Looking at this example also helped me figure out the numbers for the sides a little bit more. I already said that 0=bottom and 1=top, but now I know that 2, 3, 4, and 5 are the sides, though I probably could've guessed that.

So if you want to make a block have a certain texture always face you when you place it, just like a pumpkin, then this example should be very useful for that. If you just want something simple, that isn't affected by your position when placing it, the Sandstone example is probably the best for that, as there is nothing else in it that might be confusing like there is in the pumpkin example.
FlowerChild wrote:Remain ever vigilant against the groth menace my friends. Early detection is crucial in avoiding a full-blown groth epidemic.
User avatar
hooktail154
Posts: 18
Joined: Mon Jul 04, 2011 10:39 pm
Location: In ur block dispensar!

Re: Who here makes their own mods?

Post by hooktail154 »

If you're using ModLoader, you add texture overrides by calling:

int texID = ModLoader.addOverride("/terrain.png","/path/to/yourfile.png");

You will have to insert yourfile.png in the right spot in the jar in MCP/jars/bin/minecraft.jar like you would install a mod.

To make a block use the texture, return the int texID in the texture functions mentioned above. You can set the int as an (idk what they're called in java) variable at the bottom of your mod_name.java file, outside any function:

public int texID;

Then, you can call this in your BlockName.java file in one of the texture functions:

return mod_name.texID;

That'll give it that particular texture.

Hope it's not too incoherent and ramble. I might post parts of my stuff here later so you can get a better idea.
User avatar
darahalian
Posts: 578
Joined: Mon Jul 04, 2011 9:57 pm

Re: Who here makes their own mods?

Post by darahalian »

hooktail154 wrote:If you're using ModLoader, you add texture overrides by calling:

int texID = ModLoader.addOverride("/terrain.png","/path/to/yourfile.png");

You will have to insert yourfile.png in the right spot in the jar in MCP/jars/bin/minecraft.jar like you would install a mod.

To make a block use the texture, return the int texID in the texture functions mentioned above. You can set the int as an (idk what they're called in java) variable at the bottom of your mod_name.java file, outside any function:

public int texID;

Then, you can call this in your BlockName.java file in one of the texture functions:

return mod_name.texID;

That'll give it that particular texture.

Hope it's not too incoherent and ramble. I might post parts of my stuff here later so you can get a better idea.
Thanks! I was testing out what I had said in my post, and I was having trouble because I was defining the texID variable inside the getBlockTexture function, and so, since this function gets called a bunch of times, ModLoader was adding new overrides of the same picture until it ran out of spaces and bugged out. I'm kind of new to java, so I make these kinds of mistakes. Again, many thanks, as this is exactly what I needed. I will quote this in my other post.
FlowerChild wrote:Remain ever vigilant against the groth menace my friends. Early detection is crucial in avoiding a full-blown groth epidemic.
Evolution
Posts: 7
Joined: Wed Jul 06, 2011 4:46 pm

Re: Who here makes their own mods?

Post by Evolution »

I made pigs drop diamonds once.
Image
User avatar
cheechako
Posts: 114
Joined: Mon Jul 04, 2011 11:40 pm

Re: Who here makes their own mods?

Post by cheechako »

While migrating my own stuff to 1.7, I threw this together. You can grab the mod from my dropbox and just drop the zip into the mods folder. However, this is a teaching example, and not designed for real use; the IDs are hard-coded. The zip contains the horrible sample textures and all of the commented sorce code.

This example assumes that you have MCP and Eclipse properly installed, Minecraft decompiled, and can find your way around in Eclipse.

It contains the mod file, a do-nothing item, and a do-nothing block that uses two custom textures plus the vanilla mossy texture.

mod_ACME_Sample.java
Spoiler
Show

Code: Select all

package net.minecraft.src;

// ACME - A Cheechako Minecraft Extension

public class mod_ACME_Sample extends BaseMod {
    public static Block acmeBlock;        // Will be the instance of our custom block.
                                        // Note that we use the base class, and not our class.
    public static int acmeBlockID;        // The block ID that will be used, set by ReadConfig()
                                        // IDs range from 0-255, but 0 is air (or no block),
                                        // and vanilla uses almost to 100.
    public static Item acmeItem;        // Will be the instance of our custom item.
    public static int acmeItemID;        // The Item ID that will be used, set by ReadConfig()
                                        // Items IDs are different than blocks, and range
                                        // from 256(?) to 64K.
    
    @Override
    // Required by ModLoader since we extend the BaseMod class, but you can use whatever
    // string you want here. If this is missing, a proper IDE (Eclipse) will warn you and
    // offer to insert a 'return null' stub.
    public String Version() {
        return "ACME Sample Mod v0.1 for MC 1.7.x";
    }
    
    // ModLoader will call this method (the constructor) to "initialize" our mod
    public mod_ACME_Sample() {
        ReadConfig(); // see below
        
        // For the block, first create the global instance of the block
        acmeBlock = new ACME_SampleBlock(acmeBlockID, "My Block", AddTTX("/acme/SampleBlock.png"));
        // Register then name in ModLoader
        ModLoader.AddName(acmeBlock, "My Block");
        // And register the block
        ModLoader.RegisterBlock(acmeBlock);
        
        // For the item, first create the global instance
        acmeItem = new ACME_SampleItem(acmeItemID, "My Item", AddITX("/acme/SampleItem.png"));
        // Register the name in ModLoader
        ModLoader.AddName(acmeItem, "My Item");
        // There is no RegisterItem() method.

        
        // Some lame testing recipes - just hope you can find enough dirt
        ModLoader.AddShapelessRecipe(new ItemStack(acmeItem), new Object[] { Block.dirt });
        
        // For a crafting recipe, make sure that your layout strings are the proper lengths
        // and include spaces as needed. Most characters can be used since they are defined
        // using the pairings as seen below.
        ModLoader.AddRecipe(new ItemStack(acmeBlock), new Object[] {
                "a a", " a ", "ddd",
                Character.valueOf('a'), acmeItem,
                Character.valueOf('d'), Block.dirt
            });
        
    }
    
    // This "wraps" the call to the ModLoader function, making for shorthand coding.
    // The fewer textures you have, the less useful this might be. Remember that the
    // more textures you have, the more you may cause MC to hit a limit and black screen.
    // AFAIK, this method needs to be public and static to be called from your other
    // classes.
    //
    // Note that I've had best debugging results by putting my acme folder (with all
    // my graphics) inside the minecraft.jar in the jars folder.
    public static int AddTTX(String texture_file)
    {
        return ModLoader.addOverride("/terrain.png", texture_file);
    }

    // As above, but for the items.
    public static int AddITX(String texture_file)
    {
        return ModLoader.addOverride("/gui/items.png", texture_file);
    }
    
    // This sample does NOT implement a config (or props) file. This method should
    // handle such a thing, but instead sets IDs to hard-coded values, which is a
    // VERY BAD THING.
    // Please refer to the ModLoader java docs (saveConfig/loadConfig) or other
    // examples and tutorials to learn how to allow user-configurable IDs and
    // other settings.
    private void ReadConfig() {
        acmeBlockID = 99;        // 99 is not used by Vanilla MC (currently), so will
                                // suffice for this sample block.
        acmeItemID = 2001;        // Item IDs range higher than block IDs.
    }
}
 
ACME_SampleBlock.java
Spoiler
Show

Code: Select all

package net.minecraft.src;

// A very simple block with a custom texture, and a second texture for the front.
// Note that you don't have to stick with certain names for classes/files, but it
// helps if the names are descriptive. I like 'ACME' because most of my files are
// at the head of the Package Explorer list in Eclipse.

public class ACME_SampleBlock extends Block {
    public int frontTX;        // the ID for a custom texture used only for the front
    public int backTX = 36;    // the existing mossy cobble texture
                            // to figure out existing IDs, open terrain.png and count.
                            // the upper left is 0.

    // This is a different constructor than most examples. You can design whatever
    // constructor best suits your needs. There are many ways to do some common things
    // in MC and java. For example, you could do a 'dot' method call:
    //     MyBlock = new ACME_SampleBlock(id, tx).setBlockName("My Block");
    //
    // Personally, I don't like that syntax, and this example serves as one of the
    // many alternatives.
    
    protected ACME_SampleBlock(int block_id, String name, int primary_texture) {
        // Always call the super (the base class constructor) first
        super(block_id, primary_texture, Material.wood);    // change material as needed, or add
                                                            // it as an argument to the constructor
        setBlockName(name);
        setHardness(0.1F);        // Rather soft for debug purposes. Look at other blocks (check towards
                                // the end of Block.java, etc.) for sample values.
                                // this could also be a constructor argument or a 'dot' method call

        // Add anything else you need based on your block
        
        // this demonstrates a call to a "global" method in our mod_ file
        frontTX = mod_ACME_Sample.AddTTX("/acme/SampleFront.png");
    }

    // This code is taken directly from BlockFurnace. When Steve places a block, it will face Steve
    // in one of the cardinal directions (NSEW) - never up or down. Take note - if you want to do
    // something, think of other things that do something similar and start looking through code
    // for those things. Sometimes you can just cut and paste, but the more you try to learn what
    // is going on, the more you can advance beyond simply cloning other things.
    public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
    {
        int l = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
        if(l == 0)
        {
            world.setBlockMetadataWithNotify(i, j, k, 2);
        }
        if(l == 1)
        {
            world.setBlockMetadataWithNotify(i, j, k, 5);
        }
        if(l == 2)
        {
            world.setBlockMetadataWithNotify(i, j, k, 3);
        }
        if(l == 3)
        {
            world.setBlockMetadataWithNotify(i, j, k, 4);
        }
    }
    
    // I am not sure about this - it might be called when blocks are placed from some
    // non-living thing, like a dispenser. This method works well enough for a sample
    // module, but you may want to refer to other blocks and examples.
    public void onBlockAdded(World world, int i, int j, int k)
    {
        super.onBlockAdded(world, i, j, k);        // remember, when we call super(), it must be first
        world.setBlockMetadataWithNotify(i, j, k, 3);
    }

    // This could be made public static in your main mod_ file if you had other blocks
    // that needed this method.
    private int GetOppositeSide(int i) {
        switch(i) {
        case 0: return 1;
        case 1: return 0;
        case 2: return 3;
        case 3: return 2;
        case 4: return 5;
        case 5: return 4;
        }
        return 0;        
    }

    // We must override the base Block method if we want to be fancy with custom textures.
    // Once again, refer to other blocks for examples depending on which sides you need textured.
    // And ALWAYS remember that there is a limit to the number of textures, and too many
    // (your mod combined with any others) can cause black screen crashes.
    // Note that we've already loaded textures back in the mod_ file and the block's
    // constructor. This method just returns the proper texture id based on the side
    // being rendered.
    public int getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) {
        int i1 = iblockaccess.getBlockMetadata(i, j, k);
        if (l == i1) return frontTX;
        if (l == GetOppositeSide(i1)) return backTX;
        return blockIndexInTexture;        // note that this value was set by the super() call
                                        // in the block's constructor
    }
    
    // We also must override this method, which returns the texture for a given side
    // when the iconic version of the block is rendered. This is used when it is floating
    // on the ground as an item, in the inventory bar, and so on.
    public int getBlockTextureFromSide(int i) {
        if (i == 3) return frontTX;
        if (i == 2) return backTX;
        return blockIndexInTexture;
    }    

}
 
ACME_SampleItem.java
Spoiler
Show

Code: Select all

package net.minecraft.src;

// This is a very simple do-nothing item. Check Item.java for many examples, and look
// at other base classes such as ItemFood for items that can be consumed for health.

public class ACME_SampleItem extends Item
{
    public ACME_SampleItem(int id, String name, int tid)
    {
        super(id);
        setIconIndex(tid);
        setItemName(name);
    }
}
 
"That's the nice thing about mods. There's something for everyone. Some of us like to build functional elevators, while others want to run around with a bunny on their head."
User avatar
RegularX
Posts: 44
Joined: Tue Jul 05, 2011 11:35 am

Re: Who here makes their own mods?

Post by RegularX »

@cheechako - nice! More baseline samples out there the better. It's kind of a mishmash of tutorials at the moment it seems :/

I just created Glowstone dust by rubbing three sticks together, and couldn't be happier. Beer time.




(no, I don't pan on actually releasing that as a mod). Was just happy to get MCP up and running properly on the Mac. Using Coda of all things.
User avatar
darahalian
Posts: 578
Joined: Mon Jul 04, 2011 9:57 pm

Re: Who here makes their own mods?

Post by darahalian »

cheechako wrote:While migrating my own stuff to 1.7, I threw this together. You can grab the mod from my dropbox and just drop the zip into the mods folder. However, this is a teaching example, and not designed for real use; the IDs are hard-coded. The zip contains the horrible sample textures and all of the commented sorce code.

This example assumes that you have MCP and Eclipse properly installed, Minecraft decompiled, and can find your way around in Eclipse.

It contains the mod file, a do-nothing item, and a do-nothing block that uses two custom textures plus the vanilla mossy texture.
Thanks! I'll definitely be downloading this as a reference.
FlowerChild wrote:Remain ever vigilant against the groth menace my friends. Early detection is crucial in avoiding a full-blown groth epidemic.
User avatar
RegularX
Posts: 44
Joined: Tue Jul 05, 2011 11:35 am

Re: Who here makes their own mods?

Post by RegularX »

Hrm, anyone know why setItemName in Item isn't updating the hover text in inventory?
User avatar
cheechako
Posts: 114
Joined: Mon Jul 04, 2011 11:40 pm

Re: Who here makes their own mods?

Post by cheechako »

RegularX wrote:Hrm, anyone know why setItemName in Item isn't updating the hover text in inventory?
AFAIK, setItemName() is some internal name. Check my sample code - you also need to use ModLoader.AddName() which sets the inventory name.
"That's the nice thing about mods. There's something for everyone. Some of us like to build functional elevators, while others want to run around with a bunny on their head."
User avatar
RegularX
Posts: 44
Joined: Tue Jul 05, 2011 11:35 am

Re: Who here makes their own mods?

Post by RegularX »

cheechako wrote:
RegularX wrote:Hrm, anyone know why setItemName in Item isn't updating the hover text in inventory?
AFAIK, setItemName() is some internal name. Check my sample code - you also need to use ModLoader.AddName() which sets the inventory name.
:facepalm:

Naturally when I look at a handy example, I stare at the wrong sample class. Danke.
User avatar
hooktail154
Posts: 18
Joined: Mon Jul 04, 2011 10:39 pm
Location: In ur block dispensar!

Re: Who here makes their own mods?

Post by hooktail154 »

RegularX wrote:(no, I don't pan on actually releasing that as a mod). Was just happy to get MCP up and running properly on the Mac. Using Coda of all things.
For the love of god, just use Eclipse. It's cross-platform and has anything and everything could want in an IDE (except doing the coding for you). Go to eclipse.org. Use MCP's builtin eclipse support (point the eclipse workspace to the eclipse folder in the MCP folder). Super simple, super quick. Do it. You'll not regret it.

Eclipse, being java, is available for Windows, Mac, Linux, and more. Use it. Love it. But never forget that Xcode is, and always will be, better.
User avatar
RegularX
Posts: 44
Joined: Tue Jul 05, 2011 11:35 am

Re: Who here makes their own mods?

Post by RegularX »

hooktail154 wrote:
RegularX wrote:(no, I don't pan on actually releasing that as a mod). Was just happy to get MCP up and running properly on the Mac. Using Coda of all things.
For the love of god, just use Eclipse. It's cross-platform and has anything and everything could want in an IDE (except doing the coding for you). Go to eclipse.org. Use MCP's builtin eclipse support (point the eclipse workspace to the eclipse folder in the MCP folder). Super simple, super quick. Do it. You'll not regret it.

Eclipse, being java, is available for Windows, Mac, Linux, and more. Use it. Love it. But never forget that Xcode is, and always will be, better.
I've already got about three flavors of Eclipse on the machine, use it frequently throughout the day for work. Big fan of the IDE, but looking for excuses to try other things. And since I wanted to understand what MCP was doing behind the scenes with the scripts, command line compiling was the way to go.

Now I've got a script which recompiles, reob's, moves my classes, and resets the save point.

But in general, yes, I agree. Anyone poking at this would be well served to try Eclipse first.
User avatar
RegularX
Posts: 44
Joined: Tue Jul 05, 2011 11:35 am

Re: Who here makes their own mods?

Post by RegularX »

Has anyone played with extending ItemMap yet? A class with just extending, no new overrides, spawns correctly but doesn't trigger the first person map when held. Can't seem to find where that's getting triggered, assuming it might be looking for the specific class.
User avatar
hooktail154
Posts: 18
Joined: Mon Jul 04, 2011 10:39 pm
Location: In ur block dispensar!

Re: Who here makes their own mods?

Post by hooktail154 »

RegularX wrote:Has anyone played with extending ItemMap yet? A class with just extending, no new overrides, spawns correctly but doesn't trigger the first person map when held. Can't seem to find where that's getting triggered, assuming it might be looking for the specific class.
I'll check in the morning (heh, that's an hour. Hawaii time sucks.) It probably wouldn't be the item class. There is probably something in a render class or GUI class somewhere, so I would search elsewhere.
Post Reply