diff options
author | Linnea Gräf <nea@nea.moe> | 2023-11-27 17:34:53 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2023-11-27 17:34:53 +0100 |
commit | 899811d475202ac4c1cf9b807493cf99d12a3760 (patch) | |
tree | 0584da8cbe8a351e478045ad8795d0420fbb82ca | |
parent | de0accead4110bf9aa49e4de7202b8d4da55ecff (diff) | |
download | NotEnoughUpdates-899811d475202ac4c1cf9b807493cf99d12a3760.tar.gz NotEnoughUpdates-899811d475202ac4c1cf9b807493cf99d12a3760.tar.bz2 NotEnoughUpdates-899811d475202ac4c1cf9b807493cf99d12a3760.zip |
Add more custom icons to neu custom todosmorecustomtodoicons
3 files changed, 21 insertions, 12 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java index ca244303..cf111078 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -22,6 +22,7 @@ package io.github.moulberry.notenoughupdates.overlays; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.events.SlotClickEvent; +import io.github.moulberry.notenoughupdates.miscgui.customtodos.CustomTodo; import io.github.moulberry.notenoughupdates.miscgui.customtodos.CustomTodoHud; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.ItemUtils; @@ -174,11 +175,7 @@ public class TimersOverlay extends TextTabOverlay { String clean = Utils.cleanColour(line); String beforeColon = clean.split(":")[0]; if (beforeColon.startsWith("CUSTOM")) { - var item = Item.getByNameOrId(beforeColon.substring(6)); - if (item == null) { - item = Items.paper; - } - icon = new ItemStack(item); + icon = CustomTodoHud.INSTANCE.parseItem(CustomTodoHud.INSTANCE.decodeCustomItem(beforeColon)); } else switch (beforeColon) { case "Cakes": diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoEditor.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoEditor.kt index b0dab0f6..922240ed 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoEditor.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoEditor.kt @@ -21,7 +21,6 @@ package io.github.moulberry.notenoughupdates.miscgui.customtodos import io.github.moulberry.moulconfig.common.IItemStack import io.github.moulberry.moulconfig.forge.ForgeItemStack -import io.github.moulberry.moulconfig.gui.CloseEventListener import io.github.moulberry.moulconfig.internal.ClipboardUtils import io.github.moulberry.moulconfig.observer.ObservableList import io.github.moulberry.moulconfig.xml.Bind @@ -30,9 +29,6 @@ import io.github.moulberry.notenoughupdates.util.SBInfo import io.github.moulberry.notenoughupdates.util.Utils import io.github.moulberry.notenoughupdates.util.loadResourceLocation import net.minecraft.client.Minecraft -import net.minecraft.init.Items -import net.minecraft.item.Item -import net.minecraft.item.ItemStack import net.minecraft.util.ResourceLocation class CustomTodoEditor( @@ -160,8 +156,8 @@ class CustomTodoEditor( @Bind fun getItemStack(): IItemStack { - val item = Item.getByNameOrId(icon) ?: (Items.paper) - return ForgeItemStack.of(ItemStack(item)) + val item = CustomTodoHud.parseItem(icon) + return ForgeItemStack.of(item) } @Bind diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoHud.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoHud.kt index 591bcedb..83d162f6 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoHud.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoHud.kt @@ -24,10 +24,14 @@ import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe import io.github.moulberry.notenoughupdates.core.util.StringUtils import io.github.moulberry.notenoughupdates.events.SidebarChangeEvent import io.github.moulberry.notenoughupdates.events.TabListChangeEvent +import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor import io.github.moulberry.notenoughupdates.util.Utils +import net.minecraft.init.Items +import net.minecraft.item.ItemStack import net.minecraft.util.EnumChatFormatting import net.minecraftforge.client.event.ClientChatReceivedEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.* @NEUAutoSubscribe object CustomTodoHud { @@ -86,6 +90,13 @@ object CustomTodoHud { } } + fun encodeCustomItem(icon: String) = "CUSTOM" + Base64.getEncoder().encodeToString(icon.encodeToByteArray()) + + fun decodeCustomItem(customString: String): String { + require(customString.startsWith("CUSTOM")) + return Base64.getDecoder().decode(customString.substring(6)).decodeToString() + } + @JvmStatic fun processInto(strings: MutableList<String>) { NotEnoughUpdates.INSTANCE.config.hidden.customTodos @@ -94,7 +105,7 @@ object CustomTodoHud { val readyAt = it.readyAtOnCurrentProfile ?: (System.currentTimeMillis() - 1000L) val until = readyAt - System.currentTimeMillis() strings.add( - "CUSTOM" + it.icon + ":§3" + it.label + ": " + + encodeCustomItem(it.icon) + ":§3" + it.label + ": " + if (until <= 0) EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour].toString() + "Ready" else if (until < 60 * 30 * 1000L) @@ -113,4 +124,9 @@ object CustomTodoHud { } } + fun parseItem(icon: String): ItemStack { + val stack = GuiInvButtonEditor.getStack(icon.uppercase()) + if (stack.metadata == 255 || (stack.item == Items.painting && stack.metadata != 0)) return ItemStack(Items.paper) + return stack + } } |