diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/Multiblocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/Multiblocks.java index 6c9ff427..0c3ba95e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/Multiblocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/Multiblocks.java @@ -1,51 +1,69 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.NaturesAura; +import net.minecraft.block.Block; import net.minecraft.block.BlockLog; import net.minecraft.block.BlockSapling; import net.minecraft.block.BlockStoneBrick; import net.minecraft.block.BlockStoneBrick.EnumType; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.ResourceLocation; -import vazkii.patchouli.common.multiblock.Multiblock; -import vazkii.patchouli.common.multiblock.Multiblock.StateMatcher; -import vazkii.patchouli.common.multiblock.MultiblockRegistry; +import vazkii.patchouli.api.IMultiblock; +import vazkii.patchouli.api.IStateMatcher; +import vazkii.patchouli.api.PatchouliAPI; + +import java.util.function.Predicate; public final class Multiblocks { - public static final Multiblock ALTAR = MultiblockRegistry.registerMultiblock( + public static final IMultiblock ALTAR = make( new ResourceLocation(NaturesAura.MOD_ID, "altar"), - new Multiblock(new String[][]{ + new String[][]{ {" M ", " ", " ", " ", "M M", " ", " ", " ", " M "}, {" B ", " ", " ", " ", "B B", " ", " ", " ", " B "}, {" B ", " ", " M M ", " ", "B 0 B", " ", " M M ", " ", " B "}, {" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}}, - 'C', Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, EnumType.CHISELED), - 'B', Blocks.STONEBRICK.getDefaultState(), - 'W', Blocks.PLANKS, - 'M', Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, EnumType.MOSSY), - '0', ModBlocks.NATURE_ALTAR, - ' ', StateMatcher.ANY) + 'C', Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, EnumType.CHISELED), + 'B', Blocks.STONEBRICK.getDefaultState(), + 'W', Blocks.PLANKS, + 'M', Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, EnumType.MOSSY), + '0', ModBlocks.NATURE_ALTAR, + ' ', anyMatcher() ).setSymmetrical(true); - public static final Multiblock TREE_RITUAL = MultiblockRegistry.registerMultiblock( + public static final IMultiblock TREE_RITUAL = make( new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"), - new Multiblock(new String[][]{ + new String[][]{ {" W ", " W W ", " GGG ", " GG GG ", "W G 0 G W", " GG GG ", " GGG ", " W W ", " W "}}, - 'W', ModBlocks.WOOD_STAND, - 'G', ModBlocks.GOLD_POWDER, - '0', StateMatcher.fromPredicate(Blocks.SAPLING, state -> state.getBlock() instanceof BlockSapling || state.getBlock() instanceof BlockLog), - ' ', StateMatcher.ANY) + 'W', ModBlocks.WOOD_STAND, + 'G', ModBlocks.GOLD_POWDER, + '0', matcher(Blocks.SAPLING, state -> state.getBlock() instanceof BlockSapling || state.getBlock() instanceof BlockLog), + ' ', anyMatcher() ).setSymmetrical(true); - public static final Multiblock POTION_GENERATOR = MultiblockRegistry.registerMultiblock( + public static final IMultiblock POTION_GENERATOR = make( new ResourceLocation(NaturesAura.MOD_ID, "potion_generator"), - new Multiblock(new String[][]{ + new String[][]{ {"R R", " ", " ", " ", " ", " ", "R R"}, {"N N", " ", " ", " ", " ", " ", "N N"}, {"N N", " ", " ", " 0 ", " ", " ", "N N"}, {" N N ", "NNN NNN", " NRRRN ", " R R ", " NRRRN ", "NNN NNN", " N N "}}, - 'N', Blocks.NETHER_BRICK, - 'R', Blocks.RED_NETHER_BRICK, - '0', ModBlocks.POTION_GENERATOR, - ' ', StateMatcher.ANY) + 'N', Blocks.NETHER_BRICK, + 'R', Blocks.RED_NETHER_BRICK, + '0', ModBlocks.POTION_GENERATOR, + ' ', anyMatcher() ).setSymmetrical(true); + + private static IStateMatcher anyMatcher() { + return PatchouliAPI.instance.anyMatcher(); + } + + private static IStateMatcher matcher(Block block, Predicate predicate) { + return PatchouliAPI.instance.predicateMatcher(block, predicate); + } + + private static IMultiblock make(ResourceLocation res, String[][] pattern, Object... targets) { + IMultiblock multi = PatchouliAPI.instance.makeMultiblock(pattern, targets); + PatchouliAPI.instance.registerMultiblock(res, multi); + return multi; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java index 8849078e..fd81b268 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java @@ -137,7 +137,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { private boolean isRitualOkay() { if (!Multiblocks.TREE_RITUAL.forEachMatcher(this.world, this.ritualPos, Rotation.NONE, (char) 0, (start, actionPos, x, y, z, ch, matcher) -> - matcher.displayState.getBlock() == ModBlocks.WOOD_STAND || Multiblocks.TREE_RITUAL.test(this.world, start, x, y, z, Rotation.NONE))) { + matcher.getDisplayedState().getBlock() == ModBlocks.WOOD_STAND || Multiblocks.TREE_RITUAL.test(this.world, start, x, y, z, Rotation.NONE))) { return false; } if (this.timer < this.recipe.time / 2) { diff --git a/src/main/java/de/ellpeck/naturesaura/compat/Compat.java b/src/main/java/de/ellpeck/naturesaura/compat/Compat.java index 42d5c9a3..0d242859 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/Compat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/Compat.java @@ -1,6 +1,5 @@ package de.ellpeck.naturesaura.compat; -import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Loader; @@ -14,8 +13,4 @@ public final class Compat { MinecraftForge.EVENT_BUS.register(new BaublesCompat()); } } - - public static void initClient(){ - PatchouliCompat.initClient(); - } } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PageAltar.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PageAltar.java deleted file mode 100644 index 93936aac..00000000 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PageAltar.java +++ /dev/null @@ -1,49 +0,0 @@ -package de.ellpeck.naturesaura.compat.patchouli; - -import de.ellpeck.naturesaura.blocks.ModBlocks; -import de.ellpeck.naturesaura.recipes.AltarRecipe; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import vazkii.patchouli.client.book.BookEntry; -import vazkii.patchouli.client.book.gui.GuiBook; -import vazkii.patchouli.client.book.page.abstr.PageDoubleRecipe; - -public class PageAltar extends PageDoubleRecipe { - - private static final ItemStack ALTAR = new ItemStack(ModBlocks.NATURE_ALTAR); - - @Override - protected void drawRecipe(AltarRecipe recipe, int recipeX, int recipeY, int mouseX, int mouseY, boolean second) { - GlStateManager.enableBlend(); - this.mc.getTextureManager().bindTexture(PatchouliCompat.GUI_ELEMENTS); - Gui.drawModalRectWithCustomSizedTexture(recipeX + 12, recipeY, 0, 0, 75, 44, 256, 256); - - this.parent.drawCenteredStringNoShadow(this.getTitle(second), GuiBook.PAGE_WIDTH / 2, recipeY - 10, 0x333333); - this.renderItem(recipeX + 12 + 30, recipeY + 13, mouseX, mouseY, ALTAR); - - this.renderItem(recipeX + 12 + 4, recipeY + 13, mouseX, mouseY, recipe.input); - this.renderItem(recipeX + 12 + 56, recipeY + 13, mouseX, mouseY, recipe.output); - } - - @Override - protected AltarRecipe loadRecipe(BookEntry entry, String loc) { - if (loc != null) { - AltarRecipe recipe = AltarRecipe.RECIPES.get(new ResourceLocation(loc)); - entry.addRelevantStack(recipe.output, this.pageNum); - return recipe; - } - return null; - } - - @Override - protected ItemStack getRecipeOutput(AltarRecipe recipe) { - return recipe.output; - } - - @Override - protected int getRecipeHeight() { - return 60; - } -} diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PageTreeRitual.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PageTreeRitual.java deleted file mode 100644 index 0ea850a1..00000000 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PageTreeRitual.java +++ /dev/null @@ -1,51 +0,0 @@ -package de.ellpeck.naturesaura.compat.patchouli; - -import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import vazkii.patchouli.client.book.BookEntry; -import vazkii.patchouli.client.book.gui.GuiBook; -import vazkii.patchouli.client.book.page.abstr.PageDoubleRecipe; - -public class PageTreeRitual extends PageDoubleRecipe { - - @Override - protected void drawRecipe(TreeRitualRecipe recipe, int recipeX, int recipeY, int mouseX, int mouseY, boolean second) { - GlStateManager.enableBlend(); - this.mc.getTextureManager().bindTexture(PatchouliCompat.GUI_ELEMENTS); - Gui.drawModalRectWithCustomSizedTexture(recipeX - 13, recipeY, 0, 44, 122, 88, 256, 256); - - this.parent.drawCenteredStringNoShadow(this.getTitle(second), GuiBook.PAGE_WIDTH / 2, recipeY - 10, 0x333333); - - int[][] positions = new int[][]{{38, 4}, {38, 68}, {6, 36}, {70, 36}, {13, 11}, {63, 61}, {63, 11}, {13, 61}}; - for (int i = 0; i < recipe.items.length; i++) { - ItemStack input = recipe.items[i]; - this.renderItem(recipeX - 13 + positions[i][0], recipeY + positions[i][1], mouseX, mouseY, input); - } - - this.renderItem(recipeX - 13 + 38, recipeY + 36, mouseX, mouseY, recipe.saplingType); - this.renderItem(recipeX - 13 + 102, recipeY + 36, mouseX, mouseY, recipe.result); - } - - @Override - protected TreeRitualRecipe loadRecipe(BookEntry entry, String loc) { - if (loc != null) { - TreeRitualRecipe recipe = TreeRitualRecipe.RECIPES.get(new ResourceLocation(loc)); - entry.addRelevantStack(recipe.result, this.pageNum); - return recipe; - } - return null; - } - - @Override - protected ItemStack getRecipeOutput(TreeRitualRecipe recipe) { - return recipe.result; - } - - @Override - protected int getRecipeHeight() { - return 105; - } -} diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java deleted file mode 100644 index 42c6e07f..00000000 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.ellpeck.naturesaura.compat.patchouli; - -import de.ellpeck.naturesaura.NaturesAura; -import net.minecraft.util.ResourceLocation; -import vazkii.patchouli.client.book.BookPage; -import vazkii.patchouli.client.book.ClientBookRegistry; - -public final class PatchouliCompat { - - public static final ResourceLocation GUI_ELEMENTS = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/patchouli/elements.png"); - - public static void initClient() { - addPatchouliPage("altar", PageAltar.class); - addPatchouliPage("tree_ritual", PageTreeRitual.class); - } - - private static void addPatchouliPage(String name, Class page) { - ClientBookRegistry.INSTANCE.pageTypes.put(NaturesAura.MOD_ID + ":" + name, page); - } -} diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java new file mode 100644 index 00000000..e84c117c --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java @@ -0,0 +1,32 @@ +package de.ellpeck.naturesaura.compat.patchouli; + +import de.ellpeck.naturesaura.recipes.AltarRecipe; +import net.minecraft.util.ResourceLocation; +import vazkii.patchouli.api.IComponentProcessor; +import vazkii.patchouli.api.IVariableProvider; +import vazkii.patchouli.api.PatchouliAPI; + +public class ProcessorAltar implements IComponentProcessor { + + private AltarRecipe recipe; + + @Override + public void setup(IVariableProvider provider) { + ResourceLocation res = new ResourceLocation(provider.get("recipe")); + this.recipe = AltarRecipe.RECIPES.get(res); + } + + @Override + public String process(String key) { + switch (key) { + case "input": + return PatchouliAPI.instance.serializeItemStack(this.recipe.input); + case "output": + return PatchouliAPI.instance.serializeItemStack(this.recipe.output); + case "name": + return this.recipe.output.getDisplayName(); + default: + return null; + } + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java new file mode 100644 index 00000000..06fb26b0 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java @@ -0,0 +1,40 @@ +package de.ellpeck.naturesaura.compat.patchouli; + +import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; +import net.minecraft.util.ResourceLocation; +import vazkii.patchouli.api.IComponentProcessor; +import vazkii.patchouli.api.IVariableProvider; +import vazkii.patchouli.api.PatchouliAPI; + +public class ProcessorTreeRitual implements IComponentProcessor { + + private TreeRitualRecipe recipe; + + @Override + public void setup(IVariableProvider provider) { + ResourceLocation res = new ResourceLocation(provider.get("recipe")); + this.recipe = TreeRitualRecipe.RECIPES.get(res); + } + + @Override + public String process(String key) { + if (key.startsWith("input")) { + int id = Integer.parseInt(key.substring(5)) - 1; + if (this.recipe.items.length > id) + return PatchouliAPI.instance.serializeItemStack(this.recipe.items[id]); + else + return null; + } else { + switch (key) { + case "output": + return PatchouliAPI.instance.serializeItemStack(this.recipe.result); + case "sapling": + return PatchouliAPI.instance.serializeItemStack(this.recipe.saplingType); + case "name": + return this.recipe.result.getDisplayName(); + default: + return null; + } + } + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/events/TerrainGenEvents.java b/src/main/java/de/ellpeck/naturesaura/events/TerrainGenEvents.java index dc9f0e18..d26ff6cd 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/TerrainGenEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/TerrainGenEvents.java @@ -28,7 +28,7 @@ public class TerrainGenEvents { BlockPos pos = event.getPos(); if (!world.isRemote) { if (Multiblocks.TREE_RITUAL.forEachMatcher(world, pos, Rotation.NONE, (char) 0, (start, actionPos, x, y, z, ch, matcher) -> - matcher.displayState.getBlock() == ModBlocks.WOOD_STAND || Multiblocks.TREE_RITUAL.test(world, start, x, y, z, Rotation.NONE))) { + matcher.getDisplayedState().getBlock() == ModBlocks.WOOD_STAND || Multiblocks.TREE_RITUAL.test(world, start, x, y, z, Rotation.NONE))) { IBlockState sapling = world.getBlockState(pos); ItemStack saplingStack = sapling.getBlock().getItem(world, pos, sapling); if (!saplingStack.isEmpty()) { diff --git a/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java b/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java index b8db7435..04ef186f 100644 --- a/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java +++ b/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java @@ -34,7 +34,6 @@ public class ClientProxy implements IProxy { @Override public void preInit(FMLPreInitializationEvent event) { MinecraftForge.EVENT_BUS.register(new ClientEvents()); - Compat.initClient(); } @Override diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/altar.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/altar.json index 658a06a1..b3134d6e 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/altar.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/altar.json @@ -11,9 +11,13 @@ }, { "type": "naturesaura:altar", - "text": "Creating $(item)Infused Iron$() and $(item)Infused Rock$(), important ingredients in the creation of several $(thing)natural items$().", - "recipe": "naturesaura:infused_iron", - "recipe2": "naturesaura:infused_stone" + "text": "Creating $(item)Infused Iron$(), a material blessed with the powers of $(aura), allowing it to be used in several magical $(thing)natural items$().", + "recipe": "naturesaura:infused_iron" + }, + { + "type": "naturesaura:altar", + "text": "Creating $(item)Infused Rock$(), a material, similar looking to the fabric of $(italic)balance$() itself, infused with $(aura).", + "recipe": "naturesaura:infused_stone" } ] } \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/templates/altar.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/templates/altar.json new file mode 100644 index 00000000..458d8439 --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/templates/altar.json @@ -0,0 +1,46 @@ +{ + "processor": "de.ellpeck.naturesaura.compat.patchouli.ProcessorAltar", + "components": [ + { + "type": "item", + "item": "#input", + "x": 24, + "y": 26 + }, + { + "type": "item", + "item": "#output", + "x": 76, + "y": 26, + "link_recipe": true + }, + { + "type": "item", + "item": "naturesaura:nature_altar", + "x": 50, + "y": 26 + }, + { + "type": "image", + "image": "naturesaura:textures/gui/patchouli/elements.png", + "x": 20, + "y": 13, + "u": 0, + "v": 0, + "width": 75, + "height": 44 + }, + { + "type": "header", + "text": "#name", + "x": -1, + "y": 0 + }, + { + "type": "text", + "text": "#text", + "x": 0, + "y": 63 + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/templates/tree_ritual.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/templates/tree_ritual.json new file mode 100644 index 00000000..1e7b1c1d --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/templates/tree_ritual.json @@ -0,0 +1,88 @@ +{ + "processor": "de.ellpeck.naturesaura.compat.patchouli.ProcessorTreeRitual", + "components": [ + { + "type": "item", + "item": "#input1", + "x": 34, + "y": 14 + }, + { + "type": "item", + "item": "#input2", + "x": 34, + "y": 78 + }, + { + "type": "item", + "item": "#input3", + "x": 2, + "y": 46 + }, + { + "type": "item", + "item": "#input4", + "x": 66, + "y": 46 + }, + { + "type": "item", + "item": "#input5", + "x": 9, + "y": 21 + }, + { + "type": "item", + "item": "#input6", + "x": 59, + "y": 71 + }, + { + "type": "item", + "item": "#input7", + "x": 59, + "y": 21 + }, + { + "type": "item", + "item": "#input8", + "x": 9, + "y": 71 + }, + { + "type": "item", + "item": "#output", + "x": 98, + "y": 46, + "link_recipe": true + }, + { + "type": "item", + "item": "#sapling", + "x": 34, + "y": 46 + }, + { + "type": "image", + "image": "naturesaura:textures/gui/patchouli/elements.png", + "x": -4, + "y": 10, + "u": 0, + "v": 44, + "width": 122, + "height": 88 + }, + { + "type": "header", + "text": "#name", + "x": -1, + "y": 0 + }, + { + "type": "text", + "text": "#text", + "x": 0, + "y": 100 + } + ] +} \ No newline at end of file