mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
convert to fully using the Patchouli API
This commit is contained in:
parent
5dc3a7a83d
commit
bebdce7224
13 changed files with 256 additions and 154 deletions
|
@ -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<IBlockState> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<AltarRecipe> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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<TreeRitualRecipe> {
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
|
@ -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<? extends BookPage> page) {
|
||||
ClientBookRegistry.INSTANCE.pageTypes.put(NaturesAura.MOD_ID + ":" + name, page);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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()) {
|
||||
|
|
|
@ -34,7 +34,6 @@ public class ClientProxy implements IProxy {
|
|||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
MinecraftForge.EVENT_BUS.register(new ClientEvents());
|
||||
Compat.initClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue