Jump to content

How to fix textures runtime and use textures from outside the mod's jar.


Recommended Posts

Posted

Hello Forge Community!

 

For my new mod I am adding blocks runtime. This is necessary as there's user input to add the correct block to his game. The code for adding this block is:

 

String blockName = "testblock";
Block block = new Block(Material.rock).setHardness(1.0F).setUnlocalizedName(blockName).setCreativeTab(CreativeTabs.tabBlock);
MyMod.blocks.add(block);
GameRegistry.registerBlock(block, blockName);
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(ModCreator.MODID + ":" + blockName, "inventory"));

 

However, this doesn't get the texture working, even though the texture is included in the mod's resources folder. If I do exactly the same as above of preinitialisation the texture works  perfectly, so there is a texture baking happening within forge somewhere there which I'd have to trigger manually... But how?

 

The second problem I'm facing (unrelated to the previous problem) is that I'd like to bind a texture that's not in the mod's jar (resources folder). A texture file that is simply in the .minecraft folder. I can't seem to find out to bypass the minecraft "domain" system and just pass in a texture png file myself.

 

Does anyone have any pointers on how to do this?

Posted

Why? If world is already running, it's impossible to add a block because there are tons of problems: Networking, Texture Stitching, Block id management, etc.

You would better use TileEntities.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Well, that's not entirely true. Really the only problem is the texture stitching. It's already proven to be working in my Instant Massive Structures Mod (check this:

).

 

How would you do it with TileEntities to simulate the same thing?

Posted

Even if it works on vanilla, it doesn't mean that it has enough compatibility with other mods.

There will be high possibility to break some mechanisms if it is not done on PreInit phase.

 

If the information you want for the blocks are just the structure id and display name, TileEntity & ItemStacks can contain those information quite easily. Even if you save the whole structure there, TileEntity can hold it in most case.

 

How to display the name? Just override Item#getDisplayName and give the display name.

How to transfer the information? Look at the ItemBlock code, and override proper methods. Also Block#getDrops might be overriden on Block, but anyway this is super simple in modding wise.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

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.