Skip to content

Commit

Permalink
fix duplicate assembly line research entries (#2584)
Browse files Browse the repository at this point in the history
  • Loading branch information
TechLord22 authored Aug 22, 2024
1 parent 3aee29a commit 518a896
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/gregtech/api/recipes/RecipeMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public boolean removeRecipe(@NotNull Recipe recipe) {
* @see GTRecipeHandler#removeAllRecipes(RecipeMap)
*/
@ApiStatus.Internal
void removeAllRecipes() {
protected void removeAllRecipes() {
if (GroovyScriptModule.isCurrentlyRunning()) {
this.lookup.getRecipes(false).forEach(this.getGroovyScriptRecipeMap()::addBackup);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public boolean removeRecipe(@NotNull Recipe recipe) {
return true;
}

@Override
protected void removeAllRecipes() {
super.removeAllRecipes();
researchEntries.clear();
}

@Override
public void addDataStickEntry(@NotNull String researchId, @NotNull Recipe recipe) {
if (researchId.contains("xmetaitem.")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import gregtech.api.recipes.RecipeMaps;
import gregtech.api.recipes.machines.IResearchRecipeMap;
import gregtech.api.util.AssemblyLineManager;
import gregtech.api.util.ItemStackHashStrategy;

import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
Expand Down Expand Up @@ -41,7 +42,7 @@ public void addInformation(@NotNull ItemStack itemStack, List<String> lines) {
.getDataStickEntry(researchId);
if (recipes != null && !recipes.isEmpty()) {
lines.add(I18n.format("behavior.data_item.assemblyline.title"));
Collection<ItemStack> added = new ObjectOpenHashSet<>();
Collection<ItemStack> added = new ObjectOpenCustomHashSet<>(ItemStackHashStrategy.comparingAllButCount());
for (Recipe recipe : recipes) {
ItemStack output = recipe.getOutputs().get(0);
if (added.add(output)) {
Expand Down

0 comments on commit 518a896

Please sign in to comment.