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

    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
    • sorry, I might be stupid, but how do I open it? because the only options I have are too X out, copy it, which doesn't work and send crash report, which doesn't show it to me, also, sorry for taking so long.
    • Can you reproduce this with version 55.0.21? A whole lot of plant placement issues were just fixed in this PR.
    • Necro'ing that thread to ask if you found a solution ? I'm encountering the same crash on loading the world. I created the world in Creative to test my MP, went into survival to test combat, died, crashed on respawn and since then crash on loading the world. Deactivating Oculus isn't fixing it either, and I don't have Optifine (Twilight forest is incompatible)
  • Topics

×
×
  • Create New...

Important Information

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