From e3344f636e48bb56e9dd028760b69134cce19c49 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 26 Mar 2023 16:56:42 +0200 Subject: Added Teleport Pad Compact Name - Hide the 'Warp to' and 'No Destination' texts over teleport pads. --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 1 + .../hannibal2/skyhanni/config/features/Garden.java | 11 ++++++++ .../garden/GardenTeleportPadCompactName.kt | 32 ++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/GardenTeleportPadCompactName.kt (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index f3909ebce..00a4e68d1 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -232,6 +232,7 @@ public class SkyHanniMod { loadModule(new FarmingArmorDrops()); loadModule(new JoinCrystalHollows()); loadModule(new GardenVisitorColorNames()); + loadModule(new GardenTeleportPadCompactName()); Commands.INSTANCE.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index eacdea6cd..06056903e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -566,6 +566,17 @@ public class Garden { @Expose public Position farmingArmorDropsPos = new Position(16, -232, false, true); + @Expose + @ConfigOption(name = "Teleport Pads", desc = "") + @ConfigEditorAccordion(id = 12) + public boolean teleportPads = false; + + @Expose + @ConfigOption(name = "Compact Name", desc = "Hide the 'Warp to' and 'No Destination' texts over teleport pads.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 12) + public boolean teleportPadsCompactName = false; + @Expose @ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenTeleportPadCompactName.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenTeleportPadCompactName.kt new file mode 100644 index 000000000..95e50dff2 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenTeleportPadCompactName.kt @@ -0,0 +1,32 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.item.EntityArmorStand +import net.minecraftforge.client.event.RenderLivingEvent +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.regex.Pattern + +class GardenTeleportPadCompactName { + private val patternName = Pattern.compile("§.✦ §aWarp To (.*)") + private val patternNoName = Pattern.compile("§.✦ §cNo Destination") + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onRenderLivingB(event: RenderLivingEvent.Specials.Pre) { + if (!SkyHanniMod.feature.garden.teleportPadsCompactName) return + val entity = event.entity + if (entity !is EntityArmorStand) return + + val name = entity.name + + if (patternNoName.matcher(name).matches()) { + event.isCanceled = true + } + + val matcher = patternName.matcher(name) + if (matcher.matches()) { + entity.customNameTag = matcher.group(1) + } + } +} \ No newline at end of file -- cgit