Fixed incompatibility of dict iterator

Closes #121
This commit is contained in:
TheDarkDnKTv 2021-05-18 06:18:58 +03:00
parent bc57a5c97a
commit e6c48f2f40
8 changed files with 123 additions and 87 deletions

View file

@ -885,28 +885,28 @@ public class GT_ModHandler {
/**
* Shapeless Crafting Recipes. Deletes conflicting Recipes too.
*/
public static boolean addShapelessCraftingRecipe(ItemStack aResult, Object[] aRecipe) {
public static boolean addShapelessCraftingRecipe(ItemStack aResult, Object... aRecipe) {
return addShapelessCraftingRecipe(aResult, isElectricItem(aResult), aRecipe);
}
/**
* Shapeless Crafting Recipes. Deletes conflicting Recipes too.
*/
public static boolean addShapelessCraftingRecipe(ItemStack aResult, boolean aUseIC2Handler, Object[] aRecipe) {
public static boolean addShapelessCraftingRecipe(ItemStack aResult, boolean aUseIC2Handler, Object... aRecipe) {
return addShapelessCraftingRecipe(aResult, aUseIC2Handler, true, aRecipe);
}
/**
* Shapeless Crafting Recipes. Deletes conflicting Recipes too.
*/
public static boolean addShapelessCraftingRecipe(ItemStack aResult, boolean aUseIC2Handler, boolean aBuffered, Object[] aRecipe) {
public static boolean addShapelessCraftingRecipe(ItemStack aResult, boolean aUseIC2Handler, boolean aBuffered, Object... aRecipe) {
return addShapelessCraftingRecipe(aResult, aUseIC2Handler, aBuffered, false, aRecipe);
}
/**
* Shapeless Crafting Recipes. Deletes conflicting Recipes too.
*/
public static boolean addShapelessCraftingRecipe(ItemStack aResult, boolean aUseIC2Handler, boolean aBuffered, boolean aKeepNBT, Object[] aRecipe) {
public static boolean addShapelessCraftingRecipe(ItemStack aResult, boolean aUseIC2Handler, boolean aBuffered, boolean aKeepNBT, Object... aRecipe) {
aResult = GT_OreDictUnificator.get(true, aResult);
if (aRecipe == null || aRecipe.length <= 0) return false;
for (byte i = 0; i < aRecipe.length; i++) {

View file

@ -91,9 +91,13 @@ public class RecipeHandler {
while (iter.hasNext() && !smeltingRemove.isEmpty()) {
Entry<ItemStack, ItemStack> entr = iter.next();
for (IFurnanceMatcher matcher : smeltingRemove) {
Iterator<IFurnanceMatcher> iter2 = smeltingRemove.iterator();
while (iter2.hasNext()) {
IFurnanceMatcher matcher = iter2.next();
if (matcher.matches(entr.getKey(), entr.getValue())) {
iter.remove();
iter2.remove();
break;
}
}
}
@ -138,6 +142,7 @@ public class RecipeHandler {
if (matcher.matches(entry.getKey(), entry.getValue())) {
iter.remove();
iter2.remove();
break;
}
}
}

View file

@ -66,10 +66,6 @@ public class ProcessingIngot1 implements IOreRecipeRegistrator {
RecipeMaps.BENDING.factory().EUt(24).duration(Math.max(aMaterial.getMass() * 2, 1)).setShaped(true).input(RecipeEntry.fromStacks(1, entry.ores, Match.STRICT)).nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 1)).output(GT_OreDictUnificator.get(OrePrefixes.plate, aMaterial, 1)).buildAndRegister();
if (GT_OreDictUnificator.get(OrePrefixes.plateDense, aMaterial) != null)
RecipeMaps.BENDING.factory().EUt(24).duration(Math.max(aMaterial.getMass() * 18, 1)).setShaped(true).input(RecipeEntry.fromStacks(9, entry.ores, Match.STRICT)).nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 9)).output(GT_OreDictUnificator.get(OrePrefixes.plateDense, aMaterial, 1)).buildAndRegister();
// RecipeMaps.BENDING.factory().EUt(24).duration(Math.max(aMaterial.getMass() * 4, 1)).setShaped(true).input(RecipeEntry.fromStacks(2, entry.ores, Match.STRICT)).nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 2)).output(GT_OreDictUnificator.get(OrePrefixes.plateDouble, aMaterial, 1)).buildAndRegister();
// RecipeMaps.BENDING.factory().EUt(24).duration(Math.max(aMaterial.getMass() * 6, 1)).setShaped(true).input(RecipeEntry.fromStacks(3, entry.ores, Match.STRICT)).nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 3)).output(GT_OreDictUnificator.get(OrePrefixes.plateTriple, aMaterial, 1)).buildAndRegister();
// RecipeMaps.BENDING.factory().EUt(24).duration(Math.max(aMaterial.getMass() * 8, 1)).setShaped(true).input(RecipeEntry.fromStacks(4, entry.ores, Match.STRICT)).nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 4)).output(GT_OreDictUnificator.get(OrePrefixes.plateQuadruple, aMaterial, 1)).buildAndRegister();
// RecipeMaps.BENDING.factory().EUt(24).duration(Math.max(aMaterial.getMass() * 10, 1)).setShaped(true).input(RecipeEntry.fromStacks(5, entry.ores, Match.STRICT)).nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 5)).output(GT_OreDictUnificator.get(OrePrefixes.plateQuintuple, aMaterial, 1)).buildAndRegister();
}
if (!OrePrefixes.block.isIgnored(aMaterial)) {

View file

@ -30,23 +30,17 @@ public class ProcessingIngot2 implements IOreRecipeRegistrator {
for (OreDictEntry entry : entries) {
Materials aMaterial = this.getMaterial(aPrefix, entry);
if (this.isExecutable(aPrefix, aMaterial)) {
if (!aMaterial.contains(SubTag.NO_SMASHING)) {
RecipeMaps.BENDING.factory().EUt(24).setShaped(true)
.duration(Math.max(aMaterial.getMass() * 2, 1))
.input(RecipeEntry.fromStacks(entry.ores, Match.STRICT))
.nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 1))
.output(GT_OreDictUnificator.get(OrePrefixes.plateDouble, aMaterial, 1L))
.buildAndRegister();
ItemStack aStack = GT_OreDictUnificator.get(OrePrefixes.ingotDouble, aMaterial);
if (aStack != null && !aMaterial.contains(SubTag.NO_SMASHING)) {
RecipeMaps.BENDING.factory().EUt(24).setShaped(true)
.duration(Math.max(aMaterial.getMass() * 4, 1))
.input(RecipeEntry.fromStacks(2, entry.ores, Match.STRICT))
.input(OrePrefixes.ingot, aMaterial, 2)
.nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 2))
.output(GT_OreDictUnificator.get(OrePrefixes.plateQuadruple, aMaterial, 1L))
.output(aStack)
.buildAndRegister();
}
ItemStack aStack = GT_OreDictUnificator.get(OrePrefixes.ingotDouble, aMaterial);
if (aStack != null && !aMaterial.contains(SubTag.NO_SMASHING) && GregTech_API.sRecipeFile.get(GT_ConfigCategories.Tools.hammerdoubleingot, OrePrefixes.ingot.get(aMaterial), true)) {
if (GregTech_API.sRecipeFile.get(GT_ConfigCategories.Tools.hammerdoubleingot, OrePrefixes.ingot.get(aMaterial), true)) {
RecipeHandler.executeOnFinish(() -> {
GT_ModHandler.addCraftingRecipe(GT_Utility.copyAmount(1, aStack),
new Object[] { "I", "B", "H", 'H', GT_ToolDictNames.craftingToolHardHammer, 'I', OrePrefixes.ingot.get(aMaterial), 'B', OrePrefixes.ingot.get(aMaterial) });
@ -56,6 +50,17 @@ public class ProcessingIngot2 implements IOreRecipeRegistrator {
} else {
RecipeHandler.executeOnFinish(() -> GT_ModHandler.addShapelessCraftingRecipe(GT_Utility.copyAmount(1, aStack), new Object[] { OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial) }));
}
ItemStack plate = GT_OreDictUnificator.get(OrePrefixes.plateDouble, aMaterial);
if (plate != null) {
RecipeMaps.BENDING.factory().EUt(24).setShaped(true)
.duration(Math.max(aMaterial.getMass() * 2, 1))
.input(RecipeEntry.fromStacks(entry.ores, Match.STRICT))
.nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 1))
.output(plate)
.buildAndRegister();
}
}
}
}
}

View file

@ -30,21 +30,16 @@ public class ProcessingIngot3 implements IOreRecipeRegistrator {
for (OreDictEntry entry : entries) {
Materials aMaterial = this.getMaterial(aPrefix, entry);
if (this.isExecutable(aPrefix, aMaterial)) {
if (!aMaterial.contains(SubTag.NO_SMASHING)) {
RecipeMaps.BENDING.factory().EUt(24).setShaped(true)
.duration(Math.max(aMaterial.getMass() * 2, 1))
.input(RecipeEntry.fromStacks(entry.ores, Match.STRICT))
.nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 1))
.output(GT_OreDictUnificator.get(OrePrefixes.plateTriple, aMaterial, 1L));
ItemStack aStack = GT_OreDictUnificator.get(OrePrefixes.plateTriple, aMaterial);
if (aStack != null && !aMaterial.contains(SubTag.NO_SMASHING)) {
RecipeMaps.BENDING.factory().EUt(24).setShaped(true)
.duration(Math.max(aMaterial.getMass() * 6, 1))
.input(RecipeEntry.fromStacks(3, entry.ores, Match.STRICT))
.input(OrePrefixes.ingot, aMaterial, 3)
.nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 3))
.output(GT_OreDictUnificator.get(OrePrefixes.plateTriple, aMaterial, 1L));
}
.output(aStack);
ItemStack aStack = GT_OreDictUnificator.get(OrePrefixes.plateTriple, aMaterial);
if (aStack != null && !aMaterial.contains(SubTag.NO_SMASHING) && GregTech_API.sRecipeFile.get(GT_ConfigCategories.Tools.hammertripleingot, OrePrefixes.ingot.get(aMaterial), true)) {
if (GregTech_API.sRecipeFile.get(GT_ConfigCategories.Tools.hammertripleingot, OrePrefixes.ingot.get(aMaterial), true)) {
RecipeHandler.executeOnFinish(() -> {
GT_ModHandler.addCraftingRecipe(GT_Utility.copyAmount(1, aStack),
new Object[] { "I", "B", "H", 'H', GT_ToolDictNames.craftingToolHardHammer, 'I', OrePrefixes.ingotDouble.get(aMaterial), 'B', OrePrefixes.ingot.get(aMaterial) });
@ -56,6 +51,17 @@ public class ProcessingIngot3 implements IOreRecipeRegistrator {
new Object[] { OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial) }));
}
}
ItemStack plate = GT_OreDictUnificator.get(OrePrefixes.plateTriple, aMaterial);
if (plate != null) {
RecipeMaps.BENDING.factory().EUt(24).setShaped(true)
.duration(Math.max(aMaterial.getMass() * 3, 1))
.input(RecipeEntry.fromStacks(entry.ores, Match.STRICT))
.nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 1))
.output(plate)
.buildAndRegister();
}
}
}
}
}

