Search in sources :

Example 6 with BlockMeta

use of mcjty.lib.varia.BlockMeta in project RFTools by McJty.

the class CmdDimletCfg method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 1) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    World world = sender.getEntityWorld();
    ItemStack heldItem = null;
    if (sender instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) sender;
        heldItem = player.getHeldItem();
    }
    if (heldItem == null || heldItem.getItem() != DimletSetup.knownDimlet) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You need to hold a known dimlet in your hand!"));
        return;
    }
    DimletKey key = KnownDimletConfiguration.getDimletKey(heldItem, world);
    DimletEntry entry = KnownDimletConfiguration.getEntry(key);
    if (entry != null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "In dimlets.cfg:"));
        sender.addChatMessage(new ChatComponentText("dimletsettings {"));
        DimletType type = key.getType();
        sender.addChatMessage(new ChatComponentText("    I:\"rarity." + type.dimletType.getName() + "." + key.getName() + "\"=" + entry.getRarity()));
        sender.addChatMessage(new ChatComponentText("    I:\"rfcreate." + type.dimletType.getName() + "." + key.getName() + "\"=" + entry.getRfCreateCost()));
        sender.addChatMessage(new ChatComponentText("    I:\"rfmaintain." + type.dimletType.getName() + "." + key.getName() + "\"=" + entry.getRfMaintainCost()));
        sender.addChatMessage(new ChatComponentText("    I:\"ticks." + type.dimletType.getName() + "." + key.getName() + "\"=" + entry.getTickCost()));
        if (entry.isRandomNotAllowed()) {
            sender.addChatMessage(new ChatComponentText("    B:\"expensive." + type.dimletType.getName() + "." + key.getName() + "\"=true"));
        }
        if (entry.isLootNotAllowed()) {
            sender.addChatMessage(new ChatComponentText("    B:\"noloot." + type.dimletType.getName() + "." + key.getName() + "\"=true"));
        }
        sender.addChatMessage(new ChatComponentText("}"));
        if (!entry.isRandomNotAllowed()) {
            if (type == DimletType.DIMLET_MATERIAL || type == DimletType.DIMLET_LIQUID) {
                sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "If you only want this for features (no terrain):"));
                sender.addChatMessage(new ChatComponentText("    B:\"expensive." + type.dimletType.getName() + "." + key.getName() + "\"=true"));
            } else {
                sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "If you don't want this dimlet to be generated random:"));
                sender.addChatMessage(new ChatComponentText("    B:\"expensive." + type.dimletType.getName() + "." + key.getName() + "\"=true"));
            }
        }
        if (!entry.isLootNotAllowed()) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "If you don't want this dimlet to be generated as loot:"));
            sender.addChatMessage(new ChatComponentText("    B:\"noloot." + type.dimletType.getName() + "." + key.getName() + "\"=true"));
        }
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "In dimlets.cfg, if you want to blacklist this dimlet:"));
        sender.addChatMessage(new ChatComponentText("knowndimlets {"));
        sender.addChatMessage(new ChatComponentText("    I:\"dimlet." + type.dimletType.getName() + "." + key.getName() + "\"=-1"));
        sender.addChatMessage(new ChatComponentText("}"));
        String modid = null;
        if (type == DimletType.DIMLET_MATERIAL) {
            BlockMeta blockMeta = DimletObjectMapping.idToBlock.get(key);
            if (blockMeta != null) {
                modid = RFToolsTools.getModidForBlock(blockMeta.getBlock());
            }
        } else if (type == DimletType.DIMLET_LIQUID) {
            Block block = DimletObjectMapping.idToFluid.get(key);
            if (block != null) {
                modid = RFToolsTools.getModidForBlock(block);
            }
        }
        if (modid != null && !"?".equals(modid)) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "In dimlets.cfg, if you want to blacklist the entire mod:"));
            sender.addChatMessage(new ChatComponentText("knowndimlets {"));
            sender.addChatMessage(new ChatComponentText("    B:\"modban." + type.dimletType.getName() + "." + modid + "\"=true"));
            sender.addChatMessage(new ChatComponentText("}"));
        }
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText) BlockMeta(mcjty.lib.varia.BlockMeta)

Example 7 with BlockMeta

use of mcjty.lib.varia.BlockMeta in project RFTools by McJty.

the class MapGenLiquidOrbs method generate.

public void generate(World world, int chunkX, int chunkZ, Block[] ablock, byte[] ameta) {
    BlockMeta[] blocks = large ? provider.dimensionInformation.getHugeLiquidSphereBlocks() : provider.dimensionInformation.getLiquidSphereBlocks();
    Block[] fluids = large ? provider.dimensionInformation.getHugeLiquidSphereFluids() : provider.dimensionInformation.getLiquidSphereFluids();
    for (int cx = -r; cx <= r; cx++) {
        for (int cz = -r; cz <= r; cz++) {
            Random random = new Random((world.getSeed() + (chunkX + cx)) * 37 + (chunkZ + cz) * 5 + 113);
            random.nextFloat();
            if (random.nextFloat() < .05f) {
                int x = cx * 16 + random.nextInt(16);
                int y = 40 + random.nextInt(40);
                int z = cz * 16 + random.nextInt(16);
                int radius = random.nextInt(large ? 20 : 6) + (large ? 10 : 4);
                BlockMeta block = BlockMeta.STONE;
                if (blocks.length > 1) {
                    block = blocks[random.nextInt(blocks.length)];
                } else if (blocks.length == 1) {
                    block = blocks[0];
                }
                Block fluid = Blocks.water;
                if (fluids.length > 1) {
                    fluid = fluids[random.nextInt(fluids.length)];
                } else if (fluids.length == 1) {
                    fluid = fluids[0];
                }
                fillSphere(ablock, ameta, x, y, z, radius, block, fluid);
            }
        }
    }
}
Also used : Random(java.util.Random) Block(net.minecraft.block.Block) BlockMeta(mcjty.lib.varia.BlockMeta)

Example 8 with BlockMeta

use of mcjty.lib.varia.BlockMeta in project RFTools by McJty.

the class MapGenPyramids method generate.

public void generate(World world, int chunkX, int chunkZ, Block[] ablock, byte[] ameta) {
    BlockMeta[] blocks = provider.dimensionInformation.getPyramidBlocks();
    Random random = new Random((world.getSeed() + (chunkX)) * 1133 + (chunkZ) * 37 + 77);
    random.nextFloat();
    if (random.nextFloat() < .05f) {
        int x = 8;
        int z = 8;
        int y = getBestY(ablock, 8, 8);
        if (y < 10 || y > 230) {
            return;
        }
        BlockMeta block = BlockMeta.STONE;
        if (blocks.length > 1) {
            block = blocks[random.nextInt(blocks.length)];
        } else if (blocks.length == 1) {
            block = blocks[0];
        }
        for (int i = 7; i >= 0; i--) {
            for (int dx = -i; dx <= i - 1; dx++) {
                for (int dz = -i; dz <= i - 1; dz++) {
                    int index = ((x + dx) * 16 + (z + dz)) * 256;
                    ablock[index + y] = block.getBlock();
                    ameta[index + y] = block.getMeta();
                }
            }
            y++;
        }
    }
}
Also used : Random(java.util.Random) BlockMeta(mcjty.lib.varia.BlockMeta)

Example 9 with BlockMeta

use of mcjty.lib.varia.BlockMeta in project RFTools by McJty.

the class MapGenTendrils method func_151541_a.

