Search in sources :

Example 6 with TileEntityPneumaticDoorBase

use of pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase in project PneumaticCraft by MineMaarten.

the class BlockPneumaticDoorBase method onBlockPlacedBy.

/**
     * Called when the block is placed in the world.
     */
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) {
    TileEntityPneumaticDoorBase doorBase = (TileEntityPneumaticDoorBase) world.getTileEntity(x, y, z);
    doorBase.orientation = PneumaticCraftUtils.getDirectionFacing(par5EntityLiving, false);
    updateDoorSide(doorBase);
}
Also used : TileEntityPneumaticDoorBase(pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase)

Example 7 with TileEntityPneumaticDoorBase

use of pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase in project PneumaticCraft by MineMaarten.

the class BlockPneumaticDoorBase method onNeighborBlockChange.

@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof TileEntityPneumaticDoorBase) {
        updateDoorSide((TileEntityPneumaticDoorBase) te);
        ForgeDirection dir = ((TileEntityPneumaticDoorBase) te).orientation;
        if (world.getBlock(x + dir.offsetX, y, z + dir.offsetZ) == Blockss.pneumaticDoor) {
            Blockss.pneumaticDoor.onNeighborBlockChange(world, x + dir.offsetX, y, z + dir.offsetZ, block);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityPneumaticDoorBase(pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 8 with TileEntityPneumaticDoorBase

use of pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase in project PneumaticCraft by MineMaarten.

the class BlockPneumaticDoorBase method rotateBlock.

@Override
public boolean rotateBlock(World world, EntityPlayer player, int x, int y, int z, ForgeDirection side) {
    if (player.isSneaking()) {
        return super.rotateBlock(world, player, x, y, z, side);
    } else {
        TileEntity te = world.getTileEntity(x, y, z);
        if (te instanceof TileEntityPneumaticDoorBase) {
            TileEntityPneumaticDoorBase teDb = (TileEntityPneumaticDoorBase) te;
            teDb.orientation = teDb.orientation.getRotation(ForgeDirection.UP);
            return true;
        }
        return false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityPneumaticDoorBase(pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase)

Example 9 with TileEntityPneumaticDoorBase

use of pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase in project PneumaticCraft by MineMaarten.

the class BlockPneumaticDoor method getDoorBase.

private TileEntityPneumaticDoorBase getDoorBase(World world, int x, int y, int z) {
    if (world.getBlock(x, y, z) != this)
        return null;
    int meta = world.getBlockMetadata(x, y, z);
    if (meta < 6) {
        return getDoorBase(world, x, y + 1, z);
    } else {
        ForgeDirection dir = ForgeDirection.getOrientation(meta % 6);
        TileEntity te1 = world.getTileEntity(x + dir.getRotation(ForgeDirection.UP).offsetX, y, z + dir.getRotation(ForgeDirection.UP).offsetZ);
        if (te1 instanceof TileEntityPneumaticDoorBase) {
            TileEntityPneumaticDoorBase door = (TileEntityPneumaticDoorBase) te1;
            if (door.orientation == dir.getRotation(ForgeDirection.DOWN)) {
                return door;
            }
        }
        TileEntity te2 = world.getTileEntity(x + dir.getRotation(ForgeDirection.DOWN).offsetX, y, z + dir.getRotation(ForgeDirection.DOWN).offsetZ);
        if (te2 instanceof TileEntityPneumaticDoorBase) {
            TileEntityPneumaticDoorBase door = (TileEntityPneumaticDoorBase) te2;
            if (door.orientation == dir.getRotation(ForgeDirection.UP)) {
                return door;
            }
        }
        return null;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityPneumaticDoorBase(pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Aggregations

TileEntityPneumaticDoorBase (pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase)9 Block (net.minecraft.block.Block)3 ItemBlock (net.minecraft.item.ItemBlock)3 ItemStack (net.minecraft.item.ItemStack)3 TileEntity (net.minecraft.tileentity.TileEntity)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3