Search in sources :

Example 1 with CustomizableSCTE

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

the class EntitySecurityCamera method emitLight.

public void emitLight() {
    Block block = this.worldObj.getBlock((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ));
    if (block instanceof BlockSecurityCamera) {
        this.toggleLightCooldown = 30;
        int meta = this.worldObj.getBlockMetadata((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ));
        ItemStack[] modules = null;
        if (!((CustomizableSCTE) this.worldObj.getTileEntity((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ))).getModules().isEmpty()) {
            modules = ((CustomizableSCTE) this.worldObj.getTileEntity((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ))).itemStacks;
        }
        if (block == mod_SecurityCraft.securityCamera) {
            mod_SecurityCraft.network.sendToServer(new PacketSetBlockAndMetadata((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ), "securitycraft:securityCameraLit", meta));
            mod_SecurityCraft.network.sendToServer(new PacketSSetOwner((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ), ((IOwnable) this.worldObj.getTileEntity((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ))).getOwner().getUUID(), ((IOwnable) this.worldObj.getTileEntity((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ))).getOwner().getName()));
            if (modules != null) {
                mod_SecurityCraft.network.sendToServer(new PacketSAddModules((int) Math.floor(this.posX), (int) (this.posY - 1.0D), (int) Math.floor(this.posZ), modules));
            }
        }
    }
}
Also used : CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) PacketSAddModules(net.geforcemods.securitycraft.network.packets.PacketSAddModules) Block(net.minecraft.block.Block) PacketSetBlockAndMetadata(net.geforcemods.securitycraft.network.packets.PacketSetBlockAndMetadata) ItemStack(net.minecraft.item.ItemStack) BlockSecurityCamera(net.geforcemods.securitycraft.blocks.BlockSecurityCamera) PacketSSetOwner(net.geforcemods.securitycraft.network.packets.PacketSSetOwner)

Example 2 with CustomizableSCTE

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

the class BlockPortableRadar method searchForPlayers.

