mirror of
https://github.com/GTNewHorizons/ThaumicEnergistics.git
synced 2026-10-25 20:32:27 +00:00
Merge pull request #13 from repo-alt/AE2-RV3
Allow updating obsolete patterns
This commit is contained in:
2 files changed
+27
-2
No files matched your search
+1
-1
@@ -28,7 +28,7 @@ apply plugin: 'java'
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
version = "1.1.3.11-GTNH"
|
||||
version = "1.1.3.12-GTNH"
|
||||
group= "thaumicenergistics" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "thaumicenergistics"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package thaumicenergistics.common.inventory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -8,6 +8,8 @@ import net.minecraftforge.common.util.Constants;
|
||||
import thaumicenergistics.common.integration.tc.ArcaneCraftingPattern;
|
||||
import thaumicenergistics.common.items.ItemKnowledgeCore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Handles an {@link ItemKnowledgeCore}
|
||||
*
|
||||
@@ -167,6 +169,8 @@ public class HandlerKnowledgeCore
|
||||
|
||||
if( existingPattern == null )
|
||||
{
|
||||
// remove the existing pattern, e.g. if the result changed
|
||||
removePatternSameInputs(pattern);
|
||||
// Add the pattern
|
||||
this.patterns.add( pattern );
|
||||
|
||||
@@ -175,6 +179,27 @@ public class HandlerKnowledgeCore
|
||||
}
|
||||
|
||||
}
|
||||
private void removePatternSameInputs(final ArcaneCraftingPattern pattern) {
|
||||
IAEItemStack[] newInputs = pattern.getInputs();
|
||||
// Loop over all stored patterns
|
||||
for (ArcaneCraftingPattern p : this.patterns) {
|
||||
IAEItemStack[] oldInputs = p.getInputs();
|
||||
if (newInputs.length != oldInputs.length)
|
||||
continue;
|
||||
boolean match = true;
|
||||
for (int i = 0; i < newInputs.length; ++i) {
|
||||
if (!ItemStack.areItemStacksEqual(oldInputs[i].getItemStack(), newInputs[i].getItemStack())) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
// can't be more than one duplicate
|
||||
this.patterns.remove(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructs the handler to close.
|
||||
|
||||
Reference in new issue
Block a user