@Override
  public void tickEnd(EnumSet<TickType> type, Object... tickData) {
    final Minecraft minecraft = FMLClientHandler.instance().getClient();

    final EntityPlayerSP player = minecraft.thePlayer;

    final GCCorePlayerSP playerBaseClient = PlayerUtil.getPlayerBaseClientFromPlayer(player);

    if (player != null && player.inventory.armorItemInSlot(3) != null) {
      player.inventory.armorItemInSlot(3);
    }

    if (type.equals(EnumSet.of(TickType.CLIENT))) {
      boolean invKeyPressed = Keyboard.isKeyDown(minecraft.gameSettings.keyBindInventory.keyCode);

      if (!GCCoreTickHandlerClient.lastInvKeyPressed
          && invKeyPressed
          && minecraft.currentScreen != null
          && minecraft.currentScreen.getClass() == GuiInventory.class) {
        GCCoreTickHandlerClient.addTabsToInventory((GuiContainer) minecraft.currentScreen);
      }

      GCCoreTickHandlerClient.lastInvKeyPressed = invKeyPressed;
    } else if (type.equals(EnumSet.of(TickType.RENDER))) {
      final float partialTickTime = (Float) tickData[0];

      if (player != null) {
        ClientProxyCore.playerPosX =
            player.prevPosX + (player.posX - player.prevPosX) * partialTickTime;
        ClientProxyCore.playerPosY =
            player.prevPosY + (player.posY - player.prevPosY) * partialTickTime;
        ClientProxyCore.playerPosZ =
            player.prevPosZ + (player.posZ - player.prevPosZ) * partialTickTime;
        ClientProxyCore.playerRotationYaw =
            player.prevRotationYaw
                + (player.rotationYaw - player.prevRotationYaw) * partialTickTime;
        ClientProxyCore.playerRotationPitch =
            player.prevRotationPitch
                + (player.rotationPitch - player.prevRotationPitch) * partialTickTime;
      }

      if (player != null
          && player.ridingEntity != null
          && player.ridingEntity instanceof GCCoreEntityRocketT1) {
        float f = (((GCCoreEntityRocketT1) player.ridingEntity).timeSinceLaunch - 250F) / 175F;

        if (f < 0) {
          f = 0F;
        }

        if (f > 1) {
          f = 1F;
        }

        final ScaledResolution scaledresolution =
            new ScaledResolution(
                minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight);
        scaledresolution.getScaledWidth();
        scaledresolution.getScaledHeight();
        minecraft.entityRenderer.setupOverlayRendering();
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDepthMask(false);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, f);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      }

      if (minecraft.currentScreen == null
          && player != null
          && player.ridingEntity != null
          && player.ridingEntity instanceof EntitySpaceshipBase
          && minecraft.gameSettings.thirdPersonView != 0
          && !minecraft.gameSettings.hideGUI) {
        GCCoreOverlaySpaceship.renderSpaceshipOverlay(
            ((EntitySpaceshipBase) player.ridingEntity).getSpaceshipGui());
      }

      if (minecraft.currentScreen == null
          && player != null
          && player.ridingEntity != null
          && player.ridingEntity instanceof GCCoreEntityLander
          && minecraft.gameSettings.thirdPersonView != 0
          && !minecraft.gameSettings.hideGUI) {
        GCCoreOverlayLander.renderLanderOverlay();
      }

      if (minecraft.currentScreen == null
          && player != null
          && player.ridingEntity != null
          && player.ridingEntity instanceof EntityAutoRocket
          && minecraft.gameSettings.thirdPersonView != 0
          && !minecraft.gameSettings.hideGUI) {
        GCCoreOverlayDockingRocket.renderDockingOverlay();
      }

      if (minecraft.currentScreen == null
          && player != null
          && player.ridingEntity != null
          && player.ridingEntity instanceof EntitySpaceshipBase
          && minecraft.gameSettings.thirdPersonView != 0
          && !minecraft.gameSettings.hideGUI
          && ((EntitySpaceshipBase) minecraft.thePlayer.ridingEntity).launchPhase
              != EnumLaunchPhase.LAUNCHED.getPhase()) {
        GCCoreOverlayCountdown.renderCountdownOverlay();
      }

      if (player != null
          && player.worldObj.provider instanceof IGalacticraftWorldProvider
          && OxygenUtil.shouldDisplayTankGui(minecraft.currentScreen)) {
        int var6 = (GCCoreTickHandlerClient.airRemaining - 90) * -1;

        if (GCCoreTickHandlerClient.airRemaining <= 0) {
          var6 = 90;
        }

        int var7 = (GCCoreTickHandlerClient.airRemaining2 - 90) * -1;

        if (GCCoreTickHandlerClient.airRemaining2 <= 0) {
          var7 = 90;
        }

        GCCoreOverlayOxygenTankIndicator.renderOxygenTankIndicator(
            var6,
            var7,
            !GCCoreConfigManager.oxygenIndicatorLeft,
            !GCCoreConfigManager.oxygenIndicatorBottom);
      }

      if (playerBaseClient != null
          && player.worldObj.provider instanceof IGalacticraftWorldProvider
          && !playerBaseClient.oxygenSetupValid
          && minecraft.currentScreen == null
          && !playerBaseClient.capabilities.isCreativeMode) {
        GCCoreOverlayOxygenWarning.renderOxygenWarningOverlay();
      }
    }
  }
  @Override
  public void tickStart(EnumSet<TickType> type, Object... tickData) {
    final Minecraft minecraft = FMLClientHandler.instance().getClient();

    final WorldClient world = minecraft.theWorld;

    final EntityClientPlayerMP player = minecraft.thePlayer;

    if (type.equals(EnumSet.of(TickType.CLIENT))) {
      if (GCCoreTickHandlerClient.tickCount >= Long.MAX_VALUE) {
        GCCoreTickHandlerClient.tickCount = 0;
      }

      GCCoreTickHandlerClient.tickCount++;

      if (GCCoreTickHandlerClient.tickCount % 20 == 0) {
        if (player != null
            && player.inventory.armorItemInSlot(3) != null
            && player.inventory.armorItemInSlot(3).getItem() instanceof GCCoreItemSensorGlasses) {
          ClientProxyCore.valueableBlocks.clear();

          for (int i = -4; i < 5; i++) {
            for (int j = -4; j < 5; j++) {
              for (int k = -4; k < 5; k++) {
                int x = MathHelper.floor_double(player.posX + i);
                int y = MathHelper.floor_double(player.posY + j);
                int z = MathHelper.floor_double(player.posZ + k);

                final int id = player.worldObj.getBlockId(x, y, z);

                if (id != 0) {
                  final Block block = Block.blocksList[id];
                  int metadata = world.getBlockMetadata(x, y, z);
                  boolean isDetectable = false;

                  for (BlockMetaList blockMetaList : ClientProxyCore.detectableBlocks) {
                    if (blockMetaList.getBlockID() == id
                        && blockMetaList.getMetaList().contains(metadata)) {
                      isDetectable = true;
                      break;
                    }
                  }

                  if (isDetectable) {
                    if (!this.alreadyContainsBlock(x, y, z)) {
                      ClientProxyCore.valueableBlocks.add(new Vector3(x, y, z));
                    }
                  } else if (block instanceof IDetectableResource
                      && ((IDetectableResource) block).isValueable(metadata)) {
                    if (!this.alreadyContainsBlock(x, y, z)) {
                      ClientProxyCore.valueableBlocks.add(new Vector3(x, y, z));
                    }

                    List<Integer> metaList = Lists.newArrayList();
                    metaList.add(metadata);

                    for (BlockMetaList blockMetaList : ClientProxyCore.detectableBlocks) {
                      if (blockMetaList.getBlockID() == id) {
                        metaList.addAll(blockMetaList.getMetaList());
                        break;
                      }
                    }

                    ClientProxyCore.detectableBlocks.add(new BlockMetaList(id, metaList));
                  }
                }
              }
            }
          }
        }
      }

      if (GCCoreTickHandlerClient.addTabsNextTick) {
        if (minecraft.currentScreen.getClass().equals(GuiInventory.class)) {
          GCCoreTickHandlerClient.addTabsToInventory((GuiContainer) minecraft.currentScreen);
        }

        GCCoreTickHandlerClient.addTabsNextTick = false;
      }

      if (minecraft.currentScreen != null && minecraft.currentScreen instanceof GuiMainMenu) {
        GalacticraftCore.playersServer.clear();
        GalacticraftCore.playersClient.clear();
        ClientProxyCore.playerItemData.clear();

        if (GCCoreTickHandlerClient.missingRequirementThread == null) {
          GCCoreTickHandlerClient.missingRequirementThread =
              new GCCoreThreadRequirementMissing(FMLCommonHandler.instance().getEffectiveSide());
          GCCoreTickHandlerClient.missingRequirementThread.start();
        }
      }

      if (world != null && GCCoreTickHandlerClient.checkedVersion) {
        GCCoreUtil.checkVersion(Side.CLIENT);
        GCCoreTickHandlerClient.checkedVersion = false;
      }

      if (player != null
          && player.ridingEntity != null
          && player.ridingEntity instanceof EntitySpaceshipBase) {
        final Object[] toSend = {player.ridingEntity.rotationPitch};
        PacketDispatcher.sendPacketToServer(
            PacketUtil.createPacket(
                GalacticraftCore.CHANNEL, EnumPacketServer.UPDATE_SHIP_PITCH, toSend));
        final Object[] toSend2 = {player.ridingEntity.rotationYaw};
        PacketDispatcher.sendPacketToServer(
            PacketUtil.createPacket(
                GalacticraftCore.CHANNEL, EnumPacketServer.UPDATE_SHIP_YAW, toSend2));
      }

      if (world != null && world.provider instanceof WorldProviderSurface) {
        if (world.provider.getSkyRenderer() == null
            && player.ridingEntity != null
            && player.ridingEntity.posY >= 200) {
          world.provider.setSkyRenderer(new GCCoreSkyProviderOverworld());
        } else if (world.provider.getSkyRenderer() != null
            && world.provider.getSkyRenderer() instanceof GCCoreSkyProviderOverworld
            && (player.ridingEntity == null || player.ridingEntity.posY < 200)) {
          world.provider.setSkyRenderer(null);
        }
      }

      if (world != null && world.provider instanceof GCCoreWorldProviderSpaceStation) {
        if (world.provider.getSkyRenderer() == null) {
          world.provider.setSkyRenderer(
              new GCCoreSkyProviderOrbit(
                  new ResourceLocation(
                      GalacticraftCore.ASSET_DOMAIN, "textures/gui/planets/overworld.png"),
                  true,
                  true));
        }

        if (world.provider.getCloudRenderer() == null) {
          world.provider.setCloudRenderer(new GCCoreCloudRenderer());
        }
      }

      if (player != null
          && player.ridingEntity != null
          && player.ridingEntity instanceof EntitySpaceshipBase) {
        final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity;

        if (minecraft.gameSettings.keyBindLeft.pressed) {
          ship.turnYaw(-1.0F);
          final Object[] toSend = {ship.rotationYaw};
          PacketDispatcher.sendPacketToServer(
              PacketUtil.createPacket(
                  GalacticraftCore.CHANNEL, EnumPacketServer.UPDATE_SHIP_YAW, toSend));
        }

        if (minecraft.gameSettings.keyBindRight.pressed) {
          ship.turnYaw(1.0F);
          final Object[] toSend = {ship.rotationYaw};
          PacketDispatcher.sendPacketToServer(
              PacketUtil.createPacket(
                  GalacticraftCore.CHANNEL, EnumPacketServer.UPDATE_SHIP_YAW, toSend));
        }

        if (minecraft.gameSettings.keyBindForward.pressed) {
          if (ship.getLaunched()) {
            ship.turnPitch(-0.7F);
            final Object[] toSend = {ship.rotationPitch};
            PacketDispatcher.sendPacketToServer(
                PacketUtil.createPacket(
                    GalacticraftCore.CHANNEL, EnumPacketServer.UPDATE_SHIP_PITCH, toSend));
          }
        }

        if (minecraft.gameSettings.keyBindBack.pressed) {
          if (ship.getLaunched()) {
            ship.turnPitch(0.7F);
            final Object[] toSend = {ship.rotationPitch};
            PacketDispatcher.sendPacketToServer(
                PacketUtil.createPacket(
                    GalacticraftCore.CHANNEL, EnumPacketServer.UPDATE_SHIP_PITCH, toSend));
          }
        }
      }

      if (world != null) {
        for (int i = 0; i < world.loadedEntityList.size(); i++) {
          final Entity e = (Entity) world.loadedEntityList.get(i);

          if (e != null) {
            if (e instanceof GCCoreEntityRocketT1) {
              final GCCoreEntityRocketT1 eship = (GCCoreEntityRocketT1) e;

              if (eship.rocketSoundUpdater == null) {
                eship.rocketSoundUpdater =
                    new GCCoreSoundUpdaterSpaceship(
                        FMLClientHandler.instance().getClient().sndManager,
                        eship,
                        FMLClientHandler.instance().getClient().thePlayer);
              }
            }
          }
        }
      }

      if (FMLClientHandler.instance().getClient().currentScreen instanceof GCCoreGuiChoosePlanet) {
        player.motionY = 0;
      }

      if (world != null && world.provider instanceof IGalacticraftWorldProvider) {
        world.setRainStrength(0.0F);
      }

      if (!minecraft.gameSettings.keyBindJump.pressed) {
        ClientProxyCore.lastSpacebarDown = false;
      }

      if (player != null
          && player.ridingEntity != null
          && minecraft.gameSettings.keyBindJump.pressed
          && !ClientProxyCore.lastSpacebarDown) {
        final Object[] toSend = {0};
        PacketDispatcher.sendPacketToServer(
            PacketUtil.createPacket(
                GalacticraftCore.CHANNEL, EnumPacketServer.IGNITE_ROCKET, toSend));
        ClientProxyCore.lastSpacebarDown = true;
      }
    }
  }