Exemplo n.º 1
0
 /**
  * Current implementations of this method in child classes do not use the entry argument beside
  * ev. They just raise the damage on the stack.
  */
 public boolean hitEntity(
     ItemStack par1ItemStack,
     EntityLivingBase par2EntityLivingBase,
     EntityLivingBase par3EntityLivingBase) {
   par1ItemStack.damageItem(1, par3EntityLivingBase);
   par2EntityLivingBase.motionY = 0.6D;
   return true;
 }
  /**
   * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack,
   * world, entityPlayer
   */
  public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
    world.playSoundAtEntity(entityplayer, "morecreeps:firegem", 1.0F, 1.0F);
    itemstack.damageItem(1, entityplayer);
    entityplayer.swingItem();
    List list =
        world.getEntitiesWithinAABB(
            EntityLivingBase.class,
            new AxisAlignedBB(
                    entityplayer.posX,
                    entityplayer.posY,
                    entityplayer.posZ,
                    entityplayer.posX + 1.0D,
                    entityplayer.posY + 1.0D,
                    entityplayer.posZ + 1.0D)
                .expand(10D, 10D, 10D));

    for (int i = 0; i < list.size(); i++) {
      Entity entity = (Entity) list.get(i);

      if (!(entity instanceof EntityLivingBase)) {
        continue;
      }

      EntityLivingBase entityliving = (EntityLivingBase) entity;

      if ((entityliving instanceof CREEPSEntityHotdog)
          || (entityliving instanceof CREEPSEntityHunchback)
          || (entityliving instanceof EntityPlayer)
          || (entityliving instanceof CREEPSEntityGuineaPig)
          || (entityliving instanceof CREEPSEntityPreacher)) {
        continue;
      }

      if (world.isRemote) {
        for (int j = 0; j < 10; j++) {
          double d = random.nextGaussian() * 0.02D;
          double d1 = random.nextGaussian() * 0.02D;
          double d2 = random.nextGaussian() * 0.02D;
          world.spawnParticle(
              EnumParticleTypes.SMOKE_NORMAL,
              entityliving.posX + (double) (random.nextFloat() * 1.5F),
              entityliving.posY + 0.5D + (double) (random.nextFloat() * 2.5F),
              entityliving.posZ + (double) (random.nextFloat() * 1.5F),
              d,
              d1,
              d2);
        }
      }

      entityliving.attackEntityFrom(DamageSource.inFire, 2F);
      entityliving.motionY += 0.5D;
      entityliving.setFire(15);
    }

    return itemstack;
  }
Exemplo n.º 3
0
 @Override
 public boolean hitEntity(ItemStack itemStack, EntityLivingBase target, EntityLivingBase player) {
   itemStack.damageItem(1, player);
   if (hammerType.equals(EnumHammerType.POGO)) {
     target.motionY = Math.abs(player.motionY) + target.motionY + 0.5;
     player.motionY = 0;
     player.fallDistance = 0;
   } else if (hammerType.equals(EnumHammerType.SCARLET)) target.setFire(50);
   else if (hammerType.equals(EnumHammerType.POPAMATIC))
     target.attackEntityFrom(
         DamageSource.magic,
         (float) (player.worldObj.rand.nextInt(6) + 1) * (player.worldObj.rand.nextInt(6) + 1));
   else if (hammerType.equals(EnumHammerType.FEARNOANVIL)
       && player.worldObj.rand.nextGaussian() > 0.9) // Just a suggestion, keep it if you like it.
   target.addPotionEffect(
         new PotionEffect(
             2, 100, 3)); // Would prefer it being triggered by a critical hit instead, if it can.
   return true;
 }
Exemplo n.º 4
0
  @Override
  public void onWornTick(ItemStack stack, EntityLivingBase player) {
    if (!player.isInvisible()) {
      player.setInvisible(true);
    }
    NBTTagCompound tag = new NBTTagCompound();
    ((EntityPlayer) player).writeToNBT(tag);
    NBTTagCompound forgeTag = tag.getCompoundTag("ForgeData");

    int corruption = 0;

    if (forgeTag.hasKey("MindCorruption")) corruption = forgeTag.getInteger("MindCorruption");
    else forgeTag.setInteger("MindCorruption", 0);

    ((EntityPlayer) player).capabilities.disableDamage = true;

    if (!player.worldObj.isRemote) {
      if (corruption <= 0) {
        ((EntityPlayer) player)
            .addChatMessage(
                new ChatComponentText(
                    EMTTextHelper.PURPLE
                        + "You have worn the Ring. Your soul has now been forever "
                        + EMTTextHelper.PURPLE
                        + "tainted. "
                        + EMTTextHelper.RED
                        + EMTTextHelper.ITALIC
                        + "Beware of wearing the ring. The tainting will only "
                        + EMTTextHelper.RED
                        + EMTTextHelper.ITALIC
                        + "increase, and strange things will start happening."));
      } else if (corruption > 6000 && corruption < 24000 && random.nextInt(2000) == 0) {
        player.addPotionEffect(new PotionEffect(Potion.blindness.id, 500, 2, false));
      } else if (corruption >= 6000 && corruption < 24000 && random.nextInt(2000) == 0) {
        player.addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2, false));
      } else if (corruption >= 24000 && corruption < 72000 && random.nextInt(2000) == 0) {
        ((EntityPlayer) player).capabilities.disableDamage = false;

        player.attackEntityFrom(DamageSource.magic, 5);
      } else if (corruption >= 72000 && corruption < 120000 && random.nextInt(4000) == 0) {
        ((EntityPlayer) player).capabilities.disableDamage = false;

        player.motionY += 2d;
      } else if (corruption >= 120000 && random.nextInt(10000) == 0) {
        ((EntityPlayer) player).capabilities.disableDamage = false;

        player.addPotionEffect(new PotionEffect(Potion.wither.id, 5000, 4, false));
      } else if (corruption + 100 >= Integer.MAX_VALUE) { // =3333333
        player.isDead = true;
      }
    }
    forgeTag.setInteger("MindCorruption", ++corruption);
    tag.setTag("ForgeData", forgeTag);
    ((EntityPlayer) player).readFromNBT(tag);
  }
