Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
fix predetermined eoh outputs showing on scanner output (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
GDCloudstrike authored Mar 21, 2024
1 parent 931c218 commit f646413
Showing 1 changed file with 43 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,8 @@ public RecipeMap<?> getRecipeMap() {
private long successfulParallelAmount = 0;
private double yield = 0;
private BigInteger usedEU = BigInteger.ZERO;
private FluidStackLong stellarPlasma;
private FluidStackLong starMatter;

@Override
@NotNull
Expand Down Expand Up @@ -1303,6 +1305,12 @@ && getHydrogenStored() < currentRecipe.getHydrogenRequirement() * parallelAmount
outputFluids = recipeObject.getOutputFluids();
outputItems = recipeObject.getOutputItems();

// Star matter is always the last element in the array.
starMatter = new FluidStackLong(outputFluids.get(outputFluids.size() - 1));

// And stellar plasma is the second last.
stellarPlasma = new FluidStackLong(outputFluids.get(outputFluids.size() - 2));

successfulParallelAmount = (long) calculateChancedOutputMultiplier(
(int) (10000 * successChance),
(int) parallelAmount);
Expand Down Expand Up @@ -1553,30 +1561,33 @@ public String[] getInfoData() {
str.add("EU Input: " + RED + toStandardForm(usedEU.abs()) + RESET + " EU");
int currentMaxProgresstime = Math.max(maxProgresstime(), 1);
if (outputFluids.size() > 0) {
// Star matter is always the last element in the array.
FluidStackLong starMatter = outputFluids.get(outputFluids.size() - 1);
FluidStackLong starMatterOutput = new FluidStackLong(
starMatter.fluidStack,
(long) (starMatter.amount * yield * successChance * parallelAmount));
str.add(
"Estimated " + starMatter.fluidStack.getLocalizedName()
"Average " + starMatterOutput.fluidStack.getLocalizedName()
+ " Output: "
+ RED
+ formatNumbers(starMatter.amount)
+ formatNumbers(starMatterOutput.amount)
+ RESET
+ " L, "
+ YELLOW
+ formatNumbers(starMatter.amount * 20.0 / currentMaxProgresstime)
+ formatNumbers(starMatterOutput.amount * 20.0 / currentMaxProgresstime)
+ RESET
+ " L/s");
// And stellar plasma is the second last.
FluidStackLong stellarPlasma = outputFluids.get(outputFluids.size() - 2);

FluidStackLong stellarPlasmaOutput = new FluidStackLong(
stellarPlasma.fluidStack,
(long) (stellarPlasma.amount * yield * successChance * parallelAmount));
str.add(
"Estimated " + stellarPlasma.fluidStack.getLocalizedName()
"Average " + stellarPlasmaOutput.fluidStack.getLocalizedName()
+ " Output: "
+ RED
+ formatNumbers(stellarPlasma.amount)
+ formatNumbers(stellarPlasmaOutput.amount)
+ RESET
+ " L, "
+ YELLOW
+ formatNumbers(stellarPlasma.amount * 20.0 / currentMaxProgresstime)
+ formatNumbers(stellarPlasmaOutput.amount * 20.0 / currentMaxProgresstime)
+ RESET
+ " L/s");
}
Expand All @@ -1601,6 +1612,9 @@ public String[] getStructureDescription(ItemStack stackSize) {
private static final String ITEM_OUTPUT_NBT_TAG = EYE_OF_HARMONY + "itemOutput";
private static final String FLUID_OUTPUT_NBT_TAG = EYE_OF_HARMONY + "fluidOutput";
private static final String RECIPE_RUNNING_NBT_TAG = EYE_OF_HARMONY + "recipeRunning";
private static final String CURRENT_RECIPE_STAR_MATTER_TAG = EYE_OF_HARMONY + "recipeStarMatter";
private static final String CURRENT_RECIPE_STELLAR_PLASMA_TAG = EYE_OF_HARMONY + "recipeStellarPlasma";
private static final String CURRENT_RECIPE_FIXED_OUTPUTS_TAG = EYE_OF_HARMONY + "recipeFixedOutputs";
private static final String RECIPE_SUCCESS_CHANCE_NBT_TAG = EYE_OF_HARMONY + "recipeSuccessChance";
private static final String ROCKET_TIER_NBT_TAG = EYE_OF_HARMONY + "rocketTier";
private static final String CURRENT_CIRCUIT_MULTIPLIER_TAG = EYE_OF_HARMONY + "currentCircuitMultiplier";
Expand Down Expand Up @@ -1652,7 +1666,7 @@ public void saveNBTData(NBTTagCompound aNBT) {

aNBT.setTag(ITEM_OUTPUT_NBT_TAG, itemStackListNBTTag);

// Store damage values/stack sizes of GT fluida being outputted.
// Store damage values/stack sizes of GT fluids being outputted.
NBTTagCompound fluidStackListNBTTag = new NBTTagCompound();
fluidStackListNBTTag.setLong(NUMBER_OF_FLUIDS_NBT_TAG, outputFluids.size());

Expand All @@ -1669,6 +1683,16 @@ public void saveNBTData(NBTTagCompound aNBT) {

aNBT.setTag(FLUID_OUTPUT_NBT_TAG, fluidStackListNBTTag);

NBTTagCompound fixedRecipeOutputs = new NBTTagCompound();

fixedRecipeOutputs.setLong(0 + FLUID_AMOUNT, starMatter.amount);
aNBT.setTag(CURRENT_RECIPE_STAR_MATTER_TAG, starMatter.fluidStack.writeToNBT(new NBTTagCompound()));

fixedRecipeOutputs.setLong(1 + FLUID_AMOUNT, stellarPlasma.amount);
aNBT.setTag(CURRENT_RECIPE_STELLAR_PLASMA_TAG, stellarPlasma.fluidStack.writeToNBT(new NBTTagCompound()));

aNBT.setTag(CURRENT_RECIPE_FIXED_OUTPUTS_TAG, fixedRecipeOutputs);

super.saveNBTData(aNBT);
}

Expand Down Expand Up @@ -1723,6 +1747,14 @@ public void loadNBTData(final NBTTagCompound aNBT) {
outputFluids.add(new FluidStackLong(fluidStack, fluidAmount));
}

tempFluidTag = aNBT.getCompoundTag(CURRENT_RECIPE_FIXED_OUTPUTS_TAG);
starMatter = new FluidStackLong(
FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag(CURRENT_RECIPE_STAR_MATTER_TAG)),
tempFluidTag.getLong(0 + FLUID_AMOUNT));
stellarPlasma = new FluidStackLong(
FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag(CURRENT_RECIPE_STELLAR_PLASMA_TAG)),
tempFluidTag.getLong(1 + FLUID_AMOUNT));

super.loadNBTData(aNBT);
}
}

0 comments on commit f646413

Please sign in to comment.