Exemplo n.º 1
0
  @Override
  protected void onImpact(MovingObjectPosition par1MovingObjectPosition) {
    if (!this.worldObj.isRemote
        && potionStack.getItem() != null
        && potionStack.getItem() instanceof ItemPotion) {
      @SuppressWarnings("unchecked")
      List<PotionEffect> effectList = ((ItemPotion) potionStack.getItem()).getEffects(potionStack);

      if (effectList != null && !effectList.isEmpty()) {
        AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D);
        @SuppressWarnings("unchecked")
        List<EntityLivingBase> entityList =
            this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);

        if (entityList != null && !entityList.isEmpty()) {
          Iterator<EntityLivingBase> iterator = entityList.iterator();

          while (iterator.hasNext()) {
            EntityLivingBase entityliving = iterator.next();
            double squareDistance = this.getDistanceSqToEntity(entityliving);

            if (squareDistance < 16.0D) {
              double distanceFactor = 1.0D - Math.sqrt(squareDistance) / 4.0D;

              if (entityliving == par1MovingObjectPosition.entityHit) {
                distanceFactor = 1.0D;
              }

              Iterator<PotionEffect> iterator1 = effectList.iterator();

              while (iterator1.hasNext()) {
                PotionEffect potioneffect = iterator1.next();
                int potionID = potioneffect.getPotionID();

                if (Potion.potionTypes[potionID].isInstant()) {
                  Potion.potionTypes[potionID].affectEntity(
                      this.getThrower(), entityliving, potioneffect.getAmplifier(), distanceFactor);
                } else {
                  int potionDuration = (int) (distanceFactor * potioneffect.getDuration() + 0.5D);

                  if (potionDuration > 20) {
                    entityliving.addPotionEffect(
                        new PotionEffect(potionID, potionDuration, potioneffect.getAmplifier()));
                  }
                }
              }
            }
          }
        }
      }

      this.worldObj.playAuxSFX(
          2002,
          (int) Math.round(this.posX),
          (int) Math.round(this.posY),
          (int) Math.round(this.posZ),
          potionStack.getItemDamage());
      this.setDead();
    }
  }
 public static void addOrMergePotionEffect(EntityLivingBase player, PotionEffect newp) {
   if (player.isPotionActive(newp.getPotion())) {
     // do not use built in 'combine' function, just add up duration myself
     PotionEffect p = player.getActivePotionEffect(newp.getPotion());
     int ampMax = Math.max(p.getAmplifier(), newp.getAmplifier());
     player.addPotionEffect(
         new PotionEffect(newp.getPotion(), newp.getDuration() + p.getDuration(), ampMax));
   } else {
     player.addPotionEffect(newp);
   }
 }
  private void renderPotions() {
    GL11.glPushMatrix();
    int var1 = Resilience.getInstance().getValues().enabledModsEnabled ? 76 : 1;
    int var2 = 0;
    boolean var3 = true;
    Collection var4 = wrapper.getPlayer().getActivePotionEffects();

    if (!var4.isEmpty()) {
      ResourceLocation rL = new ResourceLocation("textures/gui/container/inventory.png");
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glDisable(GL11.GL_LIGHTING);
      int var5 = 33;

      if (var4.size() > 5) {
        var5 = 132 / (var4.size() - 1);
      }

      for (Iterator var6 = wrapper.getPlayer().getActivePotionEffects().iterator();
          var6.hasNext();
          var2 += var5) {
        PotionEffect var7 = (PotionEffect) var6.next();
        Potion var8 = Potion.potionTypes[var7.getPotionID()];
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        wrapper.getMinecraft().getTextureManager().bindTexture(rL);
        // this.drawTexturedModalRect(var1, var2, 0, 166, 140, 32);

        if (var8.hasStatusIcon()) {
          int var9 = var8.getStatusIconIndex();
          this.drawTexturedModalRect(
              var1 + 6, var2 + 7, 0 + var9 % 8 * 18, 198 + var9 / 8 * 18, 18, 18);
        }

        String var11 = I18n.format(var8.getName(), new Object[0]);

        if (var7.getAmplifier() == 1) {
          var11 = var11 + " II";
        } else if (var7.getAmplifier() == 2) {
          var11 = var11 + " III";
        } else if (var7.getAmplifier() == 3) {
          var11 = var11 + " IV";
        }

        wrapper.getFontRenderer().drawStringWithShadow(var11, var1 + 10 + 18, var2 + 6, 16777215);
        String var10 = Potion.getDurationString(var7);
        wrapper
            .getFontRenderer()
            .drawStringWithShadow(var10, var1 + 10 + 18, var2 + 6 + 10, 8355711);
      }
    }
    GL11.glPopMatrix();
  }
