From e565b456fd572175fd110e13da744524e694abe5 Mon Sep 17 00:00:00 2001
From: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com>
Date: Wed, 7 Feb 2024 15:18:32 -0800
Subject: [PATCH] Add Jade compatibility
---
build.gradle | 4 +-
.../93943142017732f21fbc4fa325d116c728b69767 | 4 +-
.../resources/assets/exdeorum/lang/en_us.json | 4 ++
.../compat/jade/BarrelComponentProvider.java | 63 ++++++++++++++++++
.../jade/CrucibleComponentProvider.java | 43 ++++++++++++
.../compat/jade/ExDeorumJadePlugin.java | 45 +++++++++++++
.../jade/InfestedLeavesComponentProvider.java | 44 +++++++++++++
.../compat/jade/SieveComponentProvider.java | 65 +++++++++++++++++++
.../exdeorum/compat/jade/package-info.java | 21 ++++++
.../compat/top/ExDeorumInfoProvider.java | 4 +-
.../thedarkcolour/exdeorum/data/English.java | 6 ++
11 files changed, 298 insertions(+), 5 deletions(-)
create mode 100644 src/main/java/thedarkcolour/exdeorum/compat/jade/BarrelComponentProvider.java
create mode 100644 src/main/java/thedarkcolour/exdeorum/compat/jade/CrucibleComponentProvider.java
create mode 100644 src/main/java/thedarkcolour/exdeorum/compat/jade/ExDeorumJadePlugin.java
create mode 100644 src/main/java/thedarkcolour/exdeorum/compat/jade/InfestedLeavesComponentProvider.java
create mode 100644 src/main/java/thedarkcolour/exdeorum/compat/jade/SieveComponentProvider.java
create mode 100644 src/main/java/thedarkcolour/exdeorum/compat/jade/package-info.java
diff --git a/build.gradle b/build.gradle
index b8c6d9ff..3cb5040e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -151,9 +151,11 @@ dependencies {
minecraft("net.minecraftforge:forge:${mc_version}-${forge_version}")
// TOP OPTIONAL
- implementation(fg.deobf("mcjty.theoneprobe:theoneprobe:1.20.1-${top_version}") {
+ compileOnly(fg.deobf("mcjty.theoneprobe:theoneprobe:1.20.1-${top_version}") {
transitive = false
})
+ // JADE OPTIONAL
+ implementation(fg.deobf("curse.maven:jade-324717:4986594"))
// JEI OPTIONAL
compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}"))
compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}"))
diff --git a/src/generated/resources/.cache/93943142017732f21fbc4fa325d116c728b69767 b/src/generated/resources/.cache/93943142017732f21fbc4fa325d116c728b69767
index eabf146e..8ff8df69 100644
--- a/src/generated/resources/.cache/93943142017732f21fbc4fa325d116c728b69767
+++ b/src/generated/resources/.cache/93943142017732f21fbc4fa325d116c728b69767
@@ -1,2 +1,2 @@
-// 1.20.1 2024-02-03T10:43:20.71792 ModKit Language: en_us for mod 'exdeorum'
-317bfdb09335e4fd7f62f796cd6b351043a93718 assets/exdeorum/lang/en_us.json
+// 1.20.1 2024-02-07T15:07:17.5326478 ModKit Language: en_us for mod 'exdeorum'
+313d90779f26fbca4597861071060dba9e94411a assets/exdeorum/lang/en_us.json
diff --git a/src/generated/resources/assets/exdeorum/lang/en_us.json b/src/generated/resources/assets/exdeorum/lang/en_us.json
index fd94d33b..1837f0cf 100644
--- a/src/generated/resources/assets/exdeorum/lang/en_us.json
+++ b/src/generated/resources/assets/exdeorum/lang/en_us.json
@@ -119,6 +119,10 @@
"block.exdeorum.willow_crucible": "Willow Crucible",
"block.exdeorum.willow_sieve": "Willow Sieve",
"block.exdeorum.witch_water": "Witch Water",
+ "config.jade.plugin_exdeorum.barrel": "Barrel",
+ "config.jade.plugin_exdeorum.crucible": "Crucible",
+ "config.jade.plugin_exdeorum.infested_leaves": "Infested Leaves",
+ "config.jade.plugin_exdeorum.sieve": "Sieve",
"exdeorum.container.mechanical_hammer": "Mechanical Hammer",
"exdeorum.container.mechanical_sieve": "Mechanical Sieve",
"fluid_type.exdeorum.witch_water": "Witch Water",
diff --git a/src/main/java/thedarkcolour/exdeorum/compat/jade/BarrelComponentProvider.java b/src/main/java/thedarkcolour/exdeorum/compat/jade/BarrelComponentProvider.java
new file mode 100644
index 00000000..179ad4fb
--- /dev/null
+++ b/src/main/java/thedarkcolour/exdeorum/compat/jade/BarrelComponentProvider.java
@@ -0,0 +1,63 @@
+/*
+ * Ex Deorum
+ * Copyright (c) 2024 thedarkcolour
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package thedarkcolour.exdeorum.compat.jade;
+
+import net.minecraft.network.chat.Component;
+import net.minecraft.resources.ResourceLocation;
+import snownee.jade.api.BlockAccessor;
+import snownee.jade.api.IBlockComponentProvider;
+import snownee.jade.api.ITooltip;
+import snownee.jade.api.config.IPluginConfig;
+import snownee.jade.api.fluid.JadeFluidObject;
+import snownee.jade.api.ui.IElementHelper;
+import thedarkcolour.exdeorum.blockentity.BarrelBlockEntity;
+
+enum BarrelComponentProvider implements IBlockComponentProvider {
+ INSTANCE;
+
+ @Override
+ public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig iPluginConfig) {
+ if (accessor.getBlockEntity() instanceof BarrelBlockEntity barrel) {
+ short volume = barrel.compost;
+
+ if (volume == 1000 || barrel.isBrewing()) {
+ int progress = (int) (barrel.progress * 100.0f);
+
+ tooltip.add(Component.literal("Progress: ").append(progress + "%"));
+ } else if (volume > 0) {
+ int volumePercent = (int) (volume / 10.0f);
+
+ tooltip.add(Component.literal("Volume: ").append(volumePercent + "%"));
+ } else if (barrel.isBurning()) {
+ int progress = 300 - (int) (barrel.progress * 300.0f);
+
+ tooltip.add(Component.literal("Burning! ").append(progress / 20 + "s"));
+ }
+ if (accessor.getPlayer().isShiftKeyDown()) {
+ var fluid = barrel.getTank().getFluid();
+ tooltip.add(IElementHelper.get().fluid(JadeFluidObject.of(fluid.getFluid(), fluid.getAmount())));
+ }
+ }
+ }
+
+ @Override
+ public ResourceLocation getUid() {
+ return ExDeorumJadePlugin.BARREL;
+ }
+}
diff --git a/src/main/java/thedarkcolour/exdeorum/compat/jade/CrucibleComponentProvider.java b/src/main/java/thedarkcolour/exdeorum/compat/jade/CrucibleComponentProvider.java
new file mode 100644
index 00000000..8c8fa0bc
--- /dev/null
+++ b/src/main/java/thedarkcolour/exdeorum/compat/jade/CrucibleComponentProvider.java
@@ -0,0 +1,43 @@
+/*
+ * Ex Deorum
+ * Copyright (c) 2024 thedarkcolour
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package thedarkcolour.exdeorum.compat.jade;
+
+import net.minecraft.network.chat.Component;
+import net.minecraft.resources.ResourceLocation;
+import snownee.jade.api.BlockAccessor;
+import snownee.jade.api.IBlockComponentProvider;
+import snownee.jade.api.ITooltip;
+import snownee.jade.api.config.IPluginConfig;
+import thedarkcolour.exdeorum.blockentity.AbstractCrucibleBlockEntity;
+
+enum CrucibleComponentProvider implements IBlockComponentProvider {
+ INSTANCE;
+
+ @Override
+ public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig config) {
+ if (accessor.getBlockEntity() instanceof AbstractCrucibleBlockEntity crucible) {
+ tooltip.add(Component.literal("Rate: " + crucible.getMeltingRate() + "x"));
+ }
+ }
+
+ @Override
+ public ResourceLocation getUid() {
+ return ExDeorumJadePlugin.CRUCIBLE;
+ }
+}
diff --git a/src/main/java/thedarkcolour/exdeorum/compat/jade/ExDeorumJadePlugin.java b/src/main/java/thedarkcolour/exdeorum/compat/jade/ExDeorumJadePlugin.java
new file mode 100644
index 00000000..9af9e26c
--- /dev/null
+++ b/src/main/java/thedarkcolour/exdeorum/compat/jade/ExDeorumJadePlugin.java
@@ -0,0 +1,45 @@
+/*
+ * Ex Deorum
+ * Copyright (c) 2024 thedarkcolour
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package thedarkcolour.exdeorum.compat.jade;
+
+import net.minecraft.resources.ResourceLocation;
+import snownee.jade.api.IWailaClientRegistration;
+import snownee.jade.api.IWailaPlugin;
+import snownee.jade.api.WailaPlugin;
+import thedarkcolour.exdeorum.ExDeorum;
+import thedarkcolour.exdeorum.block.AbstractCrucibleBlock;
+import thedarkcolour.exdeorum.block.BarrelBlock;
+import thedarkcolour.exdeorum.block.InfestedLeavesBlock;
+import thedarkcolour.exdeorum.block.SieveBlock;
+
+@WailaPlugin
+public class ExDeorumJadePlugin implements IWailaPlugin {
+ static final ResourceLocation INFESTED_LEAVES = new ResourceLocation(ExDeorum.ID, "infested_leaves");
+ static final ResourceLocation BARREL = new ResourceLocation(ExDeorum.ID, "barrel");
+ static final ResourceLocation SIEVE = new ResourceLocation(ExDeorum.ID, "sieve");
+ static final ResourceLocation CRUCIBLE = new ResourceLocation(ExDeorum.ID, "crucible");
+
+ @Override
+ public void registerClient(IWailaClientRegistration registration) {
+ registration.registerBlockComponent(InfestedLeavesComponentProvider.INSTANCE, InfestedLeavesBlock.class);
+ registration.registerBlockComponent(BarrelComponentProvider.INSTANCE, BarrelBlock.class);
+ registration.registerBlockComponent(SieveComponentProvider.INSTANCE, SieveBlock.class);
+ registration.registerBlockComponent(CrucibleComponentProvider.INSTANCE, AbstractCrucibleBlock.class);
+ }
+}
diff --git a/src/main/java/thedarkcolour/exdeorum/compat/jade/InfestedLeavesComponentProvider.java b/src/main/java/thedarkcolour/exdeorum/compat/jade/InfestedLeavesComponentProvider.java
new file mode 100644
index 00000000..360765ed
--- /dev/null
+++ b/src/main/java/thedarkcolour/exdeorum/compat/jade/InfestedLeavesComponentProvider.java
@@ -0,0 +1,44 @@
+/*
+ * Ex Deorum
+ * Copyright (c) 2024 thedarkcolour
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package thedarkcolour.exdeorum.compat.jade;
+
+import net.minecraft.network.chat.Component;
+import net.minecraft.resources.ResourceLocation;
+import snownee.jade.api.BlockAccessor;
+import snownee.jade.api.IBlockComponentProvider;
+import snownee.jade.api.ITooltip;
+import snownee.jade.api.config.IPluginConfig;
+import thedarkcolour.exdeorum.blockentity.InfestedLeavesBlockEntity;
+
+enum InfestedLeavesComponentProvider implements IBlockComponentProvider {
+ INSTANCE;
+
+ @Override
+ public void appendTooltip(ITooltip tooltip, BlockAccessor blockAccessor, IPluginConfig config) {
+ if (blockAccessor.getBlockEntity() instanceof InfestedLeavesBlockEntity leaves) {
+ int progress = (int) (leaves.getProgress() * 100.0f);
+ tooltip.add(Component.literal("Progress: ").append(Component.literal(progress + "%")));
+ }
+ }
+
+ @Override
+ public ResourceLocation getUid() {
+ return ExDeorumJadePlugin.INFESTED_LEAVES;
+ }
+}
diff --git a/src/main/java/thedarkcolour/exdeorum/compat/jade/SieveComponentProvider.java b/src/main/java/thedarkcolour/exdeorum/compat/jade/SieveComponentProvider.java
new file mode 100644
index 00000000..645b0ba5
--- /dev/null
+++ b/src/main/java/thedarkcolour/exdeorum/compat/jade/SieveComponentProvider.java
@@ -0,0 +1,65 @@
+/*
+ * Ex Deorum
+ * Copyright (c) 2024 thedarkcolour
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package thedarkcolour.exdeorum.compat.jade;
+
+import it.unimi.dsi.fastutil.objects.ObjectArrayList;
+import net.minecraft.network.chat.Component;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.phys.Vec2;
+import snownee.jade.api.BlockAccessor;
+import snownee.jade.api.IBlockComponentProvider;
+import snownee.jade.api.ITooltip;
+import snownee.jade.api.config.IPluginConfig;
+import snownee.jade.api.ui.IElementHelper;
+import thedarkcolour.exdeorum.blockentity.logic.SieveLogic;
+
+enum SieveComponentProvider implements IBlockComponentProvider {
+ INSTANCE;
+
+ @Override
+ public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig config) {
+ if (accessor.getBlockEntity() instanceof SieveLogic.Owner sieve) {
+ var logic = sieve.getLogic();
+
+ if (!logic.getContents().isEmpty()) {
+ tooltip.add(Component.literal("Progress: ").append((Math.round(1000 * logic.getProgress()) / 10) + "%"));
+ }
+ if (accessor.getPlayer().isShiftKeyDown()) {
+ var mesh = logic.getMesh();
+ var element = IElementHelper.get().item(mesh);
+ tooltip.add(element);
+ tooltip.append(IElementHelper.get().text(Component.translatable(mesh.getDescriptionId())).translate(new Vec2(2f, 6f)));
+ if (mesh.isEnchanted()) {
+ var list = new ObjectArrayList();
+ ItemStack.appendEnchantmentNames(list, mesh.getEnchantmentTags());
+
+ for (var component : list) {
+ tooltip.add(component);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public ResourceLocation getUid() {
+ return ExDeorumJadePlugin.SIEVE;
+ }
+}
diff --git a/src/main/java/thedarkcolour/exdeorum/compat/jade/package-info.java b/src/main/java/thedarkcolour/exdeorum/compat/jade/package-info.java
new file mode 100644
index 00000000..82c82ae3
--- /dev/null
+++ b/src/main/java/thedarkcolour/exdeorum/compat/jade/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Ex Deorum
+ * Copyright (c) 2024 thedarkcolour
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+@net.minecraft.MethodsReturnNonnullByDefault
+@javax.annotation.ParametersAreNonnullByDefault
+package thedarkcolour.exdeorum.compat.jade;
diff --git a/src/main/java/thedarkcolour/exdeorum/compat/top/ExDeorumInfoProvider.java b/src/main/java/thedarkcolour/exdeorum/compat/top/ExDeorumInfoProvider.java
index 85bce11f..ef1440fd 100644
--- a/src/main/java/thedarkcolour/exdeorum/compat/top/ExDeorumInfoProvider.java
+++ b/src/main/java/thedarkcolour/exdeorum/compat/top/ExDeorumInfoProvider.java
@@ -50,8 +50,8 @@ public class ExDeorumInfoProvider implements IProbeInfoProvider {
var te = level.getBlockEntity(data.getPos());
if (state.getBlock() == EBlocks.INFESTED_LEAVES.get()) {
- if (te instanceof InfestedLeavesBlockEntity) {
- int progress = (int) (((InfestedLeavesBlockEntity) te).getProgress() * 100.0f);
+ if (te instanceof InfestedLeavesBlockEntity leaves) {
+ int progress = (int) (leaves.getProgress() * 100.0f);
info.text(CompoundText.create().style(TextStyleClass.LABEL).text("Progress: ").style(TextStyleClass.WARNING).text(progress + "%"));
}
diff --git a/src/main/java/thedarkcolour/exdeorum/data/English.java b/src/main/java/thedarkcolour/exdeorum/data/English.java
index 13314f78..71d423da 100644
--- a/src/main/java/thedarkcolour/exdeorum/data/English.java
+++ b/src/main/java/thedarkcolour/exdeorum/data/English.java
@@ -87,5 +87,11 @@ class English {
english.addBlock(EBlocks.CASCADING_ARCHWOOD_CRUCIBLE, "Cascading Archwood Crucible");
english.addBlock(EBlocks.BLAZING_ARCHWOOD_CRUCIBLE, "Blazing Archwood Crucible");
english.addBlock(EBlocks.FLOURISHING_ARCHWOOD_CRUCIBLE, "Flourishing Archwood Crucible");
+
+ // Jade translation (what does this look like?)
+ english.add("config.jade.plugin_exdeorum.infested_leaves", "Infested Leaves");
+ english.add("config.jade.plugin_exdeorum.barrel", "Barrel");
+ english.add("config.jade.plugin_exdeorum.sieve", "Sieve");
+ english.add("config.jade.plugin_exdeorum.crucible", "Crucible");
}
}