From 4cbc4b40b3e1d5197b6e390311472fffcf4bec21 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 27 May 2018 16:16:10 +1000 Subject: $ Hopefully fixed issue where BoP limestone is valid for Fluorite. $ Fixed the ABS not using the correct texture on the top layer input hatch. % More internal work on LFTR rewrite. --- src/Java/gtPlusPlus/api/objects/data/AutoMap.java | 10 +++ .../objects/minecraft/NoConflictGTRecipeMap.java | 94 ++++++++++++++++++++-- 2 files changed, 99 insertions(+), 5 deletions(-) (limited to 'src/Java/gtPlusPlus/api') diff --git a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java index 7ffa2deb42..b3762dd243 100644 --- a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java @@ -9,6 +9,7 @@ public class AutoMap implements Iterable, Cloneable, Serializable { * The Internal Map */ protected final Map mInternalMap; + protected final Map mInternalNameMap; /** * The Internal ID @@ -23,6 +24,7 @@ public class AutoMap implements Iterable, Cloneable, Serializable { public AutoMap(Map defaultMapType) { mInternalMap = defaultMapType; + mInternalNameMap = new HashMap(); } @Override @@ -46,6 +48,7 @@ public class AutoMap implements Iterable, Cloneable, Serializable { } public synchronized V set(V object){ + mInternalNameMap.put(""+object.hashCode(), (mInternalID+1)); return mInternalMap.put(mInternalID++, object); } @@ -93,5 +96,12 @@ public class AutoMap implements Iterable, Cloneable, Serializable { public synchronized final int getInternalID() { return mInternalID; } + + public synchronized final boolean remove(V value) { + if (this.mInternalMap.containsValue(value)) { + return this.mInternalMap.remove(mInternalNameMap.get(""+value.hashCode()), value); + } + return false; + } } diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/NoConflictGTRecipeMap.java b/src/Java/gtPlusPlus/api/objects/minecraft/NoConflictGTRecipeMap.java index 0aeaedb01d..78e925fe04 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/NoConflictGTRecipeMap.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/NoConflictGTRecipeMap.java @@ -1,13 +1,14 @@ package gtPlusPlus.api.objects.minecraft; import java.util.Collection; +import java.util.Iterator; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Recipe; import gtPlusPlus.api.objects.data.AutoMap; -public class NoConflictGTRecipeMap { +public class NoConflictGTRecipeMap implements Collection { private AutoMap mRecipeCache = new AutoMap(); private final IGregTechTileEntity mMachineType; @@ -15,25 +16,108 @@ public class NoConflictGTRecipeMap { public NoConflictGTRecipeMap () { this(null); } - + public NoConflictGTRecipeMap (IGregTechTileEntity tile0) { this.mMachineType = tile0; } public boolean put(GT_Recipe recipe) { return add(recipe); } - + public boolean add(GT_Recipe recipe) { return mRecipeCache.setValue(recipe); } - + public Collection getRecipeMap() { return mRecipeCache.values(); } - + public boolean isMapValidForMachine(IGregTechTileEntity tile) { return tile == mMachineType; } + @Override + public boolean addAll(Collection arg0) { + int a = 0; + for (Object v : arg0) { + if (!this.mRecipeCache.containsValue((GT_Recipe) v)) { + this.mRecipeCache.put((GT_Recipe) v); + a++; + } + } + return a > 0; + } + + @Override + public void clear() { + mRecipeCache.clear(); + } + + @Override + public boolean contains(Object arg0) { + return mRecipeCache.containsValue((GT_Recipe) arg0); + } + + @Override + public boolean containsAll(Collection arg0) { + int a = 0; + for (Object v : arg0) { + if (this.mRecipeCache.containsValue((GT_Recipe) v)) { + a++; + } + } + return a == arg0.size(); + } + + @Override + public boolean isEmpty() { + return mRecipeCache.isEmpty(); + } + + @Override + public Iterator iterator() { + return mRecipeCache.iterator(); + } + + @Override + public boolean remove(Object arg0) { + return mRecipeCache.remove((GT_Recipe) arg0); + } + + @Override + public boolean removeAll(Collection arg0) { + int a = 0; + for (Object v : arg0) { + if (this.mRecipeCache.containsValue((GT_Recipe) v)) { + this.mRecipeCache.remove((GT_Recipe) v); + a++; + } + } + return a > 0; + } + + @Override + public boolean retainAll(Collection arg0) { + int mStartSize = this.mRecipeCache.size(); + this.mRecipeCache = (AutoMap) arg0; + int mEndsize = this.mRecipeCache.size(); + return mStartSize != mEndsize; + } + + @Override + public int size() { + return this.mRecipeCache.size(); + } + + @Override + public Object[] toArray() { + return this.mRecipeCache.toArray(); + } + + @Override + public T[] toArray(T[] arg0) { + return (T[]) this.mRecipeCache.toArray(); + } + } -- cgit