Search in sources :

Example 1 with TileEntityKeypad

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

the class ModuleUtils method checkForModule.

/**
	 * A large block of code that checks if the TileEntity at the specified coordinates has the given module inserted, and what should happen if it does. <p>
	 * 
	 * Args: world, x, y, z, player, moduleType.
	 */
public static boolean checkForModule(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, EnumCustomModules module) {
    TileEntity te = par1World.getTileEntity(par2, par3, par4);
    if (te == null || !(te instanceof CustomizableSCTE)) {
        return false;
    }
    if (te instanceof TileEntityKeypad) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            PlayerUtils.sendMessageToPlayer(par5EntityPlayer, StatCollector.translateToLocal("tile.keypad.name"), StatCollector.translateToLocal("messages.module.whitelisted"), EnumChatFormatting.GREEN);
            BlockKeypad.activate(par1World, par2, par3, par4);
            return true;
        }
        if (module == EnumCustomModules.BLACKLIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.BLACKLIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.BLACKLIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            PlayerUtils.sendMessageToPlayer(par5EntityPlayer, StatCollector.translateToLocal("tile.keypad.name"), StatCollector.translateToLocal("messages.module.blacklisted"), EnumChatFormatting.RED);
            return true;
        }
    } else if (te instanceof TileEntityKeycardReader) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            PlayerUtils.sendMessageToPlayer(par5EntityPlayer, StatCollector.translateToLocal("tile.keycardReader.name"), StatCollector.translateToLocal("messages.module.whitelisted"), EnumChatFormatting.GREEN);
            BlockKeycardReader.activate(par1World, par2, par3, par4);
            return true;
        }
        if (module == EnumCustomModules.BLACKLIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.BLACKLIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.BLACKLIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            PlayerUtils.sendMessageToPlayer(par5EntityPlayer, StatCollector.translateToLocal("tile.keycardReader.name"), StatCollector.translateToLocal("messages.module.blacklisted"), EnumChatFormatting.RED);
            return true;
        }
    } else if (te instanceof TileEntityRetinalScanner) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            return true;
        }
    } else if (te instanceof TileEntityInventoryScanner) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) TileEntityRetinalScanner(net.geforcemods.securitycraft.tileentity.TileEntityRetinalScanner) TileEntityInventoryScanner(net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner) TileEntityKeycardReader(net.geforcemods.securitycraft.tileentity.TileEntityKeycardReader) TileEntityKeypad(net.geforcemods.securitycraft.tileentity.TileEntityKeypad)

Example 2 with TileEntityKeypad

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

the class BlockKeypad method getDisguisedBlockState.

public IBlockState getDisguisedBlockState(IBlockAccess world, BlockPos pos) {
    if (world.getTileEntity(pos) instanceof TileEntityKeypad) {
        TileEntityKeypad te = (TileEntityKeypad) world.getTileEntity(pos);
        ItemStack module = te.hasModule(EnumCustomModules.DISGUISE) ? te.getModule(EnumCustomModules.DISGUISE) : null;
        if (module != null && !((ItemModule) module.getItem()).getBlockAddons(module.getTagCompound()).isEmpty()) {
            ItemStack disguisedStack = ((ItemModule) module.getItem()).getAddons(module.getTagCompound()).get(0);
            Block block = Block.getBlockFromItem(disguisedStack.getItem());
            boolean hasMeta = disguisedStack.getHasSubtypes();
            IBlockState disguisedModel = block.getStateFromMeta(hasMeta ? disguisedStack.getItemDamage() : getMetaFromState(world.getBlockState(pos)));
            if (block != this) {
                return block.getActualState(disguisedModel, world, pos);
            }
        }
    }
    return null;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) TileEntityKeypad(net.geforcemods.securitycraft.tileentity.TileEntityKeypad)

Example 3 with TileEntityKeypad

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

the class BlockKeypad method getDisguisedStack.

public ItemStack getDisguisedStack(IBlockAccess world, BlockPos pos) {
    if (world.getTileEntity(pos) instanceof TileEntityKeypad) {
        TileEntityKeypad te = (TileEntityKeypad) world.getTileEntity(pos);
        ItemStack stack = te.hasModule(EnumCustomModules.DISGUISE) ? te.getModule(EnumCustomModules.DISGUISE) : null;
        if (stack != null && !((ItemModule) stack.getItem()).getBlockAddons(stack.getTagCompound()).isEmpty()) {
            ItemStack disguisedStack = ((ItemModule) stack.getItem()).getAddons(stack.getTagCompound()).get(0);
            if (Block.getBlockFromItem(disguisedStack.getItem()) != this) {
                return disguisedStack;
            }
        }
    }
    return null;
}
Also used : ItemStack(net.minecraft.item.ItemStack) TileEntityKeypad(net.geforcemods.securitycraft.tileentity.TileEntityKeypad)

Example 4 with TileEntityKeypad

use of net.geforcemods.securitycraft.tileentity.TileEntityKeypad 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 5 with TileEntityKeypad

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

the class BlockKeypad method getIcon.

@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess access, int x, int y, int z, int side) {
    int meta = access.getBlockMetadata(x, y, z);
    TileEntityKeypad tileEntity = ((TileEntityKeypad) access.getTileEntity(x, y, z));
    boolean isDisguised = tileEntity.hasModule(EnumCustomModules.DISGUISE);
    if (isDisguised && !tileEntity.getAddonsFromModule(EnumCustomModules.DISGUISE).isEmpty()) {
        List<ItemStack> stacks = tileEntity.getAddonsFromModule(EnumCustomModules.DISGUISE);
        if (stacks.size() != 0) {
            ItemStack stack = stacks.get(0);
            Block disguisedAs = Block.getBlockFromItem(stack.getItem());
            return stack.getHasSubtypes() ? disguisedAs.getIcon(side, stack.getItemDamage()) : disguisedAs.getIcon(side, meta);
        }
    }
    if (meta > 6 && meta < 11) {
        return side == 1 ? this.keypadIconTop : (side == 0 ? this.keypadIconTop : (side != (meta - 5) ? this.blockIcon : this.keypadIconFrontActive));
    } else {
        return side == 1 ? this.keypadIconTop : (side == 0 ? this.keypadIconTop : (side != meta ? this.blockIcon : this.keypadIconFront));
    }
}
Also used : Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) TileEntityKeypad(net.geforcemods.securitycraft.tileentity.TileEntityKeypad) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

TileEntityKeypad (net.geforcemods.securitycraft.tileentity.TileEntityKeypad)5 ItemStack (net.minecraft.item.ItemStack)4 CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)2 Block (net.minecraft.block.Block)2 TileEntity (net.minecraft.tileentity.TileEntity)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 Owner (net.geforcemods.securitycraft.api.Owner)1 TileEntityInventoryScanner (net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner)1 TileEntityKeycardReader (net.geforcemods.securitycraft.tileentity.TileEntityKeycardReader)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 TileEntityRetinalScanner (net.geforcemods.securitycraft.tileentity.TileEntityRetinalScanner)1 IBlockState (net.minecraft.block.state.IBlockState)1