Example #1
0
  /** Checks if the entity's current position is a valid location to spawn this entity. */
  public boolean getCanSpawnHere() {
    if (this.worldObj.rand.nextInt(3) == 0) {
      return false;
    } else {
      if (this.worldObj.checkIfAABBIsClear(this.boundingBox)
          && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).size() == 0
          && !this.worldObj.isAnyLiquid(this.boundingBox)) {
        int var1 = MathHelper.floor_double(this.posX);
        int var2 = MathHelper.floor_double(this.boundingBox.minY);
        int var3 = MathHelper.floor_double(this.posZ);

        if (var2 < 63) {
          return false;
        }

        int var4 = this.worldObj.getBlockId(var1, var2 - 1, var3);

        if (var4 == Block.grass.blockID || var4 == Block.leaves.blockID) {
          return true;
        }
      }

      return false;
    }
  }
  /** Gets the safe pathing Y position for the entity depending on if it can path swim or not */
  private int getPathableYPos() {
    if (this.theEntity.isInWater() && this.canSwim) {
      int var1 = (int) this.theEntity.boundingBox.minY;
      int var2 =
          this.worldObj.getBlockId(
              MathHelper.floor_double(this.theEntity.posX),
              var1,
              MathHelper.floor_double(this.theEntity.posZ));
      int var3 = 0;

      do {
        if (var2 != Block.waterMoving.blockID && var2 != Block.waterStill.blockID) {
          return var1;
        }

        ++var1;
        var2 =
            this.worldObj.getBlockId(
                MathHelper.floor_double(this.theEntity.posX),
                var1,
                MathHelper.floor_double(this.theEntity.posZ));
        ++var3;
      } while (var3 <= 16);

      return (int) this.theEntity.boundingBox.minY;
    } else {
      return (int) (this.theEntity.boundingBox.minY + 0.5D);
    }
  }
Example #3
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 (this.attackTimer > 0) {
      --this.attackTimer;
    }

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

    if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D
        && this.rand.nextInt(5) == 0) {
      int var1 = MathHelper.floor_double(this.posX);
      int var2 = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double) this.yOffset);
      int var3 = MathHelper.floor_double(this.posZ);
      int var4 = this.worldObj.getBlockId(var1, var2, var3);

      if (var4 > 0) {
        this.worldObj.spawnParticle(
            "tilecrack_" + var4 + "_" + this.worldObj.getBlockMetadata(var1, var2, var3),
            this.posX + ((double) this.rand.nextFloat() - 0.5D) * (double) this.width,
            this.boundingBox.minY + 0.1D,
            this.posZ + ((double) this.rand.nextFloat() - 0.5D) * (double) this.width,
            4.0D * ((double) this.rand.nextFloat() - 0.5D),
            0.5D,
            ((double) this.rand.nextFloat() - 0.5D) * 4.0D);
      }
    }
  }
 /** Try to find and set a path to XYZ. Returns true if successful. */
 public boolean tryMoveToXYZ(double par1, double par3, double par5, float par7) {
   PathEntity var8 =
       this.getPathToXYZ(
           (double) MathHelper.floor_double(par1),
           (double) ((int) par3),
           (double) MathHelper.floor_double(par5));
   return this.setPath(var8, par7);
 }
