Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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?

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.

  • Author

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?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.