use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class TileEntityScreen method joinUp.
private void joinUp() {
int meta = this.getBlockMetadata();
// EnumFacing side = EnumFacing.getFront(this.getRight(meta));
EnumFacing side = getFront().rotateY();
BlockVec3 vec = new BlockVec3(this);
for (int x = -this.connectionsLeft; x <= this.connectionsRight; x++) {
TileEntity tile;
BlockVec3 newVec = vec.clone().modifyPositionFromSide(side, x);
if (x == 0) {
tile = this;
} else {
tile = newVec.getTileEntity(this.worldObj);
}
if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta && !tile.isInvalid()) {
TileEntityScreen screenTile = (TileEntityScreen) tile;
// screenTile.connectedUp = true;
screenTile.setConnectedUp(true);
TileEntity te2 = newVec.getTileEntityOnSide(this.worldObj, 1);
if (te2 instanceof TileEntityScreen && te2.getBlockMetadata() == meta && !te2.isInvalid()) {
screenTile.tryConnectUp((TileEntityScreen) te2);
}
}
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class TileEntityScreen method joinDown.
private void joinDown() {
int meta = this.getBlockMetadata();
// EnumFacing side = EnumFacing.getFront(this.getRight(meta));
EnumFacing side = getFront().rotateY();
BlockVec3 vec = new BlockVec3(this);
for (int x = -this.connectionsLeft; x <= this.connectionsRight; x++) {
TileEntity tile;
BlockVec3 newVec = vec.clone().modifyPositionFromSide(side, x);
if (x == 0) {
tile = this;
} else {
tile = newVec.getTileEntity(this.worldObj);
}
if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta && !tile.isInvalid()) {
TileEntityScreen screenTile = (TileEntityScreen) tile;
// screenTile.connectedDown = true;
screenTile.setConnectedDown(true);
TileEntity te2 = newVec.getTileEntityOnSide(this.worldObj, 0);
if (te2 instanceof TileEntityScreen && te2.getBlockMetadata() == meta && !te2.isInvalid()) {
screenTile.tryConnectDown((TileEntityScreen) te2);
}
}
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class EntityAstroMiner method tryBlockClient.
private boolean tryBlockClient(BlockPos pos) {
BlockVec3 bv = new BlockVec3(pos.getX(), pos.getY(), pos.getZ());
if (this.laserBlocks.contains(bv)) {
return false;
}
// Add minable blocks to the laser fx list
IBlockState state = this.worldObj.getBlockState(pos);
Block b = state.getBlock();
if (b.getMaterial() == Material.air) {
return false;
}
if (noMineList.contains(b)) {
return true;
}
if (b instanceof BlockLiquid) {
return false;
}
if (b instanceof IFluidBlock) {
return false;
}
if (b instanceof IPlantable) {
return true;
}
int meta = b.getMetaFromState(state);
if (b.hasTileEntity(state) || b.getBlockHardness(this.worldObj, pos) < 0) {
return true;
}
if (this.tryBlockLimit == 0) {
return false;
}
this.tryBlockLimit--;
this.laserBlocks.add(bv);
this.laserTimes.add(this.ticksExisted);
return false;
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project MorePlanets by SteveKunG.
the class ChunkGeneratorChalos method generateGas.
private void generateGas(World world, Random rand, int xx, int zz) {
BlockVec3 pos = new BlockVec3();
if (this.gasPresent(world, rand, xx, zz, pos)) {
int x = pos.x;
int cy = pos.y;
int z = pos.z;
int r = 1 + rand.nextInt(2);
int r2 = r * r;
for (int bx = -r; bx <= r; bx++) {
for (int by = -r + 2; by <= r - 2; by++) {
for (int bz = -r; bz <= r; bz++) {
int d2 = bx * bx + by * by * 3 + bz * bz;
if (d2 <= r2) {
if (this.checkBlockGas(world, bx + x - 1, by + cy, bz + z)) {
continue;
}
if (this.checkBlockGas(world, bx + x + 1, by + cy, bz + z)) {
continue;
}
if (this.checkBlockGas(world, bx + x, by + cy - 1, bz + z)) {
continue;
}
if (this.checkBlockGas(world, bx + x, by + cy, bz + z - 1)) {
continue;
}
if (this.checkBlockGas(world, bx + x, by + cy, bz + z + 1)) {
continue;
}
world.setBlockState(new BlockPos(bx + x, by + cy, bz + z), ChalosBlocks.CHEESE_OF_MILK_GAS_BLOCK.getDefaultState(), 2);
}
}
}
}
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class BlockSolar method canPlaceBlockOnSide.
@Override
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side) {
for (int y = 1; y <= 2; y++) {
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
BlockPos posAt = pos.add(y == 2 ? x : 0, y, y == 2 ? z : 0);
Block block = worldIn.getBlockState(posAt).getBlock();
if (block.getMaterial() != Material.air && !block.isReplaceable(worldIn, posAt)) {
return false;
}
}
}
}
for (int x = -2; x <= 2; x++) {
for (int z = -2; z <= 2; z++) {
BlockPos posAt = pos.add(x, 0, z);
Block block = worldIn.getBlockState(posAt).getBlock();
if (block == this) {
return false;
}
}
}
return true;
// return new BlockVec3(x1, y1, z1).newVecSide(side ^ 1).getBlock(world) != GCBlocks.fakeBlock; TODO
}
Aggregations