View file

@ -17,8 +17,8 @@ import gregtechmod.api.util.OreDictEntry;
import gregtechmod.common.RecipeHandler;
import gregtechmod.common.recipe.RecipeEntry;
import gregtechmod.common.recipe.RecipeMaps;
import net.minecraft.item.ItemStack;
import gregtechmod.common.recipe.RecipeEntry.Match;
import net.minecraft.item.ItemStack;
public class ProcessingIngot4 implements IOreRecipeRegistrator {
@ -30,17 +30,17 @@ public class ProcessingIngot4 implements IOreRecipeRegistrator {
for (OreDictEntry entry : entries) {
Materials aMaterial = this.getMaterial(aPrefix, entry);
if (this.isExecutable(aPrefix, aMaterial)) {
if (!aMaterial.contains(SubTag.NO_SMASHING)) {
ItemStack aStack = GT_OreDictUnificator.get(aPrefix, aMaterial);
if (aStack != null && !aMaterial.contains(SubTag.NO_SMASHING)) {
RecipeMaps.BENDING.factory().EUt(24).setShaped(true)
.duration(Math.max(aMaterial.getMass() * 2, 1))
.input(RecipeEntry.fromStacks(entry.ores, Match.STRICT))
.nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 1))
.output(GT_OreDictUnificator.get(OrePrefixes.plateQuadruple, aMaterial, 1L))
.input(OrePrefixes.ingot, aMaterial, 4)
.nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 4))
.output(aStack)
.buildAndRegister();
}
ItemStack aStack = GT_OreDictUnificator.get(OrePrefixes.plateQuadruple, aMaterial);
if (aStack != null && !aMaterial.contains(SubTag.NO_SMASHING) && GregTech_API.sRecipeFile.get(GT_ConfigCategories.Tools.hammerquadrupleingot, OrePrefixes.ingot.get(aMaterial), true)) {
if (GregTech_API.sRecipeFile.get(GT_ConfigCategories.Tools.hammerquadrupleingot, OrePrefixes.ingot.get(aMaterial), true)) {
RecipeHandler.executeOnFinish(() -> {
GT_ModHandler.addCraftingRecipe(GT_Utility.copyAmount(1, aStack),
new Object[] { "I", "B", "H", 'H', GT_ToolDictNames.craftingToolHardHammer, 'I', OrePrefixes.ingotTriple.get(aMaterial), 'B', OrePrefixes.ingot.get(aMaterial) });
@ -48,7 +48,18 @@ public class ProcessingIngot4 implements IOreRecipeRegistrator {
new Object[] { GT_ToolDictNames.craftingToolForgeHammer, OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial) });
});
} else {
RecipeHandler.executeOnFinish(() -> GT_ModHandler.addShapelessCraftingRecipe(GT_Utility.copyAmount(1, aStack), new Object[] { OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial) }));
RecipeHandler.executeOnFinish(() -> GT_ModHandler.addShapelessCraftingRecipe(GT_Utility.copyAmount(1, aStack), OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial)));
}
ItemStack plate = GT_OreDictUnificator.get(OrePrefixes.plateQuadruple, aMaterial);
if (plate != null) {
RecipeMaps.BENDING.factory().EUt(24).setShaped(true)
.duration(Math.max(aMaterial.getMass() * 4, 1))
.input(RecipeEntry.fromStacks(entry.ores, Match.STRICT))
.nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 1))
.output(plate)
.buildAndRegister();
}
}
}
}

