Posted November 8, 20195 yr Hey all, This code of mine is causing cascading worldgen. I'm lead to believe that the getTileEntityMap() call is what's causing the cascading worldgen. Can anyone suggest optimisations to reduce the amount of calls to getTileEntityMap()? OR even if there is any other way of finding tile entities in a large area Here is the function: private static void findTileEntity(LivingSpawnEvent.CheckSpawn event, int radius) { BlockPos pos = event.getEntity().getPosition(); int chunkPosX = pos.getX() >> 4; int chunkPosZ = pos.getZ() >> 4; if (!event.getWorld().isRemote) { for (int x = chunkPosX - radius; x < chunkPosX + radius; x++) { for (int z = chunkPosZ - radius; z < chunkPosZ + radius; z++) { Map<BlockPos, TileEntity> currentChunkTE = event.getWorld().getChunkFromChunkCoords(x, z).getTileEntityMap(); for (TileEntity te : currentChunkTE.values()) { if (te != null) { if (te instanceof TileEntityBlockBase && radius == 8) { doSomething(); } } } } } } } Thanks in advance. Edited November 8, 20195 yr by MSpace-Dev title and post changes to compliment solution
November 8, 20195 yr Author I've come up with a way to optimise this heavily. I will completely remove the search for tile entities, and instead store the TE's location (when it's placed) that can simply be referenced/compared to later. Hope this very specific solution comes in handy for others.
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.