Search in sources :

Example 6 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project ArsMagica2 by Mithion.

the class BossSpawnHelper method onIceEffigyBuilt.

public void onIceEffigyBuilt(World world, int x, int y, int z) {
    BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
    Type[] types = BiomeDictionary.getTypesForBiome(biome);
    boolean containsIceType = false;
    for (Type type : types) {
        if (type == Type.COLD) {
            containsIceType = true;
            break;
        }
    }
    if (!containsIceType)
        return;
    for (int i = -1; i <= 1; ++i) for (int j = -1; j <= 1; ++j) if (i == 0 && j == 0)
        continue;
    else if (!world.canBlockSeeTheSky(x + i, y + 1, z + j))
        return;
    world.setBlockToAir(x, y, z);
    world.setBlockToAir(x, y + 1, z);
    world.setBlockToAir(x, y + 2, z);
    EntityWinterGuardian guardian = new EntityWinterGuardian(world);
    guardian.setPosition(x + 0.5, y + 1, z + 0.5);
    world.spawnEntityInWorld(guardian);
}
Also used : Type(net.minecraftforge.common.BiomeDictionary.Type) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 7 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project NewHorizonsCoreMod by GTNewHorizons.

the class AllPurposeDebugCommand method processCommand.

@Override
public void processCommand(ICommandSender pCmdSender, String[] pArgs) {
    try {
        if (pArgs.length == 0) {
            moarArgs(pCmdSender);
            return;
        } else if (pArgs[0].equalsIgnoreCase("ci")) {
            EntityPlayer tEP = ((EntityPlayer) pCmdSender);
            World tWorldObj = tEP.worldObj;
            int x = (int) tEP.posX;
            int z = (int) tEP.posZ;
            BiomeGenBase tBiomeInfo = tWorldObj.getBiomeGenForCoords(x, z);
            PlayerChatHelper.SendInfo(pCmdSender, "POS: x/z %d / %d", x, z);
            PlayerChatHelper.SendInfo(pCmdSender, "DimID: %d", tWorldObj.provider.dimensionId);
            PlayerChatHelper.SendInfo(pCmdSender, "BiomeID / Name: %d / %s", tBiomeInfo.biomeID, tBiomeInfo.biomeName);
        } else if (pArgs[0].equalsIgnoreCase("reloadconfig")) {
            MainRegistry.CoreConfig.LoadConfig();
            PlayerChatHelper.SendInfo(pCmdSender, "Config reloaded");
        } else if (pArgs[0].equalsIgnoreCase("test")) {
            if (pArgs.length == 2) {
                PlayerChatHelper.SendInfo(pCmdSender, "LOC: %d %d %d", (int) ((EntityPlayer) pCmdSender).posX, (int) ((EntityPlayer) pCmdSender).posY, (int) ((EntityPlayer) pCmdSender).posZ);
                Vec3 calculatedPos = PlayerHelper.addDistanceByPlayerDirection((EntityPlayer) pCmdSender, Integer.parseInt(pArgs[1]));
                PlayerChatHelper.SendInfo(pCmdSender, "Calculated Block: %d %d %d", (int) calculatedPos.xCoord, (int) calculatedPos.yCoord, (int) calculatedPos.zCoord);
                ((EntityPlayer) pCmdSender).getEntityWorld().setBlock((int) calculatedPos.xCoord, (int) calculatedPos.yCoord, (int) calculatedPos.zCoord, Blocks.bedrock);
            } else
                moarArgs(pCmdSender);
        } else if (pArgs[0].equalsIgnoreCase("oilstruct")) {
            IModFix tModFix = ModFixesMaster.getModFixInstance(OilGeneratorFix.ModFixName);
            if (tModFix == null) {
                PlayerChatHelper.SendError(pCmdSender, "Required ModFix is not loaded");
                return;
            }
            OilGeneratorFix tOilGenFix = (OilGeneratorFix) tModFix;
            if (pArgs.length == 5) {
                String[] tBlock = pArgs[1].split(":");
                Vec3 tSourcePos = Vec3.createVectorHelper(((EntityPlayer) pCmdSender).posX, (double) Integer.parseInt(pArgs[2]), ((EntityPlayer) pCmdSender).posZ);
                // Offset Structure-gen by 50 Blocks from players current location
                Vec3 tOilStructPos = PlayerHelper.addDistanceByVecAndYaw(tSourcePos, ((EntityPlayer) pCmdSender).rotationYaw, 50);
                int tStructRadius = Integer.parseInt(pArgs[3]);
                int tStructGroundLevel = Integer.parseInt(pArgs[4]);
                Block tTargetBlock = GameRegistry.findBlock(tBlock[0], tBlock[1]);
                if (tTargetBlock != null) {
                    PlayerChatHelper.SendInfo(pCmdSender, "Creating oilStruct at location %d / %d / %d, radius [%d], virtual groundLevel [%d] with block [%s]", (int) tOilStructPos.xCoord, (int) tOilStructPos.yCoord, (int) tOilStructPos.zCoord, tStructRadius, tStructGroundLevel, pArgs[1]);
                    tOilGenFix.buildOilStructure(((EntityPlayer) pCmdSender).worldObj, new Random(), (int) tOilStructPos.xCoord, (int) tOilStructPos.yCoord, (int) tOilStructPos.zCoord, tStructRadius, tStructGroundLevel, tTargetBlock, false);
                } else
                    PlayerChatHelper.SendError(pCmdSender, "Unknown block [%s]", pArgs[1]);
            } else {
                moarArgs(pCmdSender);
                return;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        PlayerChatHelper.SendError(pCmdSender, "Unknown error occoured [%s]", e.getMessage());
    }
}
Also used : OilGeneratorFix(com.dreammaster.modfixes.oilgen.OilGeneratorFix) Random(java.util.Random) Vec3(net.minecraft.util.Vec3) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) IModFix(com.dreammaster.modfixes.IModFix) World(net.minecraft.world.World) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 8 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project NewHorizonsCoreMod by GTNewHorizons.

the class OilGeneratorFix method shouldSpawnOil.

// Check if given location is valid for spawning oil, and return the actual position in pPos
private boolean shouldSpawnOil(World pWorld, Random pRand, int pX, int pZ, Vec3 pPos) {
    // Limited to Whitelisted Dimensions
    if (!MainRegistry.CoreConfig.OilFixConfig.OilDimensionWhitelist.contains(pWorld.provider.dimensionId)) {
        if (YAMCore.isDebug())
            _mLog.info(String.format("Not generating OilDeposit; Dimension is not Whitelisted %d", pWorld.provider.dimensionId));
        return false;
    }
    BiomeGenBase biomegenbase = pWorld.getBiomeGenForCoords(pX + 8, pZ + 8);
    // Skip blacklisted DimensionIDs
    if (MainRegistry.CoreConfig.OilFixConfig.OilBiomeIDBlackList.contains(biomegenbase.biomeID)) {
        if (YAMCore.isDebug())
            _mLog.info(String.format("Not generating OilDeposit; BiomeID %d is Blacklisted", biomegenbase.biomeID));
        return false;
    }
    pRand.setSeed(pWorld.getSeed());
    long i1 = pRand.nextInt() / 2L * 2L + 1L;
    long j1 = pRand.nextInt() / 2L * 2L + 1L;
    pRand.setSeed(pX * i1 + pZ * j1 ^ pWorld.getSeed());
    double randMod = Math.min(0.2D, 0.0001D * MainRegistry.CoreConfig.OilFixConfig.OilSphereChance);
    if (biomegenbase.rootHeight >= 0.45F) {
        randMod /= 2.0D;
    }
    if (biomegenbase.rootHeight < -0.5F) {
        randMod *= 1.8D;
    }
    if (MainRegistry.CoreConfig.OilFixConfig.OilBoostBiomes.contains(biomegenbase.biomeID))
        randMod *= MainRegistry.CoreConfig.OilFixConfig.OilBiomeBoostFactor;
    boolean flag1 = pRand.nextDouble() <= randMod;
    boolean flag2 = pRand.nextDouble() <= randMod;
    if ((flag1) || (flag2)) {
        pPos.yCoord = (17 + pRand.nextInt(10) + pRand.nextInt(5));
        pPos.xCoord = (pX + pRand.nextInt(16));
        pPos.zCoord = (pZ + pRand.nextInt(16));
        return true;
    }
    return false;
}
Also used : BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 9 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project ArsMagica2 by Mithion.

the class AM2WorldDecorator method generateOverworld.

public void generateOverworld(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
    generateOre(vinteum, vinteumFrequency, world, random, vinteumMin, vinteumMax, chunkX, chunkZ);
    generateOre(chimerite, chimeriteFrequency, world, random, chimeriteMin, chimeriteMax, chunkX, chunkZ);
    generateOre(blueTopaz, topazFrequency, world, random, topazMin, topazMax, chunkX, chunkZ);
    generateOre(sunstone, sunstoneFrequency, world, random, sunstoneMin, sunstoneMax, chunkX, chunkZ);
    generateFlowers(blueOrchid, world, random, chunkX, chunkZ);
    generateFlowers(desertNova, world, random, chunkX, chunkZ);
    generateFlowers(tarmaRoot, world, random, chunkX, chunkZ);
    BiomeGenBase biome = world.getBiomeGenForCoords(chunkX << 4, chunkZ << 4);
    Type[] biomeTypes = BiomeDictionary.getTypesForBiome(biome);
    boolean typeValid = false;
    for (Type type : biomeTypes) {
        if (type == Type.BEACH || type == Type.SWAMP || type == Type.JUNGLE || type == Type.PLAINS || type == Type.WATER) {
            typeValid = true;
        } else if (type == Type.FROZEN) {
            typeValid = false;
            break;
        }
    }
    if (biome != BiomeGenBase.ocean && typeValid && random.nextInt(wakeChance) < 7) {
        generateFlowers(wakebloom, world, random, chunkX, chunkZ);
    }
    if (random.nextInt(witchChance) == 0) {
        generateTree(witchwoodTree, world, random, chunkX, chunkZ);
    }
    if (random.nextInt(poolChance) == 0) {
        generatePools(world, random, chunkX, chunkZ);
    }
    if ((BiomeDictionary.isBiomeOfType(biome, Type.MAGICAL) || BiomeDictionary.isBiomeOfType(biome, Type.FOREST)) && random.nextInt(4) == 0 && TerrainGen.populate(chunkProvider, world, random, chunkX, chunkZ, true, LAKE)) {
        int lakeGenX = (chunkX * 16) + random.nextInt(16) + 8;
        int lakeGenY = random.nextInt(128);
        int lakeGenZ = (chunkZ * 16) + random.nextInt(16) + 8;
        (new WorldGenEssenceLakes(BlocksCommonProxy.liquidEssence)).generate(world, random, lakeGenX, lakeGenY, lakeGenZ);
    }
}
Also used : WorldType(net.minecraft.world.WorldType) Type(net.minecraftforge.common.BiomeDictionary.Type) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 10 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project ArsMagica2 by Mithion.

the class EntityFlicker method getCanSpawnHere.

@Override
public boolean getCanSpawnHere() {
    if (AMCore.proxy.getTotalFlickerCount() > 8 * worldObj.playerEntities.size() || worldObj.rand.nextDouble() > 0.2f) {
        return false;
    }
    //get the biome we're trying to spawn in
    BiomeGenBase biome = worldObj.getBiomeGenForCoords((int) Math.floor(this.posX), (int) Math.floor(this.posZ));
    if (biome != null) {
        //get the tags on this biome
        Type[] biomeTags = BiomeDictionary.getTypesForBiome(biome);
        //pick a random tag to focus on
        Type tagType = biomeTags[worldObj.rand.nextInt(biomeTags.length)];
        //create a list of valid types based on that tag
        ArrayList<Affinity> validAffinities = new ArrayList<Affinity>();
        //DO NOT USE THIS LIST FOR AIR/EARTH/LIFE - they are handled by special cases.
        switch(tagType) {
            case END:
                validAffinities.add(Affinity.ENDER);
                break;
            case FOREST:
            case CONIFEROUS:
            case JUNGLE:
                validAffinities.add(Affinity.NATURE);
                break;
            case COLD:
            case SNOWY:
                validAffinities.add(Affinity.ICE);
                break;
            case MAGICAL:
                validAffinities.add(Affinity.ARCANE);
                break;
            case NETHER:
                validAffinities.add(Affinity.FIRE);
                break;
            case OCEAN:
                validAffinities.add(Affinity.LIGHTNING);
            case SWAMP:
            case WATER:
            case RIVER:
            case WET:
            case BEACH:
                validAffinities.add(Affinity.WATER);
                break;
            case DEAD:
            case DENSE:
            case DRY:
            case HOT:
            case LUSH:
            case MESA:
            case SANDY:
            case SAVANNA:
            case SPARSE:
            case SPOOKY:
            case WASTELAND:
            case PLAINS:
            case HILLS:
            case MOUNTAIN:
            case MUSHROOM:
            default:
                break;
        }
        //special conditions for air/earth flickers based on y coordinate
        if (posY < 55) {
            validAffinities.add(Affinity.EARTH);
        }
        if (worldObj.canBlockSeeTheSky((int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ)))
            validAffinities.add(Affinity.AIR);
        if (worldObj.isRaining() && worldObj.rand.nextBoolean()) {
            validAffinities.clear();
            validAffinities.add(Affinity.LIGHTNING);
        }
        if (validAffinities.size() <= 0)
            return false;
        //life flickers always have a chance to spawn?
        if (worldObj.rand.nextDouble() < 0.1f) {
            this.setFlickerType(Affinity.LIFE);
        } else {
            this.setFlickerType(validAffinities.get(worldObj.rand.nextInt(validAffinities.size())));
        }
        if (this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty()) {
            AMCore.proxy.incrementFlickerCount();
            return true;
        }
    }
    return false;
}
Also used : Type(net.minecraftforge.common.BiomeDictionary.Type) ArrayList(java.util.ArrayList) Affinity(am2.api.spell.enums.Affinity) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Aggregations

BiomeGenBase (net.minecraft.world.biome.BiomeGenBase)12 Type (net.minecraftforge.common.BiomeDictionary.Type)5 Block (net.minecraft.block.Block)2 Affinity (am2.api.spell.enums.Affinity)1 IModFix (com.dreammaster.modfixes.IModFix)1 OilGeneratorFix (com.dreammaster.modfixes.oilgen.OilGeneratorFix)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 Material (net.minecraft.block.material.Material)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 Vec3 (net.minecraft.util.Vec3)1 World (net.minecraft.world.World)1 WorldType (net.minecraft.world.WorldType)1 WorldGenFlowers (net.minecraft.world.gen.feature.WorldGenFlowers)1 LiquidStack (net.minecraftforge.liquids.LiquidStack)1