コード例 #1
0
 protected void alertWolves(EntityLiving entityliving, boolean flag) {
   if ((entityliving instanceof EntityCreeper) || (entityliving instanceof EntityGhast)) {
     return;
   }
   if (entityliving instanceof EntityWolf) {
     EntityWolf entitywolf = (EntityWolf) entityliving;
     if (entitywolf.isTamed() && username.equals(entitywolf.getOwner())) {
       return;
     }
   }
   if ((entityliving instanceof EntityPlayer) && !isPVPEnabled()) {
     return;
   }
   List list =
       worldObj.getEntitiesWithinAABB(
           net.minecraft.src.EntityWolf.class,
           AxisAlignedBB.getBoundingBoxFromPool(
                   posX, posY, posZ, posX + 1.0D, posY + 1.0D, posZ + 1.0D)
               .expand(16D, 4D, 16D));
   Iterator iterator = list.iterator();
   do {
     if (!iterator.hasNext()) {
       break;
     }
     Entity entity = (Entity) iterator.next();
     EntityWolf entitywolf1 = (EntityWolf) entity;
     if (entitywolf1.isTamed()
         && entitywolf1.getEntityToAttack() == null
         && username.equals(entitywolf1.getOwner())
         && (!flag || !entitywolf1.isSitting())) {
       entitywolf1.setIsSitting(false);
       entitywolf1.setEntityToAttack(entityliving);
     }
   } while (true);
 }
コード例 #2
0
 public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) {
   int l = world.getBlockMetadata(i, j, k);
   float f = 0.0625F;
   float f1 = (float) (1 + l * 2) / 16F;
   float f2 = 0.5F;
   return AxisAlignedBB.getBoundingBoxFromPool(
       (float) i + f1,
       j,
       (float) k + f,
       (float) (i + 1) - f,
       ((float) j + f2) - f,
       (float) (k + 1) - f);
 }
コード例 #3
0
  // Ceci est pour passer à travers le bloc. Enlevez-le si vous ne vous les pas avoir un effet
  // "noclip".
  public AxisAlignedBB getCollisionBoundingBoxFromPool(
      World par1World, int par2, int par3, int par4) {
    int i = par1World.getBlockMetadata(par2, par3, par4) & 7;

    if (i >= 3) {
      return AxisAlignedBB.getBoundingBoxFromPool(
          (double) par2 + minX,
          (double) par3 + minY,
          (double) par4 + minZ,
          (double) par2 + maxX,
          (float) par3 + 0.5F,
          (double) par4 + maxZ);
    } else {
      return null;
    }
  }
コード例 #4
0
  /**
   * Called when the player attack or gets attacked, it's alert all wolves in the area that are
   * owned by the player to join the attack or defend the player.
   */
  protected void alertWolves(EntityLiving par1EntityLiving, boolean par2) {
    if (!(par1EntityLiving instanceof EntityCreeper)
        && !(par1EntityLiving instanceof EntityGhast)) {
      if (par1EntityLiving instanceof EntityWolf) {
        EntityWolf var3 = (EntityWolf) par1EntityLiving;

        if (var3.isTamed() && this.username.equals(var3.getOwnerName())) {
          return;
        }
      }

      if (!(par1EntityLiving instanceof EntityPlayer) || this.isPVPEnabled()) {
        List var7 =
            this.worldObj.getEntitiesWithinAABB(
                EntityWolf.class,
                AxisAlignedBB.getBoundingBoxFromPool(
                        this.posX,
                        this.posY,
                        this.posZ,
                        this.posX + 1.0D,
                        this.posY + 1.0D,
                        this.posZ + 1.0D)
                    .expand(16.0D, 4.0D, 16.0D));
        Iterator var4 = var7.iterator();

        while (var4.hasNext()) {
          Entity var5 = (Entity) var4.next();
          EntityWolf var6 = (EntityWolf) var5;

          if (var6.isTamed()
              && var6.getEntityToAttack() == null
              && this.username.equals(var6.getOwnerName())
              && (!par2 || !var6.isSitting())) {
            var6.setSitting(false);
            var6.setTarget(par1EntityLiving);
          }
        }
      }
    }
  }
コード例 #5
0
  /**
   * Called frequently so the entity can update its state every tick as required. For example,
   * zombies and skeletons use this to react to sunlight and start to burn.
   */
  public void onLivingUpdate() {
    super.onLivingUpdate();
    if (entityToAttack == null && !hasPath() && worldObj.rand.nextInt(100) == 0 && fixai) {
      List list =
          worldObj.getEntitiesWithinAABB(
              net.minecraft.src.EntityMob.class,
              AxisAlignedBB.getBoundingBoxFromPool(
                      posX, posY, posZ, posX + 1.0D, posY + 1.0D, posZ + 1.0D)
                  .expand(16D, 4D, 16D));
      if (!list.isEmpty()) {
        setTarget((Entity) list.get(worldObj.rand.nextInt(list.size())));
      }
    }

    if (isWet()) {
      attackEntityFrom(DamageSource.drown, 1);
    }

    int i = MathHelper.floor_double(posX);
    int k = MathHelper.floor_double(posZ);

    if (worldObj.getBiomeGenForCoords(i, k).getFloatTemperature() > 1.0F) {
      attackEntityFrom(DamageSource.onFire, 1);
    }

    for (int j = 0; j < 4; j++) {
      int l = MathHelper.floor_double(posX + (double) ((float) ((j % 2) * 2 - 1) * 0.25F));
      int i1 = MathHelper.floor_double(posY);
      int j1 = MathHelper.floor_double(posZ + (double) ((float) (((j / 2) % 2) * 2 - 1) * 0.25F));

      if (worldObj.getBlockId(l, i1, j1) == 0
          && worldObj.getBiomeGenForCoords(l, j1).getFloatTemperature() < 0.8F
          && Block.snow.canPlaceBlockAt(worldObj, l, i1, j1)) {
        worldObj.setBlockWithNotify(l, i1, j1, Block.snow.blockID);
      }
    }
  }
コード例 #6
0
 public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) {
   return AxisAlignedBB.getBoundingBoxFromPool(i + 0, j + 0, k + 0, i + 1, j + 1, k + 1);
 }
