diff options
Diffstat (limited to 'src/main/kotlin/gui')
-rw-r--r-- | src/main/kotlin/gui/BarComponent.kt | 8 | ||||
-rw-r--r-- | src/main/kotlin/gui/FirmButtonComponent.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/gui/FirmHoverComponent.kt | 90 | ||||
-rw-r--r-- | src/main/kotlin/gui/ImageComponent.kt | 44 | ||||
-rw-r--r-- | src/main/kotlin/gui/config/AllConfigsGui.kt | 24 | ||||
-rw-r--r-- | src/main/kotlin/gui/config/BuiltInConfigScreenProvider.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/gui/config/ColourHandler.kt | 82 | ||||
-rw-r--r-- | src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/gui/config/KeyBindingHandler.kt | 29 | ||||
-rw-r--r-- | src/main/kotlin/gui/config/KeyBindingStateManager.kt | 44 | ||||
-rw-r--r-- | src/main/kotlin/gui/config/ManagedConfig.kt | 8 | ||||
-rw-r--r-- | src/main/kotlin/gui/config/ManagedOption.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/gui/entity/EntityRenderer.kt | 88 | ||||
-rw-r--r-- | src/main/kotlin/gui/entity/ModifyEquipment.kt | 6 |
14 files changed, 293 insertions, 138 deletions
diff --git a/src/main/kotlin/gui/BarComponent.kt b/src/main/kotlin/gui/BarComponent.kt index b82c666..da781da 100644 --- a/src/main/kotlin/gui/BarComponent.kt +++ b/src/main/kotlin/gui/BarComponent.kt @@ -113,11 +113,3 @@ class BarComponent( fun Identifier.toMoulConfig(): MyResourceLocation { return MyResourceLocation(this.namespace, this.path) } - -fun RenderContext.color(color: Color) { - color(color.red, color.green, color.blue, color.alpha) -} - -fun RenderContext.color(red: Int, green: Int, blue: Int, alpha: Int) { - color(red / 255f, green / 255f, blue / 255f, alpha / 255f) -} diff --git a/src/main/kotlin/gui/FirmButtonComponent.kt b/src/main/kotlin/gui/FirmButtonComponent.kt index 82e5b05..fe9b476 100644 --- a/src/main/kotlin/gui/FirmButtonComponent.kt +++ b/src/main/kotlin/gui/FirmButtonComponent.kt @@ -74,7 +74,7 @@ open class FirmButtonComponent( getBackground(context), 0f, 0f, context.width, context.height ) - context.renderContext.translate(insets.toFloat(), insets.toFloat(), 0f) + context.renderContext.translate(insets.toFloat(), insets.toFloat()) element.render(getChildContext(context)) context.renderContext.popMatrix() } diff --git a/src/main/kotlin/gui/FirmHoverComponent.kt b/src/main/kotlin/gui/FirmHoverComponent.kt index b1792ce..e38582a 100644 --- a/src/main/kotlin/gui/FirmHoverComponent.kt +++ b/src/main/kotlin/gui/FirmHoverComponent.kt @@ -10,50 +10,50 @@ import kotlin.time.Duration import moe.nea.firmament.util.TimeMark class FirmHoverComponent( - val child: GuiComponent, - val hoverLines: Supplier<List<String>>, - val hoverDelay: Duration, + val child: GuiComponent, + val hoverLines: Supplier<List<String>>, + val hoverDelay: Duration, ) : GuiComponent() { - override fun getWidth(): Int { - return child.width - } - - override fun getHeight(): Int { - return child.height - } - - override fun <T : Any?> foldChildren( - initial: T, - visitor: BiFunction<GuiComponent, T, T> - ): T { - return visitor.apply(child, initial) - } - - override fun render(context: GuiImmediateContext) { - if (context.isHovered && (permaHover || lastMouseMove.passedTime() > hoverDelay)) { - context.renderContext.scheduleDrawTooltip(hoverLines.get()) - permaHover = true - } else { - permaHover = false - } - if (!context.isHovered) { - lastMouseMove = TimeMark.now() - } - child.render(context) - - } - - var permaHover = false - var lastMouseMove = TimeMark.farPast() - - override fun mouseEvent(mouseEvent: MouseEvent, context: GuiImmediateContext): Boolean { - if (mouseEvent is MouseEvent.Move) { - lastMouseMove = TimeMark.now() - } - return child.mouseEvent(mouseEvent, context) - } - - override fun keyboardEvent(event: KeyboardEvent, context: GuiImmediateContext): Boolean { - return child.keyboardEvent(event, context) - } + override fun getWidth(): Int { + return child.width + } + + override fun getHeight(): Int { + return child.height + } + + override fun <T : Any?> foldChildren( + initial: T, + visitor: BiFunction<GuiComponent, T, T> + ): T { + return visitor.apply(child, initial) + } + + override fun render(context: GuiImmediateContext) { + if (context.isHovered && (permaHover || lastMouseMove.passedTime() > hoverDelay)) { + context.renderContext.scheduleDrawTooltip(context.mouseX, context.mouseY, hoverLines.get()) + permaHover = true + } else { + permaHover = false + } + if (!context.isHovered) { + lastMouseMove = TimeMark.now() + } + child.render(context) + + } + + var permaHover = false + var lastMouseMove = TimeMark.farPast() + + override fun mouseEvent(mouseEvent: MouseEvent, context: GuiImmediateContext): Boolean { + if (mouseEvent is MouseEvent.Move) { + lastMouseMove = TimeMark.now() + } + return child.mouseEvent(mouseEvent, context) + } + + override fun keyboardEvent(event: KeyboardEvent, context: GuiImmediateContext): Boolean { + return child.keyboardEvent(event, context) + } } diff --git a/src/main/kotlin/gui/ImageComponent.kt b/src/main/kotlin/gui/ImageComponent.kt index bba7dee..695c0ed 100644 --- a/src/main/kotlin/gui/ImageComponent.kt +++ b/src/main/kotlin/gui/ImageComponent.kt @@ -6,28 +6,30 @@ import io.github.notenoughupdates.moulconfig.gui.GuiImmediateContext import java.util.function.Supplier class ImageComponent( - private val width: Int, - private val height: Int, - val resourceLocation: Supplier<MyResourceLocation>, - val u1: Float, - val u2: Float, - val v1: Float, - val v2: Float, + private val width: Int, + private val height: Int, + val resourceLocation: Supplier<MyResourceLocation>, + val u1: Float, + val u2: Float, + val v1: Float, + val v2: Float, ) : GuiComponent() { - override fun getWidth(): Int { - return width - } + override fun getWidth(): Int { + return width + } - override fun getHeight(): Int { - return height - } + override fun getHeight(): Int { + return height + } - override fun render(context: GuiImmediateContext) { - context.renderContext.bindTexture(resourceLocation.get()) - context.renderContext.drawTexturedRect( - 0f, 0f, - context.width.toFloat(), context.height.toFloat(), - u1, v1, u2, v2 - ) - } + override fun render(context: GuiImmediateContext) { + context.renderContext.drawComplexTexture( + resourceLocation.get(), + 0f, 0f, + context.width.toFloat(), context.height.toFloat(), + { + it.uv(u1, v1, u2, v2) + } + ) + } } diff --git a/src/main/kotlin/gui/config/AllConfigsGui.kt b/src/main/kotlin/gui/config/AllConfigsGui.kt index 73ff444..f9ffd2d 100644 --- a/src/main/kotlin/gui/config/AllConfigsGui.kt +++ b/src/main/kotlin/gui/config/AllConfigsGui.kt @@ -4,6 +4,12 @@ import io.github.notenoughupdates.moulconfig.observer.ObservableList import io.github.notenoughupdates.moulconfig.xml.Bind import net.minecraft.client.gui.screen.Screen import net.minecraft.text.Text +import moe.nea.firmament.annotations.Subscribe +import moe.nea.firmament.commands.RestArgumentType +import moe.nea.firmament.commands.get +import moe.nea.firmament.commands.thenArgument +import moe.nea.firmament.commands.thenExecute +import moe.nea.firmament.events.CommandEvent import moe.nea.firmament.util.MC import moe.nea.firmament.util.MoulConfigUtils import moe.nea.firmament.util.ScreenUtil.setScreenLater @@ -18,6 +24,7 @@ object AllConfigsGui { object ConfigConfig : ManagedConfig("configconfig", Category.META) { val enableYacl by toggle("enable-yacl") { false } val enableMoulConfig by toggle("enable-moulconfig") { true } + val enableWideMC by toggle("wide-moulconfig") { false } } fun <T> List<T>.toObservableList(): ObservableList<T> = ObservableList(this) @@ -66,7 +73,7 @@ object AllConfigsGui { return MoulConfigUtils.loadScreen("config/main", CategoryView(), parent) } - fun makeScreen(parent: Screen? = null): Screen { + fun makeScreen(search: String? = null, parent: Screen? = null): Screen { val wantedKey = when { ConfigConfig.enableMoulConfig -> "moulconfig" ConfigConfig.enableYacl -> "yacl" @@ -74,10 +81,23 @@ object AllConfigsGui { } val provider = FirmamentConfigScreenProvider.providers.find { it.key == wantedKey } ?: FirmamentConfigScreenProvider.providers.first() - return provider.open(parent) + return provider.open(search, parent) } fun showAllGuis() { setScreenLater(makeScreen()) } + + @Subscribe + fun registerCommands(event: CommandEvent.SubCommand) { + event.subcommand("search") { + thenArgument("search", RestArgumentType) { search -> + thenExecute { + val search = this[search] + setScreenLater(makeScreen(search = search)) + } + } + } + } + } diff --git a/src/main/kotlin/gui/config/BuiltInConfigScreenProvider.kt b/src/main/kotlin/gui/config/BuiltInConfigScreenProvider.kt index 19e7383..8ecdfa2 100644 --- a/src/main/kotlin/gui/config/BuiltInConfigScreenProvider.kt +++ b/src/main/kotlin/gui/config/BuiltInConfigScreenProvider.kt @@ -8,7 +8,7 @@ class BuiltInConfigScreenProvider : FirmamentConfigScreenProvider { override val key: String get() = "builtin" - override fun open(parent: Screen?): Screen { + override fun open(search: String?, parent: Screen?): Screen { return AllConfigsGui.makeBuiltInScreen(parent) } } diff --git a/src/main/kotlin/gui/config/ColourHandler.kt b/src/main/kotlin/gui/config/ColourHandler.kt new file mode 100644 index 0000000..7d121ab --- /dev/null +++ b/src/main/kotlin/gui/config/ColourHandler.kt @@ -0,0 +1,82 @@ +package moe.nea.firmament.gui.config + +import io.github.notenoughupdates.moulconfig.ChromaColour +import io.github.notenoughupdates.moulconfig.gui.component.ColorSelectComponent +import kotlinx.serialization.KSerializer +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.JsonElement + +class ColourHandler(val config: ManagedConfig) : + ManagedConfig.OptionHandler<ChromaColour> { + @Serializable + data class ChromaDelegate( + @SerialName("h") + val hue: Float, + @SerialName("s") + val saturation: Float, + @SerialName("b") + val brightness: Float, + @SerialName("a") + val alpha: Int, + @SerialName("c") + val timeForFullRotationInMillis: Int, + ) { + constructor(delegate: ChromaColour) : this( + delegate.hue, + delegate.saturation, + delegate.brightness, + delegate.alpha, + delegate.timeForFullRotationInMillis + ) + + fun into(): ChromaColour = ChromaColour(hue, saturation, brightness, alpha, timeForFullRotationInMillis) + } + + object ChromaSerializer : KSerializer<ChromaColour> { + override val descriptor: SerialDescriptor + get() = SerialDescriptor("FirmChromaColour", ChromaDelegate.serializer().descriptor) + + override fun serialize( + encoder: Encoder, + value: ChromaColour + ) { + encoder.encodeSerializableValue(ChromaDelegate.serializer(), ChromaDelegate(value)) + } + + override fun deserialize(decoder: Decoder): ChromaColour { + return decoder.decodeSerializableValue(ChromaDelegate.serializer()).into() + } + } + + override fun toJson(element: ChromaColour): JsonElement? { + return Json.encodeToJsonElement(ChromaSerializer, element) + } + + override fun fromJson(element: JsonElement): ChromaColour { + return Json.decodeFromJsonElement(ChromaSerializer, element) + } + + override fun emitGuiElements( + opt: ManagedOption<ChromaColour>, + guiAppender: GuiAppender + ) { + guiAppender.appendLabeledRow( + opt.labelText, + ColorSelectComponent( + 0, + 0, + opt.value.toLegacyString(), + { + opt.value = ChromaColour.forLegacyString(it) + config.save() + }, + { } + ) + ) + } +} diff --git a/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt b/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt index faad1cc..8700ffa 100644 --- a/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt +++ b/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt @@ -7,7 +7,7 @@ interface FirmamentConfigScreenProvider { val key: String val isEnabled: Boolean get() = true - fun open(parent: Screen?): Screen + fun open(search: String?, parent: Screen?): Screen companion object : CompatLoader<FirmamentConfigScreenProvider>(FirmamentConfigScreenProvider::class) { val providers by lazy { diff --git a/src/main/kotlin/gui/config/KeyBindingHandler.kt b/src/main/kotlin/gui/config/KeyBindingHandler.kt index d7d0b47..14a4b32 100644 --- a/src/main/kotlin/gui/config/KeyBindingHandler.kt +++ b/src/main/kotlin/gui/config/KeyBindingHandler.kt @@ -40,34 +40,7 @@ class KeyBindingHandler(val name: String, val managedConfig: ManagedConfig) : { button.blur() }, { button.requestFocus() } ) - button = object : FirmButtonComponent( - TextComponent( - IMinecraft.instance.defaultFontRenderer, - { sm.label.string }, - 130, - TextComponent.TextAlignment.LEFT, - false, - false - ), action = { - sm.onClick() - }) { - override fun keyboardEvent(event: KeyboardEvent, context: GuiImmediateContext): Boolean { - if (event is KeyboardEvent.KeyPressed) { - return sm.keyboardEvent(event.keycode, event.pressed) - } - return super.keyboardEvent(event, context) - } - - override fun getBackground(context: GuiImmediateContext): NinePatch<MyResourceLocation> { - if (sm.editing) return activeBg - return super.getBackground(context) - } - - - override fun onLostFocus() { - sm.onLostFocus() - } - } + button = sm.createButton() sm.updateLabel() return button } diff --git a/src/main/kotlin/gui/config/KeyBindingStateManager.kt b/src/main/kotlin/gui/config/KeyBindingStateManager.kt index cc8178d..1528ac4 100644 --- a/src/main/kotlin/gui/config/KeyBindingStateManager.kt +++ b/src/main/kotlin/gui/config/KeyBindingStateManager.kt @@ -1,8 +1,15 @@ package moe.nea.firmament.gui.config +import io.github.notenoughupdates.moulconfig.common.IMinecraft +import io.github.notenoughupdates.moulconfig.common.MyResourceLocation +import io.github.notenoughupdates.moulconfig.deps.libninepatch.NinePatch +import io.github.notenoughupdates.moulconfig.gui.GuiImmediateContext +import io.github.notenoughupdates.moulconfig.gui.KeyboardEvent +import io.github.notenoughupdates.moulconfig.gui.component.TextComponent import org.lwjgl.glfw.GLFW import net.minecraft.text.Text import net.minecraft.util.Formatting +import moe.nea.firmament.gui.FirmButtonComponent import moe.nea.firmament.keybindings.SavedKeyBinding class KeyBindingStateManager( @@ -51,9 +58,11 @@ class KeyBindingStateManager( ) { lastPressed = ch } else { - setValue(SavedKeyBinding( - ch, modifiers - )) + setValue( + SavedKeyBinding( + ch, modifiers + ) + ) editing = false blur() lastPressed = 0 @@ -104,5 +113,34 @@ class KeyBindingStateManager( label = stroke } + fun createButton(): FirmButtonComponent { + return object : FirmButtonComponent( + TextComponent( + IMinecraft.instance.defaultFontRenderer, + { this@KeyBindingStateManager.label.string }, + 130, + TextComponent.TextAlignment.LEFT, + false, + false + ), action = { + this@KeyBindingStateManager.onClick() + }) { + override fun keyboardEvent(event: KeyboardEvent, context: GuiImmediateContext): Boolean { + if (event is KeyboardEvent.KeyPressed) { + return this@KeyBindingStateManager.keyboardEvent(event.keycode, event.pressed) + } + return super.keyboardEvent(event, context) + } + + override fun getBackground(context: GuiImmediateContext): NinePatch<MyResourceLocation> { + if (this@KeyBindingStateManager.editing) return activeBg + return super.getBackground(context) + } + + override fun onLostFocus() { + this@KeyBindingStateManager.onLostFocus() + } + } + } } diff --git a/src/main/kotlin/gui/config/ManagedConfig.kt b/src/main/kotlin/gui/config/ManagedConfig.kt index 7ddda9e..12b82d6 100644 --- a/src/main/kotlin/gui/config/ManagedConfig.kt +++ b/src/main/kotlin/gui/config/ManagedConfig.kt @@ -1,6 +1,7 @@ package moe.nea.firmament.gui.config import com.mojang.serialization.Codec +import io.github.notenoughupdates.moulconfig.ChromaColour import io.github.notenoughupdates.moulconfig.gui.CloseEventListener import io.github.notenoughupdates.moulconfig.gui.GuiComponentWrapper import io.github.notenoughupdates.moulconfig.gui.GuiContext @@ -38,7 +39,9 @@ abstract class ManagedConfig( MISC, CHAT, INVENTORY, + ITEMS, MINING, + GARDEN, EVENTS, INTEGRATIONS, META, @@ -69,6 +72,7 @@ abstract class ManagedConfig( category.configs.add(this) } + // TODO: warn if two files use the same config file name :( val file = Firmament.CONFIG_DIR.resolve("$name.json") val data: JsonObject by lazy { try { @@ -115,6 +119,10 @@ abstract class ManagedConfig( return option(propertyName, default, BooleanHandler(this)) } + protected fun colour(propertyName: String, default: ()-> ChromaColour) : ManagedOption<ChromaColour> { + return option(propertyName, default, ColourHandler(this)) + } + protected fun <E> choice( propertyName: String, enumClass: Class<E>, diff --git a/src/main/kotlin/gui/config/ManagedOption.kt b/src/main/kotlin/gui/config/ManagedOption.kt index 383f392..830086c 100644 --- a/src/main/kotlin/gui/config/ManagedOption.kt +++ b/src/main/kotlin/gui/config/ManagedOption.kt @@ -49,7 +49,7 @@ class ManagedOption<T : Any>( value = handler.fromJson(root[propertyName]!!) return } catch (e: Exception) { - ErrorUtil.softError( + ErrorUtil.logError( "Exception during loading of config file ${element.name}. This will reset this config.", e ) diff --git a/src/main/kotlin/gui/entity/EntityRenderer.kt b/src/main/kotlin/gui/entity/EntityRenderer.kt index b4c1c7f..a1b2577 100644 --- a/src/main/kotlin/gui/entity/EntityRenderer.kt +++ b/src/main/kotlin/gui/entity/EntityRenderer.kt @@ -27,41 +27,79 @@ object EntityRenderer { } val entityIds: Map<String, () -> LivingEntity> = mapOf( - "Zombie" to t(EntityType.ZOMBIE), + "Armadillo" to t(EntityType.ARMADILLO), + "ArmorStand" to t(EntityType.ARMOR_STAND), + "Axolotl" to t(EntityType.AXOLOTL), + "BREEZE" to t(EntityType.BREEZE), + "Bat" to t(EntityType.BAT), + "Bee" to t(EntityType.BEE), + "Blaze" to t(EntityType.BLAZE), + "CaveSpider" to t(EntityType.CAVE_SPIDER), "Chicken" to t(EntityType.CHICKEN), - "Slime" to t(EntityType.SLIME), - "Wolf" to t(EntityType.WOLF), - "Skeleton" to t(EntityType.SKELETON), + "Cod" to t(EntityType.COD), + "Cow" to t(EntityType.COW), + "Creaking" to t(EntityType.CREAKING), "Creeper" to t(EntityType.CREEPER), + "Dolphin" to t(EntityType.DOLPHIN), + "Donkey" to t(EntityType.DONKEY), + "Dragon" to t(EntityType.ENDER_DRAGON), + "Drowned" to t(EntityType.DROWNED), + "Eisengolem" to t(EntityType.IRON_GOLEM), + "Enderman" to t(EntityType.ENDERMAN), + "Endermite" to t(EntityType.ENDERMITE), + "Evoker" to t(EntityType.EVOKER), + "Fox" to t(EntityType.FOX), + "Frog" to t(EntityType.FROG), + "Ghast" to t(EntityType.GHAST), + "Giant" to t(EntityType.GIANT), + "GlowSquid" to t(EntityType.GLOW_SQUID), + "Goat" to t(EntityType.GOAT), + "Guardian" to t(EntityType.GUARDIAN), + "Horse" to t(EntityType.HORSE), + "Husk" to t(EntityType.HUSK), + "Illusioner" to t(EntityType.ILLUSIONER), + "LLama" to t(EntityType.LLAMA), + "MagmaCube" to t(EntityType.MAGMA_CUBE), + "Mooshroom" to t(EntityType.MOOSHROOM), + "Mule" to t(EntityType.MULE), "Ocelot" to t(EntityType.OCELOT), - "Blaze" to t(EntityType.BLAZE), + "Panda" to t(EntityType.PANDA), + "Phantom" to t(EntityType.PHANTOM), + "Pig" to t(EntityType.PIG), + "Piglin" to t(EntityType.PIGLIN), + "PiglinBrute" to t(EntityType.PIGLIN_BRUTE), + "Pigman" to t(EntityType.ZOMBIFIED_PIGLIN), + "Pillager" to t(EntityType.PILLAGER), + "Player" to { makeGuiPlayer(fakeWorld) }, + "PolarBear" to t(EntityType.POLAR_BEAR), + "Pufferfish" to t(EntityType.PUFFERFISH), "Rabbit" to t(EntityType.RABBIT), + "Salmom" to t(EntityType.SALMON), "Sheep" to t(EntityType.SHEEP), - "Horse" to t(EntityType.HORSE), - "Eisengolem" to t(EntityType.IRON_GOLEM), + "Shulker" to t(EntityType.SHULKER), "Silverfish" to t(EntityType.SILVERFISH), - "Witch" to t(EntityType.WITCH), - "Endermite" to t(EntityType.ENDERMITE), + "Skeleton" to t(EntityType.SKELETON), + "Slime" to t(EntityType.SLIME), + "Sniffer" to t(EntityType.SNIFFER), "Snowman" to t(EntityType.SNOW_GOLEM), - "Villager" to t(EntityType.VILLAGER), - "Guardian" to t(EntityType.GUARDIAN), - "ArmorStand" to t(EntityType.ARMOR_STAND), - "Squid" to t(EntityType.SQUID), - "Bat" to t(EntityType.BAT), "Spider" to t(EntityType.SPIDER), - "CaveSpider" to t(EntityType.CAVE_SPIDER), - "Pigman" to t(EntityType.ZOMBIFIED_PIGLIN), - "Ghast" to t(EntityType.GHAST), - "MagmaCube" to t(EntityType.MAGMA_CUBE), + "Squid" to t(EntityType.SQUID), + "Stray" to t(EntityType.STRAY), + "Strider" to t(EntityType.STRIDER), + "Tadpole" to t(EntityType.TADPOLE), + "TropicalFish" to t(EntityType.TROPICAL_FISH), + "Turtle" to t(EntityType.TURTLE), + "Vex" to t(EntityType.VEX), + "Villager" to t(EntityType.VILLAGER), + "Vindicator" to t(EntityType.VINDICATOR), + "Warden" to t(EntityType.WARDEN), + "Witch" to t(EntityType.WITCH), "Wither" to t(EntityType.WITHER), - "Enderman" to t(EntityType.ENDERMAN), - "Mooshroom" to t(EntityType.MOOSHROOM), "WitherSkeleton" to t(EntityType.WITHER_SKELETON), - "Cow" to t(EntityType.COW), - "Dragon" to t(EntityType.ENDER_DRAGON), - "Player" to { makeGuiPlayer(fakeWorld) }, - "Pig" to t(EntityType.PIG), - "Giant" to t(EntityType.GIANT), + "Wolf" to t(EntityType.WOLF), + "Zoglin" to t(EntityType.ZOGLIN), + "Zombie" to t(EntityType.ZOMBIE), + "ZombieVillager" to t(EntityType.ZOMBIE_VILLAGER) ) val entityModifiers: Map<String, EntityModifier> = mapOf( "playerdata" to ModifyPlayerSkin, diff --git a/src/main/kotlin/gui/entity/ModifyEquipment.kt b/src/main/kotlin/gui/entity/ModifyEquipment.kt index 712f5ca..2ef5007 100644 --- a/src/main/kotlin/gui/entity/ModifyEquipment.kt +++ b/src/main/kotlin/gui/entity/ModifyEquipment.kt @@ -8,10 +8,11 @@ import net.minecraft.entity.LivingEntity import net.minecraft.item.Item import net.minecraft.item.ItemStack import net.minecraft.item.Items +import moe.nea.firmament.repo.ExpensiveItemCacheApi import moe.nea.firmament.repo.SBItemStack import moe.nea.firmament.util.SkyblockId import moe.nea.firmament.util.mc.setEncodedSkullOwner -import moe.nea.firmament.util.mc.zeroUUID +import moe.nea.firmament.util.mc.arbitraryUUID object ModifyEquipment : EntityModifier { val names = mapOf( @@ -31,12 +32,13 @@ object ModifyEquipment : EntityModifier { return entity } + @OptIn(ExpensiveItemCacheApi::class) private fun createItem(item: String): ItemStack { val split = item.split("#") if (split.size != 2) return SBItemStack(SkyblockId(item)).asImmutableItemStack() val (type, data) = split return when (type) { - "SKULL" -> ItemStack(Items.PLAYER_HEAD).also { it.setEncodedSkullOwner(zeroUUID, data) } + "SKULL" -> ItemStack(Items.PLAYER_HEAD).also { it.setEncodedSkullOwner(arbitraryUUID, data) } "LEATHER_LEGGINGS" -> coloredLeatherArmor(Items.LEATHER_LEGGINGS, data) "LEATHER_BOOTS" -> coloredLeatherArmor(Items.LEATHER_BOOTS, data) "LEATHER_HELMET" -> coloredLeatherArmor(Items.LEATHER_HELMET, data) |