public Vec3 getTarget(Vec3 pos, ForgeDirection side) {
      pos.yCoord += target.yCoord;
      switch (side) {
        case NORTH:
          pos.xCoord += target.zCoord;
          pos.zCoord -= target.xCoord;
          break;
        case SOUTH:
          pos.xCoord -= target.zCoord;
          pos.zCoord += target.xCoord;
          break;
        case WEST:
          pos.xCoord -= target.xCoord;
          pos.zCoord -= target.zCoord;
          break;
        case EAST:
          pos.xCoord += target.xCoord;
          pos.zCoord += target.zCoord;
          break;
        default:
          break;
      }

      return pos.addVector(0.5, 0.5, 0.5);
    }
예제 #2
0
  protected void setVectorRotations(Vec3 vector, float xRot, float yRot, float zRot) {
    float x = xRot;
    float y = yRot;
    float z = zRot;
    float xC = MathHelper.cos(x);
    float xS = MathHelper.sin(x);
    float yC = MathHelper.cos(y);
    float yS = MathHelper.sin(y);
    float zC = MathHelper.cos(z);
    float zS = MathHelper.sin(z);

    double xVec = vector.xCoord;
    double yVec = vector.yCoord;
    double zVec = vector.zCoord;

    // rotation around x
    double xy = xC * yVec - xS * zVec;
    double xz = xC * zVec + xS * yVec;
    // rotation around y
    double yz = yC * xz - yS * xVec;
    double yx = yC * xVec + yS * xz;
    // rotation around z
    double zx = zC * yx - zS * xy;
    double zy = zC * xy + zS * yx;

    xVec = zx;
    yVec = zy;
    zVec = yz;

    vector.xCoord = xVec;
    vector.yCoord = yVec;
    vector.zCoord = zVec;
  }
예제 #3
0
 // serverとclientで視点補正がかかっていたりいなかったりするため、その差を吸収する
 // see: http://forum.minecraftuser.jp/viewtopic.php?f=21&t=7907#p63907
 public static Vec3 getPlayerPosition(EntityPlayer player) {
   Vec3 pos = player.getPosition(1.0F);
   if (player.yOffset == 0.0) {
     pos.yCoord += player.getEyeHeight();
   }
   return pos;
 }
예제 #4
0
 /**
  * Copied from CoFHLib BlockHelper.class
  * (https://github.com/CoFH/CoFHLib/blob/master/src/main/java/cofh/util/BlockHelper.java), with
  * KingLemmings permission!
  *
  * @author King Lemming
  */
 public static MovingObjectPosition getMovingObjectPosition(EntityPlayer player) {
   Vec3 posVec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ);
   Vec3 lookVec = player.getLook(1);
   posVec.yCoord += player.getEyeHeight();
   lookVec = posVec.addVector(lookVec.xCoord * 4.5F, lookVec.yCoord * 4.5F, lookVec.zCoord * 4.5F);
   return player.worldObj.rayTraceBlocks(posVec, lookVec);
 }
예제 #5
0
  public static MovingObjectPosition getCurrentMovingObjectPosition(
      EntityPlayer player, double distance, boolean fluid) {

    Vec3 posVec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ);
    Vec3 lookVec = player.getLook(1);
    posVec.yCoord += player.getEyeHeight();
    lookVec =
        posVec.addVector(
            lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance);
    return player.worldObj.rayTraceBlocks(posVec, lookVec, fluid);
  }
예제 #6
0
 @Override
 public void onEntityUpdate() {
   if (!worldObj.isRemote && getIsWaiting()) {
     if (!isUnloaded) {
       if (waitTime == 0) {
         p.setIsRed(true);
         setIsOpen(true);
         initialScale = p.getScale();
         initPos = Vec3.createVectorHelper(p.posX, p.posY, p.posZ);
         Vec3 current = Vec3.createVectorHelper(posX, posY, posZ);
         current.xCoord -= initPos.xCoord;
         current.yCoord -= initPos.yCoord;
         current.zCoord -= initPos.zCoord;
         diff = current;
         p.setScale(initialScale / 1.1f);
       }
       if (waitTime == 10) {
         p.setScale(initialScale / 1.3f);
         moveCloser();
       }
       if (waitTime == 14) {
         p.setScale(initialScale / 1.7f);
         moveCloser();
       }
       if (waitTime == 18) {
         p.setScale(initialScale / 2.2f);
         moveCloser();
       }
       if (waitTime == 22) {
         p.setScale(initialScale / 3);
         moveCloser();
         p.unloadEntity();
         isUnloaded = true;
         waitTime = 0;
         setIsOpen(false);
         p.setIsRed(false);
       }
     }
     if (thrower != null) {
       if (!thrower.worldObj.isAirBlock(
               (int) this.posX, (int) Math.ceil(this.posY) - 2, (int) this.posZ)
           && this.posY % 1 <= this.height) {
         this.motionY = 0;
         this.motionX = 0;
         this.motionZ = 0;
         setIsOnGround(true);
       }
       if (!thrower.worldObj.isAirBlock(
               (int) this.posX, (int) Math.ceil(this.posY - 1), (int) this.posZ)
           && this.posY % 1 <= this.height) posY++;
     }
     waitTime++;
   }
 }
  @SideOnly(Side.CLIENT)
  public void updateFogColor() {
    float r = 160F / 255F;
    float g = 128F / 255F;
    float b = 160F / 255F;

    r *= 0.015F;
    g *= 0.015F;
    b *= 0.015F;

    fogColor.xCoord = r;
    fogColor.yCoord = g;
    fogColor.zCoord = b;
  }