Example #5
0
 public boolean getCanSpawnHere() {
   int i = MathHelper.floor_double(posX);
   int j = MathHelper.floor_double(boundingBox.minY);
   int k = MathHelper.floor_double(posZ);
   return worldObj.getBlockId(i, j - 1, k) == Block.grass.blockID
       && worldObj.getFullBlockLightValue(i, j, k) > 8
       && super.getCanSpawnHere();
 }
 /** Returns the path to the given coordinates */
 public PathEntity getPathToXYZ(double par1, double par3, double par5) {
   return !this.canNavigate()
       ? null
       : this.worldObj.getEntityPathToXYZ(
           this.theEntity,
           MathHelper.floor_double(par1),
           (int) par3,
           MathHelper.floor_double(par5),
           this.pathSearchRange,
           this.canPassOpenWoodenDoors,
           this.canPassClosedWoodenDoors,
           this.avoidsWater,
           this.canSwim);
 }
 public void onLivingUpdate() {
   if (worldObj.isDaytime() && !worldObj.multiplayerWorld) {
     float f = getEntityBrightness(1.0F);
     if (f > 0.5F
         && worldObj.canBlockSeeTheSky(
             MathHelper.floor_double(posX),
             MathHelper.floor_double(posY),
             MathHelper.floor_double(posZ))
         && rand.nextFloat() * 30F < (f - 0.4F) * 2.0F) {
       // setFire(8);
     }
   }
   super.onLivingUpdate();
 }
  /** Trims path data from the end to the first sun covered block */
  private void removeSunnyPath() {
    if (!this.worldObj.canBlockSeeTheSky(
        MathHelper.floor_double(this.theEntity.posX),
        (int) (this.theEntity.boundingBox.minY + 0.5D),
        MathHelper.floor_double(this.theEntity.posZ))) {
      for (int var1 = 0; var1 < this.currentPath.getCurrentPathLength(); ++var1) {
        PathPoint var2 = this.currentPath.getPathPointFromIndex(var1);

        if (this.worldObj.canBlockSeeTheSky(var2.xCoord, var2.yCoord, var2.zCoord)) {
          this.currentPath.setCurrentPathLength(var1 - 1);
          return;
        }
      }
    }
  }
  /** Called upon block activation (right click on the block.) */
  public boolean onBlockActivated(
      World par1World,
      int par2,
      int par3,
      int par4,
      EntityPlayer par5EntityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    int var10 = par1World.getBlockMetadata(par2, par3, par4);

    if (isFenceGateOpen(var10)) {
      par1World.setBlockMetadataWithNotify(par2, par3, par4, var10 & -5, 2);
    } else {
      int var11 =
          (MathHelper.floor_double((double) (par5EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D)
                  & 3)
              % 4;
      int var12 = getDirection(var10);

      if (var12 == (var11 + 2) % 4) {
        var10 = var11;
      }

      par1World.setBlockMetadataWithNotify(par2, par3, par4, var10 | 4, 2);
    }

    par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
    return true;
  }
Example #10
0
 @Override
 public void onBlockPlacedBy(
     World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
   final int angle = MathHelper.floor_double(placer.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
   int change = EnumFacing.getHorizontal(angle).getOpposite().getIndex();
   worldIn.setBlockState(pos, getStateFromMeta(change), 3);
 }
  @Override
  public boolean func_71903_a(
      World par1World,
      int par2,
      int par3,
      int par4,
      EntityPlayer par5EntityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    int i = par1World.getBlockMetadata(par2, par3, par4);

    if (isFenceGateOpen(i)) {
      par1World.setBlockMetadataWithNotify(par2, par3, par4, i & -5);
    } else {
      int j =
          (MathHelper.floor_double(((par5EntityPlayer.rotationYaw * 4F) / 360F) + 0.5D) & 3) % 4;
      int k = getDirection(i);

      if (k == (j + 2) % 4) {
        i = j;
      }

      par1World.setBlockMetadataWithNotify(par2, par3, par4, i | 4);
    }

    par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
    return true;
  }
  /** Returns whether the EntityAIBase should begin execution. */
  public boolean shouldExecute() {
    if ((!this.entityObj.worldObj.isDaytime() || this.entityObj.worldObj.isRaining())
        && !this.entityObj.worldObj.worldProvider.hasNoSky) {
      if (this.entityObj.getRNG().nextInt(50) != 0) {
        return false;
      } else if (this.insidePosX != -1
          && this.entityObj.getDistanceSq(
                  (double) this.insidePosX, this.entityObj.posY, (double) this.insidePosZ)
              < 4.0D) {
        return false;
      } else {
        Village var1 =
            this.entityObj.worldObj.villageCollectionObj.findNearestVillage(
                MathHelper.floor_double(this.entityObj.posX),
                MathHelper.floor_double(this.entityObj.posY),
                MathHelper.floor_double(this.entityObj.posZ),
                14);

        if (var1 == null) {
          return false;
        } else {
          this.doorInfo =
              var1.findNearestDoorUnrestricted(
                  MathHelper.floor_double(this.entityObj.posX),
                  MathHelper.floor_double(this.entityObj.posY),
                  MathHelper.floor_double(this.entityObj.posZ));
          return this.doorInfo != null;
        }
      }
    } else {
      return false;
    }
  }
 /** Called when the block is placed in the world. */
 public void onBlockPlacedBy(
     World par1World,
     int par2,
     int par3,
     int par4,
     EntityLiving par5EntityLiving,
     ItemStack par6ItemStack) {
   int var7 =
       (MathHelper.floor_double((double) (par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D)
               & 3)
           % 4;
   par1World.setBlockMetadataWithNotify(par2, par3, par4, var7, 2);
 }
  @Override
  protected void readEntityFromNBT(NBTTagCompound nbt) {
    super.readEntityFromNBT(nbt);

    if (nbt.hasKey("fuelTank")) {
      this.fuelTank.readFromNBT(nbt.getCompoundTag("fuelTank"));
    }

    if (this.getSizeInventory() > 0) {
      final NBTTagList var2 = nbt.getTagList("Items", 10);
      this.cargoItems = new ItemStack[this.getSizeInventory()];

      for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
        final NBTTagCompound var4 = var2.getCompoundTagAt(var3);
        final int var5 = var4.getByte("Slot") & 255;

        if (var5 < this.cargoItems.length) {
          this.cargoItems[var5] = ItemStack.loadItemStackFromNBT(var4);
        }
      }
    }

    if (nbt.getBoolean("TargetValid") && nbt.hasKey("targetTileX")) {
      this.targetVec =
          new BlockPos(
              MathHelper.floor_double(nbt.getDouble("targetTileX")),
              MathHelper.floor_double(nbt.getDouble("targetTileY")),
              MathHelper.floor_double(nbt.getDouble("targetTileZ")));
    }

    this.setWaitForPlayer(nbt.getBoolean("WaitingForPlayer"));
    this.landing = nbt.getBoolean("Landing");
    int autoLaunchValue = nbt.getInteger("AutoLaunchSetting");
    this.autoLaunchSetting =
        autoLaunchValue == -1 ? null : EnumAutoLaunch.values()[autoLaunchValue];
    this.autoLaunchCountdown = nbt.getInteger("TimeUntilAutoLaunch");
    this.destinationFrequency = nbt.getInteger("DestinationFrequency");
  }
Example #15
0
  /** main AI tick function, replaces updateEntityActionState */
  protected void updateAITick() {
    if (--this.homeCheckTimer <= 0) {
      this.homeCheckTimer = 70 + this.rand.nextInt(50);
      this.villageObj =
          this.worldObj.villageCollectionObj.findNearestVillage(
              MathHelper.floor_double(this.posX),
              MathHelper.floor_double(this.posY),
              MathHelper.floor_double(this.posZ),
              32);

      if (this.villageObj == null) {
        this.func_110177_bN();
      } else {
        ChunkCoordinates var1 = this.villageObj.getCenter();
        this.func_110171_b(
            var1.posX,
            var1.posY,
            var1.posZ,
            (int) ((float) this.villageObj.getVillageRadius() * 0.6F));
      }
    }

    super.updateAITick();
  }
 @Override
 public void onUpdate() {
   if (blockID == 0) {
     setEntityDead();
     return;
   }
   prevPosX = posX;
   prevPosY = posY;
   prevPosZ = posZ;
   fallTime++;
   motionY -= 0.039999999105930328D;
   moveEntity(motionX, motionY, motionZ);
   motionX *= 0.98000001907348633D;
   motionY *= 0.98000001907348633D;
   motionZ *= 0.98000001907348633D;
   int i = MathHelper.floor_double(posX);
   int j = MathHelper.floor_double(posY);
   int k = MathHelper.floor_double(posZ);
   if (worldObj.getBlockId(i, j, k) == blockID) {
     worldObj.setBlockWithNotify(i, j, k, 0);
   }
   if (onGround) {
     motionX *= 0.69999998807907104D;
     motionZ *= 0.69999998807907104D;
     motionY *= -0.5D;
     setEntityDead();
     if ((!worldObj.canBlockBePlacedAt(blockID, i, j, k, true)
             || !worldObj.setBlockAndMetadataWithNotify(i, j, k, blockID, damage))
         && !worldObj.multiplayerWorld) {
       entityDropItem(new ItemStack(StainedGlassConstants.sandID, 1, damage), 0F);
     }
   } else if (fallTime > 100 && !worldObj.multiplayerWorld) {
     entityDropItem(new ItemStack(StainedGlassConstants.sandID, 1, damage), 0F);
     setEntityDead();
   }
 }
Example #17
0
  public boolean func_77648_a(
      ItemStack par1ItemStack,
      EntityPlayer par2EntityPlayer,
      World par3World,
      int par4,
      int par5,
      int par6,
      int par7,
      float par8,
      float par9,
      float par10) {
    if (par7 != 1) {
      return false;
    }

    par5++;
    Block block;

    if (doorMaterial == Material.wood) {
      block = Block.doorWood;
    } else {
      block = Block.doorSteel;
    }

    if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6)
        || !par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6)) {
      return false;
    }

    if (!block.canPlaceBlockAt(par3World, par4, par5, par6)) {
      return false;
    } else {
      int i =
          MathHelper.floor_double(
                  (double) (((par2EntityPlayer.rotationYaw + 180F) * 4F) / 360F) - 0.5D)
              & 3;
      placeDoorBlock(par3World, par4, par5, par6, i, block);
      par1ItemStack.stackSize--;
      return true;
    }
  }