Exemplo n.º 5
0
 /**
  * Current implementations of this method in child classes do not use the entry argument beside
  * ev. They just raise the damage on the stack.
  */
 @Override
 public boolean hitEntity(
     ItemStack par1ItemStack,
     EntityLivingBase par2EntityLivingBase,
     EntityLivingBase par3EntityLivingBase) {
   // DON'T MOVE A SINGLE DANG BIT!
   par2EntityLivingBase.motionX = 0;
   par2EntityLivingBase.motionY = 0;
   par2EntityLivingBase.motionZ = 0;
   // Apply poison
   if (this.poisonous) {
     par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.poison.id, 75, 1));
   }
   // Damage item stack
   par1ItemStack.damageItem(1, par3EntityLivingBase);
   return true;
 }
Exemplo n.º 6
0
  @Override
  public boolean hitEntity(
      ItemStack par1ItemStack,
      EntityLivingBase par2EntityLivingBase,
      EntityLivingBase par3EntityLivingBase) {
    if (par1ItemStack.getItem().equals(RioVItems.axeOfAunTun)) {
      par2EntityLivingBase.setFire(30);
    }

    if (par1ItemStack.getItem().equals(RioVItems.swordOfFlame)) {
      par2EntityLivingBase.setFire(10);
    }

    if (par1ItemStack.getItem().equals(RioVItems.daetoriSword)) {
      par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.wither.id, 100, 3));
    }

    if (par1ItemStack.getItem().equals(RioVItems.alerisSword)) {
      par2EntityLivingBase.motionY = 1;
    }

    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.kanuutu.effectId, par1ItemStack) == 2) {
      par2EntityLivingBase.motionY = 0.8;
    }

    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.kanuutu.effectId, par1ItemStack) == 1) {
      par2EntityLivingBase.motionY = 0.7;
    }

    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.frost.effectId, par1ItemStack) == 2) {
      par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 4));
    }

    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.frost.effectId, par1ItemStack) == 1) {
      par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 2));
    }

    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.venom.effectId, par1ItemStack) == 2) {
      par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.poison.id, 100, 4));
    }

    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.venom.effectId, par1ItemStack) == 1) {
      par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.poison.id, 100, 2));
    }

    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.confusion.effectId, par1ItemStack)
        == 2) {
      par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.wither.id, 100, 4));
    }

    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.confusion.effectId, par1ItemStack)
        == 1) {
      par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.wither.id, 100, 2));
    }

    if (TheMistsOfRioV.getInstance().aether) {
      if (par1ItemStack.getItem().equals(RioVItems.infusedGravititeSword)) {
        if (par3EntityLivingBase != null
            && par3EntityLivingBase instanceof EntityPlayer
            && (par2EntityLivingBase.hurtTime > 0 || par2EntityLivingBase.deathTime > 0)) {
          par2EntityLivingBase.addVelocity(0.0D, 1.0D, 0.0D);
          par1ItemStack.damageItem(1, par3EntityLivingBase);
        }
      }
    }
    par1ItemStack.damageItem(1, par3EntityLivingBase);
    return true;
  }
