Jump to content

[1.19.4] Registering a LootItemFunction / LootItemFunctionType?


Recommended Posts

Posted (edited)

I have a custom loot function that I want to have run when my own loot tables for my own blocks runs (it sets the number of drops based on a blockstate value).

Things that did not work:

  • Using Forge registries
    • Forge does not provide a replacement for BuiltInRegistries.LOOT_FUNCTION_TYPE
    • Forge also does not appear to need or provide a replacement for BuiltInRegistries.LOOT_CONDITION
      • CanToolPerformAction just creates a new LootItemConditionType and runs with it, no registration needed

  • Using an existing LootItemFunctionType in LootItemFunctionType getType()
    • De/serializer attempts to cast my function to an unrelated function
  • Using a new LootItemFunctionType()
    • De/serializer gets a null serializer to serialize with
      • Cannot invoke "net.minecraft.resources.ResourceLocation.toString()" because the return value of "net.minecraft.core.Registry.getKey(Object)" is null

  • Attempting to make the same calls LootFunctions.register does
    • Fail with fml.modloading.failedtoloadmod
  • Attempting to make the same calls as LootFunctions.register at different points during the init/setup process (tried numerous events)
    • Most fail with an Optional.get() returning no value (in this case, trying to get the built in registry's ResourceKey as a ResourceKey<E> not a ResourceKey<? extends Registry<E>>)
    • Others fail with fml.modloading.failedtoloadmod

Things I will not do, but which would probably work:

  • Individually test against 16 different values and individually compute the resulting fixed value count
    • This is so dumb I'm not even going to pretend that I should consider it
Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)

Solved

public static final DeferredRegister<LootItemFunctionType> FUNCS = 
  DeferredRegister.create(Registries.LOOT_FUNCTION_TYPE, MODID);

I hadn't been able to find Registries.LOOT_FUNCTION_TYPE

 

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.