mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 14:34:28 +00:00
1.20.2-pre1
This commit is contained in:
368 files changed
+3555
-6356
No files matched your search
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import com.google.gson.JsonElement;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.tags.TagKey;
|
||||
@@ -19,18 +19,15 @@ import java.util.stream.Stream;
|
||||
/**
|
||||
* Extension of {@link Ingredient} which makes most methods custom ingredients need to implement abstract, and removes the static constructors
|
||||
* Mods are encouraged to extend this class for their custom ingredients
|
||||
*/
|
||||
public abstract class AbstractIngredient extends Ingredient
|
||||
{
|
||||
/** Empty constructor, for the sake of dynamic ingredients */
|
||||
protected AbstractIngredient()
|
||||
{
|
||||
* /
|
||||
public abstract class AbstractIngredient extends Ingredient {
|
||||
/** Empty constructor, for the sake of dynamic ingredients * /
|
||||
protected AbstractIngredient() {
|
||||
super(Stream.of());
|
||||
}
|
||||
|
||||
/** Value constructor, for ingredients that have some vanilla representation */
|
||||
protected AbstractIngredient(Stream<? extends Value> values)
|
||||
{
|
||||
/** Value constructor, for ingredients that have some vanilla representation * /
|
||||
protected AbstractIngredient(Stream<? extends Value> values) {
|
||||
super(values);
|
||||
}
|
||||
|
||||
@@ -41,64 +38,57 @@ public abstract class AbstractIngredient extends Ingredient
|
||||
public abstract IIngredientSerializer<? extends Ingredient> getSerializer();
|
||||
|
||||
@Override
|
||||
public abstract JsonElement toJson();
|
||||
public abstract JsonElement toJson(boolean allowEmpty);
|
||||
|
||||
|
||||
/* Hide vanilla ingredient static constructors to reduce errors with constructing custom ingredients */
|
||||
/* Hide vanilla ingredient static constructors to reduce errors with constructing custom ingredients * /
|
||||
|
||||
/** @deprecated use {@link Ingredient#fromValues(Stream)} */
|
||||
/** @deprecated use {@link Ingredient#fromValues(Stream)} * /
|
||||
@Deprecated
|
||||
public static Ingredient fromValues(Stream<? extends Ingredient.Value> values)
|
||||
{
|
||||
public static Ingredient fromValues(Stream<? extends Ingredient.Value> values) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.fromValues()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#of()} */
|
||||
/** @deprecated use {@link Ingredient#of()} * /
|
||||
@Deprecated
|
||||
public static Ingredient of()
|
||||
{
|
||||
public static Ingredient of() {
|
||||
throw new UnsupportedOperationException("Use Ingredient.of()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#of(ItemLike...)} (Stream)} */
|
||||
/** @deprecated use {@link Ingredient#of(ItemLike...)} (Stream)} * /
|
||||
@Deprecated
|
||||
public static Ingredient of(ItemLike... items)
|
||||
{
|
||||
public static Ingredient of(ItemLike... items) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.of()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#of(ItemStack...)} (Stream)} */
|
||||
/** @deprecated use {@link Ingredient#of(ItemStack...)} (Stream)} * /
|
||||
@Deprecated
|
||||
public static Ingredient of(ItemStack... stacks)
|
||||
{
|
||||
public static Ingredient of(ItemStack... stacks) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.of()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#of(Stream)} (Stream)} */
|
||||
/** @deprecated use {@link Ingredient#of(Stream)} (Stream)} * /
|
||||
@Deprecated
|
||||
public static Ingredient of(Stream<ItemStack> stacks)
|
||||
{
|
||||
public static Ingredient of(Stream<ItemStack> stacks) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.of()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#of(TagKey)} (Stream)} */
|
||||
/** @deprecated use {@link Ingredient#of(TagKey)} (Stream)} * /
|
||||
@Deprecated
|
||||
public static Ingredient of(TagKey<Item> tag)
|
||||
{
|
||||
public static Ingredient of(TagKey<Item> tag) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.of()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#fromNetwork(FriendlyByteBuf)} */
|
||||
/** @deprecated use {@link Ingredient#fromNetwork(FriendlyByteBuf)} * /
|
||||
@Deprecated
|
||||
public static Ingredient fromNetwork(FriendlyByteBuf buffer)
|
||||
{
|
||||
public static Ingredient fromNetwork(FriendlyByteBuf buffer) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.fromNetwork()");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Ingredient#fromJson(JsonElement)} (Stream)} */
|
||||
/** @deprecated use {@link Ingredient#fromJson(JsonElement)} (Stream)} * /
|
||||
@Deprecated
|
||||
public static Ingredient fromJson(@Nullable JsonElement json)
|
||||
{
|
||||
public static Ingredient fromJson(@Nullable JsonElement json) {
|
||||
throw new UnsupportedOperationException("Use Ingredient.fromJson()");
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -27,7 +27,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/** Ingredient that matches if any of the child ingredients match */
|
||||
/** Ingredient that matches if any of the child ingredients match * /
|
||||
public class CompoundIngredient extends AbstractIngredient
|
||||
{
|
||||
private List<Ingredient> children;
|
||||
@@ -41,7 +41,7 @@ public class CompoundIngredient extends AbstractIngredient
|
||||
this.isSimple = children.stream().allMatch(Ingredient::isSimple);
|
||||
}
|
||||
|
||||
/** Creates a compound ingredient from the given list of ingredients */
|
||||
/** Creates a compound ingredient from the given list of ingredients * /
|
||||
public static Ingredient of(Ingredient... children)
|
||||
{
|
||||
// if 0 or 1 ingredient, can save effort
|
||||
@@ -182,3 +182,4 @@ public class CompoundIngredient extends AbstractIngredient
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
@@ -32,7 +32,7 @@ public class ConditionalAdvancement
|
||||
* Processes the conditional advancement during loading.
|
||||
* @param json The incoming json from the advancement file.
|
||||
* @return The advancement that passed the conditions, or null if none did.
|
||||
*/
|
||||
* /
|
||||
@Nullable
|
||||
public static JsonObject processConditional(JsonObject json, ICondition.IContext context) {
|
||||
JsonArray entries = GsonHelper.getAsJsonArray(json, "advancements", null);
|
||||
@@ -128,3 +128,4 @@ public class ConditionalAdvancement
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/* TODO: Conditional Recipes
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
@@ -14,6 +14,7 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
@@ -153,6 +154,7 @@ public class ConditionalRecipe
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class Finished implements FinishedRecipe
|
||||
{
|
||||
private final ResourceLocation id;
|
||||
@@ -189,19 +191,21 @@ public class ConditionalRecipe
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
public ResourceLocation id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getType()
|
||||
public RecipeSerializer<?> type()
|
||||
{
|
||||
return SERIALZIER;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JsonObject serializeAdvancement() {
|
||||
return adv == null ? null : adv.write();
|
||||
public AdvancementHolder advancement() {
|
||||
if (adv == null)
|
||||
return null;
|
||||
return new AdvancementHolder(advId, adv.)
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,3 +214,4 @@ public class ConditionalRecipe
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -6,13 +6,9 @@
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
@@ -24,12 +20,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
import net.minecraftforge.common.crafting.conditions.IConditionSerializer;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
@@ -38,28 +32,18 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CraftingHelper
|
||||
{
|
||||
public class CraftingHelper {
|
||||
@SuppressWarnings("unused")
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@SuppressWarnings("unused")
|
||||
private static final Marker CRAFTHELPER = MarkerManager.getMarker("CRAFTHELPER");
|
||||
private static Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||
private static final Map<ResourceLocation, IConditionSerializer<?>> conditions = new HashMap<>();
|
||||
/* TODO: Custom Ingredients
|
||||
private static final BiMap<ResourceLocation, IIngredientSerializer<?>> ingredients = HashBiMap.create();
|
||||
|
||||
public static IConditionSerializer<?> register(IConditionSerializer<?> serializer)
|
||||
{
|
||||
ResourceLocation key = serializer.getID();
|
||||
if (conditions.containsKey(key))
|
||||
throw new IllegalStateException("Duplicate recipe condition serializer: " + key);
|
||||
conditions.put(key, serializer);
|
||||
return serializer;
|
||||
}
|
||||
public static <T extends Ingredient> IIngredientSerializer<T> register(ResourceLocation key, IIngredientSerializer<T> serializer)
|
||||
{
|
||||
|
||||
public static <T extends Ingredient> IIngredientSerializer<T> register(ResourceLocation key, IIngredientSerializer<T> serializer) {
|
||||
if (ingredients.containsKey(key))
|
||||
throw new IllegalStateException("Duplicate recipe ingredient serializer: " + key);
|
||||
if (ingredients.containsValue(serializer))
|
||||
@@ -67,45 +51,40 @@ public class CraftingHelper
|
||||
ingredients.put(key, serializer);
|
||||
return serializer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ResourceLocation getID(IIngredientSerializer<?> serializer)
|
||||
{
|
||||
public static ResourceLocation getID(IIngredientSerializer<?> serializer) {
|
||||
return ingredients.inverse().get(serializer);
|
||||
}
|
||||
public static <T extends Ingredient> void write(FriendlyByteBuf buffer, T ingredient)
|
||||
{
|
||||
|
||||
public static <T extends Ingredient> void write(FriendlyByteBuf buffer, T ingredient) {
|
||||
@SuppressWarnings("unchecked") //I wonder if there is a better way generic wise...
|
||||
IIngredientSerializer<T> serializer = (IIngredientSerializer<T>)ingredient.getSerializer();
|
||||
ResourceLocation key = ingredients.inverse().get(serializer);
|
||||
if (key == null)
|
||||
throw new IllegalArgumentException("Tried to serialize unregistered Ingredient: " + ingredient + " " + serializer);
|
||||
if (serializer != VanillaIngredientSerializer.INSTANCE)
|
||||
{
|
||||
if (serializer != VanillaIngredientSerializer.INSTANCE) {
|
||||
buffer.writeVarInt(-1); //Marker to know there is a custom ingredient
|
||||
buffer.writeResourceLocation(key);
|
||||
}
|
||||
serializer.write(buffer, ingredient);
|
||||
}
|
||||
|
||||
public static Ingredient getIngredient(ResourceLocation type, FriendlyByteBuf buffer)
|
||||
{
|
||||
public static Ingredient getIngredient(ResourceLocation type, FriendlyByteBuf buffer) {
|
||||
IIngredientSerializer<?> serializer = ingredients.get(type);
|
||||
if (serializer == null)
|
||||
throw new IllegalArgumentException("Can not deserialize unknown Ingredient type: " + type);
|
||||
return serializer.parse(buffer);
|
||||
}
|
||||
|
||||
public static Ingredient getIngredient(JsonElement json, boolean allowEmpty)
|
||||
{
|
||||
public static Ingredient getIngredient(JsonElement json, boolean allowEmpty) {
|
||||
if (json == null || json.isJsonNull())
|
||||
throw new JsonSyntaxException("Json cannot be null");
|
||||
|
||||
if (json.isJsonArray())
|
||||
{
|
||||
if (json.isJsonArray()) {
|
||||
List<Ingredient> ingredients = Lists.newArrayList();
|
||||
List<Ingredient> vanilla = Lists.newArrayList();
|
||||
json.getAsJsonArray().forEach((ele) ->
|
||||
{
|
||||
json.getAsJsonArray().forEach((ele) -> {
|
||||
Ingredient ing = CraftingHelper.getIngredient(ele, allowEmpty);
|
||||
|
||||
if (ing.getClass() == Ingredient.class) //Vanilla, Due to how we read it splits each itemstack, so we pull out to re-merge later
|
||||
@@ -117,12 +96,9 @@ public class CraftingHelper
|
||||
if (!vanilla.isEmpty())
|
||||
ingredients.add(Ingredient.merge(vanilla));
|
||||
|
||||
if (ingredients.size() == 0)
|
||||
{
|
||||
if (ingredients.size() == 0) {
|
||||
if (allowEmpty)
|
||||
{
|
||||
return Ingredient.EMPTY;
|
||||
}
|
||||
throw new JsonSyntaxException("Item array cannot be empty, at least one item must be defined");
|
||||
}
|
||||
|
||||
@@ -147,14 +123,13 @@ public class CraftingHelper
|
||||
|
||||
return serializer.parse(obj);
|
||||
}
|
||||
*/
|
||||
|
||||
public static ItemStack getItemStack(JsonObject json, boolean readNBT)
|
||||
{
|
||||
public static ItemStack getItemStack(JsonObject json, boolean readNBT) {
|
||||
return getItemStack(json, readNBT, false);
|
||||
}
|
||||
|
||||
public static Item getItem(String itemName, boolean disallowsAirInRecipe)
|
||||
{
|
||||
public static Item getItem(String itemName, boolean disallowsAirInRecipe) {
|
||||
ResourceLocation itemKey = new ResourceLocation(itemName);
|
||||
if (!ForgeRegistries.ITEMS.containsKey(itemKey))
|
||||
throw new JsonSyntaxException("Unknown item '" + itemName + "'");
|
||||
@@ -165,31 +140,24 @@ public class CraftingHelper
|
||||
return Objects.requireNonNull(item);
|
||||
}
|
||||
|
||||
public static CompoundTag getNBT(JsonElement element)
|
||||
{
|
||||
try
|
||||
{
|
||||
public static CompoundTag getNBT(JsonElement element) {
|
||||
try {
|
||||
if (element.isJsonObject())
|
||||
return TagParser.parseTag(GSON.toJson(element));
|
||||
else
|
||||
return TagParser.parseTag(GsonHelper.convertToString(element, "nbt"));
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
} catch (CommandSyntaxException e) {
|
||||
throw new JsonSyntaxException("Invalid NBT Entry: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(JsonObject json, boolean readNBT, boolean disallowsAirInRecipe)
|
||||
{
|
||||
public static ItemStack getItemStack(JsonObject json, boolean readNBT, boolean disallowsAirInRecipe) {
|
||||
String itemName = GsonHelper.getAsString(json, "item");
|
||||
Item item = getItem(itemName, disallowsAirInRecipe);
|
||||
if (readNBT && json.has("nbt"))
|
||||
{
|
||||
if (readNBT && json.has("nbt")) {
|
||||
CompoundTag nbt = getNBT(json.get("nbt"));
|
||||
CompoundTag tmp = new CompoundTag();
|
||||
if (nbt.contains("ForgeCaps"))
|
||||
{
|
||||
if (nbt.contains("ForgeCaps")) {
|
||||
tmp.put("ForgeCaps", nbt.get("ForgeCaps"));
|
||||
nbt.remove("ForgeCaps");
|
||||
}
|
||||
@@ -204,13 +172,21 @@ public class CraftingHelper
|
||||
return new ItemStack(item, GsonHelper.getAsInt(json, "count", 1));
|
||||
}
|
||||
|
||||
public static boolean processConditions(JsonObject json, String memberName, ICondition.IContext context)
|
||||
{
|
||||
// CONDITIONS
|
||||
private static final Map<ResourceLocation, IConditionSerializer<?>> conditions = new HashMap<>();
|
||||
public static IConditionSerializer<?> register(IConditionSerializer<?> serializer) {
|
||||
ResourceLocation key = serializer.getID();
|
||||
if (conditions.containsKey(key))
|
||||
throw new IllegalStateException("Duplicate recipe condition serializer: " + key);
|
||||
conditions.put(key, serializer);
|
||||
return serializer;
|
||||
}
|
||||
|
||||
public static boolean processConditions(JsonObject json, String memberName, ICondition.IContext context) {
|
||||
return !json.has(memberName) || processConditions(GsonHelper.getAsJsonArray(json, memberName), context);
|
||||
}
|
||||
|
||||
public static boolean processConditions(JsonArray conditions, ICondition.IContext context)
|
||||
{
|
||||
public static boolean processConditions(JsonArray conditions, ICondition.IContext context) {
|
||||
for (int x = 0; x < conditions.size(); x++)
|
||||
{
|
||||
if (!conditions.get(x).isJsonObject())
|
||||
@@ -223,8 +199,7 @@ public class CraftingHelper
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ICondition getCondition(JsonObject json)
|
||||
{
|
||||
public static ICondition getCondition(JsonObject json) {
|
||||
ResourceLocation type = new ResourceLocation(GsonHelper.getAsString(json, "type"));
|
||||
IConditionSerializer<?> serializer = conditions.get(type);
|
||||
if (serializer == null)
|
||||
@@ -232,8 +207,7 @@ public class CraftingHelper
|
||||
return serializer.read(json);
|
||||
}
|
||||
|
||||
public static <T extends ICondition> JsonObject serialize(T condition)
|
||||
{
|
||||
public static <T extends ICondition> JsonObject serialize(T condition) {
|
||||
@SuppressWarnings("unchecked")
|
||||
IConditionSerializer<T> serializer = (IConditionSerializer<T>)conditions.get(condition.getID());
|
||||
if (serializer == null)
|
||||
@@ -241,13 +215,10 @@ public class CraftingHelper
|
||||
return serializer.getJson(condition);
|
||||
}
|
||||
|
||||
public static JsonArray serialize(ICondition... conditions)
|
||||
{
|
||||
public static JsonArray serialize(ICondition... conditions) {
|
||||
JsonArray arr = new JsonArray();
|
||||
for(ICondition iCond : conditions)
|
||||
{
|
||||
arr.add(serialize(iCond));
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
@@ -18,7 +18,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/** Ingredient that matches everything from the first ingredient that is not included in the second ingredient */
|
||||
/** Ingredient that matches everything from the first ingredient that is not included in the second ingredient * /
|
||||
public class DifferenceIngredient extends AbstractIngredient
|
||||
{
|
||||
private final Ingredient base;
|
||||
@@ -37,7 +37,7 @@ public class DifferenceIngredient extends AbstractIngredient
|
||||
* @param base Ingredient the item must match
|
||||
* @param subtracted Ingredient the item must not match
|
||||
* @return Ingredient that {@code base} anything in base that is not in {@code subtracted}
|
||||
*/
|
||||
* /
|
||||
public static DifferenceIngredient of(Ingredient base, Ingredient subtracted)
|
||||
{
|
||||
return new DifferenceIngredient(base, subtracted);
|
||||
@@ -98,12 +98,12 @@ public class DifferenceIngredient extends AbstractIngredient
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement toJson()
|
||||
public JsonElement toJson(boolean allowEmpty)
|
||||
{
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("type", CraftingHelper.getID(Serializer.INSTANCE).toString());
|
||||
json.add("base", base.toJson());
|
||||
json.add("subtracted", subtracted.toJson());
|
||||
json.add("base", base.toJson(allowEmpty));
|
||||
json.add("subtracted", subtracted.toJson(allowEmpty));
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -113,8 +113,7 @@ public class DifferenceIngredient extends AbstractIngredient
|
||||
return Serializer.INSTANCE;
|
||||
}
|
||||
|
||||
public static class Serializer implements IIngredientSerializer<DifferenceIngredient>
|
||||
{
|
||||
public static class Serializer implements IIngredientSerializer<DifferenceIngredient> {
|
||||
public static final IIngredientSerializer<DifferenceIngredient> INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
@@ -141,3 +140,4 @@ public class DifferenceIngredient extends AbstractIngredient
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -5,16 +5,18 @@
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
// TODO: Ingredient Serializers
|
||||
/*
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
||||
public interface IIngredientSerializer<T extends Ingredient>
|
||||
{
|
||||
public interface IIngredientSerializer<T extends Ingredient> {
|
||||
T parse(FriendlyByteBuf buffer);
|
||||
|
||||
T parse(JsonObject json);
|
||||
|
||||
void write(FriendlyByteBuf buffer, T ingredient);
|
||||
}
|
||||
*/
|
||||
@@ -15,8 +15,7 @@ import net.minecraft.world.inventory.CraftingContainer;
|
||||
* For GUIs with recipe books, this allows their containers to have
|
||||
* recipe completion and ghost recipes in their craft matrices.
|
||||
*/
|
||||
public interface IRecipeContainer
|
||||
{
|
||||
public interface IRecipeContainer {
|
||||
/**
|
||||
* The crafting result slot of your container, where you take out the crafted item.
|
||||
* The equivalent for {@link CraftingMenu} is {@code CraftingMenu#resultSlots}.
|
||||
|
||||
@@ -13,8 +13,7 @@ import net.minecraft.world.item.crafting.Recipe;
|
||||
* book and auto crafting picks the correct shape.
|
||||
* Note: These methods can't be named 'getHeight' or 'getWidth' due to obfusication issues.
|
||||
*/
|
||||
public interface IShapedRecipe<T extends Container> extends Recipe<T>
|
||||
{
|
||||
public interface IShapedRecipe<T extends Container> extends Recipe<T> {
|
||||
int getRecipeWidth();
|
||||
int getRecipeHeight();
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/** Ingredient that matches if all child ingredients match */
|
||||
/** Ingredient that matches if all child ingredients match * /
|
||||
public class IntersectionIngredient extends AbstractIngredient
|
||||
{
|
||||
private final List<Ingredient> children;
|
||||
@@ -44,7 +44,7 @@ public class IntersectionIngredient extends AbstractIngredient
|
||||
* Gets an intersection ingredient
|
||||
* @param ingredients List of ingredients to match
|
||||
* @return Ingredient that only matches if all the passed ingredients match
|
||||
*/
|
||||
* /
|
||||
public static Ingredient of(Ingredient... ingredients)
|
||||
{
|
||||
if (ingredients.length == 0)
|
||||
@@ -175,3 +175,4 @@ public class IntersectionIngredient extends AbstractIngredient
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -54,3 +54,4 @@ public class MultiItemValue implements Value
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -28,7 +28,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/** Ingredient that matches the given items, performing a partial NBT match. Use {@link StrictNBTIngredient} if you want exact match on NBT */
|
||||
/** Ingredient that matches the given items, performing a partial NBT match. Use {@link StrictNBTIngredient} if you want exact match on NBT * /
|
||||
public class PartialNBTIngredient extends AbstractIngredient
|
||||
{
|
||||
private final Set<Item> items;
|
||||
@@ -52,13 +52,13 @@ public class PartialNBTIngredient extends AbstractIngredient
|
||||
this.predicate = new NbtPredicate(nbt);
|
||||
}
|
||||
|
||||
/** Creates a new ingredient matching any item from the list, containing the given NBT */
|
||||
/** Creates a new ingredient matching any item from the list, containing the given NBT * /
|
||||
public static PartialNBTIngredient of(CompoundTag nbt, ItemLike... items)
|
||||
{
|
||||
return new PartialNBTIngredient(Arrays.stream(items).map(ItemLike::asItem).collect(Collectors.toSet()), nbt);
|
||||
}
|
||||
|
||||
/** Creates a new ingredient matching the given item, containing the given NBT */
|
||||
/** Creates a new ingredient matching the given item, containing the given NBT * /
|
||||
public static PartialNBTIngredient of(ItemLike item, CompoundTag nbt)
|
||||
{
|
||||
return new PartialNBTIngredient(Set.of(item.asItem()), nbt);
|
||||
@@ -154,3 +154,4 @@ public class PartialNBTIngredient extends AbstractIngredient
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/** Ingredient that matches the given stack, performing an exact NBT match. Use {@link PartialNBTIngredient} if you need partial match. */
|
||||
/** Ingredient that matches the given stack, performing an exact NBT match. Use {@link PartialNBTIngredient} if you need partial match. * /
|
||||
public class StrictNBTIngredient extends AbstractIngredient
|
||||
{
|
||||
private final ItemStack stack;
|
||||
@@ -26,7 +26,7 @@ public class StrictNBTIngredient extends AbstractIngredient
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
/** Creates a new ingredient matching the given stack and tag */
|
||||
/** Creates a new ingredient matching the given stack and tag * /
|
||||
public static StrictNBTIngredient of(ItemStack stack)
|
||||
{
|
||||
return new StrictNBTIngredient(stack);
|
||||
@@ -85,3 +85,4 @@ public class StrictNBTIngredient extends AbstractIngredient
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
/*
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -36,3 +36,4 @@ public class VanillaIngredientSerializer implements IIngredientSerializer<Ingred
|
||||
buffer.writeItem(stack);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -3,11 +3,10 @@
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
// Auto generated package-info by MCP
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
Reference in new issue
Block a user