Fix recipe has empty result (#837)

This commit is contained in:
IzzelAliz 2022-12-12 20:13:27 +08:00
parent f4277eecc2
commit 203a22e3d4
No known key found for this signature in database
GPG Key ID: EE50E123A11D8338
7 changed files with 27 additions and 3 deletions

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ public abstract class ShapedRecipeMixin implements IRecipeBridge {
@Override @Override
public Recipe bridge$toBukkitRecipe() { 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); return new ArclightSpecialRecipe((net.minecraft.world.item.crafting.Recipe<?>) this);
} }
CraftItemStack result = CraftItemStack.asCraftMirror(this.result); CraftItemStack result = CraftItemStack.asCraftMirror(this.result);

View File

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

View File

@ -1,6 +1,7 @@
package io.izzel.arclight.common.mixin.core.world.item.crafting; 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.bridge.core.item.crafting.IRecipeBridge;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
@ -26,6 +27,9 @@ public class SmithingRecipeMixin implements IRecipeBridge {
@Override @Override
public Recipe bridge$toBukkitRecipe() { public Recipe bridge$toBukkitRecipe() {
if (this.result.isEmpty()) {
return new ArclightSpecialRecipe((UpgradeRecipe) (Object) this);
}
CraftItemStack result = CraftItemStack.asCraftMirror(this.result); CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
return new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); 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; 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.bridge.core.item.crafting.IRecipeBridge;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.AbstractCookingRecipe; import net.minecraft.world.item.crafting.AbstractCookingRecipe;
@ -23,6 +24,9 @@ public abstract class SmokingRecipeMixin extends AbstractCookingRecipe implement
@Override @Override
public Recipe bridge$toBukkitRecipe() { public Recipe bridge$toBukkitRecipe() {
if (this.result.isEmpty()) {
return new ArclightSpecialRecipe(this);
}
CraftItemStack result = CraftItemStack.asCraftMirror(this.result); CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.getId()), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.getId()), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
recipe.setGroup(this.group); recipe.setGroup(this.group);