mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
Recipe system cleanup. (#6014)
This commit is contained in:
1 parent
3e9bc3c434
commit
e784a7f606
38 files changed
+1675
-194
No files matched your search
@@ -49,6 +49,8 @@ public class ForgeConfig
|
||||
|
||||
public final IntValue clumpingThreshold;
|
||||
|
||||
public final BooleanValue treatEmptyTagsAsAir;
|
||||
|
||||
Server(ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("Server configuration settings")
|
||||
.push("server");
|
||||
@@ -104,6 +106,11 @@ public class ForgeConfig
|
||||
.worldRestart()
|
||||
.defineInRange("clumpingThreshold", 64, 64, 1024);
|
||||
|
||||
treatEmptyTagsAsAir = builder
|
||||
.comment("Vanilla will treat crafting recipess using empty tags as air, and allow you to craft with nothing in that slot. This changes empty tags to use BARRIER as the item. To prevent crafting with air.")
|
||||
.translation("forge.configgui.treatEmptyTagsAsAir")
|
||||
.define("treatEmptyTagsAsAir", false);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.*;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
@@ -41,14 +42,32 @@ import org.apache.logging.log4j.Logger;
|
||||
import net.minecraft.command.arguments.ArgumentSerializer;
|
||||
import net.minecraft.command.arguments.ArgumentTypes;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraftforge.common.crafting.CompoundIngredient;
|
||||
import net.minecraftforge.common.crafting.ConditionalRecipe;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.IngredientNBT;
|
||||
import net.minecraftforge.common.crafting.VanillaIngredientSerializer;
|
||||
import net.minecraftforge.common.crafting.conditions.AndCondition;
|
||||
import net.minecraftforge.common.crafting.conditions.FalseCondition;
|
||||
import net.minecraftforge.common.crafting.conditions.ItemExistsCondition;
|
||||
import net.minecraftforge.common.crafting.conditions.ModLoadedCondition;
|
||||
import net.minecraftforge.common.crafting.conditions.NotCondition;
|
||||
import net.minecraftforge.common.crafting.conditions.OrCondition;
|
||||
import net.minecraftforge.common.crafting.conditions.TagEmptyCondition;
|
||||
import net.minecraftforge.common.crafting.conditions.TrueCondition;
|
||||
import net.minecraftforge.common.data.ForgeBlockTagsProvider;
|
||||
import net.minecraftforge.common.data.ForgeItemTagsProvider;
|
||||
import net.minecraftforge.common.data.ForgeRecipeProvider;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
@@ -91,6 +110,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
modEventBus.addListener(this::preInit);
|
||||
modEventBus.addListener(this::gatherData);
|
||||
modEventBus.register(this);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStarting);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStopping);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ForgeConfig.clientSpec);
|
||||
@@ -171,4 +191,24 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
gen.addProvider(new ForgeRecipeProvider(gen));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent //ModBus, can't use addListener due to nested genetics.
|
||||
public void registerRecipeSerialziers(RegistryEvent.Register<IRecipeSerializer<?>> event)
|
||||
{
|
||||
CraftingHelper.register(AndCondition.Serializer.INSTANCE);
|
||||
CraftingHelper.register(FalseCondition.Serializer.INSTANCE);
|
||||
CraftingHelper.register(ItemExistsCondition.Serializer.INSTANCE);
|
||||
CraftingHelper.register(ModLoadedCondition.Serializer.INSTANCE);
|
||||
CraftingHelper.register(NotCondition.Serializer.INSTANCE);
|
||||
CraftingHelper.register(OrCondition.Serializer.INSTANCE);
|
||||
CraftingHelper.register(TrueCondition.Serializer.INSTANCE);
|
||||
CraftingHelper.register(TagEmptyCondition.Serializer.INSTANCE);
|
||||
|
||||
CraftingHelper.register(new ResourceLocation("forge", "compound"), CompoundIngredient.Serializer.INSTANCE);
|
||||
CraftingHelper.register(new ResourceLocation("forge", "nbt"), IngredientNBT.Serializer.INSTANCE);
|
||||
CraftingHelper.register(new ResourceLocation("minecraft", "item"), VanillaIngredientSerializer.INSTANCE);
|
||||
|
||||
event.getRegistry().register(new ConditionalRecipe.Serializer<IRecipe<?>>().setRegistryName(new ResourceLocation("forge", "conditional")));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,8 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
@@ -41,15 +43,15 @@ import net.minecraft.network.PacketBuffer;
|
||||
|
||||
public class CompoundIngredient extends Ingredient
|
||||
{
|
||||
private Collection<Ingredient> children;
|
||||
private List<Ingredient> children;
|
||||
private ItemStack[] stacks;
|
||||
private IntList itemIds;
|
||||
private final boolean isSimple;
|
||||
|
||||
protected CompoundIngredient(Collection<Ingredient> children)
|
||||
protected CompoundIngredient(List<Ingredient> children)
|
||||
{
|
||||
super(Stream.of());
|
||||
this.children = children;
|
||||
this.children = Collections.unmodifiableList(children);
|
||||
this.isSimple = children.stream().allMatch(Ingredient::isSimple);
|
||||
}
|
||||
|
||||
@@ -110,17 +112,34 @@ public class CompoundIngredient extends Ingredient
|
||||
@Override
|
||||
public IIngredientSerializer<? extends Ingredient> getSerializer()
|
||||
{
|
||||
return CraftingHelper.INGREDIENT_COMPOUND;
|
||||
return Serializer.INSTANCE;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public Collection<Ingredient> getChildren()
|
||||
{
|
||||
return Collections.unmodifiableCollection(this.children);
|
||||
return this.children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize()
|
||||
{
|
||||
if (this.children.size() == 1)
|
||||
{
|
||||
return this.children.get(0).serialize();
|
||||
}
|
||||
else
|
||||
{
|
||||
JsonArray json = new JsonArray();
|
||||
this.children.stream().forEach(e -> json.add(e.serialize()));
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Serializer implements IIngredientSerializer<CompoundIngredient>
|
||||
{
|
||||
public static final Serializer INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
public CompoundIngredient parse(PacketBuffer buffer)
|
||||
{
|
||||
@@ -130,7 +149,7 @@ public class CompoundIngredient extends Ingredient
|
||||
@Override
|
||||
public CompoundIngredient parse(JsonObject json)
|
||||
{
|
||||
throw new JsonSyntaxException("CompountIngredient should not be directly referenced in json, just use an array of ingredients.");
|
||||
throw new JsonSyntaxException("CompoundIngredient should not be directly referenced in json, just use an array of ingredients.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
|
||||
public class ConditionalAdvancement
|
||||
{
|
||||
public static Builder builder()
|
||||
{
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static Advancement.Builder read(Gson gson, ResourceLocation recipeId, JsonObject json)
|
||||
{
|
||||
JsonArray entries = JSONUtils.getJsonArray(json, "advancements", null);
|
||||
if (entries == null)
|
||||
{
|
||||
if (!CraftingHelper.processConditions(json, "conditions"))
|
||||
return null;
|
||||
return gson.fromJson(json, Advancement.Builder.class);
|
||||
}
|
||||
|
||||
int idx = 0;
|
||||
for (JsonElement ele : entries)
|
||||
{
|
||||
if (!ele.isJsonObject())
|
||||
throw new JsonSyntaxException("Invalid advancement entry at index " + idx + " Must be JsonObject");
|
||||
if (CraftingHelper.processConditions(JSONUtils.getJsonArray(ele.getAsJsonObject(), "conditions")))
|
||||
return gson.fromJson(JSONUtils.getJsonObject(ele.getAsJsonObject(), "advancement"), Advancement.Builder.class);
|
||||
idx++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
{
|
||||
private List<ICondition[]> conditions = new ArrayList<>();
|
||||
private List<Advancement.Builder> advancements = new ArrayList<>();
|
||||
|
||||
private List<ICondition> currentConditions = new ArrayList<>();
|
||||
private boolean locked = false;
|
||||
|
||||
public Builder addCondition(ICondition condition)
|
||||
{
|
||||
if (locked)
|
||||
throw new IllegalStateException("Attempted to modify finished builder");
|
||||
currentConditions.add(condition);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addAdvancement(Consumer<Consumer<Advancement.Builder>> callable)
|
||||
{
|
||||
if (locked)
|
||||
throw new IllegalStateException("Attempted to modify finished builder");
|
||||
callable.accept(this::addAdvancement);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addAdvancement(Advancement.Builder recipe)
|
||||
{
|
||||
if (locked)
|
||||
throw new IllegalStateException("Attempted to modify finished builder");
|
||||
if (currentConditions.isEmpty())
|
||||
throw new IllegalStateException("Can not add a advancement with no conditions.");
|
||||
conditions.add(currentConditions.toArray(new ICondition[currentConditions.size()]));
|
||||
advancements.add(recipe);
|
||||
currentConditions.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
public JsonObject write()
|
||||
{
|
||||
if (!locked)
|
||||
{
|
||||
if (!currentConditions.isEmpty())
|
||||
throw new IllegalStateException("Invalid builder state: Orphaned conditions");
|
||||
if (advancements.isEmpty())
|
||||
throw new IllegalStateException("Invalid builder state: No Advancements");
|
||||
locked = true;
|
||||
}
|
||||
JsonObject json = new JsonObject();
|
||||
JsonArray array = new JsonArray();
|
||||
json.add("advancements", array);
|
||||
for (int x = 0; x < conditions.size(); x++)
|
||||
{
|
||||
JsonObject holder = new JsonObject();
|
||||
|
||||
JsonArray conds = new JsonArray();
|
||||
for (ICondition c : conditions.get(x))
|
||||
conds.add(CraftingHelper.serialize(c));
|
||||
holder.add("conditions", conds);
|
||||
holder.add("advancement", advancements.get(x).serialize());
|
||||
|
||||
array.add(holder);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.RecipeManager;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
public class ConditionalRecipe
|
||||
{
|
||||
@ObjectHolder("forge:conditional")
|
||||
public static final IRecipeSerializer<IRecipe<?>> SERIALZIER = null;
|
||||
|
||||
public static Builder builder()
|
||||
{
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Serializer<T extends IRecipe<?>> implements IRecipeSerializer<T>
|
||||
{
|
||||
private ResourceLocation name;
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<?> setRegistryName(ResourceLocation name)
|
||||
{
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getRegistryName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<IRecipeSerializer<?>> getRegistryType()
|
||||
{
|
||||
return Serializer.<IRecipeSerializer<?>>castClass(IRecipeSerializer.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") // Need this wrapper, because generics
|
||||
private static <G> Class<G> castClass(Class<?> cls)
|
||||
{
|
||||
return (Class<G>)cls;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") // We return a nested one, so we can't know what type it is.
|
||||
@Override
|
||||
public T read(ResourceLocation recipeId, JsonObject json)
|
||||
{
|
||||
JsonArray items = JSONUtils.getJsonArray(json, "recipes");
|
||||
int idx = 0;
|
||||
for (JsonElement ele : items)
|
||||
{
|
||||
if (!ele.isJsonObject())
|
||||
throw new JsonSyntaxException("Invalid recipes entry at index " + idx + " Must be JsonObject");
|
||||
if (CraftingHelper.processConditions(JSONUtils.getJsonArray(ele.getAsJsonObject(), "conditions")))
|
||||
return (T)RecipeManager.deserializeRecipe(recipeId, JSONUtils.getJsonObject(ele.getAsJsonObject(), "recipe"));
|
||||
idx++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Should never get here as we return one of the recipes we wrap.
|
||||
@Override public T read(ResourceLocation recipeId, PacketBuffer buffer) { return null; }
|
||||
@Override public void write(PacketBuffer buffer, T recipe) {}
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
{
|
||||
private List<ICondition[]> conditions = new ArrayList<>();
|
||||
private List<IFinishedRecipe> recipes = new ArrayList<>();
|
||||
private ResourceLocation advId;
|
||||
private ConditionalAdvancement.Builder adv;
|
||||
|
||||
private List<ICondition> currentConditions = new ArrayList<>();
|
||||
|
||||
public Builder addCondition(ICondition condition)
|
||||
{
|
||||
currentConditions.add(condition);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addRecipe(Consumer<Consumer<IFinishedRecipe>> callable)
|
||||
{
|
||||
callable.accept(this::addRecipe);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addRecipe(IFinishedRecipe recipe)
|
||||
{
|
||||
if (currentConditions.isEmpty())
|
||||
throw new IllegalStateException("Can not add a recipe with no conditions.");
|
||||
conditions.add(currentConditions.toArray(new ICondition[currentConditions.size()]));
|
||||
recipes.add(recipe);
|
||||
currentConditions.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setAdvancement(String namespace, String path, ConditionalAdvancement.Builder advancement)
|
||||
{
|
||||
return setAdvancement(new ResourceLocation(namespace, path), advancement);
|
||||
}
|
||||
|
||||
public Builder setAdvancement(ResourceLocation id, ConditionalAdvancement.Builder advancement)
|
||||
{
|
||||
if (this.advId != null)
|
||||
throw new IllegalStateException("Invalid ConditionalRecipeBuilder, Advancement already set");
|
||||
this.advId = id;
|
||||
this.adv = advancement;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void build(Consumer<IFinishedRecipe> consumer, String namespace, String path)
|
||||
{
|
||||
build(consumer, new ResourceLocation(namespace, path));
|
||||
}
|
||||
|
||||
public void build(Consumer<IFinishedRecipe> consumer, ResourceLocation id)
|
||||
{
|
||||
if (!currentConditions.isEmpty())
|
||||
throw new IllegalStateException("Invalid ConditionalRecipe builder, Orphaned conditions");
|
||||
if (recipes.isEmpty())
|
||||
throw new IllegalStateException("Invalid ConditionalRecipe builder, No recipes");
|
||||
|
||||
consumer.accept(new Finished(id, conditions, recipes, advId, adv));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Finished implements IFinishedRecipe
|
||||
{
|
||||
private final ResourceLocation id;
|
||||
private final List<ICondition[]> conditions;
|
||||
private final List<IFinishedRecipe> recipes;
|
||||
private final ResourceLocation advId;
|
||||
private final ConditionalAdvancement.Builder adv;
|
||||
|
||||
private Finished(ResourceLocation id, List<ICondition[]> conditions, List<IFinishedRecipe> recipes, ResourceLocation advId, ConditionalAdvancement.Builder adv)
|
||||
{
|
||||
this.id = id;
|
||||
this.conditions = conditions;
|
||||
this.recipes = recipes;
|
||||
this.advId = advId;
|
||||
this.adv = adv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonObject json) {
|
||||
JsonArray array = new JsonArray();
|
||||
json.add("recipes", array);
|
||||
for (int x = 0; x < conditions.size(); x++)
|
||||
{
|
||||
JsonObject holder = new JsonObject();
|
||||
|
||||
JsonArray conds = new JsonArray();
|
||||
for (ICondition c : conditions.get(x))
|
||||
conds.add(CraftingHelper.serialize(c));
|
||||
holder.add("conditions", conds);
|
||||
holder.add("recipe", recipes.get(x).getRecipeJson());
|
||||
|
||||
array.add(holder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer()
|
||||
{
|
||||
return SERIALZIER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject getAdvancementJson() {
|
||||
return adv == null ? null : adv.write();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAdvancementID() {
|
||||
return advId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,19 +19,12 @@
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fml.ModList;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -40,24 +33,21 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.item.crafting.Ingredient.IItemList;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
import net.minecraftforge.common.crafting.conditions.IConditionSerializer;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
@@ -65,71 +55,17 @@ import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
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<>();
|
||||
private static final Map<ResourceLocation, IConditionSerializer<?>> conditions = new HashMap<>();
|
||||
private static final BiMap<ResourceLocation, IIngredientSerializer<?>> ingredients = HashBiMap.create();
|
||||
private static Map<ResourceLocation, IItemList> constants = new HashMap<>();
|
||||
|
||||
public static final IConditionSerializer CONDITION_MOD_LOADED = condition("mod_loaded", json -> {
|
||||
String modid = JSONUtils.getString(json, "modid");
|
||||
return () -> ModList.get().isLoaded(modid);
|
||||
});
|
||||
public static final IConditionSerializer CONDITION_ITEM_EXISTS = condition("item_exists", json -> {
|
||||
String itemName = JSONUtils.getString(json, "item");
|
||||
return () -> ForgeRegistries.ITEMS.containsKey(new ResourceLocation(itemName));
|
||||
});
|
||||
public static final IConditionSerializer CONDITION_NOT = condition("not", json -> {
|
||||
BooleanSupplier child = CraftingHelper.getCondition(JSONUtils.getJsonObject(json, "value"));
|
||||
return () -> !child.getAsBoolean();
|
||||
});
|
||||
public static final IConditionSerializer CONDITION_OR = condition("or", json -> {
|
||||
JsonArray values = JSONUtils.getJsonArray(json, "values");
|
||||
List<BooleanSupplier> children = Lists.newArrayList();
|
||||
for (JsonElement j : values)
|
||||
{
|
||||
if (!j.isJsonObject())
|
||||
throw new JsonSyntaxException("Or condition values must be an array of JsonObjects");
|
||||
children.add(CraftingHelper.getCondition(j.getAsJsonObject()));
|
||||
}
|
||||
return () -> children.stream().anyMatch(BooleanSupplier::getAsBoolean);
|
||||
});
|
||||
public static final IConditionSerializer CONDITION_AND = condition("and", json -> {
|
||||
JsonArray values = JSONUtils.getJsonArray(json, "values");
|
||||
List<BooleanSupplier> children = Lists.newArrayList();
|
||||
for (JsonElement j : values)
|
||||
{
|
||||
if (!j.isJsonObject())
|
||||
throw new JsonSyntaxException("And condition values must be an array of JsonObjects");
|
||||
children.add(CraftingHelper.getCondition(j.getAsJsonObject()));
|
||||
}
|
||||
return () -> children.stream().allMatch(c -> c.getAsBoolean());
|
||||
});
|
||||
public static final IConditionSerializer CONDITION_FALSE = condition("false", json -> () -> false);
|
||||
|
||||
public static final IIngredientSerializer<IngredientNBT> INGREDIENT_NBT = register(new ResourceLocation("forge", "nbt"), new IngredientNBT.Serializer());
|
||||
public static final IIngredientSerializer<CompoundIngredient> INGREDIENT_COMPOUND = register(new ResourceLocation("forge", "compound"), new CompoundIngredient.Serializer());
|
||||
public static final IIngredientSerializer<Ingredient> INGREDIENT_VANILLA = register(new ResourceLocation("minecraft", "item"), new IIngredientSerializer<Ingredient>() {
|
||||
public Ingredient parse(PacketBuffer buffer) {
|
||||
return Ingredient.fromItemListStream(Stream.generate(() -> new Ingredient.SingleItemList(buffer.readItemStack())).limit(buffer.readVarInt()));
|
||||
}
|
||||
|
||||
public Ingredient parse(JsonObject json) {
|
||||
return Ingredient.fromItemListStream(Stream.of(Ingredient.deserializeItemList(json)));
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buffer, Ingredient ingredient) {
|
||||
ItemStack[] items = ingredient.getMatchingStacks();
|
||||
buffer.writeVarInt(items.length);
|
||||
|
||||
for (ItemStack stack : items)
|
||||
buffer.writeItemStack(stack);
|
||||
}
|
||||
});
|
||||
|
||||
public static IConditionSerializer register(ResourceLocation key, IConditionSerializer serializer)
|
||||
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);
|
||||
@@ -144,11 +80,11 @@ public class CraftingHelper
|
||||
ingredients.put(key, serializer);
|
||||
return serializer;
|
||||
}
|
||||
|
||||
private static IConditionSerializer condition(String name, IConditionSerializer serializer) {
|
||||
return register(new ResourceLocation("forge", name), serializer);
|
||||
@Nullable
|
||||
public static ResourceLocation getID(IIngredientSerializer<?> serializer)
|
||||
{
|
||||
return ingredients.inverse().get(serializer);
|
||||
}
|
||||
|
||||
public static <T extends Ingredient> void write(PacketBuffer buffer, T ingredient)
|
||||
{
|
||||
@SuppressWarnings("unchecked") //I wonder if there is a better way generic wise...
|
||||
@@ -156,7 +92,7 @@ public class CraftingHelper
|
||||
ResourceLocation key = ingredients.inverse().get(serializer);
|
||||
if (key == null)
|
||||
throw new IllegalArgumentException("Tried to serialize unregistered Ingredient: " + ingredient + " " + serializer);
|
||||
if (serializer != INGREDIENT_VANILLA)
|
||||
if (serializer != VanillaIngredientSerializer.INSTANCE)
|
||||
{
|
||||
buffer.writeVarInt(-1); //Marker to know there is a custom ingredient
|
||||
buffer.writeResourceLocation(key);
|
||||
@@ -275,94 +211,27 @@ public class CraftingHelper
|
||||
throw new JsonSyntaxException("Conditions must be an array of JsonObjects");
|
||||
|
||||
JsonObject json = conditions.get(x).getAsJsonObject();
|
||||
BooleanSupplier cond = CraftingHelper.getCondition(json);
|
||||
if (!cond.getAsBoolean())
|
||||
if (!CraftingHelper.getCondition(json).test())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static BooleanSupplier getCondition(JsonObject json)
|
||||
public static ICondition getCondition(JsonObject json)
|
||||
{
|
||||
ResourceLocation type = new ResourceLocation(JSONUtils.getString(json, "type"));
|
||||
IConditionSerializer serrializer = conditions.get(type);
|
||||
if (serrializer == null)
|
||||
IConditionSerializer<?> serializer = conditions.get(type);
|
||||
if (serializer == null)
|
||||
throw new JsonSyntaxException("Unknown condition type: " + type.toString());
|
||||
return serrializer.parse(json);
|
||||
return serializer.read(json);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IItemList getConstant(ResourceLocation key) {
|
||||
return constants.get(key);
|
||||
}
|
||||
|
||||
public static void reloadConstants(IResourceManager manager) {
|
||||
Map<ResourceLocation, IItemList> tmp = new HashMap<>();
|
||||
for(ResourceLocation key : manager.getAllResourceLocations("recipes", filename -> filename.equals("_constants.json")))
|
||||
{
|
||||
String path = key.getPath();
|
||||
if (!path.equals("recipes/_constants.json")) //Top level only
|
||||
continue;
|
||||
|
||||
tmp.putAll(loadConstants(manager, key));
|
||||
}
|
||||
constants = tmp;
|
||||
}
|
||||
|
||||
public static Map<ResourceLocation, IItemList> loadConstants(IResourceManager manager, ResourceLocation key) {
|
||||
Map<ResourceLocation, IItemList> tmp = new HashMap<>();
|
||||
try (IResource iresource = manager.getResource(key))
|
||||
{
|
||||
JsonObject[] elements = JSONUtils.fromJson(GSON, IOUtils.toString(iresource.getInputStream(), StandardCharsets.UTF_8), JsonObject[].class);
|
||||
for (int x = 0; x < elements.length; x++)
|
||||
{
|
||||
JsonObject json = elements[x];
|
||||
//Force namespace to the directory that this constants file is in, to prevent modders from overriding other's sneakily
|
||||
//TODO: Move back to a resource pack/mod specific constant list?
|
||||
ResourceLocation name = json.has("name") ? new ResourceLocation(JSONUtils.getString(json, "name")) : null;
|
||||
if (name != null)
|
||||
name = new ResourceLocation(key.getNamespace(), name.getPath());
|
||||
|
||||
if (json == null || json.size() == 0)
|
||||
LOGGER.error(CRAFTHELPER, "Couldn't load constant #{} from {} as it's null or empty", x, key);
|
||||
else if (!processConditions(json, "conditions"))
|
||||
LOGGER.info(CRAFTHELPER, "Skipping loading constant #{} from {} as it's conditions were not met", x, key);
|
||||
else if (name == null)
|
||||
LOGGER.error(CRAFTHELPER, "Couldn't load constant #{} from {} as it's missing `name`", x, key);
|
||||
else if (json.has("items"))
|
||||
{
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
for (JsonElement item : JSONUtils.getJsonArray(json, "items"))
|
||||
{
|
||||
if (item.isJsonObject())
|
||||
items.add(getItemStack(item.getAsJsonObject(), true));
|
||||
else
|
||||
{
|
||||
LOGGER.error(CRAFTHELPER, "Couldn't load constant #{} from {} as it's `items` entry is not a object", x, key);
|
||||
items.clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!items.isEmpty())
|
||||
tmp.put(name, new StackList(items));
|
||||
}
|
||||
else if (json.has("tag"))
|
||||
tmp.put(name, Ingredient.deserializeItemList(json));
|
||||
else if (json.has("item"))
|
||||
tmp.put(name, new StackList(Lists.newArrayList(getItemStack(JSONUtils.getJsonObject(json, "item"), true))));
|
||||
else
|
||||
LOGGER.error(CRAFTHELPER, "Couldn't load constant #{} from {} as it's missing `item` or `items` element", x, key);
|
||||
}
|
||||
|
||||
}
|
||||
catch (IllegalArgumentException | JsonParseException e)
|
||||
{
|
||||
LOGGER.error(CRAFTHELPER, "Parsing error loading constants {}", key, e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.error(CRAFTHELPER, "Couldn't read constants from {}", key, e);
|
||||
}
|
||||
return tmp;
|
||||
public static <T extends ICondition> JsonObject serialize(T condition)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
IConditionSerializer<T> serializer = (IConditionSerializer<T>)conditions.get(condition.getID());
|
||||
if (serializer == null)
|
||||
throw new JsonSyntaxException("Unknown condition type: " + condition.getID().toString());
|
||||
return serializer.getJson(condition);
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,14 @@ import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
//TODO: 1.15 Rename to NBTIngredient to match naming.
|
||||
public class IngredientNBT extends Ingredient
|
||||
{
|
||||
private final ItemStack stack;
|
||||
@@ -56,11 +58,25 @@ public class IngredientNBT extends Ingredient
|
||||
@Override
|
||||
public IIngredientSerializer<? extends Ingredient> getSerializer()
|
||||
{
|
||||
return CraftingHelper.INGREDIENT_NBT;
|
||||
return Serializer.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize()
|
||||
{
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("type", CraftingHelper.getID(Serializer.INSTANCE).toString());
|
||||
json.addProperty("item", stack.getItem().getRegistryName().toString());
|
||||
json.addProperty("count", stack.getCount());
|
||||
if (stack.hasTag())
|
||||
json.addProperty("nbt", stack.getTag().toString());
|
||||
return json;
|
||||
}
|
||||
|
||||
public static class Serializer implements IIngredientSerializer<IngredientNBT>
|
||||
{
|
||||
public static final Serializer INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
public IngredientNBT parse(PacketBuffer buffer) {
|
||||
return new IngredientNBT(buffer.readItemStack());
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
public class VanillaIngredientSerializer implements IIngredientSerializer<Ingredient>
|
||||
{
|
||||
public static final VanillaIngredientSerializer INSTANCE = new VanillaIngredientSerializer();
|
||||
|
||||
public Ingredient parse(PacketBuffer buffer)
|
||||
{
|
||||
return Ingredient.fromItemListStream(Stream.generate(() -> new Ingredient.SingleItemList(buffer.readItemStack())).limit(buffer.readVarInt()));
|
||||
}
|
||||
|
||||
public Ingredient parse(JsonObject json)
|
||||
{
|
||||
return Ingredient.fromItemListStream(Stream.of(Ingredient.deserializeItemList(json)));
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buffer, Ingredient ingredient)
|
||||
{
|
||||
ItemStack[] items = ingredient.getMatchingStacks();
|
||||
buffer.writeVarInt(items.length);
|
||||
|
||||
for (ItemStack stack : items)
|
||||
buffer.writeItemStack(stack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting.conditions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
|
||||
public class AndCondition implements ICondition
|
||||
{
|
||||
private static final ResourceLocation NAME = new ResourceLocation("forge", "and");
|
||||
private final ICondition[] children;
|
||||
|
||||
public AndCondition(ICondition... values)
|
||||
{
|
||||
if (values == null || values.length == 0)
|
||||
throw new IllegalArgumentException("Values must not be empty");
|
||||
|
||||
for (ICondition child : values)
|
||||
{
|
||||
if (child == null)
|
||||
throw new IllegalArgumentException("Value must not be null");
|
||||
}
|
||||
|
||||
this.children = values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test()
|
||||
{
|
||||
for (ICondition child : children)
|
||||
{
|
||||
if (!child.test())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return Joiner.on(" && ").join(children);
|
||||
}
|
||||
|
||||
public static class Serializer implements IConditionSerializer<AndCondition>
|
||||
{
|
||||
public static final Serializer INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
public void write(JsonObject json, AndCondition value)
|
||||
{
|
||||
JsonArray values = new JsonArray();
|
||||
for (ICondition child : value.children)
|
||||
values.add(CraftingHelper.serialize(child));
|
||||
json.add("values", values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AndCondition read(JsonObject json)
|
||||
{
|
||||
List<ICondition> children = new ArrayList<>();
|
||||
for (JsonElement j : JSONUtils.getJsonArray(json, "values"))
|
||||
{
|
||||
if (!j.isJsonObject())
|
||||
throw new JsonSyntaxException("And condition values must be an array of JsonObjects");
|
||||
children.add(CraftingHelper.getCondition(j.getAsJsonObject()));
|
||||
}
|
||||
return new AndCondition(children.toArray(new ICondition[children.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return AndCondition.NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting.conditions;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public final class FalseCondition implements ICondition
|
||||
{
|
||||
public static final FalseCondition INSTANCE = new FalseCondition();
|
||||
private static final ResourceLocation NAME = new ResourceLocation("forge", "false");
|
||||
|
||||
private FalseCondition() {}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "false";
|
||||
}
|
||||
|
||||
public static class Serializer implements IConditionSerializer<FalseCondition>
|
||||
{
|
||||
public static final Serializer INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
public void write(JsonObject json, FalseCondition value) { }
|
||||
|
||||
@Override
|
||||
public FalseCondition read(JsonObject json)
|
||||
{
|
||||
return FalseCondition.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return FalseCondition.NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-7
@@ -17,14 +17,13 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
package net.minecraftforge.common.crafting.conditions;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IConditionSerializer
|
||||
public interface ICondition
|
||||
{
|
||||
BooleanSupplier parse(JsonObject json);
|
||||
ResourceLocation getID();
|
||||
|
||||
boolean test();
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting.conditions;
|
||||
|
||||
public interface IConditionBuilder
|
||||
{
|
||||
default ICondition and(ICondition... values)
|
||||
{
|
||||
return new AndCondition(values);
|
||||
}
|
||||
|
||||
default ICondition FALSE()
|
||||
{
|
||||
return FalseCondition.INSTANCE;
|
||||
}
|
||||
|
||||
default ICondition TRUE()
|
||||
{
|
||||
return TrueCondition.INSTANCE;
|
||||
}
|
||||
|
||||
default ICondition not(ICondition value)
|
||||
{
|
||||
return new NotCondition(value);
|
||||
}
|
||||
|
||||
default ICondition or(ICondition... values)
|
||||
{
|
||||
return new OrCondition(values);
|
||||
}
|
||||
|
||||
default ICondition itemExists(String namespace, String path)
|
||||
{
|
||||
return new ItemExistsCondition(namespace, path);
|
||||
}
|
||||
|
||||
default ICondition modLoaded(String modid)
|
||||
{
|
||||
return new ModLoadedCondition(modid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting.conditions;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface IConditionSerializer<T extends ICondition>
|
||||
{
|
||||
void write(JsonObject json, T value);
|
||||
|
||||
T read(JsonObject json);
|
||||
|
||||
ResourceLocation getID();
|
||||
|
||||
default JsonObject getJson(T value)
|
||||
{
|
||||
JsonObject json = new JsonObject();
|
||||
this.write(json, value);
|
||||
json.addProperty("type", value.getID().toString());
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting.conditions;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class ItemExistsCondition implements ICondition
|
||||
{
|
||||
private static final ResourceLocation NAME = new ResourceLocation("forge", "item_exists");
|
||||
private final ResourceLocation item;
|
||||
|
||||
public ItemExistsCondition(String location)
|
||||
{
|
||||
this(new ResourceLocation(location));
|
||||
}
|
||||
|
||||
public ItemExistsCondition(String namespace, String path)
|
||||
{
|
||||
this(new ResourceLocation(namespace, path));
|
||||
}
|
||||
|
||||
public ItemExistsCondition(ResourceLocation item)
|
||||
{
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test()
|
||||
{
|
||||
return ForgeRegistries.ITEMS.containsKey(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "item_exists(\"" + item + "\")";
|
||||
}
|
||||
|
||||
public static class Serializer implements IConditionSerializer<ItemExistsCondition>
|
||||
{
|
||||
public static final Serializer INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
public void write(JsonObject json, ItemExistsCondition value)
|
||||
{
|
||||
json.addProperty("item", value.item.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemExistsCondition read(JsonObject json)
|
||||
{
|
||||
return new ItemExistsCondition(new ResourceLocation(JSONUtils.getString(json, "item")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return ItemExistsCondition.NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting.conditions;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
|
||||
public class ModLoadedCondition implements ICondition
|
||||
{
|
||||
private static final ResourceLocation NAME = new ResourceLocation("forge", "mod_loaded");
|
||||
private final String modid;
|
||||
|
||||
public ModLoadedCondition(String modid)
|
||||
{
|
||||
this.modid = modid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test()
|
||||
{
|
||||
return ModList.get().isLoaded(modid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "mod_loaded(\"" + modid + "\")";
|
||||
}
|
||||
|
||||
public static class Serializer implements IConditionSerializer<ModLoadedCondition>
|
||||
{
|
||||
public static final Serializer INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
public void write(JsonObject json, ModLoadedCondition value)
|
||||
{
|
||||
json.addProperty("modid", value.modid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModLoadedCondition read(JsonObject json)
|
||||
{
|
||||
return new ModLoadedCondition(JSONUtils.getString(json, "modid"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return ModLoadedCondition.NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting.conditions;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
|
||||
public class NotCondition implements ICondition
|
||||
{
|
||||
private static final ResourceLocation NAME = new ResourceLocation("forge", "not");
|
||||
private final ICondition child;
|
||||
|
||||
public NotCondition(ICondition child)
|
||||
{
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test()
|
||||
{
|
||||
return !child.test();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "!" + child;
|
||||
}
|
||||
|
||||
public static class Serializer implements IConditionSerializer<NotCondition>
|
||||
{
|
||||
public static final Serializer INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
public void write(JsonObject json, NotCondition value)
|
||||
{
|
||||
json.add("value", CraftingHelper.serialize(value.child));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotCondition read(JsonObject json)
|
||||
{
|
||||
return new NotCondition(CraftingHelper.getCondition(JSONUtils.getJsonObject(json, "value")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return NotCondition.NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting.conditions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
|
||||
public class OrCondition implements ICondition
|
||||
{
|
||||
private static final ResourceLocation NAME = new ResourceLocation("forge", "or");
|
||||
private final ICondition[] children;
|
||||
|
||||
public OrCondition(ICondition... values)
|
||||
{
|
||||
if (values == null || values.length == 0)
|
||||
throw new IllegalArgumentException("Values must not be empty");
|
||||
|
||||
for (ICondition child : values)
|
||||
{
|
||||
if (child == null)
|
||||
throw new IllegalArgumentException("Value must not be null");
|
||||
}
|
||||
|
||||
this.children = values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test()
|
||||
{
|
||||
for (ICondition child : children)
|
||||
{
|
||||
if (child.test())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return Joiner.on(" || ").join(children);
|
||||
}
|
||||
|
||||
public static class Serializer implements IConditionSerializer<OrCondition>
|
||||
{
|
||||
public static final Serializer INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
public void write(JsonObject json, OrCondition value)
|
||||
{
|
||||
JsonArray values = new JsonArray();
|
||||
for (ICondition child : value.children)
|
||||
values.add(CraftingHelper.serialize(child));
|
||||
json.add("values", values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrCondition read(JsonObject json)
|
||||
{
|
||||
List<ICondition> children = new ArrayList<>();
|
||||
for (JsonElement j : JSONUtils.getJsonArray(json, "values"))
|
||||
{
|
||||
if (!j.isJsonObject())
|
||||
throw new JsonSyntaxException("Or condition values must be an array of JsonObjects");
|
||||
children.add(CraftingHelper.getCondition(j.getAsJsonObject()));
|
||||
}
|
||||
return new OrCondition(children.toArray(new ICondition[children.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return OrCondition.NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting.conditions;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class TagEmptyCondition implements ICondition
|
||||
{
|
||||
private static final ResourceLocation NAME = new ResourceLocation("forge", "tag_empty");
|
||||
private final ResourceLocation tag_name;
|
||||
|
||||
public TagEmptyCondition(String location)
|
||||
{
|
||||
this(new ResourceLocation(location));
|
||||
}
|
||||
|
||||
public TagEmptyCondition(String namespace, String path)
|
||||
{
|
||||
this(new ResourceLocation(namespace, path));
|
||||
}
|
||||
|
||||
public TagEmptyCondition(ResourceLocation tag)
|
||||
{
|
||||
this.tag_name = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test()
|
||||
{
|
||||
Tag<Item> tag = ItemTags.getCollection().get(tag_name);
|
||||
return tag == null || tag.getAllElements().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "tag_empty(\"" + tag_name + "\")";
|
||||
}
|
||||
|
||||
public static class Serializer implements IConditionSerializer<TagEmptyCondition>
|
||||
{
|
||||
public static final Serializer INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
public void write(JsonObject json, TagEmptyCondition value)
|
||||
{
|
||||
json.addProperty("tag", value.tag_name.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagEmptyCondition read(JsonObject json)
|
||||
{
|
||||
return new TagEmptyCondition(new ResourceLocation(JSONUtils.getString(json, "tag")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return TagEmptyCondition.NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.crafting.conditions;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public final class TrueCondition implements ICondition
|
||||
{
|
||||
public static final TrueCondition INSTANCE = new TrueCondition();
|
||||
private static final ResourceLocation NAME = new ResourceLocation("forge", "true");
|
||||
|
||||
private TrueCondition() {}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "true";
|
||||
}
|
||||
|
||||
public static class Serializer implements IConditionSerializer<TrueCondition>
|
||||
{
|
||||
public static final Serializer INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
public void write(JsonObject json, TrueCondition value) { }
|
||||
|
||||
@Override
|
||||
public TrueCondition read(JsonObject json)
|
||||
{
|
||||
return TrueCondition.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return TrueCondition.NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,16 +52,12 @@ import net.minecraftforge.common.Tags;
|
||||
|
||||
public class ForgeRecipeProvider extends RecipeProvider
|
||||
{
|
||||
private final DataGenerator generator;
|
||||
private final Path ADV_ROOT;
|
||||
private Map<Item, Tag<Item>> replacements = new HashMap<>();
|
||||
private Set<ResourceLocation> excludes = new HashSet<>();
|
||||
|
||||
public ForgeRecipeProvider(DataGenerator generatorIn)
|
||||
{
|
||||
super(generatorIn);
|
||||
this.generator = generatorIn;
|
||||
ADV_ROOT = this.generator.getOutputFolder().resolve("data/minecraft/advancements/recipes/root.json");
|
||||
}
|
||||
|
||||
private void exclude(IItemProvider item)
|
||||
@@ -101,7 +97,6 @@ public class ForgeRecipeProvider extends RecipeProvider
|
||||
|
||||
@Override
|
||||
protected void saveRecipeAdvancement(DirectoryCache cache, JsonObject advancementJson, Path pathIn) {
|
||||
if (pathIn.equals(ADV_ROOT)) return; //We NEVER care about this.
|
||||
//NOOP - We dont replace any of the advancement things yet...
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,9 @@ public class ModLoader
|
||||
|
||||
LOGGER.debug(LOADING, "ModContainer is {}", ModContainer.class.getClassLoader());
|
||||
final List<ModContainer> containers = modFile.getScanResult().getTargets().entrySet().stream().
|
||||
map(e -> buildModContainerFromTOML(modFile, modClassLoader, modInfoMap, e)).collect(Collectors.toList());
|
||||
map(e -> buildModContainerFromTOML(modFile, modClassLoader, modInfoMap, e))
|
||||
.filter(e -> e != null)
|
||||
.collect(Collectors.toList());
|
||||
if (containers.size() != modInfoMap.size()) {
|
||||
LOGGER.fatal(LOADING,"File {} constructed {} mods: {}, but had {} mods specified: {}",
|
||||
modFile.getFilePath(),
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.server.command;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.server.command;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.server.command;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
Reference in new issue
Block a user