pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -1,32 +1,28 @@
|
||||
package appeng.forge.data;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.forge.data.providers.loot.BlockDropProvider;
|
||||
import appeng.forge.data.providers.recipes.QuartzToolRecipes;
|
||||
import appeng.forge.data.providers.recipes.SlabStairRecipes;
|
||||
import appeng.forge.data.providers.recipes.SpecialRecipes;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = AppEng.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class AE2DataGenerators {
|
||||
|
||||
@Mod.EventBusSubscriber( modid = AppEng.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD )
|
||||
public class AE2DataGenerators
|
||||
{
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onGatherData( GatherDataEvent dataEvent )
|
||||
{
|
||||
DataGenerator generator = dataEvent.getGenerator();
|
||||
if( dataEvent.includeServer() )
|
||||
{
|
||||
generator.addProvider( new BlockDropProvider( dataEvent ) );
|
||||
generator.addProvider( new SlabStairRecipes( generator ) );
|
||||
generator.addProvider( new QuartzToolRecipes( generator ) );
|
||||
generator.addProvider( new SpecialRecipes( generator ) );
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void onGatherData(GatherDataEvent dataEvent) {
|
||||
DataGenerator generator = dataEvent.getGenerator();
|
||||
if (dataEvent.includeServer()) {
|
||||
generator.addProvider(new BlockDropProvider(dataEvent));
|
||||
generator.addProvider(new SlabStairRecipes(generator));
|
||||
generator.addProvider(new QuartzToolRecipes(generator));
|
||||
generator.addProvider(new SpecialRecipes(generator));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package appeng.forge.data.providers;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.core.AppEng;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import net.minecraft.data.IDataProvider;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.storage.loot.LootParameterSet;
|
||||
@@ -14,13 +13,14 @@ import net.minecraft.world.storage.loot.LootParameterSets;
|
||||
import net.minecraft.world.storage.loot.LootTable;
|
||||
import net.minecraft.world.storage.loot.LootTableManager;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.nio.file.Path;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
public interface IAE2DataProvider extends IDataProvider
|
||||
{
|
||||
IBlocks BLOCKS = AEApi.instance().definitions().blocks();
|
||||
IItems ITEMS = AEApi.instance().definitions().items();
|
||||
IMaterials MATERIALS = AEApi.instance().definitions().materials();
|
||||
public interface IAE2DataProvider extends IDataProvider {
|
||||
IBlocks BLOCKS = AEApi.instance().definitions().blocks();
|
||||
IItems ITEMS = AEApi.instance().definitions().items();
|
||||
IMaterials MATERIALS = AEApi.instance().definitions().materials();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package appeng.forge.data.providers.loot;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.forge.data.providers.IAE2DataProvider;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.DirectoryCache;
|
||||
import net.minecraft.data.IDataProvider;
|
||||
@@ -20,98 +25,71 @@ import net.minecraft.world.storage.loot.functions.SetCount;
|
||||
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.forge.data.providers.IAE2DataProvider;
|
||||
|
||||
public class BlockDropProvider extends BlockLootTables implements IAE2DataProvider {
|
||||
private Map<Block, Function<Block, LootTable.Builder>> overrides = ImmutableMap.<Block, Function<Block, LootTable.Builder>>builder()
|
||||
.put(BLOCKS.matrixFrame().block(), $ -> LootTable.builder())
|
||||
.put(BLOCKS.quartzOre().block(),
|
||||
b -> droppingWithSilkTouch(BLOCKS.quartzOre().block(),
|
||||
withExplosionDecay(BLOCKS.quartzOre().block(),
|
||||
ItemLootEntry.builder(MATERIALS.certusQuartzCrystal().item())
|
||||
.acceptFunction(SetCount.builder(RandomValueRange.of(1.0F, 2.0F)))
|
||||
.acceptFunction(ApplyBonus.uniformBonusCount(Enchantments.FORTUNE)))))
|
||||
.put(BLOCKS.quartzOreCharged().block(),
|
||||
b -> droppingWithSilkTouch(BLOCKS.quartzOreCharged().block(),
|
||||
withExplosionDecay(BLOCKS.quartzOreCharged().block(),
|
||||
ItemLootEntry.builder(MATERIALS.certusQuartzCrystalCharged().item())
|
||||
.acceptFunction(SetCount.builder(RandomValueRange.of(1.0F, 2.0F)))
|
||||
.acceptFunction(ApplyBonus.uniformBonusCount(Enchantments.FORTUNE)))))
|
||||
.build();
|
||||
|
||||
public class BlockDropProvider extends BlockLootTables implements IAE2DataProvider
|
||||
{
|
||||
private Map<Block, Function<Block, LootTable.Builder>> overrides = ImmutableMap.<Block, Function<Block, LootTable.Builder>>builder()
|
||||
.put( BLOCKS.matrixFrame().block(), $ -> LootTable.builder() )
|
||||
.put( BLOCKS.quartzOre().block(), b ->
|
||||
droppingWithSilkTouch(BLOCKS.quartzOre().block(),
|
||||
withExplosionDecay(
|
||||
BLOCKS.quartzOre().block(),
|
||||
ItemLootEntry.builder(MATERIALS.certusQuartzCrystal().item())
|
||||
.acceptFunction(SetCount.builder(RandomValueRange.of(1.0F, 2.0F)))
|
||||
.acceptFunction(ApplyBonus.uniformBonusCount(Enchantments.FORTUNE))
|
||||
)
|
||||
)
|
||||
)
|
||||
.put( BLOCKS.quartzOreCharged().block(), b ->
|
||||
droppingWithSilkTouch(BLOCKS.quartzOreCharged().block(),
|
||||
withExplosionDecay(
|
||||
BLOCKS.quartzOreCharged().block(),
|
||||
ItemLootEntry.builder(MATERIALS.certusQuartzCrystalCharged().item())
|
||||
.acceptFunction(SetCount.builder(RandomValueRange.of(1.0F, 2.0F)))
|
||||
.acceptFunction(ApplyBonus.uniformBonusCount(Enchantments.FORTUNE))
|
||||
)
|
||||
)
|
||||
)
|
||||
.build();
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private final Path outputFolder;
|
||||
|
||||
private final Path outputFolder;
|
||||
public BlockDropProvider(GatherDataEvent dataEvent) {
|
||||
outputFolder = dataEvent.getGenerator().getOutputFolder();
|
||||
}
|
||||
|
||||
public BlockDropProvider( GatherDataEvent dataEvent )
|
||||
{
|
||||
outputFolder = dataEvent.getGenerator().getOutputFolder();
|
||||
}
|
||||
@Override
|
||||
public void act(@Nonnull DirectoryCache cache) throws IOException {
|
||||
for (Map.Entry<ResourceLocation, Block> entry : ForgeRegistries.BLOCKS.getEntries()) {
|
||||
LootTable.Builder builder;
|
||||
if (entry.getKey().getNamespace().equals(AppEng.MOD_ID)) {
|
||||
builder = overrides.getOrDefault(entry.getValue(), this::defaultBuilder).apply(entry.getValue());
|
||||
|
||||
@Override
|
||||
public void act( @Nonnull DirectoryCache cache ) throws IOException
|
||||
{
|
||||
for( Map.Entry<ResourceLocation, Block> entry : ForgeRegistries.BLOCKS.getEntries() )
|
||||
{
|
||||
LootTable.Builder builder;
|
||||
if( entry.getKey().getNamespace().equals( AppEng.MOD_ID ) )
|
||||
{
|
||||
builder = overrides.getOrDefault( entry.getValue(), this::defaultBuilder )
|
||||
.apply( entry.getValue() );
|
||||
IDataProvider.save(GSON, cache, toJson(builder), getPath(outputFolder, entry.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IDataProvider.save( GSON, cache, toJson( builder ), getPath( outputFolder, entry.getKey() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
private LootTable.Builder defaultBuilder(Block block) {
|
||||
LootEntry.Builder<?> entry = ItemLootEntry.builder(block);
|
||||
LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry)
|
||||
.acceptCondition(SurvivesExplosion.builder());
|
||||
|
||||
private LootTable.Builder defaultBuilder( Block block )
|
||||
{
|
||||
LootEntry.Builder<?> entry = ItemLootEntry.builder( block );
|
||||
LootPool.Builder pool = LootPool.builder()
|
||||
.name( "main" )
|
||||
.rolls( ConstantRange.of( 1 ) )
|
||||
.addEntry( entry )
|
||||
.acceptCondition( SurvivesExplosion.builder() );
|
||||
return LootTable.builder().addLootPool(pool);
|
||||
}
|
||||
|
||||
return LootTable.builder()
|
||||
.addLootPool( pool );
|
||||
}
|
||||
private Path getPath(Path root, ResourceLocation id) {
|
||||
return root.resolve("data/" + id.getNamespace() + "/loot_tables/blocks/" + id.getPath() + ".json");
|
||||
}
|
||||
|
||||
private Path getPath( Path root, ResourceLocation id )
|
||||
{
|
||||
return root.resolve( "data/" + id.getNamespace() + "/loot_tables/blocks/" + id.getPath() + ".json" );
|
||||
}
|
||||
public JsonElement toJson(LootTable.Builder builder) {
|
||||
return LootTableManager.toJson(finishBuilding(builder));
|
||||
}
|
||||
|
||||
public JsonElement toJson( LootTable.Builder builder )
|
||||
{
|
||||
return LootTableManager.toJson( finishBuilding( builder ) );
|
||||
}
|
||||
@Nonnull
|
||||
public LootTable finishBuilding(LootTable.Builder builder) {
|
||||
return builder.setParameterSet(LootParameterSets.BLOCK).build();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public LootTable finishBuilding( LootTable.Builder builder )
|
||||
{
|
||||
return builder.setParameterSet( LootParameterSets.BLOCK ).build();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return AppEng.MOD_NAME + " Block Drops";
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return AppEng.MOD_NAME + " Block Drops";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package appeng.forge.data.providers.recipes;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.forge.data.providers.IAE2DataProvider;
|
||||
import appeng.recipes.conditions.FeaturesEnabled;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import it.unimi.dsi.fastutil.chars.Char2ObjectArrayMap;
|
||||
import it.unimi.dsi.fastutil.chars.Char2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.chars.CharOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.chars.CharSet;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.data.RecipeProvider;
|
||||
@@ -19,119 +16,70 @@ import net.minecraft.tags.Tag;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import net.minecraftforge.common.crafting.ConditionalRecipe;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import it.unimi.dsi.fastutil.chars.Char2ObjectArrayMap;
|
||||
import it.unimi.dsi.fastutil.chars.Char2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.chars.CharOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.chars.CharSet;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.forge.data.providers.IAE2DataProvider;
|
||||
import appeng.recipes.conditions.FeaturesEnabled;
|
||||
|
||||
public class QuartzToolRecipes extends RecipeProvider implements IAE2DataProvider
|
||||
{
|
||||
public class QuartzToolRecipes extends RecipeProvider implements IAE2DataProvider {
|
||||
|
||||
private Map<net.minecraft.tags.Tag<Item>, IItemDefinition[]> items = ImmutableMap.of(
|
||||
Tags.Items.GEMS_QUARTZ,
|
||||
new IItemDefinition[] {
|
||||
ITEMS.netherQuartzAxe(),
|
||||
ITEMS.netherQuartzHoe(),
|
||||
ITEMS.netherQuartzShovel(),
|
||||
ITEMS.netherQuartzPick(),
|
||||
ITEMS.netherQuartzSword(),
|
||||
ITEMS.netherQuartzWrench(),
|
||||
ITEMS.netherQuartzKnife()
|
||||
}
|
||||
// FIXME certus quartz
|
||||
);
|
||||
private Map<net.minecraft.tags.Tag<Item>, IItemDefinition[]> items = ImmutableMap.of(Tags.Items.GEMS_QUARTZ,
|
||||
new IItemDefinition[] { ITEMS.netherQuartzAxe(), ITEMS.netherQuartzHoe(), ITEMS.netherQuartzShovel(),
|
||||
ITEMS.netherQuartzPick(), ITEMS.netherQuartzSword(), ITEMS.netherQuartzWrench(),
|
||||
ITEMS.netherQuartzKnife() }
|
||||
// FIXME certus quartz
|
||||
);
|
||||
|
||||
private String[][] patterns = {
|
||||
{
|
||||
"XX ",
|
||||
"X/ ",
|
||||
" / "
|
||||
},
|
||||
{
|
||||
"XX ",
|
||||
" / ",
|
||||
" / "
|
||||
},
|
||||
{
|
||||
" X ",
|
||||
" / ",
|
||||
" / "
|
||||
},
|
||||
{
|
||||
"XXX",
|
||||
" / ",
|
||||
" / "
|
||||
},
|
||||
{
|
||||
" X ",
|
||||
" X ",
|
||||
" / "
|
||||
},
|
||||
{
|
||||
"X X",
|
||||
" X ",
|
||||
"X X"
|
||||
},
|
||||
{
|
||||
" /",
|
||||
"I/ ",
|
||||
"XX "
|
||||
}
|
||||
};
|
||||
private String[][] patterns = { { "XX ", "X/ ", " / " }, { "XX ", " / ", " / " }, { " X ", " / ", " / " },
|
||||
{ "XXX", " / ", " / " }, { " X ", " X ", " / " }, { "X X", " X ", "X X" }, { " /", "I/ ", "XX " } };
|
||||
|
||||
private Char2ObjectMap<Tag<Item>> keys = new Char2ObjectArrayMap<>(
|
||||
new char[] { 'I', '/' },
|
||||
new Tag[] { Tags.Items.INGOTS_IRON, Tags.Items.RODS_WOODEN }
|
||||
);
|
||||
private Char2ObjectMap<Tag<Item>> keys = new Char2ObjectArrayMap<>(new char[] { 'I', '/' },
|
||||
new Tag[] { Tags.Items.INGOTS_IRON, Tags.Items.RODS_WOODEN });
|
||||
|
||||
public QuartzToolRecipes( DataGenerator generatorIn )
|
||||
{
|
||||
super( generatorIn );
|
||||
}
|
||||
public QuartzToolRecipes(DataGenerator generatorIn) {
|
||||
super(generatorIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRecipes( @Nonnull Consumer<IFinishedRecipe> consumer )
|
||||
{
|
||||
for( Map.Entry<Tag<Item>, IItemDefinition[]> entry : items.entrySet() )
|
||||
{
|
||||
Tag<Item> tag = entry.getKey();
|
||||
IItemDefinition[] tools = entry.getValue();
|
||||
@Override
|
||||
protected void registerRecipes(@Nonnull Consumer<IFinishedRecipe> consumer) {
|
||||
for (Map.Entry<Tag<Item>, IItemDefinition[]> entry : items.entrySet()) {
|
||||
Tag<Item> tag = entry.getKey();
|
||||
IItemDefinition[] tools = entry.getValue();
|
||||
|
||||
for( int i = 0; i < tools.length; i++ )
|
||||
{
|
||||
CharSet keySet = new CharOpenHashSet( new char[] { 'X', ' ' } );
|
||||
for (int i = 0; i < tools.length; i++) {
|
||||
CharSet keySet = new CharOpenHashSet(new char[] { 'X', ' ' });
|
||||
|
||||
ShapedRecipeBuilder shapedBuilder = ShapedRecipeBuilder.shapedRecipe( tools[i].item() );
|
||||
for( String s : patterns[i] )
|
||||
{
|
||||
shapedBuilder.patternLine( s );
|
||||
ShapedRecipeBuilder shapedBuilder = ShapedRecipeBuilder.shapedRecipe(tools[i].item());
|
||||
for (String s : patterns[i]) {
|
||||
shapedBuilder.patternLine(s);
|
||||
|
||||
for( int j = 0; j < s.length(); j++ )
|
||||
{
|
||||
char c = s.charAt( j );
|
||||
if( !keySet.contains( c ) )
|
||||
{
|
||||
keySet.add( c );
|
||||
shapedBuilder.key( c, keys.get( c ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < s.length(); j++) {
|
||||
char c = s.charAt(j);
|
||||
if (!keySet.contains(c)) {
|
||||
keySet.add(c);
|
||||
shapedBuilder.key(c, keys.get(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shapedBuilder.key( 'X', tag )
|
||||
.addCriterion( "has_" + tag.getId(), hasItem( tag ) );
|
||||
shapedBuilder.key('X', tag).addCriterion("has_" + tag.getId(), hasItem(tag));
|
||||
|
||||
ConditionalRecipe.builder()
|
||||
.addCondition( new FeaturesEnabled( tools[i].features() ) )
|
||||
.addRecipe( shapedBuilder::build )
|
||||
.build( consumer, AppEng.MOD_ID, "tools/" + tools[i].identifier() );
|
||||
}
|
||||
ConditionalRecipe.builder().addCondition(new FeaturesEnabled(tools[i].features()))
|
||||
.addRecipe(shapedBuilder::build)
|
||||
.build(consumer, AppEng.MOD_ID, "tools/" + tools[i].identifier());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public String getName()
|
||||
{
|
||||
return AppEng.MOD_NAME + " Quartz Tools";
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return AppEng.MOD_NAME + " Quartz Tools";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,117 +1,92 @@
|
||||
package appeng.forge.data.providers.recipes;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.forge.data.providers.IAE2DataProvider;
|
||||
import appeng.recipes.conditions.FeaturesEnabled;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.*;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.ConditionalRecipe;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Consumer;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.forge.data.providers.IAE2DataProvider;
|
||||
import appeng.recipes.conditions.FeaturesEnabled;
|
||||
|
||||
public class SlabStairRecipes extends RecipeProvider implements IAE2DataProvider {
|
||||
|
||||
public class SlabStairRecipes extends RecipeProvider implements IAE2DataProvider
|
||||
{
|
||||
IBlockDefinition[][] blocks = { { BLOCKS.skyStoneBlock(), BLOCKS.skyStoneSlab(), BLOCKS.skyStoneStairs() },
|
||||
{ BLOCKS.smoothSkyStoneBlock(), BLOCKS.smoothSkyStoneSlab(), BLOCKS.smoothSkyStoneStairs() },
|
||||
{ BLOCKS.skyStoneBrick(), BLOCKS.skyStoneBrickSlab(), BLOCKS.skyStoneBrickStairs() },
|
||||
{ BLOCKS.skyStoneSmallBrick(), BLOCKS.skyStoneSmallBrickSlab(), BLOCKS.skyStoneSmallBrickStairs() },
|
||||
{ BLOCKS.fluixBlock(), BLOCKS.fluixSlab(), BLOCKS.fluixStairs() },
|
||||
{ BLOCKS.quartzBlock(), BLOCKS.quartzSlab(), BLOCKS.quartzStairs() },
|
||||
{ BLOCKS.chiseledQuartzBlock(), BLOCKS.chiseledQuartzSlab(), BLOCKS.chiseledQuartzStairs() },
|
||||
{ BLOCKS.quartzPillar(), BLOCKS.quartzPillarSlab(), BLOCKS.quartzPillarStairs() }, };
|
||||
|
||||
IBlockDefinition[][] blocks = {
|
||||
{ BLOCKS.skyStoneBlock(), BLOCKS.skyStoneSlab(), BLOCKS.skyStoneStairs() },
|
||||
{ BLOCKS.smoothSkyStoneBlock(), BLOCKS.smoothSkyStoneSlab(), BLOCKS.smoothSkyStoneStairs() },
|
||||
{ BLOCKS.skyStoneBrick(), BLOCKS.skyStoneBrickSlab(), BLOCKS.skyStoneBrickStairs() },
|
||||
{ BLOCKS.skyStoneSmallBrick(), BLOCKS.skyStoneSmallBrickSlab(), BLOCKS.skyStoneSmallBrickStairs() },
|
||||
{ BLOCKS.fluixBlock(), BLOCKS.fluixSlab(), BLOCKS.fluixStairs() },
|
||||
{ BLOCKS.quartzBlock(), BLOCKS.quartzSlab(), BLOCKS.quartzStairs() },
|
||||
{ BLOCKS.chiseledQuartzBlock(), BLOCKS.chiseledQuartzSlab(), BLOCKS.chiseledQuartzStairs() },
|
||||
{ BLOCKS.quartzPillar(), BLOCKS.quartzPillarSlab(), BLOCKS.quartzPillarStairs() },
|
||||
};
|
||||
public SlabStairRecipes(DataGenerator generatorIn) {
|
||||
super(generatorIn);
|
||||
}
|
||||
|
||||
public SlabStairRecipes( DataGenerator generatorIn )
|
||||
{
|
||||
super( generatorIn );
|
||||
}
|
||||
@Override
|
||||
public void registerRecipes(@Nonnull Consumer<IFinishedRecipe> consumer) {
|
||||
for (IBlockDefinition[] block : blocks) {
|
||||
slabRecipe(consumer, block[0], block[1]);
|
||||
stairRecipe(consumer, block[0], block[2]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes( @Nonnull Consumer<IFinishedRecipe> consumer )
|
||||
{
|
||||
for( IBlockDefinition[] block : blocks )
|
||||
{
|
||||
slabRecipe( consumer, block[0], block[1] );
|
||||
stairRecipe( consumer, block[0], block[2] );
|
||||
}
|
||||
}
|
||||
private void slabRecipe(Consumer<IFinishedRecipe> consumer, IBlockDefinition block, IBlockDefinition slabs) {
|
||||
Block inputBlock = block.block();
|
||||
Block outputBlock = slabs.block();
|
||||
|
||||
private void slabRecipe( Consumer<IFinishedRecipe> consumer, IBlockDefinition block, IBlockDefinition slabs )
|
||||
{
|
||||
Block inputBlock = block.block();
|
||||
Block outputBlock = slabs.block();
|
||||
FeaturesEnabled condition = new FeaturesEnabled(Sets.union(block.features(), slabs.features()));
|
||||
ConditionalRecipe.builder().addCondition(condition)
|
||||
.addRecipe(ShapedRecipeBuilder.shapedRecipe(slabs.block(), 6).patternLine("###").key('#', inputBlock)
|
||||
.addCriterion(criterionName(block), hasItem(inputBlock))::build)
|
||||
.build(consumer, AppEng.MOD_ID, "slabs/" + block.identifier());
|
||||
|
||||
FeaturesEnabled condition = new FeaturesEnabled( Sets.union( block.features(), slabs.features() ) );
|
||||
ConditionalRecipe.builder()
|
||||
.addCondition( condition )
|
||||
.addRecipe(
|
||||
ShapedRecipeBuilder.shapedRecipe( slabs.block(), 6 )
|
||||
.patternLine( "###" )
|
||||
.key( '#', inputBlock )
|
||||
.addCriterion( criterionName( block ), hasItem( inputBlock ) )
|
||||
::build
|
||||
)
|
||||
.build( consumer, AppEng.MOD_ID, "slabs/" + block.identifier() );
|
||||
ConditionalRecipe.builder().addCondition(condition)
|
||||
.addRecipe(c -> SingleItemRecipeBuilder
|
||||
.stonecuttingRecipe(Ingredient.fromItems(inputBlock), outputBlock, 2)
|
||||
.addCriterion(criterionName(block), hasItem(inputBlock))
|
||||
.build(c, new ResourceLocation(AppEng.MOD_ID, slabs.identifier())))
|
||||
.build(consumer, AppEng.MOD_ID, "slabs/block_cutter/" + block.identifier());
|
||||
|
||||
ConditionalRecipe.builder()
|
||||
.addCondition( condition )
|
||||
.addRecipe(
|
||||
c -> SingleItemRecipeBuilder.stonecuttingRecipe( Ingredient.fromItems( inputBlock ), outputBlock, 2 )
|
||||
.addCriterion( criterionName( block ), hasItem( inputBlock ) )
|
||||
.build( c, new ResourceLocation( AppEng.MOD_ID, slabs.identifier() ) )
|
||||
)
|
||||
.build( consumer, AppEng.MOD_ID, "slabs/block_cutter/" + block.identifier() );
|
||||
}
|
||||
|
||||
}
|
||||
private void stairRecipe(Consumer<IFinishedRecipe> consumer, IBlockDefinition block, IBlockDefinition stairs) {
|
||||
Block inputBlock = block.block();
|
||||
Block outputBlock = stairs.block();
|
||||
|
||||
private void stairRecipe( Consumer<IFinishedRecipe> consumer, IBlockDefinition block, IBlockDefinition stairs )
|
||||
{
|
||||
Block inputBlock = block.block();
|
||||
Block outputBlock = stairs.block();
|
||||
FeaturesEnabled condition = new FeaturesEnabled(Sets.union(block.features(), stairs.features()));
|
||||
ConditionalRecipe.builder().addCondition(condition)
|
||||
.addRecipe(ShapedRecipeBuilder.shapedRecipe(outputBlock, 4).patternLine("# ").patternLine("## ")
|
||||
.patternLine("###").key('#', inputBlock)
|
||||
.addCriterion(criterionName(block), hasItem(inputBlock))::build)
|
||||
.build(consumer, AppEng.MOD_ID, "stairs/" + block.identifier());
|
||||
|
||||
FeaturesEnabled condition = new FeaturesEnabled( Sets.union( block.features(), stairs.features() ) );
|
||||
ConditionalRecipe.builder()
|
||||
.addCondition( condition )
|
||||
.addRecipe(
|
||||
ShapedRecipeBuilder.shapedRecipe( outputBlock, 4 )
|
||||
.patternLine( "# " )
|
||||
.patternLine( "## " )
|
||||
.patternLine( "###" )
|
||||
.key( '#', inputBlock )
|
||||
.addCriterion( criterionName( block ), hasItem( inputBlock ) )
|
||||
::build
|
||||
)
|
||||
.build( consumer, AppEng.MOD_ID, "stairs/" + block.identifier() );
|
||||
ConditionalRecipe.builder().addCondition(condition)
|
||||
.addRecipe(
|
||||
c -> SingleItemRecipeBuilder.stonecuttingRecipe(Ingredient.fromItems(inputBlock), outputBlock)
|
||||
.addCriterion(criterionName(block), hasItem(inputBlock))
|
||||
.build(c, new ResourceLocation(AppEng.MOD_ID, stairs.identifier())))
|
||||
.build(consumer, AppEng.MOD_ID, "stairs/block_cutter/" + block.identifier());
|
||||
|
||||
ConditionalRecipe.builder()
|
||||
.addCondition( condition )
|
||||
.addRecipe(
|
||||
c -> SingleItemRecipeBuilder.stonecuttingRecipe( Ingredient.fromItems( inputBlock ), outputBlock )
|
||||
.addCriterion( criterionName( block ), hasItem( inputBlock ) )
|
||||
.build( c, new ResourceLocation( AppEng.MOD_ID, stairs.identifier() ) )
|
||||
)
|
||||
.build( consumer, AppEng.MOD_ID, "stairs/block_cutter/" + block.identifier() );
|
||||
}
|
||||
|
||||
}
|
||||
private String criterionName(IBlockDefinition block) {
|
||||
return String.format("has_%s", block.identifier());
|
||||
}
|
||||
|
||||
private String criterionName( IBlockDefinition block )
|
||||
{
|
||||
return String.format( "has_%s", block.identifier() );
|
||||
}
|
||||
|
||||
@Override public String getName()
|
||||
{
|
||||
return AppEng.MOD_NAME + " Slabs and Stairs";
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return AppEng.MOD_NAME + " Slabs and Stairs";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,32 +1,30 @@
|
||||
package appeng.forge.data.providers.recipes;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.forge.data.providers.IAE2DataProvider;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.data.RecipeProvider;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.forge.data.providers.IAE2DataProvider;
|
||||
|
||||
public class SpecialRecipes extends RecipeProvider implements IAE2DataProvider {
|
||||
|
||||
public class SpecialRecipes extends RecipeProvider implements IAE2DataProvider
|
||||
{
|
||||
public SpecialRecipes(DataGenerator generatorIn) {
|
||||
super(generatorIn);
|
||||
}
|
||||
|
||||
public SpecialRecipes( DataGenerator generatorIn )
|
||||
{
|
||||
super( generatorIn );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRecipes( @Nonnull Consumer<IFinishedRecipe> consumer )
|
||||
{
|
||||
@Override
|
||||
protected void registerRecipes(@Nonnull Consumer<IFinishedRecipe> consumer) {
|
||||
// ConditionalRecipe.builder() FIXME this works, but NPEs at runtime
|
||||
// .addCondition( new FeaturesEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING ) )
|
||||
// .addRecipe( new FinishedRecipe( DisassembleRecipe.SERIALIZER ) )
|
||||
@@ -36,57 +34,50 @@ public class SpecialRecipes extends RecipeProvider implements IAE2DataProvider
|
||||
// .addCondition( new FeaturesEnabled( AEFeature.ENABLE_FACADE_CRAFTING ) )
|
||||
// .addRecipe( new FinishedRecipe( FacadeRecipe.SERIALIZER ) )
|
||||
// .build( consumer, AppEng.MOD_ID, "special/facade" );
|
||||
}
|
||||
}
|
||||
|
||||
private static class FinishedRecipe implements IFinishedRecipe
|
||||
{
|
||||
private static class FinishedRecipe implements IFinishedRecipe {
|
||||
|
||||
private final IRecipeSerializer<?> serializer;
|
||||
private final IRecipeSerializer<?> serializer;
|
||||
|
||||
public FinishedRecipe( IRecipeSerializer<?> serializer )
|
||||
{
|
||||
this.serializer = serializer;
|
||||
}
|
||||
public FinishedRecipe(IRecipeSerializer<?> serializer) {
|
||||
this.serializer = serializer;
|
||||
}
|
||||
|
||||
@Override public void serialize( @Nonnull JsonObject json )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public void serialize(@Nonnull JsonObject json) {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return Objects.requireNonNull( serializer.getRegistryName() );
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getID() {
|
||||
return Objects.requireNonNull(serializer.getRegistryName());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer()
|
||||
{
|
||||
return serializer;
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
return serializer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JsonObject getAdvancementJson()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public JsonObject getAdvancementJson() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getAdvancementID()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getAdvancementID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return AppEng.MOD_NAME + " Special Crafting Recipes";
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return AppEng.MOD_NAME + " Special Crafting Recipes";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user