Search in sources :

Example 1 with IOwnable

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

the class ItemKeyPanel 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 (!par3World.isRemote) {
        if (par3World.getBlock(par4, par5, par6) == mod_SecurityCraft.frame) {
            Owner owner = ((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner();
            par3World.setBlock(par4, par5, par6, mod_SecurityCraft.keypad, par3World.getBlockMetadata(par4, par5, par6), 3);
            ((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner().set(owner);
            par1ItemStack.stackSize -= 1;
        }
        return true;
    }
    return false;
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) IOwnable(net.geforcemods.securitycraft.api.IOwnable)

Example 2 with IOwnable

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

the class ItemUniversalOwnerChanger method onItemUse.

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float f1, float f2, float f3) {
    TileEntity te = world.getTileEntity(x, y, z);
    String newOwner = stack.getDisplayName();
    if (!world.isRemote) {
        if (!stack.hasDisplayName()) {
            PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("item.universalOwnerChanger.name"), StatCollector.translateToLocal("messages.universalOwnerChanger.noName"), EnumChatFormatting.RED);
            return false;
        }
        if (!(te instanceof IOwnable)) {
            PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("item.universalOwnerChanger.name"), StatCollector.translateToLocal("messages.universalOwnerChanger.cantChange"), EnumChatFormatting.RED);
            return false;
        }
        if (!((IOwnable) te).getOwner().isOwner(player)) {
            PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("item.universalOwnerChanger.name"), StatCollector.translateToLocal("messages.universalOwnerChanger.notOwned"), EnumChatFormatting.RED);
            return false;
        }
        if (world.getBlock(x, y, z) instanceof BlockReinforcedDoor) {
            if (world.getBlock(x, y + 1, z) instanceof BlockReinforcedDoor)
                ((IOwnable) world.getTileEntity(x, y + 1, z)).getOwner().set(PlayerUtils.isPlayerOnline(newOwner) ? PlayerUtils.getPlayerFromName(newOwner).getUniqueID().toString() : "ownerUUID", newOwner);
            else
                ((IOwnable) world.getTileEntity(x, y - 1, z)).getOwner().set(PlayerUtils.isPlayerOnline(newOwner) ? PlayerUtils.getPlayerFromName(newOwner).getUniqueID().toString() : "ownerUUID", newOwner);
        }
        if (te instanceof IOwnable)
            ((IOwnable) te).getOwner().set(PlayerUtils.isPlayerOnline(newOwner) ? PlayerUtils.getPlayerFromName(newOwner).getUniqueID().toString() : "ownerUUID", newOwner);
        MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(te.getDescriptionPacket());
        PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("item.universalOwnerChanger.name"), StatCollector.translateToLocal("messages.universalOwnerChanger.changed").replace("#", newOwner), EnumChatFormatting.GREEN);
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IOwnable(net.geforcemods.securitycraft.api.IOwnable) BlockReinforcedDoor(net.geforcemods.securitycraft.blocks.BlockReinforcedDoor)

Example 3 with IOwnable

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

the class ItemBlockReinforcedSlabs method func_150946_a.

private boolean func_150946_a(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7) {
    if (par7 == 0) {
        --par5;
    }
    if (par7 == 1) {
        ++par5;
    }
    if (par7 == 2) {
        --par6;
    }
    if (par7 == 3) {
        ++par6;
    }
    if (par7 == 4) {
        --par4;
    }
    if (par7 == 5) {
        ++par4;
    }
    Block block = par3World.getBlock(par4, par5, par6);
    int i1 = par3World.getBlockMetadata(par4, par5, par6);
    int j1 = i1 & 7;
    Owner owner = null;
    if (par3World.getTileEntity(par4, par5, par6) instanceof IOwnable) {
        owner = ((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner();
    }
    if (block == this.singleSlab && j1 == par1ItemStack.getItemDamage()) {
        if (par3World.checkNoEntityCollision(this.getBlockVariant(i1).getCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.setBlock(par4, par5, par6, this.getBlockVariant(i1), j1, 3)) {
            par3World.playSoundEffect(par4 + 0.5F, par5 + 0.5F, par6 + 0.5F, this.getBlockVariant(i1).stepSound.func_150496_b(), (this.getBlockVariant(i1).stepSound.getVolume() + 1.0F) / 2.0F, this.getBlockVariant(i1).stepSound.getPitch() * 0.8F);
            --par1ItemStack.stackSize;
            if (owner != null) {
                ((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner().set(owner.getUUID(), owner.getName());
            }
        }
        return true;
    } else {
        return false;
    }
}
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 4 with IOwnable

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

the class BlockClaymore method defuseMine.

public void defuseMine(World world, int par2, int par3, int par4) {
    if (!world.isRemote) {
        Owner owner = ((IOwnable) world.getTileEntity(par2, par3, par4)).getOwner();
        world.setBlock(par2, par3, par4, mod_SecurityCraft.claymoreDefused);
        ((IOwnable) world.getTileEntity(par2, par3, par4)).setOwner(owner.getUUID(), owner.getName());
    }
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) IOwnable(net.geforcemods.securitycraft.api.IOwnable)

Example 5 with IOwnable

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

the class BlockMine method defuseMine.

public void defuseMine(World world, int par2, int par3, int par4) {
    if (!world.isRemote) {
        Owner owner = ((IOwnable) world.getTileEntity(par2, par3, par4)).getOwner();
        world.setBlock(par2, par3, par4, mod_SecurityCraft.mineCut);
        ((IOwnable) world.getTileEntity(par2, par3, par4)).setOwner(owner.getUUID(), owner.getName());
    }
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) IOwnable(net.geforcemods.securitycraft.api.IOwnable)

Aggregations

IOwnable (net.geforcemods.securitycraft.api.IOwnable)32 Owner (net.geforcemods.securitycraft.api.Owner)13 TileEntity (net.minecraft.tileentity.TileEntity)10 CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)8 IPasswordProtected (net.geforcemods.securitycraft.api.IPasswordProtected)6 PacketCUpdateNBTTag (net.geforcemods.securitycraft.network.packets.PacketCUpdateNBTTag)6 Block (net.minecraft.block.Block)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 IExplosive (net.geforcemods.securitycraft.api.IExplosive)5 EnumCustomModules (net.geforcemods.securitycraft.misc.EnumCustomModules)4 IBlockState (net.minecraft.block.state.IBlockState)4 ItemBlock (net.minecraft.item.ItemBlock)4 INameable (net.geforcemods.securitycraft.api.INameable)3 BlockReinforcedDoor (net.geforcemods.securitycraft.blocks.BlockReinforcedDoor)3 CameraView (net.geforcemods.securitycraft.misc.CameraView)3 TileEntitySCTE (net.geforcemods.securitycraft.api.TileEntitySCTE)2 BlockLaserBlock (net.geforcemods.securitycraft.blocks.BlockLaserBlock)2 EntitySecurityCamera (net.geforcemods.securitycraft.entity.EntitySecurityCamera)2 CustomHoverChecker (net.geforcemods.securitycraft.gui.components.CustomHoverChecker)2 ITileEntityProvider (net.minecraft.block.ITileEntityProvider)2