aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
authorBlueWeabo <ilia.iliev2005@gmail.com>2023-02-26 13:16:07 +0200
committerGitHub <noreply@github.com>2023-02-26 12:16:07 +0100
commitb8d1ecf8b9b6348304392d09e4490d473dbb120d (patch)
tree1cdc59a1b660510fe2abd40686b2abed8b0ab40f /src/main/java/gregtech/common
parentebd7df3a1ddba9105df008d44ab046d159279628 (diff)
downloadGT5-Unofficial-b8d1ecf8b9b6348304392d09e4490d473dbb120d.tar.gz
GT5-Unofficial-b8d1ecf8b9b6348304392d09e4490d473dbb120d.tar.bz2
GT5-Unofficial-b8d1ecf8b9b6348304392d09e4490d473dbb120d.zip
Add a completely new system for late/endgame content (#1754)
* basic work * typo fixes * make an enum folder * location enums * space project manager * implement the space project teams * commands * move things around and new things * upgrade work * requirement work * if possible use an upgrades values * cleanup * more helpers in command * fix AOOBE * fix world saved data * builder for requirements * add command autocomplete * fix command npe * mark world saved data dirty * switch to saving to json string. this is fine * fix npe * fix files not saving correctly. serialization * spotless * part 1 of fixing json saving * working json file saving * rename fields * full implementation of SP_Upgrade * fixes * cleanup * texture prep * documentation part 1 * documentation part 2 and rework of json saving * fix the missed conversions * set texture when copying * more interface usage and fixes * rework saving. * Added rudimentary NEI handler for projects * Revert "Added rudimentary NEI handler for projects" This reverts commit 6d8210e25b27fee7dc1865d1afa91708a8d9b875. * address NPEs * some textures * higher quality textures, put in the moon as a temp texture * add a check to create a team if one smt weird happens * command work * add ability to localize the space bodies * Added disabled button and toggle button * Added possibility to not render the original stacksize of item stacks in NEI * Added NEI handler * Fixes item count on tooltip always rendering as 1 * Fix refactor * 5 new body textures * fix misspelled texture name --------- Co-authored-by: minecraft7771 <maxim235@gmx.de>
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r--src/main/java/gregtech/common/GT_Proxy.java2
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/SpaceProjectManager.java278
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/SpaceProjectWorldSavedData.java275
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/base/SP_Requirements.java77
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/base/SP_Upgrade.java347
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/base/SpaceProject.java440
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/commands/SPM_Command.java233
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/commands/SP_Command.java120
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/enums/JsonVariables.java22
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/enums/SolarSystem.java96
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/enums/SpaceBodyType.java17
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/enums/StarType.java32
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/enums/UpgradeStatus.java11
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/interfaces/ISpaceBody.java37
-rw-r--r--src/main/java/gregtech/common/misc/spaceprojects/interfaces/ISpaceProject.java430
15 files changed, 2417 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java
index ccc04f171e..3f50da2230 100644
--- a/src/main/java/gregtech/common/GT_Proxy.java
+++ b/src/main/java/gregtech/common/GT_Proxy.java
@@ -141,6 +141,7 @@ import gregtech.common.entities.GT_Entity_Arrow;
import gregtech.common.items.GT_MetaGenerated_Item_98;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
import gregtech.common.misc.GlobalEnergyWorldSavedData;
+import gregtech.common.misc.spaceprojects.SpaceProjectWorldSavedData;
public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IGlobalWirelessEnergy {
@@ -1051,6 +1052,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG
}
MinecraftForge.EVENT_BUS.register(new GlobalEnergyWorldSavedData(""));
+ MinecraftForge.EVENT_BUS.register(new SpaceProjectWorldSavedData());
// IC2 Hazmat
addFullHazmatToIC2Item("hazmatHelmet");
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/SpaceProjectManager.java b/src/main/java/gregtech/common/misc/spaceprojects/SpaceProjectManager.java
new file mode 100644
index 0000000000..81c7fac375
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/SpaceProjectManager.java
@@ -0,0 +1,278 @@
+package gregtech.common.misc.spaceprojects;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import net.minecraft.server.MinecraftServer;
+
+import org.apache.commons.lang3.tuple.Pair;
+
+import gregtech.api.util.GT_Recipe;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceBody;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject;
+
+/**
+ * @author BlueWeabo
+ */
+public class SpaceProjectManager {
+
+ /**
+ * Do not use! Only meant to be used in SpaceProjectWorldSavedData.java
+ */
+ public static Map<UUID, Map<Pair<ISpaceBody, String>, ISpaceProject>> spaceTeamProjects = new HashMap<>();
+ /**
+ * Do not use! Only meant to be used in SpaceProjectWorldSavedData.java Stores a Players UUID to the Leader UUID,
+ * players in lone groups give back their own UUID.
+ */
+ public static Map<UUID, UUID> spaceTeams = new HashMap<>();
+
+ /**
+ * Stores all the locations to a hash map to be accessed easier instead of through an enum
+ */
+ private static final HashMap<String, ISpaceBody> spaceLocations = new HashMap<>();
+
+ /**
+ * Stores all projects that have been made. Only adds them to this map if {@link #addProject(ISpaceProject)} has
+ * been used
+ */
+ private static final Map<String, ISpaceProject> spaceProjects = new HashMap<>();
+
+ // #region Space Project Team Helper methods
+
+ /**
+ * Used to get a specific project of the team dependent on the location and the project's name
+ */
+ public static ISpaceProject getTeamProject(UUID member, ISpaceBody location, String projectName) {
+ Map<Pair<ISpaceBody, String>, ISpaceProject> map = spaceTeamProjects.get(getLeader(member));
+ if (map == null) {
+ return null;
+ }
+ return map.get(Pair.of(location, projectName));
+ }
+
+ /**
+ * Makes a new Map for the teams if they don't have one. Adds a project to the team's project map.
+ *
+ * @param member Member of the team.
+ * @param location The location of where the project will belong to.
+ * @param projectName The name of the project being added.
+ * @param project Project which will be added to the team.
+ * @return Returns true when a project was added to the map of the player. Returns false otherwise.
+ */
+ public static boolean addTeamProject(UUID member, ISpaceBody location, String projectName, ISpaceProject project) {
+ if (!spaceTeamProjects.containsKey(getLeader(member)) || spaceTeamProjects.get(getLeader(member)) == null) {
+ spaceTeamProjects.put(getLeader(member), new HashMap<Pair<ISpaceBody, String>, ISpaceProject>());
+ }
+
+ Map<Pair<ISpaceBody, String>, ISpaceProject> map = spaceTeamProjects.get(getLeader(member));
+ if (map.containsKey(Pair.of(location, projectName))) {
+ return false;
+ }
+
+ project.setProjectLocation(location);
+ map.put(Pair.of(location, projectName), project);
+ SpaceProjectWorldSavedData.INSTANCE.markDirty();
+ return true;
+ }
+
+ /**
+ * Check whether a team has a project or not
+ *
+ * @param member Member of the team
+ * @param project The project, which you are checking for. This only compares the internal names of the project.
+ * @return True if the team has said project, false otherwise
+ */
+ public static boolean teamHasProject(UUID member, ISpaceProject project) {
+ Map<Pair<ISpaceBody, String>, ISpaceProject> map = spaceTeamProjects.get(getLeader(member));
+ if (map == null) {
+ return false;
+ }
+
+ return map.containsValue(project);
+ }
+
+ /**
+ * Used to handle when 2 players want to join together in a team. Player A can join player B's team. If player C
+ * gets an invite from A, C will join player B's team.
+ *
+ * @param teamMember Member which is joining the teamLeader
+ * @param teamLeader Leader of the party
+ */
+ public static void putInTeam(UUID teamMember, UUID teamLeader) {
+ if (teamMember.equals(teamLeader)) {
+ spaceTeams.put(teamMember, teamLeader);
+ } else if (!spaceTeams.get(teamLeader).equals(teamLeader)) {
+ putInTeam(teamMember, spaceTeams.get(teamLeader));
+ } else {
+ spaceTeams.put(teamMember, teamLeader);
+ }
+
+ SpaceProjectWorldSavedData.INSTANCE.markDirty();
+ }
+
+ /**
+ * Used to give back the UUID of the team leader.
+ *
+ * @return The UUID of the team leader.
+ */
+ public static UUID getLeader(UUID teamMember) {
+ checkOrCreateTeam(teamMember);
+ return spaceTeams.get(teamMember);
+ }
+
+ /**
+ * Used the multiblocks to check whether a given player has a team or not. If they don't have a team create one
+ * where they are their own leader.
+ *
+ * @param teamMember Member to check for.
+ */
+ public static void checkOrCreateTeam(UUID teamMember) {
+ if (spaceTeams.containsKey(teamMember)) {
+ return;
+ }
+
+ spaceTeams.put(teamMember, teamMember);
+ SpaceProjectWorldSavedData.INSTANCE.markDirty();
+ }
+
+ /**
+ * Will give back all the projects a team has made or is making.
+ *
+ * @param member UUID of the team member, used to find the leader of the team.
+ * @return All the projects a team has.
+ */
+ public static Collection<ISpaceProject> getTeamSpaceProjects(UUID member) {
+ Map<Pair<ISpaceBody, String>, ISpaceProject> map = spaceTeamProjects.get(getLeader(member));
+ if (map == null) {
+ return null;
+ }
+
+ return map.values();
+ }
+
+ /**
+ * Getting the project of a Team or a new copy.
+ *
+ * @param member UUID of the team member, which is used to find the team leader.
+ * @param projectName The name of the project, which needs to be found.
+ * @param location The location at which the project is found at.
+ * @return the project that the team has or a copy of a project.
+ */
+ public static ISpaceProject getTeamProjectOrCopy(UUID member, String projectName, ISpaceBody location) {
+ Map<Pair<ISpaceBody, String>, ISpaceProject> map = spaceTeamProjects.get(getLeader(member));
+ if (map == null) {
+ return getProject(projectName);
+ }
+
+ return map.getOrDefault(Pair.of(location, projectName), getProject(projectName));
+ }
+
+ // #endregion
+
+ // #region Project Helper methods
+
+ /**
+ * Used to add projects to the internal map.
+ *
+ * @param project Newly created project.
+ */
+ public static void addProject(ISpaceProject project) {
+ spaceProjects.put(project.getProjectName(), project);
+ GT_Recipe.GT_Recipe_Map.sFakeSpaceProjectRecipes.add(
+ new GT_Recipe.GT_Recipe_Map.GT_FakeSpaceProjectRecipe(
+ false,
+ project.getTotalItemsCost(),
+ project.getTotalFluidsCost(),
+ project.getProjectBuildTime(),
+ (int) project.getProjectVoltage(),
+ project.getTotalStages(),
+ project.getProjectName()));
+ }
+
+ /**
+ * @param projectName Internal name of the project.
+ * @return a copy of the stored project.
+ */
+ public static ISpaceProject getProject(String projectName) {
+ ISpaceProject tProject = spaceProjects.get(projectName);
+ return tProject != null ? tProject.copy() : null;
+ }
+
+ /**
+ * Should only be used for GUIs!
+ *
+ * @return The Map that the projects are stored at.
+ */
+ public static Map<String, ISpaceProject> getProjectsMap() {
+ return spaceProjects;
+ }
+
+ /**
+ * Should only be used for GUIs!
+ *
+ * @return A Collection of all the projects contained in the map.
+ */
+ public static Collection<ISpaceProject> getAllProjects() {
+ return spaceProjects.values();
+ }
+
+ // #endregion
+
+ // #region Location Helper methods
+
+ /**
+ * Adds a location to the internal map. For it to be used later
+ *
+ * @param location to add to the internal map
+ */
+ public static void addLocation(ISpaceBody location) {
+ spaceLocations.put(location.getName(), location);
+ }
+
+ /**
+ *
+ * @return a Collection of all locations, which have been registered.
+ */
+ public static Collection<ISpaceBody> getLocations() {
+ return spaceLocations.values();
+ }
+
+ /**
+ *
+ * @return a Collection fo all location names, which have been registered
+ */
+ public static Collection<String> getLocationNames() {
+ return spaceLocations.keySet();
+ }
+
+ /**
+ *
+ * @param locationName Name used to search for the location
+ * @return The location, which has been registered with said name
+ */
+ public static ISpaceBody getLocation(String locationName) {
+ return spaceLocations.get(locationName);
+ }
+
+ // #endregion
+
+ // #region General Helper methods
+
+ /**
+ * Gets the UUID using the player's username
+ */
+ public static UUID getPlayerUUIDFromName(String playerName) {
+ return MinecraftServer.getServer().func_152358_ax().func_152655_a(playerName).getId();
+ }
+
+ /**
+ * Gets the player's name using their UUID
+ */
+ public static String getPlayerNameFromUUID(UUID playerUUID) {
+ return MinecraftServer.getServer().func_152358_ax().func_152652_a(playerUUID).getName();
+ }
+
+ // #endregion
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/SpaceProjectWorldSavedData.java b/src/main/java/gregtech/common/misc/spaceprojects/SpaceProjectWorldSavedData.java
new file mode 100644
index 0000000000..6dc80db3ec
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/SpaceProjectWorldSavedData.java
@@ -0,0 +1,275 @@
+package gregtech.common.misc.spaceprojects;
+
+import static gregtech.common.misc.spaceprojects.SpaceProjectManager.spaceTeamProjects;
+import static gregtech.common.misc.spaceprojects.SpaceProjectManager.spaceTeams;
+import static gregtech.common.misc.spaceprojects.enums.JsonVariables.*;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.UUID;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.world.World;
+import net.minecraft.world.WorldSavedData;
+import net.minecraft.world.storage.MapStorage;
+import net.minecraftforge.event.world.WorldEvent;
+
+import org.apache.commons.lang3.tuple.Pair;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import gregtech.common.misc.spaceprojects.enums.SolarSystem;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceBody;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject.ISP_Upgrade;
+
+/**
+ * This class is used so that I can write and read to a json file before the world is opened. On server starting is too
+ * late for this as the data stored in the files is needed before entities load their nbt data
+ *
+ * @author BlueWeabo
+ */
+public class SpaceProjectWorldSavedData extends WorldSavedData {
+
+ public static SpaceProjectWorldSavedData INSTANCE;
+
+ private static final Gson GSON_SPACE_PROJECT = new GsonBuilder().serializeNulls().enableComplexMapKeySerialization()
+ .registerTypeAdapter(spaceTeamProjects.getClass(), new SpaceTeamProjectsMapAdapter())
+ .registerTypeAdapter(Map.class, new SpaceTeamProjectsMapAdapter())
+ .registerTypeAdapter(Pair.of((ISpaceBody) SolarSystem.Ariel, "").getClass(), new PairAdapter())
+ .registerTypeAdapter(Pair.class, new PairAdapter())
+ .registerTypeAdapter(ISpaceProject.class, new SpaceProjectAdapter())
+ .registerTypeAdapter(ISP_Upgrade.class, new SP_UpgradeAdapter())
+ .registerTypeHierarchyAdapter(ISpaceProject.class, new SpaceProjectAdapter())
+ .registerTypeHierarchyAdapter(ISP_Upgrade.class, new SP_UpgradeAdapter()).create();
+ private static final Gson GSON_TEAMS = new GsonBuilder().serializeNulls().create();
+
+ private static final String DATA_NAME = "GT_SpaceProjectData";
+
+ private static final String SPACE_TEAM_PROJECTS_JSON = "spaceTeamProject.json";
+
+ private static final String SPACE_TEAMS_JSON = "spaceTeams.json";
+
+ private static File spaceTeamsFile;
+ private static File teamProjectsFile;
+
+ public SpaceProjectWorldSavedData() {
+ super(DATA_NAME);
+ }
+
+ public SpaceProjectWorldSavedData(String aData) {
+ super(aData);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound aNBT) {
+ try (JsonReader reader = new JsonReader(new FileReader(teamProjectsFile))) {
+ spaceTeamProjects = GSON_SPACE_PROJECT.fromJson(reader, spaceTeamProjects.getClass());
+ } catch (Exception e) {
+ System.out.print("FAILED TO LOAD: " + SPACE_TEAM_PROJECTS_JSON);
+ e.printStackTrace();
+ }
+
+ try (JsonReader reader = new JsonReader(new FileReader(spaceTeamsFile))) {
+ spaceTeams = GSON_TEAMS.fromJson(reader, spaceTeams.getClass());
+ } catch (Exception e) {
+ System.out.print("FAILED TO LOAD: " + SPACE_TEAMS_JSON);
+ e.printStackTrace();
+ }
+
+ if (spaceTeams == null) {
+ spaceTeams = new HashMap<>();
+ }
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound aNBT) {
+ try (JsonWriter writer = new JsonWriter(new FileWriter(teamProjectsFile))) {
+ GSON_SPACE_PROJECT.toJson(spaceTeamProjects, spaceTeamProjects.getClass(), writer);
+ } catch (Exception ex) {
+ System.out.print("FAILED TO SAVE: " + SPACE_TEAM_PROJECTS_JSON);
+ ex.printStackTrace();
+ }
+
+ try (JsonWriter writer = new JsonWriter(new FileWriter(spaceTeamsFile))) {
+ GSON_TEAMS.toJson(spaceTeams, spaceTeams.getClass(), writer);
+ } catch (Exception ex) {
+ System.out.print("FAILED TO SAVE: " + SPACE_TEAMS_JSON);
+ ex.printStackTrace();
+ }
+ }
+
+ private static void loadInstance(World aWorld) {
+ spaceTeamProjects.clear();
+ spaceTeams.clear();
+ spaceTeamsFile = new File(aWorld.getSaveHandler().getWorldDirectory(), SPACE_TEAMS_JSON);
+ teamProjectsFile = new File(aWorld.getSaveHandler().getWorldDirectory(), SPACE_TEAM_PROJECTS_JSON);
+ MapStorage tStorage = aWorld.mapStorage;
+ INSTANCE = (SpaceProjectWorldSavedData) tStorage.loadData(SpaceProjectWorldSavedData.class, DATA_NAME);
+ if (INSTANCE == null) {
+ INSTANCE = new SpaceProjectWorldSavedData();
+ tStorage.setData(DATA_NAME, INSTANCE);
+ }
+ INSTANCE.markDirty();
+ }
+
+ @SubscribeEvent
+ public void onWorldLoad(WorldEvent.Load aEvent) {
+ if (!aEvent.world.isRemote && aEvent.world.provider.dimensionId == 0) {
+ loadInstance(aEvent.world);
+ }
+ }
+
+ private static class PairAdapter
+ implements JsonSerializer<Pair<ISpaceBody, String>>, JsonDeserializer<Pair<ISpaceBody, String>> {
+
+ @Override
+ public JsonElement serialize(Pair<ISpaceBody, String> src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonObject pair = new JsonObject();
+ pair.addProperty(PAIR_LEFT, src.getLeft().getName());
+ pair.addProperty(PAIR_RIGHT, src.getRight());
+ return pair;
+ }
+
+ @Override
+ public Pair<ISpaceBody, String> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ Pair<ISpaceBody, String> pair = null;
+ if (json.isJsonObject()) {
+ JsonObject obj = json.getAsJsonObject();
+ pair = Pair.of(
+ SpaceProjectManager.getLocation(obj.get(PAIR_LEFT).getAsString()),
+ obj.get(PAIR_RIGHT).getAsString());
+ }
+ return pair;
+ }
+ }
+
+ private static class SpaceProjectAdapter implements JsonSerializer<ISpaceProject>, JsonDeserializer<ISpaceProject> {
+
+ @Override
+ public JsonElement serialize(ISpaceProject src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonObject obj = new JsonObject();
+ obj.addProperty(PROJECT_NAME, src.getProjectName());
+ obj.addProperty(PROJECT_CURRENT_STAGE, src.getCurrentStage());
+ obj.addProperty(PROJECT_LOCATION, src.getProjectLocation().getName());
+ obj.add(PROJECT_CURRENT_UPGRADE, context.serialize(src.getUpgradeBeingBuilt()));
+ obj.add(PROJECT_UPGRADES_BUILT, context.serialize(src.getAllBuiltUpgrades()));
+ return obj;
+ }
+
+ @Override
+ public ISpaceProject deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ if (!json.isJsonObject()) {
+ return null;
+ }
+ JsonObject obj = json.getAsJsonObject();
+ String projectName = obj.get(PROJECT_NAME).getAsString();
+ ISpaceProject project = SpaceProjectManager.getProject(projectName);
+ int projectCurrentStage = obj.get(PROJECT_CURRENT_STAGE).getAsInt();
+ ISP_Upgrade[] projectUpgradesBuilt = context
+ .deserialize(obj.get(PROJECT_UPGRADES_BUILT), ISP_Upgrade.class);
+ ISP_Upgrade projectCurrentUpgrade = context
+ .deserialize(obj.get(PROJECT_CURRENT_UPGRADE), ISP_Upgrade.class);
+ ISpaceBody projectLocation = SpaceProjectManager.getLocation(obj.get(PROJECT_LOCATION).getAsString());
+ project.setBuiltUpgrade(projectUpgradesBuilt);
+ project.setCurrentUpgradeBeingBuilt(projectCurrentUpgrade);
+ project.setProjectLocation(projectLocation);
+ project.setProjectCurrentStage(projectCurrentStage);
+ return project;
+ }
+ }
+
+ private static class SP_UpgradeAdapter implements JsonSerializer<ISP_Upgrade>, JsonDeserializer<ISP_Upgrade> {
+
+ @Override
+ public JsonElement serialize(ISP_Upgrade src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonObject obj = new JsonObject();
+ obj.addProperty(UPGRADE_NAME, src.getUpgradeName());
+ obj.addProperty(UPGRADE_PROJECT_PARENT, src.getParentProject().getProjectName());
+ obj.addProperty(UPGRADE_CURRENT_STAGE, src.getCurrentStage());
+ return obj;
+ }
+
+ @Override
+ public ISP_Upgrade deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ if (!json.isJsonObject()) {
+ return null;
+ }
+ JsonObject obj = json.getAsJsonObject();
+ String projectName = obj.get(UPGRADE_PROJECT_PARENT).getAsString();
+ ISpaceProject project = SpaceProjectManager.getProject(projectName);
+ ISP_Upgrade upgrade = project.getUpgrade(obj.get(UPGRADE_NAME).getAsString());
+ if (upgrade == null) {
+ return null;
+ }
+ upgrade = upgrade.copy();
+ upgrade.setUpgradeCurrentStage(obj.get(UPGRADE_CURRENT_STAGE).getAsInt());
+ return upgrade;
+ }
+ }
+
+ private static class SpaceTeamProjectsMapAdapter
+ implements JsonSerializer<Map<UUID, Map<Pair<ISpaceBody, String>, ISpaceProject>>>,
+ JsonDeserializer<Map<UUID, Map<Pair<ISpaceBody, String>, ISpaceProject>>> {
+
+ @Override
+ public JsonElement serialize(Map<UUID, Map<Pair<ISpaceBody, String>, ISpaceProject>> src, Type typeOfSrc,
+ JsonSerializationContext context) {
+ JsonArray map = new JsonArray();
+ for (Entry<UUID, Map<Pair<ISpaceBody, String>, ISpaceProject>> firstEntry : src.entrySet()) {
+ JsonObject teamMap = new JsonObject();
+ teamMap.add(MAP_UUID, context.serialize(firstEntry.getKey()));
+ JsonArray teamProjectMap = new JsonArray();
+ for (Entry<Pair<ISpaceBody, String>, ISpaceProject> secondEntry : firstEntry.getValue().entrySet()) {
+ JsonObject projectMap = new JsonObject();
+ projectMap.add(MAP_PAIR, context.serialize(secondEntry.getKey()));
+ projectMap.add(MAP_PROJECT, context.serialize(secondEntry.getValue()));
+ teamProjectMap.add(projectMap);
+ }
+ teamMap.add(MAP_MAP, teamProjectMap);
+ map.add(teamMap);
+ }
+ return map;
+ }
+
+ @Override
+ public Map<UUID, Map<Pair<ISpaceBody, String>, ISpaceProject>> deserialize(JsonElement json, Type typeOfT,
+ JsonDeserializationContext context) throws JsonParseException {
+ JsonArray mapArray = json.getAsJsonArray();
+ Map<UUID, Map<Pair<ISpaceBody, String>, ISpaceProject>> map = new HashMap<>();
+ for (JsonElement teamMapElement : mapArray) {
+ JsonObject teamMap = teamMapElement.getAsJsonObject();
+ UUID uuid = context.deserialize(teamMap.get(MAP_UUID), UUID.class);
+ Map<Pair<ISpaceBody, String>, ISpaceProject> projectMap = new HashMap<>();
+ for (JsonElement teamProjectMapElement : teamMap.get(MAP_MAP).getAsJsonArray()) {
+ JsonObject teamProjectMap = teamProjectMapElement.getAsJsonObject();
+ Pair<ISpaceBody, String> pair = context.deserialize(teamProjectMap.get(MAP_PAIR), Pair.class);
+ ISpaceProject project = context.deserialize(teamProjectMap.get(MAP_PROJECT), ISpaceProject.class);
+ projectMap.put(pair, project);
+ }
+ map.put(uuid, projectMap);
+ }
+ return map;
+ }
+ }
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/base/SP_Requirements.java b/src/main/java/gregtech/common/misc/spaceprojects/base/SP_Requirements.java
new file mode 100644
index 0000000000..0cce6f08f0
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/base/SP_Requirements.java
@@ -0,0 +1,77 @@
+package gregtech.common.misc.spaceprojects.base;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import gregtech.common.misc.spaceprojects.enums.SpaceBodyType;
+import gregtech.common.misc.spaceprojects.enums.StarType;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject.ISP_Requirements;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject.ISP_Upgrade;
+
+/**
+ * @author BlueWeabo
+ */
+public class SP_Requirements implements ISP_Requirements {
+
+ // #region Variables
+
+ protected SpaceBodyType spaceBody = SpaceBodyType.NONE;
+ protected StarType star = StarType.NotAStar;
+ protected List<ISpaceProject> spaceProjects = new ArrayList<>();
+ protected List<ISP_Upgrade> upgrades = new ArrayList<>();
+
+ // #endregion
+
+ // #region Getters
+
+ @Override
+ public SpaceBodyType getBodyType() {
+ return spaceBody;
+ }
+
+ @Override
+ public StarType getStarType() {
+ return star;
+ }
+
+ @Override
+ public List<ISpaceProject> getProjects() {
+ return spaceProjects;
+ }
+
+ @Override
+ public List<ISP_Upgrade> getUpgrades() {
+ return upgrades;
+ }
+
+ // #endregion
+
+ // #region Setters/Builder
+
+ public SP_Requirements setSpaceBodyType(SpaceBodyType spaceBodyType) {
+ spaceBody = spaceBodyType;
+ return this;
+ }
+
+ public SP_Requirements setStarType(StarType starType) {
+ star = starType;
+ return this;
+ }
+
+ public SP_Requirements setUpgrades(ISP_Upgrade... requirementUpgrades) {
+ for (ISP_Upgrade upgrade : requirementUpgrades) {
+ upgrades.add(upgrade);
+ }
+ return this;
+ }
+
+ public SP_Requirements setSpaceProjects(ISpaceProject... requirementProjects) {
+ for (ISpaceProject project : requirementProjects) {
+ spaceProjects.add(project);
+ }
+ return this;
+ }
+
+ // #endregion
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/base/SP_Upgrade.java b/src/main/java/gregtech/common/misc/spaceprojects/base/SP_Upgrade.java
new file mode 100644
index 0000000000..6a1fe82791
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/base/SP_Upgrade.java
@@ -0,0 +1,347 @@
+package gregtech.common.misc.spaceprojects.base;
+
+import java.util.UUID;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.fluids.FluidStack;
+
+import gregtech.common.misc.spaceprojects.SpaceProjectManager;
+import gregtech.common.misc.spaceprojects.enums.UpgradeStatus;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject.ISP_Upgrade;
+
+/**
+ * @author BlueWeabo
+ */
+public class SP_Upgrade implements ISP_Upgrade {
+
+ // #region Variables
+
+ protected String name;
+ protected String unlocalizedName;
+ protected ItemStack[] itemsCost;
+ protected FluidStack[] fluidsCost;
+ protected int totalStages;
+ protected int currentStage;
+ protected int buildTime;
+ protected long voltage;
+ protected SP_Requirements requirements;
+ protected ISpaceProject projectBelongingTo;
+
+ // #endregion
+
+ // #region Getters
+
+ @Override
+ public String getUpgradeName() {
+ return name;
+ }
+
+ @Override
+ public String getUnlocalizedName() {
+ return unlocalizedName;
+ }
+
+ @Override
+ public String getLocalizedName() {
+ return StatCollector.translateToLocal(unlocalizedName);
+ }
+
+ @Override
+ public ItemStack[] getItemsCostPerStage() {
+ return itemsCost;
+ }
+
+ @Override
+ public ItemStack getItemCostPerStage(int index) {
+ if (itemsCost == null || index < 0 || index >= itemsCost.length) {
+ return null;
+ }
+
+ return itemsCost[index];
+ }
+
+ @Override
+ public ItemStack[] getCurrentItemsProgress() {
+ ItemStack[] currentItemsProgress = new ItemStack[itemsCost.length];
+ int index = 0;
+ for (ItemStack item : itemsCost) {
+ ItemStack copy = item.copy();
+ copy.stackSize *= getCurrentStage();
+ currentItemsProgress[index++] = copy;
+ }
+
+ return currentItemsProgress;
+ }
+
+ @Override
+ public ItemStack getCurrentItemProgress(int index) {
+ if (itemsCost == null || index < 0 || index >= itemsCost.length || itemsCost[index] == null) {
+ return null;
+ }
+
+ ItemStack item = itemsCost[index].copy();
+ item.stackSize *= getCurrentStage();
+ return item;
+ }
+
+ @Override
+ public ItemStack[] getTotalItemsCost() {
+ ItemStack[] totalItemsCost = new ItemStack[itemsCost.length];
+ int index = 0;
+ for (ItemStack item : itemsCost) {
+ ItemStack copy = item.copy();
+ copy.stackSize *= getTotalStages();
+ totalItemsCost[index++] = copy;
+ }
+
+ return totalItemsCost;
+ }
+
+ @Override
+ public ItemStack getTotalItemCost(int index) {
+ if (itemsCost == null || index < 0 || index >= itemsCost.length || itemsCost[index] == null) {
+ return null;
+ }
+
+ ItemStack item = itemsCost[index].copy();
+ item.stackSize *= getTotalStages();
+ return item;
+ }
+
+ @Override
+ public FluidStack[] getFluidsCostPerStage() {
+ return fluidsCost;
+ }
+
+ @Override
+ public FluidStack getFluidCostPerStage(int index) {
+ if (fluidsCost == null || index < 0 || index >= fluidsCost.length) {
+ return null;
+ }
+
+ return fluidsCost[index];
+ }
+
+ @Override
+ public FluidStack[] getCurrentFluidsProgress() {
+ if (fluidsCost == null) {
+ return null;
+ }
+
+ FluidStack[] currentFluidsProgress = new FluidStack[fluidsCost.length];
+ int index = 0;
+ for (FluidStack fluid : fluidsCost) {
+ FluidStack copy = fluid.copy();
+ copy.amount *= getCurrentStage();
+ currentFluidsProgress[index++] = copy;
+ }
+
+ return currentFluidsProgress;
+ }
+
+ @Override
+ public FluidStack getCurrentFluidProgress(int index) {
+ if (fluidsCost == null || index < 0 || index >= fluidsCost.length || fluidsCost[index] == null) {
+ return null;
+ }
+
+ FluidStack fluid = fluidsCost[index].copy();
+ fluid.amount *= getCurrentStage();
+ return fluid;
+ }
+
+ @Override
+ public FluidStack[] getTotalFluidsCost() {
+ if (fluidsCost == null) {
+ return null;
+ }
+
+ FluidStack[] totalFluidsCost = new FluidStack[fluidsCost.length];
+ int index = 0;
+ for (FluidStack fluid : fluidsCost) {
+ FluidStack copy = fluid.copy();
+ copy.amount *= getTotalStages();
+ totalFluidsCost[index++] = copy;
+ }
+
+ return totalFluidsCost;
+ }
+
+ @Override
+ public FluidStack getTotalFluidCost(int index) {
+ if (fluidsCost == null || index < 0 || index >= fluidsCost.length || fluidsCost[index] == null) {
+ return null;
+ }
+
+ FluidStack fluid = fluidsCost[index].copy();
+ fluid.amount *= getTotalStages();
+ return fluid;
+ }
+
+ @Override
+ public int getTotalStages() {
+ return totalStages;
+ }
+
+ @Override
+ public int getUpgradeBuildTime() {
+ return buildTime;
+ }
+
+ @Override
+ public int getCurrentStage() {
+ return currentStage;
+ }
+
+ @Override
+ public float getCurrentProgress() {
+ return currentStage / totalStages * 100.0f;
+ }
+
+ @Override
+ public long getVoltage() {
+ return voltage;
+ }
+
+ @Override
+ public UpgradeStatus getStatus() {
+ if (requirements == null) {
+ return UpgradeStatus.Unlocked;
+ }
+
+ if (isFinished()) {
+ return UpgradeStatus.Finished;
+ }
+ return UpgradeStatus.Locked;
+ }
+
+ @Override
+ public SP_Requirements getUpgradeRequirements() {
+ return requirements;
+ }
+
+ @Override
+ public ISpaceProject getParentProject() {
+ return projectBelongingTo;
+ }
+
+ // #endregion
+
+ // #region Setter/Builder
+
+ public SP_Upgrade() {}
+
+ public SP_Upgrade setUpgradeName(String upgradeName) {
+ name = upgradeName;
+ return this;
+ }
+
+ public SP_Upgrade setUpgradeUnlocalizedName(String upgradeUnlocalizedName) {
+ unlocalizedName = upgradeUnlocalizedName;
+ return this;
+ }
+
+ public SP_Upgrade setUpgradeItemsCost(ItemStack... upgradeItemsCost) {
+ itemsCost = upgradeItemsCost;
+ return this;
+ }
+
+ public SP_Upgrade setUpgradeFluidsCost(FluidStack... upgradeFluidsCost) {
+ fluidsCost = upgradeFluidsCost;
+ return this;
+ }
+
+ public SP_Upgrade setUpgradeRequirements(SP_Requirements upgradeRequirements) {
+ requirements = upgradeRequirements;
+ return this;
+ }
+
+ public SP_Upgrade setUpgradeTotalStages(int upgradeTotalStages) {
+ totalStages = upgradeTotalStages;
+ return this;
+ }
+
+ public SP_Upgrade setUpgradeBuildTime(int upgradeBuildTime) {
+ buildTime = upgradeBuildTime;
+ return this;
+ }
+
+ public SP_Upgrade setUpgradeVoltage(long upgradeVoltage) {
+ voltage = upgradeVoltage;
+ return this;
+ }
+
+ @Override
+ public void setUpgradeProject(ISpaceProject project) {
+ projectBelongingTo = project;
+ }
+
+ @Override
+ public void setUpgradeCurrentStage(int stage) {
+ currentStage = stage;
+ }
+
+ // #endregion
+
+ // #region Other
+
+ @Override
+ public boolean meetsRequirements(UUID aTeam) {
+ if (requirements == null) {
+ return true;
+ }
+
+ if (requirements.getBodyType() != null) {
+ if (!requirements.getBodyType().equals(projectBelongingTo.getProjectLocation().getType())) {
+ return false;
+ }
+ }
+
+ if (requirements.getStarType() != null) {
+ if (!requirements.getStarType().equals(projectBelongingTo.getProjectLocation().getStarType())) {
+ return false;
+ }
+ }
+
+ if (requirements.getProjects() != null) {
+ for (ISpaceProject tProject : requirements.getProjects()) {
+ if (!SpaceProjectManager.teamHasProject(aTeam, tProject)) {
+ return false;
+ }
+ }
+ }
+
+ if (requirements.getUpgrades() != null) {
+ for (ISP_Upgrade upgrade : requirements.getUpgrades()) {
+ if (!projectBelongingTo.hasUpgrade(upgrade.getUpgradeName())) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public SP_Upgrade copy() {
+ SP_Upgrade copy = new SP_Upgrade().setUpgradeName(name).setUpgradeUnlocalizedName(unlocalizedName)
+ .setUpgradeBuildTime(buildTime).setUpgradeFluidsCost(fluidsCost).setUpgradeItemsCost(itemsCost)
+ .setUpgradeRequirements(requirements).setUpgradeTotalStages(totalStages).setUpgradeVoltage(voltage);
+ return copy;
+ }
+
+ @Override
+ public void goToNextStage() {
+ currentStage++;
+ }
+
+ @Override
+ public boolean isFinished() {
+ return currentStage == totalStages;
+ }
+
+ // #endregion
+
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/base/SpaceProject.java b/src/main/java/gregtech/common/misc/spaceprojects/base/SpaceProject.java
new file mode 100644
index 0000000000..57625f083e
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/base/SpaceProject.java
@@ -0,0 +1,440 @@
+package gregtech.common.misc.spaceprojects.base;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.fluids.FluidStack;
+
+import com.gtnewhorizons.modularui.api.drawable.UITexture;
+
+import gregtech.common.misc.spaceprojects.SpaceProjectManager;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceBody;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject;
+
+/**
+ * @author BlueWeabo
+ */
+public class SpaceProject implements ISpaceProject {
+
+ // #region Variables
+
+ protected String name;
+ protected String unlocalizedName;
+ protected long voltage;
+ protected int buildTime;
+ protected int projectTier;
+ protected int currentStage;
+ protected int totalStage;
+ protected Map<String, ISP_Upgrade> upgradesAvailable = new HashMap<>();
+ protected Map<String, ISP_Upgrade> upgradesInstalled = new HashMap<>();
+ protected ISP_Requirements requirements;
+ protected ISP_Upgrade currentUpgrade;
+ protected ItemStack[] itemsCost;
+ protected FluidStack[] fluidsCost;
+ protected ISpaceBody location;
+ protected UITexture texture;
+
+ // #endregion
+
+ // #region Getters
+
+ @Override
+ public String getProjectName() {
+ return name;
+ }
+
+ @Override
+ public String getUnlocalizedName() {
+ return unlocalizedName;
+ }
+
+ public String getLocalizedName() {
+ return StatCollector.translateToLocal(unlocalizedName);
+ }
+
+ @Override
+ public long getProjectVoltage() {
+ return voltage;
+ }
+
+ @Override
+ public int getProjectBuildTime() {
+ return buildTime;
+ }
+
+ @Override
+ public float getProjectCurrentProgress() {
+ return currentStage / totalStage * 100.0f;
+ }
+
+ @Override
+ public int getProjectTier() {
+ return projectTier;
+ }
+
+ @Override
+ public int getCurrentStage() {
+ return currentStage;
+ }
+
+ @Override
+ public int getTotalStages() {
+ return totalStage;
+ }
+
+ @Override
+ public Collection<ISP_Upgrade> getAllUpgrades() {
+ return upgradesAvailable.values();
+ }
+
+ @Override
+ public Map<String, ISP_Upgrade> getUpgradesBuiltMap() {
+ return upgradesInstalled;
+ }
+
+ @Override
+ public Collection<ISP_Upgrade> getAllBuiltUpgrades() {
+ return upgradesInstalled.values();
+ }
+
+ @Override
+ public ISP_Upgrade getUpgrade(String upgradeName) {
+ return upgradesAvailable.get(upgradeName);
+ }
+
+ @Override
+ public ItemStack[] getItemsCostPerStage() {
+ return itemsCost;
+ }
+
+ @Override
+ public ItemStack getItemCostPerStage(int index) {
+ if (itemsCost == null || index < 0 || index >= itemsCost.length) {
+ return null;
+ }
+
+ return itemsCost[index];
+ }
+
+ @Override
+ public ItemStack[] getCurrentItemsProgress() {
+ ItemStack[] currentItemsProgress = new ItemStack[itemsCost.length];
+ int index = 0;
+ for (ItemStack item : itemsCost) {
+ if (item == null) {
+ currentItemsProgress[index++] = null;
+ continue;
+ }
+ ItemStack copy = item.copy();
+ copy.stackSize *= getCurrentStage();
+ currentItemsProgress[index++] = copy;
+ }
+
+ return currentItemsProgress;
+ }
+
+ @Override
+ public ItemStack getCurrentItemProgress(int index) {
+ if (itemsCost == null || index < 0 || index >= itemsCost.length || itemsCost[index] == null) {
+ return null;
+ }
+
+ ItemStack item = itemsCost[index].copy();
+ item.stackSize *= getCurrentStage();
+ return item;
+ }
+
+ @Override
+ public ItemStack[] getTotalItemsCost() {
+ ItemStack[] totalItemsCost = new ItemStack[itemsCost.length];
+ int index = 0;
+ for (ItemStack item : itemsCost) {
+ if (item == null) {
+ totalItemsCost[index++] = null;
+ continue;
+ }
+ ItemStack copy = item.copy();
+ copy.stackSize *= getTotalStages();
+ totalItemsCost[index++] = copy;
+ }
+
+ return totalItemsCost;
+ }
+
+ @Override
+ public ItemStack getTotalItemCost(int index) {
+ if (itemsCost == null || index < 0 || index >= itemsCost.length || itemsCost[index] == null) {
+ return null;
+ }
+
+ ItemStack item = itemsCost[index].copy();
+ item.stackSize *= getTotalStages();
+ return item;
+ }
+
+ @Override
+ public FluidStack[] getFluidsCostPerStage() {
+ return fluidsCost;
+ }
+
+ @Override
+ public FluidStack getFluidCostPerStage(int index) {
+ if (fluidsCost == null || index < 0 || index >= fluidsCost.length || fluidsCost[index] == null) {
+ return null;
+ }
+
+ return fluidsCost[index];
+ }
+
+ @Override
+ public FluidStack[] getCurrentFluidsProgress() {
+ if (fluidsCost == null) {
+ return null;
+ }
+
+ FluidStack[] currentFluidsProgress = new FluidStack[fluidsCost.length];
+ int index = 0;
+ for (FluidStack fluid : fluidsCost) {
+ if (fluid == null) {
+ currentFluidsProgress[index++] = null;
+ continue;
+ }
+ FluidStack copy = fluid.copy();
+ copy.amount *= getCurrentStage();
+ currentFluidsProgress[index++] = copy;
+ }
+
+ return currentFluidsProgress;
+ }
+
+ @Override
+ public FluidStack getCurrentFluidProgress(int index) {
+ if (fluidsCost == null || index < 0 || index >= fluidsCost.length || fluidsCost[index] == null) {
+ return null;
+ }
+
+ FluidStack fluid = fluidsCost[index].copy();
+ fluid.amount *= getCurrentStage();
+ return fluid;
+ }
+
+ @Override
+ public FluidStack[] getTotalFluidsCost() {
+ if (fluidsCost == null) {
+ return null;
+ }
+
+ FluidStack[] totalFluidsCost = new FluidStack[fluidsCost.length];
+ int index = 0;
+ for (FluidStack fluid : fluidsCost) {
+ if (fluid == null) {
+ totalFluidsCost[index++] = null;
+ continue;
+ }
+ FluidStack copy = fluid.copy();
+ copy.amount *= getTotalStages();
+ totalFluidsCost[index++] = copy;
+ }
+
+ return totalFluidsCost;
+ }
+
+ @Override
+ public FluidStack getTotalFluidCost(int index) {
+ if (fluidsCost == null || index < 0 || index >= fluidsCost.length) {
+ return null;
+ }
+
+ FluidStack fluid = fluidsCost[index].copy();
+ fluid.amount *= getTotalStages();
+ return fluid;
+ }
+
+ @Override
+ public ISP_Upgrade getUpgradeBeingBuilt() {
+ return currentUpgrade;
+ }
+
+ @Override
+ public ISpaceBody getProjectLocation() {
+ return location;
+ }
+
+ @Override
+ public UITexture getTexture() {
+ return texture;
+ }
+
+ // #endregion
+
+ // #region Setter/Builder
+
+ public SpaceProject setProjectName(String spaceProjectName) {
+ name = spaceProjectName;
+ return this;
+ }
+
+ public SpaceProject setProjectUnlocalizedName(String spaceProjectUnlocalizedName) {
+ unlocalizedName = spaceProjectUnlocalizedName;
+ return this;
+ }
+
+ public SpaceProject setProjectVoltage(long spaceProjectVoltage) {
+ voltage = spaceProjectVoltage;
+ return this;
+ }
+
+ public SpaceProject setProjectBuildTime(int spaceProjectBuildTime) {
+ buildTime = spaceProjectBuildTime;
+ return this;
+ }
+
+ public SpaceProject setProjectStages(int spaceProjectTotalStages) {
+ totalStage = spaceProjectTotalStages;
+ return this;
+ }
+
+ public SpaceProject setProjectItemsCost(ItemStack... spaceProjectItemsCost) {
+ itemsCost = spaceProjectItemsCost;
+ return this;
+ }
+
+ public SpaceProject setProjectFluidsCost(FluidStack... spaceProjectFluidsCost) {
+ fluidsCost = spaceProjectFluidsCost;
+ return this;
+ }
+
+ public SpaceProject setProjectUpgrades(ISP_Upgrade... spaceProjectUpgrades) {
+ for (ISP_Upgrade upgrade : spaceProjectUpgrades) {
+ upgradesAvailable.put(upgrade.getUpgradeName(), upgrade);
+ }
+ return this;
+ }
+
+ public SpaceProject setProjectTexture(UITexture projectTexture) {
+ texture = projectTexture;
+ return this;
+ }
+
+ public SpaceProject setProjectRequirements(ISP_Requirements projectRequirements) {
+ requirements = projectRequirements;
+ return this;
+ }
+
+ @Override
+ public void setCurrentUpgradeBeingBuilt(ISP_Upgrade newCurrentUpgrade) {
+ if (newCurrentUpgrade == null) {
+ return;
+ }
+
+ if (totalStage == currentStage) {
+ currentUpgrade = newCurrentUpgrade.copy();
+ currentUpgrade.setUpgradeProject(this);
+ }
+ }
+
+ @Override
+ public void setProjectCurrentStage(int newCurrentStage) {
+ currentStage = newCurrentStage;
+ }
+
+ @Override
+ public void setProjectLocation(ISpaceBody newLocation) {
+ location = newLocation;
+ }
+
+ @Override
+ public void setBuiltUpgrade(ISP_Upgrade... upgrades) {
+ if (upgrades == null) {
+ return;
+ }
+
+ for (ISP_Upgrade upgrade : upgrades) {
+ upgradesInstalled.put(upgrade.getUpgradeName(), upgrade);
+ }
+ }
+
+ // #endregion
+
+ // #region Other
+
+ @Override
+ public ISpaceProject copy() {
+ SpaceProject copy = new SpaceProject().setProjectName(name).setProjectUnlocalizedName(unlocalizedName)
+ .setProjectVoltage(voltage).setProjectBuildTime(buildTime).setProjectItemsCost(itemsCost)
+ .setProjectFluidsCost(fluidsCost).setProjectStages(totalStage).setProjectTexture(texture)
+ .setProjectRequirements(requirements);
+ if (upgradesAvailable != null) {
+ ISP_Upgrade[] upgrades = new SP_Upgrade[upgradesAvailable.size()];
+ int index = 0;
+ for (ISP_Upgrade upgrade : upgradesAvailable.values()) {
+ upgrades[index++] = upgrade.copy();
+ }
+ copy.setProjectUpgrades(upgrades);
+ }
+ return copy;
+ }
+
+ @Override
+ public void goToNextStage() {
+ currentStage++;
+ }
+
+ @Override
+ public boolean meetsRequirements(UUID team) {
+ return meetsRequirements(team, true);
+ }
+
+ @Override
+ public boolean meetsRequirements(UUID team, boolean checkLocation) {
+ if (requirements == null) {
+ return true;
+ }
+
+ if (requirements.getBodyType() != null && checkLocation) {
+ if (!requirements.getBodyType().equals(location.getType())) {
+ return false;
+ }
+ }
+
+ if (requirements.getStarType() != null && checkLocation) {
+ if (!requirements.getStarType().equals(location.getStarType())) {
+ return false;
+ }
+ }
+
+ if (requirements.getProjects() != null) {
+ for (ISpaceProject project : requirements.getProjects()) {
+ if (!SpaceProjectManager.teamHasProject(team, project)) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof SpaceProject)) {
+ return false;
+ }
+ return getProjectName().equals(((SpaceProject) obj).getProjectName());
+ }
+
+ @Override
+ public boolean isFinished() {
+ return currentStage == totalStage;
+ }
+
+ @Override
+ public boolean hasUpgrade(String upgradeName) {
+ return upgradesInstalled.containsKey(upgradeName);
+ }
+
+ // #endregion
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/commands/SPM_Command.java b/src/main/java/gregtech/common/misc/spaceprojects/commands/SPM_Command.java
new file mode 100644
index 0000000000..c7346319a9
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/commands/SPM_Command.java
@@ -0,0 +1,233 @@
+package gregtech.common.misc.spaceprojects.commands;
+
+import static gregtech.common.misc.spaceprojects.SpaceProjectManager.getLocation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+import net.minecraft.command.CommandBase;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.ChatComponentText;
+
+import gregtech.common.misc.spaceprojects.SpaceProjectManager;
+import gregtech.common.misc.spaceprojects.SpaceProjectWorldSavedData;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject;
+
+/**
+ * @author BlueWeabo
+ */
+public class SPM_Command extends CommandBase {
+
+ private static final String RESET = "reset";
+ private static final String UNLOCK = "unlock";
+ private static final String LOCK = "lock";
+ private static final String LIST = "list";
+ private static final String ALL = "-all";
+ private static final String AVAILABLE = "-available";
+ private static final String UNLOCKED = "-unlocked";
+ private static final String COPY = "copy";
+
+ @Override
+ public String getCommandName() {
+ return "spm";
+ }
+
+ @Override
+ public int getRequiredPermissionLevel() {
+ return 0;
+ }
+
+ @Override
+ public String getCommandUsage(ICommandSender sender) {
+ return "/" + this.getCommandName() + " <subCommand>. Available subCommands: reset, unlock, lock, list, copy";
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] arguments) {
+ if (arguments.length < 1) {
+ printHelp(sender);
+ return;
+ }
+ switch (arguments[0]) {
+ case RESET:
+ if (!sender.canCommandSenderUseCommand(4, getCommandName())) {
+ sender.addChatMessage(
+ new ChatComponentText("You don't have the permissions to execute this command"));
+ return;
+ }
+ processReset(sender, arguments.length >= 2 ? arguments[1] : sender.getCommandSenderName());
+ break;
+ case UNLOCK:
+ if (!sender.canCommandSenderUseCommand(4, getCommandName())) {
+ sender.addChatMessage(
+ new ChatComponentText("You don't have the permissions to execute this command"));
+ return;
+ }
+ if (arguments.length < 3) {
+ sender.addChatMessage(
+ new ChatComponentText("Not enough arguments. Needs to mention a project and a location"));
+ return;
+ }
+ processUnlock(
+ sender,
+ arguments[1],
+ arguments[2],
+ arguments.length >= 4 ? arguments[3] : sender.getCommandSenderName());
+ break;
+ case LOCK:
+ if (!sender.canCommandSenderUseCommand(4, getCommandName())) {
+ sender.addChatMessage(
+ new ChatComponentText("You don't have the permissions to execute this command"));
+ return;
+ }
+ if (arguments.length < 3) {
+ sender.addChatMessage(
+ new ChatComponentText("Not enough arguments. Needs to mention a project and a location"));
+ return;
+ }
+ processLock(
+ sender,
+ arguments[1],
+ arguments[2],
+ arguments.length >= 4 ? arguments[3] : sender.getCommandSenderName());
+ case LIST:
+ if (arguments.length < 2) {
+ sender.addChatMessage(
+ new ChatComponentText(
+ "No Argument for list subCommand. Usage /spm list -all, -available or -unlocked"));
+ return;
+ }
+ processList(sender, arguments[1], arguments.length >= 3 ? arguments[2] : sender.getCommandSenderName());
+ break;
+ case COPY:
+ if (!sender.canCommandSenderUseCommand(4, getCommandName())) {
+ sender.addChatMessage(
+ new ChatComponentText("You don't have the permissions to execute this command"));
+ return;
+ }
+ if (arguments.length < 3) {
+ sender.addChatMessage(new ChatComponentText("Not enough arguments. Needs to mention 2 players"));
+ return;
+ }
+ processCopy(sender, arguments[1], arguments[2]);
+ break;
+ }
+ }
+
+ @Override
+ public List<String> addTabCompletionOptions(ICommandSender sender, String[] arguments) {
+ List<String> autoComplete = new ArrayList<>();
+ String filter = arguments.length == 0 ? "" : arguments[0].trim();
+ switch (arguments.length) {
+ case 1:
+ autoComplete.addAll(Arrays.asList(getSubCommands()));
+ break;
+ case 2:
+ filter = arguments.length == 1 ? "" : arguments[1].trim();
+ if (arguments[0].equals(LIST)) {
+ autoComplete.addAll(Arrays.asList(getListArguments()));
+ } else if (arguments[0].equals(COPY) || arguments[0].equals(RESET)) {
+ autoComplete.addAll(Arrays.asList(getPlayers()));
+ } else {
+ autoComplete.addAll(Arrays.asList(getProjects()));
+ }
+ break;
+ case 3:
+ filter = arguments.length == 2 ? "" : arguments[2].trim();
+ if (arguments[1].equals(ALL)) {
+ break;
+ } else if (arguments[0].equals(LIST)) {
+ autoComplete.addAll(Arrays.asList(getPlayers()));
+ } else {
+ autoComplete.addAll(Arrays.asList(getLocations()));
+ }
+ break;
+ case 4:
+ filter = arguments.length == 3 ? "" : arguments[3].trim();
+ autoComplete.addAll(Arrays.asList(getPlayers()));
+ break;
+ }
+ String finalFilter = filter;
+ return autoComplete.stream().filter(s -> finalFilter.isEmpty() || s.startsWith(finalFilter))
+ .collect(Collectors.toList());
+ }
+
+ private String[] getPlayers() {
+ return MinecraftServer.getServer().getAllUsernames();
+ }
+
+ private String[] getLocations() {
+ return SpaceProjectManager.getLocationNames().toArray(new String[0]);
+ }
+
+ private String[] getProjects() {
+ return SpaceProjectManager.getProjectsMap().keySet().toArray(new String[0]);
+ }
+
+ private String[] getSubCommands() {
+ return new String[] { RESET, COPY, UNLOCK, LOCK, LIST };
+ }
+
+ private String[] getListArguments() {
+ return new String[] { ALL, AVAILABLE, UNLOCKED };
+ }
+
+ private void processReset(ICommandSender sender, String playerName) {
+ SpaceProjectManager.spaceTeamProjects.clear();
+ SpaceProjectWorldSavedData.INSTANCE.markDirty();
+ sender.addChatMessage(new ChatComponentText("Cleared away map"));
+ }
+
+ private void processLock(ICommandSender sender, String projectName, String location, String playerName) {
+ UUID tID = SpaceProjectManager.getPlayerUUIDFromName(playerName);
+ SpaceProjectManager.addTeamProject(tID, getLocation(location), projectName, null);
+ sender.addChatMessage(new ChatComponentText("Project locked"));
+ }
+
+ private void processUnlock(ICommandSender sender, String projectName, String location, String playerName) {
+ UUID tID = SpaceProjectManager.getPlayerUUIDFromName(playerName);
+ ISpaceProject tProject = SpaceProjectManager.getProject(projectName);
+ if (tProject != null) {
+ tProject.setProjectCurrentStage(tProject.getTotalStages());
+ SpaceProjectManager.addTeamProject(tID, getLocation(location), projectName, tProject);
+ sender.addChatMessage(new ChatComponentText("Project unlocked"));
+ } else {
+ sender.addChatMessage(new ChatComponentText("Incorrect internal project name. Try again"));
+ }
+ }
+
+ private void processList(ICommandSender sender, String argument, String playerName) {
+ UUID tID = SpaceProjectManager.getPlayerUUIDFromName(playerName);
+ switch (argument) {
+ case ALL:
+ for (String project : SpaceProjectManager.getProjectsMap().keySet()) {
+ sender.addChatMessage(new ChatComponentText(project));
+ }
+ break;
+ case AVAILABLE:
+ for (ISpaceProject project : SpaceProjectManager.getAllProjects()) {
+ if (project.meetsRequirements(tID, false)) {
+ sender.addChatMessage(new ChatComponentText(project.getProjectName()));
+ }
+ }
+ break;
+ case UNLOCKED:
+ for (ISpaceProject project : SpaceProjectManager.getTeamSpaceProjects(tID)) {
+ sender.addChatMessage(new ChatComponentText(project.getProjectName()));
+ }
+ break;
+ }
+ }
+
+ private void processCopy(ICommandSender sender, String playerToCopyFrom, String playerCopyingTo) {
+ // This will take a while
+ }
+
+ private void printHelp(ICommandSender sender) {
+
+ }
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/commands/SP_Command.java b/src/main/java/gregtech/common/misc/spaceprojects/commands/SP_Command.java
new file mode 100644
index 0000000000..ba673640c2
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/commands/SP_Command.java
@@ -0,0 +1,120 @@
+package gregtech.common.misc.spaceprojects.commands;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import net.minecraft.command.CommandBase;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.util.EnumChatFormatting;
+
+import org.apache.commons.lang3.tuple.Pair;
+
+import gregtech.api.util.GT_Utility;
+import gregtech.common.misc.spaceprojects.SpaceProjectManager;
+
+/**
+ * @author BlueWeabo
+ */
+public class SP_Command extends CommandBase {
+
+ private static Set<Pair<EntityPlayerMP, EntityPlayerMP>> invite = Collections
+ .newSetFromMap(new WeakHashMap<Pair<EntityPlayerMP, EntityPlayerMP>, Boolean>());
+ private static Set<EntityPlayerMP> confirm = Collections.newSetFromMap(new WeakHashMap<EntityPlayerMP, Boolean>());
+
+ private static final String INVITE = "invite";
+ private static final String ACCEPT = "accept";
+ private static final String LEAVE = "leave";
+ private static final String CONFIRM = "confirm";
+
+ @Override
+ public String getCommandName() {
+ return "sp";
+ }
+
+ @Override
+ public int getRequiredPermissionLevel() {
+ return 0;
+ }
+
+ @Override
+ public String getCommandUsage(ICommandSender sender) {
+ return "/" + getCommandName() + "<subCommand> [PlayerName]";
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] arguments) {
+ if (arguments.length < 1) {
+ return;
+ }
+ switch (arguments[0]) {
+ case INVITE:
+ if (arguments.length < 2) {
+ return;
+ }
+ processInvite(sender, arguments[1]);
+ break;
+ case ACCEPT:
+ if (arguments.length < 2) {
+ return;
+ }
+ processAccept(sender, arguments[1]);
+ break;
+ case LEAVE:
+ processLeave(sender);
+ break;
+ case CONFIRM:
+ processConfirm(sender);
+ break;
+ }
+ }
+
+ private void processInvite(ICommandSender sender, String playerInvited) {
+ EntityPlayerMP teamLeader = getCommandSenderAsPlayer(sender);
+ EntityPlayerMP teamMember = getPlayer(sender, playerInvited);
+ invite.add(Pair.of(teamMember, teamLeader));
+ String message = EnumChatFormatting.GOLD + teamLeader.getCommandSenderName()
+ + EnumChatFormatting.RESET
+ + " has sent you an invite to join their team. Accept it with"
+ + EnumChatFormatting.GOLD
+ + " /sp accept "
+ + teamLeader.getCommandSenderName();
+ GT_Utility.sendChatToPlayer(teamMember, message);
+ }
+
+ private void processAccept(ICommandSender sender, String playerInviter) {
+ EntityPlayerMP teamMember = getCommandSenderAsPlayer(sender);
+ EntityPlayerMP teamLeader = getPlayer(sender, playerInviter);
+ if (invite.contains(Pair.of(teamMember, teamLeader))) {
+ String message = EnumChatFormatting.GOLD + teamMember.getCommandSenderName()
+ + EnumChatFormatting.RESET
+ + " has accepted the invite.";
+ SpaceProjectManager.putInTeam(teamMember.getUniqueID(), teamLeader.getUniqueID());
+ GT_Utility.sendChatToPlayer(teamLeader, message);
+ invite.remove(Pair.of(teamMember, teamLeader));
+ }
+ }
+
+ private void processLeave(ICommandSender sender) {
+ EntityPlayerMP player = getCommandSenderAsPlayer(sender);
+ String message = "Are you sure you want to leave the team. You will lose all progress. Use "
+ + EnumChatFormatting.GOLD
+ + "/sp confirm"
+ + EnumChatFormatting.RESET
+ + " to confirm this. This does nothing if you are the team leader.";
+ GT_Utility.sendChatToPlayer(player, message);
+ confirm.add(player);
+ }
+
+ private void processConfirm(ICommandSender sender) {
+ EntityPlayerMP player = getCommandSenderAsPlayer(sender);
+ if (confirm.contains(player)) {
+ String message = "Successfully left the team.";
+ SpaceProjectManager.putInTeam(player.getUniqueID(), player.getUniqueID());
+ GT_Utility.sendChatToPlayer(player, message);
+ confirm.remove(player);
+ }
+ }
+
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/enums/JsonVariables.java b/src/main/java/gregtech/common/misc/spaceprojects/enums/JsonVariables.java
new file mode 100644
index 0000000000..665f15af74
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/enums/JsonVariables.java
@@ -0,0 +1,22 @@
+package gregtech.common.misc.spaceprojects.enums;
+
+public class JsonVariables {
+
+ public static final String PAIR_LEFT = "pairLeft";
+ public static final String PAIR_RIGHT = "pairRight";
+
+ public static final String MAP_UUID = "mapUUID";
+ public static final String MAP_MAP = "mapMap";
+ public static final String MAP_PAIR = "mapPair";
+ public static final String MAP_PROJECT = "mapProject";
+
+ public static final String PROJECT_NAME = "projectName";
+ public static final String PROJECT_CURRENT_STAGE = "projectCurrentStage";
+ public static final String PROJECT_UPGRADES_BUILT = "projectUpgradesBuilt";
+ public static final String PROJECT_LOCATION = "projectLocation";
+ public static final String PROJECT_CURRENT_UPGRADE = "projectCurrentUpgrade";
+
+ public static final String UPGRADE_NAME = "upgradeName";
+ public static final String UPGRADE_CURRENT_STAGE = "upgradeCurrentStage";
+ public static final String UPGRADE_PROJECT_PARENT = "upgradeProjectParent";
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/enums/SolarSystem.java b/src/main/java/gregtech/common/misc/spaceprojects/enums/SolarSystem.java
new file mode 100644
index 0000000000..7d0c4cee3e
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/enums/SolarSystem.java
@@ -0,0 +1,96 @@
+package gregtech.common.misc.spaceprojects.enums;
+
+import static gregtech.common.misc.spaceprojects.enums.SpaceBodyType.*;
+import static gregtech.common.misc.spaceprojects.enums.StarType.*;
+
+import com.gtnewhorizons.modularui.api.drawable.UITexture;
+
+import gregtech.common.misc.spaceprojects.SpaceProjectManager;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceBody;
+
+/**
+ * An enum of all space bodies in the Sol Solar System. Or to be exact the more important ones
+ *
+ * @author BlueWeabo
+ */
+public enum SolarSystem implements ISpaceBody {
+
+ Sol(Star, GClass),
+ Overworld(Planet),
+ Moon(NaturalSatellite),
+ Mars(Planet),
+ Deimos(NaturalSatellite),
+ Phobos(NaturalSatellite),
+ Mercury(Planet),
+ Venus(Planet),
+ Jupiter(GasGiant),
+ Io(NaturalSatellite),
+ Ganymede(NaturalSatellite),
+ Europa(NaturalSatellite),
+ Callisto(NaturalSatellite),
+ Saturn(GasGiant),
+ Mimas(NaturalSatellite),
+ Enceladus(NaturalSatellite),
+ Tethys(NaturalSatellite),
+ Rhea(NaturalSatellite),
+ Titan(NaturalSatellite),
+ Hyperion(NaturalSatellite),
+ Iapetus(NaturalSatellite),
+ Phoebe(NaturalSatellite),
+ Uranus(IceGiant),
+ Miranda(NaturalSatellite),
+ Ariel(NaturalSatellite),
+ Umbriel(NaturalSatellite),
+ Titania(NaturalSatellite),
+ Oberon(NaturalSatellite),
+ Neptune(IceGiant),
+ Proteus(NaturalSatellite),
+ Triton(NaturalSatellite),
+ Nereid(NaturalSatellite),
+ Ceres(DwarfPlanet),
+ Pluto(DwarfPlanet),
+ Arrokoth(DwarfPlanet),
+ MakeMake(DwarfPlanet),
+ KuiperBelt(AsteroidBelt),
+ NONE(SpaceBodyType.NONE);
+
+ private SpaceBodyType spaceBody;
+ private StarType star;
+ private UITexture texture;
+
+ SolarSystem(SpaceBodyType aType) {
+ this(aType, NotAStar);
+ }
+
+ SolarSystem(SpaceBodyType aType, StarType aStarType) {
+ star = aStarType;
+ spaceBody = aType;
+ texture = UITexture.fullImage("gregtech", "solarsystem/" + getName());
+ SpaceProjectManager.addLocation(this);
+ }
+
+ @Override
+ public StarType getStarType() {
+ return star;
+ }
+
+ @Override
+ public SpaceBodyType getType() {
+ return spaceBody;
+ }
+
+ @Override
+ public String getName() {
+ return name();
+ }
+
+ @Override
+ public UITexture getTexture() {
+ return texture;
+ }
+
+ @Override
+ public String getUnlocalizedName() {
+ return "gt.solar.system." + getName().toLowerCase();
+ }
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/enums/SpaceBodyType.java b/src/main/java/gregtech/common/misc/spaceprojects/enums/SpaceBodyType.java
new file mode 100644
index 0000000000..511c2c438e
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/enums/SpaceBodyType.java
@@ -0,0 +1,17 @@
+package gregtech.common.misc.spaceprojects.enums;
+
+/**
+ * @author BlueWeabo
+ */
+public enum SpaceBodyType {
+ Star,
+ NeutronStar,
+ Planet,
+ NaturalSatellite,
+ AsteroidBelt,
+ BlackHole,
+ GasGiant,
+ DwarfPlanet,
+ IceGiant,
+ NONE;
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/enums/StarType.java b/src/main/java/gregtech/common/misc/spaceprojects/enums/StarType.java
new file mode 100644
index 0000000000..abcb75d55b
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/enums/StarType.java
@@ -0,0 +1,32 @@
+package gregtech.common.misc.spaceprojects.enums;
+
+/**
+ * @author BlueWeabo
+ */
+public enum StarType {
+
+ OClass(30000, 100),
+ BClass(10000, 20),
+ AClass(20, 5),
+ FClass(4, 2),
+ GClass(1, 1),
+ KClass(0.4, 0.5f),
+ MClass(0.08, 0.1f),
+ NotAStar(0, 0);
+
+ private double solarLuminosity;
+ private float costMultiplier;
+
+ private StarType(double solarLuminosity, float costMultiplier) {
+ this.solarLuminosity = solarLuminosity;
+ this.costMultiplier = costMultiplier;
+ }
+
+ public double getSolarLuminosity() {
+ return solarLuminosity;
+ }
+
+ public float getCostMultiplier() {
+ return costMultiplier;
+ }
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/enums/UpgradeStatus.java b/src/main/java/gregtech/common/misc/spaceprojects/enums/UpgradeStatus.java
new file mode 100644
index 0000000000..d171d53c29
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/enums/UpgradeStatus.java
@@ -0,0 +1,11 @@
+package gregtech.common.misc.spaceprojects.enums;
+
+/**
+ * @author BlueWeabo
+ */
+public enum UpgradeStatus {
+ Locked,
+ Unlocked,
+ InProgress,
+ Finished;
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/interfaces/ISpaceBody.java b/src/main/java/gregtech/common/misc/spaceprojects/interfaces/ISpaceBody.java
new file mode 100644
index 0000000000..79eba4c968
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/interfaces/ISpaceBody.java
@@ -0,0 +1,37 @@
+package gregtech.common.misc.spaceprojects.interfaces;
+
+import com.gtnewhorizons.modularui.api.drawable.UITexture;
+
+import gregtech.common.misc.spaceprojects.enums.SpaceBodyType;
+import gregtech.common.misc.spaceprojects.enums.StarType;
+
+/**
+ * @author BlueWeabo
+ */
+public interface ISpaceBody {
+
+ /**
+ * @return The star type of the space body, if its a star
+ */
+ StarType getStarType();
+
+ /**
+ * @return The type of space body it is
+ */
+ SpaceBodyType getType();
+
+ /**
+ * @return The internal name of the space body
+ */
+ String getName();
+
+ /**
+ * @return The texture of the space body used for UI
+ */
+ UITexture getTexture();
+
+ /**
+ * @return The Unlocalized name for this body
+ */
+ String getUnlocalizedName();
+}
diff --git a/src/main/java/gregtech/common/misc/spaceprojects/interfaces/ISpaceProject.java b/src/main/java/gregtech/common/misc/spaceprojects/interfaces/ISpaceProject.java
new file mode 100644
index 0000000000..3de3ef2b94
--- /dev/null
+++ b/src/main/java/gregtech/common/misc/spaceprojects/interfaces/ISpaceProject.java
@@ -0,0 +1,430 @@
+package gregtech.common.misc.spaceprojects.interfaces;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+import com.gtnewhorizons.modularui.api.drawable.UITexture;
+
+import gregtech.common.misc.spaceprojects.enums.SpaceBodyType;
+import gregtech.common.misc.spaceprojects.enums.StarType;
+import gregtech.common.misc.spaceprojects.enums.UpgradeStatus;
+
+/**
+ * @author BlueWeabo
+ */
+public interface ISpaceProject {
+
+ /**
+ * @return the internal name of the project.
+ */
+ String getProjectName();
+
+ /**
+ * @return Unlocalized name of the project.
+ */
+ String getUnlocalizedName();
+
+ /**
+ * @return Localized name of the project using StatCollect#translateToLocal.
+ */
+ String getLocalizedName();
+
+ /**
+ * @return The voltage the project requires to be built at. Used by the project manager.
+ */
+ long getProjectVoltage();
+
+ /**
+ * @return The duration it takes to build out one(1) stage of the project. The time returned is in ticks
+ */
+ int getProjectBuildTime();
+
+ /**
+ * @return The Current Progress of the project in percentage form. 1 being 100% and 0 being 0%.
+ */
+ float getProjectCurrentProgress();
+
+ /**
+ * @return Currently unused, but this is the project's tier. Will be used to determine the min-tier motors needed on
+ * the Space Elevator
+ */
+ int getProjectTier();
+
+ /**
+ * @return The Current stage of the project
+ */
+ int getCurrentStage();
+
+ /**
+ * @return The Total amount of stages the project has
+ */
+ int getTotalStages();
+
+ /**
+ * @return a Collection of all upgrades the project has
+ */
+ Collection<ISP_Upgrade> getAllUpgrades();
+
+ /**
+ * @return a Map of all upgrades that have been built.
+ */
+ Map<String, ISP_Upgrade> getUpgradesBuiltMap();
+
+ /**
+ * @return
+ */
+ Collection<ISP_Upgrade> getAllBuiltUpgrades();
+
+ /**
+ * @param upgradeName The name of the upgrade wanted
+ * @return The upgrade with the appropriate name found in the available upgrades for the project
+ */
+ ISP_Upgrade getUpgrade(String upgradeName);
+
+ /**
+ * @return The Items cost required per stage in an array form. Used for making the recipe.
+ */
+ ItemStack[] getItemsCostPerStage();
+
+ /**
+ * @param index Index at which the itemstack is found at
+ * @return an item's cost at the appropriate index. Null otherwise if it goes above the index or there are no item
+ * costs
+ */
+ ItemStack getItemCostPerStage(int index);
+
+ /**
+ * @return The Items current progress in an array form.
+ */
+ ItemStack[] getCurrentItemsProgress();
+
+ /**
+ * @param index Index at which the itemstack is found at
+ * @return an item's current progress at the appropriate index. Null otherwise if it goes above the index or there
+ * are no item costs
+ */
+ ItemStack getCurrentItemProgress(int index);
+
+ /**
+ * @return The items total cost required in an array form.
+ */
+ ItemStack[] getTotalItemsCost();
+
+ /**
+ * @param index Index at which the itemstack is found at
+ * @return an item's total cost at the appropriate index. Null otherwise if it goes above the index or there are no
+ * item costs
+ */
+ ItemStack getTotalItemCost(int index);
+
+ /**
+ * @return The fluids cost required per stage in an array form. Used for making the recipe.
+ */
+ FluidStack[] getFluidsCostPerStage();
+
+ /**
+ * @param index Index at which the fluidstack is found at
+ * @return a fluid's cost at the appropriate index. Null otherwise if it goes above the index or there are no fluid
+ * costs
+ */
+ FluidStack getFluidCostPerStage(int index);
+
+ /**
+ * @return The fluids current progress in an array form. Null if there are no fluid costs
+ */
+ FluidStack[] getCurrentFluidsProgress();
+
+ /**
+ * @param index Index at which the fluidstack is found at
+ * @return a fluid's current progress at the appropriate index. Null otherwise if it goes above the index or there
+ * are no fluid costs
+ */
+ FluidStack getCurrentFluidProgress(int index);
+
+ /**
+ * @return The fluids total cost required in an array form. Null if there are no fluid costs
+ */
+ FluidStack[] getTotalFluidsCost();
+
+ /**
+ * @param index Index at which the fluidstack is found at
+ * @return a fluid's total cost at the appropriate index. Null otherwise if it goes above the index or there are no
+ * fluid costs
+ */
+ FluidStack getTotalFluidCost(int index);
+
+ /**
+ * @return The current upgrade for this project, which is being built
+ */
+ ISP_Upgrade getUpgradeBeingBuilt();
+
+ /**
+ * @return The location of the project
+ */
+ ISpaceBody getProjectLocation();
+
+ /**
+ * @return The texture used in GUIs for the project
+ */
+ UITexture getTexture();
+
+ /**
+ * Sets the current stage of the project
+ */
+ void setProjectCurrentStage(int stage);
+
+ /**
+ * Sets the current upgrade, which needs to be built
+ */
+ void setCurrentUpgradeBeingBuilt(ISP_Upgrade upgrade);
+
+ /**
+ * Sets the project's location when it starts being built
+ */
+ void setProjectLocation(ISpaceBody newLocation);
+
+ /**
+ * Sets the project's upgrades, which have been built
+ */
+ void setBuiltUpgrade(ISP_Upgrade... upgrades);
+
+ /**
+ * Goes to the next stage of the project
+ */
+ void goToNextStage();
+
+ /**
+ * Creates a copy of the space project
+ */
+ ISpaceProject copy();
+
+ /**
+ * Checks if the project meets all requirements with its current location
+ *
+ * @param team Team wanting said project and checking their projects
+ * @return true if all requirements met, false otherwise
+ */
+ boolean meetsRequirements(UUID team);
+
+ /**
+ * Checks if the project meets requirements if it requires other projects, unless {@code checkLocation} is true,
+ * then it also checks for the location
+ *
+ * @param team Team wanting said project and checking their projects
+ * @param checkLocation If the location position should be checked
+ * @return true if all requirements met, false otherwise
+ */
+ boolean meetsRequirements(UUID team, boolean checkLocation);
+
+ /**
+ * Checks if the projects is finished
+ */
+ boolean isFinished();
+
+ /**
+ * Checks if the project has a certain upgrade installed or not
+ *
+ * @param upgradeName Upgrade being searched for
+ * @return True if that upgrade has been installed, false otherwise
+ */
+ boolean hasUpgrade(String upgradeName);
+
+ /**
+ * @author BlueWeabo
+ */
+ public interface ISP_Upgrade {
+
+ /**
+ * @return internal name of the upgrade
+ */
+ String getUpgradeName();
+
+ /**
+ * @return unlocalized name of the upgrade
+ */
+ String getUnlocalizedName();
+
+ /**
+ * @return localized name of the upgrade
+ */
+ String getLocalizedName();
+
+ /**
+ * @return The Items cost required per stage in an array form. Used for making the recipe.
+ */
+ ItemStack[] getItemsCostPerStage();
+
+ /**
+ * @param index Index at which the itemstack is found at
+ * @return an item's cost at the appropriate index. Null otherwise if it goes above the index or there are no
+ * item costs
+ */
+ ItemStack getItemCostPerStage(int index);
+
+ /**
+ * @return The Items current progress in an array form.
+ */
+ ItemStack[] getCurrentItemsProgress();
+
+ /**
+ * @param index Index at which the itemstack is found at
+ * @return an item's current progress at the appropriate index. Null otherwise if it goes above the index or
+ * there are no item costs
+ */
+ ItemStack getCurrentItemProgress(int index);
+
+ /**
+ * @return The items total cost required in an array form.
+ */
+ ItemStack[] getTotalItemsCost();
+
+ /**
+ * @param index Index at which the itemstack is found at
+ * @return an item's total cost at the appropriate index. Null otherwise if it goes above the index or there are
+ * no item costs
+ */
+ ItemStack getTotalItemCost(int index);
+
+ /**
+ * @return The fluids cost required per stage in an array form. Used for making the recipe.
+ */
+ FluidStack[] getFluidsCostPerStage();
+
+ /**
+ * @param index Index at which the fluidstack is found at
+ * @return a fluid's cost at the appropriate index. Null otherwise if it goes above the index or there are no
+ * fluid costs
+ */
+ FluidStack getFluidCostPerStage(int index);
+
+ /**
+ * @return The fluids current progress in an array form. Null if there are no fluid costs
+ */
+ FluidStack[] getCurrentFluidsProgress();
+
+ /**
+ * @param index Index at which the fluidstack is found at
+ * @return a fluid's current progress at the appropriate index. Null otherwise if it goes above the index or
+ * there are no fluid costs
+ */
+ FluidStack getCurrentFluidProgress(int index);
+
+ /**
+ * @return The fluids total cost required in an array form. Null if there are no fluid costs
+ */
+ FluidStack[] getTotalFluidsCost();
+
+ /**
+ * @param index Index at which the fluidstack is found at
+ * @return a fluid's total cost at the appropriate index. Null otherwise if it goes above the index or there are
+ * no fluid costs
+ */
+ FluidStack getTotalFluidCost(int index);
+
+ /**
+ * @return the total stages an upgrade has
+ */
+ int getTotalStages();
+
+ /**
+ * @return the build time for the upgrade to go to its next stage
+ */
+ int getUpgradeBuildTime();
+
+ /**
+ * @return current stage of the upgrade
+ */
+ int getCurrentStage();
+
+ /**
+ * @return The Current Progress of the upgrade in percentage form. 1 being 100% and 0 being 0%.
+ */
+ float getCurrentProgress();
+
+ /**
+ * @return The voltage at which the upgrade requires to be build at.
+ */
+ long getVoltage();
+
+ /**
+ * Unused, unsure if it will get a sure
+ */
+ UpgradeStatus getStatus();
+
+ /**
+ * @return the requirements the upgrade has
+ */
+ ISP_Requirements getUpgradeRequirements();
+
+ /**
+ * @return the parent project, which the upgrade belongs to
+ */
+ ISpaceProject getParentProject();
+
+ /**
+ * @param project The project the upgrade belongs to
+ */
+ void setUpgradeProject(ISpaceProject project);
+
+ /**
+ * Sets the current stage of the upgrade
+ *
+ * @param stage
+ */
+ void setUpgradeCurrentStage(int stage);
+
+ /**
+ * Checks if the team has met all requirements to be able to build said upgrade
+ *
+ * @param team The one starting the upgrade
+ * @return true if all requirements are met, false otherwise
+ */
+ boolean meetsRequirements(UUID team);
+
+ /**
+ * Creates a copy of the upgrade
+ */
+ ISP_Upgrade copy();
+
+ /**
+ * Goes to the next stage of the upgrade
+ */
+ void goToNextStage();
+
+ /**
+ * @return true if the upgrade has finished all of its stages, false otherwise
+ */
+ boolean isFinished();
+ }
+
+ /**
+ * @author BlueWeabo
+ */
+ public interface ISP_Requirements {
+
+ /**
+ * @return Space Body Type required by the project/upgrade
+ */
+ SpaceBodyType getBodyType();
+
+ /**
+ * @return Star Type required by the project/upgrade
+ */
+ StarType getStarType();
+
+ /**
+ * @return a list of all project required for the team to have to unlock it
+ */
+ List<ISpaceProject> getProjects();
+
+ /**
+ * @return a list of all upgrades an upgrade can have as required.
+ */
+ List<ISP_Upgrade> getUpgrades();
+ }
+}