Example #1
0
 public EntityTrackerEntry(Entity par1Entity, int par2, int par3, boolean par4) {
   this.myEntity = par1Entity;
   this.blocksDistanceThreshold = par2;
   this.updateFrequency = par3;
   this.sendVelocityUpdates = par4;
   this.lastScaledXPosition = MathHelper.floor_double(par1Entity.posX * 32.0D);
   this.lastScaledYPosition = MathHelper.floor_double(par1Entity.posY * 32.0D);
   this.lastScaledZPosition = MathHelper.floor_double(par1Entity.posZ * 32.0D);
   this.lastYaw = MathHelper.floor_float(par1Entity.rotationYaw * 256.0F / 360.0F);
   this.lastPitch = MathHelper.floor_float(par1Entity.rotationPitch * 256.0F / 360.0F);
   this.lastHeadMotion = MathHelper.floor_float(par1Entity.setRotationYawHead() * 256.0F / 360.0F);
 }
Example #2
0
  /** Renders all the overlays that are in first person mode. Args: partialTickTime */
  public void renderOverlays(float par1) {
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    int var2;

    if (this.mc.thePlayer.isBurning()) {
      var2 = this.mc.renderEngine.getTexture("/terrain.png");
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2);
      this.renderFireInFirstPerson(par1);
    }

    if (this.mc.thePlayer.isEntityInsideOpaqueBlock()) {
      var2 = MathHelper.floor_double(this.mc.thePlayer.posX);
      int var3 = MathHelper.floor_double(this.mc.thePlayer.posY);
      int var4 = MathHelper.floor_double(this.mc.thePlayer.posZ);
      int var5 = this.mc.renderEngine.getTexture("/terrain.png");
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, var5);
      int var6 = this.mc.theWorld.getBlockId(var2, var3, var4);

      if (this.mc.theWorld.isBlockNormalCube(var2, var3, var4)) {
        this.renderInsideOfBlock(par1, Block.blocksList[var6].getBlockTextureFromSide(2));
      } else {
        for (int var7 = 0; var7 < 8; ++var7) {
          float var8 = ((float) ((var7 >> 0) % 2) - 0.5F) * this.mc.thePlayer.width * 0.9F;
          float var9 = ((float) ((var7 >> 1) % 2) - 0.5F) * this.mc.thePlayer.height * 0.2F;
          float var10 = ((float) ((var7 >> 2) % 2) - 0.5F) * this.mc.thePlayer.width * 0.9F;
          int var11 = MathHelper.floor_float((float) var2 + var8);
          int var12 = MathHelper.floor_float((float) var3 + var9);
          int var13 = MathHelper.floor_float((float) var4 + var10);

          if (this.mc.theWorld.isBlockNormalCube(var11, var12, var13)) {
            var6 = this.mc.theWorld.getBlockId(var11, var12, var13);
          }
        }
      }

      if (Block.blocksList[var6] != null) {
        this.renderInsideOfBlock(par1, Block.blocksList[var6].getBlockTextureFromSide(2));
      }
    }

    if (this.mc.thePlayer.isInsideOfMaterial(Material.water)) {
      var2 = this.mc.renderEngine.getTexture("/misc/water.png");
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2);
      this.renderWarpedTextureOverlay(par1);
    }

    GL11.glEnable(GL11.GL_ALPHA_TEST);
  }
