Jump to content

[1.12.2]Creating Items/Blocks upon creating a world


Recommended Posts

Posted

I'm pretty new to modding and I would like to create a mod in which every world has its unique set of items/blocks. I already have a way of creating a new random set of items and blocks (specifically a material, an ore for that material, and a set of tools for that material) every time I launch minecraft, but this set is destroyed and then recreated (with different names, durabilty, ecc) when relaunched. I would like a way of attaching this random set to the world in which it has been created (actually I would need help with creating the set upon the creation of the world instead of the minecraft launch too because just running the code in the eventHandler net.minecraftforge.event.world.WorldEvent.CreateSpawnPosition doesn't seem to work; I think this has something to do with registries/preInit-Init-postInit but I'm not sure) so that the next time that I open that specific world the items are the same as before. Every bit of help is welcome and if I haven't been clear or you need extra information for answering you just have to ask.

Posted
1 hour ago, leopoldix said:

I already have a way of creating a new random set of items and blocks (specifically a material, an ore for that material, and a set of tools for that material) every time I launch minecraft

I really hope you aren't changing the registry names for those items...

 

1 hour ago, leopoldix said:

actually I would need help with creating the set upon the creation of the world instead of the minecraft launch too

You have to create the Item and Block instances in the registry event. And only in the registry event.

 

1 hour ago, leopoldix said:

so that the next time that I open that specific world the items are the same as before. Every bit of help is welcome and if I haven't been clear or you need extra information for

You need to save the information and store them in the World therefore you need to use a Capability Then you'll have to pass that data onto the items.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • 2 weeks later...
Posted
 
 
 
 
 
 
 
1
On 9/30/2019 at 2:00 AM, Animefan8888 said:

I really hope you aren't changing the registry names for those items...

Actually I am, and I am wondering how I could go on about fixing this. The only thing I can think of is to just modify the name of the various items/blocks via the lang file, but I have no idea how to implement my randomly generated names in there since it is a resource and I don't know if it's possible to change resources through code.

Sorry if I seem stupid or something but probably on this topic I am. Anyway, thank you for your response. 

Posted
4 minutes ago, leopoldix said:

but I have no idea how to implement my randomly generated names in there since it is a resource and I don't know if it's possible to change resources through code.

There is a method in the item class called getUnlocalizedName use the one that takes an ItemStack you'll need to store data on that ItemStack about what its name is.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.