@Override
  public void onUpdate() {
    if (this.ticks >= Long.MAX_VALUE) {
      this.ticks = 1;
    }

    this.ticks++;

    super.onUpdate();

    if (this.worldObj.isRemote
        && (this.riddenByEntity == null
            || !(this.riddenByEntity instanceof EntityPlayer)
            || !FMLClientHandler.instance().getClient().thePlayer.equals(this.riddenByEntity))) {
      double x;
      double y;
      double var12;
      double z;
      if (this.boatPosRotationIncrements > 0) {
        x = this.posX + (this.boatX - this.posX) / this.boatPosRotationIncrements;
        y = this.posY + (this.boatY - this.posY) / this.boatPosRotationIncrements;
        z = this.posZ + (this.boatZ - this.posZ) / this.boatPosRotationIncrements;
        var12 = MathHelper.wrapAngleTo180_double(this.boatYaw - this.rotationYaw);
        this.rotationYaw = (float) (this.rotationYaw + var12 / this.boatPosRotationIncrements);
        this.rotationPitch =
            (float)
                (this.rotationPitch
                    + (this.boatPitch - this.rotationPitch) / this.boatPosRotationIncrements);
        --this.boatPosRotationIncrements;
        this.setPosition(x, y, z);
        this.setRotation(this.rotationYaw, this.rotationPitch);
      } else {
        x = this.posX + this.motionX;
        y = this.posY + this.motionY;
        z = this.posZ + this.motionZ;
        if (this.riddenByEntity != null) {
          this.setPosition(x, y, z);
        }

        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;
      }
      return;
    }

    if (this.dataWatcher.getWatchableObjectInt(this.timeSinceHit) > 0) {
      this.dataWatcher.updateObject(
          this.timeSinceHit,
          Integer.valueOf(this.dataWatcher.getWatchableObjectInt(this.timeSinceHit) - 1));
    }

    if (this.dataWatcher.getWatchableObjectInt(this.currentDamage) > 0) {
      this.dataWatcher.updateObject(
          this.currentDamage,
          Integer.valueOf(this.dataWatcher.getWatchableObjectInt(this.currentDamage) - 1));
    }

    final byte var20 = 5;
    final double var2 = 0.0D;
    int var4;

    for (var4 = 0; var4 < var20; ++var4) {}

    if (var2 < 1.0D) {
      this.motionY -= 0.04D;
    }

    if (this.riddenByEntity == null) {
      this.yOffset = 5;
    }

    if (this.inWater && this.speed > 0.2D) {
      this.worldObj.playSoundEffect(
          (float) this.posX,
          (float) this.posY,
          (float) this.posZ,
          "random.fizz",
          0.5F,
          2.6F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.8F);
    }

    this.speed *= 0.98D;

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

    if (this.isCollidedHorizontally) {
      this.speed *= 0.9;
      this.motionY = 0.1D;
    }

    if (this.worldObj.isRemote
        && this.buggyFuelTank.getFluid() != null
        && this.buggyFuelTank.getFluid().amount > 0) {
      this.motionX = -(this.speed * Math.cos((this.rotationYaw - 90F) * Math.PI / 180.0D));
      this.motionZ = -(this.speed * Math.sin((this.rotationYaw - 90F) * Math.PI / 180.0D));
    }

    if (this.worldObj.isRemote) {
      this.moveEntity(this.motionX, this.motionY, this.motionZ);
    }

    if (Math.abs(this.motionX * this.motionZ) > 0.000001) {
      double d = this.motionX * this.motionX + this.motionZ * this.motionZ;

      if (d != 0
          && !this.worldObj.isRemote
          && d != 0
          && this.ticks % MathHelper.floor_double(2 / d) == 0) {
        this.removeFuel(1);
      }
    }

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;

    if (this.worldObj.isRemote) {
      PacketDispatcher.sendPacketToServer(GCCorePacketEntityUpdate.buildUpdatePacket(this));
    }

    if (!this.worldObj.isRemote && this.ticks % 5 == 0) {
      PacketDispatcher.sendPacketToAllAround(
          this.posX,
          this.posY,
          this.posZ,
          50,
          this.dimension,
          GCCorePacketEntityUpdate.buildUpdatePacket(this));
    }

    if (!this.worldObj.isRemote && this.ticks % 5 == 0) {
      PacketManager.sendPacketToClients(
          this.getDescriptionPacket(), this.worldObj, new Vector3(this), 50);
    }
  }
  public static void setPositionList(WorldRenderer rend, int glRenderList) {
    GL11.glNewList(glRenderList + 3, GL11.GL_COMPILE);

    EntityLivingBase entitylivingbase = FMLClientHandler.instance().getClient().renderViewEntity;

    if (entitylivingbase != null) {
      if (rend.worldObj.provider instanceof WorldProviderMoon) {
        // See what a small moon looks like, for demo purposes
        // Note: terrainHeight must never be less than globalRadius
        ClientProxyCore.globalRadius = 300F;
        ClientProxyCore.terrainHeight = 64F;

        if (entitylivingbase.posY > ClientProxyCore.terrainHeight + 8F) {
          ClientProxyCore.smallMoonActive = true;
          double globalArc = ClientProxyCore.globalRadius / 57.2957795D;
          float globeRadius = ClientProxyCore.globalRadius - ClientProxyCore.terrainHeight;

          int pX = MathHelper.floor_double(entitylivingbase.posX / 16D) << 4;
          int pZ = MathHelper.floor_double(entitylivingbase.posZ / 16D) << 4;

          float dX = rend.posX - pX;
          float dZ = rend.posZ - pZ;
          float scalerX = 0;
          float scalerZ = 0;

          if (dX > 0) {
            dX -= 16F;
            if (dX > 0) {
              dX -= entitylivingbase.posX - pX;
              if (dX < 16F) {
                scalerX = 16F - ((float) entitylivingbase.posX - pX);
              } else {
                scalerX = 16F;
              }
            }
          } else if (dX < 0) {
            dX += 16F;
            if (dX < 0) {
              dX += 16F - (entitylivingbase.posX - pX);
              if (dX > -16F) {
                scalerX = (float) entitylivingbase.posX - pX;
              } else {
                scalerX = 16F;
              }
            }
          }

          if (dZ > 0) {
            dZ -= 16F;
            if (dZ > 0) {
              dZ -= entitylivingbase.posZ - pZ;
              if (dZ < 16F) {
                scalerZ = 16F - ((float) entitylivingbase.posZ - pZ);
              } else {
                scalerZ = 16F;
              }
            }
          } else if (dZ < 0) {
            dZ += 16F;
            if (dZ < 0) {
              dZ += 16F - (entitylivingbase.posZ - pZ);
              if (dZ > -16F) {
                scalerZ = (float) entitylivingbase.posZ - pZ;
              } else {
                scalerZ = 16F;
              }
            }
          }

          float origClipX = rend.posXClip;
          float origClipY = rend.posYClip;
          float origClipZ = rend.posZClip;

          float theta = (float) MathHelper.wrapAngleTo180_double(dX / globalArc);
          float phi = (float) MathHelper.wrapAngleTo180_double(dZ / globalArc);
          if (theta < 0) {
            theta += 360F;
          }
          if (phi < 0) {
            phi += 360F;
          }
          GL11.glTranslatef(origClipX - dX + 8F, -globeRadius + 8F, origClipZ - dZ + 8F);
          if (theta > 0) {
            GL11.glRotatef(theta, 0, 0, -1F);
          }
          if (phi > 0) {
            GL11.glRotatef(phi, 1F, 0, 0);
          }
          GL11.glTranslatef(-8F, origClipY + globeRadius - 8F, -8F);
          if (dX != 0 || dZ != 0) {
            float scalex =
                (ClientProxyCore.globalRadius * 2F + scalerX) / ClientProxyCore.globalRadius / 2F;
            float scalez =
                (ClientProxyCore.globalRadius * 2F + scalerZ) / ClientProxyCore.globalRadius / 2F;
            ClientProxyCore.scaleup.rewind();
            ClientProxyCore.scaleup.put(scalex);
            ClientProxyCore.scaleup.position(10);
            ClientProxyCore.scaleup.put(scalez);
            ClientProxyCore.scaleup.rewind();
            GL11.glMultMatrix(ClientProxyCore.scaleup);
            GL11.glTranslatef(-8F * (scalex - 1F), 0, -8F * (scalez - 1F));
          }
          GL11.glTranslatef(-origClipX, -origClipY, -origClipZ);
          ClientProxyCore.offsetY = rend.posY - ClientProxyCore.terrainHeight;
        } else {
          ClientProxyCore.smallMoonActive = false;
          ClientProxyCore.offsetY = 0;
        }
      } else {
        ClientProxyCore.terrainHeight = Float.MAX_VALUE;
        ClientProxyCore.globalRadius = Float.MAX_VALUE;
        ClientProxyCore.smallMoonActive = false;
        ClientProxyCore.offsetY = 0;
      }
    }
    GL11.glEndList();
  }
