use of net.minecraft.util.math.Vec3i in project ForestryMC by ForestryMC.
the class AlleleEffectFungification method doBlockEffect.
private void doBlockEffect(IBeeGenome genome, IBeeHousing housing) {
World world = housing.getWorldObj();
BlockPos housingCoordinates = housing.getCoordinates();
Vec3i area = getModifiedArea(genome, housing);
Vec3i halfArea = new Vec3i(area.getX() / 2, area.getY() / 2, area.getZ() / 2);
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
BlockPos pos = VectUtil.getRandomPositionInArea(world.rand, area).subtract(halfArea).add(housingCoordinates);
if (world.isBlockLoaded(pos)) {
IBlockState blockState = world.getBlockState(pos);
if (convertToMycelium(world, blockState, pos)) {
return;
} else if (growGiantMushroom(world, blockState, pos)) {
return;
}
}
}
}
use of net.minecraft.util.math.Vec3i in project ForestryMC by ForestryMC.
the class AlleleEffectRadioactive method destroyEnvironment.
private static IEffectData destroyEnvironment(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
World world = housing.getWorldObj();
Random rand = world.rand;
Vec3i area = VectUtil.scale(genome.getTerritory(), 2);
Vec3i offset = VectUtil.scale(area, -1 / 2.0f);
BlockPos posHousing = housing.getCoordinates();
for (int i = 0; i < 20; i++) {
BlockPos randomPos = VectUtil.getRandomPositionInArea(rand, area);
BlockPos posBlock = randomPos.add(posHousing);
posBlock = posBlock.add(offset);
if (posBlock.getY() <= 1 || posBlock.getY() >= world.getActualHeight()) {
continue;
}
// Don't destroy ourselves or blocks below us.
if (posBlock.getX() == posHousing.getX() && posBlock.getZ() == posHousing.getZ() && posBlock.getY() <= posHousing.getY()) {
continue;
}
if (!world.isBlockLoaded(posBlock) || world.isAirBlock(posBlock)) {
continue;
}
IBlockState blockState = world.getBlockState(posBlock);
Block block = blockState.getBlock();
if (block instanceof BlockAlveary) {
continue;
}
TileEntity tile = TileUtil.getTile(world, posBlock);
if (tile instanceof IBeeHousing) {
continue;
}
if (blockState.getBlockHardness(world, posBlock) < 0) {
continue;
}
BlockUtil.setBlockToAirWithSound(world, posBlock, blockState);
break;
}
return storedData;
}
use of net.minecraft.util.math.Vec3i in project ForestryMC by ForestryMC.
the class AlleleEffectSnowing method doEffectThrottled.
@Override
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
World world = housing.getWorldObj();
EnumTemperature temp = housing.getTemperature();
switch(temp) {
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
}
Vec3i area = getModifiedArea(genome, housing);
Vec3i offset = VectUtil.scale(area, -1 / 2.0f);
for (int i = 0; i < 1; i++) {
BlockPos randomPos = VectUtil.getRandomPositionInArea(world.rand, area);
BlockPos posBlock = randomPos.add(housing.getCoordinates()).add(offset);
// Put snow on the ground
if (world.isBlockLoaded(posBlock) && world.isSideSolid(posBlock.down(), EnumFacing.UP, false)) {
IBlockState state = world.getBlockState(posBlock);
Block block = state.getBlock();
if (block == Blocks.SNOW_LAYER) {
Integer layers = state.getValue(BlockSnow.LAYERS);
if (layers < 7) {
IBlockState moreSnow = state.withProperty(BlockSnow.LAYERS, layers + 1);
world.setBlockState(posBlock, moreSnow);
} else {
world.setBlockState(posBlock, Blocks.SNOW.getDefaultState());
}
} else if (block.isReplaceable(world, posBlock)) {
world.setBlockState(posBlock, Blocks.SNOW_LAYER.getDefaultState());
}
}
}
return storedData;
}
use of net.minecraft.util.math.Vec3i in project ForestryMC by ForestryMC.
the class AlleleEffectSnowing method doFX.
@Override
@SideOnly(Side.CLIENT)
public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (housing.getWorldObj().rand.nextInt(3) == 0) {
Vec3i area = getModifiedArea(genome, housing);
Vec3i offset = VectUtil.scale(area, -0.5F);
BlockPos coordinates = housing.getCoordinates();
World world = housing.getWorldObj();
BlockPos spawn = VectUtil.getRandomPositionInArea(world.rand, area).add(coordinates).add(offset);
ParticleRender.addEntitySnowFX(world, spawn.getX(), spawn.getY(), spawn.getZ());
return storedData;
} else {
return super.doFX(genome, storedData, housing);
}
}
use of net.minecraft.util.math.Vec3i in project ForestryMC by ForestryMC.
the class TilePlanter method getArea.
@Override
public Vec3i getArea() {
if (area == null) {
int basisArea = 5;
if (Config.ringFarms) {
basisArea = basisArea + 1 + Config.ringSize * 2;
}
area = new Vec3i(basisArea + Config.planterExtend, 13, basisArea + Config.planterExtend);
}
return area;
}
Aggregations