aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorGTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com>2022-12-24 08:17:46 +0000
committerGTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com>2022-12-24 08:17:46 +0000
commit8fd8e23ec7201e94188420b9e6981b7de8a13c1f (patch)
treecd182255ff2f0adb1636518128b9f2fcc9103351 /src/main/java
parentfadc3e97ba11246e5bca2c143a7fadb806de3edb (diff)
downloadGT5-Unofficial-8fd8e23ec7201e94188420b9e6981b7de8a13c1f.tar.gz
GT5-Unofficial-8fd8e23ec7201e94188420b9e6981b7de8a13c1f.tar.bz2
GT5-Unofficial-8fd8e23ec7201e94188420b9e6981b7de8a13c1f.zip
NEI work and some small optimisations
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java21
-rw-r--r--src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java22
-rw-r--r--src/main/java/com/github/technus/tectech/recipe/TT_recipe.java14
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java53
4 files changed, 79 insertions, 31 deletions
diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java
index be655f1cec..adbdcc3a99 100644
--- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java
+++ b/src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java
@@ -1,9 +1,11 @@
package com.github.technus.tectech.nei;
import static com.github.technus.tectech.Reference.MODID;
+import static com.github.technus.tectech.recipe.TT_recipe.Eye_Of_Harmony_Recipe_Map.maxItemsToRender;
import static com.github.technus.tectech.util.CommonValues.EOH_TIER_FANCY_NAMES;
import static com.google.common.math.LongMath.pow;
import static gregtech.api.util.GT_Utility.formatNumbers;
+import static net.minecraft.util.EnumChatFormatting.*;
import appeng.util.ReadableNumberConverter;
import codechicken.nei.PositionedStack;
@@ -56,11 +58,19 @@ public class TT_NEI_EyeOfHarmonyHandler extends GT_NEI_DefaultHandler {
}
CachedRecipe tObject = this.arecipes.get(aRecipeIndex);
+
if (tObject instanceof CachedDefaultRecipe) {
CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject;
EyeOfHarmonyRecipe currentRecipe = (EyeOfHarmonyRecipe) tRecipe.mRecipe.mSpecialItems;
+ // Draw tooltip on planet item.
+ if (aStack.isItemEqual(currentRecipe.getRecipeTriggerItem())) {
+ currentToolTip.add(EnumChatFormatting.GRAY + "Total Items: " + formatNumbers(currentRecipe.getSumOfItems()));
+ return currentToolTip;
+ }
+
+ // Draw tooltip on other items.
double percentage = currentRecipe.getItemStackToProbabilityMap().getOrDefault(aStack, -1.0);
if (percentage != -1.0) {
@@ -141,12 +151,19 @@ public class TT_NEI_EyeOfHarmonyHandler extends GT_NEI_DefaultHandler {
}
drawLine(index++, "Base Recipe Chance: " + formatNumbers(100 * recipe.getBaseRecipeSuccessChance()) + "%");
- drawLine(index, "Recipe Energy Efficiency: " + formatNumbers(100 * recipe.getRecipeEnergyEfficiency()) + "%");
+ drawLine(index++, "Recipe Energy Efficiency: " + formatNumbers(100 * recipe.getRecipeEnergyEfficiency()) + "%");
+
+ if (recipe.getOutputItems().size() > maxItemsToRender) {
+ drawLine(index, "" + DARK_RED + BOLD + "Warning" + RESET + ": Not all items displayed.");
+ }
+
drawOverlays(cachedRecipe);
}
@Override
protected void drawLine(int lineNumber, String line) {
- drawText(10, getDescriptionYOffset() + lineNumber * 10, line, 0xFF000000);
+ drawText(7, getDescriptionYOffset() + lineNumber * 10 + 1, line, 0xFF000000);
}
+
+
}
diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java
index 5d6a81c2e1..1bc08fcda6 100644
--- a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java
+++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java
@@ -60,6 +60,8 @@ public class EyeOfHarmonyRecipe {
private final ItemStack recipeTriggerItem;
+ private final long sumOfItems;
+
public TMap<ItemStack, Double> getItemStackToProbabilityMap() {
return itemStackToProbabilityMap;
}
@@ -75,21 +77,25 @@ public class EyeOfHarmonyRecipe {
@SuppressWarnings("FieldCanBeLocal")
private final long standardRecipeEUOutPerTick = 100 * BILLION;
+ public long getSumOfItems() {
+ return sumOfItems;
+ }
+
public EyeOfHarmonyRecipe(ArrayList<Pair<Materials, Long>> materialList,
- Block block,
- final double recipeEnergyEfficiency,
- final long hydrogenRequirement,
- final long heliumRequirement,
- final long miningTimeSeconds,
- final long spacetimeCasingTierRequired,
- final double baseSuccessChance) {
+ Block block,
+ final double recipeEnergyEfficiency,
+ final long hydrogenRequirement,
+ final long heliumRequirement,
+ final long miningTimeSeconds,
+ final long spacetimeCasingTierRequired,
+ final double baseSuccessChance) {
this.recipeTriggerItem = new ItemStack(block);
this.outputItems = validDustGenerator(materialList);
this.outputItems.sort(Comparator.comparingLong(ItemStackLong::getStackSize));
Collections.reverse(this.outputItems);
- long sumOfItems =
+ this.sumOfItems =
this.outputItems.stream().map(ItemStackLong::getStackSize).reduce(0L, Long::sum);
for (ItemStackLong itemStackLong : outputItems) {
diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java
index b5493eaa09..bcb2d386c3 100644
--- a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java
+++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java
@@ -1,6 +1,7 @@
package com.github.technus.tectech.recipe;
import static gregtech.api.enums.GT_Values.RES_PATH_GUI;
+import static java.lang.Math.min;
import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap;
@@ -264,7 +265,7 @@ public class TT_recipe extends GT_Recipe {
true,
false) // Custom NEI handler means this must be false.
.setProgressBar(GT_UITextures.PROGRESSBAR_HAMMER, ProgressBar.Direction.DOWN)
- .setProgressBarPos(78 + 1, 24 + 2)
+ .setProgressBarPos(78, 24 + 2)
.setUsualFluidOutputCount(18)
.setLogoPos(10, 10);
@@ -541,7 +542,7 @@ public class TT_recipe extends GT_Recipe {
@Override
public GT_Recipe_Map setNEIBackgroundSize(int width, int height) {
useModularUI(true);
- this.neiBackgroundSize = new Size(172, 80 + 9 * 18);
+ this.neiBackgroundSize = new Size(172, 81 + 9 * 18);
return this;
}
@@ -552,12 +553,15 @@ public class TT_recipe extends GT_Recipe {
@Override
public List<Pos2d> getItemInputPositions(int itemInputCount) {
- return UIHelper.getItemGridPositions(itemInputCount, 80, yOrigin, 1, 1);
+ return UIHelper.getItemGridPositions(itemInputCount, 79, yOrigin, 1, 1);
}
+ public static final int maxItemsToRender = 80;
+
@Override
public List<Pos2d> getItemOutputPositions(int itemOutputCount) {
- return UIHelper.getItemGridPositions(itemOutputCount, 8, yOrigin + 36, xDirMaxCount, 12);
+ return UIHelper.getItemGridPositions(min(itemOutputCount, maxItemsToRender+1), 7, yOrigin + 36, xDirMaxCount, 12);
+
}
@Override
@@ -567,7 +571,7 @@ public class TT_recipe extends GT_Recipe {
@Override
public List<Pos2d> getFluidOutputPositions(int fluidOutputCount) {
- return UIHelper.getItemGridPositions(fluidOutputCount, 8, yOrigin + 13 * 17 - 7 - 16, xDirMaxCount, 3);
+ return UIHelper.getItemGridPositions(fluidOutputCount, 7, yOrigin + 13 * 17 - 7 - 16, xDirMaxCount, 3);
}
@Override
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java
index e3413ec4ad..8ed089f24d 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java
@@ -10,6 +10,7 @@ import static gregtech.api.util.GT_Utility.formatNumbers;
import static java.lang.Math.*;
import static net.minecraft.util.EnumChatFormatting.*;
+import appeng.util.ReadableNumberConverter;
import com.github.technus.tectech.recipe.EyeOfHarmonyRecipe;
import com.github.technus.tectech.recipe.EyeOfHarmonyRecipeStorage;
import com.github.technus.tectech.thing.casing.TT_Block_SpacetimeCompressionFieldGenerators;
@@ -49,6 +50,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.FluidStack;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.opengl.GL11;
+import org.spongepowered.libraries.com.google.common.math.LongMath;
@SuppressWarnings("SpellCheckingInspection")
public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_MultiblockBase_EM
@@ -1672,19 +1674,27 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl
private EyeOfHarmonyRecipe currentRecipe;
+ private long lagPreventer = 0;
+ private final long recipeCheckInterval = 3 * 20;
+
@Override
public boolean checkRecipe_EM(ItemStack aStack) {
-
- // No item in multi gui slot.
if (aStack == null) {
return false;
}
- currentRecipe = recipes.recipeLookUp(aStack);
- if (processRecipe(currentRecipe)) {
- return true;
+ lagPreventer++;
+ if (lagPreventer < recipeCheckInterval) {
+ lagPreventer = 0;
+ // No item in multi gui slot.
+
+ currentRecipe = recipes.recipeLookUp(aStack);
+ if (processRecipe(currentRecipe)) {
+ return true;
+ }
+
+ currentRecipe = null;
}
- currentRecipe = null;
return false;
}
@@ -1698,9 +1708,13 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl
public boolean processRecipe(EyeOfHarmonyRecipe recipeObject) {
- // todo: fix changing the tier of block causing multi to unform
- if ((getHydrogenStored() < currentRecipe.getHydrogenRequirement())
- || (getHeliumStored() < currentRecipe.getHeliumRequirement())) {
+// if ((getHydrogenStored() < currentRecipe.getHydrogenRequirement())
+// || (getHeliumStored() < currentRecipe.getHeliumRequirement())) {
+// return false;
+// }
+
+ if ((getHydrogenStored() < 100)
+ || (getHeliumStored() < 100)) {
return false;
}
@@ -1767,7 +1781,7 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl
// todo Replace with proper fluid once added to GT.
int exoticMaterialOutputAmount =
(int) ((successChance) * 1440 * (getHydrogenStored() + getHeliumStored()) / 1_000_000_000.0);
- mOutputFluids = new FluidStack[] {Materials.Infinity.getFluid(exoticMaterialOutputAmount)};
+ mOutputFluids = new FluidStack[] {Materials.SpaceTime.getFluid(exoticMaterialOutputAmount)};
super.outputAfterRecipe_EM();
}
@@ -1876,15 +1890,21 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl
str.add(GOLD + "----------------- Internal Fluids Stored ----------------");
validFluidMap.forEach(
(key, value) -> str.add(BLUE + key.getLocalizedName() + RESET + " : " + RED + formatNumbers(value)));
- str.add(GOLD + "---------------------- Other Stats ---------------");
if (recipeRunning) {
- str.add("Recipe Success Chance: " + formatNumbers(100 * successChance) + "%");
- str.add("Recipe Yield: " + formatNumbers(100 * successChance) + "%");
- str.add("EU Output: " + formatNumbers(euOutput));
+ str.add(GOLD + "---------------------- Other Stats ---------------");
+ str.add("Recipe Success Chance: " + RED + formatNumbers(100 * successChance) + RESET + "%");
+ str.add("Recipe Yield: " + RED + formatNumbers(100 * successChance) + RESET + "%");
+ str.add("EU Output: " + RED + formatNumbers(euOutput) + RESET + " EU");
if (mOutputFluids.length > 0) {
// Star matter is always the last element in the array.
str.add("Estimated Star Matter Output: "
- + formatNumbers(mOutputFluids[mOutputFluids.length - 1].amount));
+ + RED + formatNumbers(mOutputFluids[mOutputFluids.length - 1].amount) + RESET + " L");
+ }
+ long euPerTick = euOutput / maxProgresstime();
+ if (euPerTick < LongMath.pow(10, 12)) {
+ str.add("Estimated EU/t: " + RED + formatNumbers(euOutput / maxProgresstime()) + RESET + " EU/t");
+ } else {
+ str.add("Estimated EU/t: " + RED + ReadableNumberConverter.INSTANCE.toWideReadableForm(euOutput / maxProgresstime()) + RESET + " EU/t");
}
str.add(GOLD + "-----------------------------------------------------");
}
@@ -1982,7 +2002,7 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl
@Override
public boolean renderInWorld(IBlockAccess aWorld, int x, int y, int z, Block block, RenderBlocks renderer) {
Tessellator tes = Tessellator.instance;
- IIcon texture = Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon();
+ IIcon texture = Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_GLOW.getIcon();
float size = 2.0f;
//if (getBaseMetaTileEntity().isActive()) {
if (true) {
@@ -2045,6 +2065,7 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_CULL_FACE);
+ GL11.glRotated(Math.random(),Math.random(),Math.random(),Math.random());
GL11.glPopMatrix();
}
return false;