public static void searchForPlayers(World par1World, int par2, int par3, int par4, double searchRadius) {
    if (!par1World.isRemote) {
        double d0 = (searchRadius);
        AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(par2, par3, par4, par2 + 1, par3 + 1, par4 + 1).expand(d0, d0, d0);
        axisalignedbb.maxY = par1World.getHeight();
        List<?> list = par1World.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
        Iterator<?> iterator = list.iterator();
        EntityPlayer entityplayer;
        if (list.isEmpty()) {
            if (par1World.getTileEntity(par2, par3, par4) != null && par1World.getTileEntity(par2, par3, par4) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.REDSTONE) && par1World.getBlockMetadata(par2, par3, par4) == 1) {
                togglePowerOutput(par1World, par2, par3, par4, false);
                return;
            }
        }
        while (iterator.hasNext()) {
            EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager().func_152612_a(((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getOwner().getName());
            entityplayer = (EntityPlayer) iterator.next();
            if (par1World.getTileEntity(par2, par3, par4) == null || !(par1World.getTileEntity(par2, par3, par4) instanceof CustomizableSCTE)) {
                continue;
            }
            if (((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(entityplayermp.getCommandSenderName().toLowerCase())) {
                continue;
            }
            if (PlayerUtils.isPlayerOnline(((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getOwner().getName())) {
                if (!((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).shouldSendMessage(entityplayer)) {
                    continue;
                }
                PlayerUtils.sendMessageToPlayer(entityplayermp, StatCollector.translateToLocal("tile.portableRadar.name"), ((INameable) par1World.getTileEntity(par2, par3, par4)).hasCustomName() ? (StatCollector.translateToLocal("messages.portableRadar.withName").replace("#p", EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET).replace("#n", EnumChatFormatting.ITALIC + ((INameable) par1World.getTileEntity(par2, par3, par4)).getCustomName() + EnumChatFormatting.RESET)) : (StatCollector.translateToLocal("messages.portableRadar.withoutName").replace("#p", EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET).replace("#l", Utils.getFormattedCoordinates(par2, par3, par4))), EnumChatFormatting.BLUE);
                ((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).setSentMessage();
            }
            if (par1World.getTileEntity(par2, par3, par4) != null && par1World.getTileEntity(par2, par3, par4) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.REDSTONE)) {
                togglePowerOutput(par1World, par2, par3, par4, true);
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) INameable(net.geforcemods.securitycraft.api.INameable) TileEntityPortableRadar(net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 3 with CustomizableSCTE

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

the class ModuleUtils method getPlayersFromModule.

/**
	 * Gets the players added to customizable modules (such as the Whitelist Module.) <p>
	 * 
	 * Args: world, x, y, z, moduleType.
	 */
public static List<String> getPlayersFromModule(World par1World, int par2, int par3, int par4, EnumCustomModules module) {
    List<String> list = new ArrayList<String>();
    CustomizableSCTE te = (CustomizableSCTE) par1World.getTileEntity(par2, par3, par4);
    if (te.hasModule(module)) {
        ItemStack item = te.getModule(module);
        for (int i = 1; i <= 10; i++) {
            if (item.stackTagCompound != null && item.stackTagCompound.getString("Player" + i) != null && !item.stackTagCompound.getString("Player" + i).isEmpty()) {
                list.add(item.stackTagCompound.getString("Player" + i).toLowerCase());
            }
        }
    }
    return list;
}
Also used : CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 4 with CustomizableSCTE

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

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

the class BlockPortableRadar method searchForPlayers.

public static void searchForPlayers(World par1World, BlockPos pos, IBlockState state) {
    if (!par1World.isRemote) {
        double d0 = (mod_SecurityCraft.configHandler.portableRadarSearchRadius);
        AxisAlignedBB axisalignedbb = BlockUtils.fromBounds(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1).expand(d0, d0, d0).addCoord(0.0D, par1World.getHeight(), 0.0D);
        List<?> list = par1World.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
        Iterator<?> iterator = list.iterator();
        EntityPlayer entityplayer;
        if (list.isEmpty()) {
            if (par1World.getTileEntity(pos) != null && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(pos)).hasModule(EnumCustomModules.REDSTONE) && state.getValue(POWERED).booleanValue()) {
                togglePowerOutput(par1World, pos, false);
                return;
            }
        }
        if (!((CustomizableSCTE) par1World.getTileEntity(pos)).hasModule(EnumCustomModules.REDSTONE)) {
            togglePowerOutput(par1World, pos, false);
        }
        while (iterator.hasNext()) {
            EntityPlayerMP entityplayermp = par1World.getMinecraftServer().getPlayerList().getPlayerByUsername(((TileEntityPortableRadar) par1World.getTileEntity(pos)).getOwner().getName());
            entityplayer = (EntityPlayer) iterator.next();
            if (entityplayermp != null && ((CustomizableSCTE) par1World.getTileEntity(pos)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, pos, EnumCustomModules.WHITELIST).contains(entityplayermp.getName().toLowerCase())) {
                continue;
            }
            if (PlayerUtils.isPlayerOnline(((TileEntityPortableRadar) par1World.getTileEntity(pos)).getOwner().getName())) {
                if (!((TileEntityPortableRadar) par1World.getTileEntity(pos)).shouldSendMessage(entityplayer)) {
                    continue;
                }
                PlayerUtils.sendMessageToPlayer(entityplayermp, I18n.translateToLocal("tile.portableRadar.name"), ((INameable) par1World.getTileEntity(pos)).hasCustomName() ? (I18n.translateToLocal("messages.portableRadar.withName").replace("#p", TextFormatting.ITALIC + entityplayer.getName() + TextFormatting.RESET).replace("#n", TextFormatting.ITALIC + ((INameable) par1World.getTileEntity(pos)).getCustomName() + TextFormatting.RESET)) : (I18n.translateToLocal("messages.portableRadar.withoutName").replace("#p", TextFormatting.ITALIC + entityplayer.getName() + TextFormatting.RESET).replace("#l", Utils.getFormattedCoordinates(pos))), TextFormatting.BLUE);
                ((TileEntityPortableRadar) par1World.getTileEntity(pos)).setSentMessage();
            }
            if (par1World.getTileEntity(pos) != null && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(pos)).hasModule(EnumCustomModules.REDSTONE)) {
                togglePowerOutput(par1World, pos, true);
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) INameable(net.geforcemods.securitycraft.api.INameable) TileEntityPortableRadar(net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Aggregations

CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)21 TileEntity (net.minecraft.tileentity.TileEntity)10 Block (net.minecraft.block.Block)9 IOwnable (net.geforcemods.securitycraft.api.IOwnable)8 ItemStack (net.minecraft.item.ItemStack)8 IPasswordProtected (net.geforcemods.securitycraft.api.IPasswordProtected)6 INameable (net.geforcemods.securitycraft.api.INameable)5 EnumCustomModules (net.geforcemods.securitycraft.misc.EnumCustomModules)4 TileEntityPortableRadar (net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 ArrayList (java.util.ArrayList)2 IExplosive (net.geforcemods.securitycraft.api.IExplosive)2 TileEntitySCTE (net.geforcemods.securitycraft.api.TileEntitySCTE)2 BlockLaserBlock (net.geforcemods.securitycraft.blocks.BlockLaserBlock)2 CustomHoverChecker (net.geforcemods.securitycraft.gui.components.CustomHoverChecker)2 ItemModule (net.geforcemods.securitycraft.items.ItemModule)2 TileEntityKeycardReader (net.geforcemods.securitycraft.tileentity.TileEntityKeycardReader)2 TileEntityKeypad (net.geforcemods.securitycraft.tileentity.TileEntityKeypad)2 ITileEntityProvider (net.minecraft.block.ITileEntityProvider)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2