aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/gregtech/api/enums/ItemList.java2
-rw-r--r--src/main/java/gregtech/api/enums/Textures.java2
-rw-r--r--src/main/java/gregtech/api/items/GT_MetaBase_Item.java6
-rw-r--r--src/main/java/gregtech/api/objects/GT_ItemStack.java7
-rw-r--r--src/main/java/gregtech/api/util/GT_OreDictUnificator.java37
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java4
-rw-r--r--src/main/java/gregtech/common/GT_Client.java7
-rw-r--r--src/main/java/gregtech/common/GT_Proxy.java4
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Block_Casings8.java10
-rw-r--r--src/main/java/gregtech/loaders/postload/GT_CraftingRecipeLoader.java8
-rw-r--r--src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java4
-rw-r--r--src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java1
-rw-r--r--src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java72
-rw-r--r--src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_IRIDIUM.pngbin0 -> 3023 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_RHODIUM_PALLADIUM.pngbin0 -> 3145 bytes
15 files changed, 98 insertions, 66 deletions
diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java
index f1522dc81f..a77a0de902 100644
--- a/src/main/java/gregtech/api/enums/ItemList.java
+++ b/src/main/java/gregtech/api/enums/ItemList.java
@@ -841,6 +841,8 @@ public enum ItemList implements IItemContainer {
Casing_Firebox_Titanium,
Casing_MiningNeutronium,
Casing_MiningBlackPlutonium,
+ Casing_Advanced_Rhodium_Palladium,
+ Casing_Advanced_Iridium,
Hull_ULV,
Hull_LV,
diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java
index 6baa3c260e..49aac808d6 100644
--- a/src/main/java/gregtech/api/enums/Textures.java
+++ b/src/main/java/gregtech/api/enums/Textures.java
@@ -244,6 +244,8 @@ public class Textures {
MACHINE_CASING_MINING_OSMIRIDIUM,
MACHINE_CASING_MINING_NEUTRONIUM,
MACHINE_CASING_MINING_BLACKPLUTONIUM,
+ MACHINE_CASING_RHODIUM_PALLADIUM,
+ MACHINE_CASING_IRIDIUM,
MACHINE_CASING_FIREBOX_TITANIUM,
MACHINE_CASING_FUSION_COIL,
diff --git a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java
index edc60b45fc..2f6685553e 100644
--- a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java
+++ b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java
@@ -58,11 +58,7 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
*/
public final GT_MetaBase_Item addItemBehavior(int aMetaValue, IItemBehaviour<GT_MetaBase_Item> aBehavior) {
if (aMetaValue < 0 || aMetaValue >= 32766 || aBehavior == null) return this;
- ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) aMetaValue);
- if (tList == null) {
- tList = new ArrayList<IItemBehaviour<GT_MetaBase_Item>>(1);
- mItemBehaviors.put((short) aMetaValue, tList);
- }
+ ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.computeIfAbsent((short) aMetaValue, k -> new ArrayList<>(1));
tList.add(aBehavior);
return this;
}
diff --git a/src/main/java/gregtech/api/objects/GT_ItemStack.java b/src/main/java/gregtech/api/objects/GT_ItemStack.java
index 7284854c5f..3e25454fa1 100644
--- a/src/main/java/gregtech/api/objects/GT_ItemStack.java
+++ b/src/main/java/gregtech/api/objects/GT_ItemStack.java
@@ -1,5 +1,6 @@
package gregtech.api.objects;
+import gregtech.api.enums.GT_Values;
import gregtech.api.util.GT_Utility;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
@@ -17,7 +18,11 @@ public class GT_ItemStack {
}
public GT_ItemStack(ItemStack aStack) {
- this(aStack == null ? null : aStack.getItem(), aStack == null ? 0 : aStack.stackSize, aStack == null ? 0 : Items.feather.getDamage(aStack));
+ this(aStack, false);
+ }
+
+ public GT_ItemStack(ItemStack aStack, boolean wildcard) {
+ this(aStack == null ? null : aStack.getItem(), aStack == null ? 0 : aStack.stackSize, aStack == null ? 0 : wildcard ? GT_Values.W : Items.feather.getDamage(aStack));
}
public GT_ItemStack(int aHashCode) {
diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
index 54ef5b2866..a017cf3bb0 100644
--- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
+++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
@@ -223,26 +223,30 @@ public class GT_OreDictUnificator {
rStack = tPrefixMaterial.mUnificationTarget;
if (GT_Utility.isStackInvalid(rStack))
return !alreadyCompared && GT_Utility.areStacksEqual(aStack, unified_tStack, true);
- assert rStack != null;
rStack.setTagCompound(aStack.getTagCompound());
return GT_Utility.areStacksEqual(rStack, unified_tStack, true);
}
public static List<ItemStack> getNonUnifiedStacks(Object obj) {
- synchronized (sUnificationTable) {
- if (sUnificationTable.isEmpty() && !sItemStack2DataMap.isEmpty()) {
- for (GT_ItemStack tGTStack0 : sItemStack2DataMap.keySet()) {
- ItemStack tStack0 = tGTStack0.toStack();
- ItemStack tStack1 = get(false, tStack0);
- if (!GT_Utility.areStacksEqual(tStack0, tStack1)) {
- GT_ItemStack tGTStack1 = new GT_ItemStack(tStack1);
- List<ItemStack> list = sUnificationTable.computeIfAbsent(tGTStack1, k -> new ArrayList<>());
- if (!list.contains(tStack0))
- list.add(tStack0);
- }
- }
- }
- }
+ if (sUnificationTable.isEmpty() && !sItemStack2DataMap.isEmpty()) {
+ // use something akin to double check lock. this synchronization overhead is causing lag whenever my
+ // 5900x tries to do NEI lookup
+ synchronized (sUnificationTable) {
+ if (sUnificationTable.isEmpty() && !sItemStack2DataMap.isEmpty()) {
+ for (GT_ItemStack tGTStack0 : sItemStack2DataMap.keySet()) {
+ ItemStack tStack0 = tGTStack0.toStack();
+ ItemStack tStack1 = get_nocopy(false, tStack0);
+ if (!GT_Utility.areStacksEqual(tStack0, tStack1)) {
+ GT_ItemStack tGTStack1 = new GT_ItemStack(tStack1);
+ List<ItemStack> list = sUnificationTable.computeIfAbsent(tGTStack1, k -> new ArrayList<>());
+ // greg's original code tries to dedupe the list using List#contains, which won't work
+ // on vanilla ItemStack. I removed it since it never worked and can be slow.
+ list.add(tStack0);
+ }
+ }
+ }
+ }
+ }
ItemStack[] aStacks = {};
if (obj instanceof ItemStack)
aStacks = new ItemStack[]{(ItemStack) obj};
@@ -257,7 +261,6 @@ public class GT_OreDictUnificator {
if (tList != null) {
for (ItemStack tStack : tList) {
ItemStack tStack1 = GT_Utility.copyAmount(aStack.stackSize, tStack);
- tStack1.setTagCompound(aStack.getTagCompound());
rList.add(tStack1);
}
}
@@ -315,7 +318,7 @@ public class GT_OreDictUnificator {
public static ItemData getItemData(ItemStack aStack) {
if (GT_Utility.isStackInvalid(aStack)) return null;
ItemData rData = sItemStack2DataMap.get(new GT_ItemStack(aStack));
- if (rData == null) rData = sItemStack2DataMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, aStack)));
+ if (rData == null) rData = sItemStack2DataMap.get(new GT_ItemStack(aStack, true));
return rData;
}
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index bcd3c193de..6130adfaef 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -800,7 +800,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
* @return if this Item is a valid Input for any for the Recipes
*/
public boolean containsInput(ItemStack aStack) {
- return aStack != null && (mRecipeItemMap.containsKey(new GT_ItemStack(aStack)) || mRecipeItemMap.containsKey(new GT_ItemStack(GT_Utility.copyMetaData(W, aStack))));
+ return aStack != null && (mRecipeItemMap.containsKey(new GT_ItemStack(aStack)) || mRecipeItemMap.containsKey(new GT_ItemStack(aStack, true)));
}
/**
@@ -886,7 +886,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes)
if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs))
return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
- tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, tStack)));
+ tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack, true));
if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes)
if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs))
return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java
index 55efd20920..b9701bb451 100644
--- a/src/main/java/gregtech/common/GT_Client.java
+++ b/src/main/java/gregtech/common/GT_Client.java
@@ -152,6 +152,7 @@ public class GT_Client extends GT_Proxy
private GT_ClientPreference mPreference;
private boolean mFirstTick = false;
public static final int ROTATION_MARKER_RESOLUTION = 120;
+ private int mReloadCount;
public GT_Client() {
mCapeRenderer = new GT_CapeRenderer(mCapeList);
@@ -505,6 +506,12 @@ public class GT_Client extends GT_Proxy
@SubscribeEvent
public void onClientConnectedToServerEvent(FMLNetworkEvent.ClientConnectedToServerEvent aEvent) {
mFirstTick = true;
+ mReloadCount++;
+ }
+
+ @Override
+ public int getReloadCount() {
+ return mReloadCount;
}
@SubscribeEvent
diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java
index ae95184062..2e18ea9693 100644
--- a/src/main/java/gregtech/common/GT_Proxy.java
+++ b/src/main/java/gregtech/common/GT_Proxy.java
@@ -776,6 +776,10 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
public void onClientConnectedToServerEvent(FMLNetworkEvent.ClientConnectedToServerEvent aEvent) {
}
+ public int getReloadCount() {
+ return 0;
+ }
+
@SubscribeEvent
public void onArrowNockEvent(ArrowNockEvent aEvent) {
if ((!aEvent.isCanceled()) && (GT_Utility.isStackValid(aEvent.result))
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java
index 6c2a1eabc5..e57af3a219 100644
--- a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java
+++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java
@@ -14,7 +14,7 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract {
//WATCH OUT FOR TEXTURE ID's
public GT_Block_Casings8() {
super(GT_Item_Casings8.class, "gt.blockcasings8", GT_Material_Casings.INSTANCE);
- for (int i = 0; i < 6; i = (i + 1)) {
+ for (int i = 0; i < 8; i = (i + 1)) {
Textures.BlockIcons.casingTexturePages[1][i+48] = TextureFactory.of(this, i);
}
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Chemically Inert Machine Casing");
@@ -23,6 +23,8 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract {
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Mining Black Plutonium Casing");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Extreme Engine Intake Casing");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Europium Reinforced Radiation Proof Machine Casing");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Advanced Rhodium Plated Palladium Machine Casing");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Advanced Iridium Plated Machine Casing");
ItemList.Casing_Chemically_Inert.set(new ItemStack(this, 1, 0));
ItemList.Casing_Pipe_Polytetrafluoroethylene.set(new ItemStack(this, 1, 1));
@@ -30,6 +32,8 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract {
ItemList.Casing_MiningBlackPlutonium.set(new ItemStack(this, 1, 3));
ItemList.Casing_ExtremeEngineIntake.set(new ItemStack(this, 1, 4));
ItemList.Casing_AdvancedRadiationProof.set(new ItemStack(this, 1, 5));
+ ItemList.Casing_Advanced_Rhodium_Palladium.set(new ItemStack(this, 1, 6));
+ ItemList.Casing_Advanced_Iridium.set(new ItemStack(this, 1, 7));
}
@Override
@@ -48,6 +52,10 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract {
return Textures.BlockIcons.MACHINE_CASING_EXTREME_ENGINE_INTAKE.getIcon();//changed color in a terrible way
case 5:
return Textures.BlockIcons.MACHINE_CASING_ADVANCEDRADIATIONPROOF.getIcon();
+ case 6:
+ return Textures.BlockIcons.MACHINE_CASING_RHODIUM_PALLADIUM.getIcon();
+ case 7:
+ return Textures.BlockIcons.MACHINE_CASING_IRIDIUM.getIcon();
}
return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon();
}
diff --git a/src/main/java/gregtech/loaders/postload/GT_CraftingRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_CraftingRecipeLoader.java
index 9ea396a30e..a2d80924d8 100644
--- a/src/main/java/gregtech/loaders/postload/GT_CraftingRecipeLoader.java
+++ b/src/main/java/gregtech/loaders/postload/GT_CraftingRecipeLoader.java
@@ -31,7 +31,8 @@ public class GT_CraftingRecipeLoader implements Runnable {
private static final String aTextIron2 = "XXX";
private static final long bits_no_remove_buffered = GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.BUFFERED;
private static final long bits = GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED;
- private static final long bitsd = GT_ModHandler.RecipeBits.DISMANTLEABLE | bits;
+ private static final String aTextPlateWrench = "PwP";
+
@Override
public void run() {
@@ -700,5 +701,8 @@ public class GT_CraftingRecipeLoader implements Runnable {
GT_ModHandler.addShapelessCraftingRecipe(Materials.Fireclay.getDust(2), new Object[]{Materials.Brick.getDust(1), Materials.Clay.getDust(1)});
GT_Values.RA.addFluidSolidifierRecipe(ItemList.Shape_Mold_Ball.get(0), new FluidStack(FluidRegistry.getFluid("molten.borosilicateglass"), 144), ItemList.VOLUMETRIC_FLASK.get(1), 44, 24);
- }
+ if (Loader.isModLoaded("bartworks")) {
+ GT_ModHandler.addCraftingRecipe(ItemList.Casing_Advanced_Rhodium_Palladium.get(1L), bits, new Object[]{"PhP", "PFP", aTextPlateWrench, 'P', GT_ModHandler.getModItem("bartworks", "gt.bwMetaGeneratedplate", 1L, 88), 'F', OrePrefixes.frameGt.get(Materials.Chrome)});
+ }
+ }
}
diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java
index 6202d363e7..d9d45e5b5e 100644
--- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java
+++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java
@@ -1485,6 +1485,10 @@ public class GT_MachineRecipeLoader implements Runnable {
GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 6L), ItemList.Casing_Turbine.get(1L), ItemList.Casing_Turbine2.get(1L), 50, 16);
GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 6L), ItemList.Casing_Turbine.get(1L), ItemList.Casing_Turbine3.get(1L), 50, 16);
GT_Values.RA.addAssemblerRecipe(ItemList.Casing_SolidSteel.get(1), GT_Utility.getIntegratedCircuit(6), Materials.Polytetrafluoroethylene.getMolten(216), ItemList.Casing_Chemically_Inert.get(1), 50, 16);
+ if (Loader.isModLoaded("bartworks")) {
+ GT_Values.RA.addAssemblerRecipe(GT_ModHandler.getModItem("bartworks", "gt.bwMetaGeneratedplate", 6L, 88), GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Chrome, 1L), ItemList.Casing_Advanced_Rhodium_Palladium.get(1L), 50, 16);
+ }
+ GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 6L), GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Iridium, 1L), ItemList.Casing_Advanced_Iridium.get(1L), 50, 16);
if (GT_Mod.gregtechproxy.mHardMachineCasings) {
GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Lead, 2L), ItemList.Casing_ULV.get(1L), Materials.Plastic.getMolten(288), ItemList.Hull_ULV.get(1L), 25, 16);
diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java
index 98e3284f4a..062e42ca5f 100644
--- a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java
+++ b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java
@@ -85,6 +85,7 @@ public class GT_Loader_MetaTileEntities implements Runnable {//TODO CHECK CIRCUI
GT_ModHandler.addCraftingRecipe(ItemList.Casing_MagicHazard.get(1L), bits, new Object[]{" Y ", "BM ", " ", 'M', ItemList.Casing_SolidSteel, 'Y', Dyes.dyeYellow, 'B', Dyes.dyeBlack});
GT_ModHandler.addCraftingRecipe(ItemList.Casing_FrostHazard.get(1L), bits, new Object[]{"BY ", " M ", " ", 'M', ItemList.Casing_SolidSteel, 'Y', Dyes.dyeYellow, 'B', Dyes.dyeBlack});
GT_ModHandler.addCraftingRecipe(ItemList.Casing_NoiseHazard.get(1L), bits, new Object[]{" ", " M ", "BY ", 'M', ItemList.Casing_SolidSteel, 'Y', Dyes.dyeYellow, 'B', Dyes.dyeBlack});
+ GT_ModHandler.addCraftingRecipe(ItemList.Casing_Advanced_Iridium.get(1L), bits, new Object[]{"PhP", "PFP", aTextPlateWrench, 'P', OrePrefixes.plate.get(Materials.Iridium), 'F', OrePrefixes.frameGt.get(Materials.Iridium)});
GT_ModHandler.addShapelessCraftingRecipe(ItemList.Casing_SolidSteel.get(1L), bits, new Object[]{ItemList.Casing_Stripes_A});
GT_ModHandler.addShapelessCraftingRecipe(ItemList.Casing_SolidSteel.get(1L), bits, new Object[]{ItemList.Casing_Stripes_B});
diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java
index f51acd9a77..2c56766162 100644
--- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java
+++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java
@@ -11,10 +11,8 @@ import codechicken.nei.recipe.GuiUsageRecipe;
import codechicken.nei.recipe.TemplateRecipeHandler;
import gregtech.GT_Mod;
import gregtech.api.enums.GT_Values;
-import gregtech.api.enums.ItemList;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.gui.GT_GUIContainer_BasicMachine;
-import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.ItemData;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_Log;
@@ -27,19 +25,22 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
-import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import java.awt.*;
+import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.stream.Collectors;
public class GT_NEI_DefaultHandler extends RecipeMapHandler {
public static final int sOffsetX = 5;
public static final int sOffsetY = 11;
+ private int mCachedRecipesVersion = -1;
+ private SoftReference<List<CachedDefaultRecipe>> mCachedRecipes = null;
static {
GuiContainerManager.addInputHandler(new GT_RectHandler());
@@ -51,12 +52,27 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier()));
}
+ @Deprecated
public List<GT_Recipe> getSortedRecipes() {
List<GT_Recipe> result = new ArrayList<>(this.mRecipeMap.mRecipeList);
Collections.sort(result);
return result;
}
+ public List<CachedDefaultRecipe> getCache() {
+ List<CachedDefaultRecipe> cache;
+ if (mCachedRecipesVersion == GT_Mod.gregtechproxy.getReloadCount() || mCachedRecipes == null || (cache = mCachedRecipes.get()) == null) {
+ cache = mRecipeMap.mRecipeList.stream() // do not use parallel stream. This is already parallelized by NEI
+ .filter(r -> !r.mHidden)
+ .map(CachedDefaultRecipe::new)
+ .collect(Collectors.toList());
+ // while the NEI parallelize handlers, for each individual handler it still uses sequential execution model
+ // so we do not need any synchronization here
+ mCachedRecipes = new SoftReference<>(cache);
+ }
+ return cache;
+ }
+
public static void drawText(int aX, int aY, String aString, int aColor) {
Minecraft.getMinecraft().fontRenderer.drawString(aString, aX, aY, aColor);
}
@@ -69,11 +85,7 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(getOverlayIdentifier())) {
- for (GT_Recipe tRecipe : getSortedRecipes()) {
- if (!tRecipe.mHidden) {
- this.arecipes.add(new CachedDefaultRecipe(tRecipe));
- }
- }
+ arecipes.addAll(getCache());
} else {
super.loadCraftingRecipes(outputId, results);
}
@@ -83,7 +95,7 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
public void loadCraftingRecipes(ItemStack aResult) {
ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult);
- ArrayList<ItemStack> tResults = new ArrayList();
+ ArrayList<ItemStack> tResults = new ArrayList<>();
tResults.add(aResult);
tResults.add(GT_OreDictUnificator.get(true, aResult));
if ((tPrefixMaterial != null) && (!tPrefixMaterial.mBlackListed) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) {
@@ -101,16 +113,9 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
if (tFluidStack != null) {
tResults.addAll(GT_Utility.getContainersFromFluid(tFluidStack));
}
- for (GT_Recipe tRecipe : getSortedRecipes()) {
- if (!tRecipe.mHidden) {
- CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe);
- for (ItemStack tStack : tResults) {
- if (tNEIRecipe.contains(tNEIRecipe.mOutputs, tStack)) {
- this.arecipes.add(tNEIRecipe);
- break;
- }
- }
- }
+ for (CachedDefaultRecipe recipe : getCache()) {
+ if (tResults.stream().anyMatch(stack -> recipe.contains(recipe.mOutputs, stack)))
+ arecipes.add(recipe);
}
}
@@ -118,7 +123,7 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
public void loadUsageRecipes(ItemStack aInput) {
ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput);
- ArrayList<ItemStack> tInputs = new ArrayList();
+ ArrayList<ItemStack> tInputs = new ArrayList<>();
tInputs.add(aInput);
tInputs.add(GT_OreDictUnificator.get(false, aInput));
if ((tPrefixMaterial != null) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) {
@@ -136,18 +141,10 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
if (tFluidStack != null) {
tInputs.addAll(GT_Utility.getContainersFromFluid(tFluidStack));
}
- for (GT_Recipe tRecipe : getSortedRecipes()) {
- if (!tRecipe.mHidden) {
- CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe);
- for (ItemStack tStack : tInputs) {
- if (tNEIRecipe.contains(tNEIRecipe.mInputs, tStack)) {
- this.arecipes.add(tNEIRecipe);
- break;
- }
- }
- }
+ for (CachedDefaultRecipe recipe : getCache()) {
+ if (tInputs.stream().anyMatch(stack -> recipe.contains(recipe.mInputs, stack)))
+ arecipes.add(recipe);
}
- CachedDefaultRecipe tNEIRecipe;
}
@Override
@@ -367,15 +364,14 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
if (this.permutated) {
return;
}
- ArrayList<ItemStack> tDisplayStacks = new ArrayList();
+ ArrayList<ItemStack> tDisplayStacks = new ArrayList<>();
for (ItemStack tStack : this.items) {
if (GT_Utility.isStackValid(tStack)) {
if (tStack.getItemDamage() == 32767) {
List<ItemStack> permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem());
if (!permutations.isEmpty()) {
- ItemStack stack;
- for (Iterator i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, stack))) {
- stack = (ItemStack) i$.next();
+ for (ItemStack permutation : permutations) {
+ tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, permutation));
}
} else {
ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize);
@@ -387,7 +383,7 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
}
}
}
- this.items = ((ItemStack[]) tDisplayStacks.toArray(new ItemStack[0]));
+ this.items = tDisplayStacks.toArray(new ItemStack[0]);
if (this.items.length == 0) {
this.items = new ItemStack[]{new ItemStack(Blocks.fire)};
}
@@ -412,14 +408,14 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
maybeIn = aRecipe.getInputPositionedStacks();
} catch(NullPointerException npe) {
maybeIn = null;
- GT_Log.err.println("CachedDefaultRecipe - Invalid InputPositionedStacks " + aRecipe.toString());
+ GT_Log.err.println("CachedDefaultRecipe - Invalid InputPositionedStacks " + aRecipe);
npe.printStackTrace(GT_Log.err);
}
try {
maybeOut = aRecipe.getOutputPositionedStacks();
} catch (NullPointerException npe) {
maybeOut = null;
- GT_Log.err.println("CachedDefaultRecipe - Invalid OutputPositionedStacks " + aRecipe.toString());
+ GT_Log.err.println("CachedDefaultRecipe - Invalid OutputPositionedStacks " + aRecipe);
npe.printStackTrace(GT_Log.err);
}
diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_IRIDIUM.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_IRIDIUM.png
new file mode 100644
index 0000000000..0aa1df15fe
--- /dev/null
+++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_IRIDIUM.png
Binary files differ
diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_RHODIUM_PALLADIUM.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_RHODIUM_PALLADIUM.png
new file mode 100644
index 0000000000..2b26fcd3e0
--- /dev/null
+++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_RHODIUM_PALLADIUM.png
Binary files differ