Search in sources :

Example 16 with BlockMeta

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

the class DimensionInformation method readBlockArrayFromBuf.

private static BlockMeta[] readBlockArrayFromBuf(ByteBuf buf) {
    int size = buf.readInt();
    List<BlockMeta> blocksMeta = new ArrayList<BlockMeta>();
    for (int i = 0; i < size; i++) {
        Block b = (Block) Block.blockRegistry.getObjectById(buf.readInt());
        int m = buf.readInt();
        blocksMeta.add(new BlockMeta(b, m));
    }
    return blocksMeta.toArray(new BlockMeta[blocksMeta.size()]);
}
Also used : Block(net.minecraft.block.Block) BlockMeta(mcjty.lib.varia.BlockMeta)

Example 17 with BlockMeta

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

the class DimensionInformation method writeBlocksToNBT.

private static void writeBlocksToNBT(NBTTagCompound tagCompound, BlockMeta[] blocks, String name) {
    List<Integer> ids = new ArrayList<Integer>(blocks.length);
    List<Integer> meta = new ArrayList<Integer>(blocks.length);
    for (BlockMeta t : blocks) {
        ids.add(Block.blockRegistry.getIDForObject(t.getBlock()));
        meta.add((int) t.getMeta());
    }
    tagCompound.setIntArray(name, ArrayUtils.toPrimitive(ids.toArray(new Integer[ids.size()])));
    tagCompound.setIntArray(name + "_meta", ArrayUtils.toPrimitive(meta.toArray(new Integer[meta.size()])));
}
Also used : BlockMeta(mcjty.lib.varia.BlockMeta)

Example 18 with BlockMeta

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

the class MapGenDenseCaves method digBlock.

/**
 * Digs out the current block, default implementation removes stone, filler, and top block
 * Sets the block to lava if y is less then 10, and air other wise.
 * If setting to air, it also checks to see if we've broken the surface and if so
 * tries to make the floor the biome's top block
 *
 * @param data     Block data array
 * @param index    Pre-calculated index into block data
 * @param x        local X position
 * @param y        local Y position
 * @param z        local Z position
 * @param chunkX   Chunk X position
 * @param chunkZ   Chunk Y position
 * @param foundTop True if we've encountered the biome's top block. Ideally if we've broken the surface.
 */
protected void digBlock(Block[] data, int index, int x, int y, int z, int chunkX, int chunkZ, boolean foundTop) {
    BiomeGenBase biome = worldObj.getBiomeGenForCoords(x + chunkX * 16, z + chunkZ * 16);
    Block top = (isExceptionBiome(biome) ? Blocks.grass : biome.topBlock);
    Block filler = (isExceptionBiome(biome) ? Blocks.dirt : biome.fillerBlock);
    Block block = data[index];
    BlockMeta baseBlock = provider.dimensionInformation.getBaseBlockForTerrain();
    if (block == baseBlock.getBlock() || block == filler || block == top) {
        if (y < 10) {
            data[index] = Blocks.lava;
        } else {
            data[index] = null;
            if (foundTop && data[index - 1] == filler) {
                data[index - 1] = top;
            }
        }
    }
}
Also used : Block(net.minecraft.block.Block) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) BlockMeta(mcjty.lib.varia.BlockMeta)

Example 19 with BlockMeta

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

the class MapGenRuinedCities method createBlockMap.

private void createBlockMap() {
    if (blockMap != null) {
        return;
    }
    blockMap = new HashMap<Character, BlockMeta>();
    blockMap.put(' ', null);
    blockMap.put('B', new BlockMeta(DimletSetup.dimensionalBlock, 0));
    blockMap.put('b', new BlockMeta(DimletSetup.dimensionalBlankBlock, 0));
    blockMap.put('p', new BlockMeta(DimletSetup.dimensionalCrossBlock, 2));
    blockMap.put('P', new BlockMeta(DimletSetup.dimensionalCrossBlock, 0));
    blockMap.put('X', new BlockMeta(DimletSetup.dimensionalPattern1Block, 0));
    blockMap.put('x', new BlockMeta(DimletSetup.dimensionalPattern2Block, 0));
    blockMap.put('g', new BlockMeta(Blocks.stained_glass, 11));
}
Also used : BlockMeta(mcjty.lib.varia.BlockMeta)

Example 20 with BlockMeta

use of mcjty.lib.varia.BlockMeta in project RFToolsDimensions 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)

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