Search in sources :

Example 51 with BlockVec3

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);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 52 with BlockVec3

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);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 53 with BlockVec3

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;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) IPlantable(net.minecraftforge.common.IPlantable) Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 54 with BlockVec3

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);
                    }
                }
            }
        }
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 55 with BlockVec3

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
}
Also used : IPartialSealableBlock(micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock) EnumSortCategoryBlock(micdoodle8.mods.galacticraft.core.util.EnumSortCategoryBlock) Block(net.minecraft.block.Block)

Aggregations

BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)104 TileEntity (net.minecraft.tileentity.TileEntity)44 EnumFacing (net.minecraft.util.EnumFacing)20 IBlockState (net.minecraft.block.state.IBlockState)14 BlockPos (net.minecraft.util.BlockPos)13 World (net.minecraft.world.World)10 IPartialSealableBlock (micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock)9 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)9 Block (net.minecraft.block.Block)9 ArrayList (java.util.ArrayList)7 FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)7 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)7 NBTTagList (net.minecraft.nbt.NBTTagList)7 IConductor (micdoodle8.mods.galacticraft.api.transmission.tile.IConductor)6 TileEntityOxygenSealer (micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 Entity (net.minecraft.entity.Entity)5 LinkedList (java.util.LinkedList)4 INetworkProvider (micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider)4 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)4