Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/main/java/gregtech/api/capability/DualHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import gregtech.api.capability.impl.FluidTankList;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.util.ItemStackHashStrategy;
import gregtech.api.util.hash.ItemStackHashStrategy;

import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
Expand All @@ -17,9 +17,6 @@

public class DualHandler implements IItemHandlerModifiable, IMultipleTankHandler, INotifiableHandler {

@NotNull
private static final ItemStackHashStrategy strategy = ItemStackHashStrategy.comparingAll();

@NotNull
protected IItemHandlerModifiable itemDelegate;
@NotNull
Expand Down Expand Up @@ -71,7 +68,7 @@ public int getSlots() {
@Override
public @NotNull ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) {
var remainder = itemDelegate.insertItem(slot, stack, simulate);
if (!simulate && !strategy.equals(remainder, stack))
if (!simulate && !ItemStackHashStrategy.comparingAll.equals(remainder, stack))
onContentsChanged();
return remainder;
}
Expand All @@ -93,8 +90,9 @@ public int getSlotLimit(int slot) {
public void setStackInSlot(int slot, @NotNull ItemStack stack) {
var oldStack = itemDelegate.getStackInSlot(slot);
itemDelegate.setStackInSlot(slot, stack);
if (!strategy.equals(oldStack, stack))
if (!ItemStackHashStrategy.comparingAll.equals(oldStack, stack)) {
onContentsChanged();
}
}

@Override
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/gregtech/api/items/armor/ArmorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import gregtech.api.capability.GregtechCapabilities;
import gregtech.api.capability.IElectricItem;
import gregtech.api.util.ItemStackHashStrategy;
import gregtech.api.util.hash.ItemStackHashStrategy;
import gregtech.common.ConfigHolder;

import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -185,8 +185,7 @@ public static ActionResult<ItemStack> canEat(EntityPlayer player, ItemStack food
* @return Formated list
*/
public static List<ItemStack> format(List<ItemStack> input) {
Object2IntMap<ItemStack> items = new Object2IntOpenCustomHashMap<>(
ItemStackHashStrategy.comparingAllButCount());
Object2IntMap<ItemStack> items = new Object2IntOpenCustomHashMap<>(ItemStackHashStrategy.comparingAllButCount);
List<ItemStack> output = new ArrayList<>();
for (ItemStack itemStack : input) {
if (items.containsKey(itemStack)) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/recipes/Recipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import gregtech.api.recipes.properties.RecipePropertyStorage;
import gregtech.api.recipes.properties.RecipePropertyStorageImpl;
import gregtech.api.util.GTUtility;
import gregtech.api.util.ItemStackHashStrategy;
import gregtech.api.util.hash.ItemStackHashStrategy;
import gregtech.integration.groovy.GroovyScriptModule;

import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -371,7 +371,7 @@ private int hashInputs() {
for (GTRecipeInput recipeIngredient : this.inputs) {
if (!recipeIngredient.isOreDict()) {
for (ItemStack is : recipeIngredient.getInputStacks()) {
hash = 31 * hash + ItemStackHashStrategy.comparingAll().hashCode(is);
hash = 31 * hash + ItemStackHashStrategy.comparingAll.hashCode(is);
}
} else {
hash = 31 * hash + recipeIngredient.getOreDict();
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/gregtech/api/recipes/logic/ParallelLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import gregtech.api.recipes.RecipeBuilder;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.ingredients.GTRecipeInput;
import gregtech.api.util.FluidStackHashStrategy;
import gregtech.api.util.GTHashMaps;
import gregtech.api.util.GTUtility;
import gregtech.api.util.ItemStackHashStrategy;
import gregtech.api.util.OverlayedFluidHandler;
import gregtech.api.util.OverlayedItemHandler;
import gregtech.api.util.hash.FluidStackHashStrategy;
import gregtech.api.util.hash.ItemStackHashStrategy;

import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
Expand Down Expand Up @@ -182,7 +182,7 @@ public static int limitParallelByItemsIncremental(@NotNull List<ItemStack> recip
Object2IntMap<ItemStack> recipeOutputsToAppend = GTHashMaps.fromItemStackCollection(outputsToAppend);

Object2IntMap<ItemStack> appendedResultMap = new Object2IntLinkedOpenCustomHashMap<>(recipeOutputs,
ItemStackHashStrategy.comparingAllButCount());
ItemStackHashStrategy.comparingAllButCount);
recipeOutputsToAppend
.forEach((stackKey, amt) -> appendedResultMap.merge(stackKey, amt * multiplier, Integer::sum));

Expand Down Expand Up @@ -405,8 +405,6 @@ protected static int getMaxRatioFluid(@NotNull Object2IntMap<FluidStack> countFl
}
}

FluidStackHashStrategy fluidStrategy = FluidStackHashStrategy.comparingAllButAmount();

// Iterate through the recipe inputs, excluding the not consumable fluids from the fluid inventory map
for (FluidStack notConsumableFluid : notConsumableMap.keySet()) {
int needed = notConsumableMap.getInt(notConsumableFluid);
Expand All @@ -416,7 +414,7 @@ protected static int getMaxRatioFluid(@NotNull Object2IntMap<FluidStack> countFl
// Strip the Non-consumable tags here, as FluidKey compares the tags, which causes finding matching
// fluids
// in the input tanks to fail, because there is nothing in those hatches with a non-consumable tag
if (fluidStrategy.equals(notConsumableFluid, inputFluid)) {
if (FluidStackHashStrategy.comparingAllButAmount.equals(notConsumableFluid, inputFluid)) {
available = countFluid.getInt(inputFluid);
if (available > needed) {
countFluid.replace(inputFluid, available - needed);
Expand Down Expand Up @@ -453,7 +451,7 @@ protected static int getMaxRatioFluid(@NotNull Object2IntMap<FluidStack> countFl
int available = 0;
// For every fluid gathered from the fluid inputs.
for (FluidStack inputFluid : countFluid.keySet()) {
if (fluidStrategy.equals(stack, inputFluid)) {
if (FluidStackHashStrategy.comparingAllButAmount.equals(stack, inputFluid)) {
available += countFluid.getInt(inputFluid);
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/gregtech/api/util/GTHashMaps.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package gregtech.api.util;

import gregtech.api.util.hash.FluidStackHashStrategy;
import gregtech.api.util.hash.ItemStackHashStrategy;

import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
Expand Down Expand Up @@ -101,8 +104,8 @@ public static Object2IntMap<ItemStack> fromItemStackCollection(@NotNull Iterable
*/
@NotNull
public static Object2IntMap<ItemStack> createItemStackMap(boolean linked) {
ItemStackHashStrategy strategy = ItemStackHashStrategy.comparingAllButCount();
return linked ? new Object2IntLinkedOpenCustomHashMap<>(strategy) : new Object2IntOpenCustomHashMap<>(strategy);
return linked ? new Object2IntLinkedOpenCustomHashMap<>(ItemStackHashStrategy.comparingAllButCount) :
new Object2IntOpenCustomHashMap<>(ItemStackHashStrategy.comparingAllButCount);
}

/**
Expand All @@ -111,8 +114,8 @@ public static Object2IntMap<ItemStack> createItemStackMap(boolean linked) {
*/
@NotNull
public static Object2IntMap<FluidStack> createFluidStackMap(boolean linked) {
var strategy = FluidStackHashStrategy.comparingAllButAmount();
return linked ? new Object2IntLinkedOpenCustomHashMap<>(strategy) : new Object2IntOpenCustomHashMap<>(strategy);
return linked ? new Object2IntLinkedOpenCustomHashMap<>(FluidStackHashStrategy.comparingAllButAmount) :
new Object2IntOpenCustomHashMap<>(FluidStackHashStrategy.comparingAllButAmount);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/gregtech/api/util/GTUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.unification.stack.ItemAndMetadata;
import gregtech.api.util.function.impl.TimedProgressSupplier;
import gregtech.api.util.hash.ItemStackHashStrategy;

import net.minecraft.block.BlockRedstoneWire;
import net.minecraft.block.BlockSnow;
Expand Down Expand Up @@ -878,7 +879,7 @@ public static Set<ItemStack> getAllSubItems(@NotNull Item item) {
if (tab == null || tab == CreativeTabs.SEARCH) continue;
item.getSubItems(tab, subItems);
}
return new ObjectOpenCustomHashSet<>(subItems, ItemStackHashStrategy.comparingItemDamageCount());
return new ObjectOpenCustomHashSet<>(subItems, ItemStackHashStrategy.comparingAllButNBT);
}

/**
Expand Down

This file was deleted.

148 changes: 0 additions & 148 deletions src/main/java/gregtech/api/util/ItemStackHashStrategy.java

This file was deleted.

6 changes: 4 additions & 2 deletions src/main/java/gregtech/api/util/OverlayedItemHandler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gregtech.api.util;

import gregtech.api.util.hash.ItemStackHashStrategy;

import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;

Expand Down Expand Up @@ -56,7 +58,7 @@ public int insertStackedItemStack(@NotNull ItemStack stack, int amountToInsert)
initSlot(i);
// if it's the same item or there is no item in the slot
ItemStack slotKey = this.slots[i].getItemStack();
if (slotKey.isEmpty() || ItemStackHashStrategy.comparingAllButCount().equals(slotKey, stack)) {
if (slotKey.isEmpty() || ItemStackHashStrategy.comparingAllButCount.equals(slotKey, stack)) {
// if the slot is not full
int canInsertUpTo = Math.min(this.slots[i].getSlotLimit() - this.slots[i].getCount(),
stack.getMaxStackSize());
Expand Down Expand Up @@ -140,7 +142,7 @@ public ItemStack getItemStack() {
}

public void setItemStack(@NotNull ItemStack itemStack) {
if (!ItemStackHashStrategy.comparingAllButCount().equals(this.itemStack, itemStack)) {
if (!ItemStackHashStrategy.comparingAllButCount.equals(this.itemStack, itemStack)) {
this.itemStack = itemStack;
this.slotLimit = Math.min(itemStack.getMaxStackSize(), slotLimit);
}
Expand Down
Loading
Loading