Skip to content
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
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,22 @@ _Elements 3 - 1.21.4_

- XP Meter (Basalt)
- Measure Basalt Gen's with keybind (default: none) and target XP / target time (configurable)
- Chat Enhancements
- show a LuckyDrop Summary within the LuckyDrop Message for a customizable Time (Minutes)
- Player Enhancements
- Option to hide the Own Armor or Armorpieces (Cosmetic)
- Player Level Enhancements
- Option to format level with dots as thousands separators (Player Level and Level in Player List)
- Option to format level with dots as thousands separators (Player Level, Top List Level and Level in Player List)
- Option to change the color of the player levels
- Option to change the color of the levels in the player list
- Player XP Enhancements
- Elements XP Enhancements
- Option to format XP with dots as thousands separators
- Option to change the color of the XP display
- Option to hide the max pet
- Option to show a XP/s indicator
- Option to show a XP/s indicator with customizable Calculation
- Option to make a Y-Axis offset for the XP display
- Overlay Settings
- Option for Override the AFK-Title Stay Time - INFINITY or Seconds
- Excalibur Time Display
- Show the time until the next Excalibur is available
- Show the next Player who can pull Excalibur
Expand Down
14 changes: 9 additions & 5 deletions src/client/java/dev/eposs/elementsutils/ElementsUtilsClient.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package dev.eposs.elementsutils;

import dev.eposs.elementsutils.feature.armorhide.RenderArmourCallback;
import dev.eposs.elementsutils.config.ModConfig;
import dev.eposs.elementsutils.feature.armorhide.RenderListener;
import dev.eposs.elementsutils.feature.bosstimer.BossTimerData;
import dev.eposs.elementsutils.feature.bosstimer.BossTimerDisplay;
import dev.eposs.elementsutils.feature.excaliburtimer.ExcaliburTimerData;
import dev.eposs.elementsutils.feature.excaliburtimer.ExcaliburTimerDisplay;
import dev.eposs.elementsutils.feature.excaliburtime.ExcaliburTimeData;
import dev.eposs.elementsutils.feature.excaliburtime.ExcaliburTimeDisplay;
import dev.eposs.elementsutils.feature.loot.LootSound;
import dev.eposs.elementsutils.feature.pet.PetDisplay;
import dev.eposs.elementsutils.feature.playerbase.BaseBorderDisplay;
Expand Down Expand Up @@ -48,8 +50,10 @@ public void onInitializeClient() {
registerKeyBinding();
registerEvents();

ExcaliburTimerData.startUpdateTimers();
ExcaliburTimeData.startUpdateTimers();
BossTimerData.startUpdateTimers();

RenderArmourCallback.EVENT.register(new RenderListener());
}

