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

[1.12] village loot not working


TheGoldenProof
 Share

Recommended Posts

basically what the title says. I have it set that it should spawn in every blacksmith chest but it doesn't.

 

Spoiler

 


@SubscribeEvent
public void loadLootTables(LootTableLoadEvent event) {
	if (event.getName().toString().equals("minecraft:chests/village_blacksmith")) {
		LootTableList.register(new ResourceLocation("saom:village_blacksmith"));
		LootEntry entry = new LootEntryTable(new ResourceLocation("saom:village_blacksmith"), 1, 5, new LootCondition[] {}, "main");
		LootPool pool = new LootPool(new LootEntry[] {entry}, new LootCondition[] {}, new RandomValueRange(1, 1), new RandomValueRange(0), "saomDragonBoneAxe");
		event.getTable().addPool(pool);
	}
}

 

EventHandler    ^

Spoiler

{
    "pools": [
        {
            "name": "main",
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "saom:dragon_bone_axe",
                    "weight": 1
                }
            ]
        }
    ]
}

 

assets/saom/loot_tables/village_blacksmith.json    ^

Edited by TheGoldenProof
Link to comment
Share on other sites

Is your code being called (hint - public static void if your using the @EventSubscriber annotation)

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

1 hour ago, Cadiboo said:

Is your code being called (hint - public static void if your using the @EventSubscriber annotation)

I forgot the static part, added it. Now, whenever I try to join a world I get a really unhelpful crash report

Spoiler

[15:46:44] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STARTING and forced into state SERVER_STOPPED. Errors may have been discarded.
[15:46:45] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ----
// This doesn't make any sense!

Time: 11/5/18 3:46 PM
Description: Exception in server tick loop

java.util.ConcurrentModificationException
	at java.util.HashMap$HashIterator.nextNode(Unknown Source)
	at java.util.HashMap$KeyIterator.next(Unknown Source)
	at java.util.Collections$UnmodifiableCollection$1.next(Unknown Source)
	at net.minecraft.world.storage.loot.LootTableManager.reloadLootTables(LootTableManager.java:47)
	at net.minecraft.world.storage.loot.LootTableManager.<init>(LootTableManager.java:35)
	at net.minecraft.world.WorldServer.init(WorldServer.java:161)
	at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:123)
	at net.minecraft.server.integrated.IntegratedServer.init(IntegratedServer.java:160)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:552)
	at java.lang.Thread.run(Unknown Source)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
	Minecraft Version: 1.12.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_191, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 703816376 bytes (671 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.42 Powered by Forge 14.23.5.2768 14 mods loaded, 14 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                                |
	|:------- |:------------------- |:--------------- |:------------------------------------------ |:---------------------------------------- |
	| UCHIJAA | minecraft           | 1.12.2          | minecraft.jar                              | None                                     |
	| UCHIJAA | mcp                 | 9.42            | minecraft.jar                              | None                                     |
	| UCHIJAA | FML                 | 8.0.99.99       | forgeSrc-1.12.2-14.23.5.2768.jar           | None                                     |
	| UCHIJAA | forge               | 14.23.5.2768    | forgeSrc-1.12.2-14.23.5.2768.jar           | None                                     |
	| UCHIJAA | saom                | 0.5a            | bin                                        | None                                     |
	| UCHIJAA | simplerpg           | 2.2             | simplerpg-2.2-1.12.1.jar                   | None                                     |
	| UCHIJAA | mantle              | 1.12-1.3.3.39   | Mantle-1.12-1.3.3.39.jar                   | None                                     |
	| UCHIJAA | natura              | 1.12.2-4.3.2.62 | natura-1.12.2-4.3.2.62.jar                 | None                                     |
	| UCHIJAA | redstoneflux        | 2.1.0           | RedstoneFlux-1.12-2.1.0.6-universal.jar    | 8a6abf2cb9e141b866580d369ba6548732eff25f |
	| UCHIJAA | cofhcore            | 4.6.1           | CoFHCore-1.12.2-4.6.1.22-universal (1).jar | None                                     |
	| UCHIJAA | waila               | 1.8.26          | Hwyla-1.8.26-B41_1.12.2.jar                | None                                     |
	| UCHIJAA | jei                 | 4.13.1.220      | jei_1.12.2-4.13.1.220.jar                  | None                                     |
	| UCHIJAA | wailaharvestability | 1.1.12          | WailaHarvestability-mc1.12-1.1.12.jar      | None                                     |
	| UCHIJAA | wawla               | 2.5.264         | Wawla-1.12.2-2.5.264.jar                   | d476d1b22b218a10d845928d1665d45fce301b27 |

	Loaded coremods (and transformers): 
	GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
	Pulsar/natura loaded Pulses: 
		- NaturaCommons (Enabled/Forced)
		- NaturaOverworld (Enabled/Not Forced)
		- NaturaNether (Enabled/Not Forced)
		- NaturaDecorative (Enabled/Not Forced)
		- NaturaTools (Enabled/Not Forced)
		- NaturaEntities (Enabled/Not Forced)
		- NaturaOredict (Enabled/Forced)
		- NaturaWorld (Enabled/Not Forced)

	Profiler Position: N/A (disabled)
	Player Count: 0 / 8; []
	Type: Integrated Server (map_client.txt)
	Is Modded: Definitely; Client brand changed to 'fml,forge'

 

 

Link to comment
Share on other sites

22 hours ago, TheGoldenProof said:

LootTableList.register(new ResourceLocation("saom:village_blacksmith"));

This is the cause of your issue. When loot tables are reloaded then all loot tables from the LootTableList are iterated using foreach. This method adds a loot table to the list. Obviously, you can't modify a collection while it is being iterated using foreach, hence the CME. Do this method soewhere else, like in a static initializer or something.

Link to comment
Share on other sites

4 hours ago, V0idWa1k3r said:

Do this method soewhere else, like in a static initializer or something.

Is there a better alternative? Like in preInit or Init?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

22 minutes ago, Cadiboo said:

Is there a better alternative? Like in preInit or Init?

That's what I meant by "or something". I don't think it really matters, LootTables are not a IForgeRegistryEntry and are managed separately. Currently it doesn't matter when they are added to the set. If you want - yes, you can absolutely register them in pre/init. 

If they ever become a IForgeRegistryEntry though I will be telling people to use the appropriate registry event :P.

  • Like 1
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
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



×
×
  • Create New...

Important Information

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