Beispiel #3
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    if (this.getRollingAmplitude() > 0) {
      this.setRollingAmplitude(this.getRollingAmplitude() - 1);
    }

    if (this.getDamage() > 0.0F) {
      this.setDamage(this.getDamage() - 1.0F);
    }

    if (this.posY < -64.0D) {
      this.kill();
    }

    if (!this.worldObj.isRemote && this.worldObj instanceof WorldServer) {
      this.worldObj.theProfiler.startSection("portal");
      MinecraftServer minecraftserver = ((WorldServer) this.worldObj).getMinecraftServer();
      int i = this.getMaxInPortalTime();

      if (this.inPortal) {
        if (minecraftserver.getAllowNether()) {
          if (this.ridingEntity == null && this.portalCounter++ >= i) {
            this.portalCounter = i;
            this.timeUntilPortal = this.getPortalCooldown();
            int j;

            if (this.worldObj.provider.getDimensionId() == -1) {
              j = 0;
            } else {
              j = -1;
            }

            this.travelToDimension(j);
          }

          this.inPortal = false;
        }
      } else {
        if (this.portalCounter > 0) {
          this.portalCounter -= 4;
        }

        if (this.portalCounter < 0) {
          this.portalCounter = 0;
        }
      }

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

      this.worldObj.theProfiler.endSection();
    }

    if (this.worldObj.isRemote) {
      if (this.turnProgress > 0) {
        double d4 = this.posX + (this.minecartX - this.posX) / (double) this.turnProgress;
        double d5 = this.posY + (this.minecartY - this.posY) / (double) this.turnProgress;
        double d6 = this.posZ + (this.minecartZ - this.posZ) / (double) this.turnProgress;
        double d1 = MathHelper.wrapAngleTo180_double(this.minecartYaw - (double) this.rotationYaw);
        this.rotationYaw = (float) ((double) this.rotationYaw + d1 / (double) this.turnProgress);
        this.rotationPitch =
            (float)
                ((double) this.rotationPitch
                    + (this.minecartPitch - (double) this.rotationPitch)
                        / (double) this.turnProgress);
        --this.turnProgress;
        this.setPosition(d4, d5, d6);
        this.setRotation(this.rotationYaw, this.rotationPitch);
      } else {
        this.setPosition(this.posX, this.posY, this.posZ);
        this.setRotation(this.rotationYaw, this.rotationPitch);
      }
    } else {
      this.prevPosX = this.posX;
      this.prevPosY = this.posY;
      this.prevPosZ = this.posZ;
      this.motionY -= 0.03999999910593033D;
      int k = MathHelper.floor_double(this.posX);
      int l = MathHelper.floor_double(this.posY);
      int i1 = MathHelper.floor_double(this.posZ);

      if (BlockRailBase.isRailBlock(this.worldObj, new BlockPos(k, l - 1, i1))) {
        --l;
      }

      BlockPos blockpos = new BlockPos(k, l, i1);
      IBlockState iblockstate = this.worldObj.getBlockState(blockpos);

      if (BlockRailBase.isRailBlock(iblockstate)) {
        this.func_180460_a(blockpos, iblockstate);

        if (iblockstate.getBlock() == Blocks.activator_rail) {
          this.onActivatorRailPass(
              k, l, i1, ((Boolean) iblockstate.getValue(BlockRailPowered.POWERED)).booleanValue());
        }
      } else {
        this.moveDerailedMinecart();
      }

      this.doBlockCollisions();
      this.rotationPitch = 0.0F;
      double d0 = this.prevPosX - this.posX;
      double d2 = this.prevPosZ - this.posZ;

      if (d0 * d0 + d2 * d2 > 0.001D) {
        this.rotationYaw = (float) (MathHelper.func_181159_b(d2, d0) * 180.0D / Math.PI);

        if (this.isInReverse) {
          this.rotationYaw += 180.0F;
        }
      }

      double d3 = (double) MathHelper.wrapAngleTo180_float(this.rotationYaw - this.prevRotationYaw);

      if (d3 < -170.0D || d3 >= 170.0D) {
        this.rotationYaw += 180.0F;
        this.isInReverse = !this.isInReverse;
      }

      this.setRotation(this.rotationYaw, this.rotationPitch);

      for (Entity entity :
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.getEntityBoundingBox()
                  .expand(0.20000000298023224D, 0.0D, 0.20000000298023224D))) {
        if (entity != this.riddenByEntity
            && entity.canBePushed()
            && entity instanceof EntityMinecart) {
          entity.applyEntityCollision(this);
        }
      }

      if (this.riddenByEntity != null && this.riddenByEntity.isDead) {
        if (this.riddenByEntity.ridingEntity == this) {
          this.riddenByEntity.ridingEntity = null;
        }

        this.riddenByEntity = null;
      }

      this.handleWaterMovement();
    }
  }
  public static void adjustRenderPos(
      Entity entity, double offsetX, double offsetY, double offsetZ) {
    GL11.glPushMatrix();
    // Skip mobs in mobspawners
    // Note: can also look for (entity.posY!=0.0D || entity.posX!=0.0D || entity.posZ!=0.0) which
    // filters hand-held entities and the player in an inventory GUI
    if (ClientProxyCore.smallMoonActive
        && (offsetX != 0.0D || offsetY != 0.0D || offsetZ != 0.0D)) {
      final Minecraft minecraft = FMLClientHandler.instance().getClient();
      final EntityPlayerSP player = minecraft.thePlayer;
      if (player.posY > ClientProxyCore.terrainHeight + 8F
          && player.ridingEntity != entity
          && player != entity) {
        double globalArc = ClientProxyCore.globalRadius / 57.2957795D;

        int pX = MathHelper.floor_double(player.posX / 16D) << 4;
        int pZ = MathHelper.floor_double(player.posZ / 16D) << 4;

        int eX = MathHelper.floor_double(entity.posX / 16D) << 4;
        int eY = MathHelper.floor_double(entity.posY / 16D) << 4;
        int eZ = MathHelper.floor_double(entity.posZ / 16D) << 4;

        float dX = eX - pX;
        float dZ = eZ - pZ;

        float floatPX = (float) player.posX;
        float floatPZ = (float) player.posZ;

        if (dX > 0) {
          dX -= 16F;
          if (dX > 0) {
            dX -= floatPX - pX;
          }
        } else if (dX < 0) {
          dX += 16F;
          if (dX < 0) {
            dX += 16F - floatPX + pX;
          }
        }

        if (dZ > 0) {
          dZ -= 16F;
          if (dZ > 0) {
            dZ -= floatPZ - pZ;
          }
        } else if (dZ < 0) {
          dZ += 16F;
          if (dZ < 0) {
            dZ += 16F - floatPZ + pZ;
          }
        }

        float theta = (float) MathHelper.wrapAngleTo180_double(dX / globalArc);
        float phi = (float) MathHelper.wrapAngleTo180_double(dZ / globalArc);
        if (theta < 0) {
          theta += 360F;
        }
        if (phi < 0) {
          phi += 360F;
        }
        float ytranslate =
            ClientProxyCore.globalRadius
                + (float) (player.posY - entity.posY)
                + eY
                - ClientProxyCore.terrainHeight;
        GL11.glTranslatef(-dX + eX - floatPX + 8F, -ytranslate, -dZ + eZ - floatPZ + 8F);
        if (theta > 0) {
          GL11.glRotatef(theta, 0, 0, -1);
        }
        if (phi > 0) {
          GL11.glRotatef(phi, 1, 0, 0);
        }
        GL11.glTranslatef(floatPX - eX - 8F, ytranslate, floatPZ - eZ - 8F);
      }
    }
  }
  public static void adjustTileRenderPos(
      TileEntity tile, double offsetX, double offsetY, double offsetZ) {
    GL11.glPushMatrix();
    // Skip tiles in inventory or in player's hand etc
    if (ClientProxyCore.smallMoonActive
        && (offsetX != 0.0D || offsetY != 0.0D || offsetZ != 0.0D)) {
      final Minecraft minecraft = FMLClientHandler.instance().getClient();
      final EntityPlayerSP player = minecraft.thePlayer;
      final WorldProvider provider = minecraft.theWorld.provider;
      if (provider instanceof WorldProviderMoon) {
        if (player.posY > ClientProxyCore.terrainHeight + 8F) {
          double globalArc = ClientProxyCore.globalRadius / 57.2957795D;

          int pX = MathHelper.floor_double(player.posX / 16D) << 4;
          int pZ = MathHelper.floor_double(player.posZ / 16D) << 4;

          int eX = tile.xCoord / 16 << 4;
          int eY = tile.yCoord / 16 << 4;
          int eZ = tile.zCoord / 16 << 4;

          float dX = eX - pX;
          float dZ = eZ - pZ;

          float floatPX = (float) player.posX;
          float floatPZ = (float) player.posZ;

          if (dX > 0) {
            dX -= 16F;
            if (dX > 0) {
              dX -= floatPX - pX;
            }
          } else if (dX < 0) {
            dX += 16F;
            if (dX < 0) {
              dX += 16F - floatPX + pX;
            }
          }

          if (dZ > 0) {
            dZ -= 16F;
            if (dZ > 0) {
              dZ -= floatPZ - pZ;
            }
          } else if (dZ < 0) {
            dZ += 16F;
            if (dZ < 0) {
              dZ += 16F - floatPZ + pZ;
            }
          }

          float theta = (float) MathHelper.wrapAngleTo180_double(dX / globalArc);
          float phi = (float) MathHelper.wrapAngleTo180_double(dZ / globalArc);
          if (theta < 0) {
            theta += 360F;
          }
          if (phi < 0) {
            phi += 360F;
          }
          float ytranslate =
              ClientProxyCore.globalRadius
                  + (float) player.posY
                  - tile.yCoord
                  + eY
                  - ClientProxyCore.terrainHeight;
          GL11.glTranslatef(-dX - floatPX + eX + 8F, -ytranslate, -dZ - floatPZ + eZ + 8F);
          if (theta > 0) {
            GL11.glRotatef(theta, 0, 0, -1);
          }
          if (phi > 0) {
            GL11.glRotatef(phi, 1, 0, 0);
          }
          GL11.glTranslatef(floatPX - eX - 8F, ytranslate, floatPZ - eZ - 8F);
        }
      }
    }
  }
 public boolean affectPulse(World world, int x, int y, int z, EntityLaserPulse e) {
   LaserEffectTile te = (LaserEffectTile) world.getTileEntity(x, y, z);
   if (te instanceof TargetTile) {
     if (e.color.matchColor(te.color) && (e.direction == te.facing || this.isOmniDirectional()))
       ((TargetTile) te).trigger(true, true, true);
   }
   switch (this) {
     case COLORIZER:
       e.color.intersect(te.color);
       return e.color.isBlack();
     case EMITTER:
       return true;
     case MIRROR:
       {
         if (!ReikaMathLibrary.isValueInsideBoundsIncl(
             3, 5, Math.abs(e.direction.ordinal() - te.facing.ordinal()))) return true;
         // ReikaJavaLibrary.pConsole(e.direction+" & "+te.facing+"
         // ("+Math.abs(e.direction.ordinal()-te.facing.ordinal())+")");
         e.reflect(te.facing);
         EntityLaserPulse eb =
             new EntityLaserPulse(world, x, y, z, e.direction, e.color, e.getLevel());
         if (!world.isRemote) world.spawnEntityInWorld(eb);
         return true;
         // return false;
       }
     case DOUBLEMIRROR:
       {
         CubeDirections dir1 = e.direction.getRotation(true, 2);
         if (dir1 == te.facing || dir1 == te.facing.getOpposite()) return true;
         CubeDirections dir = te.facing;
         if (!ReikaMathLibrary.isValueInsideBoundsIncl(
             2, 6, Math.abs(e.direction.ordinal() - te.facing.ordinal())))
           dir = dir.getOpposite();
         // ReikaJavaLibrary.pConsole(e.direction+" & "+te.facing+" > "+dir+"
         // ("+Math.abs(e.direction.ordinal()-te.facing.ordinal())+")");
         e.reflect(dir);
         EntityLaserPulse eb =
             new EntityLaserPulse(world, x, y, z, e.direction, e.color, e.getLevel());
         if (!world.isRemote) world.spawnEntityInWorld(eb);
         return true;
         // return false;
       }
     case SLITMIRROR:
       {
         CubeDirections dir = e.direction.getRotation(true, 2);
         // ReikaJavaLibrary.pConsole(e.direction+" & "+te.facing+" > "+dir+" ("+(dir !=
         // te.facing)+" & "+(dir != te.facing.getOpposite())+")");
         if (dir != te.facing && dir != te.facing.getOpposite()) {
           return DOUBLEMIRROR.affectPulse(world, x, y, z, e);
         }
         return false;
       }
     case ONEWAY:
       return e.direction != te.facing;
     case POLARIZER:
       return e.direction != te.facing && e.direction != te.facing.getOpposite();
     case PRISM:
       {
         if (e.direction != te.facing.getOpposite()) {
           boolean b1 = e.direction == te.facing.getRotation(true, 2);
           boolean b2 = e.direction == te.facing;
           boolean b3 = e.direction == te.facing.getRotation(false, 2);
           ColorData dat =
               new ColorData(e.color.red && b1, e.color.green && b2, e.color.blue && b3);
           // ReikaJavaLibrary.pConsole(dat.red+":"+dat.green+":"+dat.blue+" &
           // "+b1+","+b2+","+b3);
           /*
           if (!dat.isBlack()) {
           	EntityLaserPulse eb = new EntityLaserPulse(world, x, y, z, te.facing.getOpposite(), dat);
           	if (!world.isRemote) {
           		world.spawnEntityInWorld(eb);
           	}
           }
            */
           ((PrismTile) te).addPulse(dat);
           return true;
         }
         EntityLaserPulse e1 =
             e.color.red
                 ? new EntityLaserPulse(
                     world,
                     x,
                     y,
                     z,
                     e.direction.getRotation(true, 2),
                     new ColorData(true, false, false),
                     e.getLevel())
                 : null;
         EntityLaserPulse e2 =
             e.color.green
                 ? new EntityLaserPulse(
                     world,
                     x,
                     y,
                     z,
                     e.direction,
                     new ColorData(false, true, false),
                     e.getLevel())
                 : null;
         EntityLaserPulse e3 =
             e.color.blue
                 ? new EntityLaserPulse(
                     world,
                     x,
                     y,
                     z,
                     e.direction.getRotation(false, 2),
                     new ColorData(false, false, true),
                     e.getLevel())
                 : null;
         if (!world.isRemote) {
           if (e1 != null) world.spawnEntityInWorld(e1);
           if (e2 != null) world.spawnEntityInWorld(e2);
           if (e3 != null) world.spawnEntityInWorld(e3);
         }
         return true;
       }
     case REFRACTOR:
       int d = (int) MathHelper.wrapAngleTo180_double(e.direction.angle - te.facing.angle);
       if (d == 90) {
         e.refract(false);
       } else if (d == -45) {
         e.refract(true);
       } else {
         return true;
       }
       return false;
     case SPLITTER:
       {
         if (e.direction == te.facing) {
           EntityLaserPulse e1 =
               new EntityLaserPulse(
                   world, x, y, z, e.direction.getRotation(true), e.color, e.getLevel());
           EntityLaserPulse e2 =
               new EntityLaserPulse(
                   world, x, y, z, e.direction.getRotation(false), e.color, e.getLevel());
           if (!world.isRemote) {
             world.spawnEntityInWorld(e1);
             world.spawnEntityInWorld(e2);
           }
         } else if (e.direction == te.facing.getOpposite().getRotation(true)
             || e.direction == te.facing.getOpposite().getRotation(false)) {
           e.setDirection(te.facing.getOpposite(), true);
           return false;
         }
         return true;
       }
     case TARGET:
       return true;
     case TARGET_THRU:
       return false;
     default:
       return false;
   }
 }
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.fishPosRotationIncrements > 0) {
      double d7 = this.posX + (this.fishX - this.posX) / (double) this.fishPosRotationIncrements;
      double d8 = this.posY + (this.fishY - this.posY) / (double) this.fishPosRotationIncrements;
      double d9 = this.posZ + (this.fishZ - this.posZ) / (double) this.fishPosRotationIncrements;
      double d1 = MathHelper.wrapAngleTo180_double(this.fishYaw - (double) this.rotationYaw);
      this.rotationYaw =
          (float) ((double) this.rotationYaw + d1 / (double) this.fishPosRotationIncrements);
      this.rotationPitch =
          (float)
              ((double) this.rotationPitch
                  + (this.fishPitch - (double) this.rotationPitch)
                      / (double) this.fishPosRotationIncrements);
      --this.fishPosRotationIncrements;
      this.setPosition(d7, d8, d9);
      this.setRotation(this.rotationYaw, this.rotationPitch);
    } else {
      if (!this.worldObj.isRemote) {
        ItemStack itemstack = this.angler.getCurrentEquippedItem();

        if (this.angler.isDead
            || !this.angler.isEntityAlive()
            || itemstack == null
            || itemstack.getItem() != Items.fishing_rod
            || this.getDistanceSqToEntity(this.angler) > 1024.0D) {
          this.setDead();
          this.angler.fishEntity = null;
          return;
        }

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

          this.caughtEntity = null;
        }
      }

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

      if (this.inGround) {
        if (this.worldObj.getBlockState(new BlockPos(this.xTile, this.yTile, this.zTile)).getBlock()
            == 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;
      }

      Vec3 vec31 = new Vec3(this.posX, this.posY, this.posZ);
      Vec3 vec3 =
          new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec31, vec3);
      vec31 = new Vec3(this.posX, this.posY, this.posZ);
      vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      if (movingobjectposition != null) {
        vec3 =
            new Vec3(
                movingobjectposition.hitVec.xCoord,
                movingobjectposition.hitVec.yCoord,
                movingobjectposition.hitVec.zCoord);
      }

      Entity entity = null;
      List<Entity> list =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.getEntityBoundingBox()
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;

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

        if (entity1.canBeCollidedWith() && (entity1 != this.angler || this.ticksInAir >= 5)) {
          float f = 0.3F;
          AxisAlignedBB axisalignedbb =
              entity1.getEntityBoundingBox().expand((double) f, (double) f, (double) f);
          MovingObjectPosition movingobjectposition1 =
              axisalignedbb.calculateIntercept(vec31, vec3);

          if (movingobjectposition1 != null) {
            double d2 = vec31.squareDistanceTo(movingobjectposition1.hitVec);

            if (d2 < d0 || d0 == 0.0D) {
              entity = entity1;
              d0 = d2;
            }
          }
        }
      }

      if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
      }

      if (movingobjectposition != null) {
        if (movingobjectposition.entityHit != null) {
          if (movingobjectposition.entityHit.attackEntityFrom(
              DamageSource.causeThrownDamage(this, this.angler), 0.0F)) {
            this.caughtEntity = movingobjectposition.entityHit;
          }
        } else {
          this.inGround = true;
        }
      }

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

        for (this.rotationPitch =
                (float) (MathHelper.func_181159_b(this.motionY, (double) f5) * 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 f6 = 0.92F;

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

        int j = 5;
        double d10 = 0.0D;

        for (int k = 0; k < j; ++k) {
          AxisAlignedBB axisalignedbb1 = this.getEntityBoundingBox();
          double d3 = axisalignedbb1.maxY - axisalignedbb1.minY;
          double d4 = axisalignedbb1.minY + d3 * (double) k / (double) j;
          double d5 = axisalignedbb1.minY + d3 * (double) (k + 1) / (double) j;
          AxisAlignedBB axisalignedbb2 =
              new AxisAlignedBB(
                  axisalignedbb1.minX,
                  d4,
                  axisalignedbb1.minZ,
                  axisalignedbb1.maxX,
                  d5,
                  axisalignedbb1.maxZ);

          if (this.worldObj.isAABBInMaterial(axisalignedbb2, Material.water)) {
            d10 += 1.0D / (double) j;
          }
        }

        if (!this.worldObj.isRemote && d10 > 0.0D) {
          WorldServer worldserver = (WorldServer) this.worldObj;
          int l = 1;
          BlockPos blockpos = (new BlockPos(this)).up();

          if (this.rand.nextFloat() < 0.25F && this.worldObj.canLightningStrike(blockpos)) {
            l = 2;
          }

          if (this.rand.nextFloat() < 0.5F && !this.worldObj.canSeeSky(blockpos)) {
            --l;
          }

          if (this.ticksCatchable > 0) {
            --this.ticksCatchable;

            if (this.ticksCatchable <= 0) {
              this.ticksCaughtDelay = 0;
              this.ticksCatchableDelay = 0;
            }
          } else if (this.ticksCatchableDelay > 0) {
            this.ticksCatchableDelay -= l;

            if (this.ticksCatchableDelay <= 0) {
              this.motionY -= 0.20000000298023224D;
              this.playSound(
                  "random.splash",
                  0.25F,
                  1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
              float f8 = (float) MathHelper.floor_double(this.getEntityBoundingBox().minY);
              worldserver.spawnParticle(
                  EnumParticleTypes.WATER_BUBBLE,
                  this.posX,
                  (double) (f8 + 1.0F),
                  this.posZ,
                  (int) (1.0F + this.width * 20.0F),
                  (double) this.width,
                  0.0D,
                  (double) this.width,
                  0.20000000298023224D,
                  new int[0]);
              worldserver.spawnParticle(
                  EnumParticleTypes.WATER_WAKE,
                  this.posX,
                  (double) (f8 + 1.0F),
                  this.posZ,
                  (int) (1.0F + this.width * 20.0F),
                  (double) this.width,
                  0.0D,
                  (double) this.width,
                  0.20000000298023224D,
                  new int[0]);
              this.ticksCatchable = MathHelper.getRandomIntegerInRange(this.rand, 10, 30);
            } else {
              this.fishApproachAngle =
                  (float) ((double) this.fishApproachAngle + this.rand.nextGaussian() * 4.0D);
              float f7 = this.fishApproachAngle * 0.017453292F;
              float f10 = MathHelper.sin(f7);
              float f11 = MathHelper.cos(f7);
              double d13 = this.posX + (double) (f10 * (float) this.ticksCatchableDelay * 0.1F);
              double d15 =
                  (double)
                      ((float) MathHelper.floor_double(this.getEntityBoundingBox().minY) + 1.0F);
              double d16 = this.posZ + (double) (f11 * (float) this.ticksCatchableDelay * 0.1F);
              Block block1 =
                  worldserver
                      .getBlockState(new BlockPos((int) d13, (int) d15 - 1, (int) d16))
                      .getBlock();

              if (block1 == Blocks.water || block1 == Blocks.flowing_water) {
                if (this.rand.nextFloat() < 0.15F) {
                  worldserver.spawnParticle(
                      EnumParticleTypes.WATER_BUBBLE,
                      d13,
                      d15 - 0.10000000149011612D,
                      d16,
                      1,
                      (double) f10,
                      0.1D,
                      (double) f11,
                      0.0D,
                      new int[0]);
                }

                float f3 = f10 * 0.04F;
                float f4 = f11 * 0.04F;
                worldserver.spawnParticle(
                    EnumParticleTypes.WATER_WAKE,
                    d13,
                    d15,
                    d16,
                    0,
                    (double) f4,
                    0.01D,
                    (double) (-f3),
                    1.0D,
                    new int[0]);
                worldserver.spawnParticle(
                    EnumParticleTypes.WATER_WAKE,
                    d13,
                    d15,
                    d16,
                    0,
                    (double) (-f4),
                    0.01D,
                    (double) f3,
                    1.0D,
                    new int[0]);
              }
            }
          } else if (this.ticksCaughtDelay > 0) {
            this.ticksCaughtDelay -= l;
            float f1 = 0.15F;

            if (this.ticksCaughtDelay < 20) {
              f1 = (float) ((double) f1 + (double) (20 - this.ticksCaughtDelay) * 0.05D);
            } else if (this.ticksCaughtDelay < 40) {
              f1 = (float) ((double) f1 + (double) (40 - this.ticksCaughtDelay) * 0.02D);
            } else if (this.ticksCaughtDelay < 60) {
              f1 = (float) ((double) f1 + (double) (60 - this.ticksCaughtDelay) * 0.01D);
            }

            if (this.rand.nextFloat() < f1) {
              float f9 = MathHelper.randomFloatClamp(this.rand, 0.0F, 360.0F) * 0.017453292F;
              float f2 = MathHelper.randomFloatClamp(this.rand, 25.0F, 60.0F);
              double d12 = this.posX + (double) (MathHelper.sin(f9) * f2 * 0.1F);
              double d14 =
                  (double)
                      ((float) MathHelper.floor_double(this.getEntityBoundingBox().minY) + 1.0F);
              double d6 = this.posZ + (double) (MathHelper.cos(f9) * f2 * 0.1F);
              Block block =
                  worldserver
                      .getBlockState(new BlockPos((int) d12, (int) d14 - 1, (int) d6))
                      .getBlock();

              if (block == Blocks.water || block == Blocks.flowing_water) {
                worldserver.spawnParticle(
                    EnumParticleTypes.WATER_SPLASH,
                    d12,
                    d14,
                    d6,
                    2 + this.rand.nextInt(2),
                    0.10000000149011612D,
                    0.0D,
                    0.10000000149011612D,
                    0.0D,
                    new int[0]);
              }
            }

            if (this.ticksCaughtDelay <= 0) {
              this.fishApproachAngle = MathHelper.randomFloatClamp(this.rand, 0.0F, 360.0F);
              this.ticksCatchableDelay = MathHelper.getRandomIntegerInRange(this.rand, 20, 80);
            }
          } else {
            this.ticksCaughtDelay = MathHelper.getRandomIntegerInRange(this.rand, 100, 900);
            this.ticksCaughtDelay -= EnchantmentHelper.getLureModifier(this.angler) * 20 * 5;
          }

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

        double d11 = d10 * 2.0D - 1.0D;
        this.motionY += 0.03999999910593033D * d11;

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

        this.motionX *= (double) f6;
        this.motionY *= (double) f6;
        this.motionZ *= (double) f6;
        this.setPosition(this.posX, this.posY, this.posZ);
      }
    }
  }
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    this.onEntityUpdate();

    if (this.fishPosRotationIncrements > 0) {
      double var21 = this.posX + (this.fishX - this.posX) / this.fishPosRotationIncrements;
      double var22 = this.posY + (this.fishY - this.posY) / this.fishPosRotationIncrements;
      double var23 = this.posZ + (this.fishZ - this.posZ) / this.fishPosRotationIncrements;
      double var7 = MathHelper.wrapAngleTo180_double(this.fishYaw - this.rotationYaw);
      this.rotationYaw = (float) (this.rotationYaw + var7 / this.fishPosRotationIncrements);
      this.rotationPitch =
          (float)
              (this.rotationPitch
                  + (this.fishPitch - this.rotationPitch) / this.fishPosRotationIncrements);
      --this.fishPosRotationIncrements;
      this.setPosition(var21, var22, var23);
      this.setRotation(this.rotationYaw, this.rotationPitch);
    } else {
      if (!this.worldObj.isRemote) {
        if (angler != null) {
          ItemStack itemStack = this.angler.getHeldItem();

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

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

          this.bobber = null;
        }

        if (this != null) {
          if (this.isDead && this.bobber != null) {
            this.bobber.setDead();
          }
        }
      }

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

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

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

          if (this.ticksInGround >= 20) {
            this.setDead();

            try {
              angler.fishingChore.fishEntity = null;
            } catch (NullPointerException e) {
              return;
            }
          }

          return;
        }

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

      Vec3 vector =
          this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
      Vec3 motionVector =
          this.worldObj
              .getWorldVec3Pool()
              .getVecFromPool(
                  this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition movingObjectPosition = this.worldObj.clip(vector, motionVector);
      vector = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
      motionVector =
          this.worldObj
              .getWorldVec3Pool()
              .getVecFromPool(
                  this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      if (movingObjectPosition != null) {
        motionVector =
            this.worldObj
                .getWorldVec3Pool()
                .getVecFromPool(
                    movingObjectPosition.hitVec.xCoord,
                    movingObjectPosition.hitVec.yCoord,
                    movingObjectPosition.hitVec.zCoord);
      }

      Entity entity = null;
      List entityList =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double zeroDistance = 0.0D;
      double vectorDistance;

      for (int i = 0; i < entityList.size(); ++i) {
        Entity entityInList = (Entity) entityList.get(i);

        if (entityInList.canBeCollidedWith()
            && (entityInList != this.angler || this.ticksInAir >= 5)) {
          float boundingBoxExpansion = 0.3F;
          AxisAlignedBB bb =
              entityInList.boundingBox.expand(
                  boundingBoxExpansion, boundingBoxExpansion, boundingBoxExpansion);
          MovingObjectPosition interceptPosition = bb.calculateIntercept(vector, motionVector);

          if (interceptPosition != null) {
            vectorDistance = vector.distanceTo(interceptPosition.hitVec);

            if (vectorDistance < zeroDistance || zeroDistance == 0.0D) {
              entity = entityInList;
              zeroDistance = vectorDistance;
            }
          }
        }
      }

      if (entity != null) {
        movingObjectPosition = new MovingObjectPosition(entity);
      }

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

      if (!this.inGround) {
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
        float motion =
            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, motion) * 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 motionModifier = 0.92F;

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

        byte endByte = 5;
        double yMotion = 0.0D;

        for (int i = 0; i < endByte; ++i) {
          double boundingBoxMinY =
              this.boundingBox.minY
                  + (this.boundingBox.maxY - this.boundingBox.minY) * (i + 0) / endByte
                  - 0.125D
                  + 0.125D;
          double boundingBoxMaxY =
              this.boundingBox.minY
                  + (this.boundingBox.maxY - this.boundingBox.minY) * (i + 1) / endByte
                  - 0.125D
                  + 0.125D;
          AxisAlignedBB bb =
              AxisAlignedBB.getAABBPool()
                  .getAABB(
                      this.boundingBox.minX,
                      boundingBoxMinY,
                      this.boundingBox.minZ,
                      this.boundingBox.maxX,
                      boundingBoxMaxY,
                      this.boundingBox.maxZ);

          if (this.worldObj.isAABBInMaterial(bb, Material.water)) {
            yMotion += 1.0D / endByte;
          }
        }

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

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

            if (this.rand.nextInt(fishCatchChance) == 0) {
              this.ticksCatchable = this.rand.nextInt(30) + 10;
              this.motionY -= 0.20000000298023224D;
              this.playSound(
                  "random.splash",
                  0.25F,
                  1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);

              float floorMinY = MathHelper.floor_double(this.boundingBox.minY);
              int i;
              float randomFloat1;
              float randomFloat2;

              for (i = 0; i < 1.0F + this.width * 20.0F; ++i) {
                randomFloat1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                randomFloat2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                this.worldObj.spawnParticle(
                    "bubble",
                    this.posX + randomFloat1,
                    floorMinY + 1.0F,
                    this.posZ + randomFloat2,
                    this.motionX,
                    this.motionY - this.rand.nextFloat() * 0.2F,
                    this.motionZ);
              }

              for (i = 0; i < 1.0F + this.width * 20.0F; ++i) {
                randomFloat1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                randomFloat2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                this.worldObj.spawnParticle(
                    "splash",
                    this.posX + randomFloat1,
                    floorMinY + 1.0F,
                    this.posZ + randomFloat2,
                    this.motionX,
                    this.motionY,
                    this.motionZ);
              }
            }
          }
        }

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

        vectorDistance = yMotion * 2.0D - 1.0D;
        this.motionY += 0.03999999910593033D * vectorDistance;

        if (yMotion > 0.0D) {
          motionModifier = (float) (motionModifier * 0.9D);
          this.motionY *= 0.8D;
        }

        this.motionX *= motionModifier;
        this.motionY *= motionModifier;
        this.motionZ *= motionModifier;
        this.setPosition(this.posX, this.posY, this.posZ);
      }
    }

    try {
      if (this.angler.fishingChore.hasEnded) {
        this.setDead();
      }
    } catch (NullPointerException e) {
      return;
    }
  }
