mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 19:05:16 +00:00
Move lexicon elven trade recipe as well
This commit is contained in:
1 parent
ccd2d01bb7
commit
ff1d8ca293
15 files changed
+197
-166
No files matched your search
@@ -64,7 +64,6 @@ public final class BotaniaAPI {
|
||||
public static Map<ResourceLocation, RecipePureDaisy> pureDaisyRecipes = Collections.emptyMap();
|
||||
public static Map<ResourceLocation, RecipeManaInfusion> manaInfusionRecipes = Collections.emptyMap();
|
||||
public static Map<ResourceLocation, RecipeRuneAltar> runeAltarRecipes = Collections.emptyMap();
|
||||
public static Map<ResourceLocation, RecipeElvenTrade> elvenTradeRecipes = Collections.emptyMap();
|
||||
public static Map<ResourceLocation, RecipeBrew> brewRecipes = Collections.emptyMap();
|
||||
|
||||
public static Map<ResourceLocation, Integer> oreWeights = Collections.emptyMap();
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import vazkii.botania.common.crafting.AbstractElvenTradeRecipe;
|
||||
import vazkii.botania.common.crafting.ModRecipeTypes;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -33,8 +34,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class RecipeElvenTrade implements IRecipe<IInventory> {
|
||||
private final ResourceLocation id;
|
||||
public class RecipeElvenTrade extends AbstractElvenTradeRecipe {
|
||||
private final ImmutableList<ItemStack> outputs;
|
||||
private final ImmutableList<Ingredient> inputs;
|
||||
|
||||
@@ -43,18 +43,12 @@ public class RecipeElvenTrade implements IRecipe<IInventory> {
|
||||
}
|
||||
|
||||
public RecipeElvenTrade(ResourceLocation id, ItemStack[] outputs, Ingredient... inputs) {
|
||||
this.id = id;
|
||||
super(id);
|
||||
this.outputs = ImmutableList.copyOf(outputs);
|
||||
this.inputs = ImmutableList.copyOf(inputs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to match the recipe
|
||||
*
|
||||
* @param stacks Entire contents of the portal's buffer
|
||||
* @return {@link Optional#empty()} if recipe doesn't match, Optional with a set of items used by recipe
|
||||
* otherwise
|
||||
*/
|
||||
@Override
|
||||
public Optional<List<ItemStack>> match(List<ItemStack> stacks) {
|
||||
List<Ingredient> inputsMissing = new ArrayList<>(inputs);
|
||||
List<ItemStack> stacksToRemove = new ArrayList<>();
|
||||
@@ -88,9 +82,7 @@ public class RecipeElvenTrade implements IRecipe<IInventory> {
|
||||
return inputsMissing.isEmpty() ? Optional.of(stacksToRemove) : Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* If the recipe does not contain the item, it will be destroyed upon entering the portal.
|
||||
*/
|
||||
@Override
|
||||
public boolean containsItem(ItemStack stack) {
|
||||
for (Ingredient input : inputs) {
|
||||
if (input.test(stack)) {
|
||||
@@ -100,54 +92,23 @@ public class RecipeElvenTrade implements IRecipe<IInventory> {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(@Nonnull IInventory inv, @Nonnull World world) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult(@Nonnull IInventory inv) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFit(int width, int height) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
return ModRecipeTypes.ELVEN_TRADE_SERIALIZER;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeType<?> getType() {
|
||||
return ModRecipeTypes.ELVEN_TRADE_TYPE;
|
||||
}
|
||||
|
||||
public List<Ingredient> getInputs() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOutputs() {
|
||||
return outputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOutputs(List<ItemStack> inputs) {
|
||||
return getOutputs();
|
||||
}
|
||||
|
||||
@@ -23,17 +23,15 @@ public class RegisterRecipesEvent extends Event {
|
||||
private final Consumer<RecipePureDaisy> pureDaisy;
|
||||
private final Consumer<RecipeManaInfusion> manaInfusion;
|
||||
private final Consumer<RecipeBrew> brew;
|
||||
private final Consumer<RecipeElvenTrade> elvenTrade;
|
||||
private final Consumer<RecipePetals> apothecary;
|
||||
private final Consumer<RecipeRuneAltar> runeAltar;
|
||||
|
||||
public RegisterRecipesEvent(Consumer<RecipePureDaisy> pureDaisy, Consumer<RecipeManaInfusion> manaInfusion,
|
||||
Consumer<RecipeBrew> brew, Consumer<RecipeElvenTrade> elvenTrade,
|
||||
Consumer<RecipeBrew> brew,
|
||||
Consumer<RecipePetals> apothecary, Consumer<RecipeRuneAltar> runeAltar) {
|
||||
this.pureDaisy = pureDaisy;
|
||||
this.manaInfusion = manaInfusion;
|
||||
this.brew = brew;
|
||||
this.elvenTrade = elvenTrade;
|
||||
this.apothecary = apothecary;
|
||||
this.runeAltar = runeAltar;
|
||||
}
|
||||
@@ -50,10 +48,6 @@ public class RegisterRecipesEvent extends Event {
|
||||
return brew;
|
||||
}
|
||||
|
||||
public Consumer<RecipeElvenTrade> elvenTrade() {
|
||||
return elvenTrade;
|
||||
}
|
||||
|
||||
public Consumer<RecipePetals> apothecary() {
|
||||
return apothecary;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.mana.IManaItem;
|
||||
import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
import vazkii.botania.client.core.handler.CorporeaInputHandler;
|
||||
import vazkii.botania.client.gui.crafting.ContainerCraftingHalo;
|
||||
import vazkii.botania.client.integration.jei.brewery.BreweryRecipeCategory;
|
||||
@@ -51,6 +50,8 @@ import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.ModSubtiles;
|
||||
import vazkii.botania.common.block.tile.TileAlfPortal;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.crafting.AbstractElvenTradeRecipe;
|
||||
import vazkii.botania.common.crafting.LexiconElvenTradeRecipe;
|
||||
import vazkii.botania.common.crafting.recipe.AncientWillRecipe;
|
||||
import vazkii.botania.common.crafting.recipe.CompositeLensRecipe;
|
||||
import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe;
|
||||
@@ -184,10 +185,8 @@ public class JEIBotaniaPlugin implements IModPlugin {
|
||||
@Override
|
||||
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
|
||||
IRecipeManager recipeRegistry = jeiRuntime.getRecipeManager();
|
||||
for (RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes.values()) {
|
||||
List<Ingredient> inputs = recipe.getInputs();
|
||||
List<ItemStack> outputs = recipe.getOutputs();
|
||||
if (inputs.size() == 1 && outputs.size() == 1 && recipe.containsItem(outputs.get(0)) && outputs.get(0).getItem() != ModItems.lexicon) {
|
||||
for (AbstractElvenTradeRecipe recipe : TileAlfPortal.elvenTradeRecipes(Minecraft.getInstance().world.getRecipeManager())) {
|
||||
if (recipe instanceof LexiconElvenTradeRecipe) {
|
||||
recipeRegistry.hideRecipe(recipe, ElvenTradeRecipeCategory.UID);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -31,9 +31,9 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
import vazkii.botania.client.core.handler.MiscellaneousIcons;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.crafting.AbstractElvenTradeRecipe;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -41,7 +41,7 @@ import javax.annotation.Nonnull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ElvenTradeRecipeCategory implements IRecipeCategory<RecipeElvenTrade> {
|
||||
public class ElvenTradeRecipeCategory implements IRecipeCategory<AbstractElvenTradeRecipe> {
|
||||
|
||||
public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "elven_trade");
|
||||
private final String localizedName;
|
||||
@@ -64,8 +64,8 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory<RecipeElvenTrad
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<? extends RecipeElvenTrade> getRecipeClass() {
|
||||
return RecipeElvenTrade.class;
|
||||
public Class<? extends AbstractElvenTradeRecipe> getRecipeClass() {
|
||||
return AbstractElvenTradeRecipe.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -87,7 +87,7 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory<RecipeElvenTrad
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(RecipeElvenTrade recipe, IIngredients iIngredients) {
|
||||
public void setIngredients(AbstractElvenTradeRecipe recipe, IIngredients iIngredients) {
|
||||
ImmutableList.Builder<List<ItemStack>> builder = ImmutableList.builder();
|
||||
for (Ingredient i : recipe.getInputs()) {
|
||||
builder.add(Arrays.asList(i.getMatchingStacks()));
|
||||
@@ -97,7 +97,7 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory<RecipeElvenTrad
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(RecipeElvenTrade recipe, double mouseX, double mouseY) {
|
||||
public void draw(AbstractElvenTradeRecipe recipe, double mouseX, double mouseY) {
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableBlend();
|
||||
overlay.draw(0, 4);
|
||||
@@ -121,7 +121,7 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory<RecipeElvenTrad
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipeElvenTrade recipe, @Nonnull IIngredients ingredients) {
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull AbstractElvenTradeRecipe recipe, @Nonnull IIngredients ingredients) {
|
||||
int index = 0, posX = 42;
|
||||
for (List<ItemStack> o : ingredients.getInputs(VanillaTypes.ITEM)) {
|
||||
recipeLayout.getItemStacks().init(index, true, posX, 0);
|
||||
|
||||
@@ -16,9 +16,8 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
import vazkii.botania.client.patchouli.PatchouliUtils;
|
||||
import vazkii.botania.common.crafting.AbstractElvenTradeRecipe;
|
||||
import vazkii.botania.common.crafting.ModRecipeTypes;
|
||||
import vazkii.patchouli.api.IComponentProcessor;
|
||||
import vazkii.patchouli.api.IVariableProvider;
|
||||
@@ -28,20 +27,20 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ElvenTradeProcessor implements IComponentProcessor {
|
||||
private List<RecipeElvenTrade> recipes;
|
||||
private List<AbstractElvenTradeRecipe> recipes;
|
||||
private int longestIngredientSize, mostInputs, mostOutputs;
|
||||
|
||||
@Override
|
||||
public void setup(IVariableProvider<String> variables) {
|
||||
ImmutableList.Builder<RecipeElvenTrade> builder = ImmutableList.builder();
|
||||
ImmutableList.Builder<AbstractElvenTradeRecipe> builder = ImmutableList.builder();
|
||||
for (String s : variables.get("recipes").split(";")) {
|
||||
IRecipe<?> recipe = Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.ELVEN_TRADE_TYPE).get(new ResourceLocation(s));
|
||||
if (recipe instanceof RecipeElvenTrade) {
|
||||
builder.add((RecipeElvenTrade) recipe);
|
||||
if (recipe instanceof AbstractElvenTradeRecipe) {
|
||||
builder.add((AbstractElvenTradeRecipe) recipe);
|
||||
}
|
||||
}
|
||||
recipes = builder.build();
|
||||
for (RecipeElvenTrade recipe : recipes) {
|
||||
for (AbstractElvenTradeRecipe recipe : recipes) {
|
||||
List<Ingredient> inputs = recipe.getInputs();
|
||||
for (Ingredient ingredient : inputs) {
|
||||
int length = ingredient.getMatchingStacks().length;
|
||||
@@ -76,7 +75,7 @@ public class ElvenTradeProcessor implements IComponentProcessor {
|
||||
if (key.startsWith("output")) {
|
||||
int index = Integer.parseInt(key.substring(6)) - 1;
|
||||
if (index < mostOutputs) {
|
||||
return recipes.stream().map(RecipeElvenTrade::getOutputs)
|
||||
return recipes.stream().map(AbstractElvenTradeRecipe::getOutputs)
|
||||
.map(l -> index < l.size() ? l.get(index) : ItemStack.EMPTY)
|
||||
.map(PatchouliAPI.instance::serializeItemStack).collect(Collectors.joining(","));
|
||||
} else {
|
||||
@@ -87,7 +86,7 @@ public class ElvenTradeProcessor implements IComponentProcessor {
|
||||
}
|
||||
|
||||
private String interweaveIngredients(int inputIndex) {
|
||||
List<Ingredient> recipes = this.recipes.stream().map(RecipeElvenTrade::getInputs).map(ingredients -> {
|
||||
List<Ingredient> recipes = this.recipes.stream().map(AbstractElvenTradeRecipe::getInputs).map(ingredients -> {
|
||||
if (inputIndex < ingredients.size()) {
|
||||
return ingredients.get(inputIndex);
|
||||
} else {
|
||||
|
||||
@@ -14,7 +14,6 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.RecipeManager;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
@@ -28,10 +27,8 @@ import net.minecraft.world.Explosion;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.recipe.ElvenPortalUpdateEvent;
|
||||
import vazkii.botania.api.recipe.IElvenItem;
|
||||
import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.api.state.enums.AlfPortalState;
|
||||
import vazkii.botania.client.fx.WispParticleData;
|
||||
@@ -41,6 +38,7 @@ import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.mana.BlockPool;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.crafting.AbstractElvenTradeRecipe;
|
||||
import vazkii.botania.common.crafting.ModRecipeTypes;
|
||||
import vazkii.botania.common.item.ItemLexicon;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
@@ -179,7 +177,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
|
||||
private boolean validateItemUsage(ItemEntity entity) {
|
||||
ItemStack inputStack = entity.getItem();
|
||||
for (RecipeElvenTrade recipe : elvenTradeRecipes(world.getRecipeManager())) {
|
||||
for (AbstractElvenTradeRecipe recipe : elvenTradeRecipes(world.getRecipeManager())) {
|
||||
if (recipe.containsItem(inputStack)) {
|
||||
return true;
|
||||
}
|
||||
@@ -274,16 +272,16 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<RecipeElvenTrade> elvenTradeRecipes(RecipeManager rm) {
|
||||
public static List<AbstractElvenTradeRecipe> elvenTradeRecipes(RecipeManager rm) {
|
||||
return rm.getRecipes(ModRecipeTypes.ELVEN_TRADE_TYPE).values().stream()
|
||||
.filter(r -> r instanceof RecipeElvenTrade)
|
||||
.map(r -> (RecipeElvenTrade) r)
|
||||
.filter(r -> r instanceof AbstractElvenTradeRecipe)
|
||||
.map(r -> (AbstractElvenTradeRecipe) r)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void resolveRecipes() {
|
||||
List<BlockPos> pylons = locatePylons();
|
||||
for (RecipeElvenTrade recipe : elvenTradeRecipes(world.getRecipeManager())) {
|
||||
for (AbstractElvenTradeRecipe recipe : elvenTradeRecipes(world.getRecipeManager())) {
|
||||
Optional<List<ItemStack>> match = recipe.match(stacksIn);
|
||||
if (match.isPresent()) {
|
||||
if (consumeMana(pylons, 500, false)) {
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package vazkii.botania.common.crafting;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class AbstractElvenTradeRecipe implements IRecipe<IInventory> {
|
||||
private final ResourceLocation id;
|
||||
|
||||
protected AbstractElvenTradeRecipe(ResourceLocation id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to match the recipe
|
||||
*
|
||||
* @param stacks Entire contents of the portal's buffer
|
||||
* @return {@link Optional#empty()} if recipe doesn't match, Optional with a set of items used by recipe
|
||||
* otherwise
|
||||
*/
|
||||
public abstract Optional<List<ItemStack>> match(List<ItemStack> stacks);
|
||||
|
||||
/**
|
||||
* If the recipe does not contain the item, it will be destroyed upon entering the portal.
|
||||
*/
|
||||
public abstract boolean containsItem(ItemStack stack);
|
||||
|
||||
/**
|
||||
* @return Preview of the inputs
|
||||
*/
|
||||
public abstract List<Ingredient> getInputs();
|
||||
|
||||
/**
|
||||
* @return Preview of the outputs
|
||||
*/
|
||||
public abstract List<ItemStack> getOutputs();
|
||||
|
||||
/**
|
||||
* Actually evaluate the recipe
|
||||
*/
|
||||
public abstract List<ItemStack> getOutputs(List<ItemStack> inputs);
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getIcon() {
|
||||
return new ItemStack(ModBlocks.alfPortal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ResourceLocation getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IRecipeType<?> getType() {
|
||||
return ModRecipeTypes.ELVEN_TRADE_TYPE;
|
||||
}
|
||||
|
||||
// Ignored IRecipe boilerplate
|
||||
|
||||
@Override
|
||||
public boolean matches(IInventory inv, World world) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(IInventory inv) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFit(int width, int height) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package vazkii.botania.common.crafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.item.ItemLexicon;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class LexiconElvenTradeRecipe extends AbstractElvenTradeRecipe {
|
||||
LexiconElvenTradeRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsItem(ItemStack stack) {
|
||||
return stack.getItem() == ModItems.lexicon && !ItemNBTHelper.getBoolean(stack, ItemLexicon.TAG_ELVEN_UNLOCK, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Ingredient> getInputs() {
|
||||
return Collections.singletonList(Ingredient.fromItems(ModItems.lexicon));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOutputs() {
|
||||
ItemStack stack = new ItemStack(ModItems.lexicon);
|
||||
stack.getOrCreateTag().putBoolean(ItemLexicon.TAG_ELVEN_UNLOCK, true);
|
||||
return Collections.singletonList(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<List<ItemStack>> match(List<ItemStack> stacks) {
|
||||
if (stacks.size() == 1 && stacks.get(0).getItem() == ModItems.lexicon && !ItemNBTHelper.getBoolean(stacks.get(0), ItemLexicon.TAG_ELVEN_UNLOCK, false)) {
|
||||
return Optional.of(new ArrayList<>(stacks));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOutputs(List<ItemStack> inputs) {
|
||||
ItemStack stack = inputs.get(0).copy();
|
||||
stack.getOrCreateTag().putBoolean(ItemLexicon.TAG_ELVEN_UNLOCK, true);
|
||||
return Collections.singletonList(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<LexiconElvenTradeRecipe> getSerializer() {
|
||||
return ModRecipeTypes.LEXICON_ELVEN_TRADE_SERIALIZER;
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* This class is distributed as part of the Botania Mod.
|
||||
* Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.common.crafting;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
import vazkii.botania.api.recipe.RegisterRecipesEvent;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.item.ItemLexicon;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.lib.ModTags;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
|
||||
public class ModElvenTradeRecipes {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void register(RegisterRecipesEvent evt) {
|
||||
ItemStack elvenLexicon = new ItemStack(ModItems.lexicon);
|
||||
elvenLexicon.getOrCreateTag().putBoolean(ItemLexicon.TAG_ELVEN_UNLOCK, true);
|
||||
evt.elvenTrade().accept(new RecipeLexicon(prefix("elven_lexicon"), elvenLexicon, Ingredient.fromStacks(new ItemStack(ModItems.lexicon))));
|
||||
}
|
||||
|
||||
private static class RecipeLexicon extends RecipeElvenTrade {
|
||||
RecipeLexicon(ResourceLocation id, ItemStack output, Ingredient input) {
|
||||
super(id, output, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsItem(ItemStack stack) {
|
||||
return super.containsItem(stack) && !ItemNBTHelper.getBoolean(stack, ItemLexicon.TAG_ELVEN_UNLOCK, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<List<ItemStack>> match(List<ItemStack> stacks) {
|
||||
if (stacks.size() == 1 && !ItemNBTHelper.getBoolean(stacks.get(0), ItemLexicon.TAG_ELVEN_UNLOCK, false)) {
|
||||
return super.match(stacks);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOutputs(List<ItemStack> inputs) {
|
||||
ItemStack stack = inputs.get(0).copy();
|
||||
stack.getOrCreateTag().putBoolean(ItemLexicon.TAG_ELVEN_UNLOCK, true);
|
||||
return Collections.singletonList(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package vazkii.botania.common.crafting;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.item.crafting.SpecialRecipeSerializer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
@@ -17,14 +18,16 @@ import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ModRecipeTypes {
|
||||
public static final IRecipeType<RecipeElvenTrade> ELVEN_TRADE_TYPE = new RecipeType<>();
|
||||
public static final IRecipeType<AbstractElvenTradeRecipe> ELVEN_TRADE_TYPE = new RecipeType<>();
|
||||
public static final IRecipeSerializer<RecipeElvenTrade> ELVEN_TRADE_SERIALIZER = new RecipeElvenTrade.Serializer();
|
||||
public static final SpecialRecipeSerializer<LexiconElvenTradeRecipe> LEXICON_ELVEN_TRADE_SERIALIZER = new SpecialRecipeSerializer<>(LexiconElvenTradeRecipe::new);
|
||||
|
||||
@SubscribeEvent
|
||||
public static void register(RegistryEvent.Register<IRecipeSerializer<?>> evt) {
|
||||
ResourceLocation id = prefix("elven_trade");
|
||||
Registry.register(Registry.RECIPE_TYPE, id, ELVEN_TRADE_TYPE);
|
||||
evt.getRegistry().register(ELVEN_TRADE_SERIALIZER.setRegistryName(id));
|
||||
evt.getRegistry().register(LEXICON_ELVEN_TRADE_SERIALIZER.setRegistryName(prefix("elven_trade_lexicon")));
|
||||
}
|
||||
|
||||
private static class RecipeType<T extends IRecipe<?>> implements IRecipeType<T> {
|
||||
|
||||
@@ -45,7 +45,6 @@ public class SyncHandler {
|
||||
Map<ResourceLocation, RecipePureDaisy> pureDaisy = new HashMap<>();
|
||||
Map<ResourceLocation, RecipeManaInfusion> manaInfusion = new HashMap<>();
|
||||
Map<ResourceLocation, RecipeBrew> brew = new HashMap<>();
|
||||
Map<ResourceLocation, RecipeElvenTrade> elvenTrade = new HashMap<>();
|
||||
Map<ResourceLocation, RecipePetals> apothecary = new HashMap<>();
|
||||
Map<ResourceLocation, RecipeRuneAltar> runeAltar = new HashMap<>();
|
||||
|
||||
@@ -53,7 +52,6 @@ public class SyncHandler {
|
||||
r -> pureDaisy.put(r.getId(), r),
|
||||
r -> manaInfusion.put(r.getId(), r),
|
||||
r -> brew.put(r.getId(), r),
|
||||
r -> elvenTrade.put(r.getId(), r),
|
||||
r -> apothecary.put(r.getId(), r),
|
||||
r -> runeAltar.put(r.getId(), r)
|
||||
);
|
||||
@@ -62,7 +60,6 @@ public class SyncHandler {
|
||||
BotaniaAPI.pureDaisyRecipes = ImmutableMap.copyOf(pureDaisy);
|
||||
BotaniaAPI.manaInfusionRecipes = ImmutableMap.copyOf(manaInfusion);
|
||||
BotaniaAPI.brewRecipes = ImmutableMap.copyOf(brew);
|
||||
BotaniaAPI.elvenTradeRecipes = ImmutableMap.copyOf(elvenTrade);
|
||||
BotaniaAPI.petalRecipes = ImmutableMap.copyOf(apothecary);
|
||||
BotaniaAPI.runeAltarRecipes = ImmutableMap.copyOf(runeAltar);
|
||||
PacketHandler.HANDLER.send(PacketDistributor.ALL.noArg(), syncPacket());
|
||||
@@ -70,7 +67,7 @@ public class SyncHandler {
|
||||
}
|
||||
|
||||
private static PacketSyncRecipes syncPacket() {
|
||||
return new PacketSyncRecipes(BotaniaAPI.brewRecipes, BotaniaAPI.elvenTradeRecipes, BotaniaAPI.manaInfusionRecipes,
|
||||
return new PacketSyncRecipes(BotaniaAPI.brewRecipes, BotaniaAPI.manaInfusionRecipes,
|
||||
BotaniaAPI.petalRecipes, BotaniaAPI.pureDaisyRecipes, BotaniaAPI.runeAltarRecipes);
|
||||
}
|
||||
|
||||
@@ -79,7 +76,6 @@ public class SyncHandler {
|
||||
@SubscribeEvent
|
||||
public static void clientLogout(ClientPlayerNetworkEvent.LoggedOutEvent evt) {
|
||||
BotaniaAPI.brewRecipes = Collections.emptyMap();
|
||||
BotaniaAPI.elvenTradeRecipes = Collections.emptyMap();
|
||||
BotaniaAPI.manaInfusionRecipes = Collections.emptyMap();
|
||||
BotaniaAPI.petalRecipes = Collections.emptyMap();
|
||||
BotaniaAPI.pureDaisyRecipes = Collections.emptyMap();
|
||||
|
||||
@@ -29,15 +29,13 @@ import java.util.stream.Stream;
|
||||
|
||||
public class PacketSyncRecipes {
|
||||
private Map<ResourceLocation, RecipeBrew> brew;
|
||||
private Map<ResourceLocation, RecipeElvenTrade> elven;
|
||||
private Map<ResourceLocation, RecipeManaInfusion> manaInfusion;
|
||||
private Map<ResourceLocation, RecipePetals> petal;
|
||||
private Map<ResourceLocation, RecipePureDaisy> pureDaisy;
|
||||
private Map<ResourceLocation, RecipeRuneAltar> runeAltar;
|
||||
|
||||
public PacketSyncRecipes(Map<ResourceLocation, RecipeBrew> brew, Map<ResourceLocation, RecipeElvenTrade> elven, Map<ResourceLocation, RecipeManaInfusion> manaInfusion, Map<ResourceLocation, RecipePetals> petal, Map<ResourceLocation, RecipePureDaisy> pureDaisy, Map<ResourceLocation, RecipeRuneAltar> runeAltar) {
|
||||
public PacketSyncRecipes(Map<ResourceLocation, RecipeBrew> brew, Map<ResourceLocation, RecipeManaInfusion> manaInfusion, Map<ResourceLocation, RecipePetals> petal, Map<ResourceLocation, RecipePureDaisy> pureDaisy, Map<ResourceLocation, RecipeRuneAltar> runeAltar) {
|
||||
this.brew = brew;
|
||||
this.elven = elven;
|
||||
this.manaInfusion = manaInfusion;
|
||||
this.petal = petal;
|
||||
this.pureDaisy = pureDaisy;
|
||||
@@ -72,7 +70,6 @@ public class PacketSyncRecipes {
|
||||
Map<ResourceLocation, RecipeBrew> brew = Stream.generate(() -> RecipeBrew.read(buf))
|
||||
.limit(brewCount)
|
||||
.collect(Collectors.toMap(RecipeBrew::getId, r -> r));
|
||||
Map<ResourceLocation, RecipeElvenTrade> elven = Collections.emptyMap();
|
||||
int manaInfusionCount = buf.readVarInt();
|
||||
Map<ResourceLocation, RecipeManaInfusion> manaInfusion = Stream.generate(() -> RecipeManaInfusion.read(buf))
|
||||
.limit(manaInfusionCount)
|
||||
@@ -89,7 +86,7 @@ public class PacketSyncRecipes {
|
||||
Map<ResourceLocation, RecipeRuneAltar> rune = Stream.generate(() -> RecipeRuneAltar.read(buf))
|
||||
.limit(runeCount)
|
||||
.collect(Collectors.toMap(RecipeRuneAltar::getId, r -> r));
|
||||
return new PacketSyncRecipes(brew, elven, manaInfusion, petal, pureDaisy, rune);
|
||||
return new PacketSyncRecipes(brew, manaInfusion, petal, pureDaisy, rune);
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
@@ -99,7 +96,6 @@ public class PacketSyncRecipes {
|
||||
return;
|
||||
}
|
||||
BotaniaAPI.brewRecipes = brew;
|
||||
BotaniaAPI.elvenTradeRecipes = elven;
|
||||
BotaniaAPI.manaInfusionRecipes = manaInfusion;
|
||||
BotaniaAPI.petalRecipes = petal;
|
||||
BotaniaAPI.pureDaisyRecipes = pureDaisy;
|
||||
@@ -115,7 +111,7 @@ public class PacketSyncRecipes {
|
||||
private int loginIndex;
|
||||
|
||||
public Login() {
|
||||
this(new PacketSyncRecipes(BotaniaAPI.brewRecipes, BotaniaAPI.elvenTradeRecipes,
|
||||
this(new PacketSyncRecipes(BotaniaAPI.brewRecipes,
|
||||
BotaniaAPI.manaInfusionRecipes, BotaniaAPI.petalRecipes,
|
||||
BotaniaAPI.pureDaisyRecipes, BotaniaAPI.runeAltarRecipes));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package vazkii.botania.data;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.data.CustomRecipeBuilder;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.data.RecipeProvider;
|
||||
@@ -17,6 +18,7 @@ import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.crafting.ModRecipeTypes;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.lib.ModTags;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -54,6 +56,8 @@ public class ElvenTradeProvider extends RecipeProvider {
|
||||
consumer.accept(new FinishedRecipe(id("ender_pearl_return"), new ItemStack(Items.ENDER_PEARL), Ingredient.fromItems(Items.ENDER_PEARL)));
|
||||
consumer.accept(new FinishedRecipe(id("diamond_return"), new ItemStack(Items.DIAMOND), Ingredient.fromItems(Items.DIAMOND)));
|
||||
consumer.accept(new FinishedRecipe(id("diamond_block_return"), new ItemStack(Blocks.DIAMOND_BLOCK), Ingredient.fromItems(Blocks.DIAMOND_BLOCK)));
|
||||
|
||||
CustomRecipeBuilder.func_218656_a(ModRecipeTypes.LEXICON_ELVEN_TRADE_SERIALIZER).build(consumer, id("lexicon_elven").toString());
|
||||
}
|
||||
|
||||
private static ResourceLocation id(String path) {
|
||||
@@ -100,7 +104,8 @@ public class ElvenTradeProvider extends RecipeProvider {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override public IRecipeSerializer<?> getSerializer() {
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
return ModRecipeTypes.ELVEN_TRADE_SERIALIZER;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user