Search in sources :

Example 1 with TileEntityPortableRadar

use of net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar 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().getPlayerByUsername(((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 2 with TileEntityPortableRadar

use of net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar 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 = (SecurityCraft.config.portableRadarSearchRadius);
        AxisAlignedBB axisalignedbb = AxisAlignedBB.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) && ((Boolean) 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 = MinecraftServer.getServer().getConfigurationManager().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.getCommandSenderName().toLowerCase()))
                continue;
            if (PlayerUtils.isPlayerOnline(((TileEntityPortableRadar) par1World.getTileEntity(pos)).getOwner().getName())) {
                if (!((TileEntityPortableRadar) par1World.getTileEntity(pos)).shouldSendMessage(entityplayer))
                    continue;
                PlayerUtils.sendMessageToPlayer(entityplayermp, StatCollector.translateToLocal("tile.portableRadar.name"), ((INameable) par1World.getTileEntity(pos)).hasCustomName() ? (StatCollector.translateToLocal("messages.portableRadar.withName").replace("#p", EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET).replace("#n", EnumChatFormatting.ITALIC + ((INameable) par1World.getTileEntity(pos)).getCustomName() + EnumChatFormatting.RESET)) : (StatCollector.translateToLocal("messages.portableRadar.withoutName").replace("#p", EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET).replace("#l", Utils.getFormattedCoordinates(pos))), EnumChatFormatting.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.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 TileEntityPortableRadar

use of net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar 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)

Aggregations

CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)3 TileEntityPortableRadar (net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar)3 INameable (net.geforcemods.securitycraft.api.INameable)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)2 Owner (net.geforcemods.securitycraft.api.Owner)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 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1