Jump to content

Recommended Posts

Posted

Hi there!

 

I'm trying to inject my own loot tables within the vanilla chests ones, so there is a chance that a player can find one of those items and blocks. I am doing that in two separate mods. The weird thing is: if I run each mod separately, the loot_tables work fine, and you can find the items or blocks in vanilla chests. But if I run the game with both mods, the common loot tables fail! (in one of the mods I inject my own table in all chests tables, while in the other mod I just inject the tables on some specific chests tables... it is in those tables "common" which fails when running both at the same time!).

 

Totally lost here (it would be easier if it ALWAYS fail!).

 

Here is my event handler:

    public class onLooTableLoadListener {
        
        @SubscribeEvent
        public void onLootTablesLoad(final LootTableLoadEvent event) {

            // Test: /loot give @p loot minecraft:chests/end_city_treasure
            if (event.getName().equals(new ResourceLocation("minecraft", "chests/buried_treasure"))
                || event.getName().equals(new ResourceLocation("minecraft", "chests/underwater_ruin_big"))
                || event.getName().equals(new ResourceLocation("minecraft", "chests/pillager_outpost"))
                || event.getName().equals(new ResourceLocation("minecraft", "chests/end_city_treasure"))
                || event.getName().equals(new ResourceLocation("minecraft", "chests/stronghold_library"))
                ) {              
                event.getTable().addPool(LootPool.builder().addEntry(TableLootEntry.builder(new ResourceLocation(MODID, "chests/time_sword"))).build());
            }
        }
    }

 

The handler on the other mod:

    public class onLooTableLoadListener {
        
        @SubscribeEvent
        public void onLootTablesLoad(final LootTableLoadEvent event) {
            
            String prefix = "minecraft:chests/";
            String name = event.getName().toString();
            
            if (name.startsWith(prefix)) {
                event.getTable().addPool(LootPool.builder().addEntry(TableLootEntry.builder(new ResourceLocation(Refs.MODID, "chests/lazy_builder"))).build());
            }
        }
    }

   

The loot table .json file (I have tried many many different combinations, adding and removing fields... they all with the same result):

{
  "pools": [{
     "rolls": 1,
     "entries": [
      {
        "type": "item",
        "name": "simpleclock:time_sword",
        "weight": 50,
        "functions": [ { "function": "minecraft:set_count", "count": { "min": 1.0, "max": 1.0, "type": "minecraft:uniform" } } ]
      }
    ]
  }]
}


And the second loot table .json file

{
  "pools": [{
    "rolls": 1,
    "entries": [
      {
        "type": "minecraft:item",
        "name": "lazybuilder:start_block",
        "weight": 30,
        "functions": [ { "function": "minecraft:set_count", "count": { "min": 1.0, "max": 1.0, "type": "minecraft:uniform" } } ]
      },
      {
        "type": "minecraft:item",
        "name": "lazybuilder:mid_block",
        "weight": 30,
        "functions": [ { "function": "minecraft:set_count", "count": { "min": 1.0, "max": 1.0, "type": "minecraft:uniform" } } ]
      },      
      {
        "type": "minecraft:item",
        "name": "lazybuilder:end_block",
        "weight": 30,
        "functions": [ { "function": "minecraft:set_count", "count": { "min": 1.0, "max": 1.0, "type": "minecraft:uniform" } } ]
      },      
      {
        "type": "minecraft:item",
        "name": "lazybuilder:copy_paste_block",
        "weight": 10,
        "functions": [ { "function": "minecraft:set_count", "count": { "min": 1.0, "max": 1.0, "type": "minecraft:uniform" } } ]
      }
     ]
  }]
}


    

 

Posted
16 minutes ago, Kalma said:

public void onLootTablesLoad(final LootTableLoadEvent event) {

Do not use this, use GlobalLootModifiers.

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

Sorry to reopen this thread... and sorry again because I forgot something crucial in my previous post: I am using Forge 1.14.4.

I finally got the time to attempt this other method, but my  IDE (Eclipse) is not able to find LootModifier class (nor even trying to import it from here:  net.minecraftforge.common.loot.LootModifier)

In addition to that, I am not sure how to inject my custom pools to the existing chests loot_tables using this method.  The documentation here: https://mcforge.readthedocs.io/en/1.14.x/items/globallootmodifiers/#global-loot-modifiers. explains how to create independent loot_tables, but not how to inject them... anyone knows where to investigate more in detail?

Thx!!!

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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