Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add signal strength indicator for ProjectRed wires #22

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/main/java/mcp/mobius/waila/addons/projectred/HUDFMPWires.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package mcp.mobius.waila.addons.projectred;

import java.util.List;

import net.minecraft.item.ItemStack;

import mcp.mobius.waila.api.ITaggedList;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaFMPAccessor;
import mcp.mobius.waila.api.IWailaFMPProvider;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.utils.NBTUtil;

public class HUDFMPWires implements IWailaFMPProvider {

@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor,
IWailaConfigHandler config) {
return currenttip;
}

@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor,
IWailaConfigHandler config) {
if (!config.getConfig("pr.showsignal")) return currenttip;

ITaggedList<String, String> tagList = (ITaggedList<String, String>) currenttip;
int signal = ((NBTUtil.getNBTInteger(accessor.getNBTData(), "signal") & 0xff) + 16) / 17;
if (tagList.getEntries("signal").isEmpty()) {
tagList.add(String.format("%s : %s", LangUtil.translateG("hud.msg.power"), signal), "signal");
}

return currenttip;
}

@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor,
IWailaConfigHandler config) {
return currenttip;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ public static void register() {

ModuleRegistrar.instance().addConfigRemote("Project:Red", "pr.showio");
ModuleRegistrar.instance().addConfigRemote("Project:Red", "pr.showdata");
ModuleRegistrar.instance().addConfigRemote("Project:Red", "pr.showsignal");

ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_sgate");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_igate");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_tgate");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_bgate");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_agate");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_rgate");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPWires(), "pr_redwire");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPWires(), "pr_insulated");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPWires(), "pr_fredwire");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPWires(), "pr_finsulated");

ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_sgate");
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_igate");
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/waila/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ option.bcapi.consump=Show maximum power
option.bcapi.trigger=Show triggering energy
option.pr.showio=Show gates IO
option.pr.showdata=Show gates data
option.pr.showsignal=Show wire signal strength
option.extrautilities.fluidamount=Show fluid amount
option.openblocks.fluidamount=Show fluid amount
option.railcraft.fluidamount=Show fluid amount
Expand Down