private void func_151541_a(long seed, int chunkX, int chunkZ, Block[] data, byte[] meta, double p_151541_6_, double p_151541_8_, double p_151541_10_, float p_151541_12_, float p_151541_13_, float p_151541_14_, int p_151541_15_, int p_151541_16_, double p_151541_17_) {
    BlockMeta baseBlock = provider.dimensionInformation.getTendrilBlock();
    double d4 = (chunkX * 16 + 8);
    double d5 = (chunkZ * 16 + 8);
    float f3 = 0.0F;
    float f4 = 0.0F;
    Random random = new Random(seed);
    if (p_151541_16_ <= 0) {
        int j1 = this.range * 16 - 16;
        p_151541_16_ = j1 - random.nextInt(j1 / 4);
    }
    boolean flag2 = false;
    if (p_151541_15_ == -1) {
        p_151541_15_ = p_151541_16_ / 2;
        flag2 = true;
    }
    int k1 = random.nextInt(p_151541_16_ / 2) + p_151541_16_ / 4;
    boolean flag = random.nextInt(6) == 0;
    while (p_151541_15_ < p_151541_16_) {
        double d6 = 1.5D + (MathHelper.sin(p_151541_15_ * (float) Math.PI / p_151541_16_) * p_151541_12_ * 1.0F);
        double d7 = d6 * p_151541_17_;
        float f5 = MathHelper.cos(p_151541_14_);
        float f6 = MathHelper.sin(p_151541_14_);
        p_151541_6_ += (MathHelper.cos(p_151541_13_) * f5);
        p_151541_8_ += f6;
        p_151541_10_ += (MathHelper.sin(p_151541_13_) * f5);
        if (flag) {
            p_151541_14_ *= 0.92F;
        } else {
            p_151541_14_ *= 0.7F;
        }
        p_151541_14_ += f4 * 0.1F;
        p_151541_13_ += f3 * 0.1F;
        f4 *= 0.9F;
        f3 *= 0.75F;
        f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F;
        f3 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0F;
        if (!flag2 && p_151541_15_ == k1 && p_151541_12_ > 1.0F && p_151541_16_ > 0) {
            this.func_151541_a(random.nextLong(), chunkX, chunkZ, data, meta, p_151541_6_, p_151541_8_, p_151541_10_, random.nextFloat() * 0.5F + 0.5F, p_151541_13_ - ((float) Math.PI / 2F), p_151541_14_ / 3.0F, p_151541_15_, p_151541_16_, 1.0D);
            this.func_151541_a(random.nextLong(), chunkX, chunkZ, data, meta, p_151541_6_, p_151541_8_, p_151541_10_, random.nextFloat() * 0.5F + 0.5F, p_151541_13_ + ((float) Math.PI / 2F), p_151541_14_ / 3.0F, p_151541_15_, p_151541_16_, 1.0D);
            return;
        }
        if (flag2 || random.nextInt(4) != 0) {
            double d8 = p_151541_6_ - d4;
            double d9 = p_151541_10_ - d5;
            double d10 = (p_151541_16_ - p_151541_15_);
            double d11 = (p_151541_12_ + 2.0F + 16.0F);
            if (d8 * d8 + d9 * d9 - d10 * d10 > d11 * d11) {
                return;
            }
            if (p_151541_6_ >= d4 - 16.0D - d6 * 2.0D && p_151541_10_ >= d5 - 16.0D - d6 * 2.0D && p_151541_6_ <= d4 + 16.0D + d6 * 2.0D && p_151541_10_ <= d5 + 16.0D + d6 * 2.0D) {
                int i4 = MathHelper.floor_double(p_151541_6_ - d6) - chunkX * 16 - 1;
                int l1 = MathHelper.floor_double(p_151541_6_ + d6) - chunkX * 16 + 1;
                int j4 = MathHelper.floor_double(p_151541_8_ - d7) - 1;
                int i2 = MathHelper.floor_double(p_151541_8_ + d7) + 1;
                int k4 = MathHelper.floor_double(p_151541_10_ - d6) - chunkZ * 16 - 1;
                int j2 = MathHelper.floor_double(p_151541_10_ + d6) - chunkZ * 16 + 1;
                if (i4 < 0) {
                    i4 = 0;
                }
                if (l1 > 16) {
                    l1 = 16;
                }
                if (j4 < 1) {
                    j4 = 1;
                }
                if (i2 > 248) {
                    i2 = 248;
                }
                if (k4 < 0) {
                    k4 = 0;
                }
                if (j2 > 16) {
                    j2 = 16;
                }
                int k2;
                int j3;
                for (k2 = i4; k2 < l1; ++k2) {
                    double d13 = ((k2 + chunkX * 16) + 0.5D - p_151541_6_) / d6;
                    for (j3 = k4; j3 < j2; ++j3) {
                        double d14 = ((j3 + chunkZ * 16) + 0.5D - p_151541_10_) / d6;
                        int k3 = (k2 * 16 + j3) * 256 + i2;
                        if (d13 * d13 + d14 * d14 < 1.0D) {
                            for (int l3 = i2 - 1; l3 >= j4; --l3) {
                                double d12 = (l3 + 0.5D - p_151541_8_) / d7;
                                if (d12 > -0.7D && d13 * d13 + d12 * d12 + d14 * d14 < 1.0D) {
                                    Block block = data[k3];
                                    if (block == Blocks.air || block == null) {
                                        data[k3] = baseBlock.getBlock();
                                        meta[k3] = baseBlock.getMeta();
                                    }
                                }
                                --k3;
                            }
                        }
                    }
                    if (flag2) {
                        break;
                    }
                }
            }
        }
        ++p_151541_15_;
    }
}
Also used : Random(java.util.Random) Block(net.minecraft.block.Block) BlockMeta(mcjty.lib.varia.BlockMeta)

