Skip to content

Commit

Permalink
Merge pull request #87 from Prometheus0000/GTNH
Browse files Browse the repository at this point in the history
Add 1.7.10 GTNH compatibility
  • Loading branch information
MauveCloud authored Nov 22, 2020
2 parents 39fb604 + 967aba9 commit 9118151
Show file tree
Hide file tree
Showing 19 changed files with 518 additions and 49 deletions.
76 changes: 57 additions & 19 deletions src/Ic2ExpReactorPlanner/Bundle.properties

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions src/Ic2ExpReactorPlanner/ComponentFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,29 @@ private ComponentFactory() {
new CoolantCell(33, "coolantCellNak180k", getI18n("ComponentName.CoolantCell180kNak"), TextureFactory.getImage("gt.180k_NaK_Coolantcell.png"), 1, 180e3, "GT5.08"),
new CoolantCell(34, "coolantCellNak360k", getI18n("ComponentName.CoolantCell360kNak"), TextureFactory.getImage("gt.360k_NaK_Coolantcell.png"), 1, 360e3, "GT5.08"),
new Reflector(35, "iridiumNeutronReflector", getI18n("ComponentName.IridiumNeutronReflector"), TextureFactory.getImage("gt.neutronreflector.png", "neutron_reflector.png"), 1, 1, null),
new FuelRod(36, "fuelRodNaquadah", getI18n("ComponentName.FuelRodNaquadah"), TextureFactory.getImage("gt.Naquadahcell.png"), 100e3, 1, "GT5.09", 100, 2, 1, true),
new FuelRod(37, "dualFuelRodNaquadah", getI18n("ComponentName.DualFuelRodNaquadah"), TextureFactory.getImage("gt.Double_Naquadahcell.png"), 100e3, 1, "GT5.09", 200, 4, 2, true),
new FuelRod(38, "quadFuelRodNaquadah", getI18n("ComponentName.QuadFuelRodNaquadah"), TextureFactory.getImage("gt.Quad_Naquadahcell.png"), 100e3, 1, "GT5.09", 400, 8, 4, true),
new FuelRod(36, "fuelRodNaquadah", getI18n("ComponentName.FuelRodNaquadah"), TextureFactory.getImage("gt.Naquadahcell.png"), 100e3, 1, "GT5.09", 100, 2, 1, true),
new FuelRod(37, "dualFuelRodNaquadah", getI18n("ComponentName.DualFuelRodNaquadah"), TextureFactory.getImage("gt.Double_Naquadahcell.png"), 100e3, 1, "GT5.09", 200, 4, 2, true),
new FuelRod(38, "quadFuelRodNaquadah", getI18n("ComponentName.QuadFuelRodNaquadah"), TextureFactory.getImage("gt.Quad_Naquadahcell.png"), 100e3, 1, "GT5.09", 400, 8, 4, true),
new FuelRod(39, "fuelRodCoaxium", getI18n("ComponentName.FuelRodCoaxium"), TextureFactory.getImage("coaxium_rod.png"), 20e3, 1, "Coaxium", 100, 0, 1, false),
new FuelRod(40, "dualFuelRodCoaxium", getI18n("ComponentName.DualFuelRodCoaxium"), TextureFactory.getImage("coaxium_rod_dual.png"), 20e3, 1, "Coaxium", 200, 0, 2, false),
new FuelRod(41, "quadFuelRodCoaxium", getI18n("ComponentName.QuadFuelRodCoaxium"), TextureFactory.getImage("coaxium_rod_quad.png"), 20e3, 1, "Coaxium", 400, 0, 4, false),
new FuelRod(42, "fuelRodCesium", getI18n("ComponentName.FuelRodCesium"), TextureFactory.getImage("coaxium_rod.png"), 10861, 1, "Coaxium", 200, 1, 1, false),
new FuelRod(43, "dualFuelRodCesium", getI18n("ComponentName.DualFuelRodCesium"), TextureFactory.getImage("coaxium_rod_dual.png"), 10861, 1, "Coaxium", 400, 6, 2, false),
new FuelRod(44, "quadFuelRodCesium", getI18n("ComponentName.QuadFuelRodCesium"), TextureFactory.getImage("coaxium_rod_quad.png"), 10861, 1, "Coaxium", 800, 24, 4, false),
new FuelRod(44, "quadFuelRodCesium", getI18n("ComponentName.QuadFuelRodCesium"), TextureFactory.getImage("coaxium_rod_quad.png"), 10861, 1, "Coaxium", 800, 24, 4, false),
new FuelRod(45, "fuelRodNaquadahGTNH", getI18n("ComponentName.FuelRodNaquadahGTNH"), TextureFactory.getImage("gt.Naquadahcell.png"), 100e3, 1, "GTNH", 100, 2, 1, false),//Naq rods are not MOX-like in GTNH,
new FuelRod(46, "dualFuelRodNaquadahGTNH", getI18n("ComponentName.DualFuelRodNaquadahGTNH"), TextureFactory.getImage("gt.Double_Naquadahcell.png"), 100e3, 1, "GTNH", 200, 4, 2, false),//we have naquadria for that
new FuelRod(47, "quadFuelRodNaquadahGTNH", getI18n("ComponentName.QuadFuelRodNaquadahGTNH"), TextureFactory.getImage("gt.Quad_Naquadahcell.png"), 100e3, 1, "GTNH", 400, 8, 4, false),
new FuelRod(48, "fuelRodNaquadria", getI18n("ComponentName.FuelRodNaquadria"), TextureFactory.getImage("gt.MNqCell.png"), 100e3, 1, "GTNH", 100, 2, 1, true),
new FuelRod(49, "dualFuelRodNaquadria", getI18n("ComponentName.DualFuelRodNaquadria"), TextureFactory.getImage("gt.Double_MNqCell.png"), 100e3, 1, "GTNH", 200, 4, 2, true),
new FuelRod(50, "quadFuelRodNaquadria", getI18n("ComponentName.QuadFuelRodNaquadria"), TextureFactory.getImage("gt.Quad_MNqCell.png"), 100e3, 1, "GTNH", 400, 8, 4, true),
new FuelRod(51, "fuelRodTiberium", getI18n("ComponentName.FuelRodTiberium"), TextureFactory.getImage("gt.Tiberiumcell.png"), 50e3, 1, "GTNH", 100, 1, 1, false),
new FuelRod(52, "dualFuelRodTiberium", getI18n("ComponentName.DualFuelRodTiberium"), TextureFactory.getImage("gt.Double_Tiberiumcell.png"), 50e3, 1, "GTNH", 200, 2, 2, false),
new FuelRod(53, "quadFuelRodTiberium", getI18n("ComponentName.QuadFuelRodTiberium"), TextureFactory.getImage("gt.Quad_Tiberiumcell.png"), 50e3, 1, "GTNH", 400, 4, 4, false),
new FuelRod(54, "fuelRodTheCore", getI18n("ComponentName.FuelRodTheCore"), TextureFactory.getImage("gt.Core_Reactor_Cell.png"), 100e3, 1, "GTNH", 72534, 816, 32, false),//had to reverse engineer, maybe
new CoolantCell(55, "coolantCellSpace180k", getI18n("ComponentName.CoolantCell180kSpace"), TextureFactory.getImage("gt.180k_Space_Coolantcell.png"), 1, 180e3, "GTNH"),//it works differently with so
new CoolantCell(56, "coolantCellSpace360k", getI18n("ComponentName.CoolantCell360kSpace"), TextureFactory.getImage("gt.360k_Space_Coolantcell.png"), 1, 360e3, "GTNH"),//many rods? Or I'm wrong
new CoolantCell(57, "coolantCellSpace540k", getI18n("ComponentName.CoolantCell540kSpace"), TextureFactory.getImage("gt.540k_Space_Coolantcell.png"), 1, 540e3, "GTNH"),
new CoolantCell(58, "coolantCellSpace1080k", getI18n("ComponentName.CoolantCell1080kSpace"), TextureFactory.getImage("gt.1080k_Space_Coolantcell.png"), 1, 1080e3, "GTNH"),
};

