Esempio n. 1
0
  @Override
  public void doPostExplode() {
    super.doPostExplode();

    if (!this.worldObj.isRemote) {
      if (this.canFocusBeam(this.worldObj, position) && this.thread.isComplete) {
        /*
         * Freeze all nearby entities.
         */
        List<EntityLiving> livingEntities =
            worldObj.getEntitiesWithinAABB(
                EntityLiving.class,
                AxisAlignedBB.getBoundingBox(
                    position.xPos - getRadius(),
                    position.yPos - getRadius(),
                    position.zPos - getRadius(),
                    position.xPos + getRadius(),
                    position.yPos + getRadius(),
                    position.zPos + getRadius()));

        Iterator<EntityLiving> it = livingEntities.iterator();

        while (it.hasNext()) {
          EntityLiving entity = it.next();
          entity.addPotionEffect(
              new CustomPotionEffect(PoisonFrostBite.INSTANCE.getId(), 60 * 20, 1, null));
          entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 10 * 20, 2));
          entity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 120 * 20, 2));
          entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 120 * 20, 4));
        }

        for (Pos3D targetPosition : this.thread.results) {
          double distanceFromCenter = position.distance(targetPosition);

          if (distanceFromCenter > this.getRadius()) continue;

          /*
           * Reduce the chance of setting blocks on fire based on distance from center.
           */
          double chance = this.getRadius() - (Math.random() * distanceFromCenter);

          if (chance > distanceFromCenter * 0.55) {
            /*
             * Place down ice blocks.
             */
            Block block =
                this.worldObj.getBlock(
                    (int) targetPosition.xPos,
                    (int) targetPosition.yPos,
                    (int) targetPosition.zPos);

            if (block == Blocks.fire || block == Blocks.flowing_lava || block == Blocks.lava) {
              this.worldObj.setBlock(
                  (int) targetPosition.xPos,
                  (int) targetPosition.yPos,
                  (int) targetPosition.zPos,
                  Blocks.snow,
                  0,
                  2);
            } else if (worldObj.isAirBlock(
                    (int) targetPosition.xPos, (int) targetPosition.yPos, (int) targetPosition.zPos)
                && this.worldObj.getBlock(
                        (int) targetPosition.xPos,
                        (int) targetPosition.yPos - 1,
                        (int) targetPosition.zPos)
                    != Blocks.ice
                && !worldObj.isAirBlock(
                    (int) targetPosition.xPos,
                    (int) targetPosition.yPos - 1,
                    (int) targetPosition.zPos)) {
              this.worldObj.setBlock(
                  (int) targetPosition.xPos,
                  (int) targetPosition.yPos,
                  (int) targetPosition.zPos,
                  Blocks.ice,
                  0,
                  2);
            }
          }
        }

        this.worldObj.playSoundEffect(
            position.xPos + 0.5D,
            position.yPos + 0.5D,
            position.zPos + 0.5D,
            Reference.PREFIX + "redmatter",
            6.0F,
            (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 1F);
      }

      this.worldObj.setWorldTime(1200);
    }
  }
Esempio n. 2
0
 @Override
 public void doExplode() {
   super.doExplode();
   this.worldObj.playSoundEffect(
       position.xPos, position.yPos, position.zPos, Reference.PREFIX + "redmatter", 4.0F, 0.8F);
 }