示例#1
0
 public static EntityLivingBase searchEntityByNameRaw(String name) {
   EntityLivingBase newEntity = null;
   for (Object o : Minecraft.getMinecraft().theWorld.loadedEntityList)
     if (isCorrectEntity(o, false)) {
       EntityLivingBase en = (EntityLivingBase) o;
       if (!(o instanceof EntityPlayerSP) && !en.isDead)
         if (newEntity == null && en.getName().equals(name)) newEntity = en;
     }
   return newEntity;
 }
示例#2
0
 public void onBlockPlacedBy(
     World par1World,
     BlockPos pos,
     IBlockState state,
     EntityLivingBase par5EntityLivingBase,
     ItemStack par6ItemStack) {
   if (!par1World.isRemote) {
     if (par5EntityLivingBase instanceof EntityPlayer) {
       ((TileEntityOwnable) par1World.getTileEntity(pos))
           .setOwner(
               ((EntityPlayer) par5EntityLivingBase).getGameProfile().getId().toString(),
               par5EntityLivingBase.getName());
     }
   }
 }
示例#3
0
 public static ArrayList<EntityLivingBase> getCloseEntities(boolean ignoreFriends, float range) {
   ArrayList<EntityLivingBase> closeEntities = new ArrayList<EntityLivingBase>();
   for (Object o : Minecraft.getMinecraft().theWorld.loadedEntityList)
     if (isCorrectEntity(o, ignoreFriends)) {
       EntityLivingBase en = (EntityLivingBase) o;
       if (!(o instanceof EntityPlayerSP)
           && !en.isDead
           && en.getHealth() > 0
           && Minecraft.getMinecraft().thePlayer.canEntityBeSeen(en)
           && !en.getName().equals(Minecraft.getMinecraft().thePlayer.getName())
           && Minecraft.getMinecraft().thePlayer.getDistanceToEntity(en) <= range)
         closeEntities.add(en);
     }
   return closeEntities;
 }
示例#4
0
 public static EntityLivingBase getClosestEntity(boolean ignoreFriends, boolean useFOV) {
   EntityLivingBase closestEntity = null;
   for (Object o : Minecraft.getMinecraft().theWorld.loadedEntityList)
     if (isCorrectEntity(o, ignoreFriends)
         && getDistanceFromMouse((Entity) o)
             <= ((KillauraMod) WurstClient.INSTANCE.modManager.getModByClass(KillauraMod.class))
                     .fov
                 / 2) {
       EntityLivingBase en = (EntityLivingBase) o;
       if (!(o instanceof EntityPlayerSP)
           && !en.isDead
           && en.getHealth() > 0
           && Minecraft.getMinecraft().thePlayer.canEntityBeSeen(en)
           && !en.getName().equals(Minecraft.getMinecraft().thePlayer.getName()))
         if (closestEntity == null
             || Minecraft.getMinecraft().thePlayer.getDistanceToEntity(en)
                 < Minecraft.getMinecraft().thePlayer.getDistanceToEntity(closestEntity))
           closestEntity = en;
     }
   return closestEntity;
 }
  public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    if (args.length < 2) {
      throw new WrongUsageException("commands.effect.usage", new Object[0]);
    } else {
      EntityLivingBase var3 =
          (EntityLivingBase) func_175759_a(sender, args[0], EntityLivingBase.class);

      if (args[1].equals("clear")) {
        if (var3.getActivePotionEffects().isEmpty()) {
          throw new CommandException(
              "commands.effect.failure.notActive.all", new Object[] {var3.getName()});
        } else {
          var3.clearActivePotions();
          notifyOperators(
              sender, this, "commands.effect.success.removed.all", new Object[] {var3.getName()});
        }
      } else {
        int var4;

        try {
          var4 = parseInt(args[1], 1);
        } catch (NumberInvalidException var11) {
          Potion var6 = Potion.getPotionAtLocation(args[1]);

          if (var6 == null) {
            throw var11;
          }

          var4 = var6.id;
        }

        int var5 = 600;
        int var12 = 30;
        int var7 = 0;

        if (var4 >= 0 && var4 < Potion.potionTypes.length && Potion.potionTypes[var4] != null) {
          Potion var8 = Potion.potionTypes[var4];

          if (args.length >= 3) {
            var12 = parseInt(args[2], 0, 1000000);

            if (var8.isInstant()) {
              var5 = var12;
            } else {
              var5 = var12 * 20;
            }
          } else if (var8.isInstant()) {
            var5 = 1;
          }

          if (args.length >= 4) {
            var7 = parseInt(args[3], 0, 255);
          }

          boolean var9 = true;

          if (args.length >= 5 && "true".equalsIgnoreCase(args[4])) {
            var9 = false;
          }

          if (var12 > 0) {
            PotionEffect var10 = new PotionEffect(var4, var5, var7, false, var9);
            var3.addPotionEffect(var10);
            notifyOperators(
                sender,
                this,
                "commands.effect.success",
                new Object[] {
                  new FormattedTextTranslation(var10.getEffectName(), new Object[0]),
                  Integer.valueOf(var4),
                  Integer.valueOf(var7),
                  var3.getName(),
                  Integer.valueOf(var12)
                });
          } else if (var3.isPotionActive(var4)) {
            var3.removePotionEffect(var4);
            notifyOperators(
                sender,
                this,
                "commands.effect.success.removed",
                new Object[] {
                  new FormattedTextTranslation(var8.getName(), new Object[0]), var3.getName()
                });
          } else {
            throw new CommandException(
                "commands.effect.failure.notActive",
                new Object[] {
                  new FormattedTextTranslation(var8.getName(), new Object[0]), var3.getName()
                });
          }
        } else {
          throw new NumberInvalidException(
              "commands.effect.notFound", new Object[] {Integer.valueOf(var4)});
        }
      }
    }
  }