コード例 #7
0
ファイル: EntityBoat.java プロジェクト: Busboombot/Pixelmon
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.getTimeSinceHit() > 0) {
      this.setTimeSinceHit(this.getTimeSinceHit() - 1);
    }

    if (this.getDamageTaken() > 0) {
      this.setDamageTaken(this.getDamageTaken() - 1);
    }

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    byte var1 = 5;
    double var2 = 0.0D;

    for (int var4 = 0; var4 < var1; ++var4) {
      double var5 =
          this.boundingBox.minY
              + (this.boundingBox.maxY - this.boundingBox.minY)
                  * (double) (var4 + 0)
                  / (double) var1
              - 0.125D;
      double var7 =
          this.boundingBox.minY
              + (this.boundingBox.maxY - this.boundingBox.minY)
                  * (double) (var4 + 1)
                  / (double) var1
              - 0.125D;
      AxisAlignedBB var9 =
          AxisAlignedBB.getBoundingBoxFromPool(
              this.boundingBox.minX,
              var5,
              this.boundingBox.minZ,
              this.boundingBox.maxX,
              var7,
              this.boundingBox.maxZ);

      if (this.worldObj.isAABBInMaterial(var9, Material.water)) {
        var2 += 1.0D / (double) var1;
      }
    }

    double var21 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
    double var6;
    double var8;

    if (var21 > 0.15D) {
      var6 = Math.cos((double) this.rotationYaw * Math.PI / 180.0D);
      var8 = Math.sin((double) this.rotationYaw * Math.PI / 180.0D);

      for (int var10 = 0; (double) var10 < 1.0D + var21 * 60.0D; ++var10) {
        double var11 = (double) (this.rand.nextFloat() * 2.0F - 1.0F);
        double var13 = (double) (this.rand.nextInt(2) * 2 - 1) * 0.7D;
        double var15;
        double var17;

        if (this.rand.nextBoolean()) {
          var15 = this.posX - var6 * var11 * 0.8D + var8 * var13;
          var17 = this.posZ - var8 * var11 * 0.8D - var6 * var13;
          this.worldObj.spawnParticle(
              "splash", var15, this.posY - 0.125D, var17, this.motionX, this.motionY, this.motionZ);
        } else {
          var15 = this.posX + var6 + var8 * var11 * 0.7D;
          var17 = this.posZ + var8 - var6 * var11 * 0.7D;
          this.worldObj.spawnParticle(
              "splash", var15, this.posY - 0.125D, var17, this.motionX, this.motionY, this.motionZ);
        }
      }
    }

    double var12;
    double var23;

    if (this.worldObj.isRemote) {
      if (this.boatPosRotationIncrements > 0) {
        var6 = this.posX + (this.boatX - this.posX) / (double) this.boatPosRotationIncrements;
        var8 = this.posY + (this.boatY - this.posY) / (double) this.boatPosRotationIncrements;
        var23 = this.posZ + (this.boatZ - this.posZ) / (double) this.boatPosRotationIncrements;

        for (var12 = this.boatYaw - (double) this.rotationYaw; var12 < -180.0D; var12 += 360.0D) {;
        }

        while (var12 >= 180.0D) {
          var12 -= 360.0D;
        }

        this.rotationYaw =
            (float) ((double) this.rotationYaw + var12 / (double) this.boatPosRotationIncrements);
        this.rotationPitch =
            (float)
                ((double) this.rotationPitch
                    + (this.boatPitch - (double) this.rotationPitch)
                        / (double) this.boatPosRotationIncrements);
        --this.boatPosRotationIncrements;
        this.setPosition(var6, var8, var23);
        this.setRotation(this.rotationYaw, this.rotationPitch);
      } else {
        var6 = this.posX + this.motionX;
        var8 = this.posY + this.motionY;
        var23 = this.posZ + this.motionZ;
        this.setPosition(var6, var8, var23);

        if (this.onGround) {
          this.motionX *= 0.5D;
          this.motionY *= 0.5D;
          this.motionZ *= 0.5D;
        }

        this.motionX *= 0.9900000095367432D;
        this.motionY *= 0.949999988079071D;
        this.motionZ *= 0.9900000095367432D;
      }
    } else {
      if (var2 < 1.0D) {
        var6 = var2 * 2.0D - 1.0D;
        this.motionY += 0.03999999910593033D * var6;
      } else {
        if (this.motionY < 0.0D) {
          this.motionY /= 2.0D;
        }

        this.motionY += 0.007000000216066837D;
      }

      if (this.riddenByEntity != null) {
        this.motionX += this.riddenByEntity.motionX * 0.2D;
        this.motionZ += this.riddenByEntity.motionZ * 0.2D;
      }

      var6 = 0.4D;

      if (this.motionX < -var6) {
        this.motionX = -var6;
      }

      if (this.motionX > var6) {
        this.motionX = var6;
      }

      if (this.motionZ < -var6) {
        this.motionZ = -var6;
      }

      if (this.motionZ > var6) {
        this.motionZ = var6;
      }

      if (this.onGround) {
        this.motionX *= 0.5D;
        this.motionY *= 0.5D;
        this.motionZ *= 0.5D;
      }

      this.moveEntity(this.motionX, this.motionY, this.motionZ);

      if (this.isCollidedHorizontally && var21 > 0.2D) {
        if (!this.worldObj.isRemote) {
          this.setDead();
          int var22;

          for (var22 = 0; var22 < 3; ++var22) {
            this.dropItemWithOffset(Block.planks.blockID, 1, 0.0F);
          }

          for (var22 = 0; var22 < 2; ++var22) {
            this.dropItemWithOffset(Item.stick.shiftedIndex, 1, 0.0F);
          }
        }
      } else {
        this.motionX *= 0.9900000095367432D;
        this.motionY *= 0.949999988079071D;
        this.motionZ *= 0.9900000095367432D;
      }

      this.rotationPitch = 0.0F;
      var8 = (double) this.rotationYaw;
      var23 = this.prevPosX - this.posX;
      var12 = this.prevPosZ - this.posZ;

      if (var23 * var23 + var12 * var12 > 0.001D) {
        var8 = (double) ((float) (Math.atan2(var12, var23) * 180.0D / Math.PI));
      }

      double var14;

      for (var14 = var8 - (double) this.rotationYaw; var14 >= 180.0D; var14 -= 360.0D) {;
      }

      while (var14 < -180.0D) {
        var14 += 360.0D;
      }

      if (var14 > 20.0D) {
        var14 = 20.0D;
      }

      if (var14 < -20.0D) {
        var14 = -20.0D;
      }

      this.rotationYaw = (float) ((double) this.rotationYaw + var14);
      this.setRotation(this.rotationYaw, this.rotationPitch);
      List var16 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
      int var24;

      if (var16 != null && var16.size() > 0) {
        for (var24 = 0; var24 < var16.size(); ++var24) {
          Entity var18 = (Entity) var16.get(var24);

          if (var18 != this.riddenByEntity && var18.canBePushed() && var18 instanceof EntityBoat) {
            var18.applyEntityCollision(this);
          }
        }
      }

      for (var24 = 0; var24 < 4; ++var24) {
        int var25 = MathHelper.floor_double(this.posX + ((double) (var24 % 2) - 0.5D) * 0.8D);
        int var19 = MathHelper.floor_double(this.posY);
        int var20 = MathHelper.floor_double(this.posZ + ((double) (var24 / 2) - 0.5D) * 0.8D);

        if (this.worldObj.getBlockId(var25, var19, var20) == Block.snow.blockID) {
          this.worldObj.setBlockWithNotify(var25, var19, var20, 0);
        }
      }

      if (this.riddenByEntity != null && this.riddenByEntity.isDead) {
        this.riddenByEntity = null;
      }
    }
  }
コード例 #8
0
  public EnumStatus sleepInBedAt(int i, int j, int k) {
    if (!worldObj.multiplayerWorld) {
      if (isPlayerSleeping() || !isEntityAlive()) {
        return EnumStatus.OTHER_PROBLEM;
      }
      if (worldObj.worldProvider.isAlternateDimension) {
        return EnumStatus.NOT_POSSIBLE_HERE;
      }
      if (worldObj.isDaytime()) {
        return EnumStatus.NOT_POSSIBLE_NOW;
      }
      if (Math.abs(posX - (double) i) > 3D
          || Math.abs(posY - (double) j) > 2D
          || Math.abs(posZ - (double) k) > 3D) {
        return EnumStatus.TOO_FAR_AWAY;
      }
      double d = 8D;
      double d1 = 5D;
      List list =
          worldObj.getEntitiesWithinAABB(
              net.minecraft.src.EntityMob.class,
              AxisAlignedBB.getBoundingBoxFromPool(
                  (double) i - d,
                  (double) j - d1,
                  (double) k - d,
                  (double) i + d,
                  (double) j + d1,
                  (double) k + d));
      if (!list.isEmpty()) {
        return EnumStatus.NOT_SAFE;
      }
    }
    setSize(0.2F, 0.2F);
    yOffset = 0.2F;
    if (worldObj.blockExists(i, j, k)) {
      int l = worldObj.getBlockMetadata(i, j, k);
      int i1 = BlockBed.getDirectionFromMetadata(l);
      float f = 0.5F;
      float f1 = 0.5F;
      switch (i1) {
        case 0:
          f1 = 0.9F;
          break;

        case 2:
          f1 = 0.1F;
          break;

        case 1:
          f = 0.1F;
          break;

        case 3:
          f = 0.9F;
          break;
      }
      func_22052_e(i1);
      setPosition((float) i + f, (float) j + 0.9375F, (float) k + f1);
    } else {
      setPosition((float) i + 0.5F, (float) j + 0.9375F, (float) k + 0.5F);
    }
    sleeping = true;
    sleepTimer = 0;
    bedChunkCoordinates = new ChunkCoordinates(i, j, k);
    motionX = motionZ = motionY = 0.0D;
    if (!worldObj.multiplayerWorld) {
      worldObj.updateAllPlayersSleepingFlag();
    }
    return EnumStatus.OK;
  }
コード例 #9
0
 private void setStateIfMobInteractsWithPlate(World world, int i, int j, int k) {
   boolean flag = world.getBlockMetadata(i, j, k) == 1;
   boolean flag1 = false;
   float f = 0.125F;
   List list = null;
   if (triggerMobType == EnumMobType.everything) {
     list =
         world.getEntitiesWithinAABBExcludingEntity(
             null,
             AxisAlignedBB.getBoundingBoxFromPool(
                 (float) i + f,
                 j,
                 (float) k + f,
                 (float) (i + 1) - f,
                 (double) j + 0.25D,
                 (float) (k + 1) - f));
   }
   if (triggerMobType == EnumMobType.mobs) {
     list =
         world.getEntitiesWithinAABB(
             net.minecraft.src.EntityLiving.class,
             AxisAlignedBB.getBoundingBoxFromPool(
                 (float) i + f,
                 j,
                 (float) k + f,
                 (float) (i + 1) - f,
                 (double) j + 0.25D,
                 (float) (k + 1) - f));
   }
   if (triggerMobType == EnumMobType.players) {
     list =
         world.getEntitiesWithinAABB(
             net.minecraft.src.EntityPlayer.class,
             AxisAlignedBB.getBoundingBoxFromPool(
                 (float) i + f,
                 j,
                 (float) k + f,
                 (float) (i + 1) - f,
                 (double) j + 0.25D,
                 (float) (k + 1) - f));
   }
   if (list.size() > 0) {
     flag1 = true;
   }
   if (flag1 && !flag) {
     world.setBlockMetadataWithNotify(i, j, k, 1);
     world.notifyBlocksOfNeighborChange(i, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
     world.markBlocksDirty(i, j, k, i, j, k);
     world.playSoundEffect(
         (double) i + 0.5D,
         (double) j + 0.10000000000000001D,
         (double) k + 0.5D,
         "random.click",
         0.3F,
         0.6F);
   }
   if (!flag1 && flag) {
     world.setBlockMetadataWithNotify(i, j, k, 0);
     world.notifyBlocksOfNeighborChange(i, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
     world.markBlocksDirty(i, j, k, i, j, k);
     world.playSoundEffect(
         (double) i + 0.5D,
         (double) j + 0.10000000000000001D,
         (double) k + 0.5D,
         "random.click",
         0.3F,
         0.5F);
   }
   if (flag1) {
     world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
   }
 }
コード例 #10
0
  /** puts player to sleep on specified bed if possible */
  public EnumStatus sleepInBedAt(int par1, int par2, int par3) {
    EnumStatus customSleep = ForgeHooks.sleepInBedAt(this, par1, par2, par3);
    if (customSleep != null) {
      return customSleep;
    }

    if (!this.worldObj.isRemote) {
      if (this.isPlayerSleeping() || !this.isEntityAlive()) {
        return EnumStatus.OTHER_PROBLEM;
      }

      if (!this.worldObj.worldProvider.func_48567_d()) {
        return EnumStatus.NOT_POSSIBLE_HERE;
      }

      if (this.worldObj.isDaytime()) {
        return EnumStatus.NOT_POSSIBLE_NOW;
      }

      if (Math.abs(this.posX - (double) par1) > 3.0D
          || Math.abs(this.posY - (double) par2) > 2.0D
          || Math.abs(this.posZ - (double) par3) > 3.0D) {
        return EnumStatus.TOO_FAR_AWAY;
      }

      double var4 = 8.0D;
      double var6 = 5.0D;
      List var8 =
          this.worldObj.getEntitiesWithinAABB(
              EntityMob.class,
              AxisAlignedBB.getBoundingBoxFromPool(
                  (double) par1 - var4,
                  (double) par2 - var6,
                  (double) par3 - var4,
                  (double) par1 + var4,
                  (double) par2 + var6,
                  (double) par3 + var4));

      if (!var8.isEmpty()) {
        return EnumStatus.NOT_SAFE;
      }
    }

    this.setSize(0.2F, 0.2F);
    this.yOffset = 0.2F;

    if (this.worldObj.blockExists(par1, par2, par3)) {
      int var9 = this.worldObj.getBlockMetadata(par1, par2, par3);
      int var5 = BlockBed.getDirection(var9);
      Block block = Block.blocksList[worldObj.getBlockId(par1, par2, par3)];
      if (block != null) {
        var5 = block.getBedDirection(worldObj, par1, par2, par3);
      }
      float var10 = 0.5F;
      float var7 = 0.5F;

      switch (var5) {
        case 0:
          var7 = 0.9F;
          break;
        case 1:
          var10 = 0.1F;
          break;
        case 2:
          var7 = 0.1F;
          break;
        case 3:
          var10 = 0.9F;
      }

      this.func_22059_e(var5);
      this.setPosition(
          (double) ((float) par1 + var10),
          (double) ((float) par2 + 0.9375F),
          (double) ((float) par3 + var7));
    } else {
      this.setPosition(
          (double) ((float) par1 + 0.5F),
          (double) ((float) par2 + 0.9375F),
          (double) ((float) par3 + 0.5F));
    }

    this.sleeping = true;
    this.sleepTimer = 0;
    this.playerLocation = new ChunkCoordinates(par1, par2, par3);
    this.motionX = this.motionZ = this.motionY = 0.0D;

    if (!this.worldObj.isRemote) {
      this.worldObj.updateAllPlayersSleepingFlag();
    }

    return EnumStatus.OK;
  }
コード例 #11
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.fishPosRotationIncrements > 0) {
      double var21 = this.posX + (this.fishX - this.posX) / (double) this.fishPosRotationIncrements;
      double var22 = this.posY + (this.fishY - this.posY) / (double) this.fishPosRotationIncrements;
      double var23 = this.posZ + (this.fishZ - this.posZ) / (double) this.fishPosRotationIncrements;
      double var7;

      for (var7 = this.fishYaw - (double) this.rotationYaw; var7 < -180.0D; var7 += 360.0D) {;
      }

      while (var7 >= 180.0D) {
        var7 -= 360.0D;
      }

      this.rotationYaw =
          (float) ((double) this.rotationYaw + var7 / (double) this.fishPosRotationIncrements);
      this.rotationPitch =
          (float)
              ((double) this.rotationPitch
                  + (this.fishPitch - (double) this.rotationPitch)
                      / (double) this.fishPosRotationIncrements);
      --this.fishPosRotationIncrements;
      this.setPosition(var21, var22, var23);
      this.setRotation(this.rotationYaw, this.rotationPitch);
    } else {
      if (!this.worldObj.isRemote) {
        ItemStack var1 = this.angler.getCurrentEquippedItem();

        if (this.angler.isDead
            || !this.angler.isEntityAlive()
            || var1 == null
            || var1.getItem() != Item.fishingRod
            || this.getDistanceSqToEntity(this.angler) > 1024.0D) {
          this.setDead();
          this.angler.fishEntity = null;
          return;
        }

        if (this.bobber != null) {
          if (!this.bobber.isDead) {
            this.posX = this.bobber.posX;
            this.posY = this.bobber.boundingBox.minY + (double) this.bobber.height * 0.8D;
            this.posZ = this.bobber.posZ;
            return;
          }

          this.bobber = null;
        }
      }

      if (this.shake > 0) {
        --this.shake;
      }

      if (this.inGround) {
        int var19 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);

        if (var19 == this.inTile) {
          ++this.ticksInGround;

          if (this.ticksInGround == 1200) {
            this.setDead();
          }

          return;
        }

        this.inGround = false;
        this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
        this.ticksInGround = 0;
        this.ticksInAir = 0;
      } else {
        ++this.ticksInAir;
      }

      Vec3D var20 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      Vec3D var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition var3 = this.worldObj.rayTraceBlocks(var20, var2);
      var20 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      if (var3 != null) {
        var2 = Vec3D.createVector(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord);
      }

      Entity var4 = null;
      List var5 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double var6 = 0.0D;
      double var13;

      for (int var8 = 0; var8 < var5.size(); ++var8) {
        Entity var9 = (Entity) var5.get(var8);

        if (var9.canBeCollidedWith() && (var9 != this.angler || this.ticksInAir >= 5)) {
          float var10 = 0.3F;
          AxisAlignedBB var11 =
              var9.boundingBox.expand((double) var10, (double) var10, (double) var10);
          MovingObjectPosition var12 = var11.calculateIntercept(var20, var2);

          if (var12 != null) {
            var13 = var20.distanceTo(var12.hitVec);

            if (var13 < var6 || var6 == 0.0D) {
              var4 = var9;
              var6 = var13;
            }
          }
        }
      }

      if (var4 != null) {
        var3 = new MovingObjectPosition(var4);
      }

      if (var3 != null) {
        if (var3.entityHit != null) {
          if (var3.entityHit.attackEntityFrom(
              DamageSource.causeThrownDamage(this, this.angler), 0)) {
            this.bobber = var3.entityHit;
          }
        } else {
          this.inGround = true;
        }
      }

      if (!this.inGround) {
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
        float var24 =
            MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
        this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

        for (this.rotationPitch =
                (float) (Math.atan2(this.motionY, (double) var24) * 180.0D / Math.PI);
            this.rotationPitch - this.prevRotationPitch < -180.0F;
            this.prevRotationPitch -= 360.0F) {;
        }

        while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
          this.prevRotationPitch += 360.0F;
        }

        while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
          this.prevRotationYaw -= 360.0F;
        }

        while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
          this.prevRotationYaw += 360.0F;
        }

        this.rotationPitch =
            this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
        this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
        float var25 = 0.92F;

        if (this.onGround || this.isCollidedHorizontally) {
          var25 = 0.5F;
        }

        byte var27 = 5;
        double var26 = 0.0D;

        for (int var29 = 0; var29 < var27; ++var29) {
          double var14 =
              this.boundingBox.minY
                  + (this.boundingBox.maxY - this.boundingBox.minY)
                      * (double) (var29 + 0)
                      / (double) var27
                  - 0.125D
                  + 0.125D;
          double var16 =
              this.boundingBox.minY
                  + (this.boundingBox.maxY - this.boundingBox.minY)
                      * (double) (var29 + 1)
                      / (double) var27
                  - 0.125D
                  + 0.125D;
          AxisAlignedBB var18 =
              AxisAlignedBB.getBoundingBoxFromPool(
                  this.boundingBox.minX,
                  var14,
                  this.boundingBox.minZ,
                  this.boundingBox.maxX,
                  var16,
                  this.boundingBox.maxZ);

          if (this.worldObj.isAABBInMaterial(var18, Material.water)) {
            var26 += 1.0D / (double) var27;
          }
        }

        if (var26 > 0.0D) {
          if (this.ticksCatchable > 0) {
            --this.ticksCatchable;
          } else {
            short var28 = 500;

            if (this.worldObj.canLightningStrikeAt(
                MathHelper.floor_double(this.posX),
                MathHelper.floor_double(this.posY) + 1,
                MathHelper.floor_double(this.posZ))) {
              var28 = 300;
            }

            if (this.rand.nextInt(var28) == 0) {
              this.ticksCatchable = this.rand.nextInt(30) + 10;
              this.motionY -= 0.20000000298023224D;
              this.worldObj.playSoundAtEntity(
                  this,
                  "random.splash",
                  0.25F,
                  1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
              float var30 = (float) MathHelper.floor_double(this.boundingBox.minY);
              int var15;
              float var17;
              float var31;

              for (var15 = 0; (float) var15 < 1.0F + this.width * 20.0F; ++var15) {
                var31 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                var17 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                this.worldObj.spawnParticle(
                    "bubble",
                    this.posX + (double) var31,
                    (double) (var30 + 1.0F),
                    this.posZ + (double) var17,
                    this.motionX,
                    this.motionY - (double) (this.rand.nextFloat() * 0.2F),
                    this.motionZ);
              }

              for (var15 = 0; (float) var15 < 1.0F + this.width * 20.0F; ++var15) {
                var31 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                var17 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                this.worldObj.spawnParticle(
                    "splash",
                    this.posX + (double) var31,
                    (double) (var30 + 1.0F),
                    this.posZ + (double) var17,
                    this.motionX,
                    this.motionY,
                    this.motionZ);
              }
            }
          }
        }

        if (this.ticksCatchable > 0) {
          this.motionY -=
              (double) (this.rand.nextFloat() * this.rand.nextFloat() * this.rand.nextFloat())
                  * 0.2D;
        }

        var13 = var26 * 2.0D - 1.0D;
        this.motionY += 0.03999999910593033D * var13;

        if (var26 > 0.0D) {
          var25 = (float) ((double) var25 * 0.9D);
          this.motionY *= 0.8D;
        }

        this.motionX *= (double) var25;
        this.motionY *= (double) var25;
        this.motionZ *= (double) var25;
        this.setPosition(this.posX, this.posY, this.posZ);
      }
    }
  }