예제 #8
0
      @Override
      public void doAttack(int ticks, EntityFinalBoss boss, World w, Random rand) {
        if (ticks % 5 == 0) {
          Vec3 start = Vec3.createVectorHelper(boss.posX, boss.posY + 0.5, boss.posZ);
          AxisAlignedBB bounds =
              AxisAlignedBB.getBoundingBox(
                  start.xCoord - 50,
                  start.yCoord - 50,
                  start.zCoord - 50,
                  start.xCoord + 50,
                  start.yCoord + 50,
                  start.zCoord + 50);
          for (Object o : w.getEntitiesWithinAABB(EntityPlayer.class, bounds)) {
            EntityPlayer pl = (EntityPlayer) o;
            // For some reason, the server's position is normal, but
            // the client's position is 1.62 higher
            Vec3 end = Vec3.createVectorHelper(pl.posX, pl.posY + (w.isRemote ? 0 : 1.62), pl.posZ);
            Vec3 vec = start.subtract(end).normalize();
            vec.xCoord /= 2;
            vec.yCoord /= 2;
            vec.zCoord /= 2;

            double lastDistSq = -1;
            Vec3 pos = Vec3.createVectorHelper(start.xCoord, start.yCoord, start.zCoord);
            boolean hit = true;
            while (true) {
              pos = pos.addVector(vec.xCoord, vec.yCoord, vec.zCoord);
              if (w.getBlock(
                      (int) Math.floor(pos.xCoord),
                      (int) Math.floor(pos.yCoord),
                      (int) Math.floor(pos.zCoord))
                  .isOpaqueCube()) {
                hit = false;
                break;
              }
              if (lastDistSq >= 0 && pos.squareDistanceTo(end) > lastDistSq) {
                break;
              }
              w.spawnParticle("witchMagic", pos.xCoord, pos.yCoord, pos.zCoord, 0, 0, 0);
              lastDistSq = pos.squareDistanceTo(end);
            }
            if (hit) {
              pl.attackEntityFrom(
                  DamageSource.causeMobDamage(boss).setDamageBypassesArmor(),
                  pl.getMaxHealth() / 4);
            }
          }
        }
      }
 public synchronized void setTarget(double x, double y, double z) {
   target.xCoord = x;
   target.yCoord = y;
   target.zCoord = z;
 }
예제 #10
0
  @Override
  public void updateTask() {
    super.updateTask();

    double dist = 100;

    // control with keyboard if carrot on a stick is equipped
    if (ItemUtils.hasEquipped(rider, ModItems.vitoidFruit)) {
      Vec3 wp = rider.getLookVec();

      // scale with distance
      wp.xCoord *= dist;
      wp.yCoord *= dist;
      wp.zCoord *= dist;

      // convert to absolute position
      wp.xCoord += dragon.posX;
      wp.yCoord += dragon.posY;
      wp.zCoord += dragon.posZ;

      dragon.getWaypoint().setVector(wp);

      dragon.setMoveSpeedAirHoriz(1);
      dragon.setMoveSpeedAirVert(0);
    } else {
      Vec3 wp = dragon.getLookVec();

      // scale with distance
      wp.xCoord *= dist;
      wp.yCoord *= dist;
      wp.zCoord *= dist;

      // convert to absolute position
      wp.xCoord += dragon.posX;
      wp.yCoord += dragon.posY;
      wp.zCoord += dragon.posZ;

      dragon.getWaypoint().setVector(wp);

      double speedAir = 0;

      // change speed with forward
      if (rider.moveForward != 0) {
        speedAir = 1;

        // fly slower backwards
        // (I'm surprised this is kinda working at all...)
        if (rider.moveForward < 0) {
          speedAir *= 0.5;
        }

        speedAir *= rider.moveForward;
      }

      dragon.setMoveSpeedAirHoriz(speedAir);

      // control rotation with strafing
      if (rider.moveStrafing != 0) {
        dragon.rotationYaw -= rider.moveStrafing * 6;
      }

      double verticalSpeed = 0;

      // control height with custom keys
      if (isFlyUp()) {
        verticalSpeed = 0.5f;
      } else if (isFlyDown()) {
        verticalSpeed = -0.5f;
      }

      dragon.setMoveSpeedAirVert(verticalSpeed);
    }
  }