Jump to content

[1.14.4] Adding Items to Vanilla Generated Chests


Ommina

Recommended Posts

I expected this to take... a few minutes.  At most.  Yet here I am.

 

Let's say I want to add moditem to the optional bonus chest created at world spawn.  I expected to add a spawn_bonus_chest.json to loot_tables, get it merged into the vanilla version, then be on my way with a nice plate of crackers.

 

Except it is aggressively ignored.  It does seem to be loaded, or at least parsed, insofar as if I put weird values in the json, I will get notes in the console.  But the chest remains bereft of moditem.

 

If I move spawn_bonus_chest.json to the minecraft namespace, it works, but it replaces the vanilla table, instead of adding to it.

 

I note there is a LootTableLoadEvent, but adding the entries via code strikes me as so far from the current data-driven style of controlling loot that I have trouble believing it is the correct way of doing this.  Is there some way of merging my loot_table json with vanilla's?

Link to comment
Share on other sites

Having the same issues when it comes to adding custom loot to dungeons, the docs aren't any help either I've noticed.
It seems the way it was done in 1.13 isn't working for 1.14 anymore since part of the code is now private.
Any help on that end would also be appreciated.

Link to comment
Share on other sites

1 hour ago, Ommina said:

I note there is a LootTableLoadEvent, but adding the entries via code strikes me as so far from the current data-driven style of controlling loot that I have trouble believing it is the correct way of doing this.  Is there some way of merging my loot_table json with vanilla's?

I believe this is the best way to do it at the moment, and yes it does stay away from the data driven system, but currently no way around that. Because datapacks as they are override the whole loot table. Which is a little counter productive when you just want to add to it or remove something from it.

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.

Link to comment
Share on other sites

23 hours ago, Animefan8888 said:

I believe this is the best way to do it at the moment, and yes it does stay away from the data driven system, but currently no way around that. Because datapacks as they are override the whole loot table. Which is a little counter productive when you just want to add to it or remove something from it.

 

Thank you for the reply.  It does wholly make sense that the mod datapack overwrite the vanilla entry.  Still feels weird though!

 

@thinkverse  I don't know how adding custom loot to chests was done in 1.13, so I can't provide any particular "converting one method to another" insights.  In 1.14.4, though, a LootTable object pretty much follows the same 'form' as a loot_tables JSON files, with pretty much the same naming.  If you get a feel for how the JSON works, the LootTable object works pretty much the same way.

 

Generally, the LootTableLoadEvent will give you the LootTable object.  To the LootTable, you add one or more LootPool objects.  To each LootPool, you add one or more LootEntry.  Annnd... to each LootEntry, one or more LootFunction.  Each individual object will store the same bits of information as its corresponding block in the JSON.  For example, the pool object has .rolls().

 

Each of the various objects do seem to have their own JSON deserializer, so it may even be possible to parse some mod-provided JSON and just add the result to the provided LootTable.  I may spend some time going down this avenue at some point, but for now I'm very much in the "make it work so I can go back to being bad at creating textures" phase.

  • Like 1
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.

×
×
  • Create New...

Important Information

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