Example 10 with BlockMeta

use of mcjty.lib.varia.BlockMeta in project RFTools by McJty.

the class FeatureDimletType method getRandomBlockArray.

private BlockMeta[] getRandomBlockArray(Random random, Set<FeatureType> featureTypes, Map<FeatureType, List<DimletKey>> modifiersForFeature, FeatureType t, boolean allowEmpty) {
    BlockMeta[] blockArray;
    if (featureTypes.contains(t)) {
        List<BlockMeta> blocks = new ArrayList<BlockMeta>();
        List<Block> fluids = new ArrayList<Block>();
        DimensionInformation.getMaterialAndFluidModifiers(modifiersForFeature.get(t), blocks, fluids);
        // If no blocks are specified we will generate a few random ores.
        if (blocks.isEmpty()) {
            float chance = 1.1f;
            while (random.nextFloat() < chance) {
                DimletKey key = DimletRandomizer.getRandomMaterialBlock(random, true);
                BlockMeta bm = DimletObjectMapping.idToBlock.get(key);
                if (bm != null) {
                    blocks.add(bm);
                    chance = chance * 0.80f;
                }
            }
        }
        blockArray = blocks.toArray(new BlockMeta[blocks.size()]);
        for (int i = 0; i < blockArray.length; i++) {
            if (blockArray[i] == null) {
                blockArray[i] = BlockMeta.STONE;
            }
        }
    } else {
        blockArray = new BlockMeta[0];
    }
    if (allowEmpty || blockArray.length > 0) {
        return blockArray;
    }
    return new BlockMeta[] { BlockMeta.STONE };
}
Also used : Block(net.minecraft.block.Block) DimletKey(mcjty.rftools.items.dimlets.DimletKey) BlockMeta(mcjty.lib.varia.BlockMeta)

Aggregations

BlockMeta (mcjty.lib.varia.BlockMeta)31 Block (net.minecraft.block.Block)18 ItemStack (net.minecraft.item.ItemStack)6 Random (java.util.Random)5 DimletKey (mcjty.rftools.items.dimlets.DimletKey)3 World (net.minecraft.world.World)3 BiomeGenBase (net.minecraft.world.biome.BiomeGenBase)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Entity (net.minecraft.entity.Entity)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 TileEntity (net.minecraft.tileentity.TileEntity)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)1 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)1 Label (mcjty.lib.gui.widgets.Label)1 Panel (mcjty.lib.gui.widgets.Panel)1 Coordinate (mcjty.lib.varia.Coordinate)1