Example #18
0
  public void onUpdateMoveHelper() {
    this.entity.setMoveForward(0.0F);

    if (this.field_46074_f) {
      this.field_46074_f = false;
      int var1 = MathHelper.floor_double(this.entity.boundingBox.minY + 0.5D);
      double var2 = this.posX - this.entity.posX;
      double var4 = this.posZ - this.entity.posZ;
      double var6 = this.posY - (double) var1;
      double var8 = var2 * var2 + var6 * var6 + var4 * var4;

      if (var8 >= 2.500000277905201E-7D) {
        float var10 = (float) (Math.atan2(var4, var2) * 180.0D / Math.PI) - 90.0F;
        this.entity.rotationYaw = this.func_48437_a(this.entity.rotationYaw, var10, 30.0F);
        this.entity.setAIMoveSpeed(this.speed);

        if (var6 > 0.0D && var2 * var2 + var4 * var4 < 1.0D) {
          this.entity.getJumpHelper().setJumping();
        }
      }
    }
  }
Example #19
0
 public boolean onItemUse(
     ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
   if (l != 1) {
     return false;
   }
   j++;
   BlockBed blockbed = (BlockBed) Block.bed;
   int i1 = MathHelper.floor_double((double) ((entityplayer.rotationYaw * 4F) / 360F) + 0.5D) & 3;
   byte byte0 = 0;
   byte byte1 = 0;
   if (i1 == 0) {
     byte1 = 1;
   }
   if (i1 == 1) {
     byte0 = -1;
   }
   if (i1 == 2) {
     byte1 = -1;
   }
   if (i1 == 3) {
     byte0 = 1;
   }
   if (!entityplayer.func_35190_e(i, j, k)
       || !entityplayer.func_35190_e(i + byte0, j, k + byte1)) {
     return false;
   }
   if (world.isAirBlock(i, j, k)
       && world.isAirBlock(i + byte0, j, k + byte1)
       && world.isBlockNormalCube(i, j - 1, k)
       && world.isBlockNormalCube(i + byte0, j - 1, k + byte1)) {
     world.setBlockAndMetadataWithNotify(i, j, k, blockbed.blockID, i1);
     world.setBlockAndMetadataWithNotify(i + byte0, j, k + byte1, blockbed.blockID, i1 + 8);
     itemstack.stackSize--;
     return true;
   } else {
     return false;
   }
 }
  @Override
  protected void failRocket() {
    if (this.shouldCancelExplosion()) {
      for (int i = -3; i <= 3; i++) {
        BlockPos pos =
            new BlockPos(
                (int) Math.floor(this.posX),
                (int) Math.floor(this.posY + i),
                (int) Math.floor(this.posZ));
        if (this.landing
            && this.targetVec != null
            && this.worldObj.getTileEntity(pos) instanceof IFuelDock
            && this.posY - this.targetVec.getY() < 5) {
          for (int x = MathHelper.floor_double(this.posX) - 1;
              x <= MathHelper.floor_double(this.posX) + 1;
              x++) {
            for (int y = MathHelper.floor_double(this.posY - 3.0D);
                y <= MathHelper.floor_double(this.posY) + 1;
                y++) {
              for (int z = MathHelper.floor_double(this.posZ) - 1;
                  z <= MathHelper.floor_double(this.posZ) + 1;
                  z++) {
                BlockPos pos1 = new BlockPos(x, y, z);
                TileEntity tile = this.worldObj.getTileEntity(pos1);

                if (tile instanceof IFuelDock) {
                  this.landEntity(pos1);
                  return;
                }
              }
            }
          }
        }
      }
    }

    if (this.launchPhase == EnumLaunchPhase.LAUNCHED.ordinal()) {
      super.failRocket();
    }
  }
