Skip to content

Commit

Permalink
style: De-obfuscate some intermediary names
Browse files Browse the repository at this point in the history
  • Loading branch information
jellysquid3 committed Sep 23, 2020
1 parent 71f089a commit 90c2427
Showing 1 changed file with 48 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,47 @@ public static List<Entity> 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<Entity> getEntitiesOfClassGroup(World world, Entity excluded, EntityClassGroup type, Box box_1, Predicate<Entity> predicate_1) {
public static List<Entity> getEntitiesOfClassGroup(World world, Entity excluded, EntityClassGroup type, Box box, Predicate<Entity> 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<Entity> 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<Entity> 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<Entity> list_1, Predicate<Entity> predicate_1) {
public static void getEntitiesOfClassGroup(WorldChunk worldChunk, Entity excluded, EntityClassGroup type, Box box, List<Entity> out, Predicate<Entity> predicate) {
TypeFilterableList<Entity>[] 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);
}
}
}
Expand All @@ -98,39 +102,42 @@ public static void getEntitiesOfClassGroup(WorldChunk worldChunk, Entity exclude
*/
public static List<Entity> getEntitiesOfClass(World world, Entity except, Class<? extends Entity> 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<Entity> 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<Entity> 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<? extends Entity> entityClass, Box box, List<Entity> entityList) {
private static void getEntitiesOfClass(WorldChunk worldChunk, Entity excluded, Class<? extends Entity> entityClass, Box box, List<Entity> out) {
TypeFilterableList<Entity>[] 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);
}
}
}
Expand Down

0 comments on commit 90c2427

Please sign in to comment.