use of mcjty.lib.varia.BlockMeta in project RFTools by McJty.
the class FeatureDimletType method getRandomFluidArray.
private Block[] getRandomFluidArray(Random random, DimensionInformation dimensionInformation, Set<FeatureType> featureTypes, Map<FeatureType, List<DimletKey>> modifiersForFeature, FeatureType t, boolean allowEmpty) {
Block[] fluidsForLakes;
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 fluids are specified we will usually have default fluid generation (water+lava). Otherwise some random selection.
if (fluids.isEmpty()) {
while (random.nextFloat() < DimletConfiguration.randomLakeFluidChance) {
DimletKey key = DimletRandomizer.getRandomFluidBlock(random, true);
dimensionInformation.updateCostFactor(key);
fluids.add(DimletObjectMapping.idToFluid.get(key));
}
} else if (fluids.size() == 1 && fluids.get(0) == null) {
fluids.clear();
}
fluidsForLakes = fluids.toArray(new Block[fluids.size()]);
for (int i = 0; i < fluidsForLakes.length; i++) {
if (fluidsForLakes[i] == null) {
fluidsForLakes[i] = Blocks.water;
}
}
} else {
fluidsForLakes = new Block[0];
}
if (allowEmpty || fluidsForLakes.length > 0) {
return fluidsForLakes;
}
return new Block[] { Blocks.water };
}
use of mcjty.lib.varia.BlockMeta in project RFTools by McJty.
the class PacketChamberInfoReady method toBytes.
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(blocks.size());
for (Map.Entry<BlockMeta, Integer> entry : blocks.entrySet()) {
Block block = entry.getKey().getBlock();
buf.writeInt(Block.blockRegistry.getIDForObject(block));
buf.writeByte(entry.getKey().getMeta());
buf.writeInt(entry.getValue());
buf.writeInt(costs.get(entry.getKey()));
}
buf.writeInt(entities.size());
for (Map.Entry<String, Integer> entry : entities.entrySet()) {
NetworkTools.writeString(buf, entry.getKey());
buf.writeInt(entry.getValue());
buf.writeInt(entityCosts.get(entry.getKey()));
}
}
use of mcjty.lib.varia.BlockMeta in project RFTools by McJty.
the class BuilderTileEntity method buildBlock.
private boolean buildBlock(int rfNeeded, int sx, int sy, int sz) {
if (isEmptyOrReplacable(worldObj, sx, sy, sz)) {
BlockMeta block = consumeBlock(null, 0);
if (block == null) {
// We could not find a block. Wait
return true;
}
worldObj.setBlock(sx, sy, sz, block.getBlock(), block.getMeta(), 3);
worldObj.setBlockMetadataWithNotify(sx, sy, sz, block.getMeta(), 3);
if (!silent) {
RFToolsTools.playSound(worldObj, block.getBlock().stepSound.getBreakSound(), sx, sy, sz, 1.0f, 1.0f);
}
consumeEnergy(rfNeeded);
}
return false;
}
use of mcjty.lib.varia.BlockMeta in project RFTools by McJty.
the class BuilderTileEntity method findAndConsumeBlock.
// Also works if block is null and just picks the first available block.
private BlockMeta findAndConsumeBlock(IInventory inventory, Block block, int meta) {
if (block == null) {
// We are not looking for a specific block. Pick a random one out of the chest.
List<Integer> slots = new ArrayList<Integer>();
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack != null && stack.stackSize > 0 && stack.getItem() instanceof ItemBlock) {
slots.add(i);
}
}
if (slots.size() == 0) {
return null;
}
int randomSlot = slots.get(random.nextInt(slots.size()));
ItemStack stack = inventory.getStackInSlot(randomSlot);
ItemBlock itemBlock = (ItemBlock) stack.getItem();
inventory.decrStackSize(randomSlot, 1);
return new BlockMeta(itemBlock.field_150939_a, stack.getItemDamage());
} else {
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack != null && stack.stackSize > 0 && stack.getItem() instanceof ItemBlock) {
ItemBlock itemBlock = (ItemBlock) stack.getItem();
if (itemBlock.field_150939_a == block && (meta == -1 || stack.getItemDamage() == meta)) {
inventory.decrStackSize(i, 1);
return new BlockMeta(itemBlock.field_150939_a, stack.getItemDamage());
}
}
}
}
return null;
}
use of mcjty.lib.varia.BlockMeta in project RFTools by McJty.
the class MapGenOrbs method generate.
public void generate(World world, int chunkX, int chunkZ, Block[] ablock, byte[] ameta) {
BlockMeta[] blocks = large ? provider.dimensionInformation.getHugeSphereBlocks() : provider.dimensionInformation.getSphereBlocks();
for (int cx = -r; cx <= r; cx++) {
for (int cz = -r; cz <= r; cz++) {
Random random = new Random((world.getSeed() + (chunkX + cx)) * 113 + (chunkZ + cz) * 31 + 77);
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];
}
fillSphere(ablock, ameta, x, y, z, radius, block);
}
}
}
}
Aggregations