use of micdoodle8.mods.galacticraft.api.galaxies.Satellite in project Galacticraft by micdoodle8.
the class PacketSimple method handleClientSide.
@SideOnly(Side.CLIENT)
@Override
public void handleClientSide(EntityPlayer player) {
EntityPlayerSP playerBaseClient = null;
GCPlayerStatsClient stats = null;
if (player instanceof EntityPlayerSP) {
playerBaseClient = (EntityPlayerSP) player;
stats = GCPlayerStatsClient.get(playerBaseClient);
} else {
if (type != EnumSimplePacket.C_UPDATE_SPACESTATION_LIST && type != EnumSimplePacket.C_UPDATE_PLANETS_LIST && type != EnumSimplePacket.C_UPDATE_CONFIGS) {
return;
}
}
switch(this.type) {
case C_AIR_REMAINING:
if (String.valueOf(this.data.get(2)).equals(String.valueOf(PlayerUtil.getName(player)))) {
TickHandlerClient.airRemaining = (Integer) this.data.get(0);
TickHandlerClient.airRemaining2 = (Integer) this.data.get(1);
}
break;
case C_UPDATE_DIMENSION_LIST:
if (String.valueOf(this.data.get(0)).equals(PlayerUtil.getName(player))) {
String dimensionList = (String) this.data.get(1);
if (ConfigManagerCore.enableDebug) {
if (!dimensionList.equals(PacketSimple.spamCheckString)) {
GCLog.info("DEBUG info: " + dimensionList);
PacketSimple.spamCheckString = dimensionList;
}
}
final String[] destinations = dimensionList.split("\\?");
List<CelestialBody> possibleCelestialBodies = Lists.newArrayList();
Map<Integer, Map<String, GuiCelestialSelection.StationDataGUI>> spaceStationData = Maps.newHashMap();
for (String str : destinations) {
CelestialBody celestialBody = WorldUtil.getReachableCelestialBodiesForName(str);
if (celestialBody == null && str.contains("$")) {
String[] values = str.split("\\$");
int homePlanetID = Integer.parseInt(values[4]);
for (Satellite satellite : GalaxyRegistry.getRegisteredSatellites().values()) {
if (satellite.getParentPlanet().getDimensionID() == homePlanetID) {
celestialBody = satellite;
break;
}
}
if (!spaceStationData.containsKey(homePlanetID)) {
spaceStationData.put(homePlanetID, new HashMap<String, GuiCelestialSelection.StationDataGUI>());
}
spaceStationData.get(homePlanetID).put(values[1], new GuiCelestialSelection.StationDataGUI(values[2], Integer.parseInt(values[3])));
// spaceStationNames.put(values[1], values[2]);
// spaceStationIDs.put(values[1], Integer.parseInt(values[3]));
// spaceStationHomes.put(values[1], Integer.parseInt(values[4]));
}
if (celestialBody != null) {
possibleCelestialBodies.add(celestialBody);
}
}
if (FMLClientHandler.instance().getClient().theWorld != null) {
if (!(FMLClientHandler.instance().getClient().currentScreen instanceof GuiCelestialSelection)) {
GuiCelestialSelection gui = new GuiCelestialSelection(false, possibleCelestialBodies);
gui.spaceStationMap = spaceStationData;
// gui.spaceStationNames = spaceStationNames;
// gui.spaceStationIDs = spaceStationIDs;
FMLClientHandler.instance().getClient().displayGuiScreen(gui);
} else {
((GuiCelestialSelection) FMLClientHandler.instance().getClient().currentScreen).possibleBodies = possibleCelestialBodies;
((GuiCelestialSelection) FMLClientHandler.instance().getClient().currentScreen).spaceStationMap = spaceStationData;
// ((GuiCelestialSelection) FMLClientHandler.instance().getClient().currentScreen).spaceStationNames = spaceStationNames;
// ((GuiCelestialSelection) FMLClientHandler.instance().getClient().currentScreen).spaceStationIDs = spaceStationIDs;
}
}
}
break;
case C_SPAWN_SPARK_PARTICLES:
BlockPos pos = (BlockPos) this.data.get(0);
Minecraft mc = Minecraft.getMinecraft();
for (int i = 0; i < 4; i++) {
if (mc != null && mc.getRenderViewEntity() != null && mc.effectRenderer != null && mc.theWorld != null) {
final EntityFX fx = new EntityFXSparks(mc.theWorld, pos.getX() - 0.15 + 0.5, pos.getY() + 1.2, pos.getZ() + 0.15 + 0.5, mc.theWorld.rand.nextDouble() / 20 - mc.theWorld.rand.nextDouble() / 20, mc.theWorld.rand.nextDouble() / 20 - mc.theWorld.rand.nextDouble() / 20);
if (fx != null) {
mc.effectRenderer.addEffect(fx);
}
}
}
break;
case C_UPDATE_GEAR_SLOT:
int subtype = (Integer) this.data.get(3);
String gearName = (String) this.data.get(0);
EntityPlayer gearDataPlayer = player.worldObj.getPlayerEntityByName(gearName);
if (gearDataPlayer != null) {
PlayerGearData gearData = ClientProxyCore.playerItemData.get(PlayerUtil.getName(gearDataPlayer));
if (gearData == null) {
gearData = new PlayerGearData(player);
if (!ClientProxyCore.gearDataRequests.contains(gearName)) {
GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(PacketSimple.EnumSimplePacket.S_REQUEST_GEAR_DATA, getDimensionID(), new Object[] { gearName }));
ClientProxyCore.gearDataRequests.add(gearName);
}
} else {
ClientProxyCore.gearDataRequests.remove(gearName);
}
EnumExtendedInventorySlot type = EnumExtendedInventorySlot.values()[(Integer) this.data.get(2)];
EnumModelPacketType typeChange = EnumModelPacketType.values()[(Integer) this.data.get(1)];
switch(type) {
case MASK:
gearData.setMask(subtype);
break;
case GEAR:
gearData.setGear(subtype);
break;
case LEFT_TANK:
gearData.setLeftTank(subtype);
break;
case RIGHT_TANK:
gearData.setRightTank(subtype);
break;
case PARACHUTE:
if (typeChange == EnumModelPacketType.ADD) {
String name;
if (subtype != -1) {
name = ItemParaChute.names[subtype];
gearData.setParachute(new ResourceLocation(Constants.ASSET_PREFIX, "textures/model/parachute/" + name + ".png"));
}
} else {
gearData.setParachute(null);
}
break;
case FREQUENCY_MODULE:
gearData.setFrequencyModule(subtype);
break;
case THERMAL_HELMET:
gearData.setThermalPadding(0, subtype);
break;
case THERMAL_CHESTPLATE:
gearData.setThermalPadding(1, subtype);
break;
case THERMAL_LEGGINGS:
gearData.setThermalPadding(2, subtype);
break;
case THERMAL_BOOTS:
gearData.setThermalPadding(3, subtype);
break;
case SHIELD_CONTROLLER:
gearData.setShieldController(subtype);
break;
default:
break;
}
ClientProxyCore.playerItemData.put(gearName, gearData);
}
break;
case C_CLOSE_GUI:
FMLClientHandler.instance().getClient().displayGuiScreen(null);
break;
case C_RESET_THIRD_PERSON:
FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = stats.getThirdPersonView();
break;
case C_UPDATE_SPACESTATION_LIST:
WorldUtil.decodeSpaceStationListClient(data);
break;
case C_UPDATE_SPACESTATION_DATA:
SpaceStationWorldData var4 = SpaceStationWorldData.getMPSpaceStationData(player.worldObj, (Integer) this.data.get(0), player);
var4.readFromNBT((NBTTagCompound) this.data.get(1));
break;
case C_UPDATE_SPACESTATION_CLIENT_ID:
ClientProxyCore.clientSpaceStationID = WorldUtil.stringToSpaceStationData((String) this.data.get(0));
break;
case C_UPDATE_PLANETS_LIST:
WorldUtil.decodePlanetsListClient(data);
break;
case C_UPDATE_CONFIGS:
ConfigManagerCore.saveClientConfigOverrideable();
ConfigManagerCore.setConfigOverride(data);
break;
case C_ADD_NEW_SCHEMATIC:
final ISchematicPage page = SchematicRegistry.getMatchingRecipeForID((Integer) this.data.get(0));
if (!stats.getUnlockedSchematics().contains(page)) {
stats.getUnlockedSchematics().add(page);
}
break;
case C_UPDATE_SCHEMATIC_LIST:
for (Object o : this.data) {
Integer schematicID = (Integer) o;
if (schematicID != -2) {
Collections.sort(stats.getUnlockedSchematics());
if (!stats.getUnlockedSchematics().contains(SchematicRegistry.getMatchingRecipeForID(schematicID))) {
stats.getUnlockedSchematics().add(SchematicRegistry.getMatchingRecipeForID(schematicID));
}
}
}
break;
case C_PLAY_SOUND_BOSS_DEATH:
player.playSound(Constants.TEXTURE_PREFIX + "entity.bossdeath", 10.0F, (Float) this.data.get(0));
break;
case C_PLAY_SOUND_EXPLODE:
player.playSound("random.explode", 10.0F, 0.7F);
break;
case C_PLAY_SOUND_BOSS_LAUGH:
player.playSound(Constants.TEXTURE_PREFIX + "entity.bosslaugh", 10.0F, 1.1F);
break;
case C_PLAY_SOUND_BOW:
player.playSound("random.bow", 10.0F, 0.2F);
break;
case C_UPDATE_OXYGEN_VALIDITY:
stats.setOxygenSetupValid((Boolean) this.data.get(0));
break;
case C_OPEN_PARACHEST_GUI:
switch((Integer) this.data.get(1)) {
case 0:
if (player.ridingEntity instanceof EntityBuggy) {
FMLClientHandler.instance().getClient().displayGuiScreen(new GuiBuggy(player.inventory, (EntityBuggy) player.ridingEntity, ((EntityBuggy) player.ridingEntity).getType()));
player.openContainer.windowId = (Integer) this.data.get(0);
}
break;
case 1:
int entityID = (Integer) this.data.get(2);
Entity entity = player.worldObj.getEntityByID(entityID);
if (entity != null && entity instanceof IInventorySettable) {
FMLClientHandler.instance().getClient().displayGuiScreen(new GuiParaChest(player.inventory, (IInventorySettable) entity));
}
player.openContainer.windowId = (Integer) this.data.get(0);
break;
}
break;
case C_UPDATE_WIRE_BOUNDS:
TileEntity tile = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
if (tile instanceof TileBaseConductor) {
((TileBaseConductor) tile).adjacentConnections = null;
player.worldObj.getBlockState(tile.getPos()).getBlock().setBlockBoundsBasedOnState(player.worldObj, tile.getPos());
}
break;
case C_OPEN_SPACE_RACE_GUI:
if (Minecraft.getMinecraft().currentScreen == null) {
TickHandlerClient.spaceRaceGuiScheduled = false;
player.openGui(GalacticraftCore.instance, GuiIdsCore.SPACE_RACE_START, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
} else {
TickHandlerClient.spaceRaceGuiScheduled = true;
}
break;
case C_UPDATE_SPACE_RACE_DATA:
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++) {
String playerName = (String) this.data.get(i);
ClientProxyCore.flagRequestsSent.remove(playerName);
playerList.add(playerName);
}
SpaceRace race = new SpaceRace(playerList, teamName, flagData, teamColor);
race.setSpaceRaceID(teamID);
SpaceRaceManager.addSpaceRace(race);
break;
case C_OPEN_JOIN_RACE_GUI:
stats.setSpaceRaceInviteTeamID((Integer) this.data.get(0));
player.openGui(GalacticraftCore.instance, GuiIdsCore.SPACE_RACE_JOIN, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
break;
case C_UPDATE_DUNGEON_DIRECTION:
stats.setDungeonDirection((Float) this.data.get(0));
break;
case C_UPDATE_FOOTPRINT_LIST:
List<Footprint> printList = new ArrayList<Footprint>();
long chunkKey = (Long) this.data.get(0);
for (int i = 1; i < this.data.size(); i++) {
Footprint print = (Footprint) this.data.get(i);
if (!print.owner.equals(player.getName())) {
printList.add(print);
}
}
FootprintRenderer.setFootprints(chunkKey, printList);
break;
case C_FOOTPRINTS_REMOVED:
long chunkKey0 = (Long) this.data.get(0);
BlockVec3 position = (BlockVec3) this.data.get(1);
List<Footprint> footprintList = FootprintRenderer.footprints.get(chunkKey0);
List<Footprint> toRemove = new ArrayList<Footprint>();
if (footprintList != null) {
for (Footprint footprint : footprintList) {
if (footprint.position.x > position.x && footprint.position.x < position.x + 1 && footprint.position.z > position.z && footprint.position.z < position.z + 1) {
toRemove.add(footprint);
}
}
}
if (!toRemove.isEmpty()) {
footprintList.removeAll(toRemove);
FootprintRenderer.footprints.put(chunkKey0, footprintList);
}
break;
case C_UPDATE_STATION_SPIN:
if (playerBaseClient.worldObj.provider instanceof WorldProviderSpaceStation) {
((WorldProviderSpaceStation) playerBaseClient.worldObj.provider).getSpinManager().setSpinRate((Float) this.data.get(0), (Boolean) this.data.get(1));
}
break;
case C_UPDATE_STATION_DATA:
if (playerBaseClient.worldObj.provider instanceof WorldProviderSpaceStation) {
((WorldProviderSpaceStation) playerBaseClient.worldObj.provider).getSpinManager().setSpinCentre((Double) this.data.get(0), (Double) this.data.get(1));
}
break;
case C_UPDATE_STATION_BOX:
if (playerBaseClient.worldObj.provider instanceof WorldProviderSpaceStation) {
((WorldProviderSpaceStation) playerBaseClient.worldObj.provider).getSpinManager().setSpinBox((Integer) this.data.get(0), (Integer) this.data.get(1), (Integer) this.data.get(2), (Integer) this.data.get(3), (Integer) this.data.get(4), (Integer) this.data.get(5));
}
break;
case C_UPDATE_THERMAL_LEVEL:
stats.setThermalLevel((Integer) this.data.get(0));
stats.setThermalLevelNormalising((Boolean) this.data.get(1));
break;
case C_DISPLAY_ROCKET_CONTROLS:
player.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.spaceKey.getKeyCode()) + " - " + GCCoreUtil.translate("gui.rocket.launch.name")));
player.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.leftKey.getKeyCode()) + " / " + GameSettings.getKeyDisplayString(KeyHandlerClient.rightKey.getKeyCode()) + " - " + GCCoreUtil.translate("gui.rocket.turn.name")));
player.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.accelerateKey.getKeyCode()) + " / " + GameSettings.getKeyDisplayString(KeyHandlerClient.decelerateKey.getKeyCode()) + " - " + GCCoreUtil.translate("gui.rocket.updown.name")));
player.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.openFuelGui.getKeyCode()) + " - " + GCCoreUtil.translate("gui.rocket.inv.name")));
break;
case C_GET_CELESTIAL_BODY_LIST:
String str = "";
for (CelestialBody cBody : GalaxyRegistry.getRegisteredPlanets().values()) {
str = str.concat(cBody.getUnlocalizedName() + ";");
}
for (CelestialBody cBody : GalaxyRegistry.getRegisteredMoons().values()) {
str = str.concat(cBody.getUnlocalizedName() + ";");
}
for (CelestialBody cBody : GalaxyRegistry.getRegisteredSatellites().values()) {
str = str.concat(cBody.getUnlocalizedName() + ";");
}
for (SolarSystem solarSystem : GalaxyRegistry.getRegisteredSolarSystems().values()) {
str = str.concat(solarSystem.getUnlocalizedName() + ";");
}
GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_COMPLETE_CBODY_HANDSHAKE, getDimensionID(), new Object[] { str }));
break;
case C_UPDATE_ENERGYUNITS:
CommandGCEnergyUnits.handleParamClientside((Integer) this.data.get(0));
break;
case C_RESPAWN_PLAYER:
final WorldProvider provider = WorldUtil.getProviderForNameClient((String) this.data.get(0));
final int dimID = GCCoreUtil.getDimensionID(provider);
if (ConfigManagerCore.enableDebug) {
GCLog.info("DEBUG: Client receiving respawn packet for dim " + dimID);
}
int par2 = (Integer) this.data.get(1);
String par3 = (String) this.data.get(2);
int par4 = (Integer) this.data.get(3);
WorldUtil.forceRespawnClient(dimID, par2, par3, par4);
break;
case C_UPDATE_STATS:
stats.setBuildFlags((Integer) this.data.get(0));
BlockPanelLighting.updateClient(this.data);
break;
case C_UPDATE_TELEMETRY:
tile = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
if (tile instanceof TileEntityTelemetry) {
((TileEntityTelemetry) tile).receiveUpdate(data, this.getDimensionID());
}
break;
case C_SEND_PLAYERSKIN:
String strName = (String) this.data.get(0);
String s1 = (String) this.data.get(1);
String s2 = (String) this.data.get(2);
String strUUID = (String) this.data.get(3);
GameProfile gp = PlayerUtil.getOtherPlayerProfile(strName);
if (gp == null) {
gp = PlayerUtil.makeOtherPlayerProfile(strName, strUUID);
}
gp.getProperties().put("textures", new Property("textures", s1, s2));
break;
case C_SEND_OVERWORLD_IMAGE:
try {
int cx = (Integer) this.data.get(0);
int cz = (Integer) this.data.get(1);
byte[] bytes = (byte[]) this.data.get(2);
MapUtil.receiveOverworldImageCompressed(cx, cz, bytes);
} catch (Exception e) {
e.printStackTrace();
}
break;
case C_RECOLOR_PIPE:
TileEntity tileEntity = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
if (tileEntity instanceof TileEntityFluidPipe) {
TileEntityFluidPipe pipe = (TileEntityFluidPipe) tileEntity;
pipe.getNetwork().split(pipe);
pipe.setNetwork(null);
}
break;
case C_RECOLOR_ALL_GLASS:
BlockSpaceGlass.updateGlassColors((Integer) this.data.get(0), (Integer) this.data.get(1), (Integer) this.data.get(2));
break;
case C_UPDATE_MACHINE_DATA:
TileEntity tile3 = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
if (tile3 instanceof ITileClientUpdates) {
((ITileClientUpdates) tile3).updateClient(this.data);
}
break;
case C_LEAK_DATA:
TileEntity tile4 = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
if (tile4 instanceof TileEntityOxygenSealer) {
((ITileClientUpdates) tile4).updateClient(this.data);
}
break;
case C_SPAWN_HANGING_SCHEMATIC:
EntityHangingSchematic entity = new EntityHangingSchematic(player.worldObj, (BlockPos) this.data.get(0), EnumFacing.getFront((Integer) this.data.get(2)), (Integer) this.data.get(3));
((WorldClient) player.worldObj).addEntityToWorld((Integer) this.data.get(1), entity);
break;
default:
break;
}
}
use of micdoodle8.mods.galacticraft.api.galaxies.Satellite in project Galacticraft by micdoodle8.
the class GalacticraftCore method registerCoreGameScreens.
private static void registerCoreGameScreens() {
if (GCCoreUtil.getEffectiveSide() == Side.CLIENT) {
IGameScreen rendererBasic = new GameScreenBasic();
IGameScreen rendererCelest = new GameScreenCelestial();
// Type 0 - blank
GalacticraftRegistry.registerScreen(rendererBasic);
// Type 1 - local satellite view
GalacticraftRegistry.registerScreen(rendererBasic);
// Type 2 - solar system
GalacticraftRegistry.registerScreen(rendererCelest);
// Type 3 - local planet
GalacticraftRegistry.registerScreen(rendererCelest);
// Type 4 - render test
GalacticraftRegistry.registerScreen(rendererCelest);
} else {
GalacticraftRegistry.registerScreensServer(5);
}
}
use of micdoodle8.mods.galacticraft.api.galaxies.Satellite in project Galacticraft by micdoodle8.
the class GuiCelestialSelection method drawCelestialBodies.
public HashMap<CelestialBody, Matrix4f> drawCelestialBodies(Matrix4f worldMatrix) {
GL11.glColor3f(1, 1, 1);
FloatBuffer fb = BufferUtils.createFloatBuffer(16 * Float.SIZE);
HashMap<CelestialBody, Matrix4f> matrixMap = Maps.newHashMap();
for (SolarSystem solarSystem : GalaxyRegistry.getRegisteredSolarSystems().values()) {
Star star = solarSystem.getMainStar();
if (star != null && star.getBodyIcon() != null) {
GL11.glPushMatrix();
Matrix4f worldMatrix0 = new Matrix4f(worldMatrix);
Matrix4f.translate(this.getCelestialBodyPosition(star), worldMatrix0, worldMatrix0);
Matrix4f worldMatrix1 = new Matrix4f();
Matrix4f.rotate((float) Math.toRadians(45), new Vector3f(0, 0, 1), worldMatrix1, worldMatrix1);
Matrix4f.rotate((float) Math.toRadians(-55), new Vector3f(1, 0, 0), worldMatrix1, worldMatrix1);
worldMatrix1 = Matrix4f.mul(worldMatrix0, worldMatrix1, worldMatrix1);
fb.rewind();
worldMatrix1.store(fb);
fb.flip();
GL11.glMultMatrix(fb);
float alpha = 1.0F;
if (this.selectedBody != null && this.selectedBody != star && this.isZoomed()) {
alpha = 1.0F - Math.min(this.ticksSinceSelection / 25.0F, 1.0F);
}
if (this.selectedBody != null && this.isZoomed()) {
if (star != this.selectedBody) {
alpha = 1.0F - Math.min(this.ticksSinceSelection / 25.0F, 1.0F);
if (!(this.lastSelectedBody instanceof Star) && this.lastSelectedBody != null) {
alpha = 0.0F;
}
}
}
if (alpha != 0) {
CelestialBodyRenderEvent.Pre preEvent = new CelestialBodyRenderEvent.Pre(star, star.getBodyIcon(), 8);
MinecraftForge.EVENT_BUS.post(preEvent);
GL11.glColor4f(1, 1, 1, alpha);
if (preEvent.celestialBodyTexture != null) {
this.mc.renderEngine.bindTexture(preEvent.celestialBodyTexture);
}
if (!preEvent.isCanceled()) {
int size = getWidthForCelestialBodyStatic(star);
if (star == this.selectedBody && this.selectionState == EnumSelection.SELECTED) {
size /= 2;
size *= 3;
}
this.drawTexturedModalRect(-size / 2, -size / 2, size, size, 0, 0, preEvent.textureSize, preEvent.textureSize, false, false, preEvent.textureSize, preEvent.textureSize);
matrixMap.put(star, worldMatrix1);
}
CelestialBodyRenderEvent.Post postEvent = new CelestialBodyRenderEvent.Post(star);
MinecraftForge.EVENT_BUS.post(postEvent);
}
fb.clear();
GL11.glPopMatrix();
}
}
for (Planet planet : GalaxyRegistry.getRegisteredPlanets().values()) {
if (planet.getBodyIcon() != null) {
GL11.glPushMatrix();
Matrix4f worldMatrix0 = new Matrix4f(worldMatrix);
Matrix4f.translate(this.getCelestialBodyPosition(planet), worldMatrix0, worldMatrix0);
Matrix4f worldMatrix1 = new Matrix4f();
Matrix4f.rotate((float) Math.toRadians(45), new Vector3f(0, 0, 1), worldMatrix1, worldMatrix1);
Matrix4f.rotate((float) Math.toRadians(-55), new Vector3f(1, 0, 0), worldMatrix1, worldMatrix1);
worldMatrix1 = Matrix4f.mul(worldMatrix0, worldMatrix1, worldMatrix1);
fb.rewind();
worldMatrix1.store(fb);
fb.flip();
GL11.glMultMatrix(fb);
float alpha = 1.0F;
if ((this.selectedBody instanceof IChildBody && ((IChildBody) this.selectedBody).getParentPlanet() != planet) || (this.selectedBody instanceof Planet && this.selectedBody != planet && this.isZoomed())) {
if (this.lastSelectedBody == null && !(this.selectedBody instanceof IChildBody)) {
alpha = 1.0F - Math.min(this.ticksSinceSelection / 25.0F, 1.0F);
} else {
alpha = 0.0F;
}
}
if (alpha != 0) {
CelestialBodyRenderEvent.Pre preEvent = new CelestialBodyRenderEvent.Pre(planet, planet.getBodyIcon(), 12);
MinecraftForge.EVENT_BUS.post(preEvent);
GL11.glColor4f(1, 1, 1, alpha);
if (preEvent.celestialBodyTexture != null) {
this.mc.renderEngine.bindTexture(preEvent.celestialBodyTexture);
}
if (!preEvent.isCanceled()) {
int size = getWidthForCelestialBodyStatic(planet);
// Celestial body textures are 12x12 in a 16x16 .png
this.drawTexturedModalRect(-size / 2, -size / 2, size, size, 0, 0, preEvent.textureSize, preEvent.textureSize, false, false, 16, 16);
matrixMap.put(planet, worldMatrix1);
}
CelestialBodyRenderEvent.Post postEvent = new CelestialBodyRenderEvent.Post(planet);
MinecraftForge.EVENT_BUS.post(postEvent);
}
fb.clear();
GL11.glPopMatrix();
}
}
if (this.selectedBody != null) {
Matrix4f worldMatrix0 = new Matrix4f(worldMatrix);
for (Moon moon : GalaxyRegistry.getRegisteredMoons().values()) {
if ((moon == this.selectedBody || (moon.getParentPlanet() == this.selectedBody && this.selectionState != EnumSelection.SELECTED)) && (this.ticksSinceSelection > 35 || this.selectedBody == moon || (this.lastSelectedBody instanceof Moon && GalaxyRegistry.getMoonsForPlanet(((Moon) this.lastSelectedBody).getParentPlanet()).contains(moon))) || getSiblings(this.selectedBody).contains(moon)) {
GL11.glPushMatrix();
Matrix4f worldMatrix1 = new Matrix4f(worldMatrix0);
Matrix4f.translate(this.getCelestialBodyPosition(moon), worldMatrix1, worldMatrix1);
Matrix4f worldMatrix2 = new Matrix4f();
Matrix4f.rotate((float) Math.toRadians(45), new Vector3f(0, 0, 1), worldMatrix2, worldMatrix2);
Matrix4f.rotate((float) Math.toRadians(-55), new Vector3f(1, 0, 0), worldMatrix2, worldMatrix2);
Matrix4f.scale(new Vector3f(0.25F, 0.25F, 1.0F), worldMatrix2, worldMatrix2);
worldMatrix2 = Matrix4f.mul(worldMatrix1, worldMatrix2, worldMatrix2);
fb.rewind();
worldMatrix2.store(fb);
fb.flip();
GL11.glMultMatrix(fb);
CelestialBodyRenderEvent.Pre preEvent = new CelestialBodyRenderEvent.Pre(moon, moon.getBodyIcon(), 8);
MinecraftForge.EVENT_BUS.post(preEvent);
GL11.glColor4f(1, 1, 1, 1);
if (preEvent.celestialBodyTexture != null) {
this.mc.renderEngine.bindTexture(preEvent.celestialBodyTexture);
}
if (!preEvent.isCanceled()) {
int size = getWidthForCelestialBodyStatic(moon);
this.drawTexturedModalRect(-size / 2, -size / 2, size, size, 0, 0, preEvent.textureSize, preEvent.textureSize, false, false, preEvent.textureSize, preEvent.textureSize);
matrixMap.put(moon, worldMatrix1);
}
CelestialBodyRenderEvent.Post postEvent = new CelestialBodyRenderEvent.Post(moon);
MinecraftForge.EVENT_BUS.post(postEvent);
fb.clear();
GL11.glPopMatrix();
}
}
}
if (this.selectedBody != null) {
Matrix4f worldMatrix0 = new Matrix4f(worldMatrix);
for (Satellite satellite : GalaxyRegistry.getRegisteredSatellites().values()) {
if (this.possibleBodies != null && this.possibleBodies.contains(satellite)) {
if ((satellite == this.selectedBody || (satellite.getParentPlanet() == this.selectedBody && this.selectionState != EnumSelection.SELECTED)) && (this.ticksSinceSelection > 35 || this.selectedBody == satellite || (this.lastSelectedBody instanceof Satellite && GalaxyRegistry.getSatellitesForCelestialBody(((Satellite) this.lastSelectedBody).getParentPlanet()).contains(satellite)))) {
GL11.glPushMatrix();
Matrix4f worldMatrix1 = new Matrix4f(worldMatrix0);
Matrix4f.translate(this.getCelestialBodyPosition(satellite), worldMatrix1, worldMatrix1);
Matrix4f worldMatrix2 = new Matrix4f();
Matrix4f.rotate((float) Math.toRadians(45), new Vector3f(0, 0, 1), worldMatrix2, worldMatrix2);
Matrix4f.rotate((float) Math.toRadians(-55), new Vector3f(1, 0, 0), worldMatrix2, worldMatrix2);
Matrix4f.scale(new Vector3f(0.25F, 0.25F, 1.0F), worldMatrix2, worldMatrix2);
worldMatrix2 = Matrix4f.mul(worldMatrix1, worldMatrix2, worldMatrix2);
fb.rewind();
worldMatrix2.store(fb);
fb.flip();
GL11.glMultMatrix(fb);
CelestialBodyRenderEvent.Pre preEvent = new CelestialBodyRenderEvent.Pre(satellite, satellite.getBodyIcon(), 8);
MinecraftForge.EVENT_BUS.post(preEvent);
GL11.glColor4f(1, 1, 1, 1);
this.mc.renderEngine.bindTexture(preEvent.celestialBodyTexture);
if (!preEvent.isCanceled()) {
int size = getWidthForCelestialBodyStatic(satellite);
this.drawTexturedModalRect(-size / 2, -size / 2, size, size, 0, 0, preEvent.textureSize, preEvent.textureSize, false, false, preEvent.textureSize, preEvent.textureSize);
matrixMap.put(satellite, worldMatrix1);
}
CelestialBodyRenderEvent.Post postEvent = new CelestialBodyRenderEvent.Post(satellite);
MinecraftForge.EVENT_BUS.post(postEvent);
fb.clear();
GL11.glPopMatrix();
}
}
}
}
return matrixMap;
}
use of micdoodle8.mods.galacticraft.api.galaxies.Satellite in project Galacticraft by micdoodle8.
the class GuiCelestialSelection method drawCircle.
protected boolean drawCircle(CelestialBody body, int count, float sin, float cos) {
float x = this.getScale(body);
float y = 0;
float alpha = 1;
if (this.isZoomed()) {
alpha = this.selectedBody instanceof IChildBody ? 1.0F : Math.min(Math.max((this.ticksSinceSelection - 30) / 15.0F, 0.0F), 1.0F);
if (this.lastSelectedBody instanceof Moon && body instanceof Moon) {
if (GalaxyRegistry.getMoonsForPlanet(((Moon) this.lastSelectedBody).getParentPlanet()).contains(body)) {
alpha = 1.0F;
}
} else if (this.lastSelectedBody instanceof Satellite && body instanceof Satellite) {
if (GalaxyRegistry.getSatellitesForCelestialBody(((Satellite) this.lastSelectedBody).getParentPlanet()).contains(body)) {
alpha = 1.0F;
}
}
}
if (alpha != 0) {
switch(count % 2) {
case 0:
GL11.glColor4f(0.0F, 0.6F, 1.0F, alpha);
break;
case 1:
GL11.glColor4f(0.4F, 0.9F, 1.0F, alpha);
break;
}
CelestialBodyRenderEvent.CelestialRingRenderEvent.Pre preEvent = new CelestialBodyRenderEvent.CelestialRingRenderEvent.Pre(body, new Vector3f(0.0F, 0.0F, 0.0F));
MinecraftForge.EVENT_BUS.post(preEvent);
if (!preEvent.isCanceled()) {
GL11.glBegin(GL11.GL_LINE_LOOP);
float temp;
for (int i = 0; i < 90; i++) {
GL11.glVertex2f(x, y);
temp = x;
x = cos * x - sin * y;
y = sin * temp + cos * y;
}
GL11.glEnd();
return true;
}
CelestialBodyRenderEvent.CelestialRingRenderEvent.Post postEvent = new CelestialBodyRenderEvent.CelestialRingRenderEvent.Post(body);
MinecraftForge.EVENT_BUS.post(postEvent);
}
return false;
}
use of micdoodle8.mods.galacticraft.api.galaxies.Satellite in project Galacticraft by micdoodle8.
the class GuiCelestialSelection method drawButtons.
public void drawButtons(int mousePosX, int mousePosY) {
this.zLevel = 0.0F;
boolean handledSliderPos = false;
final int LHS = GuiCelestialSelection.BORDER_SIZE + GuiCelestialSelection.BORDER_EDGE_SIZE;
final int RHS = width - LHS;
final int TOP = LHS;
final int BOT = height - LHS;
if (this.viewState == EnumView.PROFILE) {
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
this.drawTexturedModalRect(width / 2 - 43, TOP, 86, 15, 266, 0, 172, 29, false, false);
String str = GCCoreUtil.translate("gui.message.catalog.name").toUpperCase();
this.fontRendererObj.drawString(str, width / 2 - this.fontRendererObj.getStringWidth(str) / 2, TOP + this.fontRendererObj.FONT_HEIGHT / 2, WHITE);
if (this.selectedBody != null) {
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
if (mousePosX > LHS && mousePosX < LHS + 88 && mousePosY > TOP && mousePosY < TOP + 13) {
GL11.glColor3f(3.0F, 0.0F, 0.0F);
} else {
GL11.glColor3f(0.9F, 0.2F, 0.2F);
}
this.drawTexturedModalRect(LHS, TOP, 88, 13, 0, 392, 148, 22, false, false);
str = GCCoreUtil.translate("gui.message.back.name").toUpperCase();
this.fontRendererObj.drawString(str, LHS + 45 - this.fontRendererObj.getStringWidth(str) / 2, TOP + this.fontRendererObj.FONT_HEIGHT / 2 - 2, WHITE);
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
if (mousePosX > RHS - 88 && mousePosX < RHS && mousePosY > TOP && mousePosY < TOP + 13) {
GL11.glColor3f(0.0F, 3.0F, 0.0F);
} else {
GL11.glColor3f(0.2F, 0.9F, 0.2F);
}
this.drawTexturedModalRect(RHS - 88, TOP, 88, 13, 0, 392, 148, 22, true, false);
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
this.drawTexturedModalRect(LHS, BOT - 13, 88, 13, 0, 392, 148, 22, false, true);
this.drawTexturedModalRect(RHS - 88, BOT - 13, 88, 13, 0, 392, 148, 22, true, true);
int menuTopLeft = TOP - 115 + height / 2 - 4;
int posX = LHS + Math.min(this.ticksSinceSelection * 10, 133) - 134;
int posX2 = (int) (LHS + Math.min(this.ticksSinceSelection * 1.25F, 15) - 15);
int fontPosY = menuTopLeft + GuiCelestialSelection.BORDER_EDGE_SIZE + this.fontRendererObj.FONT_HEIGHT / 2 - 2;
this.drawTexturedModalRect(posX, menuTopLeft + 12, 133, 196, 0, 0, 266, 392, false, false);
// str = this.selectedBody.getLocalizedName();
// this.fontRendererObj.drawString(str, posX + 20, fontPosY, GCCoreUtil.to32BitColor(255, 255, 255, 255));
str = GCCoreUtil.translate("gui.message.daynightcycle.name") + ":";
this.fontRendererObj.drawString(str, posX + 5, fontPosY + 14, CYAN);
str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".daynightcycle.0.name");
this.fontRendererObj.drawString(str, posX + 10, fontPosY + 25, WHITE);
str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".daynightcycle.1.name");
if (!str.isEmpty()) {
this.fontRendererObj.drawString(str, posX + 10, fontPosY + 36, WHITE);
}
str = GCCoreUtil.translate("gui.message.surfacegravity.name") + ":";
this.fontRendererObj.drawString(str, posX + 5, fontPosY + 50, CYAN);
str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".surfacegravity.0.name");
this.fontRendererObj.drawString(str, posX + 10, fontPosY + 61, WHITE);
str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".surfacegravity.1.name");
if (!str.isEmpty()) {
this.fontRendererObj.drawString(str, posX + 10, fontPosY + 72, WHITE);
}
str = GCCoreUtil.translate("gui.message.surfacecomposition.name") + ":";
this.fontRendererObj.drawString(str, posX + 5, fontPosY + 88, CYAN);
str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".surfacecomposition.0.name");
this.fontRendererObj.drawString(str, posX + 10, fontPosY + 99, WHITE);
str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".surfacecomposition.1.name");
if (!str.isEmpty()) {
this.fontRendererObj.drawString(str, posX + 10, fontPosY + 110, WHITE);
}
str = GCCoreUtil.translate("gui.message.atmosphere.name") + ":";
this.fontRendererObj.drawString(str, posX + 5, fontPosY + 126, CYAN);
str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".atmosphere.0.name");
this.fontRendererObj.drawString(str, posX + 10, fontPosY + 137, WHITE);
str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".atmosphere.1.name");
if (!str.isEmpty()) {
this.fontRendererObj.drawString(str, posX + 10, fontPosY + 148, WHITE);
}
str = GCCoreUtil.translate("gui.message.meansurfacetemp.name") + ":";
this.fontRendererObj.drawString(str, posX + 5, fontPosY + 165, CYAN);
str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".meansurfacetemp.0.name");
this.fontRendererObj.drawString(str, posX + 10, fontPosY + 176, WHITE);
str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".meansurfacetemp.1.name");
if (!str.isEmpty()) {
this.fontRendererObj.drawString(str, posX + 10, fontPosY + 187, WHITE);
}
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
this.drawTexturedModalRect(posX2, menuTopLeft + 12, 17, 199, 439, 0, 32, 399, false, false);
// this.drawRectD(posX2 + 16.5, menuTopLeft + 13, posX + 131, menuTopLeft + 14, GCCoreUtil.to32BitColor(120, 0, (int) (0.6F * 255), 255));
}
} else {
String str;
// Catalog:
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
this.drawTexturedModalRect(LHS, TOP, 74, 11, 0, 392, 148, 22, false, false);
str = GCCoreUtil.translate("gui.message.catalog.name").toUpperCase();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.fontRendererObj.drawString(str, LHS + 40 - fontRendererObj.getStringWidth(str) / 2, TOP + 1, WHITE);
int scale = (int) Math.min(95, this.ticksSinceMenuOpen * 12.0F);
boolean planetZoomedNotMoon = this.isZoomed() && !(this.selectedParent instanceof Planet);
// Parent frame:
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
this.drawTexturedModalRect(LHS - 95 + scale, TOP + 12, 95, 41, 0, 436, 95, 41, false, false);
str = planetZoomedNotMoon ? this.selectedBody.getLocalizedName() : this.getParentName();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.fontRendererObj.drawString(str, LHS + 9 - 95 + scale, TOP + 34, WHITE);
GL11.glColor4f(1, 1, 0, 1);
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
// Grandparent frame:
this.drawTexturedModalRect(LHS + 2 - 95 + scale, TOP + 14, 93, 17, 95, 436, 93, 17, false, false);
str = planetZoomedNotMoon ? this.getParentName() : this.getGrandparentName();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.fontRendererObj.drawString(str, LHS + 7 - 95 + scale, TOP + 16, GREY3);
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
List<CelestialBody> children = this.getChildren(planetZoomedNotMoon ? this.selectedBody : this.selectedParent);
drawChildren(children, 0, 0, true);
if (this.mapMode) {
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
GL11.glColor4f(1.0F, 0.0F, 0.0F, 1);
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
this.drawTexturedModalRect(RHS - 74, TOP, 74, 11, 0, 392, 148, 22, true, false);
str = GCCoreUtil.translate("gui.message.exit.name").toUpperCase();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.fontRendererObj.drawString(str, RHS - 40 - fontRendererObj.getStringWidth(str) / 2, TOP + 1, WHITE);
}
if (this.selectedBody != null) {
// Right-hand bar (basic selectionState info)
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain1);
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
if (this.selectedBody instanceof Satellite) {
Satellite selectedSatellite = (Satellite) this.selectedBody;
int stationListSize = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).size();
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain1);
int max = Math.min((this.height / 2) / 14, stationListSize);
this.drawTexturedModalRect(RHS - 95, TOP, 95, 53, this.selectedStationOwner.length() == 0 ? 95 : 0, 186, 95, 53, false, false);
if (this.spaceStationListOffset <= 0) {
GL11.glColor4f(0.65F, 0.65F, 0.65F, 1);
} else {
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
}
this.drawTexturedModalRect(RHS - 85, TOP + 45, 61, 4, 0, 239, 61, 4, false, false);
if (max + spaceStationListOffset >= stationListSize) {
GL11.glColor4f(0.65F, 0.65F, 0.65F, 1);
} else {
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
}
this.drawTexturedModalRect(RHS - 85, TOP + 49 + max * 14, 61, 4, 0, 239, 61, 4, false, true);
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
if (this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(this.selectedStationOwner) == null) {
str = GCCoreUtil.translate("gui.message.select_ss.name");
this.drawSplitString(str, RHS - 47, TOP + 20, 91, WHITE, false, false);
} else {
str = GCCoreUtil.translate("gui.message.ss_owner.name");
this.fontRendererObj.drawString(str, RHS - 85, TOP + 18, WHITE);
str = this.selectedStationOwner;
this.fontRendererObj.drawString(str, RHS - 47 - this.fontRendererObj.getStringWidth(str) / 2, TOP + 30, WHITE);
}
Iterator<Map.Entry<String, StationDataGUI>> it = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).entrySet().iterator();
int i = 0;
int j = 0;
while (it.hasNext() && i < max) {
Map.Entry<String, StationDataGUI> e = it.next();
if (j >= this.spaceStationListOffset) {
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
int xOffset = 0;
if (e.getKey().equalsIgnoreCase(this.selectedStationOwner)) {
xOffset -= 5;
}
this.drawTexturedModalRect(RHS - 95 + xOffset, TOP + 50 + i * 14, 93, 12, 95, 464, 93, 12, true, false);
str = "";
String str0 = e.getValue().getStationName();
int point = 0;
while (this.fontRendererObj.getStringWidth(str) < 80 && point < str0.length()) {
str = str + str0.substring(point, point + 1);
point++;
}
if (this.fontRendererObj.getStringWidth(str) >= 80) {
str = str.substring(0, str.length() - 3);
str = str + "...";
}
this.fontRendererObj.drawString(str, RHS - 88 + xOffset, TOP + 52 + i * 14, WHITE);
i++;
}
j++;
}
} else {
this.drawTexturedModalRect(RHS - 96, TOP, 96, 139, 63, 0, 96, 139, false, false);
}
if (this.canCreateSpaceStation(this.selectedBody) && (!(this.selectedBody instanceof Satellite))) {
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain1);
int canCreateLength = Math.max(0, this.drawSplitString(GCCoreUtil.translate("gui.message.can_create_space_station.name"), 0, 0, 91, 0, true, true) - 2);
canCreateOffset = canCreateLength * this.fontRendererObj.FONT_HEIGHT;
this.drawTexturedModalRect(RHS - 95, TOP + 134, 93, 4, 159, 102, 93, 4, false, false);
for (int barY = 0; barY < canCreateLength; ++barY) {
this.drawTexturedModalRect(RHS - 95, TOP + 138 + barY * this.fontRendererObj.FONT_HEIGHT, 93, this.fontRendererObj.FONT_HEIGHT, 159, 106, 93, this.fontRendererObj.FONT_HEIGHT, false, false);
}
this.drawTexturedModalRect(RHS - 95, TOP + 138 + canCreateOffset, 93, 43, 159, 106, 93, 43, false, false);
this.drawTexturedModalRect(RHS - 79, TOP + 129, 61, 4, 0, 170, 61, 4, false, false);
SpaceStationRecipe recipe = WorldUtil.getSpaceStationRecipe(this.selectedBody.getDimensionID());
if (recipe != null) {
GL11.glColor4f(0.0F, 1.0F, 0.1F, 1);
boolean validInputMaterials = true;
int i = 0;
for (Map.Entry<Object, Integer> e : recipe.getInput().entrySet()) {
Object next = e.getKey();
int xPos = (int) (RHS - 95 + i * 93 / (double) recipe.getInput().size() + 5);
int yPos = TOP + 154 + canCreateOffset;
if (next instanceof ItemStack) {
int amount = getAmountInInventory((ItemStack) next);
RenderHelper.enableGUIStandardItemLighting();
ItemStack toRender = ((ItemStack) next).copy();
this.itemRender.renderItemAndEffectIntoGUI(toRender, xPos, yPos);
this.itemRender.renderItemOverlayIntoGUI(mc.fontRendererObj, toRender, xPos, yPos, null);
RenderHelper.disableStandardItemLighting();
GL11.glEnable(GL11.GL_BLEND);
if (mousePosX >= xPos && mousePosX <= xPos + 16 && mousePosY >= yPos && mousePosY <= yPos + 16) {
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glPushMatrix();
GL11.glTranslatef(0, 0, 300);
int k = this.fontRendererObj.getStringWidth(((ItemStack) next).getDisplayName());
int j2 = mousePosX - k / 2;
int k2 = mousePosY - 12;
int i1 = 8;
if (j2 + k > this.width) {
j2 -= (j2 - this.width + k);
}
if (k2 + i1 + 6 > this.height) {
k2 = this.height - i1 - 6;
}
int j1 = ColorUtil.to32BitColor(190, 0, 153, 255);
this.drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1);
this.drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1);
this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1);
this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1);
this.drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1);
int k1 = ColorUtil.to32BitColor(170, 0, 153, 255);
int l1 = (k1 & 16711422) >> 1 | k1 & -16777216;
this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1);
this.drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1);
this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1);
this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1);
this.fontRendererObj.drawString(((ItemStack) next).getDisplayName(), j2, k2, WHITE);
GL11.glPopMatrix();
}
str = "" + e.getValue();
boolean valid = amount >= e.getValue();
if (!valid && validInputMaterials) {
validInputMaterials = false;
}
int color = valid | this.mc.thePlayer.capabilities.isCreativeMode ? GREEN : RED;
this.fontRendererObj.drawString(str, xPos + 8 - this.fontRendererObj.getStringWidth(str) / 2, TOP + 170 + canCreateOffset, color);
} else if (next instanceof Collection) {
Collection<ItemStack> items = (Collection<ItemStack>) next;
int amount = 0;
for (ItemStack stack : items) {
amount += getAmountInInventory(stack);
}
RenderHelper.enableGUIStandardItemLighting();
Iterator<ItemStack> it = items.iterator();
int count = 0;
int toRenderIndex = (this.ticksSinceMenuOpen / 20) % items.size();
ItemStack toRender = null;
while (it.hasNext()) {
ItemStack stack = it.next();
if (count == toRenderIndex) {
toRender = stack;
break;
}
count++;
}
if (toRender == null) {
continue;
}
this.itemRender.renderItemAndEffectIntoGUI(toRender, xPos, yPos);
this.itemRender.renderItemOverlayIntoGUI(mc.fontRendererObj, toRender, xPos, yPos, null);
RenderHelper.disableStandardItemLighting();
GL11.glEnable(GL11.GL_BLEND);
if (mousePosX >= xPos && mousePosX <= xPos + 16 && mousePosY >= yPos && mousePosY <= yPos + 16) {
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glPushMatrix();
GL11.glTranslatef(0, 0, 300);
int k = this.fontRendererObj.getStringWidth(toRender.getDisplayName());
int j2 = mousePosX - k / 2;
int k2 = mousePosY - 12;
int i1 = 8;
if (j2 + k > this.width) {
j2 -= (j2 - this.width + k);
}
if (k2 + i1 + 6 > this.height) {
k2 = this.height - i1 - 6;
}
int j1 = ColorUtil.to32BitColor(190, 0, 153, 255);
this.drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1);
this.drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1);
this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1);
this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1);
this.drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1);
int k1 = ColorUtil.to32BitColor(170, 0, 153, 255);
int l1 = (k1 & 16711422) >> 1 | k1 & -16777216;
this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1);
this.drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1);
this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1);
this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1);
this.fontRendererObj.drawString(toRender.getDisplayName(), j2, k2, WHITE);
GL11.glPopMatrix();
}
str = "" + e.getValue();
boolean valid = amount >= e.getValue();
if (!valid && validInputMaterials) {
validInputMaterials = false;
}
int color = valid | this.mc.thePlayer.capabilities.isCreativeMode ? GREEN : RED;
this.fontRendererObj.drawString(str, xPos + 8 - this.fontRendererObj.getStringWidth(str) / 2, TOP + 170 + canCreateOffset, color);
}
i++;
}
if (validInputMaterials || this.mc.thePlayer.capabilities.isCreativeMode) {
GL11.glColor4f(0.0F, 1.0F, 0.1F, 1);
} else {
GL11.glColor4f(1.0F, 0.0F, 0.0F, 1);
}
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain1);
if (!this.mapMode) {
if (mousePosX >= RHS - 95 && mousePosX <= RHS && mousePosY >= TOP + 182 + canCreateOffset && mousePosY <= TOP + 182 + 12 + canCreateOffset) {
this.drawTexturedModalRect(RHS - 95, TOP + 182 + canCreateOffset, 93, 12, 0, 174, 93, 12, false, false);
}
}
this.drawTexturedModalRect(RHS - 95, TOP + 182 + canCreateOffset, 93, 12, 0, 174, 93, 12, false, false);
int color = (int) ((Math.sin(this.ticksSinceMenuOpen / 5.0) * 0.5 + 0.5) * 255);
this.drawSplitString(GCCoreUtil.translate("gui.message.can_create_space_station.name"), RHS - 48, TOP + 137, 91, ColorUtil.to32BitColor(255, color, 255, color), true, false);
if (!mapMode) {
this.drawSplitString(GCCoreUtil.translate("gui.message.create_ss.name").toUpperCase(), RHS - 48, TOP + 185 + canCreateOffset, 91, WHITE, false, false);
}
} else {
this.drawSplitString(GCCoreUtil.translate("gui.message.cannot_create_space_station.name"), RHS - 48, TOP + 138, 91, WHITE, true, false);
}
}
// Catalog overlay
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.3F - Math.min(0.3F, this.ticksSinceSelection / 50.0F));
this.drawTexturedModalRect(LHS, TOP, 74, 11, 0, 392, 148, 22, false, false);
str = GCCoreUtil.translate("gui.message.catalog.name").toUpperCase();
this.fontRendererObj.drawString(str, LHS + 40 - fontRendererObj.getStringWidth(str) / 2, TOP + 1, WHITE);
// Top bar title:
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
if (this.selectedBody instanceof Satellite) {
if (this.selectedStationOwner.length() == 0 || !this.selectedStationOwner.equalsIgnoreCase(PlayerUtil.getName(this.mc.thePlayer))) {
GL11.glColor4f(1.0F, 0.0F, 0.0F, 1);
} else {
GL11.glColor4f(0.0F, 1.0F, 0.0F, 1);
}
this.drawTexturedModalRect(width / 2 - 47, TOP, 94, 11, 0, 414, 188, 22, false, false);
} else {
this.drawTexturedModalRect(width / 2 - 47, TOP, 94, 11, 0, 414, 188, 22, false, false);
}
if (this.selectedBody.getTierRequirement() >= 0 && (!(this.selectedBody instanceof Satellite))) {
boolean canReach;
if (!this.selectedBody.getReachable() || (this.possibleBodies != null && !this.possibleBodies.contains(this.selectedBody))) {
canReach = false;
GL11.glColor4f(1.0F, 0.0F, 0.0F, 1);
} else {
canReach = true;
GL11.glColor4f(0.0F, 1.0F, 0.0F, 1);
}
this.drawTexturedModalRect(width / 2 - 30, TOP + 11, 30, 11, 0, 414, 60, 22, false, false);
this.drawTexturedModalRect(width / 2, TOP + 11, 30, 11, 128, 414, 60, 22, false, false);
str = GCCoreUtil.translateWithFormat("gui.message.tier.name", this.selectedBody.getTierRequirement() == 0 ? "?" : this.selectedBody.getTierRequirement());
this.fontRendererObj.drawString(str, width / 2 - this.fontRendererObj.getStringWidth(str) / 2, TOP + 13, canReach ? GREY4 : RED3);
}
str = this.selectedBody.getLocalizedName();
if (this.selectedBody instanceof Satellite) {
str = GCCoreUtil.translate("gui.message.rename.name").toUpperCase();
}
this.fontRendererObj.drawString(str, width / 2 - this.fontRendererObj.getStringWidth(str) / 2, TOP + 2, WHITE);
// Catalog wedge:
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
this.drawTexturedModalRect(LHS + 4, TOP, 83, 12, 0, 477, 83, 12, false, false);
if (!this.mapMode) {
if (!this.selectedBody.getReachable() || (this.possibleBodies != null && !this.possibleBodies.contains(this.selectedBody)) || (this.selectedBody instanceof Satellite && this.selectedStationOwner.equals(""))) {
GL11.glColor4f(1.0F, 0.0F, 0.0F, 1);
} else {
GL11.glColor4f(0.0F, 1.0F, 0.0F, 1);
}
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
this.drawTexturedModalRect(RHS - 74, TOP, 74, 11, 0, 392, 148, 22, true, false);
str = GCCoreUtil.translate("gui.message.launch.name").toUpperCase();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.fontRendererObj.drawString(str, RHS - 40 - fontRendererObj.getStringWidth(str) / 2, TOP + 2, WHITE);
}
if (this.selectionState == EnumSelection.SELECTED && !(this.selectedBody instanceof Satellite)) {
handledSliderPos = true;
int sliderPos = this.zoomTooltipPos;
if (zoomTooltipPos != 38) {
sliderPos = Math.min(this.ticksSinceSelection * 2, 38);
this.zoomTooltipPos = sliderPos;
}
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
this.drawTexturedModalRect(RHS - 182, height - GuiCelestialSelection.BORDER_SIZE - GuiCelestialSelection.BORDER_EDGE_SIZE - sliderPos, 83, 38, 512 - 166, 512 - 76, 166, 76, true, false);
boolean flag0 = GalaxyRegistry.getSatellitesForCelestialBody(this.selectedBody).size() > 0;
boolean flag1 = this.selectedBody instanceof Planet && GalaxyRegistry.getMoonsForPlanet((Planet) this.selectedBody).size() > 0;
if (flag0 && flag1) {
this.drawSplitString(GCCoreUtil.translate("gui.message.click_again.0.name"), RHS - 182 + 41, height - GuiCelestialSelection.BORDER_SIZE - GuiCelestialSelection.BORDER_EDGE_SIZE + 2 - sliderPos, 79, GREY5, false, false);
} else if (!flag0 && flag1) {
this.drawSplitString(GCCoreUtil.translate("gui.message.click_again.1.name"), RHS - 182 + 41, height - GuiCelestialSelection.BORDER_SIZE - GuiCelestialSelection.BORDER_EDGE_SIZE + 6 - sliderPos, 79, GREY5, false, false);
} else if (flag0) {
this.drawSplitString(GCCoreUtil.translate("gui.message.click_again.2.name"), RHS - 182 + 41, height - GuiCelestialSelection.BORDER_SIZE - GuiCelestialSelection.BORDER_EDGE_SIZE + 6 - sliderPos, 79, GREY5, false, false);
} else {
this.drawSplitString(GCCoreUtil.translate("gui.message.click_again.3.name"), RHS - 182 + 41, height - GuiCelestialSelection.BORDER_SIZE - GuiCelestialSelection.BORDER_EDGE_SIZE + 11 - sliderPos, 79, GREY5, false, false);
}
}
if (this.selectedBody instanceof Satellite && renamingSpaceStation) {
this.drawDefaultBackground();
GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain1);
this.drawTexturedModalRect(width / 2 - 90, this.height / 2 - 38, 179, 67, 159, 0, 179, 67, false, false);
this.drawTexturedModalRect(width / 2 - 90 + 4, this.height / 2 - 38 + 2, 171, 10, 159, 92, 171, 10, false, false);
this.drawTexturedModalRect(width / 2 - 90 + 8, this.height / 2 - 38 + 18, 161, 13, 159, 67, 161, 13, false, false);
this.drawTexturedModalRect(width / 2 - 90 + 17, this.height / 2 - 38 + 59, 72, 12, 159, 80, 72, 12, true, false);
this.drawTexturedModalRect(width / 2, this.height / 2 - 38 + 59, 72, 12, 159, 80, 72, 12, false, false);
str = GCCoreUtil.translate("gui.message.assign_name.name");
this.fontRendererObj.drawString(str, width / 2 - this.fontRendererObj.getStringWidth(str) / 2, this.height / 2 - 35, WHITE);
str = GCCoreUtil.translate("gui.message.apply.name");
this.fontRendererObj.drawString(str, width / 2 - this.fontRendererObj.getStringWidth(str) / 2 - 36, this.height / 2 + 23, WHITE);
str = GCCoreUtil.translate("gui.message.cancel.name");
this.fontRendererObj.drawString(str, width / 2 + 36 - this.fontRendererObj.getStringWidth(str) / 2, this.height / 2 + 23, WHITE);
if (this.renamingString == null) {
Satellite selectedSatellite = (Satellite) this.selectedBody;
String playerName = PlayerUtil.getName(this.mc.thePlayer);
this.renamingString = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(playerName).getStationName();
if (this.renamingString == null) {
this.renamingString = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(playerName.toLowerCase()).getStationName();
}
if (this.renamingString == null) {
this.renamingString = "";
}
}
str = this.renamingString;
String str0 = this.renamingString;
if ((this.ticksSinceMenuOpen / 10) % 2 == 0) {
str0 += "_";
}
this.fontRendererObj.drawString(str0, width / 2 - this.fontRendererObj.getStringWidth(str) / 2, this.height / 2 - 17, WHITE);
}
// this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
// GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
}
}
if (!handledSliderPos) {
this.zoomTooltipPos = 0;
}
}
Aggregations