Skip to content

Commit

Permalink
use ItemStackSnapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooy1 committed Sep 6, 2021
1 parent 92f2014 commit 8ff9108
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.mooy1</groupId>
<artifactId>InfinityLib</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack;
import io.github.thebusybiscuit.slimefun4.libraries.dough.items.ItemStackSnapshot;
import io.github.thebusybiscuit.slimefun4.libraries.dough.items.ItemUtils;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
Expand Down Expand Up @@ -102,8 +103,9 @@ public final CraftingBlock addRecipesFrom(MachineRecipeType recipeType) {

@Nullable
protected final CraftingBlockRecipe getOutput(ItemStack[] input) {
ItemStackSnapshot[] snapshots = ItemStackSnapshot.wrapArray(input);
for (CraftingBlockRecipe recipe : recipes) {
if (recipe.check(input)) {
if (recipe.check(snapshots)) {
return recipe;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.inventory.ItemStack;

import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.libraries.dough.items.ItemStackSnapshot;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;

@Getter
Expand All @@ -17,11 +18,11 @@ public final class CraftingBlockRecipe {

CraftingBlockRecipe(ItemStack output, ItemStack[] inputs) {
this.output = output;
this.inputs = inputs;
this.inputs = ItemStackSnapshot.wrapArray(inputs);
this.item = SlimefunItem.getByItem(output);
}

boolean check(ItemStack[] input) {
boolean check(ItemStackSnapshot[] input) {
for (int i = 0; i < inputs.length; i++) {
if (!SlimefunUtils.isItemSimilar(input[i], inputs[i], true, true)) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ protected void setup(BlockMenuPreset preset) {
}

@Override
protected final int[] getInputSlots() {
protected int[] getInputSlots() {
return layout.inputSlots();
}

@Override
protected final int[] getOutputSlots() {
protected int[] getOutputSlots() {
return layout.outputSlots();
}

Expand Down

0 comments on commit 8ff9108

Please sign in to comment.