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: 
        javafml@28.1
        minecraft@1
    Mod List: 
        client-extra.jar Minecraft {minecraft@1.14.4 DONE}
        main Vanilla Extended {vanillaextended@NONE DONE}
        forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar Forge {forge@28.1.96 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

    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
  • Topics

×
×
  • Create New...

Important Information

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