Jump to content

Creating a block with infinite terrain files


critter1227

Recommended Posts

So, first i am new at modding and such, but i have plans for a mod that adds many blocks for creative purposes. To make my life easier i want to use a terrain file instead of individual 16-bit files. The tutorial* for making the files (as far as i know) doesn't show how to make the blocks read off of the files, so i only get a white block with a black dot. Does the code go directly on the mod_**** file or the block file and where?

 

  public static final Block DarkBrick= new CreatixBlockDarkBrick(340, ModLoader.addOverride("/terrain.png", "/CamelMod/CamelOre/terrain/titaniumore.png")).setHardness(3F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("DarkBrick");

 

* http://minecraftforge.net/wiki/How_to_use_infinite_terrain_and_sprite_indexes

Link to comment
Share on other sites

Heres the code, i mainly have two problems i can explain better now.

 

mod_Creatix.java

package net.minecraft.src;

 

import net.minecraft.src.forge.MinecraftForgeClient;

 

public class mod_Creatix extends BaseMod

{

        public static final Block darkBrick = new CreatixBlockDarkBrick(390, ModLoader.addOverride("/terrain.png", "/CamelMod/CamelOre/terrain/titaniumore.png")).setHardness(3F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("darkBrick");

        public static final Item creatix = (new Item(389)).setIconIndex(0).setItemName("creatix");

        public mod_Creatix()

        {

               

        }

 

        public void load()

        {

          MinecraftForgeClient.preloadTexture("/Creatix/Build.png");

          MinecraftForgeClient.preloadTexture("/Creatix/Items.png");

                ModLoader.registerBlock(darkBrick);

                ModLoader.addName(darkBrick, "Dark Brick");

                ModLoader.addName(creatix, "Creatix");

        }

 

        public String getVersion()

        {

                return "0.0.1";

        }

}

 

 

CreatixBlockDarkBrick.java

package net.minecraft.src;

 

import java.util.Random;

 

import net.minecraft.src.forge.ITextureProvider;

 

public class CreatixBlockDarkBrick extends Block implements ITextureProvider

{

        public CreatixBlockDarkBrick(int i, int j)

        {

                super(i, j, Material.rock);

        }

       

        public String getTextureFile()

        {

                return "/Creatix/Build.png";

        }

       

        public int quantityDropped(Random par1Random)

        {

            return 1;

        }

       

}

 

CreatixItemCreatix

package net.minecraft.src;

 

import java.util.Random;

 

import net.minecraft.src.forge.ITextureProvider;

 

public class CreatixItemCreatix extends Block implements ITextureProvider

{

        public CreatixItemCreatix(int i, int j)

        {

                super(i, j, Material.rock);

        }

       

        public String getTextureFile()

        {

                return "/Creatix/Items.png";

        }

       

        public int quantityDropped(Random par1Random)

        {

            return 1;

        }

       

}

 

1. I don't see a way that CreatixItemCreatix is linked to "  public static final Item creatix = (new Item(389)).setIconIndex(0).setItemName("creatix");" So i'm not sure if i messed up there.

 

2. I don't know the string to declare where the block dark bricks texture will be, since i'm using an infinite terrain file.

 

I hope thats all info, but reply if you need more to help.

Link to comment
Share on other sites

sorry, i was rushed, the only same parts that i would change are the file paths.

 

*updated*

Um, the dark brick thing is not right. It needs to just have the index of the block in your sprite sheet. You also need to make the folders in the <MCP folder>/jars/minecraft.jar.

So you would make the folder Creatix in it and have build.png and Items.png.

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Link to comment
Share on other sites

sorry, i was rushed, the only same parts that i would change are the file paths.

 

*updated*

Um, the dark brick thing is not right. It needs to just have the index of the block in your sprite sheet. You also need to make the folders in the <MCP folder>/jars/minecraft.jar.

So you would make the folder Creatix in it and have build.png and Items.png.

 

And then you use vanilla's getBlockTextureFromSideAndMetadata() function in order to tell Minecraft where on your new terrain file is the texture you want to use.

Link to comment
Share on other sites

Also, do not static construct your blocks, construct them in load().

 

...Stupid question, but: Why?!

I'm gonna go from a guess here and say it's because the load function was made specifically to load the mod and if there was an error initializing a block of should appear during the load() and not during the constructor of the mod.

My tutorial series on the wiki has been discontinued until I get the hang of forge for 3.1.x and just everything from forge in general.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.