@Override
  public void processCommand(ICommandSender icommandsender, String[] astring) {
    GCEntityPlayerMP playerBase = null;

    if (astring.length < 2) {
      try {
        if (astring.length == 1) {
          playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(astring[0], true);
        } else {
          playerBase =
              PlayerUtil.getPlayerBaseServerFromPlayerUsername(
                  icommandsender.getCommandSenderName(), true);
        }

        if (playerBase != null) {
          playerBase.getPlayerStats().rocketStacks = new ItemStack[2];
          playerBase.getPlayerStats().rocketType = IRocketType.EnumRocketType.DEFAULT.ordinal();
          playerBase.getPlayerStats().rocketItem = GCItems.rocketTier1;
          playerBase.getPlayerStats().fuelLevel = 1000;

          HashMap<String, Integer> map =
              WorldUtil.getArrayOfPossibleDimensions(
                  WorldUtil.getPossibleDimensionsForSpaceshipTier(Integer.MAX_VALUE), playerBase);

          String temp = "";
          int count = 0;

          for (Entry<String, Integer> entry : map.entrySet()) {
            temp = temp.concat(entry.getKey() + (count < map.entrySet().size() - 1 ? "?" : ""));
            count++;
          }

          GalacticraftCore.packetPipeline.sendTo(
              new PacketSimple(
                  EnumSimplePacket.C_UPDATE_DIMENSION_LIST,
                  new Object[] {playerBase.getGameProfile().getName(), temp}),
              playerBase);
          playerBase.getPlayerStats().spaceshipTier = Integer.MAX_VALUE;
          playerBase.getPlayerStats().usingPlanetSelectionGui = true;
          playerBase.mountEntity(null);

          VersionUtil.notifyAdmins(
              icommandsender,
              this,
              "commands.dimensionteleport",
              new Object[] {
                String.valueOf(EnumColor.GREY + "[" + playerBase.getCommandSenderName()), "]"
              });
        } else {
          throw new Exception("Could not find player with name: " + astring[0]);
        }
      } catch (final Exception var6) {
        throw new CommandException(var6.getMessage(), new Object[0]);
      }
    } else {
      throw new WrongUsageException(
          "Not enough command arguments! Usage: " + this.getCommandUsage(icommandsender),
          new Object[0]);
    }
  }
  @Override
  public void onTeleport(EntityPlayerMP player) {
    final GCCorePlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player);

    player.playerNetServerHandler.sendPacketToPlayer(
        PacketUtil.createPacket(GalacticraftCore.CHANNEL, 22, new Object[] {0}));

    if (playerBase != null) {
      if (this.cargoItems == null || this.cargoItems.length == 0) {
        playerBase.setRocketStacks(new ItemStack[9]);
      } else {
        playerBase.setRocketStacks(this.cargoItems);
      }

      playerBase.setRocketType(this.rocketType.getIndex());
      int liquid =
          (int)
              Math.floor(
                  (this.spaceshipFuelTank.getFluid() == null
                          ? 0
                          : this.spaceshipFuelTank.getFluid().amount)
                      / 2.0D);
      playerBase.setFuelDamage(
          Math.max(
              Math.min(
                  GCCoreItems.fuelCanister.getMaxDamage() - liquid,
                  GCCoreItems.fuelCanister.getMaxDamage()),
              1));
    }
  }
