Jump to content

How do I create a LootPool with multiple entries


skeddles

Recommended Posts

I originally created my LootPool by making my LootEntry a LootEntryTable that gets the items from a loot table json, but now I want to do it with code. I figured out how to create a loot entry for a single item by using LootEntryItem instead of LootEntryTable, but how can I make a list of multiple items?

 

 

//loot tables
@SubscribeEvent
public static void lootLoad(LootTableLoadEvent evt) {
   String name = evt.getName().toString();
   
   if (name.contains("chest")) {
      LootEntry entry = new LootEntryItem(Items.COOKIE, 15, 60, new LootFunction[0], new LootCondition[0], "modpoolcustomtest");

      LootPool pool = new LootPool(new LootEntry[] {entry}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(1), "modpool"); 
      
      evt.getTable().addPool(pool);
   }
}
Edited by skeddles
Link to comment
Share on other sites

  • Like 1

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

I didn't realize that it could be an array.  This code seems to work now.

 

I haven't used arrays before, how does this look? Would there be any performance loss doing it this way, even if there was hundreds or thousands of items?

 

//loot tables
@SubscribeEvent
public static void lootLoad(LootTableLoadEvent evt) {
   String name = evt.getName().toString();
   
   if (name.contains("chest")) {

      LootEntry[] entry = {
              new LootEntryItem(Items.COOKIE, 1, 60, new LootFunction[0], new LootCondition[0], "test:cookie"),
              new LootEntryItem(Items.SKULL, 1, 60, new LootFunction[0], new LootCondition[0], "test:skull")
      };

      LootPool pool = new LootPool(entry, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(1), "testpool");
      
      evt.getTable().addPool(pool);
   }
}

 

edit: just realized i need to be able to add to the array at will so probably need an arraylist, workin on that

 

edit:

here's what I got now, uses an arraylist and then converts it at the end:

 

ArrayList<LootEntryItem> entries = new ArrayList<LootEntryItem>();

entries.add(new LootEntryItem(Items.COOKIE, 1, 60, new LootFunction[0], new LootCondition[0], "examplemod:cookie"));
entries.add(new LootEntryItem(Items.SKULL, 1, 60, new LootFunction[0], new LootCondition[0], "examplemod:skull"));

LootEntry [] entriesArray = entries.toArray(new LootEntry[entries.size()]);

LootPool pool = new LootPool(entriesArray, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(1), "heroicarmorypool");

evt.getTable().addPool(pool);
Edited by skeddles
Link to comment
Share on other sites

Yeah. Gotta be an array, but lists are easier to work with.

Its why my utils class got so convoluted so quickly.

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • when i do the same on my pc it works
    • Use your IDE for this. For example, if you are using "IntelliJ IDEA" and you correctly setup your project (jdk, forge mdk, gradle, parchment, etc.), then you can just use Ctrl + B with Block type selected. It will navigate you to class declaration.
    • I need help, my forge server crashes and i don't know where is the problem.    [25sep2023 14:24:30.772] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.1.4, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, /home/luka/.local/share/atlauncher/runtimes/minecraft/jre-legacy/linux/jre-legacy/bin/java nogui] [25sep2023 14:24:30.777] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 1.8.0_202 by Oracle Corporation [25sep2023 14:24:31.055] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [25sep2023 14:24:31.098] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.2 Source=file:/home/luka/.local/share/atlauncher/servers/Darksouls/libraries/org/spongepowered/mixin/0.8.2/mixin-0.8.2.jar Service=ModLauncher Env=SERVER [25sep2023 14:24:32.824] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [com.performant.coremod.mixin.Connector] [25sep2023 14:24:32.835] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmlserver' with arguments [--gameDir, ., /home/luka/.local/share/atlauncher/runtimes/minecraft/jre-legacy/linux/jre-legacy/bin/java nogui] [25sep2023 14:24:32.898] [main/INFO] [com.performant.coremod.Performant/]: Performant configs loaded [25sep2023 14:24:32.996] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/renderer/GameRenderer for invalid dist DEDICATED_SERVER [25sep2023 14:24:32.997] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/renderer/GameRenderer (java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/GameRenderer for invalid dist DEDICATED_SERVER) [25sep2023 14:24:32.999] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.renderer.GameRenderer was not found shouldersurfing.mixins.json:MixinGameRenderer [25sep2023 14:24:33.011] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/GameSettings for invalid dist DEDICATED_SERVER [25sep2023 14:24:33.011] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/GameSettings (java.lang.RuntimeException: Attempted to load class net/minecraft/client/GameSettings for invalid dist DEDICATED_SERVER) [25sep2023 14:24:33.012] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.GameSettings was not found shouldersurfing.mixins.json:MixinGameSettings [25sep2023 14:24:33.034] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/gui/IngameGui for invalid dist DEDICATED_SERVER [25sep2023 14:24:33.035] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/gui/IngameGui (java.lang.RuntimeException: Attempted to load class net/minecraft/client/gui/IngameGui for invalid dist DEDICATED_SERVER) [25sep2023 14:24:33.035] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.gui.IngameGui was not found shouldersurfing.mixins.json:MixinIngameGui [25sep2023 14:24:33.128] [main/WARN] [mixin/]: Error loading class: net/optifine/shaders/ShadersRender (java.lang.ClassNotFoundException: null) [25sep2023 14:24:33.130] [main/WARN] [mixin/]: @Mixin target net.optifine.shaders.ShadersRender was not found shouldersurfing.mixins.json:MixinShadersRender [25sep2023 14:24:33.678] [main/INFO] [com.performant.coremod.Performant/]: Not enabling mixin forcom.performant.coremod.mixin.forge.BasicEventHooksMixin as config disables it. [25sep2023 14:24:33.706] [main/INFO] [com.performant.coremod.Performant/]: Not enabling mixin forcom.performant.coremod.mixin.entity.LivingEntityUpdateEventMixin as config disables it. [25sep2023 14:24:33.796] [main/WARN] [mixin/]: @Mixin target net/minecraft/world/server/ChunkManager$EntityTracker is public in performant.mixins.json:world.chunk.ChunkManagerEntityTrackMixin and should be specified in value [25sep2023 14:24:34.092] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class com/teamderpy/shouldersurfing/config/Config$ClientConfig for invalid dist DEDICATED_SERVER [25sep2023 14:24:34.092] [main/WARN] [mixin/]: Error loading class: com/teamderpy/shouldersurfing/config/Config$ClientConfig (java.lang.RuntimeException: Attempted to load class com/teamderpy/shouldersurfing/config/Config$ClientConfig for invalid dist DEDICATED_SERVER) [25sep2023 14:24:35.634] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/Minecraft for invalid dist DEDICATED_SERVER [25sep2023 14:24:35.634] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/Minecraft (java.lang.RuntimeException: Attempted to load class net/minecraft/client/Minecraft for invalid dist DEDICATED_SERVER) [25sep2023 14:24:35.636] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException [25sep2023 14:24:35.636] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39) [25sep2023 14:24:35.636] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [25sep2023 14:24:35.636] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [25sep2023 14:24:35.637] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [25sep2023 14:24:35.637] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63) [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60) [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: Caused by: java.lang.reflect.InvocationTargetException [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [25sep2023 14:24:35.639] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [25sep2023 14:24:35.639] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [25sep2023 14:24:35.639] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at java.lang.reflect.Method.invoke(Method.java:498) [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at net.minecraftforge.fml.loading.FMLServerLaunchProvider.lambda$launchService$0(FMLServerLaunchProvider.java:51) [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     ... 7 more [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363) [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:223) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at org.spongepowered.asm.mixin.transformer.MixinTransformationHandler.processClass(MixinTransformationHandler.java:121) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at org.spongepowered.asm.launch.MixinLaunchPlugin.processClass(MixinLaunchPlugin.java:131) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:154) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:85) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:265) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:136) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.block.Blocks.<clinit>(Blocks.java:30) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.world.gen.surfacebuilders.SurfaceBuilder.<clinit>(SurfaceBuilder.java:12) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilders.<clinit>(SourceFile:11) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.WorldGenRegistries.func_243674_g(WorldGenRegistries.java:33) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.WorldGenRegistries.func_243668_a(WorldGenRegistries.java:89) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.WorldGenRegistries.<clinit>(WorldGenRegistries.java:88) [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.Registry.<clinit>(Registry.java:464) [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.Bootstrap.func_151354_b(Bootstrap.java:38) [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.server.Main.main(Main.java:92) [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     ... 13 more [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]: Caused by: org.spongepowered.asm.mixin.throwables.ClassMetadataNotFoundException: net.minecraft.client.Minecraft [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transformMethod(MixinPreProcessorStandard.java:741) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transform(MixinPreProcessorStandard.java:726) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.attach(MixinPreProcessorStandard.java:297) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.createContextFor(MixinPreProcessorStandard.java:267) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinInfo.createContextFor(MixinInfo.java:1271) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:287) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:345) [25sep2023 14:24:35.645] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:569) [25sep2023 14:24:35.645] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:351) [25sep2023 14:24:35.645] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     ... 33 more
    • How can I see the Minecraft Blocks source code?
    • I have installed a minecraft 1.12.2 server and java 8, but the forge-blahblahblah.jar file isnt doing anything, the minecraft server file is opening the server but as expacted, it just launches a vanilla server
  • Topics

×
×
  • Create New...

Important Information

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