View file

@ -30,17 +30,15 @@ public class ProcessingIngot5 implements IOreRecipeRegistrator {
for (OreDictEntry entry : entries) {
Materials aMaterial = this.getMaterial(aPrefix, entry);
if (this.isExecutable(aPrefix, aMaterial)) {
if (!aMaterial.contains(SubTag.NO_SMASHING)) {
ItemStack aStack = GT_OreDictUnificator.get(aPrefix, aMaterial);
if (aStack != null && !aMaterial.contains(SubTag.NO_SMASHING)) {
RecipeMaps.BENDING.factory().EUt(24).setShaped(true)
.duration(Math.max(aMaterial.getMass() * 2, 1))
.input(RecipeEntry.fromStacks(5, entry.ores, Match.STRICT))
.nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 1))
.output(GT_OreDictUnificator.get(OrePrefixes.plateQuintuple, aMaterial, 1L))
.input(OrePrefixes.ingot, aMaterial, 5)
.nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 5))
.output(aStack)
.buildAndRegister();
}
ItemStack aStack = GT_OreDictUnificator.get(OrePrefixes.plateQuintuple, aMaterial);
if (aStack != null && !aMaterial.contains(SubTag.NO_SMASHING) && GregTech_API.sRecipeFile.get(GT_ConfigCategories.Tools.hammerquintupleingot, OrePrefixes.ingot.get(aMaterial), true)) {
if (GregTech_API.sRecipeFile.get(GT_ConfigCategories.Tools.hammerquintupleingot, OrePrefixes.ingot.get(aMaterial), true)) {
RecipeHandler.executeOnFinish(() -> {
GT_ModHandler.addCraftingRecipe(GT_Utility.copyAmount(1, aStack),
new Object[] { "I", "B", "H", 'H', GT_ToolDictNames.craftingToolHardHammer, 'I', OrePrefixes.ingotQuadruple.get(aMaterial), 'B', OrePrefixes.ingot.get(aMaterial) });
@ -51,6 +49,17 @@ public class ProcessingIngot5 implements IOreRecipeRegistrator {
RecipeHandler.executeOnFinish(() -> GT_ModHandler.addShapelessCraftingRecipe(GT_Utility.copyAmount(1, aStack),
new Object[] { OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial), OrePrefixes.ingot.get(aMaterial) }));
}
ItemStack plate = GT_OreDictUnificator.get(OrePrefixes.plateQuintuple, aMaterial);
if (plate != null) {
RecipeMaps.BENDING.factory().EUt(24).setShaped(true)
.duration(Math.max(aMaterial.getMass() * 5, 1))
.input(RecipeEntry.fromStacks(entry.ores, Match.STRICT))
.nonConsumable(GT_Items.Circuit_Integrated.getWithDamage(0, 1))
.output(plate)
.buildAndRegister();
}
}
}
}
}

View file

@ -14,6 +14,7 @@ import gregtechmod.api.util.OreDictEntry;
import gregtechmod.common.RecipeHandler;
import gregtechmod.common.recipe.RecipeEntry;
import gregtechmod.common.recipe.RecipeMaps;
import net.minecraft.item.ItemStack;
import gregtechmod.common.recipe.RecipeEntry.Match;
public class ProcessingNugget implements IOreRecipeRegistrator {
@ -26,10 +27,12 @@ public class ProcessingNugget implements IOreRecipeRegistrator {
for (OreDictEntry entry : entries) {
Materials aMaterial = this.getMaterial(aPrefix, entry);
if (this.isExecutable(aPrefix, aMaterial) && (aMaterial.mTypes & 2) != 0) {
RecipeMaps.LATHE.factory().EUt(8)
ItemStack round = GT_OreDictUnificator.get(OrePrefixes.round, aMaterial, 1L);
if (round != null) RecipeMaps.LATHE.factory().EUt(8)
.duration(Math.max(aMaterial.getMass() / 4, 1))
.input(RecipeEntry.fromStacks(entry.ores, Match.STRICT))
.output(GT_OreDictUnificator.get(OrePrefixes.round, aMaterial, 1L))
.output(round)
.buildAndRegister();
RecipeMaps.ALLOY_SMELTING.factory().EUt(2).duration(200)
.input(RecipeEntry.fromStacks(9, entry.ores, Match.STRICT))
@ -38,6 +41,7 @@ public class ProcessingNugget implements IOreRecipeRegistrator {
RecipeHandler.executeOnFinish(() -> {
GameRegistry.addRecipe(new GT_Shapeless_Recipe(GT_OreDictUnificator.get(OrePrefixes.ingot, aMaterial, 1L), new Object[] { entry.oreDictName, entry.oreDictName, entry.oreDictName, entry.oreDictName, entry.oreDictName, entry.oreDictName, entry.oreDictName, entry.oreDictName, entry.oreDictName }));
if (round != null)
GameRegistry.addRecipe(new GT_Shapeless_Recipe(GT_OreDictUnificator.get(OrePrefixes.round, aMaterial, 1L), new Object[] { GT_ToolDictNames.craftingToolFile.toString(), entry.oreDictName, entry.oreDictName }));
});
}