Skip to content

Commit

Permalink
offline work
Browse files Browse the repository at this point in the history
  • Loading branch information
strubium committed Jun 7, 2024
1 parent 4c93582 commit 46d968b
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 17 deletions.
12 changes: 8 additions & 4 deletions src/main/java/mcjty/theoneprobe/api/NumberFormat.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package mcjty.theoneprobe.api;

public enum NumberFormat {
FULL, // Full format
COMPACT, // Compact format (like 3.5M)
COMMAS, // Language dependent comma separated format
NONE // No output (empty string)
/**Full format*/
FULL,
/**Compact format (like 3.5M)*/
COMPACT,
/**Language dependent comma separated format*/
COMMAS,
/**No output (empty string)*/
NONE
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import mcjty.theoneprobe.apiimpl.styles.DefaultOverlayStyle;
import mcjty.theoneprobe.config.ConfigSetup;
import mcjty.theoneprobe.rendering.OverlayRenderer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class DefaultOverlayRenderer implements IOverlayRenderer {

Expand All @@ -21,6 +23,7 @@ public IProbeInfo createProbeInfo() {
}

@Override
@SideOnly(Side.CLIENT)
public void render(IOverlayStyle style, IProbeInfo probeInfo) {
OverlayRenderer.renderOverlay(style, probeInfo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,21 @@ public void addProbeEntityInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlaye
vertical = probeInfo.vertical(new LayoutStyle().borderColor(0xffff4444).spacing(2));

EntityLivingBase entityLivingBase = (EntityLivingBase) entity;
float stepHeight = entityLivingBase.stepHeight;
int totalArmorValue = entityLivingBase.getTotalArmorValue();
int age = entityLivingBase.getIdleTime();
float absorptionAmount = entityLivingBase.getAbsorptionAmount();
float aiMoveSpeed = entityLivingBase.getAIMoveSpeed();
int revengeTimer = entityLivingBase.getRevengeTimer();
boolean isOnFire = entityLivingBase.isBurning();
vertical
.text(LABEL + "Step Height: " + INFO + stepHeight)
.text(LABEL + "Total armor: " + INFO + totalArmorValue)
.text(LABEL + "Age: " + INFO + age)
.text(LABEL + "Absorption: " + INFO + absorptionAmount)
.text(LABEL + "AI Move Speed: " + INFO + aiMoveSpeed)
.text(LABEL + "Revenge Timer: " + INFO + revengeTimer);
.text(LABEL + "Revenge Timer: " + INFO + revengeTimer)
.text(LABEL + "On Fire: " + INFO + isOnFire);
}
if (entity instanceof EntityAgeable) {

Expand All @@ -56,7 +60,8 @@ public void addProbeEntityInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlaye
EntityWaterMob entityWaterMob = (EntityWaterMob) entity;
boolean canBreatheUnderwater = entityWaterMob.canBreatheUnderwater();
vertical
.text(LABEL + "Can Breath Underwater: " + INFO + canBreatheUnderwater);
.text(LABEL + "Can Breath Underwater: " + INFO + canBreatheUnderwater)
.text(LABEL + "In Water: " + INFO + entityWaterMob.isInWater());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ private void showDebugInfo(IProbeInfo probeInfo, World world, IBlockState blockS
if (te != null) {
vertical.text(LABEL + "TileEntity: " + INFO + te.getClass().getSimpleName());
if (te instanceof IBigPower) {
vertical.text(LABEL + "Energy: " + INFO + RedstoneFluxTools.getEnergy(te));
vertical.text(LABEL + "Max Energy: " + INFO + RedstoneFluxTools.getMaxEnergy(te));
vertical.text(LABEL + "Energy: " + INFO + RedstoneFluxTools.getEnergy(te))
.text(LABEL + "Max Energy: " + INFO + RedstoneFluxTools.getMaxEnergy(te));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void addProbeEntityInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlaye
probeInfo.text(LABEL + "{*theoneprobe.probe.rotation_indicator*} " + INFO + itemFrame.getRotation());
}
} else {
probeInfo.text(LABEL + "Empty");
probeInfo.text(LABEL + "{*theoneprobe.probe.empty_indicator*}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void showHarvestLevel(IProbeInfo probeInfo, IBlockState blockState, Block
static void showCanBeHarvested(IProbeInfo probeInfo, World world, BlockPos pos, Block block, EntityPlayer player) {
if (ModItems.isProbeInHand(player.getHeldItemMainhand())) {
// If the player holds the probe there is no need to show harvestability information as the
// probe cannot harvest anything. This is only supposed to work in off hand.
// probe cannot harvest anything. This is only supposed to work in the off hand.
return;
}

Expand Down
13 changes: 6 additions & 7 deletions src/main/java/mcjty/theoneprobe/rendering/OverlayRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ public class OverlayRenderer {
private static Map<UUID, Pair<Long, ProbeInfo>> cachedEntityInfo = new HashMap<>();
private static long lastCleanupTime = 0;

// For a short while we keep displaying the last pair if we have no new information
// to prevent flickering
/**For a short while we keep displaying the last pair if we have no new information to prevent flickering*/
private static Pair<Long, ProbeInfo> lastPair;
private static long lastPairTime = 0;

// When the server delays too long we also show some preliminary information already
/** When the server delays too long we also show some preliminary information already*/
private static long lastRenderedTime = -1;

public static void registerProbeInfo(int dim, BlockPos pos, ProbeInfo probeInfo) {
Expand Down Expand Up @@ -295,10 +294,10 @@ private static ProbeInfo getWaitingInfo(ProbeMode mode, RayTraceResult mouseOver
DefaultProbeInfoProvider.showStandardBlockInfo(probeConfig, mode, probeInfo, blockState, block, data);
} catch (Exception e) {
ThrowableIdentity.registerThrowable(e);
probeInfo.text(ERROR + "Error (see log for details)!");
probeInfo.text(ERROR + "{*theoneprobe.probe.error_log_indicator*}");
}

probeInfo.text(ERROR + "Waiting for server...");
probeInfo.text(ERROR + "{*theoneprobe.probe.waiting_server_indicator*}");
return probeInfo;
}

Expand All @@ -311,10 +310,10 @@ private static ProbeInfo getWaitingEntityInfo(ProbeMode mode, RayTraceResult mou
DefaultProbeInfoEntityProvider.showStandardInfo(mode, probeInfo, entity, probeConfig);
} catch (Exception e) {
ThrowableIdentity.registerThrowable(e);
probeInfo.text(ERROR + "Error (see log for details)!");
probeInfo.text(ERROR + "{*theoneprobe.probe.error_log_indicator*}");
}

probeInfo.text(ERROR + "Waiting for server...");
probeInfo.text(ERROR + "{*theoneprobe.probe.waiting_server_indicator*}");
return probeInfo;
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/mcjty/theoneprobe/setup/Registration.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.ProgressManager;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Mod.EventBusSubscriber
public class Registration {

@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
final ProgressManager.ProgressBar bar = ProgressManager.push("Registering Items", 1);
bar.step("Registering Items");
ModItems.init();

event.getRegistry().register(ModItems.probe);
Expand All @@ -25,6 +28,7 @@ public static void registerItems(RegistryEvent.Register<Item> event) {
if (ModSetup.baubles) {
event.getRegistry().register(ModItems.probeGoggles);
}
ProgressManager.pop(bar);
}

}
2 changes: 2 additions & 0 deletions src/main/resources/assets/theoneprobe/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ theoneprobe.probe.jump_height_indicator=Jump height:
theoneprobe.probe.speed_indicator=Speed:
theoneprobe.probe.playing_indicator=Playing:
theoneprobe.probe.collar_color_indicator=Collar Color:
theoneprobe.probe.waiting_server_indicator=Waiting for server...
theoneprobe.probe.error_log_indicator=Error (see log for details)!

config.theoneprobe.config.title=The One Probe Config

Expand Down

0 comments on commit 46d968b

Please sign in to comment.