Fixed Build issues
This commit is contained in:
parent
f6703dc8bf
commit
0a8b66c551
14 changed files with 99 additions and 141 deletions
|
@ -1,11 +1,12 @@
|
|||
package org.betterx.bclib.api.v2.advancement;
|
||||
|
||||
import net.minecraft.advancements.AdvancementType;
|
||||
import net.minecraft.advancements.DisplayInfo;
|
||||
import net.minecraft.advancements.FrameType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class Display {
|
||||
|
@ -13,7 +14,7 @@ class Display {
|
|||
Component title;
|
||||
net.minecraft.network.chat.Component description;
|
||||
@Nullable ResourceLocation background;
|
||||
FrameType frame;
|
||||
AdvancementType frame;
|
||||
boolean showToast;
|
||||
boolean announceChat;
|
||||
boolean hidden;
|
||||
|
@ -25,7 +26,7 @@ class Display {
|
|||
this.icon = null;
|
||||
this.title = null;
|
||||
this.description = null;
|
||||
frame = FrameType.TASK;
|
||||
frame = AdvancementType.TASK;
|
||||
background = null;
|
||||
showToast = true;
|
||||
announceChat = true;
|
||||
|
@ -36,7 +37,7 @@ class Display {
|
|||
DisplayInfo build() {
|
||||
return new DisplayInfo(
|
||||
icon, title, description,
|
||||
background, frame, showToast, announceChat, hidden
|
||||
Optional.of(background), frame, showToast, announceChat, hidden
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.betterx.bclib.api.v3.datagen;
|
|||
import org.betterx.bclib.api.v2.advancement.AdvancementManager;
|
||||
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricAdvancementProvider;
|
||||
|
@ -21,7 +22,7 @@ public abstract class AdvancementDataProvider extends FabricAdvancementProvider
|
|||
protected abstract void bootstrap();
|
||||
|
||||
@Override
|
||||
public void generateAdvancement(Consumer<Advancement> consumer) {
|
||||
public void generateAdvancement(Consumer<AdvancementHolder> consumer) {
|
||||
bootstrap();
|
||||
AdvancementManager.registerAllDataGen(modIDs, consumer);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.betterx.bclib.api.v3.datagen;
|
||||
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.data.recipes.RecipeOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
@ -11,5 +11,5 @@ public interface DatapackRecipeBuilder {
|
|||
default String getNamespace() {
|
||||
return this.getId().getNamespace();
|
||||
}
|
||||
void build(Consumer<FinishedRecipe> cc);
|
||||
void build(RecipeOutput cc);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.betterx.bclib.api.v3.datagen;
|
|||
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.data.recipes.RecipeOutput;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
|
||||
|
@ -25,7 +25,7 @@ public class RecipeDataProvider extends FabricRecipeProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildRecipes(Consumer<FinishedRecipe> exporter) {
|
||||
public void buildRecipes(RecipeOutput exporter) {
|
||||
if (RECIPES == null) return;
|
||||
|
||||
for (var r : RECIPES) {
|
||||
|
|
|
@ -3,19 +3,21 @@ package org.betterx.bclib.interfaces;
|
|||
|
||||
import org.betterx.bclib.recipes.AnvilRecipe;
|
||||
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AnvilScreenHandlerExtended {
|
||||
void bcl_updateCurrentRecipe(AnvilRecipe recipe);
|
||||
void bcl_updateCurrentRecipe(RecipeHolder<AnvilRecipe> recipe);
|
||||
|
||||
AnvilRecipe bcl_getCurrentRecipe();
|
||||
RecipeHolder<AnvilRecipe> bcl_getCurrentRecipe();
|
||||
|
||||
List<AnvilRecipe> bcl_getRecipes();
|
||||
List<RecipeHolder<AnvilRecipe>> bcl_getRecipes();
|
||||
|
||||
default void be_nextRecipe() {
|
||||
List<AnvilRecipe> recipes = bcl_getRecipes();
|
||||
List<RecipeHolder<AnvilRecipe>> recipes = bcl_getRecipes();
|
||||
if (recipes.size() < 2) return;
|
||||
AnvilRecipe current = bcl_getCurrentRecipe();
|
||||
RecipeHolder<AnvilRecipe> current = bcl_getCurrentRecipe();
|
||||
int i = recipes.indexOf(current) + 1;
|
||||
if (i >= recipes.size()) {
|
||||
i = 0;
|
||||
|
@ -24,9 +26,9 @@ public interface AnvilScreenHandlerExtended {
|
|||
}
|
||||
|
||||
default void be_previousRecipe() {
|
||||
List<AnvilRecipe> recipes = bcl_getRecipes();
|
||||
List<RecipeHolder<AnvilRecipe>> recipes = bcl_getRecipes();
|
||||
if (recipes.size() < 2) return;
|
||||
AnvilRecipe current = bcl_getCurrentRecipe();
|
||||
RecipeHolder<AnvilRecipe> current = bcl_getCurrentRecipe();
|
||||
int i = recipes.indexOf(current) - 1;
|
||||
if (i <= 0) {
|
||||
i = recipes.size() - 1;
|
||||
|
|
|
@ -11,15 +11,16 @@ import net.minecraft.world.entity.player.Inventory;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.*;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.LevelEvent;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
@ -32,16 +33,15 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
@Mixin(AnvilMenu.class)
|
||||
public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilScreenHandlerExtended {
|
||||
private List<AnvilRecipe> bcl_recipes = Collections.emptyList();
|
||||
private AnvilRecipe bcl_currentRecipe;
|
||||
private DataSlot anvilLevel;
|
||||
@Unique
|
||||
private List<RecipeHolder<AnvilRecipe>> bcl_recipes = Collections.emptyList();
|
||||
@Unique
|
||||
private RecipeHolder<AnvilRecipe> bcl_currentRecipe;
|
||||
|
||||
@Shadow
|
||||
private int repairItemCountCost;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
private DataSlot cost;
|
||||
@Unique
|
||||
private DataSlot bcl_anvilLevel;
|
||||
|
||||
|
||||
public AnvilMenuMixin(
|
||||
@Nullable MenuType<?> menuType,
|
||||
|
@ -54,15 +54,15 @@ public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilSc
|
|||
|
||||
@Inject(method = "<init>(ILnet/minecraft/world/entity/player/Inventory;Lnet/minecraft/world/inventory/ContainerLevelAccess;)V", at = @At("TAIL"))
|
||||
public void be_initAnvilLevel(int syncId, Inventory inventory, ContainerLevelAccess context, CallbackInfo info) {
|
||||
this.anvilLevel = addDataSlot(DataSlot.standalone());
|
||||
this.bcl_anvilLevel = addDataSlot(DataSlot.standalone());
|
||||
if (context != ContainerLevelAccess.NULL) {
|
||||
int level = context.evaluate((world, blockPos) -> {
|
||||
Block anvilBlock = world.getBlockState(blockPos).getBlock();
|
||||
return LeveledAnvilBlock.getAnvilCraftingLevel(anvilBlock);
|
||||
}, 0);
|
||||
anvilLevel.set(level);
|
||||
bcl_anvilLevel.set(level);
|
||||
} else {
|
||||
anvilLevel.set(0);
|
||||
bcl_anvilLevel.set(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilSc
|
|||
@Inject(method = "mayPickup", at = @At("HEAD"), cancellable = true)
|
||||
protected void bcl_canTakeOutput(Player player, boolean present, CallbackInfoReturnable<Boolean> info) {
|
||||
if (bcl_currentRecipe != null) {
|
||||
info.setReturnValue(bcl_currentRecipe.checkHammerDurability(inputSlots, player));
|
||||
info.setReturnValue(bcl_currentRecipe.value().checkHammerDurability(inputSlots, player));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,8 @@ public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilSc
|
|||
if (bcl_currentRecipe != null) {
|
||||
final int ingredientSlot = AnvilRecipe.getIngredientSlot(inputSlots);
|
||||
|
||||
inputSlots.getItem(ingredientSlot).shrink(bcl_currentRecipe.getInputCount());
|
||||
stack = bcl_currentRecipe.craft(inputSlots, player);
|
||||
inputSlots.getItem(ingredientSlot).shrink(bcl_currentRecipe.value().getInputCount());
|
||||
stack = bcl_currentRecipe.value().craft(inputSlots, player);
|
||||
slotsChanged(inputSlots);
|
||||
access.execute((level, blockPos) -> {
|
||||
final BlockState anvilState = level.getBlockState(blockPos);
|
||||
|
@ -119,12 +119,12 @@ public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilSc
|
|||
public void bcl_updateOutput(CallbackInfo info) {
|
||||
RecipeManager recipeManager = this.player.level().getRecipeManager();
|
||||
bcl_recipes = recipeManager.getRecipesFor(AnvilRecipe.TYPE, inputSlots, player.level());
|
||||
if (bcl_recipes.size() > 0) {
|
||||
int anvilLevel = this.anvilLevel.get();
|
||||
if (!bcl_recipes.isEmpty()) {
|
||||
int anvilLevel = this.bcl_anvilLevel.get();
|
||||
bcl_recipes = bcl_recipes.stream()
|
||||
.filter(recipe -> anvilLevel >= recipe.getAnvilLevel())
|
||||
.filter(recipe -> anvilLevel >= recipe.value().getAnvilLevel())
|
||||
.collect(Collectors.toList());
|
||||
if (bcl_recipes.size() > 0) {
|
||||
if (!bcl_recipes.isEmpty()) {
|
||||
if (bcl_currentRecipe == null || !bcl_recipes.contains(bcl_currentRecipe)) {
|
||||
bcl_currentRecipe = bcl_recipes.get(0);
|
||||
}
|
||||
|
@ -156,25 +156,26 @@ public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilSc
|
|||
return super.clickMenuButton(player, id);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void bcl_updateResult() {
|
||||
if (bcl_currentRecipe == null) return;
|
||||
resultSlots.setItem(0, bcl_currentRecipe.assemble(inputSlots, this.player.level().registryAccess()));
|
||||
resultSlots.setItem(0, bcl_currentRecipe.value().assemble(inputSlots, this.player.level().registryAccess()));
|
||||
broadcastChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bcl_updateCurrentRecipe(AnvilRecipe recipe) {
|
||||
public void bcl_updateCurrentRecipe(RecipeHolder<AnvilRecipe> recipe) {
|
||||
this.bcl_currentRecipe = recipe;
|
||||
bcl_updateResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnvilRecipe bcl_getCurrentRecipe() {
|
||||
public RecipeHolder<AnvilRecipe> bcl_getCurrentRecipe() {
|
||||
return bcl_currentRecipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AnvilRecipe> bcl_getRecipes() {
|
||||
public List<RecipeHolder<AnvilRecipe>> bcl_getRecipes() {
|
||||
return bcl_recipes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ import org.betterx.bclib.api.v3.datagen.DatapackRecipeBuilder;
|
|||
import org.betterx.bclib.api.v3.datagen.RecipeDataProvider;
|
||||
import org.betterx.bclib.util.RecipeHelper;
|
||||
|
||||
import net.minecraft.advancements.CriterionTriggerInstance;
|
||||
import net.minecraft.advancements.Criterion;
|
||||
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.data.recipes.RecipeCategory;
|
||||
import net.minecraft.data.recipes.RecipeOutput;
|
||||
import net.minecraft.data.recipes.RecipeProvider;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -21,7 +21,6 @@ import net.minecraft.world.level.ItemLike;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class AbstractBaseRecipeBuilder<T extends AbstractBaseRecipeBuilder> implements DatapackRecipeBuilder {
|
||||
|
@ -132,7 +131,7 @@ public abstract class AbstractBaseRecipeBuilder<T extends AbstractBaseRecipeBuil
|
|||
return unlockedBy(items);
|
||||
}
|
||||
|
||||
protected abstract T unlocks(String name, CriterionTriggerInstance trigger);
|
||||
protected abstract T unlocks(String name, Criterion<?> criterion);
|
||||
|
||||
|
||||
public final T build() {
|
||||
|
@ -158,10 +157,10 @@ public abstract class AbstractBaseRecipeBuilder<T extends AbstractBaseRecipeBuil
|
|||
return true;
|
||||
}
|
||||
|
||||
protected abstract void buildRecipe(Consumer<FinishedRecipe> cc);
|
||||
protected abstract void buildRecipe(RecipeOutput cc);
|
||||
|
||||
@Override
|
||||
public final void build(Consumer<FinishedRecipe> cc) {
|
||||
public final void build(RecipeOutput cc) {
|
||||
if (!checkRecipe()) return;
|
||||
buildRecipe(cc);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.betterx.bclib.recipes;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.util.ItemUtil;
|
||||
import org.betterx.bclib.util.RecipeHelper;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -12,9 +11,6 @@ import net.minecraft.world.item.crafting.Ingredient;
|
|||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public abstract class AbstractDoubleInputRecipeBuilder<T extends AbstractDoubleInputRecipeBuilder, R extends Recipe<? extends Container>> extends AbstractSingleInputRecipeBuilder<T, R> {
|
||||
protected Ingredient secondaryInput;
|
||||
|
||||
|
@ -62,18 +58,4 @@ public abstract class AbstractDoubleInputRecipeBuilder<T extends AbstractDoubleI
|
|||
}
|
||||
return super.checkRecipe();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void serializeRecipeData(JsonObject root) {
|
||||
final JsonArray ingredients = new JsonArray();
|
||||
ingredients.add(primaryInput.toJson());
|
||||
ingredients.add(secondaryInput.toJson());
|
||||
root.add("ingredients", ingredients);
|
||||
|
||||
if (group != null && !group.isEmpty()) {
|
||||
root.addProperty("group", group);
|
||||
}
|
||||
|
||||
root.add("result", ItemUtil.toJsonRecipe(output));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package org.betterx.bclib.recipes;
|
||||
|
||||
import org.betterx.bclib.util.ItemUtil;
|
||||
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.CriterionTriggerInstance;
|
||||
import net.minecraft.advancements.RequirementsStrategy;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.advancements.AdvancementRequirements;
|
||||
import net.minecraft.advancements.Criterion;
|
||||
import net.minecraft.advancements.critereon.RecipeUnlockedTrigger;
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.data.recipes.RecipeBuilder;
|
||||
import net.minecraft.data.recipes.RecipeOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.Container;
|
||||
|
@ -17,9 +16,6 @@ import net.minecraft.world.item.crafting.Recipe;
|
|||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class AbstractSingleInputRecipeBuilder<T extends AbstractSingleInputRecipeBuilder, R extends Recipe<? extends Container>> extends AbstractSimpleRecipeBuilder<T> {
|
||||
|
@ -46,73 +42,49 @@ public abstract class AbstractSingleInputRecipeBuilder<T extends AbstractSingleI
|
|||
}
|
||||
|
||||
@Override
|
||||
protected T unlocks(String name, CriterionTriggerInstance trigger) {
|
||||
protected T unlocks(String name, Criterion<?> trigger) {
|
||||
this.advancement.addCriterion(name, trigger);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void buildRecipe(Consumer<FinishedRecipe> cc) {
|
||||
protected void buildRecipe(RecipeOutput cc) {
|
||||
setupAdvancementForResult();
|
||||
cc.accept(new AbstractSingleInputRecipeBuilder<T, R>.Result());
|
||||
final AdvancementHolder advancementHolder = advancement.build(getId());
|
||||
final R recipe = createRecipe(getId());
|
||||
cc.accept(getId(), recipe, advancementHolder);
|
||||
}
|
||||
|
||||
protected abstract R createRecipe(ResourceLocation id);
|
||||
|
||||
protected abstract RecipeSerializer<R> getSerializer();
|
||||
|
||||
protected void serializeRecipeData(JsonObject root) {
|
||||
root.add("input", ItemUtil.toJsonIngredientWithNBT(primaryInput));
|
||||
|
||||
if (group != null && !group.isEmpty()) {
|
||||
root.addProperty("group", group);
|
||||
}
|
||||
|
||||
root.add("result", ItemUtil.toJsonRecipeWithNBT(output));
|
||||
}
|
||||
|
||||
protected void setupAdvancementForResult() {
|
||||
advancement.parent(RecipeBuilder.ROOT_RECIPE_ADVANCEMENT)
|
||||
.addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(id))
|
||||
.rewards(net.minecraft.advancements.AdvancementRewards.Builder.recipe(id))
|
||||
.requirements(RequirementsStrategy.OR);
|
||||
advancement
|
||||
.parent(RecipeBuilder.ROOT_RECIPE_ADVANCEMENT)//automatically at root level
|
||||
.addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(id))
|
||||
.rewards(net.minecraft.advancements.AdvancementRewards.Builder.recipe(id))
|
||||
.requirements(AdvancementRequirements.Strategy.OR);
|
||||
}
|
||||
|
||||
protected ResourceLocation createAdvancementId() {
|
||||
return id.withPrefix("recipes/" + category.getFolderName() + "/");
|
||||
}
|
||||
|
||||
public class Result implements FinishedRecipe {
|
||||
private final ResourceLocation advancementId;
|
||||
public class Result implements RecipeOutput {
|
||||
@Override
|
||||
public void accept(
|
||||
ResourceLocation resourceLocation,
|
||||
Recipe<?> recipe,
|
||||
@Nullable AdvancementHolder advancementHolder
|
||||
) {
|
||||
|
||||
protected Result() {
|
||||
this.advancementId = createAdvancementId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return AbstractSingleInputRecipeBuilder.this.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<R> getType() {
|
||||
return getSerializer();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JsonObject serializeAdvancement() {
|
||||
return advancement.serializeToJson();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getAdvancementId() {
|
||||
return advancementId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeRecipeData(JsonObject root) {
|
||||
AbstractSingleInputRecipeBuilder.this.serializeRecipeData(root);
|
||||
public Advancement.Builder advancement() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.betterx.bclib.recipes;
|
||||
|
||||
import net.minecraft.advancements.CriterionTriggerInstance;
|
||||
import net.minecraft.advancements.Criterion;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -15,7 +15,7 @@ public abstract class AbstractUnlockableRecipeBuilder<T extends AbstractUnlockab
|
|||
super(id, output);
|
||||
}
|
||||
|
||||
protected final Map<String, CriterionTriggerInstance> unlocks = new HashMap<>();
|
||||
protected final Map<String, Criterion<?>> unlocks = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public T unlockedBy(ItemLike item) {
|
||||
|
@ -28,8 +28,8 @@ public abstract class AbstractUnlockableRecipeBuilder<T extends AbstractUnlockab
|
|||
}
|
||||
|
||||
@Override
|
||||
protected T unlocks(String name, CriterionTriggerInstance trigger) {
|
||||
this.unlocks.put(name, trigger);
|
||||
protected T unlocks(String name, Criterion<?> criterion) {
|
||||
this.unlocks.put(name, criterion);
|
||||
return (T) this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.betterx.bclib.recipes;
|
|||
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.data.recipes.RecipeOutput;
|
||||
import net.minecraft.data.recipes.SimpleCookingRecipeBuilder;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
|
@ -139,7 +139,7 @@ public class CookingRecipeBuilder extends AbstractUnlockableRecipeBuilder<Cookin
|
|||
build(false, true, true);
|
||||
}
|
||||
|
||||
private void buildRecipe(Consumer<FinishedRecipe> cc, SimpleCookingRecipeBuilder builder, String postfix) {
|
||||
private void buildRecipe(RecipeOutput cc, SimpleCookingRecipeBuilder builder, String postfix) {
|
||||
ResourceLocation loc = new ResourceLocation(id.getNamespace(), id.getPath() + "_" + postfix);
|
||||
for (var item : unlocks.entrySet()) {
|
||||
builder.unlockedBy(item.getKey(), item.getValue());
|
||||
|
@ -148,7 +148,7 @@ public class CookingRecipeBuilder extends AbstractUnlockableRecipeBuilder<Cookin
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void buildRecipe(Consumer<FinishedRecipe> cc) {
|
||||
protected void buildRecipe(RecipeOutput cc) {
|
||||
if (smelting) {
|
||||
buildRecipe(
|
||||
cc,
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.betterx.bclib.recipes;
|
|||
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import net.minecraft.advancements.CriterionTriggerInstance;
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.advancements.Criterion;
|
||||
import net.minecraft.data.recipes.RecipeOutput;
|
||||
import net.minecraft.data.recipes.ShapedRecipeBuilder;
|
||||
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -16,7 +16,6 @@ import net.minecraft.world.level.ItemLike;
|
|||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftingRecipeBuilder extends AbstractBaseRecipeBuilder<CraftingRecipeBuilder> {
|
||||
private String[] shape;
|
||||
|
@ -35,7 +34,7 @@ public class CraftingRecipeBuilder extends AbstractBaseRecipeBuilder<CraftingRec
|
|||
return new CraftingRecipeBuilder(id, output);
|
||||
}
|
||||
|
||||
protected final Map<String, CriterionTriggerInstance> unlocks = new HashMap<>();
|
||||
protected final Map<String, Criterion<?>> unlocks = new HashMap<>();
|
||||
protected final Map<Character, Ingredient> materials = new HashMap<>();
|
||||
|
||||
@Override
|
||||
|
@ -114,8 +113,8 @@ public class CraftingRecipeBuilder extends AbstractBaseRecipeBuilder<CraftingRec
|
|||
}
|
||||
|
||||
@Override
|
||||
protected CraftingRecipeBuilder unlocks(String name, CriterionTriggerInstance trigger) {
|
||||
this.unlocks.put(name, trigger);
|
||||
protected CraftingRecipeBuilder unlocks(String name, Criterion<?> criterion) {
|
||||
this.unlocks.put(name, criterion);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -132,7 +131,7 @@ public class CraftingRecipeBuilder extends AbstractBaseRecipeBuilder<CraftingRec
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void buildRecipe(Consumer<FinishedRecipe> cc) {
|
||||
protected void buildRecipe(RecipeOutput cc) {
|
||||
if (shape != null) buildShaped(cc);
|
||||
else buildShapeless(cc);
|
||||
}
|
||||
|
@ -145,11 +144,11 @@ public class CraftingRecipeBuilder extends AbstractBaseRecipeBuilder<CraftingRec
|
|||
return super.checkRecipe();
|
||||
}
|
||||
|
||||
protected void buildShapeless(Consumer<FinishedRecipe> cc) {
|
||||
protected void buildShapeless(RecipeOutput cc) {
|
||||
final ShapelessRecipeBuilder builder = ShapelessRecipeBuilder.shapeless(
|
||||
category, output.getItem(), output.getCount()
|
||||
);
|
||||
for (Map.Entry<String, CriterionTriggerInstance> item : unlocks.entrySet()) {
|
||||
for (Map.Entry<String, Criterion<?>> item : unlocks.entrySet()) {
|
||||
builder.unlockedBy(item.getKey(), item.getValue());
|
||||
}
|
||||
for (Map.Entry<Character, Ingredient> mat : materials.entrySet()) {
|
||||
|
@ -201,11 +200,11 @@ public class CraftingRecipeBuilder extends AbstractBaseRecipeBuilder<CraftingRec
|
|||
}
|
||||
|
||||
|
||||
protected void buildShaped(Consumer<FinishedRecipe> cc) {
|
||||
protected void buildShaped(RecipeOutput cc) {
|
||||
final ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(
|
||||
category, output.getItem(), output.getCount()
|
||||
);
|
||||
for (Map.Entry<String, CriterionTriggerInstance> item : unlocks.entrySet()) {
|
||||
for (Map.Entry<String, Criterion<?>> item : unlocks.entrySet()) {
|
||||
builder.unlockedBy(item.getKey(), item.getValue());
|
||||
}
|
||||
for (Map.Entry<Character, Ingredient> mat : materials.entrySet()) {
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.betterx.bclib.recipes;
|
|||
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.data.recipes.RecipeOutput;
|
||||
import net.minecraft.data.recipes.SmithingTransformRecipeBuilder;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
|
@ -85,7 +85,7 @@ public class SmithingRecipeBuilder extends AbstractUnlockableRecipeBuilder<Smith
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void buildRecipe(Consumer<FinishedRecipe> cc) {
|
||||
protected void buildRecipe(RecipeOutput cc) {
|
||||
final SmithingTransformRecipeBuilder builder = SmithingTransformRecipeBuilder.smithing(
|
||||
Ingredient.of(template),
|
||||
primaryInput,
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package org.betterx.bclib.recipes;
|
||||
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.advancements.Criterion;
|
||||
import net.minecraft.data.recipes.RecipeOutput;
|
||||
import net.minecraft.data.recipes.SingleItemRecipeBuilder;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.Map;
|
||||
|
||||
public class StonecutterRecipeBuilder extends AbstractUnlockableRecipeBuilder<StonecutterRecipeBuilder> {
|
||||
|
||||
|
@ -53,11 +54,11 @@ public class StonecutterRecipeBuilder extends AbstractUnlockableRecipeBuilder<St
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void buildRecipe(Consumer<FinishedRecipe> cc) {
|
||||
protected void buildRecipe(RecipeOutput cc) {
|
||||
final SingleItemRecipeBuilder builder = SingleItemRecipeBuilder.stonecutting(
|
||||
primaryInput, category, output.getItem(), output.getCount()
|
||||
);
|
||||
for (var item : unlocks.entrySet()) {
|
||||
for (Map.Entry<String, Criterion<?>> item : unlocks.entrySet()) {
|
||||
builder.unlockedBy(item.getKey(), item.getValue());
|
||||
}
|
||||
builder.group(group);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue