Skip to content

Commit

Permalink
Implement equals and hashCode for SizedIngredients (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster authored May 17, 2024
1 parent e9e8af0 commit a7edbae
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import java.util.Objects;
import java.util.stream.Stream;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
Expand Down Expand Up @@ -143,6 +144,18 @@ public ItemStack[] getItems() {
return cachedStacks;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SizedIngredient other)) return false;
return count == other.count && ingredient.equals(other.ingredient);
}

@Override
public int hashCode() {
return Objects.hash(ingredient, count);
}

@Override
public String toString() {
return count + "x " + ingredient;
Expand Down

0 comments on commit a7edbae

Please sign in to comment.