-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 新增 CraftTweaker 兼容类 CraftingOthers,用于处理特殊配方 - 修改 CraftingTable 类,使其仅处理基础工作台配方 - 更新 EternalSingularityCraftRecipe 和 InfinityCatalystCraftRecipe 的配方类型为 CRAFTING_OTHERS_RECIPE - 在 KubeJSAvaritiaPlugin 中注册永恒奇点合成的配方序列化器 - 新增 ModRecipeTypes.CRAFTING_OTHERS_RECIPE 配方类型
- Loading branch information
Showing
6 changed files
with
67 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/committee/nova/mods/avaritia/init/compat/crafttweaker/CraftingOthers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package committee.nova.mods.avaritia.init.compat.crafttweaker; | ||
|
||
import com.blamejared.crafttweaker.api.CraftTweakerAPI; | ||
import com.blamejared.crafttweaker.api.CraftTweakerConstants; | ||
import com.blamejared.crafttweaker.api.action.recipe.ActionAddRecipe; | ||
import com.blamejared.crafttweaker.api.action.recipe.ActionRemoveRecipe; | ||
import com.blamejared.crafttweaker.api.annotation.ZenRegister; | ||
import com.blamejared.crafttweaker.api.ingredient.IIngredient; | ||
import com.blamejared.crafttweaker.api.item.IItemStack; | ||
import com.blamejared.crafttweaker.api.item.MCItemStack; | ||
import com.blamejared.crafttweaker.api.recipe.manager.base.IRecipeManager; | ||
import committee.nova.mods.avaritia.api.common.crafting.ISpecialRecipe; | ||
import committee.nova.mods.avaritia.common.crafting.recipe.InfinityCatalystCraftRecipe; | ||
import committee.nova.mods.avaritia.init.registry.ModRecipeTypes; | ||
import net.minecraft.core.NonNullList; | ||
import net.minecraft.core.RegistryAccess; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
import net.minecraft.world.item.crafting.RecipeType; | ||
import org.openzen.zencode.java.ZenCodeType; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Description: | ||
* Author: cnlimiter | ||
* Date: 2022/5/17 8:39 | ||
* Version: 1.0 | ||
*/ | ||
@ZenCodeType.Name("mods.avaritia.CraftingOthers") | ||
@ZenRegister | ||
public class CraftingOthers implements IRecipeManager<ISpecialRecipe> { | ||
private static final CraftingOthers INSTANCE = new CraftingOthers(); | ||
|
||
@ZenCodeType.Method | ||
public static void addCatalyst(String name, IIngredient[] inputs) { | ||
var id = CraftTweakerConstants.rl(INSTANCE.fixRecipeName(name)); | ||
var recipe = new InfinityCatalystCraftRecipe(id, "default", toIngredientsList(inputs)); | ||
|
||
recipe.setTransformers((slot, stack) -> inputs[slot].getRemainingItem(new MCItemStack(stack)).getInternal()); | ||
|
||
CraftTweakerAPI.apply(new ActionAddRecipe<>(INSTANCE, (ISpecialRecipe)recipe)); | ||
} | ||
|
||
@ZenCodeType.Method | ||
public static void remove(IItemStack stack) { | ||
CraftTweakerAPI.apply(new ActionRemoveRecipe<>(INSTANCE, recipe -> recipe.getResultItem(RegistryAccess.EMPTY).is(stack.getInternal().getItem()))); | ||
} | ||
|
||
private static NonNullList<Ingredient> toIngredientsList(IIngredient... ingredients) { | ||
return Arrays.stream(ingredients) | ||
.map(IIngredient::asVanillaIngredient) | ||
.collect(Collectors.toCollection(NonNullList::create)); | ||
} | ||
|
||
@Override | ||
public RecipeType<ISpecialRecipe> getRecipeType() { | ||
return ModRecipeTypes.CRAFTING_OTHERS_RECIPE.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters