@Override
  public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase player) {
    if (player.worldObj.isRemote) return true;
    if (victim instanceof EntityPlayer) {
      EntityPlayer pvp = (EntityPlayer) victim;
      if (LudicrousItems.isInfinite(pvp)) {
        victim.attackEntityFrom(
            new DamageSourceInfinitySword(player).setDamageBypassesArmor(), 4.0F);
        return true;
      }
      if (pvp.getHeldItem() != null
          && pvp.getHeldItem().getItem() == LudicrousItems.infinity_sword
          && pvp.isUsingItem()) return true;
    }

    try {
      stupidMojangProtectedVariable.setInt(victim, 60);
    } catch (Exception e) {
      Lumberjack.log(Level.ERROR, e, "The sword isn't reflecting right! Polish it!");
    }
    victim
        .func_110142_aN()
        .func_94547_a(
            new DamageSourceInfinitySword(player), victim.getHealth(), victim.getHealth());
    victim.setHealth(0);
    victim.onDeath(new EntityDamageSource("infinity", player));
    return true;
  }
Exemplo n.º 2
0
 public void performEffect(EntityLivingBase p_76394_1_, int p_76394_2_) {
   if (this.id == REGENERATION.id) {
     if (p_76394_1_.getHealth() < p_76394_1_.getMaxHealth()) {
       p_76394_1_.heal(1.0F);
     }
   } else if (this.id == POISON.id) {
     if (p_76394_1_.getHealth() > 1.0F) {
       p_76394_1_.attackEntityFrom(DamageSource.magic, 1.0F);
     }
   } else if (this.id == WITHER.id) {
     p_76394_1_.attackEntityFrom(DamageSource.wither, 1.0F);
   } else if (this.id == HUNGER.id && p_76394_1_ instanceof EntityPlayer) {
     ((EntityPlayer) p_76394_1_).addExhaustion(0.025F * (float) (p_76394_2_ + 1));
   } else if (this.id == SATURATION.id && p_76394_1_ instanceof EntityPlayer) {
     if (!p_76394_1_.worldObj.isRemote) {
       ((EntityPlayer) p_76394_1_).getFoodStats().addStats(p_76394_2_ + 1, 1.0F);
     }
   } else if ((this.id != INSTANT_HEALTH.id || p_76394_1_.isEntityUndead())
       && (this.id != INSTANT_DAMAGE.id || !p_76394_1_.isEntityUndead())) {
     if (this.id == INSTANT_DAMAGE.id && !p_76394_1_.isEntityUndead()
         || this.id == INSTANT_HEALTH.id && p_76394_1_.isEntityUndead()) {
       p_76394_1_.attackEntityFrom(DamageSource.magic, (float) (6 << p_76394_2_));
     }
   } else {
     p_76394_1_.heal((float) Math.max(4 << p_76394_2_, 0));
   }
 }
Exemplo n.º 3
0
 @Override
 protected boolean isValidTarget(Entity ent) {
   if (ent instanceof TargetEntity) return ((TargetEntity) ent).shouldTarget(this, placerUUID);
   if (!(ent instanceof EntityLivingBase)) return false;
   EntityLivingBase elb = (EntityLivingBase) ent;
   if (elb.isDead || elb.getHealth() <= 0) return false;
   if (ent.onGround || ent.isInWater() || ent.isInsideOfMaterial(Material.lava)) return false;
   if (elb instanceof EntityFlying && ReikaEntityHelper.isHostile(elb)) {
     return ReikaMathLibrary.py3d(
             ent.posX - xCoord - 0.5, ent.posY - yCoord - 0.5, ent.posZ - zCoord - 0.5)
         > 2;
   }
   if (ent instanceof EntityBlaze || ent instanceof EntityWither || ent instanceof EntityDragon) {
     return ReikaMathLibrary.py3d(
             ent.posX - xCoord - 0.5, ent.posY - yCoord - 0.5, ent.posZ - zCoord - 0.5)
         > 2;
   }
   if (ent instanceof FlyingMob) {
     FlyingMob fm = (FlyingMob) ent;
     return fm.isCurrentlyFlying()
         && fm.isHostile()
         && ReikaMathLibrary.py3d(
                 ent.posX - xCoord - 0.5, ent.posY - yCoord - 0.5, ent.posZ - zCoord - 0.5)
             > 2;
   }
   if (InterfaceCache.BCROBOT.instanceOf(ent)) {
     return true;
   }
   return false;
 }
Exemplo n.º 4
0
  public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLiving, float par2) {
    if (!this.getAggressive()) {
      EntityPotion var2 = new EntityPotion(this.worldObj, this, 32732);
      var2.rotationPitch -= -20.0F;
      double var3 = par1EntityLiving.posX + par1EntityLiving.motionX - this.posX;
      double var5 =
          par1EntityLiving.posY
              + (double) par1EntityLiving.getEyeHeight()
              - 1.100000023841858D
              - this.posY;
      double var7 = par1EntityLiving.posZ + par1EntityLiving.motionZ - this.posZ;
      float var9 = MathHelper.sqrt_double(var3 * var3 + var7 * var7);
      if (var9 >= 8.0F && !par1EntityLiving.isPotionActive(Potion.moveSlowdown)) {
        var2.setPotionDamage(32698);
      } else if (par1EntityLiving.getHealth() >= 8.0F
          && !par1EntityLiving.isPotionActive(Potion.poison)) {
        var2.setPotionDamage(32660);
      } else if (var9 <= 3.0F
          && !par1EntityLiving.isPotionActive(Potion.weakness)
          && this.rand.nextFloat() < 0.25F) {
        var2.setPotionDamage(32696);
      }

      var2.setThrowableHeading(var3, var5 + (double) (var9 * 0.2F), var7, 0.75F, 8.0F);
      this.worldObj.spawnEntityInWorld(var2);
    }
  }
Exemplo n.º 5
0
 @Override
 public boolean itemInteractionForEntity(
     ItemStack itemStack, EntityPlayer player, EntityLivingBase entity) {
   if (entity.worldObj.isRemote) {
     return false;
   } else {
     ItemStack container;
     switch (itemStack.getItemDamage()) {
       case 0:
         break;
       case 1:
         container = LifeSystem.findFilledLifeContainer(player.inventory.mainInventory);
         if (container != null && entity.getHealth() < entity.getMaxHealth()) {
           if (((ILifeContainer) container.getItem()).takeLife(container, 1) > 0) {
             entity.heal(1f);
             player.addStat(ModAchievements.useLP, 1);
             return true;
           }
         }
         break;
       case 2:
         break;
     }
   }
   return false;
 }
 @Override
 protected boolean isValidTarget(Entity ent) {
   if (ent.isDead) return false;
   if (ent instanceof TargetEntity) return ((TargetEntity) ent).shouldTarget(this, placerUUID);
   if (!(ent instanceof EntityLivingBase)) return false;
   EntityLivingBase elb = (EntityLivingBase) ent;
   return elb.getHealth() > 0 && this.isMobOrUnlistedPlayer(elb);
 }
Exemplo n.º 7
0
 @Override
 public void onHeld(
     ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
   if (par3Entity instanceof EntityLivingBase) {
     if (!par2World.isRemote && par2World.rand.nextInt(100) == 0) { // about 5 seconds
       EntityLivingBase elb = (EntityLivingBase) par3Entity;
       elb.setHealth(elb.getHealth() + 1);
       // elb.heal(1F);
     }
   }
 }
Exemplo n.º 8
0
 public static EntityLivingBase getClosestEntityRaw(boolean ignoreFriends) {
   EntityLivingBase closestEntity = null;
   for (Object o : Minecraft.getMinecraft().theWorld.loadedEntityList)
     if (isCorrectEntity(o, ignoreFriends)) {
       EntityLivingBase en = (EntityLivingBase) o;
       if (!(o instanceof EntityPlayerSP) && !en.isDead && en.getHealth() > 0)
         if (closestEntity == null
             || Minecraft.getMinecraft().thePlayer.getDistanceToEntity(en)
                 < Minecraft.getMinecraft().thePlayer.getDistanceToEntity(closestEntity))
           closestEntity = en;
     }
   return closestEntity;
 }
Exemplo n.º 9
0
  @SubscribeEvent
  public void onEntityHurt(LivingHurtEvent event) {
    EntityLivingBase entity = event.entityLiving;
    if (entity instanceof EntityPlayer) {
      float curMaxHealth =
          (float)
              ((EntityPlayer) entity)
                  .getEntityAttribute(SharedMonsterAttributes.maxHealth)
                  .getAttributeValue();
      float newMaxHealth = FoodStatsTFC.getMaxHealth((EntityPlayer) entity);
      float h = ((EntityPlayer) entity).getHealth();
      if (newMaxHealth != curMaxHealth)
        ((EntityPlayer) entity)
            .getEntityAttribute(SharedMonsterAttributes.maxHealth)
            .setBaseValue(newMaxHealth);
      if (newMaxHealth < h) ((EntityPlayer) entity).setHealth(newMaxHealth);
    }

    if (event.source == DamageSource.onFire) {
      event.ammount = 50;
    } else if (event.source == DamageSource.fall) {
      float healthMod = TFC_Core.getEntityMaxHealth(entity) / 1000f;
      event.ammount *= 80 * healthMod;
    } else if (event.source == DamageSource.drown) {
      event.ammount = 50;
    } else if (event.source == DamageSource.lava) {
      event.ammount = 100;
    } else if (event.source == DamageSource.inWall) {
      event.ammount = 100;
    } else if (event.source == DamageSource.fallingBlock) {
      event.ammount = 100;
    } else if (event.source.isExplosion()) {
      event.ammount *= 30;
    } else if (event.source == DamageSource.magic && entity.getHealth() > 25) {
      event.ammount = 25;
    } else if ("player".equals(event.source.damageType)
        || "mob".equals(event.source.damageType)
        || "arrow".equals(event.source.damageType)) {
      event.ammount = applyArmorCalculations(entity, event.source, event.ammount);
      if ("arrow".equals(event.source.damageType)) {
        Entity e = ((EntityDamageSourceIndirect) event.source).getSourceOfDamage();
        if (e instanceof EntityJavelin) {
          ((EntityJavelin) e).setDamageTaken((short) (((EntityJavelin) e).damageTaken + 10));
          if (((EntityJavelin) e).damageTaken >= ((EntityJavelin) e).pickupItem.getMaxDamage()) {
            e.setDead();
          }
        }
      }
    }
  }
Exemplo n.º 10
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;
 }
  public boolean hitEntity(
      ItemStack par1ItemStack, EntityLivingBase targetEntity, EntityLivingBase entityActed) {
    // Drain
    float damage =
        EntityInfo.instance().<Float>get(entityActed.getEntityId(), DataType.DiamondSwordAttack)
            - targetEntity.getHealth();
    if (damage > 0.0f) {
      int lvl = TcEnchantmentHelper.getDrainModifier(entityActed);
      entityActed.heal(damage * (lvl * 0.1f + 0.1f));
    }

    EntityInfo.instance().remove(entityActed.getEntityId(), DataType.DiamondSwordAttack);

    return super.hitEntity(par1ItemStack, targetEntity, entityActed);
  }
Exemplo n.º 12
0
  @Override
  public boolean onUse(final EntityPlayer player) {
    if (player.worldObj.isRemote) {
      return false;
    }

    Entity targetCl = Minecraft.getMinecraft().pointedEntity;
    Entity targetSr = null;

    if (targetCl != null) {
      targetSr = player.worldObj.getEntityByID(targetCl.getEntityId());
    }

    float base =
        (float) player.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
    float extra = new Random().nextFloat() * 1024 / (2048 - this.getExperience(player));

    if (targetSr instanceof EntityLivingBase) {
      EntityLivingBase entity = (EntityLivingBase) targetSr;
      if (entity instanceof EntitySlime) {
        base = Math.min(base / 5, entity.getHealth() - 0.1F);
        extra = 0F;
      }
      entity.attackEntityFrom(DamageSource.causePlayerDamage(player), base);
      entity.attackEntityFrom(NullaDamageSource.CauseAuroraDamage(player), base * extra);
      double vx = 0.2D * (entity.posX - player.posX);
      double vy = 0.2D * (entity.posY - player.posY + 2D);
      double vz = 0.2D * (entity.posZ - player.posZ);
      Minecraft.getMinecraft().thePlayer.setVelocity(vx, vy, vz);

    } else {
      return false;
    }

    if (player.getHeldItem() != null) {
      player.getHeldItem().damageItem(16, player);
    }

    // 随机事件只在服务器发生
    if (!player.worldObj.isRemote) {
      Random rand = new Random();
      int exp = rand.nextInt(5) + 1;
      modifyExperience(player, exp);
    }

    return true;
  }
Exemplo n.º 13
0
 public static EntityLivingBase getClosestEnemy(EntityLivingBase friend) {
   EntityLivingBase closestEnemy = null;
   for (Object o : Minecraft.getMinecraft().theWorld.loadedEntityList)
     if (isCorrectEntity(o, true)) {
       EntityLivingBase en = (EntityLivingBase) o;
       if (!(o instanceof EntityPlayerSP)
           && o != friend
           && !en.isDead
           && en.getHealth() <= 0 == false
           && Minecraft.getMinecraft().thePlayer.canEntityBeSeen(en))
         if (closestEnemy == null
             || Minecraft.getMinecraft().thePlayer.getDistanceToEntity(en)
                 < Minecraft.getMinecraft().thePlayer.getDistanceToEntity(closestEnemy))
           closestEnemy = en;
     }
   return closestEnemy;
 }
Exemplo n.º 14
0
  protected void renderHealthMount(int width, int height) {
    EntityPlayer player = (EntityPlayer) mc.getRenderViewEntity();
    Entity tmp = player.ridingEntity;
    if (!(tmp instanceof EntityLivingBase)) return;

    bind(icons);

    if (pre(HEALTHMOUNT)) return;

    boolean unused = false;
    int left_align = width / 2 + 91;

    mc.mcProfiler.endStartSection("mountHealth");
    GlStateManager.enableBlend();
    EntityLivingBase mount = (EntityLivingBase) tmp;
    int health = (int) Math.ceil((double) mount.getHealth());
    float healthMax = mount.getMaxHealth();
    int hearts = (int) (healthMax + 0.5F) / 2;

    if (hearts > 30) hearts = 30;

    final int MARGIN = 52;
    final int BACKGROUND = MARGIN + (unused ? 1 : 0);
    final int HALF = MARGIN + 45;
    final int FULL = MARGIN + 36;

    for (int heart = 0; hearts > 0; heart += 20) {
      int top = height - right_height;

      int rowCount = Math.min(hearts, 10);
      hearts -= rowCount;

      for (int i = 0; i < rowCount; ++i) {
        int x = left_align - i * 8 - 9;
        drawTexturedModalRect(x, top, BACKGROUND, 9, 9, 9);

        if (i * 2 + 1 + heart < health) drawTexturedModalRect(x, top, FULL, 9, 9, 9);
        else if (i * 2 + 1 + heart == health) drawTexturedModalRect(x, top, HALF, 9, 9, 9);
      }

      right_height += 10;
    }
    GlStateManager.disableBlend();
    post(HEALTHMOUNT);
  }
Exemplo n.º 15
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;
 }
  @Override
  public void updateEntity() {
    if (worldObj.isRemote) {
      this.rotation += this.rotationIncrement;
    } else {
      surroundingCheckTicks++;
    }

    if (worldObj.isRemote || ticksSinceLastEntityScan++ > 25) {
      updateNearbyEntities();
      ticksSinceLastEntityScan = 0;
    }

    Iterator<EntityLivingBase> it = cachedEntities.iterator();
    while (it.hasNext()) {

      EntityLivingBase ent = it.next();

      if (ent.isDead) {
        it.remove();
        continue;
      }

      MovingObjectPosition mop =
          this.worldObj.rayTraceBlocks(
              Vec3.createVectorHelper(xCoord + 0.5, yCoord + 1.5, zCoord + 0.5),
              Vec3.createVectorHelper(ent.posX, ent.posY + ent.getEyeHeight(), ent.posZ),
              false);

      if (EntityUtilities.isSummon(ent) || mop != null) {
        continue;
      }

      ent.motionY = 0;
      ent.motionX = 0;
      ent.motionZ = 0;
      double deltaX = this.xCoord + 0.5f - ent.posX;
      double deltaZ = this.zCoord + 0.5f - ent.posZ;
      double deltaY = this.yCoord - ent.posY;
      double angle = Math.atan2(deltaZ, deltaX);

      double offsetX = Math.cos(angle) * 0.1;
      double offsetZ = Math.sin(angle) * 0.1;
      double offsetY = 0.05f;

      double distanceHorizontal = deltaX * deltaX + deltaZ * deltaZ;
      double distanceVertical = this.yCoord - ent.posY;
      boolean spawnedParticles = false;

      if (distanceHorizontal < 1.3) {
        if (distanceVertical < -1.5) {
          if (worldObj.isRemote && worldObj.rand.nextInt(10) < 3) {
            AMCore.proxy.particleManager.BoltFromPointToPoint(
                worldObj,
                xCoord + 0.5,
                yCoord + 1.3,
                zCoord + 0.5,
                ent.posX,
                ent.posY,
                ent.posZ,
                4,
                0x000000);
          }
        }
        if (distanceVertical < -2) {
          offsetY = 0;
          if (!worldObj.isRemote) {
            if (ent.attackEntityFrom(DamageSources.darkNexus, 4)) {
              if (ent.getHealth() <= 0) {
                ent.setDead();
                float power =
                    ((int) Math.ceil((ent.getMaxHealth() * (ent.ticksExisted / 20)) % 5000))
                        * this.powerMultiplier;
                PowerNodeRegistry.For(this.worldObj).insertPower(this, PowerTypes.DARK, power);
              }
            }
          }
        }
      }

      if (worldObj.isRemote) {
        if (!arcs.containsKey(ent)) {
          AMLineArc arc =
              (AMLineArc)
                  AMCore.proxy.particleManager.spawn(
                      worldObj,
                      "textures/blocks/oreblocksunstone.png",
                      xCoord + 0.5,
                      yCoord + 1.3,
                      zCoord + 0.5,
                      ent);
          if (arc != null) {
            arc.setExtendToTarget();
            arc.setRBGColorF(1, 1, 1);
          }
          arcs.put(ent, arc);
        }
        Iterator arcIterator = arcs.keySet().iterator();
        ArrayList<Entity> toRemove = new ArrayList<Entity>();
        while (arcIterator.hasNext()) {
          Entity arcEnt = (Entity) arcIterator.next();
          AMLineArc arc = (AMLineArc) arcs.get(arcEnt);
          if (arcEnt == null
              || arcEnt.isDead
              || arc == null
              || arc.isDead
              || new AMVector3(ent).distanceSqTo(new AMVector3(xCoord, yCoord, zCoord)) > 100)
            toRemove.add(arcEnt);
        }

        for (Entity e : toRemove) {
          arcs.remove(e);
        }
      }
      if (!worldObj.isRemote) ent.moveEntity(offsetX, offsetY, offsetZ);
    }
    if (surroundingCheckTicks % 100 == 0) {
      checkNearbyBlockState();
      surroundingCheckTicks = 1;
      if (!worldObj.isRemote
          && PowerNodeRegistry.For(this.worldObj).checkPower(this, this.capacity * 0.1f)) {
        List<EntityPlayer> nearbyPlayers =
            worldObj.getEntitiesWithinAABB(
                EntityPlayer.class,
                AxisAlignedBB.getBoundingBox(
                    this.xCoord - 2,
                    this.yCoord,
                    this.zCoord - 2,
                    this.xCoord + 2,
                    this.yCoord + 3,
                    this.zCoord + 2));
        for (EntityPlayer p : nearbyPlayers) {
          if (p.isPotionActive(BuffList.manaRegen.id)) continue;
          p.addPotionEffect(new BuffEffectManaRegen(600, 3));
        }
      }

      // TODO:
      /*if (rand.nextDouble() < (this.getCharge() / this.getCapacity()) * 0.01){
      	int maxSev = (int)Math.ceil((this.getCharge() / this.getCapacity()) * 2) + rand.nextInt(2);
      	IllEffectsManager.instance.ApplyRandomBadThing(this, IllEffectSeverity.values()[maxSev], BadThingTypes.DARKNEXUS);
      }*/
    }

    super.callSuperUpdate();
  }
