Search in sources :

Example 1 with TObjectIntCustomHashMap

use of gnu.trove.map.custom_hash.TObjectIntCustomHashMap in project DynamicSurroundings by OreCruncher.

the class BiomeScanner method update.

@Override
public void update() {
    final BlockPos position = EnvironState.getPlayerPosition();
    if (this.surveyedBiome != EnvironState.getPlayerBiome() || this.surveyedDimension != EnvironState.getDimensionId() || this.surveyedPosition.compareTo(position) != 0) {
        this.surveyedBiome = EnvironState.getPlayerBiome();
        this.surveyedDimension = EnvironState.getDimensionId();
        this.surveyedPosition = position;
        this.biomeArea = 0;
        this.weights.clear();
        if (EnvironState.getPlayerBiome().isFake()) {
            this.biomeArea = 1;
            this.weights.put(EnvironState.getPlayerBiome(), 1);
        } else {
            final IBlockAccessEx provider = ClientChunkCache.INSTANCE;
            // Collect raw biome data before mapping to BiomeInfo - saves lookups
            final TObjectIntCustomHashMap<Biome> scratch = new TObjectIntCustomHashMap<>(IdentityHashingStrategy.INSTANCE);
            for (int dX = -BIOME_SURVEY_RANGE; dX <= BIOME_SURVEY_RANGE; dX++) for (int dZ = -BIOME_SURVEY_RANGE; dZ <= BIOME_SURVEY_RANGE; dZ++) {
                this.mutable.setPos(this.surveyedPosition.getX() + dX, 0, this.surveyedPosition.getZ() + dZ);
                scratch.adjustOrPutValue(provider.getBiome(this.mutable), 1, 1);
            }
            this.biomeArea = MAX_BIOME_AREA;
            scratch.forEachEntry((biome, w) -> {
                this.weights.put(ClientRegistry.BIOME.get(biome), w);
                return true;
            });
        }
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) IBlockAccessEx(org.blockartistry.lib.chunk.IBlockAccessEx) BlockPos(net.minecraft.util.math.BlockPos) TObjectIntCustomHashMap(gnu.trove.map.custom_hash.TObjectIntCustomHashMap)

Aggregations

TObjectIntCustomHashMap (gnu.trove.map.custom_hash.TObjectIntCustomHashMap)1 BlockPos (net.minecraft.util.math.BlockPos)1 Biome (net.minecraft.world.biome.Biome)1 IBlockAccessEx (org.blockartistry.lib.chunk.IBlockAccessEx)1