Skip to content

Commit

Permalink
Speed up pattern validation by using now-fixed cache (#3011)
Browse files Browse the repository at this point in the history
  • Loading branch information
necauqua authored Jun 13, 2021
1 parent c2adba6 commit b24ce55
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.refinedmods.refinedstorage.inventory.item.validator;

import com.refinedmods.refinedstorage.RSItems;
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternProvider;
import com.refinedmods.refinedstorage.item.PatternItem;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

Expand All @@ -15,6 +17,9 @@ public PatternItemValidator(World world) {

@Override
public boolean test(ItemStack stack) {
if (stack.getItem() == RSItems.PATTERN.get()) {
return PatternItem.fromCache(world, stack).isValid();
}
return stack.getItem() instanceof ICraftingPatternProvider && ((ICraftingPatternProvider) stack.getItem()).create(world, stack, null).isValid();
}
}

0 comments on commit b24ce55

Please sign in to comment.