Beispiel #9
0
 public void drawRadar() {
   tick++;
   if (tick >= 50) {
     tick = 0;
   }
   GL11.glLineWidth(2.0F);
   InstanceMain.getInstance()
       .getRender()
       .drawFilledCircle(Minecraft.getMinecraft().displayWidth / 2 - 60, 60, 50, 0x55008881);
   InstanceMain.getInstance()
       .getRender()
       .drawCircle(Minecraft.getMinecraft().displayWidth / 2 - 60, 60, 50, 0x8800999C);
   InstanceMain.getInstance()
       .getRender()
       .drawCircle(Minecraft.getMinecraft().displayWidth / 2 - 60, 60, 38, 0x8800999C);
   InstanceMain.getInstance()
       .getRender()
       .drawCircle(Minecraft.getMinecraft().displayWidth / 2 - 60, 60, 25, 0x8800999C);
   InstanceMain.getInstance()
       .getRender()
       .drawCircle(Minecraft.getMinecraft().displayWidth / 2 - 60, 60, 13, 0x8800999C);
   InstanceMain.getInstance()
       .getRender()
       .drawCircle(Minecraft.getMinecraft().displayWidth / 2 - 60, 60, tick, 0x33000000);
   InstanceMain.getInstance()
       .getRender()
       .dr(
           Minecraft.getMinecraft().displayWidth / 2 - 110,
           59.5,
           Minecraft.getMinecraft().displayWidth / 2 - 10,
           60.5,
           0x99000000);
   InstanceMain.getInstance()
       .getRender()
       .dr(
           Minecraft.getMinecraft().displayWidth / 2 - 59.5,
           10,
           Minecraft.getMinecraft().displayWidth / 2 - 60.5,
           110,
           0x99000000);
   InstanceMain.getInstance()
       .getRender()
       .drawCircle(Minecraft.getMinecraft().displayWidth / 2 - 60, 60, 1, 0xffffffff); // Player
   List<Entity> list1 = this.mc.theWorld.loadedEntityList;
   GL11.glLineWidth(1.0F);
   for (int i = 0; i < list1.size(); i++) {
     Entity entity = list1.get(i);
     double xdis = this.mc.thePlayer.posX - entity.posX;
     double zdis = this.mc.thePlayer.posZ - entity.posZ;
     double tdis = Math.sqrt((xdis * xdis) + (zdis * zdis));
     double difInAng =
         MathHelper.wrapAngleTo180_double(
             this.mc.thePlayer.rotationYaw - ((Math.atan2(zdis, xdis) * 180.0D) / Math.PI));
     double finalX = Math.cos(Math.toRadians(difInAng)) * tdis;
     double finalY = -Math.sin(Math.toRadians(difInAng)) * tdis;
     GL11.glPushMatrix();
     GL11.glTranslatef(Minecraft.getMinecraft().displayWidth / 2 - 60, 60, 0);
     if (tdis <= 100) {
       if (!(entity instanceof EntityPlayerSP)) {
         if (entity instanceof EntityPlayer) {
           InstanceMain.getInstance()
               .getRender()
               .drawCircle((int) finalX / 2, (int) finalY / 2, 1, 0xff0000ff);
           GL11.glScalef(0.5F, 0.5F, 0.5F);
           EntityPlayer p = (EntityPlayer) entity;
           String u = p.getName();
           this.mc.fontRendererObj.drawString(
               u,
               (int) (finalX) - (this.mc.fontRendererObj.getStringWidth(u) / 2),
               (int) finalY - 10,
               0xffffff);
           GL11.glScalef(1F, 0.5F, 1F);
         }
         if (entity instanceof EntityAnimal) {
           InstanceMain.getInstance()
               .getRender()
               .drawCircle((int) finalX / 2, (int) finalY / 2, 1, 0xff00ff00);
         }
         if (entity instanceof EntityMob) {
           InstanceMain.getInstance()
               .getRender()
               .drawCircle((int) finalX / 2, (int) finalY / 2, 1, 0xffff0000);
         }
         if (entity instanceof EntitySlime) {
           InstanceMain.getInstance()
               .getRender()
               .drawCircle((int) finalX / 2, (int) finalY / 2, 1, 0xffff88cc);
         }
         if (entity instanceof EntityVillager) {
           InstanceMain.getInstance()
               .getRender()
               .drawCircle((int) finalX / 2, (int) finalY / 2, 1, 0xff8b4513);
         }
         if (entity instanceof EntityBat) {
           InstanceMain.getInstance()
               .getRender()
               .drawCircle((int) finalX / 2, (int) finalY / 2, 1, 0xfff4a460);
         }
         if (entity instanceof EntitySquid) {
           InstanceMain.getInstance()
               .getRender()
               .drawCircle((int) finalX / 2, (int) finalY / 2, 1, 0xff003399);
         }
       }
     }
     GL11.glPopMatrix();
   }
 }
  /** Called to update the entity's position/logic. */
  @Override
  public void onUpdate() {
    onEntityUpdate();

    if (fishPosRotationIncrements > 0) {
      final double var21 = posX + (fishX - posX) / fishPosRotationIncrements;
      final double var22 = posY + (fishY - posY) / fishPosRotationIncrements;
      final double var23 = posZ + (fishZ - posZ) / fishPosRotationIncrements;
      final double var7 = MathHelper.wrapAngleTo180_double(fishYaw - rotationYaw);
      rotationYaw = (float) (rotationYaw + var7 / fishPosRotationIncrements);
      rotationPitch =
          (float) (rotationPitch + (fishPitch - rotationPitch) / fishPosRotationIncrements);
      --fishPosRotationIncrements;
      setPosition(var21, var22, var23);
      setRotation(rotationYaw, rotationPitch);
    } else {
      if (!worldObj.isRemote) {
        if (angler != null) {
          final ItemStack itemStack = angler.getHeldItem();

          if (angler.isDead
              || !angler.isEntityAlive()
              || itemStack == null
              || itemStack.getItem() != Items.fishing_rod
              || getDistanceSqToEntity(angler) > 1024.0D) {
            setDead();
            angler.fishingChore.fishEntity = null;
            return;
          }
        } else {
          setDead();
        }

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

          field_146043_c = null;
        }

        if (this != null) {
          if (isDead && field_146043_c != null) {
            field_146043_c.setDead();
          }
        }
      }

      if (field_146044_a > 0) {
        --field_146044_a;
      }

      // TODO
      //			if (this.inGround)
      //			{
      //				if (this.worldObj.getBlock(this.field_146037_g, this.field_146048_h,
      // this.field_146050_i) == this.field_146046_j)
      //				{
      //					++this.ticksInGround;
      //
      //					if (this.ticksInGround >= 20)
      //					{
      //						this.setDead();
      //
      //						try
      //						{
      //							angler.fishingChore.fishEntity = null;
      //						}
      //
      //						catch (NullPointerException e)
      //						{
      //							return;
      //						}
      //					}
      //
      //					return;
      //				}
      //
      //				this.inGround = false;
      //				this.motionX *= this.rand.nextFloat() * 0.2F;
      //				this.motionY *= this.rand.nextFloat() * 0.2F;
      //				this.motionZ *= this.rand.nextFloat() * 0.2F;
      //				this.ticksInGround = 0;
      //				this.ticksInAir = 0;
      //			}
      //
      //			else
      //			{
      //				++this.ticksInAir;
      //			}

      Vec3 vector = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ);
      Vec3 motionVector =
          worldObj
              .getWorldVec3Pool()
              .getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ);
      MovingObjectPosition movingObjectPosition = worldObj.rayTraceBlocks(vector, motionVector);
      vector = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ);
      motionVector =
          worldObj
              .getWorldVec3Pool()
              .getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ);

      if (movingObjectPosition != null) {
        motionVector =
            worldObj
                .getWorldVec3Pool()
                .getVecFromPool(
                    movingObjectPosition.hitVec.xCoord,
                    movingObjectPosition.hitVec.yCoord,
                    movingObjectPosition.hitVec.zCoord);
      }

      Entity entity = null;
      final List entityList =
          worldObj.getEntitiesWithinAABBExcludingEntity(
              this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
      double zeroDistance = 0.0D;
      double vectorDistance;

      for (int i = 0; i < entityList.size(); ++i) {
        final Entity entityInList = (Entity) entityList.get(i);

        if (entityInList.canBeCollidedWith() && (entityInList != angler || ticksInAir >= 5)) {
          final float boundingBoxExpansion = 0.3F;
          final AxisAlignedBB bb =
              entityInList.boundingBox.expand(
                  boundingBoxExpansion, boundingBoxExpansion, boundingBoxExpansion);
          final MovingObjectPosition interceptPosition =
              bb.calculateIntercept(vector, motionVector);

          if (interceptPosition != null) {
            vectorDistance = vector.distanceTo(interceptPosition.hitVec);

            if (vectorDistance < zeroDistance || zeroDistance == 0.0D) {
              entity = entityInList;
              zeroDistance = vectorDistance;
            }
          }
        }
      }

      if (entity != null) {
        movingObjectPosition = new MovingObjectPosition(entity);
      }

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

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

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

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

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

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

        rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
        rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
        float motionModifier = 0.92F;

        if (onGround || isCollidedHorizontally) {
          motionModifier = 0.5F;
        }

        final byte endByte = 5;
        double yMotion = 0.0D;

        for (int i = 0; i < endByte; ++i) {
          final double boundingBoxMinY =
              boundingBox.minY
                  + (boundingBox.maxY - boundingBox.minY) * (i + 0) / endByte
                  - 0.125D
                  + 0.125D;
          final double boundingBoxMaxY =
              boundingBox.minY
                  + (boundingBox.maxY - boundingBox.minY) * (i + 1) / endByte
                  - 0.125D
                  + 0.125D;
          final AxisAlignedBB bb =
              AxisAlignedBB.getAABBPool()
                  .getAABB(
                      boundingBox.minX,
                      boundingBoxMinY,
                      boundingBox.minZ,
                      boundingBox.maxX,
                      boundingBoxMaxY,
                      boundingBox.maxZ);

          if (worldObj.isAABBInMaterial(bb, Material.water)) {
            yMotion += 1.0D / endByte;
          }
        }

        if (yMotion > 0.0D) {
          if (ticksCatchable > 0) {
            --ticksCatchable;
          } else {
            short fishCatchChance = 500;

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

            if (rand.nextInt(fishCatchChance) == 0) {
              ticksCatchable = rand.nextInt(30) + 10;
              motionY -= 0.20000000298023224D;
              playSound(
                  "random.splash", 0.25F, 1.0F + (rand.nextFloat() - rand.nextFloat()) * 0.4F);

              final float floorMinY = MathHelper.floor_double(boundingBox.minY);
              int i;
              float randomFloat1;
              float randomFloat2;

              for (i = 0; i < 1.0F + width * 20.0F; ++i) {
                randomFloat1 = (rand.nextFloat() * 2.0F - 1.0F) * width;
                randomFloat2 = (rand.nextFloat() * 2.0F - 1.0F) * width;
                worldObj.spawnParticle(
                    "bubble",
                    posX + randomFloat1,
                    floorMinY + 1.0F,
                    posZ + randomFloat2,
                    motionX,
                    motionY - rand.nextFloat() * 0.2F,
                    motionZ);
              }

              for (i = 0; i < 1.0F + width * 20.0F; ++i) {
                randomFloat1 = (rand.nextFloat() * 2.0F - 1.0F) * width;
                randomFloat2 = (rand.nextFloat() * 2.0F - 1.0F) * width;
                worldObj.spawnParticle(
                    "splash",
                    posX + randomFloat1,
                    floorMinY + 1.0F,
                    posZ + randomFloat2,
                    motionX,
                    motionY,
                    motionZ);
              }
            }
          }
        }

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

        vectorDistance = yMotion * 2.0D - 1.0D;
        motionY += 0.03999999910593033D * vectorDistance;

        if (yMotion > 0.0D) {
          motionModifier = (float) (motionModifier * 0.9D);
          motionY *= 0.8D;
        }

        motionX *= motionModifier;
        motionY *= motionModifier;
        motionZ *= motionModifier;
        setPosition(posX, posY, posZ);
      }
    }

    try {
      if (angler.fishingChore.hasEnded) {
        setDead();
      }
    } catch (final NullPointerException e) {
      return;
    }
  }