Merge remote-tracking branch 'Ayutac/1.18-Ayutac-datagen-6' into 1.18
# Conflicts: # RebornCore/src/main/java/reborncore/common/misc/TagConvertible.java # src/datagen/groovy/techreborn/datagen/recipes/TechRebornRecipesProvider.groovy # src/datagen/groovy/techreborn/datagen/recipes/machine/compressor/CompressorRecipesProvider.groovy # src/main/java/techreborn/init/TRContent.java
This commit is contained in:
commit
45c1e7412c
667 changed files with 18984 additions and 2246 deletions
|
@ -34,15 +34,14 @@ import net.minecraft.recipe.Recipe;
|
|||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.RebornCore;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||
import reborncore.common.util.DefaultedListCollector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
|
||||
private final RebornRecipeType<?> type;
|
||||
|
@ -62,6 +61,16 @@ public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
|
|||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack createIcon() {
|
||||
Optional<Item> catalyst = Registry.ITEM.getOrEmpty(type.name());
|
||||
if (catalyst.isPresent())
|
||||
return new ItemStack(catalyst.get());
|
||||
else
|
||||
RebornCore.LOGGER.warn("Missing toast icon for {}!", type.name());
|
||||
return Recipe.super.createIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return name;
|
||||
|
@ -166,7 +175,7 @@ public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
|
|||
// Done to try and stop the table from loading it
|
||||
@Override
|
||||
public boolean isIgnoredInRecipeBook() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,10 @@ import com.google.gson.JsonElement;
|
|||
import com.google.gson.JsonObject;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import net.minecraft.advancement.Advancement;
|
||||
import net.minecraft.advancement.AdvancementRewards;
|
||||
import net.minecraft.advancement.CriterionMerger;
|
||||
import net.minecraft.advancement.criterion.RecipeUnlockedCriterion;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -40,12 +44,14 @@ import net.minecraft.util.JsonHelper;
|
|||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import reborncore.common.util.DefaultedListCollector;
|
||||
import reborncore.common.util.serialization.SerializationUtil;
|
||||
import reborncore.mixin.common.AccessorRecipeManager;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class RecipeUtils {
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -82,4 +88,24 @@ public class RecipeUtils {
|
|||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the following toast/recipe defaults to an advancement builder:
|
||||
* <ul>
|
||||
* <li>parent as "recipes/root"</li>
|
||||
* <li>criterion "has_the_recipe" via OR</li>
|
||||
* <li>reward: the specified recipe</li>
|
||||
* </ul>
|
||||
* @param builder the advancement task builder to expand
|
||||
* @param recipeId the ID of the recipe
|
||||
* @throws NullPointerException If any parameter refers to <code>null</code>.
|
||||
*/
|
||||
public static void addToastDefaults(@NotNull Advancement.Builder builder, @NotNull Identifier recipeId) {
|
||||
Objects.requireNonNull(builder);
|
||||
Objects.requireNonNull(recipeId);
|
||||
builder.parent(new Identifier("recipes/root"))
|
||||
.criterion("has_the_recipe", RecipeUnlockedCriterion.create(recipeId))
|
||||
.rewards(AdvancementRewards.Builder.recipe(recipeId))
|
||||
.criteriaMerger(CriterionMerger.OR);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public final class FluidValue {
|
|||
|
||||
private final long rawValue;
|
||||
|
||||
private static FluidValue fromMillibuckets(long millibuckets) {
|
||||
public static FluidValue fromMillibuckets(long millibuckets) {
|
||||
return new FluidValue(millibuckets * 81);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ package reborncore.common.misc;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tag.TagKey;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Tells if an item, block etc. has a tag solely for compatibility with other mods.
|
||||
|
@ -43,4 +44,16 @@ public interface TagConvertible<T> {
|
|||
*/
|
||||
TagKey<T> asTag();
|
||||
|
||||
/**
|
||||
* Converts a given object into its tag form if the item is a {@link TagConvertible}.
|
||||
* @param obj the object to convert
|
||||
* @return The tag of the object or the object itself if it is not a {@link TagConvertible}.
|
||||
*/
|
||||
@Contract("null -> null")
|
||||
static Object convertIf(Object obj) {
|
||||
if (obj instanceof TagConvertible<?> convertible)
|
||||
return convertible.asTag();
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue