Search in sources :

Example 1 with TileEntityPneumaticDoorBase

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

the class BlockPneumaticDoor method onBlockActivated.

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
    TileEntityPneumaticDoorBase doorBase = getDoorBase(world, x, y, z);
    if (!world.isRemote && doorBase != null && doorBase.redstoneMode == 2 && doorBase.getPressure(ForgeDirection.UNKNOWN) >= PneumaticValues.MIN_PRESSURE_PNEUMATIC_DOOR) {
        doorBase.setOpening(!doorBase.isOpening());
        doorBase.setNeighborOpening(doorBase.isOpening());
        return true;
    }
    return false;
}
Also used : TileEntityPneumaticDoorBase(pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase)

Example 2 with TileEntityPneumaticDoorBase

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

the class BlockPneumaticDoor method onNeighborBlockChange.

@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
    boolean powered = world.isBlockIndirectlyGettingPowered(x, y, z);
    if (!powered) {
        int meta = world.getBlockMetadata(x, y, z);
        if (meta < 6) {
            powered = world.isBlockIndirectlyGettingPowered(x, y + 1, z);
        } else {
            powered = world.isBlockIndirectlyGettingPowered(x, y - 1, z);
        }
    }
    TileEntityPneumaticDoorBase doorBase = getDoorBase(world, x, y, z);
    if (!world.isRemote && doorBase != null && doorBase.getPressure(ForgeDirection.UNKNOWN) >= PneumaticValues.MIN_PRESSURE_PNEUMATIC_DOOR) {
        if (powered != doorBase.wasPowered) {
            doorBase.wasPowered = powered;
            doorBase.setOpening(powered);
        }
    }
}
Also used : TileEntityPneumaticDoorBase(pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase)

Example 3 with TileEntityPneumaticDoorBase

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

the class BlockPneumaticDoorBase method shouldSideBeRendered.

@Override
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
    ForgeDirection d = ForgeDirection.getOrientation(side);
    TileEntityPneumaticDoorBase te = (TileEntityPneumaticDoorBase) world.getTileEntity(x - d.offsetX, y - d.offsetY, z - d.offsetZ);
    ItemStack camoStack = te.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT);
    if (camoStack != null && camoStack.getItem() instanceof ItemBlock) {
        Block block = ((ItemBlock) camoStack.getItem()).field_150939_a;
        if (PneumaticCraftUtils.isRenderIDCamo(block.getRenderType())) {
            return true;
        }
    }
    return false;
}
Also used : TileEntityPneumaticDoorBase(pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 4 with TileEntityPneumaticDoorBase

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

the class ModelPneumaticDoorBase method renderDynamic.

@Override
public void renderDynamic(float size, TileEntity tile, float partialTicks) {
    if (tile instanceof TileEntityPneumaticDoorBase) {
        TileEntityPneumaticDoorBase door = (TileEntityPneumaticDoorBase) tile;
        ItemStack camoStack = door.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT);
        boolean renderBase = true;
        if (camoStack != null && camoStack.getItem() instanceof ItemBlock) {
            Block block = Block.getBlockFromItem(camoStack.getItem());
            renderBase = !PneumaticCraftUtils.isRenderIDCamo(block.getRenderType());
        }
        PneumaticCraftUtils.rotateMatrixByMetadata(door.orientation.ordinal());
        renderModel(size, door.oldProgress + (door.progress - door.oldProgress) * partialTicks, renderBase, ((TileEntityPneumaticDoorBase) tile).rightGoing);
    } else {
        renderModel(size, 1, true, false);
    }
}
Also used : TileEntityPneumaticDoorBase(pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 5 with TileEntityPneumaticDoorBase

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

the class BlockPneumaticDoorBase method getIcon.

@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
    TileEntityPneumaticDoorBase te = (TileEntityPneumaticDoorBase) world.getTileEntity(x, y, z);
    ItemStack camoStack = te.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT);
    if (camoStack != null && camoStack.getItem() instanceof ItemBlock) {
        Block block = ((ItemBlock) camoStack.getItem()).field_150939_a;
        if (PneumaticCraftUtils.isRenderIDCamo(block.getRenderType())) {
            return block.getIcon(side, camoStack.getItemDamage());
        }
    }
    return this.getIcon(side, world.getBlockMetadata(x, y, z));
}
Also used : TileEntityPneumaticDoorBase(pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

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