Exemplo n.º 17
0
  private void func_180477_d(ScaledResolution p_180477_1_) {
    if (this.mc.func_175606_aa() instanceof EntityPlayer) {
      EntityPlayer var2 = (EntityPlayer) this.mc.func_175606_aa();
      int var3 = MathHelper.ceiling_float_int(var2.getHealth());
      boolean var4 =
          this.field_175191_F > (long) this.updateCounter
              && (this.field_175191_F - (long) this.updateCounter) / 3L % 2L == 1L;

      if (var3 < this.field_175194_C && var2.hurtResistantTime > 0) {
        this.field_175190_E = Minecraft.getSystemTime();
        this.field_175191_F = (long) (this.updateCounter + 20);
      } else if (var3 > this.field_175194_C && var2.hurtResistantTime > 0) {
        this.field_175190_E = Minecraft.getSystemTime();
        this.field_175191_F = (long) (this.updateCounter + 10);
      }

      if (Minecraft.getSystemTime() - this.field_175190_E > 1000L) {
        this.field_175194_C = var3;
        this.field_175189_D = var3;
        this.field_175190_E = Minecraft.getSystemTime();
      }

      this.field_175194_C = var3;
      int var5 = this.field_175189_D;
      this.rand.setSeed((long) (this.updateCounter * 312871));
      boolean var6 = false;
      FoodStats var7 = var2.getFoodStats();
      int var8 = var7.getFoodLevel();
      int var9 = var7.getPrevFoodLevel();
      IAttributeInstance var10 = var2.getEntityAttribute(SharedMonsterAttributes.maxHealth);
      int var11 = p_180477_1_.getScaledWidth() / 2 - 91;
      int var12 = p_180477_1_.getScaledWidth() / 2 + 91;
      int var13 = p_180477_1_.getScaledHeight() - 39;
      float var14 = (float) var10.getAttributeValue();
      float var15 = var2.getAbsorptionAmount();
      int var16 = MathHelper.ceiling_float_int((var14 + var15) / 2.0F / 10.0F);
      int var17 = Math.max(10 - (var16 - 2), 3);
      int var18 = var13 - (var16 - 1) * var17 - 10;
      float var19 = var15;
      int var20 = var2.getTotalArmorValue();
      int var21 = -1;

      if (var2.isPotionActive(Potion.regeneration)) {
        var21 = this.updateCounter % MathHelper.ceiling_float_int(var14 + 5.0F);
      }

      this.mc.mcProfiler.startSection("armor");
      int var22;
      int var23;

      for (var22 = 0; var22 < 10; ++var22) {
        if (var20 > 0) {
          var23 = var11 + var22 * 8;

          if (var22 * 2 + 1 < var20) {
            this.drawTexturedModalRect(var23, var18, 34, 9, 9, 9);
          }

          if (var22 * 2 + 1 == var20) {
            this.drawTexturedModalRect(var23, var18, 25, 9, 9, 9);
          }

          if (var22 * 2 + 1 > var20) {
            this.drawTexturedModalRect(var23, var18, 16, 9, 9, 9);
          }
        }
      }

      this.mc.mcProfiler.endStartSection("health");
      int var25;
      int var26;
      int var27;

      for (var22 = MathHelper.ceiling_float_int((var14 + var15) / 2.0F) - 1; var22 >= 0; --var22) {
        var23 = 16;

        if (var2.isPotionActive(Potion.poison)) {
          var23 += 36;
        } else if (var2.isPotionActive(Potion.wither)) {
          var23 += 72;
        }

        byte var24 = 0;

        if (var4) {
          var24 = 1;
        }

        var25 = MathHelper.ceiling_float_int((float) (var22 + 1) / 10.0F) - 1;
        var26 = var11 + var22 % 10 * 8;
        var27 = var13 - var25 * var17;

        if (var3 <= 4) {
          var27 += this.rand.nextInt(2);
        }

        if (var22 == var21) {
          var27 -= 2;
        }

        byte var28 = 0;

        if (var2.worldObj.getWorldInfo().isHardcoreModeEnabled()) {
          var28 = 5;
        }

        this.drawTexturedModalRect(var26, var27, 16 + var24 * 9, 9 * var28, 9, 9);

        if (var4) {
          if (var22 * 2 + 1 < var5) {
            this.drawTexturedModalRect(var26, var27, var23 + 54, 9 * var28, 9, 9);
          }

          if (var22 * 2 + 1 == var5) {
            this.drawTexturedModalRect(var26, var27, var23 + 63, 9 * var28, 9, 9);
          }
        }

        if (var19 > 0.0F) {
          if (var19 == var15 && var15 % 2.0F == 1.0F) {
            this.drawTexturedModalRect(var26, var27, var23 + 153, 9 * var28, 9, 9);
          } else {
            this.drawTexturedModalRect(var26, var27, var23 + 144, 9 * var28, 9, 9);
          }

          var19 -= 2.0F;
        } else {
          if (var22 * 2 + 1 < var3) {
            this.drawTexturedModalRect(var26, var27, var23 + 36, 9 * var28, 9, 9);
          }

          if (var22 * 2 + 1 == var3) {
            this.drawTexturedModalRect(var26, var27, var23 + 45, 9 * var28, 9, 9);
          }
        }
      }

      Entity var34 = var2.ridingEntity;
      int var36;

      if (var34 == null) {
        this.mc.mcProfiler.endStartSection("food");

        for (var23 = 0; var23 < 10; ++var23) {
          var36 = var13;
          var25 = 16;
          byte var38 = 0;

          if (var2.isPotionActive(Potion.hunger)) {
            var25 += 36;
            var38 = 13;
          }

          if (var2.getFoodStats().getSaturationLevel() <= 0.0F
              && this.updateCounter % (var8 * 3 + 1) == 0) {
            var36 = var13 + (this.rand.nextInt(3) - 1);
          }

          if (var6) {
            var38 = 1;
          }

          var27 = var12 - var23 * 8 - 9;
          this.drawTexturedModalRect(var27, var36, 16 + var38 * 9, 27, 9, 9);

          if (var6) {
            if (var23 * 2 + 1 < var9) {
              this.drawTexturedModalRect(var27, var36, var25 + 54, 27, 9, 9);
            }

            if (var23 * 2 + 1 == var9) {
              this.drawTexturedModalRect(var27, var36, var25 + 63, 27, 9, 9);
            }
          }

          if (var23 * 2 + 1 < var8) {
            this.drawTexturedModalRect(var27, var36, var25 + 36, 27, 9, 9);
          }

          if (var23 * 2 + 1 == var8) {
            this.drawTexturedModalRect(var27, var36, var25 + 45, 27, 9, 9);
          }
        }
      } else if (var34 instanceof EntityLivingBase) {
        this.mc.mcProfiler.endStartSection("mountHealth");
        EntityLivingBase var35 = (EntityLivingBase) var34;
        var36 = (int) Math.ceil((double) var35.getHealth());
        float var37 = var35.getMaxHealth();
        var26 = (int) (var37 + 0.5F) / 2;

        if (var26 > 30) {
          var26 = 30;
        }

        var27 = var13;

        for (int var39 = 0; var26 > 0; var39 += 20) {
          int var29 = Math.min(var26, 10);
          var26 -= var29;

          for (int var30 = 0; var30 < var29; ++var30) {
            byte var31 = 52;
            byte var32 = 0;

            if (var6) {
              var32 = 1;
            }

            int var33 = var12 - var30 * 8 - 9;
            this.drawTexturedModalRect(var33, var27, var31 + var32 * 9, 9, 9, 9);

            if (var30 * 2 + 1 + var39 < var36) {
              this.drawTexturedModalRect(var33, var27, var31 + 36, 9, 9, 9);
            }

            if (var30 * 2 + 1 + var39 == var36) {
              this.drawTexturedModalRect(var33, var27, var31 + 45, 9, 9, 9);
            }
          }

          var27 -= 10;
        }
      }

      this.mc.mcProfiler.endStartSection("air");

      if (var2.isInsideOfMaterial(Material.water)) {
        var23 = this.mc.thePlayer.getAir();
        var36 = MathHelper.ceiling_double_int((double) (var23 - 2) * 10.0D / 300.0D);
        var25 = MathHelper.ceiling_double_int((double) var23 * 10.0D / 300.0D) - var36;

        for (var26 = 0; var26 < var36 + var25; ++var26) {
          if (var26 < var36) {
            this.drawTexturedModalRect(var12 - var26 * 8 - 9, var18, 16, 18, 9, 9);
          } else {
            this.drawTexturedModalRect(var12 - var26 * 8 - 9, var18, 25, 18, 9, 9);
          }
        }
      }

      this.mc.mcProfiler.endSection();
    }
  }
Exemplo n.º 18
0
  @Override
  public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer ep) {
    if (is.getItemDamage() <= 0) {
      this.noCharge();
      return is;
    }
    this.warnCharge(is);
    if (!ReikaPlayerAPI.playerHasOrIsCreative(ep, Block.gravel.blockID, -1)) {
      if (!world.isRemote) world.playAuxSFX(1001, (int) ep.posX, (int) ep.posY, (int) ep.posZ, 1);
      return is;
    }
    for (float i = 1; i <= 128; i += 0.5) {
      Vec3 look = ep.getLookVec();
      double[] looks = ReikaVectorHelper.getPlayerLookCoords(ep, i);
      AxisAlignedBB fov =
          AxisAlignedBB.getBoundingBox(
              looks[0] - 0.5,
              looks[1] - 0.5,
              looks[2] - 0.5,
              looks[0] + 0.5,
              looks[1] + 0.5,
              looks[2] + 0.5);
      List infov = world.getEntitiesWithinAABB(EntityLivingBase.class, fov);
      for (int k = 0; k < infov.size(); k++) {
        EntityLivingBase ent = (EntityLivingBase) infov.get(k);
        if (!ep.equals(ent)
            && this.isEntityAttackable(ent)
            && ReikaWorldHelper.lineOfSight(world, ep, ent)) {
          double dist =
              ReikaMathLibrary.py3d(ep.posX - ent.posX, ep.posY - ent.posY, ep.posZ - ent.posZ);
          double x = ep.posX + look.xCoord;
          double y = ep.posY + ep.getEyeHeight() + look.yCoord;
          double z = ep.posZ + look.zCoord;
          double dx = ent.posX - ep.posX;
          double dy = ent.posY - ep.posY;
          double dz = ent.posZ - ep.posZ;
          if (!world.isRemote) {
            ItemStack fl = new ItemStack(Item.flint);
            EntityItem ei =
                new EntityItem(
                    world,
                    look.xCoord / look.lengthVector() + ep.posX,
                    look.yCoord / look.lengthVector() + ep.posY,
                    look.zCoord / look.lengthVector() + ep.posZ,
                    fl);
            ei.delayBeforeCanPickup = 100;
            ei.motionX = dx;
            ei.motionY = dy + 1;
            ei.motionZ = dz;
            // ReikaChatHelper.writeCoords(world, ei.posX, ei.posY, ei.posZ);
            ei.velocityChanged = true;
            world.playSoundAtEntity(ep, "dig.gravel", 1.5F, 2F);
            ei.lifespan = 5;
            world.spawnEntityInWorld(ei);

            if (is.getItemDamage() > 4096) { // approx the 1-hit kill of a 10-heart mob
              // ReikaPacketHelper.sendUpdatePacket(RotaryCraft.packetChannel,
              // PacketRegistry.GRAVELGUN.getMinValue(), world, (int)ent.posX, (int)ent.posY,
              // (int)ent.posZ);
              // world.playSoundAtEntity(ep, "random.explode", 0.25F, 1F);
            }
            if (ent instanceof EntityDragon) {
              EntityDragon ed = (EntityDragon) ent;
              ed.attackEntityFromPart(
                  ed.dragonPartBody, DamageSource.causePlayerDamage(ep), this.getAttackDamage(is));
            } else {
              int dmg = this.getAttackDamage(is);
              if (ent instanceof EntityPlayer) {
                for (int n = 1; n < 5; n++) {
                  ItemRegistry ir = ItemRegistry.getEntry(ent.getCurrentItemOrArmor(n));
                  if (ir != null) {
                    if (ir.isBedrockArmor()) dmg *= 0.75;
                  }
                }
              }
              ent.attackEntityFrom(DamageSource.causePlayerDamage(ep), dmg);
              if (dmg >= 500) RotaryAchievements.MASSIVEHIT.triggerAchievement(ep);
            }
            if (ent instanceof EntityMob
                && (ent.isDead || ent.getHealth() <= 0)
                && ReikaMathLibrary.py3d(ep.posX - ent.posX, ep.posY - ent.posY, ep.posZ - ent.posZ)
                    >= 80) RotaryAchievements.GRAVELGUN.triggerAchievement(ep);
          }
          // ReikaWorldHelper.spawnParticleLine(world, x, y, z, ent.posX, ent.posY+ent.height/2,
          // ent.posZ, "crit", 0, 0, 0, 60);
          for (float t = 0; t < 2; t += 0.05F)
            world.spawnParticle("crit", x, y, z, dx / dist * t, dy / dist * t, dz / dist * t);
        }
      }
      if (infov.size() > 0 && !(infov.size() == 1 && infov.get(0) instanceof EntityPlayer)) {
        if (!ep.capabilities.isCreativeMode)
          ReikaInventoryHelper.findAndDecrStack(
              Block.gravel.blockID, -1, ep.inventory.mainInventory);
        return new ItemStack(is.itemID, is.stackSize, is.getItemDamage() - 1);
      }
    }
    return is;
  }
Exemplo n.º 19
0
  @Override
  public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {

    if (entity instanceof EntityLivingBase) {
      MovingObjectPosition movingobjectposition = new MovingObjectPosition(entity);

      // SAVE ENTITY NBT //
      NBTTagCompound nbt = new NBTTagCompound();
      if (movingobjectposition.entityHit instanceof EntityLivingBase) {
        ((EntityLivingBase) movingobjectposition.entityHit).writeEntityToNBT(nbt);
      }

      // CAUSE DAMAGE //

      if (player.capabilities.isCreativeMode) {
        movingobjectposition.entityHit.attackEntityFrom(
            DamageSource.causePlayerDamage(player), (float) 99999F);
      } else {
        movingobjectposition.entityHit.attackEntityFrom(
            DamageSource.causePlayerDamage(player), (float) 2F);
        stack.stackSize--;
        if (stack.stackSize <= 0)
          player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
      }

      // PETRIFICATION //
      EntityLivingBase target = (EntityLivingBase) entity;

      if (target.getHealth() <= 0) {
        World world = target.worldObj;
        int x = (int) target.posX;
        int y = (int) target.posY;
        int z = (int) target.posZ;

        WorldUtil.setBlock(world, x, y, z, BlockData.statue.block);

        TileStatue tile = (TileStatue) WorldUtil.getPTile(world, x, y, z);

        EntityLivingBase statueEntity = null;
        Class oclass = target.getClass();

        if (oclass != null) {
          try {
            statueEntity =
                (EntityLivingBase)
                    oclass
                        .getConstructor(new Class[] {World.class})
                        .newInstance(new Object[] {player.worldObj});
          } catch (Exception exception) {
            exception.printStackTrace();
          }
        }

        if (statueEntity != null) {
          statueEntity.readEntityFromNBT(nbt);
          tile.setEntity((EntityLivingBase) statueEntity);

          tile.setAngle((int) (-target.rotationYaw));
          if (!world.isRemote && ConfigData.statueSmoke)
            PacketHandler.sendToAllInDimension(
                new SmokePacket(x, y, z, player.dimension), player.dimension);
        } else System.out.println("Entity was null!");
      }

      return true;
    }

    return false;
  }
  @Override
  public void updateEntity(World world, int x, int y, int z, int meta) {
    super.updateEntity(world, x, y, z, meta);

    if (DragonAPICore.debugtest) {
      if (!hasMultiblock) {
        CrystalElement e = CrystalElement.randomElement();
        FilledBlockArray b = ChromaStructures.getPylonStructure(world, x, y - 9, z, e);
        b.place();
        // world.setBlock(x, y+9, z, this.getTile().getBlock(), this.getTile().getBlockMetadata(),
        // 3);
        // TileEntityCrystalPylon te = (TileEntityCrystalPylon)world.getTileEntity(x, y+9, z);
        color = e;
        hasMultiblock = true;
        this.syncAllData(true);
      }
    }

    if (hasMultiblock) {
      // ReikaJavaLibrary.pConsole(energy, Side.SERVER, color == CrystalElement.BLUE);

      int max = this.getCapacity();
      if (world.getTotalWorldTime() != lastWorldTick) {
        this.charge(world, x, y, z, max);
        lastWorldTick = world.getTotalWorldTime();
      }
      energy = Math.min(energy, max);

      if (world.isRemote) {
        this.spawnParticle(world, x, y, z);
      }

      if (!world.isRemote && rand.nextInt(80) == 0) {
        int r = 8 + rand.nextInt(8);
        AxisAlignedBB box = ReikaAABBHelper.getBlockAABB(x, y, z).expand(r, r, r);
        List<EntityLivingBase> li = world.getEntitiesWithinAABB(EntityLivingBase.class, box);
        for (EntityLivingBase e : li) {
          boolean attack = !e.isDead && e.getHealth() > 0;
          if (e instanceof EntityPlayer) {
            EntityPlayer ep = (EntityPlayer) e;
            attack =
                attack && !ep.capabilities.isCreativeMode && !Chromabilities.PYLON.enabledOn(ep);
          } else if (e instanceof EntityBallLightning) {
            attack = ((EntityBallLightning) e).getElement() != color;
          }
          if (attack) {
            this.attackEntity(e);
            this.sendClientAttack(this, e);
          }
        }
      }

      float f = this.isEnhanced() ? 1.125F : 1;

      if (TileEntityCrystalPylon.TUNED_PYLONS)
        f *= CrystalMusicManager.instance.getDingPitchScale(color);

      if (this.getTicksExisted() % (int) (72 / f) == 0) {
        ChromaSounds.POWER.playSoundAtBlock(this, 1, f);
      }

      int n = this.isEnhanced() ? 24 : 36;
      if (world.isRemote && rand.nextInt(n) == 0) {
        this.spawnLightning(world, x, y, z);
      }

      if (!world.isRemote
          && ChromaOptions.BALLLIGHTNING.getState()
          && energy >= this.getCapacity() / 2
          && rand.nextInt(24000) == 0
          && this.isChunkLoaded()) {
        world.spawnEntityInWorld(
            new EntityBallLightning(world, color, x + 0.5, y + 0.5, z + 0.5)
                .setPylon()
                .setNoDrops());
      }
    }
  }