Example #3
0
  /** Renders all the overlays that are in first person mode. Args: partialTickTime */
  public void renderOverlays(float par1) {
    GL11.glDisable(GL11.GL_ALPHA_TEST);

    if (mc.thePlayer.isBurning()) {
      int i = mc.renderEngine.getTexture("/terrain.png");
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, i);
      renderFireInFirstPerson(par1);
    }

    if (mc.thePlayer.isEntityInsideOpaqueBlock()) {
      int j = MathHelper.floor_double(mc.thePlayer.posX);
      int l = MathHelper.floor_double(mc.thePlayer.posY);
      int i1 = MathHelper.floor_double(mc.thePlayer.posZ);
      int j1 = mc.renderEngine.getTexture("/terrain.png");
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, j1);
      int k1 = mc.theWorld.getBlockId(j, l, i1);

      if (mc.theWorld.isBlockNormalCube(j, l, i1)) {
        renderInsideOfBlock(par1, Block.blocksList[k1].getBlockTextureFromSide(2));
      } else {
        for (int l1 = 0; l1 < 8; l1++) {
          float f = ((float) ((l1 >> 0) % 2) - 0.5F) * mc.thePlayer.width * 0.9F;
          float f1 = ((float) ((l1 >> 1) % 2) - 0.5F) * mc.thePlayer.height * 0.2F;
          float f2 = ((float) ((l1 >> 2) % 2) - 0.5F) * mc.thePlayer.width * 0.9F;
          int i2 = MathHelper.floor_float((float) j + f);
          int j2 = MathHelper.floor_float((float) l + f1);
          int k2 = MathHelper.floor_float((float) i1 + f2);

          if (mc.theWorld.isBlockNormalCube(i2, j2, k2)) {
            k1 = mc.theWorld.getBlockId(i2, j2, k2);
          }
        }
      }

      if (Block.blocksList[k1] != null) {
        renderInsideOfBlock(par1, Block.blocksList[k1].getBlockTextureFromSide(2));
      }
    }

    if (mc.thePlayer.isInsideOfMaterial(Material.water)) {
      int k = mc.renderEngine.getTexture("/misc/water.png");
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, k);
      renderWarpedTextureOverlay(par1);
    }

    GL11.glEnable(GL11.GL_ALPHA_TEST);
  }
Example #4
0
  public Packet23VehicleSpawn(Entity par1Entity, int par2, int par3) {
    this.entityId = par1Entity.entityId;
    this.xPosition = MathHelper.floor_double(par1Entity.posX * 32.0D);
    this.yPosition = MathHelper.floor_double(par1Entity.posY * 32.0D);
    this.zPosition = MathHelper.floor_double(par1Entity.posZ * 32.0D);
    this.pitch = MathHelper.floor_float(par1Entity.rotationPitch * 256.0F / 360.0F);
    this.yaw = MathHelper.floor_float(par1Entity.rotationYaw * 256.0F / 360.0F);
    this.type = par2;
    this.throwerEntityId = par3;

    if (par3 > 0) {
      double var4 = par1Entity.motionX;
      double var6 = par1Entity.motionY;
      double var8 = par1Entity.motionZ;
      double var10 = 3.9D;

      if (var4 < -var10) {
        var4 = -var10;
      }

      if (var6 < -var10) {
        var6 = -var10;
      }

      if (var8 < -var10) {
        var8 = -var10;
      }

      if (var4 > var10) {
        var4 = var10;
      }

      if (var6 > var10) {
        var6 = var10;
      }

      if (var8 > var10) {
        var8 = var10;
      }

      this.speedX = (int) (var4 * 8000.0D);
      this.speedY = (int) (var6 * 8000.0D);
      this.speedZ = (int) (var8 * 8000.0D);
    }
  }
Example #5
0
  /** Checks if the current block the entity is within of the specified material type */
  public boolean isInsideOfMaterial(Material par1Material) {
    double d = posY + (double) getEyeHeight();
    int i = MathHelper.floor_double(posX);
    int j = MathHelper.floor_float(MathHelper.floor_double(d));
    int k = MathHelper.floor_double(posZ);
    int l = worldObj.getBlockId(i, j, k);

    if (l != 0 && Block.blocksList[l].blockMaterial == par1Material) {
      float f = BlockFluid.getFluidHeightPercent(worldObj.getBlockMetadata(i, j, k)) - 0.1111111F;
      float f1 = (float) (j + 1) - f;
      return d < (double) f1;
    } else {
      return false;
    }
  }
