Search in sources :

Example 1 with TileEntityAlarm

use of net.geforcemods.securitycraft.tileentity.TileEntityAlarm in project SecurityCraft by Geforce132.

the class BlockAlarm method playSoundAndUpdate.

private void playSoundAndUpdate(World par1World, int par2, int par3, int par4) {
    if (!(par1World.getTileEntity(par2, par3, par4) instanceof TileEntityAlarm))
        return;
    if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
        boolean isPowered = ((TileEntityAlarm) par1World.getTileEntity(par2, par3, par4)).isPowered();
        if (!isPowered) {
            Owner owner = ((TileEntityAlarm) par1World.getTileEntity(par2, par3, par4)).getOwner();
            par1World.setBlock(par2, par3, par4, SCContent.alarmLit, par1World.getBlockMetadata(par2, par3, par4), 3);
            ((TileEntityAlarm) par1World.getTileEntity(par2, par3, par4)).getOwner().set(owner);
            ((TileEntityAlarm) par1World.getTileEntity(par2, par3, par4)).setPowered(true);
        }
    } else {
        boolean isPowered = ((TileEntityAlarm) par1World.getTileEntity(par2, par3, par4)).isPowered();
        if (isPowered) {
            Owner owner = ((TileEntityAlarm) par1World.getTileEntity(par2, par3, par4)).getOwner();
            par1World.setBlock(par2, par3, par4, SCContent.alarm, par1World.getBlockMetadata(par2, par3, par4), 3);
            ((TileEntityAlarm) par1World.getTileEntity(par2, par3, par4)).getOwner().set(owner);
            ((TileEntityAlarm) par1World.getTileEntity(par2, par3, par4)).setPowered(false);
        }
    }
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) TileEntityAlarm(net.geforcemods.securitycraft.tileentity.TileEntityAlarm)

Example 2 with TileEntityAlarm

use of net.geforcemods.securitycraft.tileentity.TileEntityAlarm in project SecurityCraft by Geforce132.

the class BlockAlarm method playSoundAndUpdate.

private void playSoundAndUpdate(World par1World, BlockPos pos) {
    if (!(par1World.getTileEntity(pos) instanceof TileEntityAlarm))
        return;
    if (par1World.isBlockIndirectlyGettingPowered(pos) > 0) {
        boolean isPowered = ((TileEntityAlarm) par1World.getTileEntity(pos)).isPowered();
        if (!isPowered) {
            Owner owner = ((TileEntityAlarm) par1World.getTileEntity(pos)).getOwner();
            EnumFacing dir = BlockUtils.getBlockPropertyAsEnum(par1World, pos, FACING);
            BlockUtils.setBlock(par1World, pos, SCContent.alarmLit);
            BlockUtils.setBlockProperty(par1World, pos, FACING, dir);
            ((TileEntityAlarm) par1World.getTileEntity(pos)).getOwner().set(owner);
            ((TileEntityAlarm) par1World.getTileEntity(pos)).setPowered(true);
        }
    } else {
        boolean isPowered = ((TileEntityAlarm) par1World.getTileEntity(pos)).isPowered();
        if (isPowered) {
            Owner owner = ((TileEntityAlarm) par1World.getTileEntity(pos)).getOwner();
            EnumFacing dir = BlockUtils.getBlockPropertyAsEnum(par1World, pos, FACING);
            BlockUtils.setBlock(par1World, pos, SCContent.alarm);
            BlockUtils.setBlockProperty(par1World, pos, FACING, dir);
            ((TileEntityAlarm) par1World.getTileEntity(pos)).getOwner().set(owner);
            ((TileEntityAlarm) par1World.getTileEntity(pos)).setPowered(false);
        }
    }
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) TileEntityAlarm(net.geforcemods.securitycraft.tileentity.TileEntityAlarm) EnumFacing(net.minecraft.util.EnumFacing)

Aggregations

Owner (net.geforcemods.securitycraft.api.Owner)2 TileEntityAlarm (net.geforcemods.securitycraft.tileentity.TileEntityAlarm)2 EnumFacing (net.minecraft.util.EnumFacing)1