Search in sources :

Example 26 with BlockMeta

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

the class MapGenRuinedCities method createBuilding.

private void createBuilding(Block[] ablock, byte[] ameta, Span span) {
    createBlockMap();
    int idx = 0;
    for (int y = span.low - 1; y <= span.high; y++) {
        if (idx >= LEVEL.length) {
            return;
        }
        String[] level = LEVEL[idx++];
        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                int index = (x * 16 + z) * 256 + y;
                char c = level[z].charAt(x);
                BlockMeta blockMeta = blockMap.get(c);
                if (blockMeta != null) {
                    ablock[index] = blockMeta.getBlock();
                    ameta[index] = blockMeta.getMeta();
                }
            }
        }
    }
}
Also used : BlockMeta(mcjty.lib.varia.BlockMeta)

Example 27 with BlockMeta

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

the class KnownDimletConfiguration method initMaterialItem.

private static int initMaterialItem(Configuration cfg, Block block, int meta, DimletMapping mapping, boolean master, DimletEntry override) {
    DimletKey key = getMaterialDimletKey(block, meta);
    if (key == null) {
        return -1;
    }
    String modid = RFToolsTools.getModidForBlock(block);
    ItemStack stack = new ItemStack(block, 1, meta);
    if (stack.getItem() == null) {
        return -1;
    }
    int id = registerDimlet(cfg, key, mapping, master, modid, override);
    if (id != -1) {
        idToDisplayName.put(key, DimletType.DIMLET_MATERIAL.dimletType.getName() + " " + stack.getDisplayName() + " Dimlet");
        DimletObjectMapping.idToBlock.put(key, new BlockMeta(block, (byte) meta));
    }
    return id;
}
Also used : ItemStack(net.minecraft.item.ItemStack) BlockMeta(mcjty.lib.varia.BlockMeta)

Example 28 with BlockMeta

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

the class TerrainDimletType method constructDimension.

@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
    dimlets = DimensionInformation.extractType(DimletType.DIMLET_TERRAIN, dimlets);
    List<DimletKey> modifiers;
    TerrainType terrainType = TerrainType.TERRAIN_VOID;
    if (dimlets.isEmpty()) {
        // Pick a random terrain type with a seed that is generated from all the
        // dimlets so we always get the same random value for these dimlets.
        List<DimletKey> idList = new ArrayList<DimletKey>(DimletObjectMapping.idToTerrainType.keySet());
        DimletKey key = idList.get(random.nextInt(idList.size()));
        dimensionInformation.updateCostFactor(key);
        terrainType = DimletObjectMapping.idToTerrainType.get(key);
        modifiers = Collections.emptyList();
    } else {
        int index = random.nextInt(dimlets.size());
        DimletKey key = dimlets.get(index).getLeft();
        terrainType = DimletObjectMapping.idToTerrainType.get(key);
        modifiers = dimlets.get(index).getRight();
    }
    List<BlockMeta> blocks = new ArrayList<BlockMeta>();
    List<Block> fluids = new ArrayList<Block>();
    DimensionInformation.getMaterialAndFluidModifiers(modifiers, blocks, fluids);
    dimensionInformation.setTerrainType(terrainType);
    BlockMeta baseBlockForTerrain;
    if (dimensionInformation.isPatreonBitSet(Patreons.PATREON_LAYEREDMETA)) {
        baseBlockForTerrain = new BlockMeta(Blocks.wool, 127);
    } else {
        if (!blocks.isEmpty()) {
            baseBlockForTerrain = blocks.get(random.nextInt(blocks.size()));
            if (baseBlockForTerrain == null) {
                // This is the default in case None was specified.
                baseBlockForTerrain = BlockMeta.STONE;
            }
        } else {
            // If the terrain type is void we always pick stone as a random material.
            if (terrainType == TerrainType.TERRAIN_VOID) {
                baseBlockForTerrain = BlockMeta.STONE;
            } else if (random.nextFloat() < DimletConfiguration.randomBaseBlockChance) {
                DimletKey key = DimletRandomizer.getRandomMaterialBlock(random, false);
                dimensionInformation.updateCostFactor(key);
                baseBlockForTerrain = DimletObjectMapping.idToBlock.get(key);
            } else {
                baseBlockForTerrain = BlockMeta.STONE;
            }
        }
    }
    dimensionInformation.setBaseBlockForTerrain(baseBlockForTerrain);
    Block fluidForTerrain;
    if (!fluids.isEmpty()) {
        fluidForTerrain = fluids.get(random.nextInt(fluids.size()));
        if (fluidForTerrain == null) {
            // This is the default.
            fluidForTerrain = Blocks.water;
        }
    } else {
        // If the terrain type is void we always pick water as the random liquid.
        if (terrainType == TerrainType.TERRAIN_VOID) {
            fluidForTerrain = Blocks.water;
        } else if (random.nextFloat() < DimletConfiguration.randomOceanLiquidChance) {
            DimletKey key = DimletRandomizer.getRandomFluidBlock(random, false);
            dimensionInformation.updateCostFactor(key);
            fluidForTerrain = DimletObjectMapping.idToFluid.get(key);
        } else {
            fluidForTerrain = Blocks.water;
        }
    }
    dimensionInformation.setFluidForTerrain(fluidForTerrain);
}
Also used : ArrayList(java.util.ArrayList) Block(net.minecraft.block.Block) DimletKey(mcjty.rftools.items.dimlets.DimletKey) TerrainType(mcjty.rftools.dimension.world.types.TerrainType) BlockMeta(mcjty.lib.varia.BlockMeta)

