Jump to content

[1.14.4] My TileEntities are not being registered properly & ConcurrentModification Exception


Cerandior

Recommended Posts

Their registry name is null. Considering the registry event is being called (I checked at the debugger), I am guessing I am doing the linking between the TileEntityType and the TileEntity wrong. I followed the docs tutorial on how to create tile entities but surely I must have messed up something.

 

The related classes:

Main Class:
https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/main/VanillaExtended.java
 

BlockList Class:

https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/blocks/BlockList.java

TileEntity Class (I am providing only one of them, same error with both):

https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/tileentities/CSTile.java

Edited by Cerandior
Link to comment
Share on other sites

You never assign the objects in your BlocksList class to anything.

 

  • Thanks 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

14 hours ago, Draco18s said:

You never assign the objects in your BlocksList class to anything.

 

Sorry about that, I fixed it now.
However I am getting a concurrent modification exception right now (unrelated to the original problem, I thought it was at first). I don't think I am removing or adding anything to the list while iterating through it, I am modifying some of its elements however. Can I not do this?

 

Spoiler

---- Minecraft Crash Report ----
// Oh - I know what I did wrong!

Time: 2/9/20 11:58 AM
Description: Unexpected error

java.util.ConcurrentModificationException: null
    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909) ~[?:1.8.0_181] {}
    at java.util.ArrayList$Itr.next(ArrayList.java:859) ~[?:1.8.0_181] {}
    at teabx.vanillaextended.tileentities.TPTile.updateStorageBlock(TPTile.java:27) ~[classes/:?] {re:classloading}
    at teabx.vanillaextended.blocks.CollectiveStorage.onBlockPlacedBy(CollectiveStorage.java:38) ~[classes/:?] {re:classloading}
    at net.minecraft.item.BlockItem.tryPlace(BlockItem.java:69) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading}
    at net.minecraft.item.BlockItem.onItemUse(BlockItem.java:42) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading}
    at net.minecraft.item.ItemStack.lambda$onItemUse$0(ItemStack.java:169) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading}
    at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:184) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading}
    at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:169) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading}
    at net.minecraft.client.multiplayer.PlayerController.func_217292_a(PlayerController.java:310) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1286) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:1544) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1377) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:904) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.run(Minecraft.java:384) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.main.Main.main(Main.java:128) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181] {}
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_181] {}
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_181] {}
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_181] {}
    at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-4.1.0.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-4.1.0.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-4.1.0.jar:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-4.1.0.jar:?] {}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-4.1.0.jar:?] {}
    at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:101) [forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}


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

-- Head --
Thread: Client thread
Stacktrace:
    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909)
    at java.util.ArrayList$Itr.next(ArrayList.java:859)
    at teabx.vanillaextended.tileentities.TPTile.updateStorageBlock(TPTile.java:27)
    at teabx.vanillaextended.blocks.CollectiveStorage.onBlockPlacedBy(CollectiveStorage.java:38)
    at net.minecraft.item.BlockItem.tryPlace(BlockItem.java:69)
    at net.minecraft.item.BlockItem.onItemUse(BlockItem.java:42)
    at net.minecraft.item.ItemStack.lambda$onItemUse$0(ItemStack.java:169)
    at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:184)
    at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:169)
    at net.minecraft.client.multiplayer.PlayerController.func_217292_a(PlayerController.java:310)
    at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1286)
    at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:1544)

-- Affected level --
Details:
    All players: 1 total; [ClientPlayerEntity['Dev'/149, l='MpServer', x=-4.39, y=72.79, z=348.25]]
    Chunk stats: Client Chunk Cache: 289, 139
    Level dimension: DimensionType{minecraft:overworld}
    Level name: MpServer
    Level seed: 0
    Level generator: ID 00 - default, ver 1. Features enabled: false
    Level generator options: {}
    Level spawn location: World: (96,64,217), Chunk: (at 0,4,9 in 6,13; contains blocks 96,0,208 to 111,255,223), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
    Level time: 5841 game time, 5841 day time
    Level storage version: 0x00000 - Unknown?
    Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
    Server brand: forge
    Server type: Integrated singleplayer server
Stacktrace:
    at net.minecraft.client.world.ClientWorld.fillCrashReport(ClientWorld.java:425)
    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:1824)
    at net.minecraft.client.Minecraft.run(Minecraft.java:405)
    at net.minecraft.client.main.Main.main(Main.java:128)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55)
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54)
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72)
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:81)
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:65)
    at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:101)

-- System Details --
Details:
    Minecraft Version: 1.14.4
    Minecraft Version ID: 1.14.4
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_181, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 286427984 bytes (273 MB) / 1045430272 bytes (997 MB) up to 1778384896 bytes (1696 MB)
    CPUs: 4
    JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
    ModLauncher: 4.1.0+62+5bfa59b
    ModLauncher launch target: fmluserdevclient
    ModLauncher naming: mcp
    ModLauncher services: 
        /eventbus-1.0.0-service.jar eventbus PLUGINSERVICE 
        /forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-launcher.jar object_holder_definalize PLUGINSERVICE 
        /forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-launcher.jar runtime_enum_extender PLUGINSERVICE 
        /accesstransformers-1.0.1-milestone.0.1+94458e7-shadowed.jar accesstransformer PLUGINSERVICE 
        /forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-launcher.jar capability_inject_definalize PLUGINSERVICE 
        /forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-launcher.jar runtimedistcleaner PLUGINSERVICE 
        /forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-launcher.jar fml TRANSFORMATIONSERVICE 
    FML: 28.1
    Forge: net.minecraftforge:28.1.96
    FML Language Providers: 
        [email protected]
        minecraft@1
    Mod List: 
        client-extra.jar Minecraft {[email protected] DONE}
        main Vanilla Extended {vanillaextended@NONE DONE}
        forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar Forge {[email protected] DONE}
    Launched Version: MOD_DEV
    LWJGL: 3.2.2 build 10
    OpenGL: AMD Radeon HD 7560D GL version 4.5.13399 Compatibility Profile Context 15.201.1151.1008, ATI Technologies Inc.
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'forge'
    Type: Client (map_client.txt)
    Resource Packs: 
    Current Language: English (US)
    CPU: 4x AMD A8-5600K APU with Radeon(tm) HD Graphics 

 

