Recipe system cleanup. (#6014)

This commit is contained in:
LexManos authored and David Quintana committed 2019-08-29 03:18:41 +02:00
1 parent 3e9bc3c434
commit e784a7f606
38 files changed
+1675 -194

No files matched your search

@@ -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.debug;
import java.util.function.Consumer;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementRewards;
import net.minecraft.advancements.FrameType;
import net.minecraft.block.Blocks;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.data.RecipeProvider;
import net.minecraft.data.ShapedRecipeBuilder;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.crafting.ConditionalAdvancement;
import net.minecraftforge.common.crafting.ConditionalRecipe;
import net.minecraftforge.common.crafting.conditions.IConditionBuilder;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
@Mod("data_gen_test")
@Mod.EventBusSubscriber(bus = Bus.MOD)
public class DataGeneratorTest
{
@SubscribeEvent
public static void gatherData(GatherDataEvent event)
{
DataGenerator gen = event.getGenerator();
if (event.includeServer())
{
gen.addProvider(new Recipes(gen));
}
}
public static class Recipes extends RecipeProvider implements IConditionBuilder
{
public Recipes(DataGenerator gen)
{
super(gen);
}
protected void registerRecipes(Consumer<IFinishedRecipe> consumer)
{
ResourceLocation ID = new ResourceLocation("data_gen_test", "conditional");
ConditionalRecipe.builder()
.addCondition(
and(
not(modLoaded("minecraft")),
itemExists("minecraft", "dirt"),
FALSE()
)
)
.addRecipe(
ShapedRecipeBuilder.shapedRecipe(Blocks.DIAMOND_BLOCK, 64)
.patternLine("XXX")
.patternLine("XXX")
.patternLine("XXX")
.key('X', Blocks.DIRT)
.setGroup("")
.addCriterion("has_dirt", hasItem(Blocks.DIRT)) //Doesn't actually print... TODO: nested/conditional advancements?
::build
)
.setAdvancement(ID,
ConditionalAdvancement.builder()
.addCondition(
and(
not(modLoaded("minecraft")),
itemExists("minecraft", "dirt"),
FALSE()
)
)
.addAdvancement(
Advancement.Builder.builder()
.withParentId(new ResourceLocation("minecraft", "root"))
.withDisplay(Blocks.DIAMOND_BLOCK,
new StringTextComponent("Dirt2Diamonds"),
new StringTextComponent("The BEST crafting recipe in the game!"),
null, FrameType.TASK, false, false, false
)
.withRewards(AdvancementRewards.Builder.recipe(ID))
.withCriterion("has_dirt", hasItem(Blocks.DIRT))
)
)
.build(consumer, ID);
}
}
}
@@ -54,7 +54,7 @@ import net.minecraftforge.fml.common.Mod;
public class PistonEventTest
{
public static final String MODID = "pistoneventtest";
public static final String MODID = "piston_event_test";
private static Block shiftOnMove = new BlockShiftOnMove();
@@ -151,4 +151,4 @@ public class PistonEventTest
}
}
}