コード例 #12
0
  public void doExplosion() {
    float f = explosionSize;
    int i = 16;
    for (int j = 0; j < i; j++) {
      for (int l = 0; l < i; l++) {
        label0:
        for (int j1 = 0; j1 < i; j1++) {
          if (j != 0 && j != i - 1 && l != 0 && l != i - 1 && j1 != 0 && j1 != i - 1) {
            continue;
          }
          double d = ((float) j / ((float) i - 1.0F)) * 2.0F - 1.0F;
          double d1 = ((float) l / ((float) i - 1.0F)) * 2.0F - 1.0F;
          double d2 = ((float) j1 / ((float) i - 1.0F)) * 2.0F - 1.0F;
          double d3 = Math.sqrt(d * d + d1 * d1 + d2 * d2);
          d /= d3;
          d1 /= d3;
          d2 /= d3;
          float f1 = explosionSize * (0.7F + worldObj.rand.nextFloat() * 0.6F);
          double d5 = explosionX;
          double d7 = explosionY;
          double d9 = explosionZ;
          float f2 = 0.3F;
          do {
            if (f1 <= 0.0F) {
              continue label0;
            }
            int j4 = MathHelper.floor_double(d5);
            int k4 = MathHelper.floor_double(d7);
            int l4 = MathHelper.floor_double(d9);
            int i5 = worldObj.getBlockId(j4, k4, l4);
            if (i5 > 0) {
              f1 -= (Block.blocksList[i5].getExplosionResistance(exploder) + 0.3F) * f2;
            }
            if (f1 > 0.0F) {
              destroyedBlockPositions.add(new ChunkPosition(j4, k4, l4));
            }
            d5 += d * (double) f2;
            d7 += d1 * (double) f2;
            d9 += d2 * (double) f2;
            f1 -= f2 * 0.75F;
          } while (true);
        }
      }
    }

    explosionSize *= 2.0F;
    int k = MathHelper.floor_double(explosionX - (double) explosionSize - 1.0D);
    int i1 = MathHelper.floor_double(explosionX + (double) explosionSize + 1.0D);
    int k1 = MathHelper.floor_double(explosionY - (double) explosionSize - 1.0D);
    int l1 = MathHelper.floor_double(explosionY + (double) explosionSize + 1.0D);
    int i2 = MathHelper.floor_double(explosionZ - (double) explosionSize - 1.0D);
    int j2 = MathHelper.floor_double(explosionZ + (double) explosionSize + 1.0D);
    List list =
        worldObj.getEntitiesWithinAABBExcludingEntity(
            exploder, AxisAlignedBB.getBoundingBoxFromPool(k, k1, i2, i1, l1, j2));
    Vec3D vec3d = Vec3D.createVector(explosionX, explosionY, explosionZ);
    for (int k2 = 0; k2 < list.size(); k2++) {
      Entity entity = (Entity) list.get(k2);
      double d4 = entity.getDistance(explosionX, explosionY, explosionZ) / (double) explosionSize;
      if (d4 <= 1.0D) {
        double d6 = entity.posX - explosionX;
        double d8 = entity.posY - explosionY;
        double d10 = entity.posZ - explosionZ;
        double d11 = MathHelper.sqrt_double(d6 * d6 + d8 * d8 + d10 * d10);
        d6 /= d11;
        d8 /= d11;
        d10 /= d11;
        double d12 = worldObj.func_494_a(vec3d, entity.boundingBox);
        double d13 = (1.0D - d4) * d12;
        entity.attackEntityFrom(
            exploder, (int) (((d13 * d13 + d13) / 2D) * 8D * (double) explosionSize + 1.0D));
        double d14 = d13;
        entity.motionX += d6 * d14;
        entity.motionY += d8 * d14;
        entity.motionZ += d10 * d14;
      }
    }

    explosionSize = f;
    ArrayList arraylist = new ArrayList();
    arraylist.addAll(destroyedBlockPositions);
    if (isFlaming) {
      for (int l2 = arraylist.size() - 1; l2 >= 0; l2--) {
        ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l2);
        int i3 = chunkposition.x;
        int j3 = chunkposition.y;
        int k3 = chunkposition.z;
        int l3 = worldObj.getBlockId(i3, j3, k3);
        int i4 = worldObj.getBlockId(i3, j3 - 1, k3);
        if (l3 == 0 && Block.opaqueCubeLookup[i4] && ExplosionRNG.nextInt(3) == 0) {
          worldObj.setBlockWithNotify(i3, j3, k3, Block.fire.blockID);
        }
      }
    }
  }