diff --git a/gradle.properties b/gradle.properties index ecd953e2..a542297a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx2G -mod_version = 1.1.6 +mod_version = 1.1.7 maven_group = red.jackf archives_base_name = chesttracker @@ -19,6 +19,6 @@ cloth_client_version=2.0.54 modmenu_version=3.0.0 libgui_version=5.0.0-beta.2+1.18-rc1 -whereisit_version=1.14.4 +whereisit_version=1.14.6 expanded_storage_file_id=3539944 ninjaphenix_container_lib_file_id=3539922 diff --git a/src/main/java/red/jackf/chesttracker/ChestTracker.java b/src/main/java/red/jackf/chesttracker/ChestTracker.java index 914cb801..43f7d776 100644 --- a/src/main/java/red/jackf/chesttracker/ChestTracker.java +++ b/src/main/java/red/jackf/chesttracker/ChestTracker.java @@ -44,9 +44,11 @@ import red.jackf.chesttracker.memory.MemoryDatabase; import red.jackf.chesttracker.memory.MemoryUtils; import red.jackf.chesttracker.resource.ButtonPositionManager; +import red.jackf.whereisit.WhereIsIt; import red.jackf.whereisit.WhereIsItClient; import red.jackf.whereisit.client.PositionData; import red.jackf.whereisit.client.RenderUtils; +import red.jackf.whereisit.compat.OptifineHooks; import java.util.Collection; @@ -116,6 +118,7 @@ public static int sliderValueToRange(int sliderValue) { } public static void drawLabels(WorldRenderContext context) { + if (ChestTracker.CONFIG.visualOptions.nameRenderRange == 0) return; MemoryDatabase database = MemoryDatabase.getCurrent(); if (database == null) return; MinecraftClient mc = MinecraftClient.getInstance(); @@ -124,10 +127,12 @@ public static void drawLabels(WorldRenderContext context) { Collection toRender = database.getNamedMemories(mc.world.getRegistryKey().getValue()); for (Memory memory : toRender) { BlockPos blockPos = memory.getPosition(); - if (blockPos != null && memory.getTitle() != null && !RenderUtils.FOUND_ITEM_POSITIONS.containsKey(blockPos)) { + boolean alreadyHandled = WhereIsIt.CONFIG.shouldShowResultLabels() && RenderUtils.FOUND_ITEM_POSITIONS.containsKey(blockPos); + if (blockPos != null && memory.getTitle() != null && !alreadyHandled) { Vec3d pos = Vec3d.of(blockPos); if (memory.getNameOffset() != null) pos = pos.add(memory.getNameOffset()); - RenderUtils.drawTextWithBackground(context, pos, memory.getTitle(), CONFIG.visualOptions.nameRenderRange); + if (!context.world().getBlockState(blockPos.up()).isOpaque()) pos = pos.add(0, 1d, 0); + RenderUtils.drawTextWithBackground(context, pos, memory.getTitle(), CONFIG.visualOptions.nameRenderRange, true); } } } @@ -143,7 +148,12 @@ public void onInitializeClient() { if (database != null) database.save(); }); - WorldRenderEvents.AFTER_ENTITIES.register(ChestTracker::drawLabels); + WorldRenderEvents.BEFORE_BLOCK_OUTLINE.register((context, hitResult) -> { + OptifineHooks.doOptifineAwareRender(context, (context1, simple) -> { + ChestTracker.drawLabels(context1); + }); + return true; + }); WhereIsItClient.SEARCH_FOR_ITEM.register((item, matchNbt, compoundTag) -> { ItemStack stack = new ItemStack(item); diff --git a/src/main/java/red/jackf/chesttracker/config/ChestTrackerConfig.java b/src/main/java/red/jackf/chesttracker/config/ChestTrackerConfig.java index e2617c29..a04f8913 100644 --- a/src/main/java/red/jackf/chesttracker/config/ChestTrackerConfig.java +++ b/src/main/java/red/jackf/chesttracker/config/ChestTrackerConfig.java @@ -30,7 +30,7 @@ public class ChestTrackerConfig implements ConfigData { @Override public void validatePostLoad() { visualOptions.borderColour = MathHelper.clamp(visualOptions.borderColour, 0, 0xffffff); - visualOptions.nameRenderRange = MathHelper.clamp(visualOptions.nameRenderRange, 1, 16); + visualOptions.nameRenderRange = MathHelper.clamp(visualOptions.nameRenderRange, 0, 16); visualOptions.rowCount = MathHelper.clamp(visualOptions.rowCount, 6, 12); visualOptions.columnCount = MathHelper.clamp(visualOptions.columnCount, 9, 18); databaseOptions.destroyedMemoryCheckInterval = MathHelper.clamp(databaseOptions.destroyedMemoryCheckInterval, 0, 60); @@ -40,7 +40,7 @@ public void validatePostLoad() { public static class VisualOptions { @ConfigEntry.ColorPicker public int borderColour = 0x00baff; - @ConfigEntry.BoundedDiscrete(min = 1, max = 16) + @ConfigEntry.BoundedDiscrete(min = 0, max = 16) public int nameRenderRange = 12; @ConfigEntry.BoundedDiscrete(min = 6, max = 12) public int rowCount = 6; diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 97c9080a..e503e7c9 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -61,7 +61,7 @@ "fabricloader": ">=0.7.4", "fabric": "*", "minecraft": "1.18.x", - "whereisit": ">=1.12.0", + "whereisit": ">=1.14.6", "cloth-config2": ">=6.0.0" }, "suggests": {