Jump to content

Loot table fishing 1.16.4


Godis_apan

Recommended Posts

Hello again. I've been for some time trying to add fishing to loot tables and it seems it is now possible with GLM using the new loot_table_id condition. However, I've run into a hurdle. I'm adding fish and therefore want to add loot to this loot table: loot_tables/gameplay/fishing/fish.json. But when I do this the fish is not possible to get from fishing or using "/loot give @p fish minecraft:gameplay/fishing ~ ~ ~ ". Only when I use this command can I get my fish: "/loot give @p fish minecraft:gameplay/fishing/fish ~ ~ ~". I've tried debugging it and it seems like the doApply does not get fired when I'm fishing even though I'm modifying that loot table.

 

Loot table class: https://github.com/Phrille/Vanilla-Boom/blob/master/src/main/java/phrille/vanillaboom/loot/LootTableHandler.java

Loot modifier json: https://github.com/Phrille/Vanilla-Boom/blob/master/src/main/resources/data/vanillaboom/loot_modifiers/fish.json

Fish loot table (referenced in the loot modifier json): https://github.com/Phrille/Vanilla-Boom/blob/master/src/main/resources/data/vanillaboom/loot_tables/gameplay/fishing/fish.json

Link to comment
Share on other sites

Yes but when something is fished it calls the fishing loot table which in turn calls fish.json in which I add my loot. How would I otherwise go about adding this? Because if I modify fishing.json more than one fish will added to the loot table.

Link to comment
Share on other sites

Is this the way to do it? Because this isn't working for me yet. This extends my previous LootModifier which handles the serialization.

 

 public static class FishLootModifier extends LootTableDropModifier
    {
        public FishLootModifier(ILootCondition[] conditions, TableLootEntry lootTable, Item[] overwrite)
        {
            super(conditions, lootTable, overwrite);
        }
        
        @Nonnull
        @Override
        protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context)
        {
            try
            {
                Field field = context.getClass().getField("lootTables"); //Just for testing purposes, change to obfuscated name later
                field.setAccessible(true);
                Set<LootTable> set = (Set<LootTable>) field.get(context);
                
                if (set.size() == 1) 
                {
                    return super.doApply(generatedLoot, context); //Adds my table to the list
                }
            }
            catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
            {
                throw new RuntimeException("Could not add access lootTables", e);
            }
            
            return generatedLoot;
        }
    }

 

Link to comment
Share on other sites

Still no luck I'm afraid, now I'm back to the same problem where both the vanilla fish and my fish is added at the same time... Updated my git repo for reference:

https://github.com/Phrille/Vanilla-Boom/blob/master/src/main/java/phrille/vanillaboom/loot/LootTableHandler.java

Link to comment
Share on other sites

What I'm trying to achieve is adding a new fish and then when fishing, either my fish or a vanilla one get fished up. I can't add it to gamplay/fishing/fish.json since like you said: "nested" loot tables will not be affected by GLM. So how do I go about adding a fish to a vanilla loot table without using LootTableLoadEvent that will allow a random fish (vanilla or modded) to be captured. And not wto fish at the same time.

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.

Announcements



×
×
  • Create New...

Important Information

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