Search in sources :

Example 11 with EnumGem

use of net.silentchaos512.gems.lib.EnumGem in project SilentGems by SilentChaos512.

the class GemsWorldGenerator method generateFlowers.

private void generateFlowers(World world, Random random, int posX, int posZ) {
    int i, x, y, z, meta;
    IBlockState state;
    BlockPos pos;
    for (i = 0; i < GemsConfig.GLOW_ROSE_PER_CHUNK; ++i) {
        x = posX + 8 + random.nextInt(16);
        y = random.nextInt(120) + 50;
        z = posZ + 8 + random.nextInt(16);
        pos = new BlockPos(x, y, z);
        meta = random.nextInt(16);
        EnumGem gem = EnumGem.values()[meta];
        state = ModBlocks.glowRose.getDefaultState().withProperty(EnumGem.VARIANT_GEM, gem);
        // Find top-most valid block
        for (; y > 50; --y) {
            if (world.isAirBlock(pos) && pos.getY() < 255 && ModBlocks.glowRose.canBlockStay(world, pos, state)) {
                world.setBlockState(pos, state, 2);
                break;
            }
            pos = pos.down();
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumGem(net.silentchaos512.gems.lib.EnumGem) BlockPos(net.minecraft.util.math.BlockPos)

Example 12 with EnumGem

use of net.silentchaos512.gems.lib.EnumGem in project SilentGems by SilentChaos512.

the class GeodeGenerator method generateGems.

public void generateGems(World worldIn, Random rand, BlockPos position, float diameterXZ, float diameterY) {
    Predicate shellPredicate = BlockMatcher.forBlock(shellBlock.getBlock());
    diameterXZ *= GemsConfig.GEODE_FILL_RATIO;
    diameterY *= GemsConfig.GEODE_FILL_RATIO;
    int xmin = (int) (position.getX() - diameterXZ / 2);
    int xmax = (int) (position.getX() + diameterXZ / 2);
    int ymin = (int) (position.getY() - diameterY / 2);
    int ymax = (int) (position.getY() + diameterY / 2);
    int zmin = (int) (position.getZ() - diameterXZ / 2);
    int zmax = (int) (position.getZ() + diameterXZ / 2);
    Block block = gemSet == Set.LIGHT ? ModBlocks.gemOreLight : gemSet == Set.DARK ? ModBlocks.gemOreDark : ModBlocks.gemOre;
    int count = 0;
    for (int x = xmin; x <= xmax; ++x) {
        float dx = x - position.getX();
        for (int y = ymin; y <= ymax; ++y) {
            float dy = y - position.getY();
            for (int z = zmin; z <= zmax; ++z) {
                float dz = z - position.getZ();
                if ((dx * dx) / (diameterXZ * diameterXZ) + (dy * dy) / (diameterY * diameterY) + (dz * dz) / (diameterXZ * diameterXZ) <= 0.25f) {
                    // We are in the spawn area.
                    if (rand.nextFloat() <= GemsConfig.GEODE_GEM_DENSITY) {
                        ++count;
                        BlockPos blockpos = new BlockPos(x, y, z);
                        IBlockState state = worldIn.getBlockState(blockpos);
                        if (state.getBlock().isReplaceableOreGen(state, worldIn, blockpos, shellPredicate)) {
                            EnumGem gem = EnumGem.values()[rand.nextInt(16)];
                            IBlockState stateToPlace = block.getDefaultState().withProperty(EnumGem.VARIANT_GEM, gem);
                            worldIn.setBlockState(blockpos, stateToPlace, 2);
                        }
                    }
                    // TODO: Doesn't seem to work very well...
                    if (GemsConfig.GEODE_SEAL_BREAKS) {
                        for (EnumFacing facing : EnumFacing.values()) {
                            BlockPos offset = position.offset(facing);
                            IBlockState adjacent = worldIn.getBlockState(offset);
                            if (worldIn.isAirBlock(offset) || adjacent != shellBlock && adjacent.getBlock() != block) {
                                worldIn.setBlockState(offset, shellBlock);
                            }
                        }
                    }
                }
            }
        }
    }
// SilentGems.logHelper.debug(xmin, xmax, ymin, ymax, zmin, zmax, count);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) EnumGem(net.silentchaos512.gems.lib.EnumGem) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) Predicate(com.google.common.base.Predicate)

Example 13 with EnumGem

use of net.silentchaos512.gems.lib.EnumGem in project SilentGems by SilentChaos512.

the class ItemGem method addOreDict.

@Override
public void addOreDict() {
    for (EnumGem gem : EnumGem.values()) {
        OreDictionary.registerOre(gem.getItemOreName(), gem.getItem());
        OreDictionary.registerOre(gem.getItemSuperOreName(), gem.getItemSuper());
    }
}
Also used : EnumGem(net.silentchaos512.gems.lib.EnumGem)

Example 14 with EnumGem

use of net.silentchaos512.gems.lib.EnumGem in project SilentGems by SilentChaos512.

the class ItemGem method clAddInformation.

@Override
public void clAddInformation(ItemStack stack, World world, List list, boolean advanced) {
    EnumGem gem = EnumGem.getFromStack(stack);
    boolean controlDown = KeyTracker.isControlDown();
    if (controlDown && (gem == EnumGem.RUBY || gem == EnumGem.BERYL || gem == EnumGem.SAPPHIRE || gem == EnumGem.TOPAZ)) {
        list.add(SilentGems.localizationHelper.getItemSubText(itemName, "original4"));
    }
}
Also used : EnumGem(net.silentchaos512.gems.lib.EnumGem)

Example 15 with EnumGem

use of net.silentchaos512.gems.lib.EnumGem in project SilentGems by SilentChaos512.

the class ItemGem method addRecipes.

@Override
public void addRecipes(RecipeMaker recipes) {
    String centerItem = GemsConfigHC.HARD_SUPER_GEMS ? "gemEnderEssence" : "dustGlowstone";
    for (EnumGem gem : EnumGem.values()) {
        // Supercharged gems
        recipes.addShapedOre("gem_super_" + gem.name(), gem.getItemSuper(), "cgc", "cdc", "cgc", 'g', gem.getItem(), 'd', centerItem, 'c', "gemChaos");
        // Gems <--> shards
        recipes.addCompression("gem_" + gem.name(), gem.getShard(), gem.getItem(), 9);
        ItemStack shards = gem.getShard();
        StackHelper.setCount(shards, 9);
        recipes.addShapelessOre("gem_shard_" + gem.name() + "_oredict", shards, gem.getItemOreName());
    }
}
Also used : EnumGem(net.silentchaos512.gems.lib.EnumGem) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EnumGem (net.silentchaos512.gems.lib.EnumGem)27 ItemStack (net.minecraft.item.ItemStack)16 IBlockState (net.minecraft.block.state.IBlockState)4 BlockPos (net.minecraft.util.math.BlockPos)3 Random (java.util.Random)2 IArmor (net.silentchaos512.gems.api.IArmor)2 WeightedRandomItemSG (net.silentchaos512.gems.util.WeightedRandomItemSG)2 RecipeMaker (net.silentchaos512.lib.registry.RecipeMaker)2 Predicate (com.google.common.base.Predicate)1 Block (net.minecraft.block.Block)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 IItemColor (net.minecraft.client.renderer.color.IItemColor)1 ItemColors (net.minecraft.client.renderer.color.ItemColors)1 EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)1 Item (net.minecraft.item.Item)1 IRecipe (net.minecraft.item.crafting.IRecipe)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 EnumFacing (net.minecraft.util.EnumFacing)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 WeightedRandom (net.minecraft.util.WeightedRandom)1