diff options
Diffstat (limited to 'src/main')
11 files changed, 215 insertions, 21 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java b/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java index c7555fb..bbeaf48 100644 --- a/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java +++ b/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java @@ -53,7 +53,7 @@ public abstract class MixinHandledScreen<T extends AbstractContainerMenu> { private void onMouseReleased(MouseButtonEvent click, CallbackInfoReturnable<Boolean> cir) { var self = (AbstractContainerScreen<?>) (Object) this; var clickEvent = new HandledScreenClickEvent(self, click.x(), click.y(), click.button()); - var keyEvent = new HandledScreenKeyReleasedEvent(self, GenericInputAction.mouse(click), InputModifiers.current()); + var keyEvent = new HandledScreenKeyReleasedEvent(self, GenericInputAction.mouse(click), InputModifiers.of(click.modifiers())); if (HandledScreenClickEvent.Companion.publish(clickEvent).getCancelled() || HandledScreenKeyReleasedEvent.Companion.publish(keyEvent).getCancelled()) { cir.setReturnValue(true); diff --git a/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java b/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java index 7852fc3..7a4a3c7 100644 --- a/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java +++ b/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java @@ -28,13 +28,13 @@ public abstract class CustomCapeFeatureRenderer extends RenderLayer<AvatarRender super(context); } - @WrapOperation( - method = "submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/AvatarRenderState;FF)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/RenderType;IIILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V") - ) - private void onRender(SubmitNodeCollector instance, Model model, Object o, PoseStack matrixStack, RenderType renderLayer, int light, int overlay, int outlineColor, ModelFeatureRenderer.CrumblingOverlay crumblingOverlayCommand, Operation<Void> original, - @Local(argsOnly = true) AvatarRenderState playerEntityRenderState, @Local PlayerSkin skinTextures) { - // TODO: 1.21.10 custom capes by pre rendering the texture id. this is more viable on this version i am fairly sure, without clogging up all of the cached image render layers +// @WrapOperation( +// method = "submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/AvatarRenderState;FF)V", +// at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/RenderType;IIILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V") +// ) +// private void onRender(SubmitNodeCollector instance, Model model, Object o, PoseStack matrixStack, RenderType renderLayer, int light, int overlay, int outlineColor, ModelFeatureRenderer.CrumblingOverlay crumblingOverlayCommand, Operation<Void> original, +// @Local(argsOnly = true) AvatarRenderState playerEntityRenderState, @Local PlayerSkin skinTextures) { +// // TODO: 1.21.10 custom capes by pre rendering the texture id. this is more viable on this version i am fairly sure, without clogging up all of the cached image render layers // CustomCapes.render( // playerEntityRenderState, // vertexConsumer, @@ -45,5 +45,5 @@ public abstract class CustomCapeFeatureRenderer extends RenderLayer<AvatarRender // original.call(instance, matrixStack, updatedConsumer, light, overlay, outlineColor); // return Unit.INSTANCE; // }); - } +// } } diff --git a/src/main/kotlin/events/HandledScreenClickEvent.kt b/src/main/kotlin/events/HandledScreenClickEvent.kt index b937907..c9890af 100644 --- a/src/main/kotlin/events/HandledScreenClickEvent.kt +++ b/src/main/kotlin/events/HandledScreenClickEvent.kt @@ -1,10 +1,11 @@ - - package moe.nea.firmament.events import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen -data class HandledScreenClickEvent(val screen: AbstractContainerScreen<*>, val mouseX: Double, val mouseY: Double, val button: Int) : - FirmamentEvent.Cancellable() { - companion object : FirmamentEventBus<HandledScreenClickEvent>() +data class HandledScreenClickEvent( + val screen: AbstractContainerScreen<*>, + val mouseX: Double, val mouseY: Double, val button: Int +) : + FirmamentEvent.Cancellable() { + companion object : FirmamentEventBus<HandledScreenClickEvent>() } diff --git a/src/main/kotlin/features/diana/AncestralSpadeSolver.kt b/src/main/kotlin/features/diana/AncestralSpadeSolver.kt index 72806c9..c12a2c6 100644 --- a/src/main/kotlin/features/diana/AncestralSpadeSolver.kt +++ b/src/main/kotlin/features/diana/AncestralSpadeSolver.kt @@ -32,7 +32,11 @@ object AncestralSpadeSolver { fun isEnabled() = DianaWaypoints.TConfig.ancestralSpadeSolver && SBData.skyblockLocation == SkyBlockIsland.HUB - && MC.player?.inventory?.hasAnyMatching { it.skyBlockId == SkyBlockItems.ANCESTRAL_SPADE } == true // TODO: add a reactive property here + && MC.player?.inventory?.hasAnyMatching { + it.skyBlockId == SkyBlockItems.ANCESTRAL_SPADE || + it.skyBlockId == SkyBlockItems.ARCHAIC_SPADE || + it.skyBlockId == SkyBlockItems.DEIFIC_SPADE + } == true // TODO: add a reactive property here @Subscribe fun onKeyBind(event: WorldKeyboardEvent) { diff --git a/src/main/kotlin/features/fixes/Fixes.kt b/src/main/kotlin/features/fixes/Fixes.kt index bb17536..ae4abd7 100644 --- a/src/main/kotlin/features/fixes/Fixes.kt +++ b/src/main/kotlin/features/fixes/Fixes.kt @@ -23,6 +23,7 @@ object Fixes { var autoSprint by toggle("auto-sprint") { false } val autoSprintKeyBinding by keyBindingWithDefaultUnbound("auto-sprint-keybinding") val autoSprintUnderWater by toggle("auto-sprint-underwater") { true } + var autoSprintHudToggle by toggle("auto-sprint-hud-toggle") { true } val autoSprintHud by position("auto-sprint-hud", 80, 10) { Vector2i() } val peekChat by keyBindingWithDefaultUnbound("peek-chat") val peekChatScroll by toggle("peek-chat-scroll") { false } @@ -48,7 +49,7 @@ object Fixes { @Subscribe fun onRenderHud(it: HudRenderEvent) { - if (!TConfig.autoSprintKeyBinding.isBound) return + if (!TConfig.autoSprintKeyBinding.isBound || !TConfig.autoSprintHudToggle) return it.context.pose().pushMatrix() TConfig.autoSprintHud.applyTransformations(it.context.pose()) it.context.drawString( diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt index 3e0bb4b..d56e4d2 100644 --- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt +++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt @@ -529,6 +529,7 @@ class StorageOverlayScreen : Screen(Component.literal("")) { PAGE_SLOTS_WIDTH, inv.rows * SLOT_SIZE ) + val scrollPanel = getScrollPanelInner() inv.stacks.forEachIndexed { index, stack -> val slotX = (index % 9) * SLOT_SIZE + x + 3 val slotY = (index / 9) * SLOT_SIZE + y + 5 + font.lineHeight + 1 @@ -538,11 +539,10 @@ class StorageOverlayScreen : Screen(Component.literal("")) { context.renderItem(stack, slotX, slotY) context.renderItemDecorations(font, stack, slotX, slotY) SlotRenderEvents.After.publish(SlotRenderEvents.After(context, fakeSlot)) - val rect = getScrollPanelInner() if (StorageOverlay.TConfig.showInactivePageTooltips && !stack.isEmpty && mouseX >= slotX && mouseY >= slotY && mouseX <= slotX + 16 && mouseY <= slotY + 16 && - mouseY >= rect.minY && mouseY <= rect.maxY) { + scrollPanel.contains(mouseX, mouseY)) { try { context.setTooltipForNextFrame(font, stack, mouseX, mouseY) } catch (e: IllegalStateException) { diff --git a/src/main/kotlin/features/items/recipes/ItemList.kt b/src/main/kotlin/features/items/recipes/ItemList.kt index f8268f4..9517a0b 100644 --- a/src/main/kotlin/features/items/recipes/ItemList.kt +++ b/src/main/kotlin/features/items/recipes/ItemList.kt @@ -1,19 +1,31 @@ package moe.nea.firmament.features.items.recipes +import io.github.notenoughupdates.moulconfig.observer.GetSetter +import io.github.notenoughupdates.moulconfig.observer.Property import java.util.Optional +import me.shedaniel.math.Rectangle +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.gui.components.Renderable +import net.minecraft.client.gui.components.events.GuiEventListener +import net.minecraft.client.gui.navigation.ScreenAxis import net.minecraft.client.gui.navigation.ScreenRectangle import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen +import net.minecraft.client.input.MouseButtonEvent +import net.minecraft.client.input.MouseButtonInfo +import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.api.v1.FirmamentAPI +import moe.nea.firmament.events.HandledScreenClickEvent import moe.nea.firmament.events.HandledScreenForegroundEvent import moe.nea.firmament.events.ReloadRegistrationEvent import moe.nea.firmament.repo.RepoManager import moe.nea.firmament.repo.SBItemStack import moe.nea.firmament.util.MC import moe.nea.firmament.util.accessors.castAccessor +import moe.nea.firmament.util.render.drawLine import moe.nea.firmament.util.skyblockId object ItemList { @@ -78,6 +90,115 @@ object ItemList { var lastRenderPositions: List<Pair<ScreenRectangle, SBItemStack>> = listOf() var lastHoveredItemStack: Pair<ScreenRectangle, SBItemStack>? = null + abstract class ItemListElement( + ) : Renderable, GuiEventListener { + abstract val rectangle: Rectangle + override fun setFocused(focused: Boolean) { + } + + override fun isFocused(): Boolean { + return false + } + + override fun isMouseOver(mouseX: Double, mouseY: Double): Boolean { + return rectangle.contains(mouseX, mouseY) + } + } + + interface HasLabel { + fun component(): Component + } + + + class PopupSettingsElement<T : HasLabel>( + x: Int, + y: Int, + width: Int, + val selected: GetSetter<T>, + val options: List<T>, + ) : ItemListElement() { + override val rectangle: Rectangle = Rectangle(x, y, width, 4 + (MC.font.lineHeight + 2) * options.size) + fun bb(i: Int) = + Rectangle( + rectangle.minX, rectangle.minY + (2 + MC.font.lineHeight) * i + 2, + rectangle.width, MC.font.lineHeight + ) + + override fun render( + guiGraphics: GuiGraphics, + mouseX: Int, + mouseY: Int, + partialTick: Float + ) { + guiGraphics.fill(rectangle.minX, rectangle.minY, rectangle.maxX, rectangle.maxY, 0xFF000000.toInt()) + guiGraphics.submitOutline(rectangle.x, rectangle.y, rectangle.width, rectangle.height, -1) + val sel = selected.get() + for ((index, element) in options.withIndex()) { + val b = bb(index) + val tw = MC.font.width(element.component()) + guiGraphics.drawString( + MC.font, element.component(), b.centerX - tw / 2, + b.y + 1, + if (element == sel) 0xFFA0B000.toInt() else -1 + ) + if (b.contains(mouseX, mouseY)) + guiGraphics.hLine(b.centerX - tw / 2, b.centerX + tw / 2 - 1, b.maxY + 1, -1) + } + } + + override fun mouseClicked(event: MouseButtonEvent, isDoubleClick: Boolean): Boolean { + popupElement = null + for ((index, element) in options.withIndex()) { + val b = bb(index) + if (b.contains(event.x, event.y)) { + selected.set(element) + break + } + } + return true + } + } + + class SettingElement<T : HasLabel>( + x: Int, + y: Int, + val selected: GetSetter<T>, + val options: List<T> + ) : ItemListElement() { + val height = MC.font.lineHeight + 4 + val width = options.maxOf { MC.font.width(it.component()) } + 4 + override val rectangle: Rectangle = Rectangle(x, y, width, height) + + override fun render( + guiGraphics: GuiGraphics, + mouseX: Int, + mouseY: Int, + partialTick: Float + ) { + guiGraphics.drawCenteredString(MC.font, selected.get().component(), rectangle.centerX, rectangle.y + 2, -1) + if (isMouseOver(mouseX.toDouble(), mouseY.toDouble())) { + guiGraphics.hLine(rectangle.minX, rectangle.maxX - 1, rectangle.maxY - 2, -1) + } + } + + override fun mouseClicked( + event: MouseButtonEvent, + isDoubleClick: Boolean + ): Boolean { + popupElement = PopupSettingsElement( + rectangle.x, + rectangle.y - options.size * (MC.font.lineHeight + 2) - 2, + width, + selected, + options + ) + return true + } + } + + var popupElement: ItemListElement? = null + + fun findStackUnder(mouseX: Int, mouseY: Int): Pair<ScreenRectangle, SBItemStack>? { val lhis = lastHoveredItemStack if (lhis != null && lhis.first.containsPoint(mouseX, mouseY)) @@ -86,6 +207,33 @@ object ItemList { } @Subscribe + fun onClick(event: HandledScreenClickEvent) { + val pe = popupElement + val me = MouseButtonEvent( + event.mouseX, event.mouseY, + MouseButtonInfo(event.button, 0) // TODO: missing modifiers + ) + if (pe != null) { + event.cancel() + if (!pe.isMouseOver(event.mouseX, event.mouseY)) { + popupElement = null + return + } + pe.mouseClicked( + me, + false + ) + return + } + listElements.forEach { + if (it.isMouseOver(event.mouseX, event.mouseY)) + it.mouseClicked(me, false) + } + } + + var listElements = listOf<ItemListElement>() + + @Subscribe fun onRender(event: HandledScreenForegroundEvent) { lastHoveredItemStack = null lastRenderPositions = listOf() @@ -94,16 +242,18 @@ object ItemList { val screenWidth = event.screen.width val rightThird = ScreenRectangle( screenWidth - screenWidth / 3, 0, - screenWidth / 3, event.screen.height + screenWidth / 3, event.screen.height - MC.font.lineHeight - 4 ) val coords = coordinates(rightThird, exclusions) lastRenderPositions = coords.zip(potentiallyVisible.asSequence()).toList() + val isPopupHovered = popupElement?.isMouseOver(event.mouseX.toDouble(),event.mouseY.toDouble()) + ?: false lastRenderPositions.forEach { (pos, stack) -> val realStack = stack.asLazyImmutableItemStack() val toRender = realStack ?: ItemStack(Items.PAINTING) event.context.renderItem(toRender, pos.left() + 1, pos.top() + 1) - if (pos.containsPoint(event.mouseX, event.mouseY)) { + if (!isPopupHovered && pos.containsPoint(event.mouseX, event.mouseY)) { lastHoveredItemStack = pos to stack event.context.setTooltipForNextFrame( MC.font, @@ -116,5 +266,39 @@ object ItemList { ) } } + event.context.fill( + rightThird.left(), + rightThird.bottom(), + rightThird.right(), + event.screen.height, + 0xFF000000.toInt() + ) + val le = mutableListOf<ItemListElement>() + le.add( + SettingElement( + 0, + rightThird.bottom(), + sortOrder, + SortOrder.entries + ) + ) + val bottomWidth = le.sumOf { it.rectangle.width + 2 } - 2 + var startX = rightThird.getCenterInAxis(ScreenAxis.HORIZONTAL) - bottomWidth / 2 + le.forEach { + it.rectangle.translate(startX, 0) + startX += it.rectangle.width + 2 + } + le.forEach { it.render(event.context, event.mouseX, event.mouseY, event.delta) } + listElements = le + popupElement?.render(event.context, event.mouseX, event.mouseY, event.delta) + } + + enum class SortOrder(val component: Component) : HasLabel { + NAME(Component.literal("Name")), + RARITY(Component.literal("Rarity")); + + override fun component(): Component = component } + + val sortOrder = Property.of(SortOrder.NAME) } diff --git a/src/main/kotlin/features/items/recipes/RecipeScreen.kt b/src/main/kotlin/features/items/recipes/RecipeScreen.kt index d365c0e..9a746f3 100644 --- a/src/main/kotlin/features/items/recipes/RecipeScreen.kt +++ b/src/main/kotlin/features/items/recipes/RecipeScreen.kt @@ -35,7 +35,7 @@ class RecipeScreen( var scrollPortWidth: Int = 0 var heightEstimate: Int = 0 val gutter = 10 - override fun init() {// TODO: wrap all of this in a scroll layout + override fun init() { super.init() scrollViewport = minOf(height - 20, 250) scrollPortWidth = 0 diff --git a/src/main/kotlin/features/misc/CustomCapes.kt b/src/main/kotlin/features/misc/CustomCapes.kt index 8aa19d3..fe54e6b 100644 --- a/src/main/kotlin/features/misc/CustomCapes.kt +++ b/src/main/kotlin/features/misc/CustomCapes.kt @@ -139,6 +139,7 @@ object CustomCapes { Devs.nea to AllCapes.UNPLEASANT_GRADIENT, Devs.kath to AllCapes.FIRMAMENT_STATIC, Devs.jani to AllCapes.FIRMAMENT_ANIMATED, + Devs.nat to AllCapes.FIRMAMENT_ANIMATED, Devs.HPlus.ic22487 to AllCapes.HYPIXEL_PLUS, ), Devs.FurfSky.all.map { it to AllCapes.FURFSKY_STATIC }, diff --git a/src/main/kotlin/features/misc/Devs.kt b/src/main/kotlin/features/misc/Devs.kt index 91095c0..b9f7e03 100644 --- a/src/main/kotlin/features/misc/Devs.kt +++ b/src/main/kotlin/features/misc/Devs.kt @@ -13,6 +13,7 @@ object Devs { val nea = Dev("d3cb85e2-3075-48a1-b213-a9bfb62360c1", "842204e6-6880-487b-ae5a-0595394f9948") val kath = Dev("add71246-c46e-455c-8345-c129ea6f146c", "b491990d-53fd-4c5f-a61e-19d58cc7eddf") val jani = Dev("8a9f1841-48e9-48ed-b14f-76a124e6c9df") + val nat = Dev("168300e6-4e74-4a6d-89a0-7b7cf8ad6a7d", "06914e9d-7bc2-4cb7-b112-62c4cc958d96") object FurfSky { val smolegit = Dev("02b38b96-eb19-405a-b319-d6bc00b26ab3") diff --git a/src/main/kotlin/util/skyblock/SkyBlockItems.kt b/src/main/kotlin/util/skyblock/SkyBlockItems.kt index 785866e..5f4acd4 100644 --- a/src/main/kotlin/util/skyblock/SkyBlockItems.kt +++ b/src/main/kotlin/util/skyblock/SkyBlockItems.kt @@ -8,6 +8,8 @@ object SkyBlockItems { val ENCHANTED_DIAMOND = SkyblockId("ENCHANTED_DIAMOND") val DIAMOND = SkyblockId("DIAMOND") val ANCESTRAL_SPADE = SkyblockId("ANCESTRAL_SPADE") + val ARCHAIC_SPADE = SkyblockId("ARCHAIC_SPADE") + val DEIFIC_SPADE = SkyblockId("DEIFIC_SPADE") val REFORGE_ANVIL = SkyblockId("REFORGE_ANVIL") val SLICE_OF_BLUEBERRY_CAKE = SkyblockId("SLICE_OF_BLUEBERRY_CAKE") val SLICE_OF_CHEESECAKE = SkyblockId("SLICE_OF_CHEESECAKE") |
