Jump to content

[1.15.2] editing a vanilla loot table


kemika1girl

Recommended Posts

hi, i created a loot table which overrides already existing vanilla table and caught this problem:

error: method onLootLoad in class PlantFiberLootTable cannot be applied to given types;
        PlantFiberLootTable.onLootLoad();
                           ^
  required: LootTableLoadEvent
  found: no arguments
  reason: actual and formal argument lists differ in length

and there is the code:

@Mod.EventBusSubscriber
public class PlantFiberLootTable {
        @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("primal", "grass"))).build());
            }
        }
    }

however, even if i try just to replace vanilla table with my own, nothing happens. what did i do wrong?

Link to comment
Share on other sites

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

6 hours ago, ChampionAsh5357 said:

I wouldn't use LootTableLoadEvent. Instead of doing this, look into using global loot modifiers (GLMs) instead. That would be the correct way of handling this.

 

Also, to answer your question, you're missing the mod id passed into the event bus subscriber annotation.

 

6 hours ago, Draco18s said:

oh, thanks!
so, there is the new code for global modifiers:

@Mod.EventBusSubscriber(modid = PrimitiveTools.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class GrassDrops {
    @SubscribeEvent
    public static void registerModifiers(RegistryEvent.Register<GlobalLootModifierSerializer<?>> event)
    {
        event.getRegistry().register(
                new GrassDropSerializer().setRegistryName(PrimitiveTools.MOD_ID, "plant_fiber_from_grass")
        );
    }

    public static class GrassDropSerializer extends GlobalLootModifierSerializer<GrassDropModifier>
    {

        @Override
        public GrassDropModifier read(ResourceLocation location, JsonObject object, ILootCondition[] ailootcondition)
        {
            return new GrassDropModifier(ailootcondition);
        }
    }
    private static class GrassDropModifier extends LootModifier
    {

        protected GrassDropModifier(ILootCondition[] conditionsIn)
        {
            super(conditionsIn);
        }

        @Nonnull
        @Override
        protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context)
        {
            generatedLoot.add(new ItemStack(Items.STICK));
            return generatedLoot;
        }
    }
}

when i entered the world, i caught a new error: 

[23:39:40] [Server thread/ERROR] [ne.mi.co.lo.LootModifierManager/]: Couldn't parse loot modifier primitivetools:plant_fiber_from_grass
java.lang.NullPointerException: null
	at net.minecraftforge.common.loot.LootModifierManager.deserializeModifier(LootModifierManager.java:129) ~[?:?] {re:classloading}
	at net.minecraftforge.common.loot.LootModifierManager.lambda$apply$0(LootModifierManager.java:118) ~[?:?] {re:classloading}
	at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:1.8.0_251] {}
	at net.minecraftforge.common.loot.LootModifierManager.apply(LootModifierManager.java:116) ~[?:?] {re:classloading}
	at net.minecraftforge.common.loot.LootModifierManager.apply(LootModifierManager.java:57) ~[?:?] {re:classloading}
	at net.minecraft.client.resources.ReloadListener.lambda$reload$1(ReloadListener.java:14) ~[?:?] {re:classloading}
	at java.util.concurrent.CompletableFuture.uniAccept(CompletableFuture.java:670) ~[?:1.8.0_251] {}
	at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:646) ~[?:1.8.0_251] {}
	at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:456) ~[?:1.8.0_251] {}
	at net.minecraft.resources.AsyncReloader.lambda$null$3(AsyncReloader.java:66) ~[?:?] {re:classloading}
	at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:20) [?:?] {re:classloading}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:140) [?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) [?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:759) [?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:141) [?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:110) [?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.driveOneInternal(MinecraftServer.java:742) [?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:736) [?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.driveUntil(ThreadTaskExecutor.java:123) [?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.loadDataPacks(MinecraftServer.java:1583) [?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.loadDataPacks(MinecraftServer.java:457) [?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:77) [?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.integrated.IntegratedServer.init(IntegratedServer.java:99) [?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:638) [?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_251] {}

obviously, no new drop appeared and i don't know what's the problem since global loot modifiers is something new for me.

Link to comment
Share on other sites

Did you add your modifier to the resources/forge/loot_modifiers.json?

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

11 hours ago, Draco18s said:

Did you add your modifier to the resources/forge/loot_modifiers.json?

yes, my modifier is there
i have good news: my modifiers started working, the problem was my plant_fiber_from_grass.json was in the resources/data/primitivetools/ and not in the resources/data/primitivetools/loot_modifiers so it was just my carelessness

 

thanks you very much for the help!
 

Edited by kemika1girl
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.