Jump to content

Recommended Posts

Posted

Hello everyone,

in my mod, I am modifying a map to update it client side. At each tick, I am checking worldSavedData to match it with my te map on server side and then I put it to the client using a packet. But as I destroy two block I run into a very strange exception : ConcurentModificationException. Here is the code of the tile entity : Tile Entity

I am using hashMap and here is the complete crash report :

 

---- Minecraft Crash Report ---- // Daisy, daisy... Time: 25/04/20 10:36 Description: Ticking block entity java.util.ConcurrentModificationException: null at java.util.HashMap.forEach(HashMap.java:1292) ~[?:1.8.0_231] {} at fr.mattmouss.gates.tileentity.CardGetterTileEntity.lambda$tick$7(CardGetterTileEntity.java:145) ~[?:?] {re:classloading} at net.minecraftforge.common.util.LazyOptional.ifPresent(LazyOptional.java:161) ~[?:?] {re:classloading} at fr.mattmouss.gates.tileentity.CardGetterTileEntity.tick(CardGetterTileEntity.java:137) ~[?:?] {re:classloading} at net.minecraft.world.World.tickBlockEntities(World.java:473) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:368) ~[?:?] {re:classloading} at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:841) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:776) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:112) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:634) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:748) [?:1.8.0_231] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Server thread Stacktrace: at java.util.HashMap.forEach(HashMap.java:1292) at fr.mattmouss.gates.tileentity.CardGetterTileEntity.lambda$tick$7(CardGetterTileEntity.java:145) at net.minecraftforge.common.util.LazyOptional.ifPresent(LazyOptional.java:161) at fr.mattmouss.gates.tileentity.CardGetterTileEntity.tick(CardGetterTileEntity.java:137) -- Block entity being ticked -- Details: Name: gates:card_getter // fr.mattmouss.gates.tileentity.CardGetterTileEntity Block: Block{gates:card_getter}[facing=west] Block location: World: (51,4,153), Chunk: (at 3,0,9 in 3,9; contains blocks 48,0,144 to 63,255,159), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Block: Block{gates:card_getter}[facing=west] Block location: World: (51,4,153), Chunk: (at 3,0,9 in 3,9; contains blocks 48,0,144 to 63,255,159), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Stacktrace: at net.minecraft.world.World.tickBlockEntities(World.java:473) at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:368) -- Affected level -- Details: All players: 1 total; [ServerPlayerEntity['Dev'/276, l='New World', x=46.12, y=4.00, z=155.12]] Chunk stats: ServerChunkCache: 3019 Level dimension: DimensionType{minecraft:overworld} Level name: New World Level seed: -4566557193619946920 Level generator: ID 01 - flat, ver 0. Features enabled: true Level generator options: {} Level spawn location: World: (48,4,160), Chunk: (at 0,0,0 in 3,10; contains blocks 48,0,160 to 63,255,175), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 5794 game time, 5794 day time Level storage version: 0x04ABD - Anvil Level weather: Rain time: 127319 (now: false), thunder time: 47119 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:841) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:776) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:112) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:634) at java.lang.Thread.run(Thread.java:748) -- System Details -- Details: Minecraft Version: 1.15.1 Minecraft Version ID: 1.15.1 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_231, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 459278856 bytes (438 MB) / 1008205824 bytes (961 MB) up to 1411383296 bytes (1346 MB) CPUs: 4 JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump ModLauncher: 5.0.0-milestone.4+67+b1a340b ModLauncher launch target: fmluserdevclient ModLauncher naming: mcp ModLauncher services: /eventbus-2.0.0-milestone.1-service.jar eventbus PLUGINSERVICE /forge-1.15.1-30.0.51_mapped_snapshot_20200213-1.15.1-launcher.jar object_holder_definalize PLUGINSERVICE /forge-1.15.1-30.0.51_mapped_snapshot_20200213-1.15.1-launcher.jar runtime_enum_extender PLUGINSERVICE /accesstransformers-2.0.0-milestone.1-shadowed.jar accesstransformer PLUGINSERVICE /forge-1.15.1-30.0.51_mapped_snapshot_20200213-1.15.1-launcher.jar capability_inject_definalize PLUGINSERVICE /forge-1.15.1-30.0.51_mapped_snapshot_20200213-1.15.1-launcher.jar runtimedistcleaner PLUGINSERVICE /forge-1.15.1-30.0.51_mapped_snapshot_20200213-1.15.1-launcher.jar fml TRANSFORMATIONSERVICE FML: 30.0 Forge: net.minecraftforge:30.0.51 FML Language Providers: [email protected] minecraft@1 Mod List: client-extra.jar Minecraft {[email protected] DONE} main Gates {[email protected] DONE} forge-1.15.1-30.0.51_mapped_snapshot_20200213-1.15.1.jar Forge {[email protected] DONE} Player Count: 1 / 8; [ServerPlayerEntity['Dev'/276, l='New World', x=46.12, y=4.00, z=155.12]] Data Packs: vanilla, mod:forge (incompatible), mod:gates Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'forge'

 

Posted

Howdy

This error means that either 

* two different threads are attempting to modify your HashMap at the same time, or

* you are iterating through a hashmap and trying to modify it at the same time (eg using remove or add)

 

-TGG

 

 

 

 

Posted

I finally found the error it was java error. In my te I am searching into the Map using HashMap#forEach and inside it I remove value in this same map. This is logically impossible and it crashes. I found the solution on using a List from outside function that register the value to delete. Thanks for your answer that was simplier than expected

Posted (edited)

Also, there's little reason to call this.GetCapability, because all it does it return this.costStorage which you already had access to. And because it's wrapped in a lazy optional, you then have to call .orElse(), .orElseThrow(), or .ifPresent() on it (rather than accessing the data directly), but all your implementation does is call this.getStorage() in one way or another. And all that does is call new CostStorage(). Meaning you haven't actually STORED any data anywhere. You keep dropping it on the floor and forgetting about it and the roomba comes along and garbage collects it.

 

Compare to this:

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/entity/AxelTileEntity.java#L28

and

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/entity/AxelTileEntity.java#L45

Edited by Draco18s

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.

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.