diff --git a/src/main/java/gregtech/api/nuclear/fission/FissionFuelRegistry.java b/src/main/java/gregtech/api/nuclear/fission/FissionFuelRegistry.java index 8b64091072e..1db20921e23 100644 --- a/src/main/java/gregtech/api/nuclear/fission/FissionFuelRegistry.java +++ b/src/main/java/gregtech/api/nuclear/fission/FissionFuelRegistry.java @@ -4,7 +4,6 @@ import net.minecraft.item.ItemStack; -import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import org.jetbrains.annotations.NotNull; @@ -15,14 +14,14 @@ public class FissionFuelRegistry { - private static final Map HASHED_FUELS = new Int2ObjectArrayMap<>(); + private static final Map IDENTIFIED_FUELS = new Object2ObjectOpenHashMap<>(); private static final Map FUELS = new Object2ObjectOpenCustomHashMap<>( ItemStackHashStrategy.comparingAllButCount()); private static final Map DEPLETED_FUELS = new Object2ObjectOpenHashMap<>(); public static void registerFuel(@NotNull ItemStack item, @NotNull IFissionFuelStats fuel, @NotNull ItemStack depletedFuel) { - HASHED_FUELS.put(fuel.hashCode(), fuel); + IDENTIFIED_FUELS.put(fuel.getID(), fuel); FUELS.put(item, fuel); DEPLETED_FUELS.put(fuel, depletedFuel); } @@ -38,8 +37,8 @@ public static Collection getAllFissionableRods() { } @Nullable - public static IFissionFuelStats getFissionFuel(int hash) { - return HASHED_FUELS.get(hash); + public static IFissionFuelStats getFissionFuel(String name) { + return IDENTIFIED_FUELS.get(name); } public static @NotNull ItemStack getDepletedFuel(IFissionFuelStats stats) { diff --git a/src/main/java/gregtech/api/nuclear/fission/IFissionFuelStats.java b/src/main/java/gregtech/api/nuclear/fission/IFissionFuelStats.java index aef72a62d15..5cb9cf72366 100644 --- a/src/main/java/gregtech/api/nuclear/fission/IFissionFuelStats.java +++ b/src/main/java/gregtech/api/nuclear/fission/IFissionFuelStats.java @@ -54,4 +54,9 @@ default int getNeutronGenerationTimeCategory() { return 3; } } + + /** + * @return A unique ID for this fuel. + */ + String getID(); } diff --git a/src/main/java/gregtech/api/unification/material/Material.java b/src/main/java/gregtech/api/unification/material/Material.java index 2fabc56ddf3..a6ef65ec532 100644 --- a/src/main/java/gregtech/api/unification/material/Material.java +++ b/src/main/java/gregtech/api/unification/material/Material.java @@ -495,8 +495,7 @@ public Builder(int id, @NotNull ResourceLocation resourceLocation) { */ /** - * Add a {@link FluidProperty} to this Material.
- * Will be created as a {@link FluidStorageKeys#LIQUID}, with + * Add a {@link FluidProperty} to this Material.
Will be created as a {@link FluidStorageKeys#LIQUID}, with * standard {@link FluidBuilder} defaults. *

* Can be called multiple times to add multiple fluids. @@ -506,8 +505,7 @@ public Builder fluid() { } /** - * Add a {@link FluidProperty} to this Material.
- * Will be created with the specified state a with standard + * Add a {@link FluidProperty} to this Material.
Will be created with the specified state a with standard * {@link FluidBuilder} defaults. *

* Can be called multiple times to add multiple fluids. @@ -600,8 +598,7 @@ public Builder gas(@NotNull FluidBuilder builder) { } /** - * Add a {@link DustProperty} to this Material.
- * Will be created with a Harvest Level of 2 and no Burn Time + * Add a {@link DustProperty} to this Material.
Will be created with a Harvest Level of 2 and no Burn Time * (Furnace Fuel). * * @throws IllegalArgumentException If a {@link DustProperty} has already been added to this Material. @@ -612,11 +609,9 @@ public Builder dust() { } /** - * Add a {@link DustProperty} to this Material.
- * Will be created with no Burn Time (Furnace Fuel). + * Add a {@link DustProperty} to this Material.
Will be created with no Burn Time (Furnace Fuel). * - * @param harvestLevel The Harvest Level of this block for Mining.
- * If this Material also has a + * @param harvestLevel The Harvest Level of this block for Mining.
If this Material also has a * {@link ToolProperty}, this value will also be used to determine the tool's Mining Level. * @throws IllegalArgumentException If a {@link DustProperty} has already been added to this Material. */ @@ -627,8 +622,7 @@ public Builder dust(int harvestLevel) { /** * Add a {@link DustProperty} to this Material. * - * @param harvestLevel The Harvest Level of this block for Mining.
- * If this Material also has a + * @param harvestLevel The Harvest Level of this block for Mining.
If this Material also has a * {@link ToolProperty}, this value will also be used to determine the tool's Mining Level. * @param burnTime The Burn Time (in ticks) of this Material as a Furnace Fuel. * @throws IllegalArgumentException If a {@link DustProperty} has already been added to this Material. @@ -639,8 +633,7 @@ public Builder dust(int harvestLevel, int burnTime) { } /** - * Add a {@link WoodProperty} to this Material.
- * Will be created with a Harvest Level of 0 and a Burn Time of + * Add a {@link WoodProperty} to this Material.
Will be created with a Harvest Level of 0 and a Burn Time of * 300 (Furnace Fuel). */ public Builder wood() { @@ -648,11 +641,9 @@ public Builder wood() { } /** - * Add a {@link WoodProperty} to this Material.
- * Will be created with a Burn Time of 300 (Furnace Fuel). + * Add a {@link WoodProperty} to this Material.
Will be created with a Burn Time of 300 (Furnace Fuel). * - * @param harvestLevel The Harvest Level of this block for Mining.
- * If this Material also has a + * @param harvestLevel The Harvest Level of this block for Mining.
If this Material also has a * {@link ToolProperty}, this value will also be used to determine the tool's Mining Level. */ public Builder wood(int harvestLevel) { @@ -662,8 +653,7 @@ public Builder wood(int harvestLevel) { /** * Add a {@link WoodProperty} to this Material. * - * @param harvestLevel The Harvest Level of this block for Mining.
- * If this Material also has a + * @param harvestLevel The Harvest Level of this block for Mining.
If this Material also has a * {@link ToolProperty}, this value will also be used to determine the tool's Mining Level. * @param burnTime The Burn Time (in ticks) of this Material as a Furnace Fuel. */ @@ -674,10 +664,8 @@ public Builder wood(int harvestLevel, int burnTime) { } /** - * Add an {@link IngotProperty} to this Material.
- * Will be created with a Harvest Level of 2 and no Burn Time - * (Furnace Fuel).
- * Will automatically add a {@link DustProperty} to this Material if it does not already + * Add an {@link IngotProperty} to this Material.
Will be created with a Harvest Level of 2 and no Burn Time + * (Furnace Fuel).
Will automatically add a {@link DustProperty} to this Material if it does not already * have one. * * @throws IllegalArgumentException If an {@link IngotProperty} has already been added to this Material. @@ -688,16 +676,12 @@ public Builder ingot() { } /** - * Add an {@link IngotProperty} to this Material.
- * Will be created with no Burn Time (Furnace Fuel).
- * Will + * Add an {@link IngotProperty} to this Material.
Will be created with no Burn Time (Furnace Fuel).
Will * automatically add a {@link DustProperty} to this Material if it does not already have one. * - * @param harvestLevel The Harvest Level of this block for Mining. 2 will make it require a iron tool.
- * If + * @param harvestLevel The Harvest Level of this block for Mining. 2 will make it require a iron tool.
If * this Material also has a {@link ToolProperty}, this value will also be used to determine - * the tool's Mining level (-1). So 2 will make the tool harvest diamonds.
- * If this + * the tool's Mining level (-1). So 2 will make the tool harvest diamonds.
If this * Material already had a Harvest Level defined, it will be overridden. * @throws IllegalArgumentException If an {@link IngotProperty} has already been added to this Material. */ @@ -706,18 +690,14 @@ public Builder ingot(int harvestLevel) { } /** - * Add an {@link IngotProperty} to this Material.
- * Will automatically add a {@link DustProperty} to this + * Add an {@link IngotProperty} to this Material.
Will automatically add a {@link DustProperty} to this * Material if it does not already have one. * - * @param harvestLevel The Harvest Level of this block for Mining. 2 will make it require a iron tool.
- * If + * @param harvestLevel The Harvest Level of this block for Mining. 2 will make it require a iron tool.
If * this Material also has a {@link ToolProperty}, this value will also be used to determine - * the tool's Mining level (-1). So 2 will make the tool harvest diamonds.
- * If this + * the tool's Mining level (-1). So 2 will make the tool harvest diamonds.
If this * Material already had a Harvest Level defined, it will be overridden. - * @param burnTime The Burn Time (in ticks) of this Material as a Furnace Fuel.
- * If this Material already + * @param burnTime The Burn Time (in ticks) of this Material as a Furnace Fuel.
If this Material already * had a Burn Time defined, it will be overridden. * @throws IllegalArgumentException If an {@link IngotProperty} has already been added to this Material. */ @@ -733,10 +713,8 @@ public Builder ingot(int harvestLevel, int burnTime) { } /** - * Add a {@link GemProperty} to this Material.
- * Will be created with a Harvest Level of 2 and no Burn Time - * (Furnace Fuel).
- * Will automatically add a {@link DustProperty} to this Material if it does not already + * Add a {@link GemProperty} to this Material.
Will be created with a Harvest Level of 2 and no Burn Time + * (Furnace Fuel).
Will automatically add a {@link DustProperty} to this Material if it does not already * have one. * * @throws IllegalArgumentException If a {@link GemProperty} has already been added to this Material. @@ -747,16 +725,12 @@ public Builder gem() { } /** - * Add a {@link GemProperty} to this Material.
- * Will be created with no Burn Time (Furnace Fuel).
- * Will + * Add a {@link GemProperty} to this Material.
Will be created with no Burn Time (Furnace Fuel).
Will * automatically add a {@link DustProperty} to this Material if it does not already have one. * - * @param harvestLevel The Harvest Level of this block for Mining.
- * If this Material also has a + * @param harvestLevel The Harvest Level of this block for Mining.
If this Material also has a * {@link ToolProperty}, this value will also be used to determine the tool's Mining - * level.
- * If this Material already had a Harvest Level defined, it will be overridden. + * level.
If this Material already had a Harvest Level defined, it will be overridden. * @throws IllegalArgumentException If a {@link GemProperty} has already been added to this Material. */ public Builder gem(int harvestLevel) { @@ -764,17 +738,13 @@ public Builder gem(int harvestLevel) { } /** - * Add a {@link GemProperty} to this Material.
- * Will automatically add a {@link DustProperty} to this + * Add a {@link GemProperty} to this Material.
Will automatically add a {@link DustProperty} to this * Material if it does not already have one. * - * @param harvestLevel The Harvest Level of this block for Mining.
- * If this Material also has a + * @param harvestLevel The Harvest Level of this block for Mining.
If this Material also has a * {@link ToolProperty}, this value will also be used to determine the tool's Mining - * level.
- * If this Material already had a Harvest Level defined, it will be overridden. - * @param burnTime The Burn Time (in ticks) of this Material as a Furnace Fuel.
- * If this Material already + * level.
If this Material already had a Harvest Level defined, it will be overridden. + * @param burnTime The Burn Time (in ticks) of this Material as a Furnace Fuel.
If this Material already * had a Burn Time defined, it will be overridden. */ public Builder gem(int harvestLevel, int burnTime) { @@ -789,10 +759,8 @@ public Builder gem(int harvestLevel, int burnTime) { } /** - * Add a {@link PolymerProperty} to this Material.
- * Will be created with a Harvest Level of 2 and no Burn - * Time (Furnace Fuel).
- * Will automatically add a {@link DustProperty} to this Material if it does not + * Add a {@link PolymerProperty} to this Material.
Will be created with a Harvest Level of 2 and no Burn + * Time (Furnace Fuel).
Will automatically add a {@link DustProperty} to this Material if it does not * already have one. * * @throws IllegalArgumentException If an {@link PolymerProperty} has already been added to this Material. @@ -803,15 +771,12 @@ public Builder polymer() { } /** - * Add a {@link PolymerProperty} to this Material.
- * Will automatically add a {@link DustProperty} to this + * Add a {@link PolymerProperty} to this Material.
Will automatically add a {@link DustProperty} to this * Material if it does not already have one. Will have a burn time of 0 * - * @param harvestLevel The Harvest Level of this block for Mining.
- * If this Material also has a + * @param harvestLevel The Harvest Level of this block for Mining.
If this Material also has a * {@link ToolProperty}, this value will also be used to determine the tool's Mining - * level.
- * If this Material already had a Harvest Level defined, it will be overridden. + * level.
If this Material already had a Harvest Level defined, it will be overridden. * @throws IllegalArgumentException If an {@link PolymerProperty} has already been added to this Material. */ public Builder polymer(int harvestLevel) { @@ -833,8 +798,7 @@ public Builder burnTime(int burnTime) { } /** - * Set the Color of this Material.
- * Defaults to 0xFFFFFF unless {@link Builder#colorAverage()} was called, + * Set the Color of this Material.
Defaults to 0xFFFFFF unless {@link Builder#colorAverage()} was called, * where it will be a weighted average of the components of the Material. * * @param color The RGB-formatted Color. @@ -850,8 +814,7 @@ public Builder colorAverage() { } /** - * Set the {@link MaterialIconSet} of this Material.
- * Defaults vary depending on if the Material has a:
+ * Set the {@link MaterialIconSet} of this Material.
Defaults vary depending on if the Material has a:
*

    *
  • {@link GemProperty}, it will default to {@link MaterialIconSet#GEM_VERTICAL} *
  • {@link IngotProperty} or {@link DustProperty}, it will default to {@link MaterialIconSet#DULL} @@ -890,8 +853,7 @@ public Builder components(ImmutableList components) { } /** - * Add {@link MaterialFlags} to this Material.
    - * Dependent Flags (for example, + * Add {@link MaterialFlags} to this Material.
    Dependent Flags (for example, * {@link MaterialFlags#GENERATE_LONG_ROD} requiring {@link MaterialFlags#GENERATE_ROD}) will be automatically * applied. */ @@ -901,8 +863,7 @@ public Builder flags(MaterialFlag... flags) { } /** - * Add {@link MaterialFlags} to this Material.
    - * Dependent Flags (for example, + * Add {@link MaterialFlags} to this Material.
    Dependent Flags (for example, * {@link MaterialFlags#GENERATE_LONG_ROD} requiring {@link MaterialFlags#GENERATE_ROD}) will be automatically * applied. * @@ -1094,7 +1055,8 @@ public Builder fissionFuel(int maxTemperature, int duration, double slowNeutronC properties.setProperty(PropertyKey.FISSION_FUEL, new FissionFuelProperty(maxTemperature, duration, slowNeutronCaptureCrossSection, fastNeutronCaptureCrossSection, slowNeutronFissionCrossSection, - fastNeutronFissionCrossSection, neutronGenerationTime)); + fastNeutronFissionCrossSection, neutronGenerationTime, + this.materialInfo.resourceLocation.toString())); return this; } @@ -1181,13 +1143,12 @@ private void verifyInfo(MaterialProperties p, boolean averageRGB) { iconSet = MaterialIconSet.GEM_VERTICAL; } else if (p.hasProperty(PropertyKey.DUST) || p.hasProperty(PropertyKey.INGOT) || p.hasProperty(PropertyKey.POLYMER)) { - iconSet = MaterialIconSet.DULL; - } else - if (p.hasProperty(PropertyKey.FLUID)) { - iconSet = MaterialIconSet.FLUID; - } else { - iconSet = MaterialIconSet.DULL; - } + iconSet = MaterialIconSet.DULL; + } else if (p.hasProperty(PropertyKey.FLUID)) { + iconSet = MaterialIconSet.FLUID; + } else { + iconSet = MaterialIconSet.DULL; + } } // Verify MaterialRGB diff --git a/src/main/java/gregtech/api/unification/material/properties/FissionFuelProperty.java b/src/main/java/gregtech/api/unification/material/properties/FissionFuelProperty.java index 9e3202d5c7e..02f757bdcb8 100644 --- a/src/main/java/gregtech/api/unification/material/properties/FissionFuelProperty.java +++ b/src/main/java/gregtech/api/unification/material/properties/FissionFuelProperty.java @@ -18,6 +18,7 @@ public class FissionFuelProperty implements IMaterialProperty, IFissionFuelStats private double fastNeutronFissionCrossSection; // The average time for a neutron to be emitted during a fission event. Do not make this accurate. private double neutronGenerationTime; + private String id; @Override public void verifyProperty(MaterialProperties properties) { @@ -26,7 +27,7 @@ public void verifyProperty(MaterialProperties properties) { public FissionFuelProperty(int maxTemperature, int duration, double slowNeutronCaptureCrossSection, double fastNeutronCaptureCrossSection, double slowNeutronFissionCrossSection, - double fastNeutronFissionCrossSection, double neutronGenerationTime) { + double fastNeutronFissionCrossSection, double neutronGenerationTime, String id) { this.maxTemperature = maxTemperature; this.duration = duration; this.slowNeutronCaptureCrossSection = slowNeutronCaptureCrossSection; @@ -34,6 +35,7 @@ public FissionFuelProperty(int maxTemperature, int duration, double slowNeutronC this.slowNeutronFissionCrossSection = slowNeutronFissionCrossSection; this.fastNeutronFissionCrossSection = fastNeutronFissionCrossSection; this.neutronGenerationTime = neutronGenerationTime; + this.id = id; } @Override @@ -97,6 +99,11 @@ public double getNeutronGenerationTime() { return neutronGenerationTime; } + @Override + public String getID() { + return this.id; + } + public void setNeutronGenerationTime(double neutronGenerationTime) { this.neutronGenerationTime = neutronGenerationTime; } diff --git a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityFuelRodImportBus.java b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityFuelRodImportBus.java index 11051ac991c..c9151c65a96 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityFuelRodImportBus.java +++ b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityFuelRodImportBus.java @@ -131,14 +131,14 @@ public void readFromNBT(NBTTagCompound data) { super.readFromNBT(data); getLockedImport().setLock(data.getBoolean("locked")); if (data.hasKey("partialFuel")) { - this.partialFuel = FissionFuelRegistry.getFissionFuel(data.getInteger("partialFuel")); + this.partialFuel = FissionFuelRegistry.getFissionFuel(data.getString("partialFuel")); } } @Override public NBTTagCompound writeToNBT(NBTTagCompound data) { data.setBoolean("locked", getLockedImport().isLocked()); - if (partialFuel != null) data.setInteger("partialFuel", this.partialFuel.hashCode()); + if (partialFuel != null) data.setString("partialFuel", this.partialFuel.getID()); return super.writeToNBT(data); }