private void registerEvents() {
Expand Down Expand Up @@ -79,7 +83,7 @@ private void onJoin(ClientPlayNetworkHandler handler, PacketSender sender, Minec
if (server != ModConfig.InternalConfig.Servers.UNKNOWN) {
PetDisplay.loadPet(handler.getRegistryManager());
BossTimerData.updateData();
ExcaliburTimerData.updateData();
ExcaliburTimeData.updateData();
}
}

Expand Down Expand Up @@ -161,7 +165,7 @@ private void onKeyEvent(MinecraftClient client) {
BossTimerDisplay.toggleDisplay(client);
}
while (excaliburTimeToggle.wasPressed()) {
ExcaliburTimerDisplay.toggleDisplay(client);
ExcaliburTimeDisplay.toggleDisplay(client);
}
while (xpMeasureTrigger.wasPressed()) {
XpMeter.startXPMeasurement(client);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dev.eposs.elementsutils.api.timer;

import dev.eposs.elementsutils.feature.excaliburtimer.ExcaliburTimerData;
import dev.eposs.elementsutils.feature.excaliburtime.ExcaliburTimeData;

public class ExcaliburTimerApi extends AbstractTimerApi<ExcaliburTimerData> {
public class ExcaliburTimerApi extends AbstractTimerApi<ExcaliburTimeData> {
public ExcaliburTimerApi() {
super(ExcaliburTimerData.class, "https://elements-utils.eposs.dev/api/excalibur?server=$SERVER_ID");
super(ExcaliburTimeData.class, "https://elements-utils.eposs.dev/api/excalibur?server=$SERVER_ID");
}
}
64 changes: 50 additions & 14 deletions src/client/java/dev/eposs/elementsutils/config/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public static class PetData {
}
}


public boolean showMoonPhaseDisplay = true;
public boolean showTimeDisplay = true;
public boolean showPetDisplay = true;
Expand All @@ -62,9 +61,9 @@ public static class BossTimerConfig {
public boolean show = true;
public boolean textOutline = true;

public TimeFormat bossTimeFormat = TimeFormat.RELATIVE;
public boolean colorBossNames = true;
public boolean colorBossTime = true;
public TimeFormat bossTimeFormat = TimeFormat.RELATIVE;
}

@ConfigEntry.Gui.CollapsibleObject
Expand Down Expand Up @@ -96,10 +95,22 @@ public enum Position {
}

@ConfigEntry.Gui.CollapsibleObject
public XPMeterConfig xpMeterConfig = new XPMeterConfig();
public static class XPMeterConfig {
public Integer measuringXpTarget = 500;
public Integer measuringTimeTarget = 300;
public ChatEnhancementsConfig chatEnhancements = new ChatEnhancementsConfig();

public static class ChatEnhancementsConfig {
public boolean showLuckyDropSummary = false;
public int luckyDropSummaryMinutes = 60;
}

@ConfigEntry.Gui.CollapsibleObject
public PlayerEnhancementsConfig playerEnhancements = new PlayerEnhancementsConfig();

public static class PlayerEnhancementsConfig {
public boolean hideOwnArmor = false;
public boolean hideHelmet = true;
public boolean hideChestplate = true;
public boolean hideLeggings = true;
public boolean hideBoots = false;
}

@ConfigEntry.Gui.CollapsibleObject
Expand All @@ -110,6 +121,35 @@ public static class PlayerLevelConfig {
public KnownColor formattedPlayerListLevelColor = KnownColor.YELLOW;
}

@ConfigEntry.Gui.CollapsibleObject
public ElementsXPConfig elementsXPConfig = new ElementsXPConfig();
public static class ElementsXPConfig {
public boolean enabled = true;
public boolean showXpPerSecond = false;
public KnownColor xpPerSecondColor = KnownColor.GRAY;
public int maxAgeSeconds = 20;
public int resetTimeoutSeconds = 5;
public KnownColor overlayMessageColor = KnownColor.DARK_AQUA;
public boolean hideMaxPetXP = false;
public int overlayMessageYOffset = 0;
}

@ConfigEntry.Gui.CollapsibleObject
public OverlaySettingsConfig overlaySettings = new OverlaySettingsConfig();
public static class OverlaySettingsConfig {
public boolean overrideAfkTitleTime = false;

@ConfigEntry.Gui.Tooltip
public AfkTitleTimeType afkTitleTimeType = AfkTitleTimeType.INFINITY;

public int afkTitleTimeSeconds = 30;

public enum AfkTitleTimeType {
INFINITY,
SECONDS
}
}

public enum KnownColor {
BLACK(0x000000),
DARK_BLUE(0x0000AA),
Expand All @@ -134,14 +174,10 @@ public enum KnownColor {
}

@ConfigEntry.Gui.CollapsibleObject
public PlayerXPConfig playerXPConfig = new PlayerXPConfig();
public static class PlayerXPConfig {
public boolean enabled = true;
public boolean showXpPerSecond = false;
public KnownColor xpPerSecondColor = KnownColor.GRAY;
public KnownColor overlayMessageColor = KnownColor.DARK_AQUA;
public boolean hideMaxPetXP = false;
public int overlayMessageYOffset = 0;
public XPMeterConfig xpMeterConfig = new XPMeterConfig();
public static class XPMeterConfig {
public Integer measuringXpTarget = 500;
public Integer measuringTimeTarget = 300;
}

@ConfigEntry.Gui.CollapsibleObject
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package dev.eposs.elementsutils.feature.armorhide;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.render.entity.state.BipedEntityRenderState;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;

/**
* Callback interface for intercepting armor rendering.
* Implementations can cancel or modify the rendering of armor pieces.
*/
@Environment(EnvType.CLIENT)
public interface RenderArmourCallback {
/**
* Event for registering {@link RenderArmourCallback} listeners.
* All listeners are called in order; the first non-PASS result is used.
*/
Event<RenderArmourCallback> EVENT = EventFactory.createArrayBacked(RenderArmourCallback.class,
listeners -> (renderer, matrices, vertexConsumers, state, stack, slot, light, armorModel) -> {
for (RenderArmourCallback listener : listeners) {
ActionResult result = listener.preRenderArmour(renderer, matrices, vertexConsumers, state, stack, slot, light, armorModel);
if (result != ActionResult.PASS) {
return result;
}
}
return ActionResult.PASS;
});

/**
* Called before an armor piece is rendered.
* Return {@link ActionResult#FAIL} to cancel rendering, or {@link ActionResult#PASS} to allow it.
*
* @param renderer The armor feature renderer instance
* @param matrices The matrix stack for rendering
* @param vertexConsumers The vertex consumer provider
* @param state The render state of the entity
* @param stack The item stack of the armor
* @param slot The equipment slot
* @param light The light value
* @param armorModel The armor model
* @return {@link ActionResult#FAIL} to cancel rendering, {@link ActionResult#PASS} otherwise
*/
ActionResult preRenderArmour(
ArmorFeatureRenderer<?, ?, ?> renderer,
MatrixStack matrices,
VertexConsumerProvider vertexConsumers,
BipedEntityRenderState state,
ItemStack stack,
EquipmentSlot slot,
int light,
BipedEntityModel<?> armorModel
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package dev.eposs.elementsutils.feature.armorhide;

import dev.eposs.elementsutils.config.ModConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.render.entity.state.BipedEntityRenderState;
import net.minecraft.client.render.entity.state.PlayerEntityRenderState;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;

/**
* Listener for the RenderArmourCallback event.
* Prevents rendering of the player's own armor depending on config options.
*/
@Environment(EnvType.CLIENT)
public class RenderListener implements RenderArmourCallback {
/**
* Called before rendering an armor piece.
* Cancels rendering for the local player if the corresponding config option is enabled.
*
* @param instance The armor feature renderer instance
* @param matrices The matrix stack for rendering
* @param vertexConsumers The vertex consumer provider
* @param bipedEntityRenderState The render state of the entity
* @param stack The item stack of the armor
* @param slot The equipment slot
* @param light The light value
* @param armorModel The armor model
* @return ActionResult.FAIL to cancel rendering, ActionResult.PASS otherwise
*/
@Override
public ActionResult preRenderArmour(
ArmorFeatureRenderer<?, ?, ?> instance,
MatrixStack matrices,
VertexConsumerProvider vertexConsumers,
BipedEntityRenderState bipedEntityRenderState,
ItemStack stack,
EquipmentSlot slot,
int light,
BipedEntityModel<?> armorModel
) {
ModConfig.PlayerEnhancementsConfig config = ModConfig.getConfig().playerEnhancements;
ClientPlayerEntity player = MinecraftClient.getInstance().player;

if (config.hideOwnArmor
&& bipedEntityRenderState instanceof PlayerEntityRenderState pers
&& player != null
&& player.getId() == pers.id) {

// Check slot-specific visibility
boolean hide = switch (slot) {
case HEAD -> config.hideHelmet;
case CHEST -> config.hideChestplate;
case LEGS -> config.hideLeggings;
case FEET -> config.hideBoots;
default -> false;
};
return hide ? ActionResult.FAIL : ActionResult.PASS;
}
return ActionResult.PASS;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.eposs.elementsutils.feature.excaliburtimer;
package dev.eposs.elementsutils.feature.excaliburtime;

import dev.eposs.elementsutils.api.timer.ExcaliburTimerApi;
import dev.eposs.elementsutils.util.TimerUtil;
Expand All @@ -11,17 +11,17 @@
import java.util.concurrent.atomic.AtomicReference;


public class ExcaliburTimerData {
public class ExcaliburTimeData {

private String next_user;
private String time;

private static final AtomicReference<ExcaliburTimerData> INSTANCE = new AtomicReference<>(new ExcaliburTimerData());
private static final AtomicReference<ExcaliburTimeData> INSTANCE = new AtomicReference<>(new ExcaliburTimeData());

private static Instant lastUpdate = Instant.MIN;

public static void startUpdateTimers() {
new Timer("ExcaliburTimerData Update Timer").scheduleAtFixedRate(new TimerTask() {
new Timer("ExcaliburTimeData Update Timer").scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
updateData();
Expand All @@ -33,16 +33,16 @@ public static void updateData() {
// Only update data every 10 seconds to prevent spamming the API
if (lastUpdate.isAfter(Instant.now().minusSeconds(10))) return;

Thread.ofVirtual().name("ExcaliburTimerData Update Thread").start(() -> {
Thread.ofVirtual().name("ExcaliburTimeData Update Thread").start(() -> {
lastUpdate = Instant.now();
ExcaliburTimerData data = new ExcaliburTimerApi().getTimerData();
ExcaliburTimeData data = new ExcaliburTimerApi().getTimerData();
if (data != null) {
INSTANCE.set(data);
}
});
}

public static ExcaliburTimerData getInstance() {
public static ExcaliburTimeData getInstance() {
return INSTANCE.get();
}

Expand Down
Loading