aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2020-01-15 14:55:05 +0100
committerbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2020-01-15 14:55:05 +0100
commita0782b97055efc31016b18ac6a495c9d0372f815 (patch)
treed56e37e6808f9819443c2fb6393d772117290b3d
parent4cf9fb11b978843c58a01a2d5d5182802e774bbf (diff)
downloadGT5-Unofficial-a0782b97055efc31016b18ac6a495c9d0372f815.tar.gz
GT5-Unofficial-a0782b97055efc31016b18ac6a495c9d0372f815.tar.bz2
GT5-Unofficial-a0782b97055efc31016b18ac6a495c9d0372f815.zip
fixed rejoin issues
+ made circuit assembler recipes get readded if server is switched and re-calcuted + added a command to clear the crafting cache + made the NEI OreHandler more stable + worked a bit on implementing the APL + version increase Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Former-commit-id: f784e1ce2c2486f002d21f407010c87a41688f62
-rw-r--r--build.properties2
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java2
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ClearCraftingCache.java46
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java25
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java49
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java32
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java6
7 files changed, 127 insertions, 35 deletions
diff --git a/build.properties b/build.properties
index d8837dced6..128bba6264 100644
--- a/build.properties
+++ b/build.properties
@@ -22,7 +22,7 @@
mc_version=1.7.10
majorUpdate=0
minorUpdate=5
-buildNumber=6
+buildNumber=7
APIVersion=8
ic2.version=2.2.828-experimental
gregtech.version=5.09.32.36
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
index f1ad6e2b2a..9cb1dffbaf 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
@@ -32,6 +32,7 @@ import com.github.bartimaeusnek.bartworks.client.creativetabs.GT2Tab;
import com.github.bartimaeusnek.bartworks.client.creativetabs.bartworksTab;
import com.github.bartimaeusnek.bartworks.client.textures.PrefixTextureLinker;
import com.github.bartimaeusnek.bartworks.common.commands.ChangeConfig;
+import com.github.bartimaeusnek.bartworks.common.commands.ClearCraftingCache;
import com.github.bartimaeusnek.bartworks.common.commands.PrintRecipeListToFile;
import com.github.bartimaeusnek.bartworks.common.commands.SummonRuin;
import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler;
@@ -206,6 +207,7 @@ public final class MainMod {
event.registerServerCommand(new SummonRuin());
event.registerServerCommand(new ChangeConfig());
event.registerServerCommand(new PrintRecipeListToFile());
+ event.registerServerCommand(new ClearCraftingCache());
}
@Mod.EventHandler
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ClearCraftingCache.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ClearCraftingCache.java
new file mode 100644
index 0000000000..42385c60f1
--- /dev/null
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ClearCraftingCache.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2018-2020 bartimaeusnek
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.github.bartimaeusnek.bartworks.common.commands;
+
+import com.github.bartimaeusnek.ASM.BWCoreStaticReplacementMethodes;
+import net.minecraft.command.CommandBase;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.ChatComponentText;
+
+public class ClearCraftingCache extends CommandBase {
+ @Override
+ public String getCommandName() {
+ return "bwclr";
+ }
+
+ @Override
+ public String getCommandUsage(ICommandSender p_71518_1_) {
+ return "bwclr";
+ }
+
+ @Override
+ public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {
+ BWCoreStaticReplacementMethodes.RECENTLYUSEDRECIPES.clear();
+ p_71515_1_.addChatMessage(new ChatComponentText("Recipe Cache cleared? "+(BWCoreStaticReplacementMethodes.RECENTLYUSEDRECIPES.size() == 0)));
+ }
+}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java
index b23fa6fd0b..902bf6681c 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java
@@ -96,21 +96,30 @@ public class BW_NEI_OreHandler extends TemplateRecipeHandler {
public void drawExtras(int recipe) {
if ((recipe < this.arecipes.size()) && (this.arecipes.get(recipe) instanceof CachedOreRecipe) ) {
CachedOreRecipe cachedOreRecipe = (CachedOreRecipe) this.arecipes.get(recipe);
-
- GuiDraw.drawString(ChatColorHelper.BOLD + "DIM: " + ChatColorHelper.RESET + cachedOreRecipe.worldGen.getDimName(), 0, 40, 0, false);
+ if (cachedOreRecipe == null || cachedOreRecipe.getOtherStacks() == null ||
+ cachedOreRecipe.getOtherStacks().get(0) == null || cachedOreRecipe.getOtherStacks().get(1) == null
+ || cachedOreRecipe.getOtherStacks().get(2) == null || cachedOreRecipe.getOtherStacks().get(3) == null ||
+ cachedOreRecipe.getOtherStacks().get(0).item == null || cachedOreRecipe.getOtherStacks().get(1).item == null
+ || cachedOreRecipe.getOtherStacks().get(2).item == null || cachedOreRecipe.getOtherStacks().get(3).item == null
+ )
+ return;
+ if (cachedOreRecipe.worldGen != null)
+ GuiDraw.drawString(ChatColorHelper.BOLD + "DIM: " + ChatColorHelper.RESET + cachedOreRecipe.worldGen.getDimName(), 0, 40, 0, false);
GuiDraw.drawString(ChatColorHelper.BOLD + "Primary:", 0, 50, 0, false);
- GuiDraw.drawString(this.arecipes.get(recipe).getOtherStacks().get(0).item.getDisplayName(), 0, 60, 0, false);
+ GuiDraw.drawString(cachedOreRecipe.getOtherStacks().get(0).item.getDisplayName(), 0, 60, 0, false);
if (!cachedOreRecipe.small) {
GuiDraw.drawString(ChatColorHelper.BOLD + "Secondary:", 0, 70, 0, false);
- GuiDraw.drawString(this.arecipes.get(recipe).getOtherStacks().get(1).item.getDisplayName(), 0, 80, 0, false);
+ GuiDraw.drawString(cachedOreRecipe.getOtherStacks().get(1).item.getDisplayName(), 0, 80, 0, false);
GuiDraw.drawString(ChatColorHelper.BOLD + "InBetween:", 0, 90, 0, false);
- GuiDraw.drawString(this.arecipes.get(recipe).getOtherStacks().get(2).item.getDisplayName(), 0, 100, 0, false);
+ GuiDraw.drawString(cachedOreRecipe.getOtherStacks().get(2).item.getDisplayName(), 0, 100, 0, false);
GuiDraw.drawString(ChatColorHelper.BOLD + "Sporadic:", 0, 110, 0, false);
- GuiDraw.drawString(this.arecipes.get(recipe).getOtherStacks().get(3).item.getDisplayName(), 0, 120, 0, false);
+ GuiDraw.drawString(cachedOreRecipe.getOtherStacks().get(3).item.getDisplayName(), 0, 120, 0, false);
} else {
- GuiDraw.drawString(ChatColorHelper.BOLD + "Amount per Chunk:",0,70,0,false);
- GuiDraw.drawString(((CachedOreRecipe) this.arecipes.get(recipe)).worldGen.mDensity+"",0,80,0, false);
+ if (cachedOreRecipe.worldGen != null) {
+ GuiDraw.drawString(ChatColorHelper.BOLD + "Amount per Chunk:", 0, 70, 0, false);
+ GuiDraw.drawString(cachedOreRecipe.worldGen.mDensity + "", 0, 80, 0, false);
+ }
}
}
super.drawExtras(recipe);
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java
index 4ffade4528..a7823ed112 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java
@@ -57,21 +57,37 @@ public class CircuitImprintLoader {
static final HashBiMap<CircuitData,ItemStack> bwCircuitTagMap = HashBiMap.create(20);
private static final HashSet<IRecipe> recipeWorldCache = new HashSet<>();
private static final HashSet<GT_Recipe> gtrecipeWorldCache = new HashSet<>();
+ private static final HashSet<GT_Recipe> ORIGINAL_CAL_RECIPES = new HashSet<>();
+ private static final HashSet<GT_Recipe> MODIFIED_CAL_RECIPES = new HashSet<>();
public static void run() {
HashSet<GT_Recipe> toRem = new HashSet<>();
HashSet<GT_Recipe> toAdd = new HashSet<>();
- boolean newServer = checkAndDeleteCALRecipes();
+ deleteCALRecipesAndTags();
+ rebuildCircuitAssemblerMap(toRem,toAdd);
+ exchangeRecipesInList(toRem,toAdd);
+ makeCircuitImprintRecipes();
+
+ toRem = null;
+ toAdd = null;
+ }
+
+ private static void reAddOriginalRecipes(){
+ GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.removeAll(MODIFIED_CAL_RECIPES);
+ GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.addAll(ORIGINAL_CAL_RECIPES);
+ ORIGINAL_CAL_RECIPES.clear();
+ MODIFIED_CAL_RECIPES.clear();
+ }
+
+ private static void rebuildCircuitAssemblerMap(HashSet<GT_Recipe> toRem,HashSet<GT_Recipe> toAdd) {
+ reAddOriginalRecipes();
GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.forEach(e -> CircuitImprintLoader.handleCircuitRecipeRebuilding(e, toRem, toAdd));
- exchangeRecipesInList(toRem,toAdd,newServer);
- makeCircuitImprintRecipes(newServer);
}
private static void handleCircuitRecipeRebuilding(GT_Recipe circuitRecipe, HashSet<GT_Recipe> toRem, HashSet<GT_Recipe> toAdd) {
ItemStack[] outputs = circuitRecipe.mOutputs;
String name = getTypeFromOreDict(outputs);
-
if (name.contains("Circuit") || name.contains("circuit")) {
CircuitImprintLoader.recipeTagMap.put(CircuitImprintLoader.getTagFromStack(outputs[0]), circuitRecipe.copy());
@@ -80,7 +96,7 @@ public class CircuitImprintLoader {
GT_Recipe newRecipe = CircuitImprintLoader.reBuildRecipe(circuitRecipe);
if (newRecipe != null)
BWRecipes.instance.getMappingsFor(BWRecipes.CIRCUITASSEMBLYLINE).addRecipe(newRecipe);
- addCutoffRecipeToSets(toRem,toAdd,circuitRecipe);
+ addCutoffRecipeToSets(toRem,toAdd,circuitRecipe);
} else {
if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier))
toRem.add(circuitRecipe);
@@ -97,11 +113,11 @@ public class CircuitImprintLoader {
return OreDictionary.getOreName(oreIDS[0]);
}
- private static void exchangeRecipesInList(HashSet<GT_Recipe> toRem, HashSet<GT_Recipe> toAdd, boolean newServer) {
- if (!newServer) {
- GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.addAll(toAdd);
- GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.removeAll(toRem);
- }
+ private static void exchangeRecipesInList(HashSet<GT_Recipe> toRem, HashSet<GT_Recipe> toAdd) {
+ GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.addAll(toAdd);
+ GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.removeAll(toRem);
+ ORIGINAL_CAL_RECIPES.addAll(toRem);
+ MODIFIED_CAL_RECIPES.addAll(toAdd);
}
private static void addCutoffRecipeToSets(HashSet<GT_Recipe> toRem, HashSet<GT_Recipe> toAdd, GT_Recipe circuitRecipe) {
@@ -182,9 +198,8 @@ public class CircuitImprintLoader {
}
}
- private static void makeCircuitImprintRecipes(boolean newServer) {
- if (newServer)
- removeOldRecipesFromRegistries();
+ private static void makeCircuitImprintRecipes() {
+ removeOldRecipesFromRegistries();
CircuitImprintLoader.recipeTagMap.keySet().forEach(e -> {
makeAndAddSlicingRecipe(e);
makeAndAddCraftingRecipes(e);
@@ -225,6 +240,7 @@ public class CircuitImprintLoader {
for (GT_Recipe recipe : CircuitImprintLoader.recipeTagMap.get(tag)) {
eut = Math.min(eut, recipe.mEUt);
}
+
eut = Math.min(eut, BW_Util.getMachineVoltageFromTier(BW_Util.getCircuitTierFromOreDictName(OreDictionary.getOreName(OreDictionary.getOreIDs(stack)[0]))));
GT_Recipe slicingRecipe = new BWRecipes.DynamicGTRecipe(true,new ItemStack[]{stack,ItemList.Shape_Slicer_Flat.get(0)},new ItemStack[]{BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1)},null,null,null,null,300,eut, BW_Util.CLEANROOM);
gtrecipeWorldCache.add(slicingRecipe);
@@ -263,14 +279,9 @@ public class CircuitImprintLoader {
return ItemStack.loadItemStackFromNBT(tagCompound);
}
- private static boolean checkAndDeleteCALRecipes() {
- boolean newServer = false;
- if (BWRecipes.instance.getMappingsFor(BWRecipes.CIRCUITASSEMBLYLINE).mRecipeList.size() > 0){
+ private static void deleteCALRecipesAndTags() {
BWRecipes.instance.getMappingsFor(BWRecipes.CIRCUITASSEMBLYLINE).mRecipeList.clear();
recipeTagMap.clear();
- newServer = true;
- }
- return newServer;
}
} \ No newline at end of file
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java
index a1067b051e..4d49e8523f 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java
@@ -74,12 +74,26 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public E removeFirst() {
- throw new NotImplementedException("");
+ E first = head.getELEMENT();
+ AccessPriorityListNode<E> node = head;
+ head = node.getNext();
+ head.setBefore(null);
+ node.destroy();
+ node = null;
+ this.size--;
+ return first;
}
@Override
public E removeLast() {
- throw new NotImplementedException("");
+ E last = tail.getELEMENT();
+ AccessPriorityListNode<E> node = tail;
+ tail = node.getBefore();
+ tail.setNext(null);
+ node.destroy();
+ node = null;
+ this.size--;
+ return last;
}
@Override
@@ -237,7 +251,7 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public E poll() {
- throw new NotImplementedException("");
+ return removeFirst();
}
@Override
@@ -257,11 +271,15 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public E pop() {
- throw new NotImplementedException("");
+ return removeFirst();
}
@Override
public boolean remove(Object o) {
+// Object p;
+// for (Iterator it = this.iterator(); it.hasNext(); o.equals(p)){
+// p = it.next();
+// }
throw new NotImplementedException("");
}
@@ -272,9 +290,9 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public boolean addAll(Collection<? extends E> c) {
- for (E e : c) {
- this.addLast(e);
- }
+ if (c == null)
+ return false;
+ c.forEach(this::addLast);
return true;
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java
index b8fd357027..3c0a037a88 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java
@@ -72,4 +72,10 @@ public class AccessPriorityListNode<E> {
public void setBefore(AccessPriorityListNode<E> before) {
this.before = before;
}
+
+ void destroy(){
+ this.before = null;
+ this.next = null;
+ this.priority = 0L;
+ }
}