use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.
the class GenericWorldGenerator method addOreSpawn.
public void addOreSpawn(IBlockState block, IBlockState targetBlock, World world, Random random, int blockXPos, int blockZPos, int minVeinSize, int maxVeinSize, int chancesToSpawn, int minY, int maxY) {
WorldGenMinable minable = new WorldGenMinable(block, (minVeinSize - random.nextInt(maxVeinSize - minVeinSize)), p -> p == targetBlock);
for (int i = 0; i < chancesToSpawn; i++) {
int posX = blockXPos + random.nextInt(16);
int posY = minY + random.nextInt(maxY - minY);
int posZ = blockZPos + random.nextInt(16);
minable.generate(world, random, new BlockPos(posX, posY, posZ));
}
}
use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.
the class GenericWorldGenerator method generateLootSpawners.
private void generateLootSpawners(Random random, int chunkX, int chunkZ, World world) {
BuildingInfo info = new BuildingInfo(chunkX, chunkZ, world.getSeed());
int buildingtop = 0;
boolean building = info.hasBuilding;
if (building) {
buildingtop = 69 + info.floors * 6;
}
int height = 63 - info.floorsBelowGround * 6;
while (height < buildingtop) {
int f = LostCitiesTerrainGenerator.getFloor(height);
if (f == 0) {
BlockPos floorpos = new BlockPos(chunkX * 16, height, chunkZ * 16);
int floortype = info.floorTypes[LostCitiesTerrainGenerator.getLevel(height) + info.floorsBelowGround];
GenInfo getInfo = LostCitiesTerrainGenerator.getGenInfos().get(Pair.of(info.getGenInfoIndex(), floortype));
for (BlockPos p : getInfo.getChest()) {
BlockPos pos = floorpos.add(p);
if (!world.isAirBlock(pos)) {
createLootChest(random, world, pos);
}
}
for (BlockPos p : getInfo.getRandomFeatures()) {
BlockPos pos = floorpos.add(p);
if (!world.isAirBlock(pos)) {
createRandomFeature(random, world, pos);
}
}
for (BlockPos p : getInfo.getModularStorages()) {
BlockPos pos = floorpos.add(p);
if (!world.isAirBlock(pos)) {
createModularStorage(random, world, pos);
}
}
for (BlockPos p : getInfo.getRandomRFToolsMachines()) {
BlockPos pos = floorpos.add(p);
if (!world.isAirBlock(pos)) {
createRFToolsMachine(random, world, pos);
}
}
for (Map.Entry<BlockPos, Integer> entry : getInfo.getSpawnerType().entrySet()) {
BlockPos pos = floorpos.add(entry.getKey());
if (!world.isAirBlock(pos)) {
world.setBlockState(pos, Blocks.MOB_SPAWNER.getDefaultState());
TileEntity tileentity = world.getTileEntity(pos);
if (tileentity instanceof TileEntityMobSpawner) {
TileEntityMobSpawner spawner = (TileEntityMobSpawner) tileentity;
switch(entry.getValue()) {
case 1:
EntityTools.setSpawnerEntity(world, spawner, new ResourceLocation("minecraft:zombie"), "Zombie");
break;
case 2:
EntityTools.setSpawnerEntity(world, spawner, new ResourceLocation("minecraft:skeleton"), "Skeleton");
break;
case 3:
EntityTools.setSpawnerEntity(world, spawner, new ResourceLocation("minecraft:spider"), "Spider");
break;
case 4:
EntityTools.setSpawnerEntity(world, spawner, new ResourceLocation("minecraft:blaze"), "Blaze");
break;
}
}
}
}
}
height++;
}
}
use of net.minecraft.util.math.BlockPos in project ImmersiveEngineering by BluSunrize.
the class TileEntityDieselGenerator method update.
@Override
public void update() {
super.update();
if (isDummy())
return;
if (active || animation_fanFadeIn > 0 || animation_fanFadeOut > 0) {
float base = 18f;
float step = active ? base : 0;
if (animation_fanFadeIn > 0) {
step -= (animation_fanFadeIn / 80f) * base;
animation_fanFadeIn--;
}
if (animation_fanFadeOut > 0) {
step += (animation_fanFadeOut / 80f) * base;
animation_fanFadeOut--;
}
animation_fanRotationStep = step;
animation_fanRotation += step;
animation_fanRotation %= 360;
}
if (worldObj.isRemote) {
ImmersiveEngineering.proxy.handleTileSound(IESounds.dieselGenerator, this, active, .5f, 1);
if (active && worldObj.getTotalWorldTime() % 4 == 0) {
BlockPos exhaust = this.getBlockPosForPos(38);
EnumFacing fl = facing;
EnumFacing fw = facing.rotateY();
if (mirrored)
fw = fw.getOpposite();
worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, exhaust.getX() + .5 + (fl.getFrontOffsetX() * .3125f) + (-fw.getFrontOffsetX() * .3125f), exhaust.getY() + 1.25, exhaust.getZ() + .5 + (fl.getFrontOffsetZ() * .3125f) + (-fw.getFrontOffsetZ() * .3125f), 0, 0, 0);
}
} else {
boolean prevActive = active;
if (!isRSDisabled() && tanks[0].getFluid() != null && tanks[0].getFluid().getFluid() != null) {
int burnTime = DieselHandler.getBurnTime(tanks[0].getFluid().getFluid());
if (burnTime > 0) {
int fluidConsumed = 1000 / burnTime;
int output = IEConfig.Machines.dieselGen_output;
int connected = 0;
TileEntity[] receivers = new TileEntity[3];
for (int i = 0; i < 3; i++) {
receivers[i] = getEnergyOutput(i == 1 ? -1 : i == 2 ? 1 : 0);
if (receivers[i] != null) {
if (EnergyHelper.insertFlux(receivers[i], EnumFacing.DOWN, 4096, true) > 0)
connected++;
}
}
if (connected > 0 && tanks[0].getFluidAmount() >= fluidConsumed) {
if (!active) {
active = true;
animation_fanFadeIn = 80;
}
tanks[0].drain(fluidConsumed, true);
int splitOutput = output / connected;
int leftover = output % connected;
for (int i = 0; i < 3; i++) if (receivers[i] != null)
EnergyHelper.insertFlux(receivers[i], EnumFacing.DOWN, splitOutput + (leftover-- > 0 ? 1 : 0), false);
} else if (active) {
active = false;
animation_fanFadeOut = 80;
}
}
} else if (active) {
active = false;
animation_fanFadeOut = 80;
}
if (prevActive != active) {
this.markDirty();
this.markContainingBlockForUpdate(null);
}
}
}
use of net.minecraft.util.math.BlockPos in project ImmersiveEngineering by BluSunrize.
the class TileEntityAssembler method doProcessOutput.
@Override
public void doProcessOutput(ItemStack output) {
BlockPos pos = getPos().offset(facing, -1);
TileEntity inventoryTile = this.worldObj.getTileEntity(pos);
if (inventoryTile != null)
output = Utils.insertStackIntoInventory(inventoryTile, output, facing.getOpposite());
if (output != null)
Utils.dropStackAtPos(worldObj, pos, output, facing);
}
use of net.minecraft.util.math.BlockPos in project ImmersiveEngineering by BluSunrize.
the class TileEntityExcavator method disassemble.
@Override
public void disassemble() {
super.disassemble();
BlockPos wheelPos = this.getBlockPosForPos(31);
TileEntity center = worldObj.getTileEntity(wheelPos);
if (center instanceof TileEntityBucketWheel)
worldObj.addBlockEvent(center.getPos(), center.getBlockType(), 0, 0);
}
Aggregations