Skip to content

Commit

Permalink
Properly hide builtin Jade energy bar for newer versions of Jade and …
Browse files Browse the repository at this point in the history
…improve checks related to showing tank contents for TOP
  • Loading branch information
pupnewfster committed Dec 19, 2022
1 parent 4036fae commit 1fa222c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Expand Up @@ -26,6 +26,7 @@
public class MekanismJadePlugin implements IWailaPlugin {

private static final ResourceLocation FORGE_ENERGY = new ResourceLocation("fe");
private static final ResourceLocation NEW_ENERGY = new ResourceLocation("energy_storage");
private static final ResourceLocation FORGE_FLUID = new ResourceLocation("fluid");

@Override
Expand All @@ -48,7 +49,10 @@ public void registerClient(IWailaClientRegistration registration) {
@Override
public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig config) {
if (accessor.getServerData().contains(NBTConstants.MEK_DATA, Tag.TAG_LIST)) {
//TODO - 1.19.3: Switch to using snownee.jade.api.Identifiers.UNIVERSAL_FLUID_STORAGE and UNIVERSAL_ENERGY_STORAGE
// as we will know the class exists in all versions
tooltip.remove(FORGE_ENERGY);
tooltip.remove(NEW_ENERGY);
tooltip.remove(FORGE_FLUID);
}
}
Expand Down
@@ -1,6 +1,8 @@
package mekanism.common.integration.lookingat.theoneprobe;

import java.util.function.BooleanSupplier;
import java.util.function.Function;
import java.util.function.Supplier;
import mcjty.theoneprobe.api.CompoundText;
import mcjty.theoneprobe.api.IProbeConfig;
import mcjty.theoneprobe.api.IProbeConfig.ConfigMode;
Expand Down Expand Up @@ -32,8 +34,8 @@
//Registered via IMC
public class TOPProvider implements IProbeInfoProvider, Function<ITheOneProbe, Void> {

private boolean displayFluidTanks;
private ConfigMode tankMode = ConfigMode.EXTENDED;
private BooleanSupplier displayFluidTanks;
private Supplier<ConfigMode> tankMode = () -> ConfigMode.EXTENDED;

@Override
public Void apply(ITheOneProbe probe) {
Expand All @@ -48,8 +50,8 @@ public Void apply(ITheOneProbe probe) {
probe.registerElementFactory(new SlurryElementFactory());
//Grab the default view settings
IProbeConfig probeConfig = probe.createProbeConfig();
displayFluidTanks = probeConfig.getTankMode() > 0;
tankMode = probeConfig.getShowTankSetting();
displayFluidTanks = () -> probeConfig.getTankMode() > 0;
tankMode = probeConfig::getShowTankSetting;
return null;
}

Expand All @@ -73,19 +75,16 @@ public void addProbeInfo(ProbeMode mode, IProbeInfo info, Player player, Level w
}
BlockEntity tile = WorldUtils.getTileEntity(world, pos);
if (tile != null) {
LookingAtUtils.addInfo(new TOPLookingAtHelper(info), tile, displayTanks(mode), displayFluidTanks);
LookingAtUtils.addInfo(new TOPLookingAtHelper(info), tile, displayTanks(mode), displayFluidTanks.getAsBoolean());
}
}

private boolean displayTanks(ProbeMode mode) {
if (tankMode == ConfigMode.NOT) {
//Don't display tanks
return false;
}
if (tankMode == ConfigMode.NORMAL) {
return mode == ProbeMode.NORMAL;
}
return mode == ProbeMode.EXTENDED;
return switch (tankMode.get()) {
case NOT -> false;//Don't display tanks
case NORMAL -> mode == ProbeMode.NORMAL;
case EXTENDED -> mode == ProbeMode.EXTENDED;
};
}

static class TOPLookingAtHelper implements LookingAtHelper {
Expand Down

0 comments on commit 1fa222c

Please sign in to comment.