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

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" } } ]
      }
     ]
  }]
}


    

 

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.

  • Author

Totally different approach... I will give it a try (will need some extra-time though).

 

Thanks for your prompt reply!!!

 

  • Author

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.

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.