Fix recipe has empty result (#837)

This commit is contained in:
IzzelAliz 2022-12-12 20:13:27 +08:00
parent ff387cc03e
commit 516d491734
No known key found for this signature in database
GPG Key ID: EE50E123A11D8338
8 changed files with 28 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package io.izzel.arclight.common.mixin.core.world.item.crafting;
import io.izzel.arclight.common.bridge.core.item.crafting.IRecipeBridge;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
@ -24,6 +25,9 @@ public abstract class BlastingRecipeMixin extends AbstractCookingRecipe implemen
@Override
public Recipe bridge$toBukkitRecipe() {
if (this.result.isEmpty()) {
return new ArclightSpecialRecipe(this);
}
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
CraftBlastingRecipe recipe = new CraftBlastingRecipe(CraftNamespacedKey.fromMinecraft(this.getId()), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
recipe.setGroup(this.group);

View File

@ -1,6 +1,7 @@
package io.izzel.arclight.common.mixin.core.world.item.crafting;
import io.izzel.arclight.common.bridge.core.item.crafting.IRecipeBridge;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
@ -24,6 +25,9 @@ public abstract class CampfireCookingRecipeMixin extends AbstractCookingRecipe i
@Override
public Recipe bridge$toBukkitRecipe() {
if (this.result.isEmpty()) {
return new ArclightSpecialRecipe(this);
}
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
CraftCampfireRecipe recipe = new CraftCampfireRecipe(CraftNamespacedKey.fromMinecraft(this.getId()), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
recipe.setGroup(this.group);

View File

@ -30,7 +30,7 @@ public abstract class ShapedRecipeMixin implements IRecipeBridge {
@Override
public Recipe bridge$toBukkitRecipe() {
if (this.getWidth() < 0 || this.getWidth() > 3 || this.getHeight() < 0 || this.getHeight() > 3) {
if (this.getWidth() < 1 || this.getWidth() > 3 || this.getHeight() < 1 || this.getHeight() > 3 || this.result.isEmpty()) {
return new ArclightSpecialRecipe((net.minecraft.world.item.crafting.Recipe<?>) this);
}
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);

View File

@ -1,6 +1,7 @@
package io.izzel.arclight.common.mixin.core.world.item.crafting;
import io.izzel.arclight.common.bridge.core.item.crafting.IRecipeBridge;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
import net.minecraft.core.NonNullList;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingBookCategory;
@ -22,12 +23,15 @@ public abstract class ShapelessRecipeMixin implements IRecipeBridge {
@Shadow @Final String group;
@Shadow @Final NonNullList<Ingredient> ingredients;
@Shadow public abstract CraftingBookCategory category();
// @formatter:off
// @formatter:on
@Override
public Recipe bridge$toBukkitRecipe() {
if (this.result.isEmpty()) {
return new ArclightSpecialRecipe((ShapelessRecipe) (Object) this);
}
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
CraftShapelessRecipe recipe = new CraftShapelessRecipe(result, (ShapelessRecipe)(Object) this);
CraftShapelessRecipe recipe = new CraftShapelessRecipe(result, (ShapelessRecipe) (Object) this);
recipe.setGroup(this.group);
recipe.setCategory(CraftRecipe.getCategory(this.category()));
for (Ingredient list : this.ingredients) {

View File

@ -1,6 +1,7 @@
package io.izzel.arclight.common.mixin.core.world.item.crafting;
import io.izzel.arclight.common.bridge.core.item.crafting.IRecipeBridge;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
@ -24,6 +25,9 @@ public abstract class SmeltingRecipeMixin extends AbstractCookingRecipe implemen
@Override
public Recipe bridge$toBukkitRecipe() {
if (this.result.isEmpty()) {
return new ArclightSpecialRecipe(this);
}
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);

View File

@ -1,6 +1,7 @@
package io.izzel.arclight.common.mixin.core.world.item.crafting;
import io.izzel.arclight.common.bridge.core.item.crafting.IRecipeBridge;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
@ -26,6 +27,9 @@ public class SmithingRecipeMixin implements IRecipeBridge {
@Override
public Recipe bridge$toBukkitRecipe() {
if (this.result.isEmpty()) {
return new ArclightSpecialRecipe((UpgradeRecipe) (Object) this);
}
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
return new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition));
}

View File

@ -1,6 +1,7 @@
package io.izzel.arclight.common.mixin.core.world.item.crafting;
import io.izzel.arclight.common.bridge.core.item.crafting.IRecipeBridge;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
@ -24,6 +25,9 @@ public abstract class SmokingRecipeMixin extends AbstractCookingRecipe implement
@Override
public Recipe bridge$toBukkitRecipe() {
if (this.result.isEmpty()) {
return new ArclightSpecialRecipe(this);
}
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.getId()), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
recipe.setGroup(this.group);

View File

@ -18,7 +18,7 @@ allprojects {
apiVersion = '1.5.1'
toolsVersion = '1.3.0'
mixinVersion = '0.8.5'
versionName = 'horn'
versionName = 'great-horn'
gitHash = getGitHash()
}