Jump to content

[1.14.4] Can't figure out to add entry to already existing lootpool


Recommended Posts

Posted (edited)

So I tried to make it so that my newly added seeds drop when breaking grass, just like wheat seeds. I couldn't get it working so I tried to do what @Draco18s mentioned in an earlier thread.

 

Here's what I did

Spoiler

@Mod.EventBusSubscriber(modid = BoneAppleTea.MOD_ID)
public class EventHandlers {

    @SubscribeEvent
    public static void onLootLoad(LootTableLoadEvent event) {
        if (event.getName().equals(new ResourceLocation("minecraft", "blocks/grass"))) {
			event.getTable().addPool(LootPool.builder().addEntry(TableLootEntry.builder(new ResourceLocation(BoneAppleTea.MOD_ID, "blocks/grass"))).build());
        }
    }
}

 

 

And here's the json file I created:

Spoiler

{
  "type": "minecraft:block",
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "minecraft:alternatives",
          "children": [
            {
              "type": "minecraft:item",
              "conditions": [
                {
                  "condition": "minecraft:random_chance",
                  "chance": 0.125
                }
              ],
              "functions": [
                {
                  "function": "minecraft:apply_bonus",
                  "enchantment": "minecraft:fortune",
                  "formula": "minecraft:uniform_bonus_count",
                  "parameters": {
                    "bonusMultiplier": 2
                  }
                },
                {
                  "function": "minecraft:explosion_decay"
                }
              ],
              "name": "boneappletea:barley_seeds"
            }
          ]
        }
      ]
    }
  ]
}

 

 

This is all similar to what Draco18s did in his mod:

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderfarming/EventHandlers.java

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/resources/data/harderfarming/loot_tables/blocks/grass.json

 

The problem is that this adds a new pool to the already existing loot table for minecraft:grass. This makes it so that when you shear grass, the seeds from my mod can still drop. To fix this I don't want to add a new pool to the table, but modify the already existing table (the one which tells it to drop grass when using shears, and when not using shears have a chance to drop wheat seeds). If I can add an entry to this table then grass will: A: drop itself when using shears, B: sometimes drop wheat seeds, or C : sometimes drop my seeds.

 

I tried to add an entry to the pool but because addEntry can not be directly used (it is commented out in LootPool.class, I have no idea why) I did the following:

Spoiler

@Mod.EventBusSubscriber(modid = BoneAppleTea.MOD_ID)
public class EventHandlers {

    @SubscribeEvent
    public static void onLootLoad(LootTableLoadEvent event) {
        if (event.getName().equals(new ResourceLocation("minecraft", "blocks/grass"))) {

            LootPool pool = event.getTable().getPool("main");
            LootPool newPool = pool.builder().addEntry(TableLootEntry.builder(new ResourceLocation(BoneAppleTea.MOD_ID, "blocks/grass"))).build();

            event.getTable().addPool(newPool);
            event.getTable().removePool("main");
        }
    }
}

 

This also didn't work because now the original LootPool is not working and only the entry that I added. Grass can now only drop my seeds, even when using shears. Wheat seeds or grass itself don't drop anymore. I also tried this:

Spoiler

@Mod.EventBusSubscriber(modid = BoneAppleTea.MOD_ID)
public class EventHandlers {

    @SubscribeEvent
    public static void onLootLoad(LootTableLoadEvent event) {
        if (event.getName().equals(new ResourceLocation("minecraft", "blocks/grass"))) {

            LootPool pool = event.getTable().getPool("main");
            event.setTable(LootTable.builder().addLootPool(pool.builder().addEntry(TableLootEntry.builder(new ResourceLocation(BoneAppleTea.MOD_ID, "blocks/grass")))).build());
        }
    }
}

 

The result of this was the same as the thing I tried earlier: only my seeds drop. Wheat seeds and grass itself don't drop anymore.

 

If someone could help me with this that would be greatly appreciated.

Edited by Tieso2001
Posted

That gets tricky.

The only thing I can suggest is doing what I did back in 1.12:

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/util/LootUtils.java

I have not updated this class and it does some reflection magic to get access to things, but it will let you directly modify loot pools. Or at least, give you the information necessary to write such a hook.

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

Thanks for the information. I was hoping that it would be easier than that. Hope forge will add an easy way to do this because adding seeds to grass in 1.12.2 was really easy, using just one line of code.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hey, sorry I haven't said anything in a while. I was banned on here for sending you straight up crash logs and they banned me for spam... but I learned that these forums are for forge only and I was working with neoforge... but thank you for all the help.
    • la verdad nose que hago
    • Ok i check and this is real axioM, BUT i have seen strange thing when mods less then 100 is working great but when its more then 100, i got crash   i realy need this mod can i some how fix it? or only delete axiom
    • It is an issue with the mod Axiom
    • I am in 1.20.1, and I have about 50 mods, I'd say. But for some reason, the search bar broke at some point. It's a real pain to search for a certain object.. Mods that I have(I had to write ALL OF THESE OUT arhg): Epic Knights. AI-Improvements, Alexscaves, alexsmobs, AmbientSounds, Aquamirae, Architectury, Betterfpsdist, BiomesOPlenty, Bookshelf, Born In Chaos, Bountiful Critters, CarbonConfig, Citadel, Cloth config, Clumps, Corgilib, Creative Core, Creeperoverhaul, crittersandcompanions, CullLessLeaves, Cupboard, Duckling, Embeddium, Enchantment Descriptions, Enderman Overhaul, Entity Model Features, Entity Texture Features, Entity Culling, Exotic Birds, Extra Sounds, Falling Leaves, Farmers Delight, Fast Leaf Decay, Fastload, Ferritecore, FpsReducer2, Framework Forge, Gamma Creatures Mod, Geckolib, Geophilic, Ghosts, Goblin Traders, Gpumemleakfix, Guardvillagers, Ichunutil, ImmediatelyFast Forge, Immersive Paintings, Incendium, Konkrete Forge, Let Sleeping Dogs Lie, Make Bubbles Pop, MCW Bridges, MCW doors, MCW Fences, MCW lights, MCW paths, MCW trapdoors, Medieval Paintings, More Creative Tabs Combo, Nether's Overhaul, Nyfss Spiders Forge, Obscure Api, oculus MC, Oh The Biomes We've Gone, Oh The Trees You'll Grow, Physics Mod, Prehistoric Park, Quark Delight, Quark, Rainbow Reef, Refurbished Furniture Forge, Regrowth, Repurposed Structures, Resourcefulconfig, Ribbits, Rubidium, Saturn mc, Skin Layers 3d Forge, Smoothchunk, Starlight, Structory, TerraBlender, Terralith, Visuality, Water Erosion, Xaeros Minimap, Xaeros World Map, YungsApi, YungsBetter Desert Temples, Yungs Better Dungeons, Yungs Jungle Templates, Yungs Better Mineshafts, Yungs Better Nether Fortresses, Yungs Better Strongholds, Yungs Better Witch Huts, Yungs Bridges, Yungs Extras, Zeta.   Why isn't my search bar working!!!!😭
  • Topics

×
×
  • Create New...

Important Information

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