Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


Tieso2001
 Share

Recommended Posts

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
Link to comment
Share on other sites

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.

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.

Guest
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • ---- Minecraft Crash Report ---- WARNING: coremods are present:   TransformLoader (DynamicSurroundings-1.12.2-3.6.1.0.jar)   ForgelinPlugin (Forgelin-1.8.4.jar)   MovingWorldCore (movingworld-1.12-6.353-full.jar)   Quark Plugin (Quark-r1.6-179.jar)   CorePlugin (ForgeEndertech-1.12.2-4.5.5.0-build.0561.jar)   CTMCorePlugin (CTM-MC1.12.2-1.0.2.31.jar)   FarseekCoreMod (Farseek-1.12-2.5.1.jar)   FutureMC (future-mc-1.12.2-0.2.6.1.jar) Contact their authors BEFORE contacting forge // Surprise! Haha. Well, this is awkward. Time: 9/20/21 10:59 AM Description: Ticking block entity java.lang.NullPointerException: Ticking block entity     at net.minecraftforge.fluids.FluidStack.<init>(FluidStack.java:72)     at ic2.core.block.transport.TileEntityFluidPipe$PipeFluidHandler.drain(TileEntityFluidPipe.java:350)     at ic2.core.util.LiquidUtil.drainTile(LiquidUtil.java:332)     at ic2.core.util.LiquidUtil.drainTile(LiquidUtil.java:323)     at ic2.core.block.machine.tileentity.TileEntityPump.pump(TileEntityPump.java:204)     at ic2.core.block.machine.tileentity.TileEntityPump.operate(TileEntityPump.java:177)     at ic2.core.block.machine.tileentity.TileEntityPump.canoperate(TileEntityPump.java:146)     at ic2.core.block.machine.tileentity.TileEntityPump.updateEntityServer(TileEntityPump.java:123)     at ic2.core.block.TileEntityBlock.func_73660_a(TileEntityBlock.java:326)     at net.minecraft.world.World.func_72939_s(World.java:1838)     at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:613)     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:767)     at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397)     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668)     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)     at java.lang.Thread.run(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Server thread Stacktrace:     at net.minecraftforge.fluids.FluidStack.<init>(FluidStack.java:72)     at ic2.core.block.transport.TileEntityFluidPipe$PipeFluidHandler.drain(TileEntityFluidPipe.java:350)     at ic2.core.util.LiquidUtil.drainTile(LiquidUtil.java:332)     at ic2.core.util.LiquidUtil.drainTile(LiquidUtil.java:323)     at ic2.core.block.machine.tileentity.TileEntityPump.pump(TileEntityPump.java:204)     at ic2.core.block.machine.tileentity.TileEntityPump.operate(TileEntityPump.java:177)     at ic2.core.block.machine.tileentity.TileEntityPump.canoperate(TileEntityPump.java:146)     at ic2.core.block.machine.tileentity.TileEntityPump.updateEntityServer(TileEntityPump.java:123)     at ic2.core.block.TileEntityBlock.func_73660_a(TileEntityBlock.java:326) -- Block entity being ticked -- Details:     Name: ic2:pump // ic2.core.block.machine.tileentity.TileEntityPump     Block type: ID #388 (ic2.te // ic2.core.block.BlockTileEntity // ic2:te)     Block data value: 1 / 0x1 / 0b0001     Block location: World: (137,34,-88), Chunk: (at 9,2,8 in 8,-6; contains blocks 128,0,-96 to 143,255,-81), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)     Actual block type: ID #388 (ic2.te // ic2.core.block.BlockTileEntity // ic2:te)     Actual block data value: 1 / 0x1 / 0b0001 Stacktrace:     at net.minecraft.world.World.func_72939_s(World.java:1838)     at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:613) -- Affected level -- Details:     Level name: world     All players: 1 total; [EntityPlayerMP['ZtiromDE'/383, l='world', x=136.18, y=35.14, z=-88.54]]     Chunk stats: ServerChunkCache: 137 Drop: 0     Level seed: 6427110845652378783     Level generator: ID 00 - default, ver 1. Features enabled: false     Level generator options:     Level spawn location: World: (0,0,0), Chunk: (at 0,0,0 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)     Level time: 0 game time, 0 day time     Level dimension: 0     Level storage version: 0x00000 - Unknown?     Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)     Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false Stacktrace:     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:767)     at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397)     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668)     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)     at java.lang.Thread.run(Unknown Source) -- System Details -- Details:     Minecraft Version: 1.12.2     Operating System: Windows 10 (amd64) version 10.0     Java Version: 1.8.0_301, Oracle Corporation     Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation     Memory: 2877134552 bytes (2743 MB) / 4130340864 bytes (3939 MB) up to 8388608000 bytes (8000 MB)     JVM Flags: 1 total; -Xmx9000M     IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 7     FML: MCP 9.42 Powered by Forge 14.23.5.2854 58 mods loaded, 58 mods active     States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored     | State  | ID                                           | Version            | Source                                        | Signature                                |     |:------ |:-------------------------------------------- |:------------------ |:--------------------------------------------- |:---------------------------------------- |     | LCHIJA | minecraft                                    | 1.12.2             | minecraft.jar                                 | None                                     |     | LCHIJA | mcp                                          | 9.42               | minecraft.jar                                 | None                                     |     | LCHIJA | FML                                          | 8.0.99.99          | server.jar                                    | e3c3d50c7c986df74c645c0ac54639741c90a557 |     | LCHIJA | forge                                        | 14.23.5.2854       | server.jar                                    | e3c3d50c7c986df74c645c0ac54639741c90a557 |     | LCHIJA | com.elytradev.movingworld.common.asm.coremod |                    | minecraft.jar                                 | None                                     |     | LCHIJA | forgeendertech                               | 1.12.2-4.5.5.0     | ForgeEndertech-1.12.2-4.5.5.0-build.0561.jar  | None                                     |     | LCHIJA | adpoles                                      | 1.12.2-2.0.3.0     | AdPoles-1.12.2-2.0.3.0-build.0552.jar         | None                                     |     | LCHIJA | crafttweaker                                 | 4.1.20             | CraftTweaker2-1.12-4.1.20.660.jar             | None                                     |     | LCHIJA | jei                                          | 4.16.1.301         | jei_1.12.2-4.16.1.301.jar                     | None                                     |     | LCHIJA | quark                                        | r1.6-179           | Quark-r1.6-179.jar                            | None                                     |     | LCHIJA | autoreglib                                   | 1.3-32             | AutoRegLib-1.3-32.jar                         | None                                     |     | LCHIJA | biomesoplenty                                | 7.0.1.2441         | BiomesOPlenty-1.12.2-7.0.1.2441-universal.jar | None                                     |     | LCHIJA | bookshelf                                    | 2.3.590            | Bookshelf-1.12.2-2.3.590.jar                  | d476d1b22b218a10d845928d1665d45fce301b27 |     | LCHIJA | chisel                                       | MC1.12.2-1.0.2.45  | Chisel-MC1.12.2-1.0.2.45.jar                  | None                                     |     | LCHIJA | chiselsandbits                               | 14.33              | chiselsandbits-14.33.jar                      | None                                     |     | LCHIJA | clumps                                       | 3.1.2              | Clumps-3.1.2.jar                              | None                                     |     | LCHIJA | collective                                   | 2.64               | collective-1.12.2-2.64.jar                    | None                                     |     | LCHIJA | cosmeticarmorreworked                        | 1.12.2-v5a         | CosmeticArmorReworked-1.12.2-v5a.jar          | aaaf83332a11df02406e9f266b1b65c1306f0f76 |     | LCHIJA | crafttweakerjei                              | 2.0.3              | CraftTweaker2-1.12-4.1.20.660.jar             | None                                     |     | LCHIJA | movingworld                                  | 1.12-6.353         | movingworld-1.12-6.353-full.jar               | None                                     |     | LCHIJA | davincisvessels                              | @DVESSELSVER@      | davincisvessels-1.12-6.340-full.jar           | None                                     |     | LCHIJA | orelib                                       | 3.6.0.1            | OreLib-1.12.2-3.6.0.1.jar                     | 7a2128d395ad96ceb9d9030fbd41d035b435753a |     | LCHIJA | dsurround                                    | 3.6.1.0            | DynamicSurroundings-1.12.2-3.6.1.0.jar        | 7a2128d395ad96ceb9d9030fbd41d035b435753a |     | LCHIJA | farseek                                      | 2.5.1              | Farseek-1.12-2.5.1.jar                        | None                                     |     | LCHIJA | forgelin                                     | 1.8.4              | Forgelin-1.8.4.jar                            | None                                     |     | LCHIJA | futuremc                                     | 0.2.6              | future-mc-1.12.2-0.2.6.1.jar                  | None                                     |     | LCHIJA | gamestages                                   | 2.0.123            | GameStages-1.12.2-2.0.123.jar                 | d476d1b22b218a10d845928d1665d45fce301b27 |     | LCHIJA | geographicraft                               | 0.8.7              | GeographiCraft-1.12-0.8.9b.jar                | None                                     |     | LCHIJA | grapplemod                                   | 1.12.2-v11.1       | grapplemod-v11.1-1.12.2.jar                   | None                                     |     | LCHIJA | gravestone                                   | 1.10.3             | gravestone-1.10.3.jar                         | None                                     |     | LCHIJA | happytrails                                  | 1.0.0.5            | HappyTrails-1.12.2-1.0.0.5.jar                | None                                     |     | LCHIJA | waila                                        | 1.8.26             | Hwyla-1.8.26-B41_1.12.2.jar                   | None                                     |     | LCHIJA | ichunutil                                    | 7.2.2              | iChunUtil-1.12.2-7.2.2.jar                    | 4db5c2bd1b556f252a5b8b54b256d381b2a0a6b8 |     | LCHIJA | ido                                          | 1.0.6              | ido-1.12.2-1.1.0.jar                          | None                                     |     | LCHIJA | ic2                                          | 2.8.170-ex112      | industrialcraft-2-2.8.170-ex112.jar           | de041f9f6187debbc77034a344134053277aa3b0 |     | LCHIJA | mantle                                       | 1.12-1.3.3.55      | Mantle-1.12-1.3.3.55.jar                      | None                                     |     | LCHIJA | inspirations                                 | 1.12.2-0.2.9       | Inspirations-1.12.2-0.2.9.jar                 | None                                     |     | LCHIJA | ironchest                                    | 1.12.2-7.0.67.844  | ironchest-1.12.2-7.0.72.847.jar               | None                                     |     | LCHIJA | journeymap                                   | 1.12.2-5.7.1       | journeymap-1.12.2-5.7.1.jar                   | None                                     |     | LCHIJA | guilib                                       | $version           | morepaintings-paintings-1.12.2-5.0.1.2.jar    | None                                     |     | LCHIJA | paintingselgui                               | $version           | morepaintings-paintings-1.12.2-5.0.1.2.jar    | None                                     |     | LCHIJA | morepaintings                                | $version           | morepaintings-paintings-1.12.2-5.0.1.2.jar    | None                                     |     | LCHIJA | naturescompass                               | 1.8.5              | NaturesCompass-1.12.2-1.8.5.jar               | None                                     |     | LCHIJA | netherendingores                             | 1.12.2-1.4.2       | Netherending-Ores-1.12.2-1.4.2.jar            | None                                     |     | LCHIJA | examplemod                                   | 1.0                | NuclearCraft-2.18z-1.12.2.jar                 | None                                     |     | LCHIJA | nuclearcraft                                 | 2.18z              | NuclearCraft-2.18z-1.12.2.jar                 | None                                     |     | LCHIJA | pixelmon                                     | 8.2.0              | Pixelmon-1.12.2-8.2.0-universal.jar           | None                                     |     | LCHIJA | placeableitems                               | 3.3                | placeableitems-3.3.jar                        | None                                     |     | LCHIJA | refinedstorage                               | 1.6.16             | refinedstorage-1.6.16.jar                     | 57893d5b90a7336e8c63fe1c1e1ce472c3d59578 |     | LCHIJA | spartanshields                               | 1.5.4              | SpartanShields-1.12.2-1.5.4.jar               | None                                     |     | LCHIJA | spartanweaponry                              | beta 1.3.8         | SpartanWeaponry-1.12.2-beta-1.3.8.jar         | None                                     |     | LCHIJA | streams                                      | 0.4.9              | Streams-1.12-0.4.9.jar                        | None                                     |     | LCHIJA | tinymobfarm                                  | 1.0.5              | TinyMobFarm-1.12.2-1.0.5.jar                  | None                                     |     | LCHIJA | travelersbackpack                            | 1.0.35             | TravelersBackpack-1.12.2-1.0.35.jar           | None                                     |     | LCHIJA | treeharvester                                | 3.2                | treeharvester_1.12.2-3.2.jar                  | None                                     |     | LCHIJA | wailastages                                  | 2.0.23             | WailaStages-1.12.2-2.0.23.jar                 | d476d1b22b218a10d845928d1665d45fce301b27 |     | LCHIJA | waystones                                    | 4.1.0              | Waystones_1.12.2-4.1.0.jar                    | None                                     |     | LCHIJA | rtg                                          | 6.1.0.0-snapshot.1 | RTG-1.12.2-6.1.0.0-snapshot.1.jar             | None                                     |     Loaded coremods (and transformers): TransformLoader (DynamicSurroundings-1.12.2-3.6.1.0.jar)   ForgelinPlugin (Forgelin-1.8.4.jar)   MovingWorldCore (movingworld-1.12-6.353-full.jar)   Quark Plugin (Quark-r1.6-179.jar)   vazkii.quark.base.asm.ClassTransformer CorePlugin (ForgeEndertech-1.12.2-4.5.5.0-build.0561.jar)   CTMCorePlugin (CTM-MC1.12.2-1.0.2.31.jar)   team.chisel.ctm.client.asm.CTMTransformer FarseekCoreMod (Farseek-1.12-2.5.1.jar)   farseek.core.FarseekClassTransformer FutureMC (future-mc-1.12.2-0.2.6.1.jar)   thedarkcolour.futuremc.asm.CoreTransformer     Pulsar/inspirations loaded Pulses:         - InspirationsShared (Enabled/Forced)         - InspirationsBuilding (Enabled/Not Forced)         - InspirationsUtility (Enabled/Not Forced)         - InspirationsTools (Enabled/Not Forced)         - InspirationsRecipes (Enabled/Not Forced)         - InspirationsTweaks (Enabled/Not Forced)         - InspirationsShared (Enabled/Forced)         - WailaPlugin (Enabled/Not Forced)     Profiler Position: N/A (disabled)     Player Count: 2 / 20; [EntityPlayerMP['T3rm1n6t0r'/17, l='world', x=9.98, y=73.00, z=99.44], EntityPlayerMP['ZtiromDE'/383, l='world', x=136.18, y=35.14, z=-88.54]]     Is Modded: Definitely; Server brand changed to 'fml,forge'     Type: Dedicated Server (map_server.txt)
    • Sorry, for the late reply.  Deleting the folders worked perfect thank you so far.  As the log is that big can you tell me what you searched for to find this paths?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.