Exemplo n.º 21
0
  protected int applyArmorCalculations(
      EntityLivingBase entity, DamageSource source, float originalDamage) {
    ItemStack[] armor = entity.getLastActiveItems();
    int pierceRating = 0;
    int slashRating = 0;
    int crushRating = 0;

    EntityArmorCalcEvent eventPre =
        new EntityArmorCalcEvent(entity, originalDamage, EntityArmorCalcEvent.EventType.PRE);
    MinecraftForge.EVENT_BUS.post(eventPre);
    float damage = eventPre.incomingDamage;

    if (!source.isUnblockable() && armor != null) {
      // 1. Get Random Hit Location
      int location = getRandomSlot(entity.getRNG());

      // 2. Get Armor Rating for armor in hit Location
      if (armor[location] != null && armor[location].getItem() instanceof ItemTFCArmor) {
        pierceRating = ((ItemTFCArmor) armor[location].getItem()).armorTypeTFC.getPiercingAR();
        slashRating = ((ItemTFCArmor) armor[location].getItem()).armorTypeTFC.getSlashingAR();
        crushRating = ((ItemTFCArmor) armor[location].getItem()).armorTypeTFC.getCrushingAR();
        if (entity instanceof IInnateArmor) {
          pierceRating += ((IInnateArmor) entity).getPierceArmor();
          slashRating += ((IInnateArmor) entity).getSlashArmor();
          crushRating += ((IInnateArmor) entity).getCrushArmor();
        }

        // 3. Convert the armor rating to % damage reduction
        float pierceMult = getDamageReduction(pierceRating);
        float slashMult = getDamageReduction(slashRating);
        float crushMult = getDamageReduction(crushRating);

        // 4. Reduce incoming damage
        damage = processDamageSource(source, damage, pierceMult, slashMult, crushMult);

        // 5. Damage the armor that was hit
        armor[location].damageItem((int) processArmorDamage(armor[location], damage), entity);
      } else if (armor[location] == null
          || armor[location] != null && !(armor[location].getItem() instanceof ItemTFCArmor)) {
        if (entity instanceof IInnateArmor) {
          pierceRating += ((IInnateArmor) entity).getPierceArmor();
          slashRating += ((IInnateArmor) entity).getSlashArmor();
          crushRating += ((IInnateArmor) entity).getCrushArmor();
        }
        // 1. Convert the armor rating to % damage reduction
        float pierceMult = getDamageReduction(pierceRating);
        float slashMult = getDamageReduction(slashRating);
        float crushMult = getDamageReduction(crushRating);
        // 4. Reduce incoming damage
        damage = processDamageSource(source, damage, pierceMult, slashMult, crushMult);

        // a. If the attack hits an unprotected head, it does 75% more damage
        // b. If the attack hits unprotected feet, it applies a slow to the player
        if (location == 3) damage *= 1.75f;
        else if (location == 0)
          entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 100, 1));
      }
      // 6. Apply the damage to the player
      EntityArmorCalcEvent eventPost =
          new EntityArmorCalcEvent(entity, damage, EntityArmorCalcEvent.EventType.POST);
      MinecraftForge.EVENT_BUS.post(eventPost);
      // TerraFirmaCraft.log.info(entity.getClass()+", "+eventPre.incomingDamage+",
      // "+eventPost.incomingDamage);
      float hasHealth = entity.getHealth();
      entity.setHealth(entity.getHealth() - eventPost.incomingDamage);
      entity.func_110142_aN().func_94547_a(source, hasHealth, eventPost.incomingDamage);
    }
    return 0;
  }