Search in sources :

Example 11 with Owner

use of net.geforcemods.securitycraft.api.Owner in project SecurityCraft by Geforce132.

the class ItemBlockReinforcedSlabs method onItemUse.

public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
    if (this.isNotSlab) {
        return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
    } else if (par1ItemStack.stackSize == 0) {
        return false;
    } else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) {
        return false;
    } else {
        Block block = par3World.getBlock(par4, par5, par6);
        int i1 = par3World.getBlockMetadata(par4, par5, par6);
        int j1 = i1 & 7;
        boolean flag = (i1 & 8) != 0;
        Owner owner = null;
        if (par3World.getTileEntity(par4, par5, par6) instanceof IOwnable) {
            owner = ((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner();
            if (!((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner().isOwner(par2EntityPlayer)) {
                if (!par3World.isRemote) {
                    PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("messages.reinforcedSlab"), StatCollector.translateToLocal("messages.reinforcedSlab.cannotDoubleSlab"), EnumChatFormatting.RED);
                }
                return false;
            }
        }
        if ((par7 == 1 && !flag || par7 == 0 && flag) && isBlock(block) && j1 == par1ItemStack.getItemDamage()) {
            if (par3World.checkNoEntityCollision(this.getBlockVariant(i1).getCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.setBlock(par4, par5, par6, this.getBlockVariant(block, i1), (block == mod_SecurityCraft.reinforcedStoneSlabs && i1 == 2 ? 2 : j1), 3)) {
                par3World.playSoundEffect(par4 + 0.5F, par5 + 0.5F, par6 + 0.5F, this.getBlockVariant(block, i1).stepSound.func_150496_b(), (this.getBlockVariant(block, i1).stepSound.getVolume() + 1.0F) / 2.0F, this.getBlockVariant(block, i1).stepSound.getPitch() * 0.8F);
                --par1ItemStack.stackSize;
                if (owner != null) {
                    ((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner().set(owner);
                }
            }
            return true;
        } else {
            return this.func_150946_a(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7) ? true : super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
        }
    }
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) IOwnable(net.geforcemods.securitycraft.api.IOwnable)

Example 12 with Owner

use of net.geforcemods.securitycraft.api.Owner in project SecurityCraft by Geforce132.

the class ItemBlockReinforcedSlabs method tryPlace.

private boolean tryPlace(ItemStack stack, World worldIn, BlockPos pos, Object variantInStack) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Owner owner = null;
    if (worldIn.getTileEntity(pos) instanceof IOwnable) {
        owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
    }
    if (iblockstate.getBlock() == this.singleSlab) {
        Comparable<?> comparable = iblockstate.getValue(this.singleSlab.getVariantProperty());
        if (comparable == variantInStack) {
            IBlockState iblockstate1 = this.doubleSlab.getDefaultState().withProperty(this.singleSlab.getVariantProperty(), comparable);
            if (worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3)) {
                worldIn.playSoundEffect(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, this.doubleSlab.stepSound.getPlaceSound(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getFrequency() * 0.8F);
                --stack.stackSize;
                if (owner != null) {
                    ((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
                }
            }
            return true;
        }
    }
    return false;
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) IBlockState(net.minecraft.block.state.IBlockState) IOwnable(net.geforcemods.securitycraft.api.IOwnable)

Example 13 with Owner

use of net.geforcemods.securitycraft.api.Owner in project SecurityCraft by Geforce132.

the class ItemBlockReinforcedWoodSlabs method tryPlace.

private boolean tryPlace(ItemStack stack, World worldIn, BlockPos pos, Object variantInStack) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Owner owner = null;
    if (worldIn.getTileEntity(pos) instanceof IOwnable) {
        owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
    }
    if (iblockstate.getBlock() == this.singleSlab) {
        Comparable<?> comparable = iblockstate.getValue(this.singleSlab.getVariantProperty());
        if (comparable == variantInStack) {
            IBlockState iblockstate1 = this.doubleSlab.getDefaultState().withProperty(this.singleSlab.getVariantProperty(), comparable);
            if (worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3)) {
                worldIn.playSoundEffect(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, this.doubleSlab.stepSound.getPlaceSound(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getFrequency() * 0.8F);
                --stack.stackSize;
                if (owner != null) {
                    ((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
                }
            }
            return true;
        }
    }
    return false;
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) IBlockState(net.minecraft.block.state.IBlockState) IOwnable(net.geforcemods.securitycraft.api.IOwnable)

Example 14 with Owner

use of net.geforcemods.securitycraft.api.Owner in project SecurityCraft by Geforce132.

the class ItemKeyPanel method onItemUse.

public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing par5EnumFacing, float hitX, float hitY, float hitZ) {
    if (!par3World.isRemote) {
        if (BlockUtils.getBlock(par3World, pos) == mod_SecurityCraft.frame) {
            Owner owner = ((IOwnable) par3World.getTileEntity(pos)).getOwner();
            EnumFacing enumfacing = (EnumFacing) par3World.getBlockState(pos).getValue(BlockKeypad.FACING);
            par3World.setBlockState(pos, mod_SecurityCraft.keypad.getDefaultState().withProperty(BlockKeypad.FACING, enumfacing).withProperty(BlockKeypad.POWERED, false));
            ((IOwnable) par3World.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
            par1ItemStack.stackSize -= 1;
        }
        return true;
    }
    return false;
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) EnumFacing(net.minecraft.util.EnumFacing) IOwnable(net.geforcemods.securitycraft.api.IOwnable)

Example 15 with Owner

use of net.geforcemods.securitycraft.api.Owner in project SecurityCraft by Geforce132.

the class ItemBlockReinforcedSlabs method tryPlace.

private boolean tryPlace(ItemStack stack, World worldIn, EntityPlayer player, BlockPos pos, Object variantInStack) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Owner owner = null;
    if (worldIn.getTileEntity(pos) instanceof IOwnable) {
        owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
    }
    if (iblockstate.getBlock() == this.singleSlab) {
        Comparable<?> comparable = iblockstate.getValue(this.singleSlab.getVariantProperty());
        if (comparable == variantInStack) {
            IBlockState iblockstate1 = this.makeState(this.singleSlab.getVariantProperty(), comparable);
            if (worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(iblockstate1, worldIn, pos)) && worldIn.setBlockState(pos, iblockstate1, 3)) {
                worldIn.playSound(player, pos, this.doubleSlab.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (this.doubleSlab.getSoundType().getVolume() + 1.0F) / 2.0F, this.doubleSlab.getSoundType().getPitch() * 0.8F);
                --stack.stackSize;
                if (owner != null) {
                    ((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
                }
            }
            return true;
        }
    }
    return false;
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) IBlockState(net.minecraft.block.state.IBlockState) IOwnable(net.geforcemods.securitycraft.api.IOwnable)

Aggregations

Owner (net.geforcemods.securitycraft.api.Owner)16 IOwnable (net.geforcemods.securitycraft.api.IOwnable)13 IBlockState (net.minecraft.block.state.IBlockState)4 EnumFacing (net.minecraft.util.EnumFacing)3 TileEntityAlarm (net.geforcemods.securitycraft.tileentity.TileEntityAlarm)2 Block (net.minecraft.block.Block)2 ItemBlock (net.minecraft.item.ItemBlock)2 CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)1 TileEntityKeypad (net.geforcemods.securitycraft.tileentity.TileEntityKeypad)1 TileEntityKeypadChest (net.geforcemods.securitycraft.tileentity.TileEntityKeypadChest)1 TileEntityKeypadFurnace (net.geforcemods.securitycraft.tileentity.TileEntityKeypadFurnace)1 TileEntityOwnable (net.geforcemods.securitycraft.tileentity.TileEntityOwnable)1 TileEntityPortableRadar (net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1