Exemplo n.º 7
0
  private void updateAbility() {
    if (!worldObj.isRemote) {
      abilityCounter--;

      if (abilityCounter <= 0) {
        // Boom spider throws a boom ball.
        if (spiderType == EnumSpiderType.BOOM && target != null) {
          EntityBoomBall boomBall = new EntityBoomBall(this, target, 2.5F);
          worldObj.spawnEntityInWorld(boomBall);
        }

        // Slinger spider throws a web shot.
        else if (spiderType == EnumSpiderType.SLINGER && target != null) {
          EntityWebShot webShot = new EntityWebShot(this, target, 2.5F);
          worldObj.spawnEntityInWorld(webShot);

          worldObj.playSoundAtEntity(this, "random.bow", 0.75F, 1.0F);
        }

        // Nova spider heals nearby spiders.
        else if (spiderType == EnumSpiderType.NOVA && RadixLogic.getBooleanWithProbability(20)) {
          EntitySpiderEx spider =
              (EntitySpiderEx)
                  RadixLogic.getNearestEntityOfTypeWithinDistance(EntitySpiderEx.class, this, 8);

          if (spider != null && spider.getHealth() < spider.getMaxHealth()) {
            int healthIncrease = getLevel() * 5;
            spider.setHealth(healthIncrease);
            Utils.spawnParticlesAroundEntityS("heart", this, 6);
            Utils.spawnParticlesAroundEntityS("heart", spider, 6);
          }
        }

        // Ender spider throws targets into the air.
        else if (spiderType == EnumSpiderType.ENDER && target != null) {
          if (worldObj.canBlockSeeTheSky((int) posX, (int) posY, (int) posZ)) {
            Utils.spawnParticlesAroundEntityS(Particle.PORTAL, this, 6);
            target.motionY = 1.0F + (0.3F * getLevel());

            target.motionX =
                rand.nextBoolean()
                    ? rand.nextDouble()
                    : rand.nextBoolean() ? rand.nextDouble() * -1 : 0;
            target.motionZ =
                rand.nextBoolean()
                    ? rand.nextDouble()
                    : rand.nextBoolean() ? rand.nextDouble() * -1 : 0;

            if (getLevel() == 3) {
              target.motionX = target.motionX > 0 ? target.motionX + 2.0F : target.motionX - 2.0F;
              target.motionZ = target.motionZ > 0 ? target.motionZ + 2.0F : target.motionZ - 2.0F;
            }

            worldObj.playSoundAtEntity(target, "mob.endermen.portal", 1.0F, 1.0F);

            Utils.spawnParticlesAroundEntityS(Particle.PORTAL, target, 6);
          }
        }

        abilityCounter = abilityThreshold;
      }
    }
  }
Exemplo n.º 8
0
 protected void swingThrower() {
   EntityLivingBase thrower = getThrower();
   if (thrower != null && !thrower.onGround && isInGround()) {
     if (thrower.worldObj.isRemote) {
       // Determine the swing variables on first swing tick:
       float x = dataWatcher.getWatchableObjectFloat(HIT_POS_X);
       float y = dataWatcher.getWatchableObjectFloat(HIT_POS_Y);
       float z = dataWatcher.getWatchableObjectFloat(HIT_POS_Z);
       if (swingTicks == 0 && swingVec == null && thrower.motionY < 0) {
         swingVec =
             Vec3.createVectorHelper(
                     (x - thrower.posX),
                     y - (thrower.posY + thrower.getEyeHeight()),
                     (z - thrower.posZ))
                 .normalize();
         dy = (thrower.getDistance(x, y, z) / 7.0D); // lower divisor gives bigger change in y
         // calculate horizontal distance to find initial swing tick position
         // as distance approaches zero, swing ticks should approach ticks required / 2
         // as distance approaches maxDistance, swing ticks should approach zero
         // this makes sure player's arc is even around pivot point
         double d = Math.min(thrower.getDistance(x, thrower.posY, z), getMaxDistance());
         swingTicks = MathHelper.floor_double(((getMaxDistance() - d) / getMaxDistance()) * 8);
       }
       if (swingVec != null) {
         double sin = Math.sin(10.0D * swingTicks * Math.PI / 180.0D);
         double f = 0.8D; // arbitrary horizontal motion factor
         thrower.motionX = (sin * swingVec.xCoord * f);
         thrower.motionZ = (sin * swingVec.zCoord * f);
         // y motion needs to oscillate twice as quickly, so it goes up on the other side of the
         // swing
         thrower.motionY = dy * -Math.sin(20.0D * swingTicks * Math.PI / 180.0D);
         // check for horizontal collisions that should stop swinging motion
         MovingObjectPosition mop =
             TargetUtils.checkForImpact(worldObj, thrower, this, -(thrower.width / 4.0F), false);
         if (mop != null && mop.typeOfHit != MovingObjectType.MISS) {
           thrower.motionX = -thrower.motionX * 0.15D;
           thrower.motionY = -thrower.motionY * 0.15D;
           thrower.motionZ = -thrower.motionZ * 0.15D;
           swingVec = null;
         }
         ++swingTicks; // increment at end
         if (thrower.fallDistance > 0 && thrower.motionY < 0) {
           // 0.466885F seems to be roughly the amount added each tick while swinging; round for a
           // little extra server-side padding
           PacketDispatcher.sendToServer(new FallDistancePacket(thrower, -0.467F));
           thrower.fallDistance -= 0.467F;
         }
       } else if (swingTicks > 0) {
         // still let player hang there after colliding, but move towards center
         if (thrower.getDistanceSq(x, thrower.posY, z) > 1.0D) {
           double dx = x - thrower.posX;
           double dz = z - thrower.posZ;
           thrower.motionX = 0.15D * dx;
           thrower.motionZ = 0.15D * dz;
         }
         if (thrower.posY < (y - (getMaxDistance() / 2.0D))) {
           thrower.motionY = 0;
         }
         ++swingTicks; // increment at end
         PacketDispatcher.sendToServer(new FallDistancePacket(thrower, 0.0F));
         thrower.fallDistance = 0.0F;
       }
     }
   }
 }
  @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();
  }