Example #3
0
  public static EntityPlayerMP getPlayerBaseServerFromPlayer(
      EntityPlayer player, boolean ignoreCase) {
    if (player == null) {
      return null;
    }

    if (player instanceof EntityPlayerMP) {
      return (EntityPlayerMP) player;
    }

    return PlayerUtil.getPlayerBaseServerFromPlayerUsername(player.getName(), ignoreCase);
  }
  @Override
  public void processCommand(ICommandSender icommandsender, String[] astring) {
    String var3 = null;
    GCEntityPlayerMP playerBase = null;

    if (astring.length > 0) {
      var3 = astring[0];

      try {
        playerBase =
            PlayerUtil.getPlayerBaseServerFromPlayerUsername(
                icommandsender.getCommandSenderName(), false);

        if (playerBase != null) {
          if (playerBase.getSpaceStationDimensionID() <= 0) {
            throw new WrongUsageException(
                "Could not find space station for your username, you need to travel there first!",
                new Object[0]);
          } else {
            final SpaceStationWorldData data =
                SpaceStationWorldData.getStationData(
                    playerBase.worldObj, playerBase.getSpaceStationDimensionID(), playerBase);

            if (data.getAllowedPlayers().contains(var3.toLowerCase())) {
              data.getAllowedPlayers().remove(var3.toLowerCase());
              data.markDirty();
            } else {
              throw new CommandException(
                  "Couldn't find player with username \"" + var3 + "\" on your Space Station list!",
                  new Object[0]);
            }
          }
        }
      } catch (final Exception var6) {
        throw new CommandException(var6.getMessage(), new Object[0]);
      }

    } else {
      throw new WrongUsageException(
          "Not enough command arguments! Usage: " + this.getCommandUsage(icommandsender),
          new Object[0]);
    }

    if (playerBase != null) {
      playerBase.addChatMessage(
          new ChatComponentText("Successfully removed " + var3 + " from Space Station list!"));
    }
  }
  @Override
  public void onTeleport(EntityPlayerMP player) {
    final GCEntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);

    if (playerBase != null) {
      if (this.cargoItems == null || this.cargoItems.length == 0) {
        playerBase.getPlayerStats().rocketStacks = new ItemStack[2];
      } else {
        playerBase.getPlayerStats().rocketStacks = this.cargoItems;
        if ((this.cargoItems.length - 2) % 18 != 0) {
          System.out.println("Strange rocket inventory size " + this.cargoItems.length);
          int fail = 1 / 0;
        }
      }

      playerBase.getPlayerStats().rocketType = this.rocketType.getIndex();
      playerBase.getPlayerStats().rocketItem = GCItems.rocketTier1;
      playerBase.getPlayerStats().fuelLevel = this.fuelTank.getFluidAmount();
    }
  }
  public static void renderSensorGlassesValueableBlocks(
      ItemStack stack,
      EntityPlayer player,
      ScaledResolution resolution,
      float partialTicks,
      boolean hasScreen,
      int mouseX,
      int mouseY) {
    final Iterator<?> var51 = ClientProxyCore.valueableBlocks.iterator();
    double var52;
    double var58;
    double var59;
    double var20;
    double var21;
    float var60;

    while (var51.hasNext()) {
      final int[] coords = (int[]) var51.next();

      final int x = coords[0];
      final int y = coords[1];
      final int z = coords[2];

      var52 = ClientProxyCore.playerPosX - x - 0.5D;
      var58 = ClientProxyCore.playerPosY - y - 0.5D;
      var59 = ClientProxyCore.playerPosZ - z - 0.5D;
      var60 = (float) Math.toDegrees(Math.atan2(var52, var59));
      var20 = Math.sqrt(var52 * var52 + var58 * var58 + var59 * var59) * 0.5D;
      var21 = Math.sqrt(var52 * var52 + var59 * var59) * 0.5D;

      final ScaledResolution var5 =
          new ScaledResolution(
              GCCoreOverlaySensorGlasses.minecraft.gameSettings,
              GCCoreOverlaySensorGlasses.minecraft.displayWidth,
              GCCoreOverlaySensorGlasses.minecraft.displayHeight);
      final int var6 = var5.getScaledWidth();
      final int var7 = var5.getScaledHeight();

      boolean var2 = false;

      final GCCorePlayerSP client =
          PlayerUtil.getPlayerBaseClientFromPlayer(GCCoreOverlaySensorGlasses.minecraft.thePlayer);

      if (client != null) {
        var2 = client.getUsingGoggles();
      }

      GCCoreOverlaySensorGlasses.minecraft.fontRenderer.drawString(
          StatCollector.translateToLocal("gui.sensor.advanced")
              + ": "
              + (var2
                  ? StatCollector.translateToLocal("gui.sensor.advancedon")
                  : StatCollector.translateToLocal("gui.sensor.advancedoff")),
          var6 / 2 - 50,
          4,
          0x03b88f);

      try {
        GL11.glPushMatrix();

        if (var20 < 4.0D) {
          GL11.glColor4f(
              0.0F,
              255F / 255F,
              198F / 255F,
              (float) Math.min(1.0D, Math.max(0.2D, (var20 - 1.0D) * 0.1D)));
          FMLClientHandler.instance()
              .getClient()
              .renderEngine
              .bindTexture(GCCoreOverlaySensorGlasses.indicatorTexture);
          GL11.glRotatef(-var60 - ClientProxyCore.playerRotationYaw + 180.0F, 0.0F, 0.0F, 1.0F);
          GL11.glTranslated(0.0D, var2 ? -var20 * 16 : -var21 * 16, 0.0D);
          GL11.glRotatef(-(-var60 - ClientProxyCore.playerRotationYaw + 180.0F), 0.0F, 0.0F, 1.0F);
          GCCoreOverlay.drawCenteringRectangle(var6 / 2, var7 / 2, 1.0D, 8.0D, 8.0D);
        }
      } finally {
        GL11.glPopMatrix();
      }
    }
  }
  @Override
  public void handleServerSide(EntityPlayer player) {
    GCEntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
    if (playerBase == null) {
      return;
    }

    switch (this.type) {
      case S_RESPAWN_PLAYER:
        playerBase.playerNetServerHandler.sendPacket(
            new S07PacketRespawn(
                player.dimension,
                player.worldObj.difficultySetting,
                player.worldObj.getWorldInfo().getTerrainType(),
                playerBase.theItemInWorldManager.getGameType()));
        break;
      case S_TELEPORT_ENTITY:
        try {
          final WorldProvider provider = WorldUtil.getProviderForName((String) this.data.get(0));
          final Integer dim = provider.dimensionId;
          GCLog.info(
              "Found matching world ("
                  + dim.toString()
                  + ") for name: "
                  + (String) this.data.get(0));

          if (playerBase.worldObj instanceof WorldServer) {
            final WorldServer world = (WorldServer) playerBase.worldObj;

            if (provider instanceof IOrbitDimension) {
              WorldUtil.transferEntityToDimension(playerBase, dim, world);
            } else {
              WorldUtil.transferEntityToDimension(playerBase, dim, world);
            }
          }

          playerBase.getPlayerStats().teleportCooldown = 300;
          GalacticraftCore.packetPipeline.sendTo(
              new PacketSimple(EnumSimplePacket.C_CLOSE_GUI, new Object[] {}), playerBase);
        } catch (final Exception e) {
          GCLog.severe(
              "Error occurred when attempting to transfer entity to dimension: "
                  + (String) this.data.get(0));
          e.printStackTrace();
        }
        break;
      case S_IGNITE_ROCKET:
        if (!player.worldObj.isRemote
            && !player.isDead
            && player.ridingEntity != null
            && !player.ridingEntity.isDead
            && player.ridingEntity instanceof EntityTieredRocket) {
          final EntityTieredRocket ship = (EntityTieredRocket) player.ridingEntity;

          if (!ship.landing) {
            if (ship.hasValidFuel()) {
              ItemStack stack2 = playerBase.getPlayerStats().extendedInventory.getStackInSlot(4);

              if (stack2 != null && stack2.getItem() instanceof ItemParaChute
                  || playerBase.getPlayerStats().launchAttempts > 0) {
                ship.igniteCheckingCooldown();
                playerBase.getPlayerStats().launchAttempts = 0;
              } else if (playerBase.getPlayerStats().chatCooldown == 0
                  && playerBase.getPlayerStats().launchAttempts == 0) {
                player.addChatMessage(
                    new ChatComponentText(GCCoreUtil.translate("gui.rocket.warning.noparachute")));
                playerBase.getPlayerStats().chatCooldown = 250;
                playerBase.getPlayerStats().launchAttempts = 1;
              }
            } else if (playerBase.getPlayerStats().chatCooldown == 0) {
              player.addChatMessage(
                  new ChatComponentText(GCCoreUtil.translate("gui.rocket.warning.nofuel")));
              playerBase.getPlayerStats().chatCooldown = 250;
            }
          }
        }
        break;
      case S_OPEN_SCHEMATIC_PAGE:
        if (player != null) {
          final ISchematicPage page =
              SchematicRegistry.getMatchingRecipeForID((Integer) this.data.get(0));

          player.openGui(
              GalacticraftCore.instance,
              page.getGuiID(),
              player.worldObj,
              (int) player.posX,
              (int) player.posY,
              (int) player.posZ);
        }
        break;
      case S_OPEN_FUEL_GUI:
        if (player.ridingEntity instanceof EntityBuggy) {
          GCCoreUtil.openBuggyInv(
              playerBase,
              (EntityBuggy) player.ridingEntity,
              ((EntityBuggy) player.ridingEntity).getType());
        } else if (player.ridingEntity instanceof EntitySpaceshipBase) {
          player.openGui(
              GalacticraftCore.instance,
              GuiIdsCore.ROCKET_INVENTORY,
              player.worldObj,
              (int) player.posX,
              (int) player.posY,
              (int) player.posZ);
        }
        break;
      case S_UPDATE_SHIP_YAW:
        if (player.ridingEntity instanceof EntitySpaceshipBase) {
          final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity;

          if (ship != null) {
            ship.rotationYaw = (Float) this.data.get(0);
          }
        }
        break;
      case S_UPDATE_SHIP_PITCH:
        if (player.ridingEntity instanceof EntitySpaceshipBase) {
          final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity;

          if (ship != null) {
            ship.rotationPitch = (Float) this.data.get(0);
          }
        }
        break;
      case S_SET_ENTITY_FIRE:
        Entity entity = player.worldObj.getEntityByID((Integer) this.data.get(0));

        if (entity instanceof EntityLiving) {
          ((EntityLiving) entity).setFire(3);
        }
        break;
      case S_OPEN_REFINERY_GUI:
        player.openGui(
            GalacticraftCore.instance,
            -1,
            player.worldObj,
            (Integer) this.data.get(0),
            (Integer) this.data.get(1),
            (Integer) this.data.get(2));
        break;
      case S_BIND_SPACE_STATION_ID:
        if ((playerBase.getPlayerStats().spaceStationDimensionID == -1
                || playerBase.getPlayerStats().spaceStationDimensionID == 0)
            && !ConfigManagerCore.disableSpaceStationCreation) {
          WorldUtil.bindSpaceStationToNewDimension(playerBase.worldObj, playerBase);

          WorldUtil.getSpaceStationRecipe((Integer) this.data.get(0)).matches(playerBase, true);
        }
        break;
      case S_UNLOCK_NEW_SCHEMATIC:
        final Container container = player.openContainer;

        if (container instanceof ContainerSchematic) {
          final ContainerSchematic schematicContainer = (ContainerSchematic) container;

          ItemStack stack = schematicContainer.craftMatrix.getStackInSlot(0);

          if (stack != null) {
            final ISchematicPage page = SchematicRegistry.getMatchingRecipeForItemStack(stack);

            if (page != null) {
              SchematicRegistry.unlockNewPage(playerBase, stack);

              if (--stack.stackSize <= 0) {
                stack = null;
              }

              schematicContainer.craftMatrix.setInventorySlotContents(0, stack);
              schematicContainer.craftMatrix.markDirty();

              GalacticraftCore.packetPipeline.sendTo(
                  new PacketSimple(
                      EnumSimplePacket.C_ADD_NEW_SCHEMATIC, new Object[] {page.getPageID()}),
                  playerBase);
            }
          }
        }
        break;
      case S_UPDATE_DISABLEABLE_BUTTON:
        final TileEntity tileAt =
            player.worldObj.getTileEntity(
                (Integer) this.data.get(0), (Integer) this.data.get(1), (Integer) this.data.get(2));

        if (tileAt instanceof IDisableableMachine) {
          final IDisableableMachine machine = (IDisableableMachine) tileAt;

          machine.setDisabled(
              (Integer) this.data.get(3), !machine.getDisabled((Integer) this.data.get(3)));
        }
        break;
      case S_ON_FAILED_CHEST_UNLOCK:
        if (playerBase.getPlayerStats().chatCooldown == 0) {
          player.addChatMessage(
              new ChatComponentText(
                  GCCoreUtil.translateWithFormat("gui.chest.warning.wrongkey", this.data.get(0))));
          playerBase.getPlayerStats().chatCooldown = 100;
        }
        break;
      case S_RENAME_SPACE_STATION:
        final SpaceStationWorldData ssdata =
            SpaceStationWorldData.getStationData(
                playerBase.worldObj, (Integer) this.data.get(1), playerBase);

        if (ssdata != null
            && ssdata.getOwner().equalsIgnoreCase(player.getGameProfile().getName())) {
          ssdata.setSpaceStationName((String) this.data.get(0));
          ssdata.setDirty(true);
        }
        break;
      case S_OPEN_EXTENDED_INVENTORY:
        player.openGui(
            GalacticraftCore.instance, GuiIdsCore.EXTENDED_INVENTORY, player.worldObj, 0, 0, 0);
        break;
      case S_ON_ADVANCED_GUI_CLICKED_INT:
        TileEntity tile1 =
            player.worldObj.getTileEntity(
                (Integer) this.data.get(1), (Integer) this.data.get(2), (Integer) this.data.get(3));

        switch ((Integer) this.data.get(0)) {
          case 0:
            if (tile1 instanceof TileEntityAirLockController) {
              TileEntityAirLockController launchController = (TileEntityAirLockController) tile1;
              launchController.redstoneActivation = (Integer) this.data.get(4) == 1;
            }
            break;
          case 1:
            if (tile1 instanceof TileEntityAirLockController) {
              TileEntityAirLockController launchController = (TileEntityAirLockController) tile1;
              launchController.playerDistanceActivation = (Integer) this.data.get(4) == 1;
            }
            break;
          case 2:
            if (tile1 instanceof TileEntityAirLockController) {
              TileEntityAirLockController launchController = (TileEntityAirLockController) tile1;
              launchController.playerDistanceSelection = (Integer) this.data.get(4);
            }
            break;
          case 3:
            if (tile1 instanceof TileEntityAirLockController) {
              TileEntityAirLockController launchController = (TileEntityAirLockController) tile1;
              launchController.playerNameMatches = (Integer) this.data.get(4) == 1;
            }
            break;
          case 4:
            if (tile1 instanceof TileEntityAirLockController) {
              TileEntityAirLockController launchController = (TileEntityAirLockController) tile1;
              launchController.invertSelection = (Integer) this.data.get(4) == 1;
            }
            break;
          case 5:
            if (tile1 instanceof TileEntityAirLockController) {
              TileEntityAirLockController launchController = (TileEntityAirLockController) tile1;
              launchController.lastHorizontalModeEnabled = launchController.horizontalModeEnabled;
              launchController.horizontalModeEnabled = (Integer) this.data.get(4) == 1;
            }
            break;
          case 6:
            if (tile1 instanceof IBubbleProvider) {
              IBubbleProvider distributor = (IBubbleProvider) tile1;
              distributor.setBubbleVisible((Integer) this.data.get(4) == 1);
            }
            break;
          default:
            break;
        }
        break;
      case S_ON_ADVANCED_GUI_CLICKED_STRING:
        TileEntity tile2 =
            player.worldObj.getTileEntity(
                (Integer) this.data.get(1), (Integer) this.data.get(2), (Integer) this.data.get(3));

        switch ((Integer) this.data.get(0)) {
          case 0:
            if (tile2 instanceof TileEntityAirLockController) {
              TileEntityAirLockController launchController = (TileEntityAirLockController) tile2;
              launchController.playerToOpenFor = (String) this.data.get(4);
            }
            break;
          default:
            break;
        }
        break;
      case S_UPDATE_SHIP_MOTION_Y:
        int entityID = (Integer) this.data.get(0);
        boolean up = (Boolean) this.data.get(1);

        Entity entity2 = player.worldObj.getEntityByID(entityID);

        if (entity2 instanceof EntityAutoRocket) {
          EntityAutoRocket autoRocket = (EntityAutoRocket) entity2;
          autoRocket.motionY += up ? 0.02F : -0.02F;
        }

        break;
      case S_START_NEW_SPACE_RACE:
        Integer teamID = (Integer) this.data.get(0);
        String teamName = (String) this.data.get(1);
        FlagData flagData = (FlagData) this.data.get(2);
        Vector3 teamColor = (Vector3) this.data.get(3);
        List<String> playerList = new ArrayList<String>();

        for (int i = 4; i < this.data.size(); i++) {
          playerList.add((String) this.data.get(i));
        }

        boolean previousData = SpaceRaceManager.getSpaceRaceFromID(teamID) != null;

        SpaceRace newRace = new SpaceRace(playerList, teamName, flagData, teamColor);

        if (teamID > 0) {
          newRace.setSpaceRaceID(teamID);
        }

        SpaceRaceManager.addSpaceRace(newRace);

        if (previousData) {
          SpaceRaceManager.sendSpaceRaceData(
              null, SpaceRaceManager.getSpaceRaceFromPlayer(playerBase.getGameProfile().getName()));
        }
        break;
      case S_REQUEST_FLAG_DATA:
        SpaceRaceManager.sendSpaceRaceData(
            playerBase, SpaceRaceManager.getSpaceRaceFromPlayer((String) this.data.get(0)));
        break;
      case S_INVITE_RACE_PLAYER:
        GCEntityPlayerMP playerInvited =
            PlayerUtil.getPlayerBaseServerFromPlayerUsername((String) this.data.get(0), true);
        if (playerInvited != null) {
          Integer teamInvitedTo = (Integer) this.data.get(1);
          SpaceRace race = SpaceRaceManager.getSpaceRaceFromID(teamInvitedTo);

          if (race != null) {
            playerInvited.getPlayerStats().spaceRaceInviteTeamID = teamInvitedTo;
            String dA = EnumColor.DARK_AQUA.code;
            String bG = EnumColor.BRIGHT_GREEN.code;
            String dB = EnumColor.PURPLE.code;
            String teamNameTotal = "";
            String[] teamNameSplit = race.getTeamName().split(" ");
            for (String teamNamePart : teamNameSplit) {
              teamNameTotal = teamNameTotal.concat(dB + teamNamePart + " ");
            }
            playerInvited.addChatMessage(
                new ChatComponentText(
                        "Received Space Race Team Invite from "
                            + bG
                            + player.getGameProfile().getName()
                            + dA
                            + ". To join "
                            + teamNameTotal
                            + dA
                            + "use command "
                            + EnumColor.AQUA
                            + "/joinrace")
                    .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA)));
          }
        }
        break;
      case S_REMOVE_RACE_PLAYER:
        Integer teamInvitedTo = (Integer) this.data.get(1);
        SpaceRace race = SpaceRaceManager.getSpaceRaceFromID(teamInvitedTo);

        if (race != null) {
          String playerToRemove = (String) this.data.get(0);

          if (!race.getPlayerNames().remove(playerToRemove)) {
            player.addChatMessage(
                new ChatComponentText("Could not find player with name: " + playerToRemove));
          } else {
            SpaceRaceManager.onPlayerRemoval(playerToRemove, race);
          }
        }
        break;
      case S_ADD_RACE_PLAYER:
        Integer teamToAddPlayer = (Integer) this.data.get(1);
        SpaceRace spaceRaceToAddPlayer = SpaceRaceManager.getSpaceRaceFromID(teamToAddPlayer);

        if (spaceRaceToAddPlayer != null) {
          String playerToAdd = (String) this.data.get(0);

          if (!spaceRaceToAddPlayer.getPlayerNames().contains(playerToAdd)) {
            SpaceRace oldRace = null;
            while ((oldRace = SpaceRaceManager.getSpaceRaceFromPlayer(playerToAdd)) != null) {
              SpaceRaceManager.removeSpaceRace(oldRace);
            }

            spaceRaceToAddPlayer.getPlayerNames().add(playerToAdd);
            SpaceRaceManager.sendSpaceRaceData(null, spaceRaceToAddPlayer);

            for (String member : spaceRaceToAddPlayer.getPlayerNames()) {
              EntityPlayerMP memberObj =
                  MinecraftServer.getServer()
                      .getConfigurationManager()
                      .getPlayerForUsername(member);

              if (memberObj != null) {
                memberObj.addChatMessage(
                    new ChatComponentText(
                            EnumColor.BRIGHT_GREEN
                                + playerToAdd
                                + EnumColor.DARK_AQUA
                                + " has joined the Space Race!")
                        .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA)));
              }
            }
          } else {
            player.addChatMessage(
                new ChatComponentText("You are already a part of this space race!")
                    .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED)));
          }
        }
        break;
      default:
        break;
    }
  }
  @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();
      }
    }
  }