Add Jade compatibility

This commit is contained in:
thedarkcolour 2024-02-07 15:18:32 -08:00
parent da98acc3cd
commit e565b456fd
11 changed files with 298 additions and 5 deletions

View File

@ -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}"))

View File

@ -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

View File

@ -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",

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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);
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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<Component>();
ItemStack.appendEnchantmentNames(list, mesh.getEnchantmentTags());
for (var component : list) {
tooltip.add(component);
}
}
}
}
}
@Override
public ResourceLocation getUid() {
return ExDeorumJadePlugin.SIEVE;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
@net.minecraft.MethodsReturnNonnullByDefault
@javax.annotation.ParametersAreNonnullByDefault
package thedarkcolour.exdeorum.compat.jade;

View File

@ -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 + "%"));
}

View File

@ -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");
}
}