Search in sources :

Example 6 with Owner

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

the class BlockMine method activateMine.

public void activateMine(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.mine);
        ((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 7 with Owner

use of net.geforcemods.securitycraft.api.Owner 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, mod_SecurityCraft.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, mod_SecurityCraft.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)

Example 8 with Owner

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

the class BlockUtils method setBlockProperty.

public static void setBlockProperty(World par1World, BlockPos pos, PropertyBool property, boolean value, boolean retainOldTileEntity) {
    if (retainOldTileEntity) {
        ItemStack[] modules = null;
        ItemStack[] inventory = null;
        int[] times = new int[4];
        String password = "";
        Owner owner = null;
        int cooldown = -1;
        if (par1World.getTileEntity(pos) instanceof CustomizableSCTE) {
            modules = ((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks;
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
            inventory = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks;
            times[0] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime;
            times[1] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime;
            times[2] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime;
            times[3] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime;
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityOwnable && ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner() != null) {
            owner = ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner();
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityKeypad && ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword() != null) {
            password = ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword();
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace && ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword() != null) {
            password = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword();
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityKeypadChest && ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword() != null) {
            password = ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword();
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown() != 0) {
            cooldown = ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown();
        }
        TileEntity tileEntity = par1World.getTileEntity(pos);
        par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
        par1World.setTileEntity(pos, tileEntity);
        if (modules != null) {
            ((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks = modules;
        }
        if (inventory != null && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks = inventory;
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime = times[0];
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime = times[1];
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime = times[2];
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime = times[3];
        }
        if (owner != null) {
            ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner().set(owner);
        }
        if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypad) {
            ((TileEntityKeypad) par1World.getTileEntity(pos)).setPassword(password);
        }
        if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).setPassword(password);
        }
        if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadChest) {
            ((TileEntityKeypadChest) par1World.getTileEntity(pos)).setPassword(password);
        }
        if (cooldown != -1 && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar) {
            ((TileEntityPortableRadar) par1World.getTileEntity(pos)).setAttackCooldown(cooldown);
        }
    } else {
        par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
    }
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) TileEntityKeypadFurnace(net.geforcemods.securitycraft.tileentity.TileEntityKeypadFurnace) TileEntity(net.minecraft.tileentity.TileEntity) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) TileEntityKeypadChest(net.geforcemods.securitycraft.tileentity.TileEntityKeypadChest) TileEntityPortableRadar(net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar) ItemStack(net.minecraft.item.ItemStack) TileEntityOwnable(net.geforcemods.securitycraft.tileentity.TileEntityOwnable) TileEntityKeypad(net.geforcemods.securitycraft.tileentity.TileEntityKeypad)

Example 9 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, 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)

Example 10 with Owner

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

the class BlockClaymore method activateMine.

public void activateMine(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.claymoreActive);
        ((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

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