Example #1
0
 public virtual void updateEntityWithOptionalForce(Entity entity, bool flag)
 {
     int i = MathHelper.floor_double(entity.posX);
     int j = MathHelper.floor_double(entity.posZ);
     byte byte0 = 32;
     if (flag && !checkChunksExist(i - byte0, 0, j - byte0, i + byte0, 128, j + byte0))
     {
         return;
     }
     entity.lastTickPosX = entity.posX;
     entity.lastTickPosY = entity.posY;
     entity.lastTickPosZ = entity.posZ;
     entity.prevRotationYaw = entity.rotationYaw;
     entity.prevRotationPitch = entity.rotationPitch;
     if (flag && entity.addedToChunk)
     {
         if (entity.ridingEntity != null)
         {
             entity.updateRidden();
         }
         else
         {
             entity.onUpdate();
         }
     }
     if (Double.isNaN(entity.posX) || Double.isInfinite(entity.posX))
     {
         entity.posX = entity.lastTickPosX;
     }
     if (Double.isNaN(entity.posY) || Double.isInfinite(entity.posY))
     {
         entity.posY = entity.lastTickPosY;
     }
     if (Double.isNaN(entity.posZ) || Double.isInfinite(entity.posZ))
     {
         entity.posZ = entity.lastTickPosZ;
     }
     if (Double.isNaN(entity.rotationPitch) || Double.isInfinite(entity.rotationPitch))
     {
         entity.rotationPitch = entity.prevRotationPitch;
     }
     if (Double.isNaN(entity.rotationYaw) || Double.isInfinite(entity.rotationYaw))
     {
         entity.rotationYaw = entity.prevRotationYaw;
     }
     int k = MathHelper.floor_double(entity.posX/16D);
     int l = MathHelper.floor_double(entity.posY/16D);
     int i1 = MathHelper.floor_double(entity.posZ/16D);
     if (!entity.addedToChunk || entity.chunkCoordX != k || entity.chunkCoordY != l || entity.chunkCoordZ != i1)
     {
         if (entity.addedToChunk && chunkExists(entity.chunkCoordX, entity.chunkCoordZ))
         {
             getChunkFromChunkCoords(entity.chunkCoordX, entity.chunkCoordZ).removeEntityAtIndex(entity,
                                                                                                 entity.
                                                                                                     chunkCoordY);
         }
         if (chunkExists(k, i1))
         {
             entity.addedToChunk = true;
             getChunkFromChunkCoords(k, i1).addEntity(entity);
         }
         else
         {
             entity.addedToChunk = false;
         }
     }
     if (flag && entity.addedToChunk && entity.riddenByEntity != null)
     {
         if (entity.riddenByEntity.isDead || entity.riddenByEntity.ridingEntity != entity)
         {
             entity.riddenByEntity.ridingEntity = null;
             entity.riddenByEntity = null;
         }
         else
         {
             updateEntity(entity.riddenByEntity);
         }
     }
 }