Example #6
0
  /** also sends velocity, rotation, and riding info. */
  public void sendLocationToAllClients(List par1List) {
    this.playerEntitiesUpdated = false;

    if (!this.isDataInitialized
        || this.myEntity.getDistanceSq(this.posX, this.posY, this.posZ) > 16.0D) {
      this.posX = this.myEntity.posX;
      this.posY = this.myEntity.posY;
      this.posZ = this.myEntity.posZ;
      this.isDataInitialized = true;
      this.playerEntitiesUpdated = true;
      this.sendEventsToPlayers(par1List);
    }

    if (this.field_85178_v != this.myEntity.ridingEntity) {
      this.field_85178_v = this.myEntity.ridingEntity;
      this.sendPacketToAllTrackingPlayers(
          new Packet39AttachEntity(this.myEntity, this.myEntity.ridingEntity));
    }

    if (this.myEntity instanceof EntityItemFrame && this.ticks % 10 == 0) {
      EntityItemFrame var23 = (EntityItemFrame) this.myEntity;
      ItemStack var24 = var23.getDisplayedItem();

      if (var24 != null && var24.getItem() instanceof ItemMap) {
        MapData var26 = Item.map.getMapData(var24, this.myEntity.worldObj);
        Iterator var29 = par1List.iterator();

        while (var29.hasNext()) {
          EntityPlayer var30 = (EntityPlayer) var29.next();
          EntityPlayerMP var31 = (EntityPlayerMP) var30;
          var26.updateVisiblePlayers(var31, var24);

          if (var31.playerNetServerHandler.packetSize() <= 5) {
            Packet var32 = Item.map.createMapDataPacket(var24, this.myEntity.worldObj, var31);

            if (var32 != null) {
              var31.playerNetServerHandler.sendPacketToPlayer(var32);
            }
          }
        }
      }

      DataWatcher var28 = this.myEntity.getDataWatcher();

      if (var28.hasChanges()) {
        this.sendPacketToAllAssociatedPlayers(
            new Packet40EntityMetadata(this.myEntity.entityId, var28, false));
      }
    } else if (this.ticks++ % this.updateFrequency == 0 || this.myEntity.isAirBorne) {
      int var2;
      int var3;

      if (this.myEntity.ridingEntity == null) {
        ++this.ticksSinceLastForcedTeleport;
        var2 = this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posX);
        var3 = MathHelper.floor_double(this.myEntity.posY * 32.0D);
        int var4 = this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posZ);
        int var5 = MathHelper.floor_float(this.myEntity.rotationYaw * 256.0F / 360.0F);
        int var6 = MathHelper.floor_float(this.myEntity.rotationPitch * 256.0F / 360.0F);
        int var7 = var2 - this.lastScaledXPosition;
        int var8 = var3 - this.lastScaledYPosition;
        int var9 = var4 - this.lastScaledZPosition;
        Object var10 = null;
        boolean var11 =
            Math.abs(var7) >= 4
                || Math.abs(var8) >= 4
                || Math.abs(var9) >= 4
                || this.ticks % 60 == 0;
        boolean var12 = Math.abs(var5 - this.lastYaw) >= 4 || Math.abs(var6 - this.lastPitch) >= 4;

        if (var7 >= -128
            && var7 < 128
            && var8 >= -128
            && var8 < 128
            && var9 >= -128
            && var9 < 128
            && this.ticksSinceLastForcedTeleport <= 400
            && !this.ridingEntity) {
          if (var11 && var12) {
            var10 =
                new Packet33RelEntityMoveLook(
                    this.myEntity.entityId,
                    (byte) var7,
                    (byte) var8,
                    (byte) var9,
                    (byte) var5,
                    (byte) var6);
          } else if (var11) {
            var10 =
                new Packet31RelEntityMove(
                    this.myEntity.entityId, (byte) var7, (byte) var8, (byte) var9);
          } else if (var12) {
            var10 = new Packet32EntityLook(this.myEntity.entityId, (byte) var5, (byte) var6);
          }
        } else {
          this.ticksSinceLastForcedTeleport = 0;
          var10 =
              new Packet34EntityTeleport(
                  this.myEntity.entityId, var2, var3, var4, (byte) var5, (byte) var6);
        }

        if (this.sendVelocityUpdates) {
          double var13 = this.myEntity.motionX - this.motionX;
          double var15 = this.myEntity.motionY - this.motionY;
          double var17 = this.myEntity.motionZ - this.motionZ;
          double var19 = 0.02D;
          double var21 = var13 * var13 + var15 * var15 + var17 * var17;

          if (var21 > var19 * var19
              || var21 > 0.0D
                  && this.myEntity.motionX == 0.0D
                  && this.myEntity.motionY == 0.0D
                  && this.myEntity.motionZ == 0.0D) {
            this.motionX = this.myEntity.motionX;
            this.motionY = this.myEntity.motionY;
            this.motionZ = this.myEntity.motionZ;
            this.sendPacketToAllTrackingPlayers(
                new Packet28EntityVelocity(
                    this.myEntity.entityId, this.motionX, this.motionY, this.motionZ));
          }
        }

        if (var10 != null) {
          this.sendPacketToAllTrackingPlayers((Packet) var10);
        }

        DataWatcher var33 = this.myEntity.getDataWatcher();

        if (var33.hasChanges()) {
          this.sendPacketToAllAssociatedPlayers(
              new Packet40EntityMetadata(this.myEntity.entityId, var33, false));
        }

        if (var11) {
          this.lastScaledXPosition = var2;
          this.lastScaledYPosition = var3;
          this.lastScaledZPosition = var4;
        }

        if (var12) {
          this.lastYaw = var5;
          this.lastPitch = var6;
        }

        this.ridingEntity = false;
      } else {
        var2 = MathHelper.floor_float(this.myEntity.rotationYaw * 256.0F / 360.0F);
        var3 = MathHelper.floor_float(this.myEntity.rotationPitch * 256.0F / 360.0F);
        boolean var25 = Math.abs(var2 - this.lastYaw) >= 4 || Math.abs(var3 - this.lastPitch) >= 4;

        if (var25) {
          this.sendPacketToAllTrackingPlayers(
              new Packet32EntityLook(this.myEntity.entityId, (byte) var2, (byte) var3));
          this.lastYaw = var2;
          this.lastPitch = var3;
        }

        this.lastScaledXPosition =
            this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posX);
        this.lastScaledYPosition = MathHelper.floor_double(this.myEntity.posY * 32.0D);
        this.lastScaledZPosition =
            this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posZ);
        DataWatcher var27 = this.myEntity.getDataWatcher();

        if (var27.hasChanges()) {
          this.sendPacketToAllAssociatedPlayers(
              new Packet40EntityMetadata(this.myEntity.entityId, var27, false));
        }

        this.ridingEntity = true;
      }

      var2 = MathHelper.floor_float(this.myEntity.setRotationYawHead() * 256.0F / 360.0F);

      if (Math.abs(var2 - this.lastHeadMotion) >= 4) {
        this.sendPacketToAllTrackingPlayers(
            new Packet35EntityHeadRotation(this.myEntity.entityId, (byte) var2));
        this.lastHeadMotion = var2;
      }

      this.myEntity.isAirBorne = false;
    }

    if (this.myEntity.velocityChanged) {
      this.sendPacketToAllAssociatedPlayers(new Packet28EntityVelocity(this.myEntity));
      this.myEntity.velocityChanged = false;
    }
  }
Example #7
0
  private Packet getPacketForThisEntity() {
    if (this.myEntity.isDead) {
      System.out.println("Fetching addPacket for removed entity");
    }

    if (this.myEntity instanceof EntityItem) {
      return new Packet23VehicleSpawn(this.myEntity, 2, 1);
    } else if (this.myEntity instanceof EntityPlayerMP) {
      return new Packet20NamedEntitySpawn((EntityPlayer) this.myEntity);
    } else {
      EntityMinecart var1;

      if (this.myEntity instanceof EntityMinecart) {
        var1 = (EntityMinecart) this.myEntity;

        if (var1.minecartType == 0) {
          return new Packet23VehicleSpawn(this.myEntity, 10);
        }

        if (var1.minecartType == 1) {
          return new Packet23VehicleSpawn(this.myEntity, 11);
        }

        if (var1.minecartType == 2) {
          return new Packet23VehicleSpawn(this.myEntity, 12);
        }
      }

      if (this.myEntity instanceof EntityBoat) {
        return new Packet23VehicleSpawn(this.myEntity, 1);
      } else if (!(this.myEntity instanceof IAnimals) && !(this.myEntity instanceof EntityDragon)) {
        if (this.myEntity instanceof EntityFishHook) {
          EntityPlayer var10 = ((EntityFishHook) this.myEntity).angler;
          return new Packet23VehicleSpawn(
              this.myEntity, 90, var10 != null ? var10.entityId : this.myEntity.entityId);
        } else if (this.myEntity instanceof EntityArrow) {
          Entity var8 = ((EntityArrow) this.myEntity).shootingEntity;
          return new Packet23VehicleSpawn(
              this.myEntity, 60, var8 != null ? var8.entityId : this.myEntity.entityId);
        } else if (this.myEntity instanceof EntitySnowball) {
          return new Packet23VehicleSpawn(this.myEntity, 61);
        } else if (this.myEntity instanceof EntityPotion) {
          return new Packet23VehicleSpawn(
              this.myEntity, 73, ((EntityPotion) this.myEntity).getPotionDamage());
        } else if (this.myEntity instanceof EntityExpBottle) {
          return new Packet23VehicleSpawn(this.myEntity, 75);
        } else if (this.myEntity instanceof EntityEnderPearl) {
          return new Packet23VehicleSpawn(this.myEntity, 65);
        } else if (this.myEntity instanceof EntityEnderEye) {
          return new Packet23VehicleSpawn(this.myEntity, 72);
        } else if (this.myEntity instanceof EntityFireworkRocket) {
          return new Packet23VehicleSpawn(this.myEntity, 76);
        } else {
          Packet23VehicleSpawn var4;

          if (this.myEntity instanceof EntityFireball) {
            EntityFireball var7 = (EntityFireball) this.myEntity;
            var1 = null;
            byte var9 = 63;

            if (this.myEntity instanceof EntitySmallFireball) {
              var9 = 64;
            } else if (this.myEntity instanceof EntityWitherSkull) {
              var9 = 66;
            }

            if (var7.shootingEntity != null) {
              var4 =
                  new Packet23VehicleSpawn(
                      this.myEntity,
                      var9,
                      ((EntityFireball) this.myEntity).shootingEntity.entityId);
            } else {
              var4 = new Packet23VehicleSpawn(this.myEntity, var9, 0);
            }

            var4.speedX = (int) (var7.accelerationX * 8000.0D);
            var4.speedY = (int) (var7.accelerationY * 8000.0D);
            var4.speedZ = (int) (var7.accelerationZ * 8000.0D);
            return var4;
          } else if (this.myEntity instanceof EntityEgg) {
            return new Packet23VehicleSpawn(this.myEntity, 62);
          } else if (this.myEntity instanceof EntityTNTPrimed) {
            return new Packet23VehicleSpawn(this.myEntity, 50);
          } else if (this.myEntity instanceof EntityEnderCrystal) {
            return new Packet23VehicleSpawn(this.myEntity, 51);
          } else if (this.myEntity instanceof EntityFallingSand) {
            EntityFallingSand var6 = (EntityFallingSand) this.myEntity;
            return new Packet23VehicleSpawn(this.myEntity, 70, var6.blockID | var6.metadata << 16);
          } else if (this.myEntity instanceof EntityPainting) {
            return new Packet25EntityPainting((EntityPainting) this.myEntity);
          } else if (this.myEntity instanceof EntityItemFrame) {
            EntityItemFrame var5 = (EntityItemFrame) this.myEntity;
            var4 = new Packet23VehicleSpawn(this.myEntity, 71, var5.hangingDirection);
            var4.xPosition = MathHelper.floor_float((float) (var5.xPosition * 32));
            var4.yPosition = MathHelper.floor_float((float) (var5.yPosition * 32));
            var4.zPosition = MathHelper.floor_float((float) (var5.zPosition * 32));
            return var4;
          } else if (this.myEntity instanceof EntityXPOrb) {
            return new Packet26EntityExpOrb((EntityXPOrb) this.myEntity);
          } else {
            Iterator var2 = ModLoader.getTrackers().values().iterator();
            EntityTrackerNonliving var3;

            do {
              if (!var2.hasNext()) {
                throw new IllegalArgumentException(
                    "Don\'t know how to add " + this.myEntity.getClass() + "!");
              }

              var3 = (EntityTrackerNonliving) var2.next();
            } while (!var3.entityClass.isAssignableFrom(this.myEntity.getClass()));

            return var3.mod.getSpawnPacket(this.myEntity, var3.id);
          }
        }
      } else {
        this.lastHeadMotion =
            MathHelper.floor_float(this.myEntity.setRotationYawHead() * 256.0F / 360.0F);
        return new Packet24MobSpawn((EntityLiving) this.myEntity);
      }
    }
  }
