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()]);
}
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()])));
}
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;
}
}
}
}
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));
}
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();
}
}
}
}
}
Aggregations