Example #21
0
  /**
   * Checks for block collisions, and calls the associated onBlockCollided method for the collided
   * block.
   */
  protected void doBlockCollisions() {
    int var1 = MathHelper.floor_double(this.boundingBox.minX + 0.001D);
    int var2 = MathHelper.floor_double(this.boundingBox.minY - 0.01D);
    int var3 = MathHelper.floor_double(this.boundingBox.minZ + 0.001D);
    int var4 = MathHelper.floor_double(this.boundingBox.maxX - 0.001D);
    int var5 = MathHelper.floor_double(this.boundingBox.maxY - 0.001D);
    int var6 = MathHelper.floor_double(this.boundingBox.maxZ - 0.001D);

    if (this.worldObj.checkChunksExist(var1, var2, var3, var4, var5, var6)) {
      for (int var7 = var1; var7 <= var4; ++var7) {
        for (int var8 = var2; var8 <= var5; ++var8) {
          for (int var9 = var3; var9 <= var6; ++var9) {
            int var10 = this.worldObj.getBlockId(var7, var8, var9);

            if (var10 > 0) {
              Block.blocksList[var10].onEntityCollidedWithBlock(
                  this.worldObj, var7, var8, var9, this);
            }
          }
        }
      }
    }
  }
  public boolean setFrequency() {
    if (!GalacticraftCore.isPlanetsLoaded) {
      return false;
    }

    for (int x = MathHelper.floor_double(this.posX) - 1;
        x <= MathHelper.floor_double(this.posX) + 1;
        x++) {
      for (int y = MathHelper.floor_double(this.posY) - 3;
          y <= MathHelper.floor_double(this.posY) + 1;
          y++) {
        for (int z = MathHelper.floor_double(this.posZ) - 1;
            z <= MathHelper.floor_double(this.posZ) + 1;
            z++) {
          BlockPos pos = new BlockPos(x, y, z);
          TileEntity tile = this.worldObj.getTileEntity(pos);

          if (tile instanceof IFuelDock) {
            IFuelDock dock = (IFuelDock) tile;

            try {
              TileEntity launchController = null;
              Class<?> controllerClass =
                  Class.forName(
                      "micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController");

              for (ILandingPadAttachable connectedTile : dock.getConnectedTiles()) {
                try {
                  controllerClass.cast(connectedTile);
                } catch (ClassCastException e) {
                  continue;
                }

                launchController = (TileEntity) connectedTile;
                if (launchController != null) {
                  TileEntity tile2 =
                      launchController.getWorld().getTileEntity(launchController.getPos());

                  try {
                    controllerClass.cast(tile2);
                  } catch (ClassCastException e) {
                    launchController = null;
                    continue;
                  }

                  launchController = tile2;
                }

                if (launchController != null) {
                  break;
                }
              }

              if (launchController != null) {
                Boolean b =
                    (Boolean) controllerClass.getMethod("validFrequency").invoke(launchController);

                if (b != null && b) {
                  int controllerFrequency =
                      controllerClass.getField("destFrequency").getInt(launchController);
                  boolean foundPad = this.setTarget(false, controllerFrequency);

                  if (foundPad) {
                    this.destinationFrequency = controllerFrequency;
                    GCLog.debug(
                        "Rocket under launch control: going to target frequency "
                            + controllerFrequency);
                    return true;
                  }
                }
              }
            } catch (ClassCastException e) {
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        }
      }
    }

    this.destinationFrequency = -1;
    return false;
  }
Example #23
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

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

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionY -= 0.029999999329447746D;

    if (this.worldObj.getBlockMaterial(
            MathHelper.floor_double(this.posX),
            MathHelper.floor_double(this.posY),
            MathHelper.floor_double(this.posZ))
        == Material.lava) {
      this.motionY = 0.20000000298023224D;
      this.motionX = (double) ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
      this.motionZ = (double) ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
      this.worldObj.playSoundAtEntity(
          this, "random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F);
    }

    this.pushOutOfBlocks(
        this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ);
    double var1 = 8.0D;

    if (this.field_80002_g < this.xpColor - 20 + this.entityId % 100) {
      if ((this.closestPlayer == null
              || this.closestPlayer.getDistanceSqToEntity(this) > var1 * var1)
          && !this.m_bNotPlayerOwned) {
        this.closestPlayer = this.worldObj.getClosestPlayerToEntity(this, var1);
      }

      this.field_80002_g = this.xpColor;
    }

    if (this.closestPlayer != null) {
      double var3 = (this.closestPlayer.posX - this.posX) / var1;
      double var5 =
          (this.closestPlayer.posY + (double) this.closestPlayer.getEyeHeight() - this.posY) / var1;
      double var7 = (this.closestPlayer.posZ - this.posZ) / var1;
      double var9 = var3 * var3 + var5 * var5 + var7 * var7;

      if (var9 < 1.0D) {
        double var11 = Math.sqrt(var9);
        double var13 = 1.0D - var11;
        var13 *= var13;
        this.motionX += var3 / var11 * var13 * 0.1D;
        this.motionY += var5 / var11 * var13 * 0.1D;
        this.motionZ += var7 / var11 * var13 * 0.1D;
      }
    }

    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    float var15 = 0.98F;

    if (this.onGround) {
      var15 = 0.5880001F;
      int var4 =
          this.worldObj.getBlockId(
              MathHelper.floor_double(this.posX),
              MathHelper.floor_double(this.boundingBox.minY) - 1,
              MathHelper.floor_double(this.posZ));

      if (var4 > 0) {
        var15 = Block.blocksList[var4].slipperiness * 0.98F;
      }
    }

    this.motionX *= (double) var15;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= (double) var15;

    if (this.onGround) {
      this.motionY *= -0.8999999761581421D;
    }

    ++this.xpColor;
    ++this.xpOrbAge;

    if (this.xpOrbAge >= 6000) {
      this.setDead();
    }
  }
  @Override
  public void onLaunch() {
    if (!(this.worldObj.provider.getDimensionId()
            == GalacticraftCore.planetOverworld.getDimensionID()
        || this.worldObj.provider instanceof IGalacticraftWorldProvider)) {
      if (ConfigManagerCore.disableRocketLaunchAllNonGC) {
        this.cancelLaunch();
        return;
      }

      // No rocket flight in the Nether, the End etc
      for (int i = ConfigManagerCore.disableRocketLaunchDimensions.length - 1; i >= 0; i--) {
        if (ConfigManagerCore.disableRocketLaunchDimensions[i]
            == this.worldObj.provider.getDimensionId()) {
          this.cancelLaunch();
          return;
        }
      }
    }

    super.onLaunch();

    if (!this.worldObj.isRemote) {
      GCPlayerStats stats = null;

      if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayerMP) {
        stats = GCPlayerStats.get((EntityPlayerMP) this.riddenByEntity);

        if (!(this.worldObj.provider instanceof IOrbitDimension)) {
          stats.coordsTeleportedFromX = this.riddenByEntity.posX;
          stats.coordsTeleportedFromZ = this.riddenByEntity.posZ;
        }
      }

      int amountRemoved = 0;

      PADSEARCH:
      for (int x = MathHelper.floor_double(this.posX) - 1;
          x <= MathHelper.floor_double(this.posX) + 1;
          x++) {
        for (int y = MathHelper.floor_double(this.posY) - 3;
            y <= MathHelper.floor_double(this.posY) + 1;
            y++) {
          for (int z = MathHelper.floor_double(this.posZ) - 1;
              z <= MathHelper.floor_double(this.posZ) + 1;
              z++) {
            BlockPos pos = new BlockPos(x, y, z);
            final Block block = this.worldObj.getBlockState(pos).getBlock();

            if (block != null && block instanceof BlockLandingPadFull) {
              if (amountRemoved < 9) {
                EventLandingPadRemoval event = new EventLandingPadRemoval(this.worldObj, pos);
                MinecraftForge.EVENT_BUS.post(event);

                if (event.allow) {
                  this.worldObj.setBlockToAir(pos);
                  amountRemoved = 9;
                }
                break PADSEARCH;
              }
            }
          }
        }
      }

      // Set the player's launchpad item for return on landing - or null if launchpads not removed
      if (stats != null) {
        stats.launchpadStack = amountRemoved == 9 ? new ItemStack(GCBlocks.landingPad, 9, 0) : null;
      }

      this.playSound(
          "random.pop",
          0.2F,
          ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
    }
  }
  /** Internal implementation of creating a path from an entity to a point */
  private PathEntity createEntityPathTo(
      Entity par1Entity, double par2, double par4, double par6, float par8) {
    this.path.clearPath();
    this.pointMap.clearMap();
    boolean var9 = this.isPathingInWater;
    int var10 = MathHelper.floor_double(par1Entity.boundingBox.minY + 0.5D);

    if (this.canEntityDrown && par1Entity.isInWater()) {
      var10 = (int) par1Entity.boundingBox.minY;

      for (int var11 =
              this.worldMap.getBlockId(
                  MathHelper.floor_double(par1Entity.posX),
                  var10,
                  MathHelper.floor_double(par1Entity.posZ));
          var11 == Block.waterMoving.blockID || var11 == Block.waterStill.blockID;
          var11 =
              this.worldMap.getBlockId(
                  MathHelper.floor_double(par1Entity.posX),
                  var10,
                  MathHelper.floor_double(par1Entity.posZ))) {
        ++var10;
      }

      var9 = this.isPathingInWater;
      this.isPathingInWater = false;
    } else {
      var10 = MathHelper.floor_double(par1Entity.boundingBox.minY + 0.5D);
    }

    PathPoint var15 =
        this.openPoint(
            MathHelper.floor_double(par1Entity.boundingBox.minX),
            var10,
            MathHelper.floor_double(par1Entity.boundingBox.minZ));
    PathPoint var12 =
        this.openPoint(
            MathHelper.floor_double(par2 - (double) (par1Entity.width / 2.0F)),
            MathHelper.floor_double(par4),
            MathHelper.floor_double(par6 - (double) (par1Entity.width / 2.0F)));
    PathPoint var13 =
        new PathPoint(
            MathHelper.floor_float(par1Entity.width + 1.0F),
            MathHelper.floor_float(par1Entity.height + 1.0F),
            MathHelper.floor_float(par1Entity.width + 1.0F));
    PathEntity var14 = this.addToPath(par1Entity, var15, var12, var13, par8);
    this.isPathingInWater = var9;
    return var14;
  }
  public static int func_82565_a(
      Entity par0Entity,
      int par1,
      int par2,
      int par3,
      PathPoint par4PathPoint,
      boolean par5,
      boolean par6,
      boolean par7) {
    boolean var8 = false;

    for (int var9 = par1; var9 < par1 + par4PathPoint.xCoord; ++var9) {
      for (int var10 = par2; var10 < par2 + par4PathPoint.yCoord; ++var10) {
        for (int var11 = par3; var11 < par3 + par4PathPoint.zCoord; ++var11) {
          int var12 = par0Entity.worldObj.getBlockId(var9, var10, var11);

          if (var12 > 0) {
            if (var12 == Block.trapdoor.blockID) {
              var8 = true;
            } else if (var12 != Block.waterMoving.blockID && var12 != Block.waterStill.blockID) {
              if (!par7 && var12 == Block.doorWood.blockID) {
                return 0;
              }
            } else {
              if (par5) {
                return -1;
              }

              var8 = true;
            }

            Block var13 = Block.blocksList[var12];
            int var14 = var13.getRenderType();

            if (par0Entity.worldObj.blockGetRenderType(var9, var10, var11) == 9) {
              int var18 = MathHelper.floor_double(par0Entity.posX);
              int var16 = MathHelper.floor_double(par0Entity.posY);
              int var17 = MathHelper.floor_double(par0Entity.posZ);

              if (par0Entity.worldObj.blockGetRenderType(var18, var16, var17) != 9
                  && par0Entity.worldObj.blockGetRenderType(var18, var16 - 1, var17) != 9) {
                return -3;
              }
            } else if (!var13.getBlocksMovement(par0Entity.worldObj, var9, var10, var11)
                && (!par6 || var12 != Block.doorWood.blockID)) {
              if (var14 == 11 || var12 == Block.fenceGate.blockID || var14 == 32) {
                return -3;
              }

              if (var12 == Block.trapdoor.blockID) {
                return -4;
              }

              Material var15 = var13.blockMaterial;

              if (var15 != Material.lava) {
                return 0;
              }

              if (!par0Entity.handleLavaMovement()) {
                return -2;
              }
            }
          }
        }
      }
    }

    return var8 ? 2 : 1;
  }
  /**
   * Returns true when an entity of specified size could safely walk in a straight line between the
   * two points. Args: pos1, pos2, entityXSize, entityYSize, entityZSize
   */
  private boolean isDirectPathBetweenPoints(
      Vec3 par1Vec3, Vec3 par2Vec3, int par3, int par4, int par5) {
    int var6 = MathHelper.floor_double(par1Vec3.xCoord);
    int var7 = MathHelper.floor_double(par1Vec3.zCoord);
    double var8 = par2Vec3.xCoord - par1Vec3.xCoord;
    double var10 = par2Vec3.zCoord - par1Vec3.zCoord;
    double var12 = var8 * var8 + var10 * var10;

    if (var12 < 1.0E-8D) {
      return false;
    } else {
      double var14 = 1.0D / Math.sqrt(var12);
      var8 *= var14;
      var10 *= var14;
      par3 += 2;
      par5 += 2;

      if (!this.isSafeToStandAt(
          var6, (int) par1Vec3.yCoord, var7, par3, par4, par5, par1Vec3, var8, var10)) {
        return false;
      } else {
        par3 -= 2;
        par5 -= 2;
        double var16 = 1.0D / Math.abs(var8);
        double var18 = 1.0D / Math.abs(var10);
        double var20 = (double) (var6 * 1) - par1Vec3.xCoord;
        double var22 = (double) (var7 * 1) - par1Vec3.zCoord;

        if (var8 >= 0.0D) {
          ++var20;
        }

        if (var10 >= 0.0D) {
          ++var22;
        }

        var20 /= var8;
        var22 /= var10;
        int var24 = var8 < 0.0D ? -1 : 1;
        int var25 = var10 < 0.0D ? -1 : 1;
        int var26 = MathHelper.floor_double(par2Vec3.xCoord);
        int var27 = MathHelper.floor_double(par2Vec3.zCoord);
        int var28 = var26 - var6;
        int var29 = var27 - var7;

        do {
          if (var28 * var24 <= 0 && var29 * var25 <= 0) {
            return true;
          }

          if (var20 < var22) {
            var20 += var16;
            var6 += var24;
            var28 = var26 - var6;
          } else {
            var22 += var18;
            var7 += var25;
            var29 = var27 - var7;
          }
        } while (this.isSafeToStandAt(
            var6, (int) par1Vec3.yCoord, var7, par3, par4, par5, par1Vec3, var8, var10));

        return false;
      }
    }
  }
  @Override
  public void onUpdate() {
    super.onUpdate();

    if (!this.worldObj.isRemote) {
      if (this.statusMessageCooldown > 0) {
        this.statusMessageCooldown--;
      }

      if (this.statusMessageCooldown == 0
          && this.lastStatusMessageCooldown > 0
          && this.statusValid) {
        this.autoLaunch();
      }

      if (this.autoLaunchCountdown > 0
          && (!(this instanceof EntityTieredRocket) || this.riddenByEntity != null)) {
        this.autoLaunchCountdown--;

        if (this.autoLaunchCountdown <= 0) {
          this.autoLaunch();
        }
      }

      if (this.autoLaunchSetting == EnumAutoLaunch.ROCKET_IS_FUELED
          && this.fuelTank.getFluidAmount() == this.fuelTank.getCapacity()
          && (!(this instanceof EntityTieredRocket) || this.riddenByEntity != null)) {
        this.autoLaunch();
      }

      if (this.autoLaunchSetting == EnumAutoLaunch.INSTANT) {
        if (this.autoLaunchCountdown == 0
            && (!(this instanceof EntityTieredRocket) || this.riddenByEntity != null)) {
          this.autoLaunch();
        }
      }

      if (this.autoLaunchSetting == EnumAutoLaunch.REDSTONE_SIGNAL) {
        if (this.ticks % 25 == 0) {
          if (this.getLandingPad() != null && this.getLandingPad().getConnectedTiles() != null) {
            for (ILandingPadAttachable tile : this.getLandingPad().getConnectedTiles()) {
              if (this.worldObj.getTileEntity(((TileEntity) tile).getPos()) != null) {
                try {
                  Class<?> controllerClass =
                      Class.forName(
                          "micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController");

                  try {
                    controllerClass.cast(this.worldObj.getTileEntity(((TileEntity) tile).getPos()));
                  } catch (ClassCastException e) {
                    continue;
                  }

                  if (this.worldObj.isBlockIndirectlyGettingPowered(((TileEntity) tile).getPos())
                      > 0) {
                    this.autoLaunch();
                  }
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            }
          }
        }
      }

      if (this.launchPhase == EnumLaunchPhase.LAUNCHED.ordinal() && this.hasValidFuel()) {
        if (this.landing
            && this.targetVec != null
            && this.worldObj.getTileEntity(this.targetVec) instanceof IFuelDock) {
          this.motionY =
              Math.max(
                  -2.0F,
                  (this.posY - this.getOnPadYOffset() - 0.4D - this.targetVec.getY()) / -70.0D);

          if (this.getEntityBoundingBox().minY - this.targetVec.getY() < 0.5F) {
            for (int x = MathHelper.floor_double(this.posX) - 1;
                x <= MathHelper.floor_double(this.posX) + 1;
                x++) {
              for (int y =
                      MathHelper.floor_double(
                              this.getEntityBoundingBox().minY - this.getOnPadYOffset() - 0.45D)
                          - 1;
                  y <= MathHelper.floor_double(this.getEntityBoundingBox().maxY) + 1;
                  y++) {
                for (int z = MathHelper.floor_double(this.posZ) - 1;
                    z <= MathHelper.floor_double(this.posZ) + 1;
                    z++) {
                  TileEntity tile = this.worldObj.getTileEntity(new BlockPos(x, y, z));

                  if (tile instanceof IFuelDock) {
                    this.failRocket();
                  }
                }
              }
            }
          }
        }
      }

      if (this.getLandingPad() != null && this.getLandingPad().getConnectedTiles() != null) {
        for (ILandingPadAttachable tile : this.getLandingPad().getConnectedTiles()) {
          if (this.worldObj.getTileEntity(((TileEntity) tile).getPos()) != null
              && this.worldObj.getTileEntity(((TileEntity) tile).getPos())
                  instanceof TileEntityFuelLoader) {
            if (tile instanceof TileEntityFuelLoader
                && ((TileEntityFuelLoader) tile).getEnergyStoredGC() > 0) {
              if (this.launchPhase == EnumLaunchPhase.LAUNCHED.ordinal()) {
                this.setPad(null);
              }
            }
          }
        }
      }

      this.lastStatusMessageCooldown = this.statusMessageCooldown;
    }

    if (this.launchPhase == EnumLaunchPhase.IGNITED.ordinal() || this.getLaunched()) {
      if (this.rocketSoundUpdater != null) {
        this.rocketSoundUpdater.update();
        this.rocketSoundToStop = true;
      }
    } else {
      // Not ignited - either because not yet launched, or because it has landed
      if (this.rocketSoundToStop) this.stopRocketSound();
    }
  }
 @Override
 public void onBlockPlacedBy(
     World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
   int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
   world.setBlockState(pos, getDefaultState().withProperty(FACING, EnumFacing.fromAngle(90 * l)));
 }
  /** Updates the task */
  public void updateTask() {
    EntityPlayer var1 = (EntityPlayer) this.thisEntity.riddenByEntity;
    EntityCreature var2 = (EntityCreature) this.thisEntity;
    float var3 =
        MathHelper.wrapAngleTo180_float(var1.rotationYaw - this.thisEntity.rotationYaw) * 0.5F;

    if (var3 > 5.0F) {
      var3 = 5.0F;
    }

    if (var3 < -5.0F) {
      var3 = -5.0F;
    }

    this.thisEntity.rotationYaw =
        MathHelper.wrapAngleTo180_float(this.thisEntity.rotationYaw + var3);

    if (this.currentSpeed < this.maxSpeed) {
      this.currentSpeed += (this.maxSpeed - this.currentSpeed) * 0.01F;
    }

    if (this.currentSpeed > this.maxSpeed) {
      this.currentSpeed = this.maxSpeed;
    }

    int var4 = MathHelper.floor_double(this.thisEntity.posX);
    int var5 = MathHelper.floor_double(this.thisEntity.posY);
    int var6 = MathHelper.floor_double(this.thisEntity.posZ);
    float var7 = this.currentSpeed;

    if (this.speedBoosted) {
      if (this.speedBoostTime++ > this.maxSpeedBoostTime) {
        this.speedBoosted = false;
      }

      var7 +=
          var7
              * 1.15F
              * MathHelper.sin(
                  (float) this.speedBoostTime / (float) this.maxSpeedBoostTime * (float) Math.PI);
    }

    float var8 = 0.91F;

    if (this.thisEntity.onGround) {
      var8 = 0.54600006F;
      int var9 =
          this.thisEntity.worldObj.getBlockId(
              MathHelper.floor_float((float) var4),
              MathHelper.floor_float((float) var5) - 1,
              MathHelper.floor_float((float) var6));

      if (var9 > 0) {
        var8 = Block.blocksList[var9].slipperiness * 0.91F;
      }
    }

    float var23 = 0.16277136F / (var8 * var8 * var8);
    float var10 = MathHelper.sin(var2.rotationYaw * (float) Math.PI / 180.0F);
    float var11 = MathHelper.cos(var2.rotationYaw * (float) Math.PI / 180.0F);
    float var12 = var2.getAIMoveSpeed() * var23;
    float var13 = Math.max(var7, 1.0F);
    var13 = var12 / var13;
    float var14 = var7 * var13;
    float var15 = -(var14 * var10);
    float var16 = var14 * var11;

    if (MathHelper.abs(var15) > MathHelper.abs(var16)) {
      if (var15 < 0.0F) {
        var15 -= this.thisEntity.width / 2.0F;
      }

      if (var15 > 0.0F) {
        var15 += this.thisEntity.width / 2.0F;
      }

      var16 = 0.0F;
    } else {
      var15 = 0.0F;

      if (var16 < 0.0F) {
        var16 -= this.thisEntity.width / 2.0F;
      }

      if (var16 > 0.0F) {
        var16 += this.thisEntity.width / 2.0F;
      }
    }

    int var17 = MathHelper.floor_double(this.thisEntity.posX + (double) var15);
    int var18 = MathHelper.floor_double(this.thisEntity.posZ + (double) var16);
    PathPoint var19 =
        new PathPoint(
            MathHelper.floor_float(this.thisEntity.width + 1.0F),
            MathHelper.floor_float(this.thisEntity.height + var1.height + 1.0F),
            MathHelper.floor_float(this.thisEntity.width + 1.0F));

    if (var4 != var17 || var6 != var18) {
      int var20 = this.thisEntity.worldObj.getBlockId(var4, var5, var6);
      int var21 = this.thisEntity.worldObj.getBlockId(var4, var5 - 1, var6);
      boolean var22 =
          this.func_98216_b(var20) || Block.blocksList[var20] == null && this.func_98216_b(var21);

      if (!var22
          && PathFinder.func_82565_a(this.thisEntity, var17, var5, var18, var19, false, false, true)
              == 0
          && PathFinder.func_82565_a(
                  this.thisEntity, var4, var5 + 1, var6, var19, false, false, true)
              == 1
          && PathFinder.func_82565_a(
                  this.thisEntity, var17, var5 + 1, var18, var19, false, false, true)
              == 1) {
        var2.getJumpHelper().setJumping();
      }
    }

    if (!var1.capabilities.isCreativeMode
        && this.currentSpeed >= this.maxSpeed * 0.5F
        && this.thisEntity.getRNG().nextFloat() < 0.006F
        && !this.speedBoosted) {
      ItemStack var24 = var1.getHeldItem();

      if (var24 != null && var24.itemID == Item.carrotOnAStick.itemID) {
        var24.damageItem(1, var1);

        if (var24.stackSize == 0) {
          ItemStack var25 = new ItemStack(Item.fishingRod);
          var25.setTagCompound(var24.stackTagCompound);
          var1.inventory.mainInventory[var1.inventory.currentItem] = var25;
        }
      }
    }

    this.thisEntity.moveEntityWithHeading(0.0F, var7);
  }