Example #8
0
  public void runTick() {
    if (ticksRan == 6000) {
      func_28001_B();
    }
    statFileWriter.func_27178_d();
    ingameGUI.updateTick();
    entityRenderer.getMouseOver(1.0F);
    if (thePlayer != null) {
      net.minecraft.src.IChunkProvider ichunkprovider = theWorld.getIChunkProvider();
      if (ichunkprovider instanceof ChunkProviderLoadOrGenerate) {
        ChunkProviderLoadOrGenerate chunkproviderloadorgenerate =
            (ChunkProviderLoadOrGenerate) ichunkprovider;
        int j = MathHelper.floor_float((int) thePlayer.posX) >> 4;
        int i1 = MathHelper.floor_float((int) thePlayer.posZ) >> 4;
        chunkproviderloadorgenerate.setCurrentChunkOver(j, i1);
      }
    }
    if (!isGamePaused && theWorld != null) {
      playerController.updateController();
    }
    GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, renderEngine.getTexture("/terrain.png"));
    if (!isGamePaused) {
      renderEngine.updateDynamicTextures();
    }
    if (currentScreen == null && thePlayer != null) {
      if (thePlayer.health <= 0) {
        displayGuiScreen(null);
      } else if (thePlayer.isPlayerSleeping() && theWorld != null && theWorld.multiplayerWorld) {
        displayGuiScreen(new GuiSleepMP());
      }
    } else if (currentScreen != null
        && (currentScreen instanceof GuiSleepMP)
        && !thePlayer.isPlayerSleeping()) {
      displayGuiScreen(null);
    }
    if (currentScreen != null) {
      leftClickCounter = 10000;
      mouseTicksRan = ticksRan + 10000;
    }
    if (currentScreen != null) {
      currentScreen.handleInput();
      if (currentScreen != null) {
        currentScreen.field_25091_h.func_25088_a();
        currentScreen.updateScreen();
      }
    }
    if (currentScreen == null || currentScreen.field_948_f) {
      do {
        if (!Mouse.next()) {
          break;
        }
        long l = System.currentTimeMillis() - systemTime;
        if (l <= 200L) {
          int k = Mouse.getEventDWheel();
          if (k != 0) {
            thePlayer.inventory.changeCurrentItem(k);
            if (gameSettings.field_22275_C) {
              if (k > 0) {
                k = 1;
              }
              if (k < 0) {
                k = -1;
              }
              gameSettings.field_22272_F += (float) k * 0.25F;
            }
          }
          if (currentScreen == null) {
            if (!inGameHasFocus && Mouse.getEventButtonState()) {
              setIngameFocus();
            } else {
              if (Mouse.getEventButton() == 0 && Mouse.getEventButtonState()) {
                clickMouse(0);
                mouseTicksRan = ticksRan;
              }
              if (Mouse.getEventButton() == 1 && Mouse.getEventButtonState()) {
                clickMouse(1);
                mouseTicksRan = ticksRan;
              }
              if (Mouse.getEventButton() == 2 && Mouse.getEventButtonState()) {
                clickMiddleMouseButton();
              }
            }
          } else if (currentScreen != null) {
            currentScreen.handleMouseInput();
          }
        }
      } while (true);
      if (leftClickCounter > 0) {
        leftClickCounter--;
      }
      do {
        if (!Keyboard.next()) {
          break;
        }
        thePlayer.handleKeyPress(Keyboard.getEventKey(), Keyboard.getEventKeyState());
        if (Keyboard.getEventKeyState()) {
          if (Keyboard.getEventKey() == 87) {
            toggleFullscreen();
          } else {
            if (currentScreen != null) {
              currentScreen.handleKeyboardInput();
            } else {
              if (Keyboard.getEventKey() == 1) {
                displayInGameMenu();
              }
              if (Keyboard.getEventKey() == 31 && Keyboard.isKeyDown(61)) {
                forceReload();
              }
              if (Keyboard.getEventKey() == 59) {
                gameSettings.hideGUI = !gameSettings.hideGUI;
              }
              if (Keyboard.getEventKey() == 61) {
                gameSettings.showDebugInfo = !gameSettings.showDebugInfo;
              }
              if (Keyboard.getEventKey() == 63) {
                gameSettings.thirdPersonView = !gameSettings.thirdPersonView;
              }
              if (Keyboard.getEventKey() == 66) {
                gameSettings.smoothCamera = !gameSettings.smoothCamera;
              }
              if (Keyboard.getEventKey() == gameSettings.keyBindInventory.keyCode) {
                displayGuiScreen(new GuiInventory(thePlayer));
              }
              if (Keyboard.getEventKey() == gameSettings.keyBindDrop.keyCode) {
                thePlayer.dropCurrentItem();
              }
              if (isMultiplayerWorld()
                  && Keyboard.getEventKey() == gameSettings.keyBindChat.keyCode) {
                displayGuiScreen(new GuiChat());
              }
            }
            for (int i = 0; i < 9; i++) {
              if (Keyboard.getEventKey() == 2 + i) {
                thePlayer.inventory.currentItem = i;
              }
            }

            if (Keyboard.getEventKey() == gameSettings.keyBindToggleFog.keyCode) {
              gameSettings.setOptionValue(
                  EnumOptions.RENDER_DISTANCE,
                  !Keyboard.isKeyDown(42) && !Keyboard.isKeyDown(54) ? 1 : -1);
            }
          }
        }
      } while (true);
      if (currentScreen == null) {
        if (Mouse.isButtonDown(0)
            && (float) (ticksRan - mouseTicksRan) >= timer.ticksPerSecond / 4F
            && inGameHasFocus) {
          clickMouse(0);
          mouseTicksRan = ticksRan;
        }
        if (Mouse.isButtonDown(1)
            && (float) (ticksRan - mouseTicksRan) >= timer.ticksPerSecond / 4F
            && inGameHasFocus) {
          clickMouse(1);
          mouseTicksRan = ticksRan;
        }
      }
      func_6254_a(0, currentScreen == null && Mouse.isButtonDown(0) && inGameHasFocus);
    }
    if (theWorld != null) {
      if (thePlayer != null) {
        joinPlayerCounter++;
        if (joinPlayerCounter == 30) {
          joinPlayerCounter = 0;
          theWorld.joinEntityInSurroundings(thePlayer);
        }
      }
      theWorld.difficultySetting = gameSettings.difficulty;
      if (theWorld.multiplayerWorld) {
        theWorld.difficultySetting = 3;
      }
      if (!isGamePaused) {
        entityRenderer.updateRenderer();
      }
      if (!isGamePaused) {
        renderGlobal.updateClouds();
      }
      if (!isGamePaused) {
        if (theWorld.field_27172_i > 0) {
          theWorld.field_27172_i--;
        }
        theWorld.updateEntities();
      }
      if (!isGamePaused || isMultiplayerWorld()) {
        theWorld.setAllowedMobSpawns(gameSettings.difficulty > 0, true);
        theWorld.tick();
      }
      if (!isGamePaused && theWorld != null) {
        theWorld.randomDisplayUpdates(
            MathHelper.floor_double(thePlayer.posX),
            MathHelper.floor_double(thePlayer.posY),
            MathHelper.floor_double(thePlayer.posZ));
      }
      if (!isGamePaused) {
        effectRenderer.updateEffects();
      }
    }
    systemTime = System.currentTimeMillis();
  }
