Search in sources :

Example 46 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project RFToolsDimensions by McJty.

the class BiomeAbsorberTileEntity method checkStateServer.

protected void checkStateServer() {
    if (absorbing > 0) {
        BiomeGenBase biomeGenBase = worldObj.getBiomeGenForCoords(getPos());
        if (biomeGenBase == null || !biomeGenBase.biomeName.equals(biomeName)) {
            return;
        }
        absorbing--;
        markDirtyClient();
    }
}
Also used : BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 47 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project RFToolsDimensions by McJty.

the class DimensionInformation method setupFromNBT.

private void setupFromNBT(NBTTagCompound tagCompound) {
    terrainType = TerrainType.values()[tagCompound.getInteger("terrain")];
    featureTypes = toEnumSet(getIntArraySafe(tagCompound, "features"), FeatureType.values());
    structureTypes = toEnumSet(getIntArraySafe(tagCompound, "structures"), StructureType.values());
    effectTypes = toEnumSet(getIntArraySafe(tagCompound, "effects"), EffectType.values());
    biomes.clear();
    for (int a : getIntArraySafe(tagCompound, "biomes")) {
        BiomeGenBase biome = BiomeGenBase.getBiome(a);
        if (biome != null) {
            biomes.add(biome);
        } else {
            // Protect against deleted biomes (i.e. a mod with biomes gets removed and this dimension still uses it).
            // We will pick a replacement biome here.
            biomes.add(BiomeGenBase.plains);
        }
    }
    if (tagCompound.hasKey("controller")) {
        controllerType = ControllerType.values()[tagCompound.getInteger("controller")];
    } else {
        // Support for old type.
        if (biomes.isEmpty()) {
            controllerType = ControllerType.CONTROLLER_DEFAULT;
        } else {
            controllerType = ControllerType.CONTROLLER_SINGLE;
        }
    }
    digitString = tagCompound.getString("digits");
    forcedDimensionSeed = tagCompound.getLong("forcedSeed");
    baseSeed = tagCompound.getLong("baseSeed");
    worldVersion = tagCompound.getInteger("worldVersion");
    baseBlockForTerrain = getBlockMeta(tagCompound, "baseBlock");
    tendrilBlock = getBlockMeta(tagCompound, "tendrilBlock");
    canyonBlock = getBlockMeta(tagCompound, "canyonBlock");
    fluidForTerrain = (Block) Block.blockRegistry.getObjectById(tagCompound.getInteger("fluidBlock"));
    hugeLiquidSphereFluids = readFluidsFromNBT(tagCompound, "hugeLiquidSphereFluids");
    hugeLiquidSphereBlocks = readBlockArrayFromNBT(tagCompound, "hugeLiquidSphereBlocks");
    // Support for the old format with only one liquid block.
    Block oldLiquidSphereFluid = (Block) Block.blockRegistry.getObjectById(tagCompound.getInteger("liquidSphereFluid"));
    liquidSphereFluids = readFluidsFromNBT(tagCompound, "liquidSphereFluids");
    if (liquidSphereFluids.length == 0) {
        liquidSphereFluids = new Block[] { oldLiquidSphereFluid };
    }
    // Support for the old format with only one sphere block.
    IBlockState oldLiquidSphereBlock = getBlockMeta(tagCompound, "liquidSphereBlock");
    liquidSphereBlocks = readBlockArrayFromNBT(tagCompound, "liquidSphereBlocks");
    if (liquidSphereBlocks.length == 0) {
        liquidSphereBlocks = new IBlockState[] { oldLiquidSphereBlock };
    }
    pyramidBlocks = readBlockArrayFromNBT(tagCompound, "pyramidBlocks");
    if (pyramidBlocks.length == 0) {
        pyramidBlocks = new IBlockState[] { Blocks.stone.getDefaultState() };
    }
    // Support for the old format with only one sphere block.
    IBlockState oldSphereBlock = getBlockMeta(tagCompound, "sphereBlock");
    sphereBlocks = readBlockArrayFromNBT(tagCompound, "sphereBlocks");
    if (sphereBlocks.length == 0) {
        sphereBlocks = new IBlockState[] { oldSphereBlock };
    }
    hugeSphereBlocks = readBlockArrayFromNBT(tagCompound, "hugeSphereBlocks");
    extraOregen = readBlockArrayFromNBT(tagCompound, "extraOregen");
    fluidsForLakes = readFluidsFromNBT(tagCompound, "lakeFluids");
    peaceful = tagCompound.getBoolean("peaceful");
    noanimals = tagCompound.getBoolean("noanimals");
    shelter = tagCompound.getBoolean("shelter");
    respawnHere = tagCompound.getBoolean("respawnHere");
    if (tagCompound.hasKey("celestialAngle")) {
        celestialAngle = tagCompound.getFloat("celestialAngle");
    } else {
        celestialAngle = null;
    }
    if (tagCompound.hasKey("timeSpeed")) {
        timeSpeed = tagCompound.getFloat("timeSpeed");
    } else {
        timeSpeed = null;
    }
    probeCounter = tagCompound.getInteger("probes");
    actualRfCost = tagCompound.getInteger("actualCost");
    skyDescriptor = new SkyDescriptor.Builder().fromNBT(tagCompound).build();
    calculateCelestialBodyDescriptors();
    patreon1 = tagCompound.getLong("patreon1");
    weatherDescriptor = new WeatherDescriptor.Builder().fromNBT(tagCompound).build();
    extraMobs.clear();
    NBTTagList list = tagCompound.getTagList("mobs", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < list.tagCount(); i++) {
        NBTTagCompound tc = list.getCompoundTagAt(i);
        String className = tc.getString("class");
        int chance = tc.getInteger("chance");
        int minGroup = tc.getInteger("minGroup");
        int maxGroup = tc.getInteger("maxGroup");
        int maxLoaded = tc.getInteger("maxLoaded");
        Class<? extends EntityLiving> c = null;
        try {
            c = (Class<? extends EntityLiving>) Class.forName(className);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
        MobDescriptor mob = new MobDescriptor(c, chance, minGroup, maxGroup, maxLoaded);
        extraMobs.add(mob);
    }
    String ds = tagCompound.getString("dimensionTypes");
    dimensionTypes = StringUtils.split(ds, ",");
    if (dimensionTypes == null) {
        dimensionTypes = new String[0];
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) Block(net.minecraft.block.Block)

Example 48 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project RFToolsDimensions by McJty.

the class DimensionInformation method dump.

public void dump(EntityPlayer player) {
    String digits = getDigitString();
    if (!digits.isEmpty()) {
        logDebug(player, "    Digits: " + digits);
    }
    if (forcedDimensionSeed != 0) {
        logDebug(player, "    Forced seed: " + forcedDimensionSeed);
    }
    if (baseSeed != 0) {
        logDebug(player, "    Base seed: " + baseSeed);
    }
    logDebug(player, "    World version: " + worldVersion);
    TerrainType terrainType = getTerrainType();
    logDebug(player, "    Terrain: " + terrainType.toString());
    logDebug(player, "        Base block: " + getDisplayName(baseBlockForTerrain));
    if (featureTypes.contains(FeatureType.FEATURE_TENDRILS)) {
        logDebug(player, "        Tendril block: " + getDisplayName(tendrilBlock));
    }
    if (featureTypes.contains(FeatureType.FEATURE_PYRAMIDS)) {
        for (IBlockState block : pyramidBlocks) {
            if (block != null) {
                logDebug(player, "        Pyramid blocks: " + getDisplayName(block));
            }
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_ORBS)) {
        for (IBlockState block : sphereBlocks) {
            if (block != null) {
                logDebug(player, "        Orb blocks: " + getDisplayName(block));
            }
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_HUGEORBS)) {
        for (IBlockState block : hugeSphereBlocks) {
            if (block != null) {
                logDebug(player, "        Huge Orb blocks: " + getDisplayName(block));
            }
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_LIQUIDORBS)) {
        for (IBlockState block : liquidSphereBlocks) {
            if (block != null) {
                logDebug(player, "        Liquid Orb blocks: " + getDisplayName(block));
            }
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_HUGELIQUIDORBS)) {
        for (IBlockState block : hugeLiquidSphereBlocks) {
            if (block != null) {
                logDebug(player, "        Huge Liquid Orb blocks: " + getDisplayName(block));
            }
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_CANYONS)) {
        logDebug(player, "        Canyon block: " + getDisplayName(canyonBlock));
    }
    logDebug(player, "        Base fluid: " + getDisplayName(fluidForTerrain));
    logDebug(player, "    Biome controller: " + (controllerType == null ? "<null>" : controllerType.name()));
    for (BiomeGenBase biome : getBiomes()) {
        if (biome != null) {
            logDebug(player, "    Biome: " + biome.biomeName);
        }
    }
    for (FeatureType featureType : getFeatureTypes()) {
        logDebug(player, "    Feature: " + featureType.toString());
    }
    for (IBlockState block : extraOregen) {
        if (block != null) {
            logDebug(player, "        Extra ore: " + getDisplayName(block));
        }
    }
    for (Block block : fluidsForLakes) {
        logDebug(player, "        Lake fluid: " + getDisplayName(block));
    }
    if (featureTypes.contains(FeatureType.FEATURE_LIQUIDORBS)) {
        for (Block fluid : liquidSphereFluids) {
            logDebug(player, "        Liquid orb fluids: " + getDisplayName(fluid));
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_HUGELIQUIDORBS)) {
        for (Block fluid : hugeLiquidSphereFluids) {
            logDebug(player, "        Huge Liquid orb fluids: " + getDisplayName(fluid));
        }
    }
    for (StructureType structureType : getStructureTypes()) {
        logDebug(player, "    Structure: " + structureType.toString());
    }
    if (structureTypes.contains(StructureType.STRUCTURE_RECURRENTCOMPLEX)) {
        for (String type : dimensionTypes) {
            logDebug(player, "    RR DimensionType: " + type);
        }
    }
    for (EffectType effectType : getEffectTypes()) {
        logDebug(player, "    Effect: " + effectType.toString());
    }
    logDebug(player, "    Sun brightness: " + skyDescriptor.getSunBrightnessFactor());
    logDebug(player, "    Star brightness: " + skyDescriptor.getStarBrightnessFactor());
    float r = skyDescriptor.getSkyColorFactorR();
    float g = skyDescriptor.getSkyColorFactorG();
    float b = skyDescriptor.getSkyColorFactorB();
    logDebug(player, "    Sky color: " + r + ", " + g + ", " + b);
    r = skyDescriptor.getFogColorFactorR();
    g = skyDescriptor.getFogColorFactorG();
    b = skyDescriptor.getFogColorFactorB();
    logDebug(player, "    Fog color: " + r + ", " + g + ", " + b);
    SkyType skyType = skyDescriptor.getSkyType();
    if (skyType != SkyType.SKY_NORMAL) {
        logDebug(player, "    Sky type: " + skyType.toString());
    }
    for (CelestialBodyType bodyType : skyDescriptor.getCelestialBodies()) {
        logDebug(player, "    Sky body: " + bodyType.name());
    }
    if (weatherDescriptor.getRainStrength() > -0.5f) {
        logDebug(player, "    Weather rain: " + weatherDescriptor.getRainStrength());
    }
    if (weatherDescriptor.getThunderStrength() > -0.5f) {
        logDebug(player, "    Weather thunder " + weatherDescriptor.getThunderStrength());
    }
    for (MobDescriptor mob : extraMobs) {
        if (mob != null) {
            if (mob.getEntityClass() == null) {
                logDebug(player, "    Mob: " + mob);
            } else {
                logDebug(player, "    Mob: " + mob.getEntityClass().getName());
            }
        }
    }
    if (peaceful) {
        logDebug(player, "    Peaceful mode");
    }
    if (noanimals) {
        logDebug(player, "    No animals mode");
    }
    if (shelter) {
        logDebug(player, "    Safe shelter");
    }
    if (respawnHere) {
        logDebug(player, "    Respawn local");
    }
    if (celestialAngle != null) {
        logDebug(player, "    Celestial angle: " + celestialAngle);
    }
    if (timeSpeed != null) {
        logDebug(player, "    Time speed: " + timeSpeed);
    }
    if (probeCounter > 0) {
        logDebug(player, "    Probes: " + probeCounter);
    }
    if (patreon1 != 0) {
        logDebug(player, "    Patreon: " + patreon1);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 49 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project RFToolsDimensions by McJty.

the class DimensionInformation method setupBiomeMapping.

private void setupBiomeMapping() {
    biomeMapping.clear();
    if (controllerType == ControllerType.CONTROLLER_FILTERED) {
        BiomeGenBase[] biomeGenArray = BiomeGenBase.getBiomeGenArray();
        final Set<Integer> ids = new HashSet<Integer>();
        for (BiomeGenBase biome : biomes) {
            if (biome != null) {
                ids.add(biome.biomeID);
            } else {
                ids.add(BiomeGenBase.plains.biomeID);
            }
        }
        ControllerType.BiomeFilter biomeFilter = new ControllerType.BiomeFilter() {

            @Override
            public boolean match(BiomeGenBase biome) {
                return ids.contains(biome.biomeID);
            }

            @Override
            public double calculateBiomeDistance(BiomeGenBase a, BiomeGenBase b) {
                return calculateBiomeDistance(a, b, false, false, false);
            }
        };
        BiomeControllerMapping.makeFilteredBiomeMap(biomeGenArray, biomeMapping, biomeFilter);
    }
}
Also used : BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 50 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project RFToolsDimensions by McJty.

the class DimensionInformation method toBytes.

public void toBytes(ByteBuf buf) {
    NetworkTools.writeString(buf, ownerName);
    if (owner == null) {
        buf.writeBoolean(false);
    } else {
        buf.writeBoolean(true);
        buf.writeLong(owner.getMostSignificantBits());
        buf.writeLong(owner.getLeastSignificantBits());
    }
    NetworkTools.writeEnum(buf, terrainType, TerrainType.TERRAIN_VOID);
    NetworkTools.writeEnumCollection(buf, featureTypes);
    NetworkTools.writeEnumCollection(buf, structureTypes);
    NetworkTools.writeEnumCollection(buf, effectTypes);
    buf.writeInt(biomes.size());
    for (BiomeGenBase entry : biomes) {
        if (entry != null) {
            buf.writeInt(entry.biomeID);
        } else {
            buf.writeInt(BiomeGenBase.plains.biomeID);
        }
    }
    NetworkTools.writeEnum(buf, controllerType, ControllerType.CONTROLLER_DEFAULT);
    NetworkTools.writeString(buf, digitString);
    buf.writeLong(forcedDimensionSeed);
    buf.writeLong(baseSeed);
    buf.writeInt(worldVersion);
    buf.writeInt(Block.blockRegistry.getIDForObject(baseBlockForTerrain.getBlock()));
    buf.writeInt(baseBlockForTerrain.getBlock().getMetaFromState(baseBlockForTerrain));
    buf.writeInt(Block.blockRegistry.getIDForObject(tendrilBlock.getBlock()));
    buf.writeInt(tendrilBlock.getBlock().getMetaFromState(tendrilBlock));
    writeBlockArrayToBuf(buf, pyramidBlocks);
    writeBlockArrayToBuf(buf, sphereBlocks);
    writeBlockArrayToBuf(buf, hugeSphereBlocks);
    writeBlockArrayToBuf(buf, liquidSphereBlocks);
    writeFluidArrayToBuf(buf, liquidSphereFluids);
    writeBlockArrayToBuf(buf, hugeLiquidSphereBlocks);
    writeFluidArrayToBuf(buf, hugeLiquidSphereFluids);
    buf.writeInt(Block.blockRegistry.getIDForObject(canyonBlock.getBlock()));
    buf.writeInt(canyonBlock.getBlock().getMetaFromState(canyonBlock));
    buf.writeInt(Block.blockRegistry.getIDForObject(fluidForTerrain));
    writeBlockArrayToBuf(buf, extraOregen);
    writeFluidArrayToBuf(buf, fluidsForLakes);
    buf.writeBoolean(peaceful);
    buf.writeBoolean(noanimals);
    buf.writeBoolean(shelter);
    buf.writeBoolean(respawnHere);
    NetworkTools.writeFloat(buf, celestialAngle);
    NetworkTools.writeFloat(buf, timeSpeed);
    buf.writeInt(probeCounter);
    buf.writeInt(actualRfCost);
    skyDescriptor.toBytes(buf);
    weatherDescriptor.toBytes(buf);
    buf.writeLong(patreon1);
    int mobsize = 0;
    for (MobDescriptor mob : extraMobs) {
        if (mob != null) {
            if (mob.getEntityClass() != null) {
                mobsize++;
            }
        }
    }
    buf.writeInt(mobsize);
    for (MobDescriptor mob : extraMobs) {
        if (mob != null) {
            if (mob.getEntityClass() != null) {
                NetworkTools.writeString(buf, mob.getEntityClass().getName());
                buf.writeInt(mob.getSpawnChance());
                buf.writeInt(mob.getMinGroup());
                buf.writeInt(mob.getMaxGroup());
                buf.writeInt(mob.getMaxLoaded());
            }
        }
    }
    buf.writeInt(dimensionTypes.length);
    for (String type : dimensionTypes) {
        NetworkTools.writeString(buf, type);
    }
}
Also used : BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Aggregations

BiomeGenBase (net.minecraft.world.biome.BiomeGenBase)63 BlockPos (net.minecraft.util.BlockPos)10 Block (net.minecraft.block.Block)8 World (net.minecraft.world.World)5 Type (net.minecraftforge.common.BiomeDictionary.Type)5 ArrayList (java.util.ArrayList)4 EnumHumidity (forestry.api.core.EnumHumidity)3 IBlockState (net.minecraft.block.state.IBlockState)3 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)3 BiomeDictionary (net.minecraftforge.common.BiomeDictionary)3 IBeeGenome (forestry.api.apiculture.IBeeGenome)2 EnumTemperature (forestry.api.core.EnumTemperature)2 File (java.io.File)2 HashSet (java.util.HashSet)2 Random (java.util.Random)2 Material (net.minecraft.block.material.Material)2 Entity (net.minecraft.entity.Entity)2 ChunkCoordinates (net.minecraft.util.ChunkCoordinates)2 EventHandler (net.minecraftforge.fml.common.Mod.EventHandler)2 Color (org.blockartistry.mod.DynSurround.util.Color)2