Example 29 with BlockMeta

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

the class MapGenCanyons method func_151540_a.

private void func_151540_a(long seed, int p_151540_3_, int p_151540_4_, Block[] data, byte[] meta, double p_151540_6_, double p_151540_8_, double p_151540_10_, float p_151540_12_, float p_151540_13_, float p_151540_14_, int p_151540_15_, int p_151540_16_, double p_151540_17_) {
    BlockMeta baseBlock = provider.dimensionInformation.getCanyonBlock();
    Random random = new Random(seed);
    double d4 = (p_151540_3_ * 16 + 8);
    double d5 = (p_151540_4_ * 16 + 8);
    float f3 = 0.0F;
    float f4 = 0.0F;
    if (p_151540_16_ <= 0) {
        int j1 = this.range * 16 - 16;
        p_151540_16_ = j1 - random.nextInt(j1 / 4);
    }
    boolean flag1 = false;
    if (p_151540_15_ == -1) {
        p_151540_15_ = p_151540_16_ / 2;
        flag1 = true;
    }
    float f5 = 1.0F;
    for (int k1 = 0; k1 < 256; ++k1) {
        if (k1 == 0 || random.nextInt(3) == 0) {
            f5 = 1.0F + random.nextFloat() * random.nextFloat() * 1.0F;
        }
        this.field_75046_d[k1] = f5 * f5;
    }
    for (; p_151540_15_ < p_151540_16_; ++p_151540_15_) {
        double d12 = 1.5D + (MathHelper.sin(p_151540_15_ * (float) Math.PI / p_151540_16_) * p_151540_12_ * 1.0F);
        double d6 = d12 * p_151540_17_;
        d12 *= random.nextFloat() * 0.25D + 0.75D;
        d6 *= random.nextFloat() * 0.25D + 0.75D;
        float f6 = MathHelper.cos(p_151540_14_);
        float f7 = MathHelper.sin(p_151540_14_);
        p_151540_6_ += (MathHelper.cos(p_151540_13_) * f6);
        p_151540_8_ += f7;
        p_151540_10_ += (MathHelper.sin(p_151540_13_) * f6);
        p_151540_14_ *= 0.7F;
        p_151540_14_ += f4 * 0.05F;
        p_151540_13_ += f3 * 0.05F;
        f4 *= 0.8F;
        f3 *= 0.5F;
        f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F;
        f3 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0F;
        if (flag1 || random.nextInt(4) != 0) {
            double d7 = p_151540_6_ - d4;
            double d8 = p_151540_10_ - d5;
            double d9 = (p_151540_16_ - p_151540_15_);
            double d10 = (p_151540_12_ + 2.0F + 16.0F);
            if (d7 * d7 + d8 * d8 - d9 * d9 > d10 * d10) {
                return;
            }
            if (p_151540_6_ >= d4 - 16.0D - d12 * 2.0D && p_151540_10_ >= d5 - 16.0D - d12 * 2.0D && p_151540_6_ <= d4 + 16.0D + d12 * 2.0D && p_151540_10_ <= d5 + 16.0D + d12 * 2.0D) {
                int i4 = MathHelper.floor_double(p_151540_6_ - d12) - p_151540_3_ * 16 - 1;
                int l1 = MathHelper.floor_double(p_151540_6_ + d12) - p_151540_3_ * 16 + 1;
                int j4 = MathHelper.floor_double(p_151540_8_ - d6) - 1;
                int i2 = MathHelper.floor_double(p_151540_8_ + d6) + 1;
                int k4 = MathHelper.floor_double(p_151540_10_ - d12) - p_151540_4_ * 16 - 1;
                int j2 = MathHelper.floor_double(p_151540_10_ + d12) - p_151540_4_ * 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 + p_151540_3_ * 16) + 0.5D - p_151540_6_) / d12;
                    for (j3 = k4; j3 < j2; ++j3) {
                        double d14 = ((j3 + p_151540_4_ * 16) + 0.5D - p_151540_10_) / d12;
                        int k3 = (k2 * 16 + j3) * 256 + i2;
                        if (d13 * d13 + d14 * d14 < 1.0D) {
                            for (int l3 = i2 - 1; l3 >= j4; --l3) {
                                double d11 = (l3 + 0.5D - p_151540_8_) / d6;
                                if ((d13 * d13 + d14 * d14) * this.field_75046_d[l3] + d11 * d11 / 6.0D < 1.0D) {
                                    Block block = data[k3];
                                    if (block == Blocks.air || block == null) {
                                        data[k3] = baseBlock.getBlock();
                                        meta[k3] = baseBlock.getMeta();
                                    }
                                }
                                --k3;
                            }
                        }
                    }
                }
                if (flag1) {
                    break;
                }
            }
        }
    }
}
Also used : Random(java.util.Random) Block(net.minecraft.block.Block) BlockMeta(mcjty.lib.varia.BlockMeta)

Example 30 with BlockMeta

use of mcjty.lib.varia.BlockMeta in project RFTools 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.
    BlockMeta oldLiquidSphereBlock = getBlockMeta(tagCompound, "liquidSphereBlock");
    liquidSphereBlocks = readBlockArrayFromNBT(tagCompound, "liquidSphereBlocks");
    if (liquidSphereBlocks.length == 0) {
        liquidSphereBlocks = new BlockMeta[] { oldLiquidSphereBlock };
    }
    pyramidBlocks = readBlockArrayFromNBT(tagCompound, "pyramidBlocks");
    if (pyramidBlocks.length == 0) {
        pyramidBlocks = new BlockMeta[] { BlockMeta.STONE };
    }
    // Support for the old format with only one sphere block.
    BlockMeta oldSphereBlock = getBlockMeta(tagCompound, "sphereBlock");
    sphereBlocks = readBlockArrayFromNBT(tagCompound, "sphereBlocks");
    if (sphereBlocks.length == 0) {
        sphereBlocks = new BlockMeta[] { 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(null, 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 : BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) Block(net.minecraft.block.Block) 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