Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加铁砧工艺配方kubejs支持 #421

Merged
merged 9 commits into from
Apr 28, 2024
Merged
3 changes: 3 additions & 0 deletions common/src/main/java/dev/dubhe/anvilcraft/AnvilCraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import dev.dubhe.anvilcraft.api.registry.AnvilCraftRegistrate;
import dev.dubhe.anvilcraft.config.AnvilCraftConfig;
import dev.dubhe.anvilcraft.data.generator.AnvilCraftDatagen;
import dev.dubhe.anvilcraft.data.recipe.anvil.AnvilRecipe;
import dev.dubhe.anvilcraft.init.ModBlockEntities;
import dev.dubhe.anvilcraft.init.ModBlocks;
import dev.dubhe.anvilcraft.init.ModDispenserBehavior;
Expand Down Expand Up @@ -52,6 +53,8 @@ public static void init() {
ModDispenserBehavior.register();
ModLootContextParamSet.register();
ModEnchantments.register();

AnvilRecipe.init();
// datagen
AnvilCraftDatagen.init();
// fabric 独有,请在此之前插入注册
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,10 @@ public enum Type implements RecipeType<AnvilRecipe> {
INSTANCE
}

static {
/**
* 初始化 Predicate 和 Outcome
*/
public static void init() {
RecipePredicate.register("has_item", HasItem::new, HasItem::new);
RecipePredicate.register("has_item_ingredient", HasItemIngredient::new, HasItemIngredient::new);
RecipePredicate.register("has_block", HasBlock::new, HasBlock::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package dev.dubhe.anvilcraft.integration.kubejs;

import dev.dubhe.anvilcraft.AnvilCraft;
import dev.dubhe.anvilcraft.data.recipe.anvil.AnvilRecipe;
import dev.dubhe.anvilcraft.data.recipe.anvil.outcome.DamageAnvil;
import dev.dubhe.anvilcraft.data.recipe.anvil.outcome.RunCommand;
import dev.dubhe.anvilcraft.data.recipe.anvil.outcome.SelectOne;
import dev.dubhe.anvilcraft.data.recipe.anvil.outcome.SetBlock;
import dev.dubhe.anvilcraft.data.recipe.anvil.outcome.SpawnExperience;
import dev.dubhe.anvilcraft.data.recipe.anvil.outcome.SpawnItem;
import dev.dubhe.anvilcraft.data.recipe.anvil.predicate.HasBlock;
import dev.dubhe.anvilcraft.data.recipe.anvil.predicate.HasBlockIngredient;
import dev.dubhe.anvilcraft.data.recipe.anvil.predicate.HasFluidCauldron;
import dev.dubhe.anvilcraft.data.recipe.anvil.predicate.HasItem;
import dev.dubhe.anvilcraft.data.recipe.anvil.predicate.HasItemIngredient;
import dev.dubhe.anvilcraft.data.recipe.anvil.predicate.NotHasBlock;
import dev.dubhe.anvilcraft.init.ModBlocks;
import dev.dubhe.anvilcraft.init.ModItems;
import dev.dubhe.anvilcraft.integration.kubejs.recipe.AnvilCraftRecipeSchema;
import dev.dubhe.anvilcraft.integration.kubejs.recipe.builder.SelectOneBuilder;
import dev.latvian.mods.kubejs.KubeJSPlugin;
import dev.latvian.mods.kubejs.recipe.schema.RegisterRecipeSchemasEvent;
import dev.latvian.mods.kubejs.script.BindingsEvent;
import dev.latvian.mods.kubejs.script.ScriptType;
import dev.latvian.mods.kubejs.util.ClassFilter;

public class AnvilCraftKubeJsPlugin extends KubeJSPlugin {

@Override
public void init() {
AnvilRecipe.init();
}

@Override
public void registerRecipeSchemas(RegisterRecipeSchemasEvent event) {
super.registerRecipeSchemas(event);
event.register(AnvilCraft.of("anvil_processing"), AnvilCraftRecipeSchema.SCHEMA);
}

@Override
public void registerClasses(ScriptType type, ClassFilter filter) {
super.registerClasses(type, filter);
filter.allow("dev.dubhe.anvilcraft");
}

@Override
public void registerBindings(BindingsEvent event) {
super.registerBindings(event);

event.add("AnvilCraftItems", ModItems.class);
event.add("AnvilCraftBlocks", ModBlocks.class);
event.add("AnvilCraftBlockPredicate", HasBlock.ModBlockPredicate.class);

// outcomes
event.add("DamageAnvil", DamageAnvil.class);
event.add("RunCommand", RunCommand.class);
event.add("SelectOne", SelectOne.class);
event.add("SetBlock", SetBlock.class);
event.add("SpawnExperience", SpawnExperience.class);
event.add("SpawnItem", SpawnItem.class);

// predicates
event.add("HasBlock", HasBlock.class);
event.add("HasBlockIngredient", HasBlockIngredient.class);
event.add("HasFluidCauldron", HasFluidCauldron.class);
event.add("HasItem", HasItem.class);
event.add("HasItemIngredient", HasItemIngredient.class);
event.add("NotHasBlock", NotHasBlock.class);

// builder
event.add("SelectOneBuilder", SelectOneBuilder.class);
}
}
Loading
Loading