Exemplo n.º 4
0
  /** Displays debuff/potion effects that are currently being applied to the player */
  private void displayDebuffEffects() {
    int var1 = this.guiLeft - 124;
    int var2 = this.guiTop;
    Collection var4 = this.mc.thePlayer.getActivePotionEffects();

    if (!var4.isEmpty()) {
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glDisable(GL11.GL_LIGHTING);
      int var6 = 33;

      if (var4.size() > 5) {
        var6 = 132 / (var4.size() - 1);
      }

      for (Iterator var7 = this.mc.thePlayer.getActivePotionEffects().iterator();
          var7.hasNext();
          var2 += var6) {
        PotionEffect var8 = (PotionEffect) var7.next();
        Potion var9 =
            Potion.potionTypes[var8.getPotionID()] instanceof TFCPotion
                ? ((TFCPotion) Potion.potionTypes[var8.getPotionID()])
                : Potion.potionTypes[var8.getPotionID()];
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.func_110434_K().func_110577_a(field_110408_a);
        this.drawTexturedModalRect(var1, var2, 0, 166, 140, 32);

        if (var9.hasStatusIcon()) {
          int var10 = var9.getStatusIconIndex();
          this.drawTexturedModalRect(
              var1 + 6, var2 + 7, 0 + var10 % 8 * 18, 198 + var10 / 8 * 18, 18, 18);
        }

        String var12 = StatCollector.translateToLocal(var9.getName());

        if (var8.getAmplifier() == 1) {
          var12 = var12 + " II";
        } else if (var8.getAmplifier() == 2) {
          var12 = var12 + " III";
        } else if (var8.getAmplifier() == 3) {
          var12 = var12 + " IV";
        }

        this.fontRenderer.drawStringWithShadow(var12, var1 + 10 + 18, var2 + 6, 16777215);
        String var11 = Potion.getDurationString(var8);
        this.fontRenderer.drawStringWithShadow(var11, var1 + 10 + 18, var2 + 6 + 10, 8355711);
      }
    }
  }
Exemplo n.º 5
0
  @Override
  public void onUpdate(
      ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
    super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
    if (par3Entity instanceof EntityPlayer) {
      EntityPlayer player = (EntityPlayer) par3Entity;
      PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed);
      float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F;

      if (player.getCurrentEquippedItem() == par1ItemStack
          && player.swingProgress == check
          && !par2World.isRemote
          && par2World.rand.nextInt(2) == 0) {
        MovingObjectPosition pos = ToolCommons.raytraceFromEntity(par2World, par3Entity, true, 48);
        if (pos != null) {
          Vector3 posVec = new Vector3(pos.blockX, pos.blockY, pos.blockZ);
          Vector3 motVec = new Vector3((Math.random() - 0.5) * 18, 24, (Math.random() - 0.5) * 18);
          posVec.add(motVec);
          motVec.normalize().negate().multiply(1.5);

          EntityFallingStar star = new EntityFallingStar(par2World, player);
          star.setPosition(posVec.x, posVec.y, posVec.z);
          star.motionX = motVec.x;
          star.motionY = motVec.y;
          star.motionZ = motVec.z;
          par2World.spawnEntityInWorld(star);

          ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE);
          par2World.playSoundAtEntity(player, "botania:starcaller", 0.4F, 1.4F);
        }
      }
    }
  }
Exemplo n.º 6
0
  public Packet41EntityEffect(int par1, PotionEffect par2PotionEffect) {
    this.entityId = par1;
    this.effectId = (byte) (par2PotionEffect.getPotionID() & 255);
    this.effectAmplifier = (byte) (par2PotionEffect.getAmplifier() & 255);

    if (par2PotionEffect.getDuration() > 32767) {
      this.duration = 32767;
    } else {
      this.duration = (short) par2PotionEffect.getDuration();
    }
  }
Exemplo n.º 7
0
  public int amplifyEffect(EntityPlayer player, Potion potion) {
    PotionEffect eff = player.getActivePotionEffect(potion);
    if (eff != null) {
      int max = 1;
      max = 6;
      int newAmp = eff.getAmplifier();
      int newDur = eff.getDuration();
      if (newAmp < max) {
        newAmp++;
      }
      newDur += 500;
      eff.combine(new PotionEffect(eff.getPotionID(), newDur, newAmp));

      return newAmp;
    }

    player.addPotionEffect(new PotionEffect(potion.id, 300, 0));
    return 1;
  }
 @Override
 public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
   double totalEnergy = ElectricItemUtils.getPlayerEnergy(player);
   PotionEffect invis = null;
   Collection<PotionEffect> effects = player.getActivePotionEffects();
   for (PotionEffect effect : effects) {
     if (effect.getAmplifier() == 81 && effect.getPotionID() == Potion.invisibility.id) {
       invis = effect;
       break;
     }
   }
   if (50 < totalEnergy) {
     if (invis == null || invis.getDuration() < 210) {
       player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 500, 81));
       ElectricItemUtils.drainPlayerEnergy(player, 50);
     }
   } else {
     if (invis != null) {
       player.removePotionEffect(Potion.invisibility.id);
     }
   }
 }
Exemplo n.º 9
0
  @Override
  public void control(EntityPlayerCustom playerCustom, EntityPlayer player, Side side) {
    int x = MathHelper.floor_double(player.posX);
    int y = MathHelper.floor_double(player.posY);
    int z = MathHelper.floor_double(player.posZ);
    int heading = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    if (!playerCustom.isSneaking) {
      if (((((Util.isCube(player.worldObj.getBlock(x, y, z - 1)) && heading == 2)
                  || (Util.isCube(player.worldObj.getBlock(x, y, z + 1)) && heading == 0)
                  || (Util.isCube(player.worldObj.getBlock(x - 1, y, z)) && heading == 1)
                  || (Util.isCube(player.worldObj.getBlock(x + 1, y, z)) && heading == 3))
              && ((!Util.isCube(player.worldObj.getBlock(x, y + 1, z - 1)) && heading == 2)
                  || (!Util.isCube(player.worldObj.getBlock(x, y + 1, z + 1)) && heading == 0)
                  || (!Util.isCube(player.worldObj.getBlock(x - 1, y + 1, z)) && heading == 1)
                  || (!Util.isCube(player.worldObj.getBlock(x + 1, y + 1, z)) && heading == 3))
              && (!Util.isCube(player.worldObj.getBlock(x, y - 2, z)))))
          && player.worldObj.getBlock(x, y, z) != Blocks.ladder
          && player.getCurrentEquippedItem() == null) {
        playerCustom.isGrabbing = true;
        playerCustom.rotationYaw = player.rotationYaw;
        playerCustom.rotationPitch = player.rotationPitch;
        playerCustom.prevRotationPitch = player.prevRotationPitch;
        playerCustom.prevRotationYaw = player.prevRotationYaw;
        playerCustom.grabbingDirections[heading] = true;
        if (heading == 0) {
          playerCustom.grabbingDirections[3] = true;
        } else {
          playerCustom.grabbingDirections[heading - 1] = true;
        }

        if (heading == 3) {
          playerCustom.grabbingDirections[0] = true;
        } else {
          playerCustom.grabbingDirections[heading + 1] = true;
        }
      } else {
        playerCustom.isGrabbing = false;
        playerCustom.rotationYaw = 0;
        if (!playerCustom.isRolling) {
          playerCustom.rotationPitch = 0;
        }
        playerCustom.prevRotationPitch = 0;
        playerCustom.prevRotationYaw = 0;
        playerCustom.grabbingDirections[0] = false;
        playerCustom.grabbingDirections[1] = false;
        playerCustom.grabbingDirections[2] = false;
        playerCustom.grabbingDirections[3] = false;
      }
      if (playerCustom.isGrabbing && !playerCustom.wasSneaking && player.isSneaking()) {
        playerCustom.wasSneaking = true;
      }
      if (!playerCustom.isGrabbing) {
        playerCustom.wasSneaking = false;
      }
      if (playerCustom.wasSneaking) {
        return;
      }
      if (!player.isSneaking()
          && !(Boolean)
              ObfuscationReflectionHelper.getPrivateValue(
                  EntityLivingBase.class, (EntityLivingBase) player, 41)
          && playerCustom.isGrabbing) {
        if (heading == 1 || heading == 3) {
          player.setPosition(x + 0.5F, y + 0.9F, player.posZ);
          player.motionX = 0;
        }
        if (heading == 2 || heading == 0) {
          player.setPosition(player.posX, y + 0.9F, z + 0.5F);
          player.motionZ = 0;
        }
        player.motionY = 0.0;
        if (player.isSprinting()) {
          player.setSprinting(false);
        }
      } else if ((Boolean)
              ObfuscationReflectionHelper.getPrivateValue(
                  EntityLivingBase.class, (EntityLivingBase) player, 41)
          && playerCustom.isGrabbing) {
        player.motionY = 0.55D;
      }
    }

    //		if(side == Side.CLIENT){
    ////			Util.channel.sendToServer(new CPacketPlayerAction(playerCustom.isGrabbing ? 0 : 1));
    //		}
    //
    //		if(side == Side.SERVER){
    //			System.out.println("1 : " + playerCustom.isGrabbing);
    //		}
    /*    CLIENT    */
    if (!player.worldObj.isRemote) {
      if (playerCustom.isGrabbing && !player.capabilities.isCreativeMode) {
        PotionEffect potioneffect = player.getActivePotionEffect(Potion.jump);
        float f1 = potioneffect != null ? (float) (potioneffect.getAmplifier() + 1) : 0.0F;
        int i = MathHelper.ceiling_float_int(player.fallDistance - 3.0F - f1);
        if (i > 0) {
          player.playSound(
              i > 4 ? "game.neutral.hurt.fall.big" : "game.neutral.hurt.fall.small", 1.0F, 1.0F);
          damageEntity(EntityLivingBase.class, player, DamageSource.fall, (float) i);
        }
        player.fallDistance = 0;
      }
    }
  }
Exemplo n.º 10
0
 @Override
 public double getDurationModifier() {
   return handle.getAmplifier();
 }
Exemplo n.º 11
0
  @SideOnly(Side.CLIENT)
  public void addInformation(ItemStack ist, EntityPlayer player, List list, boolean flag) {
    if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
      return;
    PotionEssence essence = new PotionEssence(ist.getTagCompound());
    if (essence.getEffects().size() > 0) {
      HashMultimap hashmultimap = HashMultimap.create();
      Iterator iterator1;

      if (essence.getEffects() != null && !essence.getEffects().isEmpty()) {
        iterator1 = essence.getEffects().iterator();

        while (iterator1.hasNext()) {
          PotionEffect potioneffect = (PotionEffect) iterator1.next();
          String s1 = StatCollector.translateToLocal(potioneffect.getEffectName()).trim();
          Potion potion = Potion.potionTypes[potioneffect.getPotionID()];
          Map map = potion.func_111186_k();

          if (map != null && map.size() > 0) {
            Iterator iterator = map.entrySet().iterator();

            while (iterator.hasNext()) {
              Map.Entry entry = (Map.Entry) iterator.next();
              AttributeModifier attributemodifier = (AttributeModifier) entry.getValue();
              AttributeModifier attributemodifier1 =
                  new AttributeModifier(
                      attributemodifier.getName(),
                      potion.func_111183_a(potioneffect.getAmplifier(), attributemodifier),
                      attributemodifier.getOperation());
              hashmultimap.put(
                  ((IAttribute) entry.getKey()).getAttributeUnlocalizedName(), attributemodifier1);
            }
          }

          if (potioneffect.getAmplifier() > 0) {
            s1 = s1 + " " + (potioneffect.getAmplifier() + 1);
          }

          if (potioneffect.getDuration() > 20) {
            s1 = s1 + " (" + Potion.getDurationString(potioneffect) + ")";
          }

          if (potion.isBadEffect()) {
            list.add(EnumChatFormatting.RED + s1);
          } else {
            list.add(EnumChatFormatting.GRAY + s1);
          }
        }
      } else {
        String s = StatCollector.translateToLocal("potion.empty").trim();
        list.add(EnumChatFormatting.GRAY + s);
      }

      if (!hashmultimap.isEmpty()) {
        list.add("");
        list.add(
            EnumChatFormatting.DARK_PURPLE
                + StatCollector.translateToLocal("potion.effects.whenDrank"));
        iterator1 = hashmultimap.entries().iterator();

        while (iterator1.hasNext()) {
          Map.Entry entry1 = (Map.Entry) iterator1.next();
          AttributeModifier attributemodifier2 = (AttributeModifier) entry1.getValue();
          double d0 = attributemodifier2.getAmount();
          double d1;

          if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2) {
            d1 = attributemodifier2.getAmount();
          } else {
            d1 = attributemodifier2.getAmount() * 100.0D;
          }

          if (d0 > 0.0D) {
            list.add(
                EnumChatFormatting.BLUE
                    + StatCollector.translateToLocalFormatted(
                        "attribute.modifier.plus." + attributemodifier2.getOperation(),
                        new Object[] {
                          ItemStack.field_111284_a.format(d1),
                          StatCollector.translateToLocal(
                              "attribute.name." + (String) entry1.getKey())
                        }));
          } else if (d0 < 0.0D) {
            d1 *= -1.0D;
            list.add(
                EnumChatFormatting.RED
                    + StatCollector.translateToLocalFormatted(
                        "attribute.modifier.take." + attributemodifier2.getOperation(),
                        new Object[] {
                          ItemStack.field_111284_a.format(d1),
                          StatCollector.translateToLocal(
                              "attribute.name." + (String) entry1.getKey())
                        }));
          }
        }
      }
    }
  }