Example #9
0
 public void changeWorld(World world, String s, EntityPlayer entityplayer) {
   statFileWriter.func_27175_b();
   statFileWriter.syncStats();
   renderViewEntity = null;
   loadingScreen.printText(s);
   loadingScreen.displayLoadingString("");
   sndManager.playStreaming(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
   if (theWorld != null) {
     theWorld.saveWorldIndirectly(loadingScreen);
   }
   theWorld = world;
   if (world != null) {
     playerController.func_717_a(world);
     if (!isMultiplayerWorld()) {
       if (entityplayer == null) {
         thePlayer = (EntityPlayerSP) world.func_4085_a(net.minecraft.src.EntityPlayerSP.class);
       }
     } else if (thePlayer != null) {
       thePlayer.preparePlayerToSpawn();
       if (world != null) {
         world.entityJoinedWorld(thePlayer);
       }
     }
     if (!world.multiplayerWorld) {
       func_6255_d(s);
     }
     if (thePlayer == null) {
       thePlayer = (EntityPlayerSP) playerController.createPlayer(world);
       thePlayer.preparePlayerToSpawn();
       playerController.flipPlayer(thePlayer);
     }
     thePlayer.movementInput = new MovementInputFromOptions(gameSettings);
     if (renderGlobal != null) {
       renderGlobal.changeWorld(world);
     }
     if (effectRenderer != null) {
       effectRenderer.clearEffects(world);
     }
     playerController.func_6473_b(thePlayer);
     if (entityplayer != null) {
       world.emptyMethod1();
     }
     net.minecraft.src.IChunkProvider ichunkprovider = world.getIChunkProvider();
     if (ichunkprovider instanceof ChunkProviderLoadOrGenerate) {
       ChunkProviderLoadOrGenerate chunkproviderloadorgenerate =
           (ChunkProviderLoadOrGenerate) ichunkprovider;
       int i = MathHelper.floor_float((int) thePlayer.posX) >> 4;
       int j = MathHelper.floor_float((int) thePlayer.posZ) >> 4;
       chunkproviderloadorgenerate.setCurrentChunkOver(i, j);
     }
     world.spawnPlayerWithLoadedChunks(thePlayer);
     if (world.isNewWorld) {
       world.saveWorldIndirectly(loadingScreen);
     }
     renderViewEntity = thePlayer;
   } else {
     thePlayer = null;
   }
   System.gc();
   systemTime = 0L;
 }