Block Class:
https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/blocks/CollectiveStorage.java

 

Tile Class:
https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/tileentities/TPTile.java

Edited by Cerandior
Link to comment
Share on other sites

The problem is you execute the updateStorageBlock method recursively, which leads to the execution of the update method and there you add a new tile entity to your list you currently iterating over. This leads to the thrown ConcurrentModificationException because it's not allowed to modifie a list you currently iterating over. A simple fix would be copy the content of the list in a new list and iterate over this copy instead of the original one. But this fix only works if you not need the newly added tile entities.

  • Thanks 1
Link to comment
Share on other sites

52 minutes ago, korti11 said:

The problem is you execute the updateStorageBlock method recursively, which leads to the execution of the update method and there you add a new tile entity to your list you currently iterating over. This leads to the thrown ConcurrentModificationException because it's not allowed to modifie a list you currently iterating over. A simple fix would be copy the content of the list in a new list and iterate over this copy instead of the original one. But this fix only works if you not need the newly added tile entities.

That was the idea. Every time I right-clicked the master block (which is the CSTile), it would go through each of the connected parts and re-update the StorageBlock (An object that I am using to keep track of chests and storage block parts, such as CSTile and TPTile that are connected to this multi-block). I still don't think I am actually updating the original list. I am updating the list of an object that is stored in the original list. Does that still throw the Exception?

I am following another route now, if that works I'll post here the updated code in case someone else has a similar issue in the future.

Link to comment
Share on other sites

Alright, fixed it. You can find the updated classes below:

The Block Class:
https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/blocks/CollectiveStorage.java

The Tile Class:
https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/tileentities/TPTile.java

 

The StorageBlock Class:
https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/blocks/StorageBlock.java

 

Ignore the printlns, I was checking a couple of things, didn't have time to cleanup right now.
Also the update() method at the StorageBlock is kind of stupid I know. I was having a problem with duplicates, and that's my fault for using an ArrayList. I should have used a HashSet since the beginning, since I don't really care about the order of the list elements. (You can use LinkedHashSet if you do care about that).

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://youtube.com/shorts/gqLTSMymgUg?si=5QOeSvA4TTs-bL46
    • CubeHaven is a SMP server with unique features that can't be found on the majority of other servers! Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132 3 different stores: - CubeHaven Store: Our store to purchase using real money. - Bitcoin Store: Store for Bitcoin. Bitcoin can be earned from playing the server. Giving options for players if they want to spend real money or grind to obtain exclusive packages. - Black Market: A hidden store for trading that operates outside our traditional stores, like custom enchantments, exclusive items and more. Some of our features include: Rank Up: Progress through different ranks to unlock new privileges and perks. 📈 Skills: RPG-style skill system that enhances your gaming experience! 🎮 Leaderboards: Compete and shine! Top players are rewarded weekly! 🏆 Random Teleporter: Travel instantly across different worlds with a click! 🌐 Custom World Generation: Beautifully generated world. 🌍 Dungeons: Explore challenging and rewarding dungeons filled with treasures and monsters. 🏰 Kits: Unlock ranks and gain access to various kits. 🛠️ Fishing Tournament: Compete in a friendly fishing tournament! 🎣 Chat Games: Enjoy games right within the chat! 🎲 Minions: Get some help from your loyal minions. 👥 Piñata Party: Enjoy a festive party with Piñatas! 🎉 Quests: Over 1000 quests that you can complete! 📜 Bounty Hunter: Set a bounty on a player's head. 💰 Tags: Displayed on nametags, in the tab list, and in chat. 🏷️ Coinflip: Bet with other players on coin toss outcomes, victory, or defeat! 🟢 Invisible & Glowing Frames: Hide your frames for a cleaner look or apply a glow to it for a beautiful look. 🔲✨[ Player Warp: Set your own warp points for other players to teleport to. 🌟 Display Shop: Create your own shop and sell to other players! 🛒 Item Skins: Customize your items with unique skins. 🎨 Pets: Your cute loyal companion to follow you wherever you go! 🐾 Cosmetics: Enhance the look of your character with beautiful cosmetics! 💄 XP-Bottle: Store your exp safely in a bottle for later use! 🍶 Chest & Inventory Sorting: Keep your items neatly sorted in your inventory or chest! 📦 Glowing: Stand out from other players with a colorful glow! ✨ Player Particles: Over 100 unique particle effects to show off. 🎇 Portable Inventories: Over virtual inventories with ease. 🧳 And a lot more! Become part of our growing community today! Discord: https://cubehaven.net/discord Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132
    • # Problematic frame: # C [libopenal.so+0x9fb4d] It is always the same issue - this refers to the Linux OS - so your system may prevent Java from working   I am not familiar with Linux - check for similar/related issues  
    • Create a new instance and start with Embeddium/Oculus and Valkyrien Skies Try different builds of Embeddium/Valkyrien Skies until you find a working combination - then add the rest of your mods one by one or in groups
  • Topics

×
×
  • Create New...

Important Information

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