MinecraftForge / ForgeFlower

Forge's modifications to FernFlower. Fixing various bugs/inconsistencies. Main Repo: https://github.com/MinecraftForge/FernFlower
Apache License 2.0
80 stars 44 forks source link

WorldEntitySpawner.func_234964_a_ - the loop has gotten completely smashed apart #70

Closed cpw closed 1 year ago

cpw commented 4 years ago
   public static WorldEntitySpawner.EntityDensityManager func_234964_a_(int p_234964_0_, Iterable<Entity> p_234964_1_, WorldEntitySpawner.IInitialDensityAdder p_234964_2_) {
      MobDensityTracker mobdensitytracker = new MobDensityTracker();
      Object2IntOpenHashMap<EntityClassification> object2intopenhashmap = new Object2IntOpenHashMap<>();
      Iterator iterator = p_234964_1_.iterator();

      while(true) {
         Entity entity;
         while(true) {
            if (!iterator.hasNext()) {
               return new WorldEntitySpawner.EntityDensityManager(p_234964_0_, object2intopenhashmap, mobdensitytracker);
            }

            entity = (Entity)iterator.next();
            if (!(entity instanceof MobEntity)) {
               break;
            }

            MobEntity mobentity = (MobEntity)entity;
            if (!mobentity.func_104002_bU() && !mobentity.func_213392_I()) {
               break;
            }
         }

         EntityClassification entityclassification = entity.func_200600_R().func_220339_d();
         if (entityclassification != EntityClassification.MISC) {
            BlockPos blockpos = entity.func_233580_cy_();
            long i = ChunkPos.func_77272_a(blockpos.func_177958_n() >> 4, blockpos.func_177952_p() >> 4);
            p_234964_2_.query(i, (p_234971_5_) -> {
               Biome biome = func_234980_b_(blockpos, p_234971_5_);
               Biome.EntityDensity biome$entitydensity = biome.func_235058_a_(entity.func_200600_R());
               if (biome$entitydensity != null) {
                  mobdensitytracker.func_234998_a_(entity.func_233580_cy_(), biome$entitydensity.func_235120_b_());
               }

               object2intopenhashmap.addTo(entityclassification, 1);
            });
         }
      }
   }

This loop structure looks really weird, as if it was unable to figure out a for loop properly, with a continue condition or something similar.