Search in sources :

Example 16 with Owner

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

the class ItemKeyPanel method onItemUse.

@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote) {
        if (BlockUtils.getBlock(worldIn, pos) == mod_SecurityCraft.frame) {
            Owner owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
            EnumFacing enumfacing = worldIn.getBlockState(pos).getValue(BlockKeypad.FACING);
            worldIn.setBlockState(pos, mod_SecurityCraft.keypad.getDefaultState().withProperty(BlockKeypad.FACING, enumfacing).withProperty(BlockKeypad.POWERED, false));
            ((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
            stack.stackSize -= 1;
        }
        return EnumActionResult.SUCCESS;
    }
    return EnumActionResult.FAIL;
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) EnumFacing(net.minecraft.util.EnumFacing) 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