Fixed being able to convert any item into botched gems

This commit is contained in:
Sollace 2022-10-07 09:03:24 +02:00
parent 43ef65261c
commit 4a73cae094

View file

@ -166,7 +166,7 @@ public class SpellbookScreenHandler extends ScreenHandler {
.findFirst()
.filter(recipe -> result.shouldCraftRecipe(world, (ServerPlayerEntity)this.inventory.player, recipe))
.map(recipe -> recipe.craft(input))
.orElse(input.getTraits().applyTo(UItems.BOTCHED_GEM.getDefaultStack())) : ItemStack.EMPTY;
.orElseGet(this::getFallbackStack) : ItemStack.EMPTY;
outputSlot.setStack(resultStack);
setPreviousTrackedSlot(outputSlot.id, resultStack);
@ -175,6 +175,15 @@ public class SpellbookScreenHandler extends ScreenHandler {
});
}
private ItemStack getFallbackStack() {
ItemStack gemStack = gemSlot.getStack();
if (gemStack.isOf(UItems.GEMSTONE) || gemStack.isOf(UItems.BOTCHED_GEM)) {
return input.getTraits().applyTo(UItems.BOTCHED_GEM.getDefaultStack());
}
return ItemStack.EMPTY;
}
@Override
public ItemStack transferSlot(PlayerEntity player, int index) {
Slot sourceSlot = slots.get(index);