private static final Map<String, ReactorItem> ITEM_MAP = makeItemMap();
Expand Down
30 changes: 26 additions & 4 deletions src/Ic2ExpReactorPlanner/MaterialsList.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public final class MaterialsList {
public static final String ALUMINIUM = getI18n("MaterialName.Aluminium");
public static final String BERYLLIUM = getI18n("MaterialName.Beryllium");
public static final String BRONZE = getI18n("MaterialName.Bronze");
public static final String CALLISTOICEDUST = getI18n("MaterialName.CallistoIceDust");
public static final String CESIUM = getI18n("MaterialName.CesiumFuel");
public static final String COAL = getI18n("MaterialName.Coal");
public static final String COAXIUM = getI18n("MaterialName.CoaxiumFuel");
Expand All @@ -35,23 +36,30 @@ public final class MaterialsList {
public static final String DISTILLED_WATER = getI18n("MaterialName.DistilledWater");
// Since GT 5.09 allows different materials for making the "empty cell" (steel, tin, or PTFE), it is treated as a primitive material for GT recipes instead of a crafted item that can be further broken down.
public static final String EMPTY_CELL = getI18n("MaterialName.EmptyCell");
public static final String ENRICHEDNAQUADAH = getI18n("MaterialName.EnrichedNaquadah");
public static final String FLUXEDELECTRUM = getI18n("MaterialName.FluxedElectrum");//too long
public static final String GOLD = getI18n("MaterialName.Gold");
public static final String GRAPHITE = getI18n("MaterialName.Graphite");
public static final String HELIUM = getI18n("MaterialName.Helium");
public static final String GLASS = getI18n("MaterialName.Glass");
public static final String GLOWSTONE = getI18n("MaterialName.GlowstoneDust");
public static final String HELIUM = getI18n("MaterialName.Helium");
public static final String IRIDIUM = getI18n("MaterialName.Iridium");
public static final String IRON = getI18n("MaterialName.Iron");
public static final String LAPIS = getI18n("MaterialName.LapisLazuli");
public static final String LEAD = getI18n("MaterialName.Lead");
public static final String LEDOXDUST = getI18n("MaterialName.LedoxDust");
public static final String MOX = getI18n("MaterialName.MoxFuel");
public static final String NAQUADAH = getI18n("MaterialName.EnrichedNaquadah");
public static final String NAQUADRIA = getI18n("MaterialName.Naquadria");
public static final String PLATINUM = getI18n("MaterialName.Platinum");
public static final String POTASSIUM = getI18n("MaterialName.Potassium");
public static final String REDSTONE = getI18n("MaterialName.Redstone");
public static final String REINFORCEDGLASS = getI18n("MaterialName.ReinforcedGlass");//alt recipes
public static final String RUBBER = getI18n("MaterialName.Rubber");
public static final String SODIUM = getI18n("MaterialName.Sodium");
public static final String THORIUM = getI18n("MaterialName.Thorium");
public static final String TIBERIUM = getI18n("MaterialName.Tiberium");
public static final String TIN = getI18n("MaterialName.Tin");
public static final String TUNGSTEN = getI18n("MaterialName.Tungsten");
public static final String URANIUM = getI18n("MaterialName.UraniumFuel");

// Special materials lists for items that may expand differently.
Expand Down Expand Up @@ -215,7 +223,7 @@ public static MaterialsList getMaterialsForComponent(ReactorItem component) {
}

private static Map<String, MaterialsList> buildComponentMaterialsMap() {
Map<String, MaterialsList> result = new HashMap<>(50);
Map<String, MaterialsList> result = new HashMap<>(63);//result.put+2? Added 14, but I can't really tell if that's right
result.put("fuelRodUranium", new MaterialsList(IRON, URANIUM));
result.put("dualFuelRodUranium", new MaterialsList(IRON, 2, result.get("fuelRodUranium")));
result.put("quadFuelRodUranium", new MaterialsList(3, IRON, 2, COPPER, 4, result.get("fuelRodUranium")));
Expand Down Expand Up @@ -264,7 +272,7 @@ private static Map<String, MaterialsList> buildComponentMaterialsMap() {
result.put("coolantCellNak180k", new MaterialsList(3, result.get("coolantCellNak60k"), 6, TIN));
result.put("coolantCellNak360k", new MaterialsList(2, result.get("coolantCellNak180k"), 6, TIN, 9, COPPER));
result.put("iridiumNeutronReflector", new MaterialsList(6, result.get("thickNeutronReflector"), 18, COPPER, iridiumPlate));
result.put("fuelRodNaquadah", new MaterialsList(IRON, 3, NAQUADAH));
result.put("fuelRodNaquadah", new MaterialsList(IRON, 3, ENRICHEDNAQUADAH));
result.put("dualFuelRodNaquadah", new MaterialsList(IRON, 2, result.get("fuelRodNaquadah")));
result.put("quadFuelRodNaquadah", new MaterialsList(3, IRON, 2, COPPER, 4, result.get("fuelRodNaquadah")));
result.put("fuelRodCoaxium", new MaterialsList(4, IRIDIUM, 36, DIAMOND, 3, COAXIUM));
Expand All @@ -273,6 +281,20 @@ private static Map<String, MaterialsList> buildComponentMaterialsMap() {
result.put("fuelRodCesium", new MaterialsList(IRON, 3, CESIUM));
result.put("dualFuelRodCesium", new MaterialsList(IRON, 2, result.get("fuelRodCesium")));
result.put("quadFuelRodCesium", new MaterialsList(3, IRON, 2, COPPER, 4, result.get("fuelRodCesium")));
result.put("fuelRodNaquadahGTNH", new MaterialsList(4, IRON, 4, TUNGSTEN, 1, PLATINUM, 3, ENRICHEDNAQUADAH));
result.put("dualFuelRodNaquadahGTNH", new MaterialsList(IRON, TUNGSTEN, 2, result.get("fuelRodNaquadahGTNH")));
result.put("quadFuelRodNaquadahGTNH", new MaterialsList(3, IRON, 3, TUNGSTEN, 4, result.get("fuelRodNaquadahGTNH")));
result.put("fuelRodNaquadria", new MaterialsList(4, IRON, 4, TUNGSTEN, 1, PLATINUM, 3, NAQUADRIA));
result.put("dualFuelRodNaquadria", new MaterialsList(IRON, TUNGSTEN, 2, result.get("fuelRodNaquadria")));
result.put("quadFuelRodNaquadria", new MaterialsList(3, IRON, 3, TUNGSTEN, 4, result.get("fuelRodNaquadria")));
result.put("fuelRodTiberium", new MaterialsList(4, IRON, 4, TUNGSTEN, 1, PLATINUM, 3, TIBERIUM));
result.put("dualFuelRodTiberium", new MaterialsList(IRON, TUNGSTEN, 2, result.get("fuelRodTiberium")));
result.put("quadFuelRodTiberium", new MaterialsList(3, IRON, 3, TUNGSTEN, 4, result.get("fuelRodTiberium")));
result.put("fuelRodTheCore", new MaterialsList(96, IRON, 96, TUNGSTEN, 128, TIBERIUM, 32, result.get("fuelRodNaquadah")));
result.put("coolantCellSpace180k", new MaterialsList(0.5, CALLISTOICEDUST, 0.5, LEDOXDUST, 1000, DISTILLED_WATER, LAPIS, REINFORCEDGLASS, 2, IRON, 2, TUNGSTEN));
result.put("coolantCellSpace360k", new MaterialsList(1.5, IRON, 1.5, TUNGSTEN, 2, result.get("coolantCellSpace180k")));
result.put("coolantCellSpace540k", new MaterialsList(3, IRON, 3, TUNGSTEN, 3, result.get("coolantCellSpace180k")));
result.put("coolantCellSpace1080k", new MaterialsList(3, IRON, 3, TUNGSTEN, 9, FLUXEDELECTRUM, 3, result.get("coolantCellSpace540k")));

return result;
}
Expand Down
27 changes: 18 additions & 9 deletions src/Ic2ExpReactorPlanner/Reactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class Reactor {

// maximum paramatter types for a reactor component (current initial heat, automation threshold, reactor pause
private static final int MAX_PARAM_TYPES = 3;

public static final int MAX_COMPONENT_HEAT = 1_080_000;

public ReactorItem getComponentAt(final int row, final int column) {
if (row >= 0 && row < grid.length && column >= 0 && column < grid[row].length) {
Expand Down Expand Up @@ -498,8 +500,13 @@ private void readCodeString(final String code) {
BigintStorage storage = BigintStorage.inputBase64(code);
// read the code revision from the code itself instead of making it part of the prefix.
int codeRevision = storage.extract(255);
int maxComponentHeat;
if (codeRevision == 3)
maxComponentHeat = (int)1080e3;
else
maxComponentHeat = (int)360e3;
// Check if the code revision is supported yet.
if (codeRevision > 2) {
if (codeRevision > 3) {
throw new IllegalArgumentException("Unsupported code revision in reactor code.");
}
// for code revision 1 or newer, read whether the reactor is pulsed and/or automated next.
Expand All @@ -514,16 +521,18 @@ private void readCodeString(final String code) {
// Changes may be coming to the number of components available, so make sure to check the code revision number.
if (codeRevision <= 1) {
componentId = storage.extract(38);
} else {
} else if (codeRevision == 2) {
componentId = storage.extract(44);
} else {
componentId = storage.extract(58);
}
if (componentId != 0) {
ReactorItem component = ComponentFactory.createComponent(componentId);
int hasSpecialAutomationConfig = storage.extract(1);
if (hasSpecialAutomationConfig > 0) {
component.setInitialHeat(storage.extract((int)360e3));
component.setInitialHeat(storage.extract(maxComponentHeat));
if (codeRevision == 0 || (codeRevision >= 1 && automated)) {
component.setAutomationThreshold(storage.extract((int)360e3));
component.setAutomationThreshold(storage.extract(maxComponentHeat));
component.setReactorPause(storage.extract((int)10e3));
}
}
Expand Down Expand Up @@ -574,23 +583,23 @@ private String buildCodeString() {
if (component.getInitialHeat() > 0 || component.getAutomationThreshold() != ComponentFactory.getDefaultComponent(id).getAutomationThreshold() || component.getReactorPause() != ComponentFactory.getDefaultComponent(id).getReactorPause()) {
if (automated) {
storage.store(component.getReactorPause(), (int)10e3);
storage.store(component.getAutomationThreshold(), (int)360e3);
storage.store(component.getAutomationThreshold(), (int)1080e3);
}
storage.store((int)component.getInitialHeat(), (int)360e3);
storage.store((int)component.getInitialHeat(), (int)1080e3);
storage.store(1, 1);
} else {
storage.store(0, 1);
}
storage.store(id, 44);
storage.store(id, 58);
} else {
storage.store(0, 44);
storage.store(0, 58);
}
}
}
storage.store(automated ? 1 : 0, 1);
storage.store(pulsed ? 1 : 0, 1);
// store the code revision, allowing values up to 255 (8 bits) before adjusting how it is stored in the code.
storage.store(2, 255);
storage.store(3, 255);
return storage.outputBase64();
}

Expand Down
Loading

0 comments on commit 9118151

Please sign in to comment.