From 90c24275fb4d342ab8360267bd488b1260d13fb0 Mon Sep 17 00:00:00 2001 From: JellySquid Date: Wed, 23 Sep 2020 09:37:25 -0500 Subject: [PATCH] style: De-obfuscate some intermediary names --- .../lithium/common/world/WorldHelper.java | 89 ++++++++++--------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/src/main/java/me/jellysquid/mods/lithium/common/world/WorldHelper.java b/src/main/java/me/jellysquid/mods/lithium/common/world/WorldHelper.java index 2321ef828..071da7ad8 100644 --- a/src/main/java/me/jellysquid/mods/lithium/common/world/WorldHelper.java +++ b/src/main/java/me/jellysquid/mods/lithium/common/world/WorldHelper.java @@ -50,43 +50,47 @@ public static List getEntitiesWithCollisionBoxForEntity(EntityView entit * Method that allows getting entities of a class group. * [VanillaCopy] but custom combination of: get class filtered entities together with excluding one entity */ - public static List getEntitiesOfClassGroup(World world, Entity excluded, EntityClassGroup type, Box box_1, Predicate predicate_1) { + public static List getEntitiesOfClassGroup(World world, Entity excluded, EntityClassGroup type, Box box, Predicate predicate) { world.getProfiler().visit("getEntities"); - int int_1 = MathHelper.floor((box_1.minX - 2.0D) / 16.0D); - int int_2 = MathHelper.ceil((box_1.maxX + 2.0D) / 16.0D); - int int_3 = MathHelper.floor((box_1.minZ - 2.0D) / 16.0D); - int int_4 = MathHelper.ceil((box_1.maxZ + 2.0D) / 16.0D); - List list_1 = Lists.newArrayList(); - ChunkManager chunkManager_1 = world.getChunkManager(); - - for (int int_5 = int_1; int_5 < int_2; ++int_5) { - for (int int_6 = int_3; int_6 < int_4; ++int_6) { - WorldChunk worldChunk_1 = chunkManager_1.getWorldChunk(int_5, int_6, false); - if (worldChunk_1 != null) { - WorldHelper.getEntitiesOfClassGroup(worldChunk_1, excluded, type, box_1, list_1, predicate_1); + + int minChunkX = MathHelper.floor((box.minX - 2.0D) / 16.0D); + int maxChunkX = MathHelper.ceil((box.maxX + 2.0D) / 16.0D); + int minChunkZ = MathHelper.floor((box.minZ - 2.0D) / 16.0D); + int maxChunkZ = MathHelper.ceil((box.maxZ + 2.0D) / 16.0D); + + List entities = Lists.newArrayList(); + ChunkManager chunkManager = world.getChunkManager(); + + for (int chunkX = minChunkX; chunkX < maxChunkX; chunkX++) { + for (int chunkZ = minChunkZ; chunkZ < maxChunkZ; chunkZ++) { + WorldChunk chunk = chunkManager.getWorldChunk(chunkX, chunkZ, false); + + if (chunk != null) { + WorldHelper.getEntitiesOfClassGroup(chunk, excluded, type, box, entities, predicate); } } } - return list_1; + return entities; } /** * Method that allows getting entities of a class group. * [VanillaCopy] but custom combination of: get class filtered entities together with excluding one entity */ - public static void getEntitiesOfClassGroup(WorldChunk worldChunk, Entity excluded, EntityClassGroup type, Box box_1, List list_1, Predicate predicate_1) { + public static void getEntitiesOfClassGroup(WorldChunk worldChunk, Entity excluded, EntityClassGroup type, Box box, List out, Predicate predicate) { TypeFilterableList[] entitySections = worldChunk.getEntitySectionArray(); - int int_1 = MathHelper.floor((box_1.minY - 2.0D) / 16.0D); - int int_2 = MathHelper.floor((box_1.maxY + 2.0D) / 16.0D); - int_1 = MathHelper.clamp(int_1, 0, entitySections.length - 1); - int_2 = MathHelper.clamp(int_2, 0, entitySections.length - 1); + int minSectionY = MathHelper.floor((box.minY - 2.0D) / 16.0D); + int maxSectionY = MathHelper.floor((box.maxY + 2.0D) / 16.0D); - for (int int_3 = int_1; int_3 <= int_2; ++int_3) { + minSectionY = MathHelper.clamp(minSectionY, 0, entitySections.length - 1); + maxSectionY = MathHelper.clamp(maxSectionY, 0, entitySections.length - 1); + + for (int sectionY = minSectionY; sectionY <= maxSectionY; ++sectionY) { //noinspection rawtypes - for (Object entity_1 : ((ClassGroupFilterableList) entitySections[int_3]).getAllOfGroupType(type)) { - if (entity_1 != excluded && ((Entity) entity_1).getBoundingBox().intersects(box_1) && (predicate_1 == null || predicate_1.test((Entity) entity_1))) { - list_1.add((Entity) entity_1); + for (Object entity : ((ClassGroupFilterableList) entitySections[sectionY]).getAllOfGroupType(type)) { + if (entity != excluded && ((Entity) entity).getBoundingBox().intersects(box) && (predicate == null || predicate.test((Entity) entity))) { + out.add((Entity) entity); } } } @@ -98,39 +102,42 @@ public static void getEntitiesOfClassGroup(WorldChunk worldChunk, Entity exclude */ public static List getEntitiesOfClass(World world, Entity except, Class entityClass, Box box) { world.getProfiler().visit("getEntities"); - int chunkX1 = MathHelper.floor((box.minX - 2.0D) / 16.0D); - int chunkX2 = MathHelper.ceil((box.maxX + 2.0D) / 16.0D); - int chunkZ1 = MathHelper.floor((box.minZ - 2.0D) / 16.0D); - int chunkZ2 = MathHelper.ceil((box.maxZ + 2.0D) / 16.0D); - List entityList = Lists.newArrayList(); + + int minChunkX = MathHelper.floor((box.minX - 2.0D) / 16.0D); + int maxChunkX = MathHelper.ceil((box.maxX + 2.0D) / 16.0D); + int minChunkZ = MathHelper.floor((box.minZ - 2.0D) / 16.0D); + int maxChunkZ = MathHelper.ceil((box.maxZ + 2.0D) / 16.0D); + + List entities = Lists.newArrayList(); ChunkManager chunkManager = world.getChunkManager(); - for (int chunkX = chunkX1; chunkX < chunkX2; ++chunkX) { - for (int chunkZ = chunkZ1; chunkZ < chunkZ2; ++chunkZ) { - WorldChunk worldChunk = chunkManager.getWorldChunk(chunkX, chunkZ, false); - if (worldChunk != null) { - WorldHelper.getEntitiesOfClass(worldChunk, except, entityClass, box, entityList); + for (int chunkX = minChunkX; chunkX < maxChunkX; ++chunkX) { + for (int chunkZ = minChunkZ; chunkZ < maxChunkZ; ++chunkZ) { + WorldChunk chunk = chunkManager.getWorldChunk(chunkX, chunkZ, false); + + if (chunk != null) { + WorldHelper.getEntitiesOfClass(chunk, except, entityClass, box, entities); } } } - return entityList; + return entities; } /** * [VanillaCopy] Method for getting entities by class but also exclude one entity */ - private static void getEntitiesOfClass(WorldChunk worldChunk, Entity excluded, Class entityClass, Box box, List entityList) { + private static void getEntitiesOfClass(WorldChunk worldChunk, Entity excluded, Class entityClass, Box box, List out) { TypeFilterableList[] entitySections = worldChunk.getEntitySectionArray(); - int chunkY1 = MathHelper.floor((box.minY - 2.0D) / 16.0D); - int chunkY2 = MathHelper.floor((box.maxY + 2.0D) / 16.0D); - chunkY1 = MathHelper.clamp(chunkY1, 0, entitySections.length - 1); - chunkY2 = MathHelper.clamp(chunkY2, 0, entitySections.length - 1); + int minChunkY = MathHelper.floor((box.minY - 2.0D) / 16.0D); + int maxChunkY = MathHelper.floor((box.maxY + 2.0D) / 16.0D); + minChunkY = MathHelper.clamp(minChunkY, 0, entitySections.length - 1); + maxChunkY = MathHelper.clamp(maxChunkY, 0, entitySections.length - 1); - for (int chunkY = chunkY1; chunkY <= chunkY2; ++chunkY) { + for (int chunkY = minChunkY; chunkY <= maxChunkY; chunkY++) { for (Entity entity : entitySections[chunkY].getAllOfType(entityClass)) { if (entity != excluded && entity.getBoundingBox().intersects(box)) { - entityList.add(entity); + out.add(entity); } } }