Skip to content

Commit

Permalink
Start of major refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
blackd committed Aug 30, 2024
1 parent 740cb62 commit 8ef128e
Show file tree
Hide file tree
Showing 23 changed files with 168 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.render.RenderTickCounter;
import org.anti_ad.mc.common.gui.NativeContext;
import org.anti_ad.mc.ipnext.event.AutoRefillHandler;
import org.anti_ad.mc.ipnext.event.autorefill.AutoRefillHandler;
import org.anti_ad.mc.ipnext.event.LockSlotsHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ object Integrations {
val carpetEmptyShulkersStackSize = 1

fun init(): Boolean {
trySwallow {
ChippedIntegration.init()
}
return false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import net.minecraft.client.gui.GuiGraphics;

import org.anti_ad.mc.common.gui.NativeContext;
import org.anti_ad.mc.ipnext.event.AutoRefillHandler;
import org.anti_ad.mc.ipnext.event.autorefill.AutoRefillHandler;
import org.anti_ad.mc.ipnext.event.LockSlotsHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import org.anti_ad.mc.common.gui.NativeContext;
import org.anti_ad.mc.ipnext.event.AutoRefillHandler;
import org.anti_ad.mc.ipnext.event.autorefill.AutoRefillHandler;
import org.anti_ad.mc.ipnext.event.LockSlotsHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.anti_ad.mc.common.vanilla.Vanilla
import org.anti_ad.mc.ipn.api.access.IContainerClicker
import org.anti_ad.mc.ipn.api.access.IPN
import org.anti_ad.mc.ipnext.config.ModSettings
import org.anti_ad.mc.ipnext.event.AutoRefillHandler
import org.anti_ad.mc.ipnext.event.autorefill.AutoRefillHandler
import org.anti_ad.mc.ipnext.event.LockSlotsHandler
import org.anti_ad.mc.ipnext.event.LockedSlotKeeper
import org.anti_ad.mc.ipnext.ingame.vCursorStack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import org.anti_ad.mc.ipnext.integration.MergePriority
import org.anti_ad.mc.ipnext.config.defaults.AUTO_REFILL_WAIT_TICK_DEFAULT
import org.anti_ad.mc.ipnext.config.defaults.AUTO_REFILL_WAIT_TICK_MINIMUM
import org.anti_ad.mc.ipnext.debug.GenerateTagsAsJson
import org.anti_ad.mc.ipnext.event.AutoRefillHandler
import org.anti_ad.mc.ipnext.event.autorefill.AutoRefillHandler
import org.anti_ad.mc.ipnext.event.LockedSlotKeeper
import org.anti_ad.mc.ipnext.gui.ConfigScreeHelper.keyToggleBool
import org.anti_ad.mc.ipnext.item.ItemTypeExtensionsObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.anti_ad.mc.ipnext.config.GuiSettings
import org.anti_ad.mc.ipnext.config.LockedSlotsSettings
import org.anti_ad.mc.ipnext.config.ModSettings
import org.anti_ad.mc.ipnext.config.Tweaks
import org.anti_ad.mc.ipnext.event.autorefill.AutoRefillHandler
import org.anti_ad.mc.ipnext.parser.CustomDataFileLoader
import org.anti_ad.mc.ipnext.specific.event.PClientEventHandler
import org.anti_ad.mc.ipnext.versionCheckUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import org.anti_ad.mc.ipnext.config.ModSettings
import org.anti_ad.mc.ipnext.config.SwitchType.HOLD
import org.anti_ad.mc.ipnext.config.SwitchType.TOGGLE
import org.anti_ad.mc.ipnext.gui.base.InventoryOverlay
import org.anti_ad.mc.ipnext.gui.base.InventoryOverlay.Companion.backgroundSprite
import org.anti_ad.mc.ipnext.ingame.`(containerBounds)`
import org.anti_ad.mc.ipnext.ingame.`(invSlot)`
import org.anti_ad.mc.ipnext.ingame.`(inventoryOrNull)`
Expand All @@ -54,6 +53,7 @@ import org.anti_ad.mc.ipnext.ingame.`(scaledHeight)`
import org.anti_ad.mc.ipnext.ingame.`(scaledWidth)`
import org.anti_ad.mc.ipnext.ingame.`(selectedSlot)`
import org.anti_ad.mc.ipnext.ingame.`(slots)`
import org.anti_ad.mc.ipnext.ingame.`(topLeft)`
import org.anti_ad.mc.ipnext.ingame.`(window)`
import org.anti_ad.mc.ipnext.ingame.vPlayerSlotOf
import org.anti_ad.mc.ipnext.item.maxCount
Expand All @@ -78,6 +78,21 @@ object LockSlotsHandler: InventoryOverlay {
override val enabledBackground: Boolean
get() = ModSettings.ENABLE_LOCK_SLOTS.booleanValue && LockedSlotsSettings.SHOW_LOCKED_SLOTS_BACKGROUND.booleanValue

override val slotLocations: Map<Int, Point>
get() {
val screen = Vanilla.screen() as? ContainerScreen<*> ?: return mapOf()
@Suppress("USELESS_ELVIS")
val container = Vanilla.container() ?: return mapOf()
return container.`(slots)`.mapNotNull { slot ->
val playerSlot = vPlayerSlotOf(slot,
screen)
val topLeft =slot.`(topLeft)`
val inv = playerSlot.`(inventoryOrNull)` ?: return@mapNotNull null
return@mapNotNull if (inv is PlayerInventory) playerSlot.`(invSlot)` to topLeft else null
}.toMap()
}


val lockedInvSlotsStoredValue = mutableSetOf<Int>() // locked invSlot list

val lockedInvSlots: Iterable<Int>
Expand Down Expand Up @@ -141,7 +156,7 @@ object LockSlotsHandler: InventoryOverlay {



fun postRender(context: NativeContext) { // display config
override fun postRender(context: NativeContext) { // display config
}

override fun drawForeground(context: NativeContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.anti_ad.mc.common.vanilla.VanillaUtil
import org.anti_ad.mc.ipnext.config.Debugs
import org.anti_ad.mc.ipnext.config.LockedSlotsSettings
import org.anti_ad.mc.ipnext.config.ModSettings
import org.anti_ad.mc.ipnext.event.autorefill.AutoRefillHandler
import org.anti_ad.mc.ipnext.ingame.`(itemStack)`
import org.anti_ad.mc.ipnext.ingame.`(itemType)`
import org.anti_ad.mc.ipnext.ingame.`(selectedSlot)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import org.anti_ad.mc.common.vanilla.VanillaUtil
import org.anti_ad.mc.ipnext.config.EditProfiles
import org.anti_ad.mc.ipnext.config.GuiSettings
import org.anti_ad.mc.ipnext.config.Hotkeys
import org.anti_ad.mc.ipnext.event.autorefill.AutoRefillHandler
import org.anti_ad.mc.ipnext.ingame.`(itemStack)`
import org.anti_ad.mc.ipnext.ingame.`(selectedSlot)`
import org.anti_ad.mc.ipnext.ingame.`(slots)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object SlotHighlightHandler: InventoryOverlay {
override fun drawConfig(context: NativeContext) {
}

fun postRender(context: NativeContext) {
override fun postRender(context: NativeContext) {

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/*
* Inventory Profiles Next
*
* Copyright (c) 2019-2020 jsnimda <7615255+jsnimda@users.noreply.github.com>
* Copyright (c) 2021-2022 Plamen K. Kosseff <p.kosseff@gmail.com>
* Copyright (c) 2021-2024 Plamen K. Kosseff <p.kosseff@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand All @@ -20,7 +19,7 @@

@file:Suppress("UnusedImport")

package org.anti_ad.mc.ipnext.event
package org.anti_ad.mc.ipnext.event.autorefill

import org.anti_ad.mc.alias.client.gui.screen.ingame.ContainerScreen
import org.anti_ad.mc.alias.client.gui.screen.ingame.InventoryScreen
Expand Down Expand Up @@ -58,8 +57,10 @@ import org.anti_ad.mc.ipnext.config.ModSettings
import org.anti_ad.mc.ipnext.config.ThresholdUnit.ABSOLUTE
import org.anti_ad.mc.ipnext.config.ThresholdUnit.PERCENTAGE
import org.anti_ad.mc.ipnext.config.ToolReplaceVisualNotification
import org.anti_ad.mc.ipnext.event.LockedSlotKeeper
import org.anti_ad.mc.ipnext.event.MouseTracer
import org.anti_ad.mc.ipnext.event.Sounds
import org.anti_ad.mc.ipnext.gui.base.InventoryOverlay
import org.anti_ad.mc.ipnext.gui.base.InventoryOverlay.Companion.TEXTURE
import org.anti_ad.mc.ipnext.ingame.`(containerBounds)`
import org.anti_ad.mc.ipnext.ingame.`(equipmentSlot)`
import org.anti_ad.mc.ipnext.ingame.`(id)`
Expand Down Expand Up @@ -831,6 +832,10 @@ object AutoRefillHandler: InventoryOverlay {

}

override fun postRender(context: NativeContext) {

}

override fun drawBackground(context: NativeContext) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import org.anti_ad.mc.ipnext.config.Hotkeys
import org.anti_ad.mc.ipnext.config.ModSettings
import org.anti_ad.mc.ipnext.config.Modpacks
import org.anti_ad.mc.ipnext.config.SaveLoadManager
import org.anti_ad.mc.ipnext.event.AutoRefillHandler
import org.anti_ad.mc.ipnext.event.autorefill.AutoRefillHandler

import org.anti_ad.mc.common.input.KeybindSettings
import org.anti_ad.mc.common.input.KeybindSettings.Companion.INGAME_DEFAULT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,40 @@

package org.anti_ad.mc.ipnext.gui.base

import org.anti_ad.mc.alias.client.gui.screen.ingame.ContainerScreen
import org.anti_ad.mc.alias.inventory.PlayerInventory

import org.anti_ad.mc.common.gui.NativeContext
import org.anti_ad.mc.common.math2d.Point
import org.anti_ad.mc.common.math2d.Rectangle
import org.anti_ad.mc.common.vanilla.Vanilla

import org.anti_ad.mc.common.vanilla.render.glue.IdentifierHolder
import org.anti_ad.mc.common.vanilla.render.glue.Sprite
import org.anti_ad.mc.ipnext.ingame.`(invSlot)`
import org.anti_ad.mc.ipnext.ingame.`(inventoryOrNull)`
import org.anti_ad.mc.ipnext.ingame.`(slots)`
import org.anti_ad.mc.ipnext.ingame.`(topLeft)`
import org.anti_ad.mc.ipnext.ingame.vPlayerSlotOf


interface InventoryOverlay {

val enabledForeground: Boolean
val enabledBackground: Boolean

companion object {
val TEXTURE = IdentifierHolder("inventoryprofilesnext", "textures/gui/overlay_new.png")
val backgroundSprite = Sprite(TEXTURE, Rectangle(40, 8, 32, 32))
@JvmField
val COMP_TEXTURE = IdentifierHolder("inventoryprofilesnext", "textures/gui/overlay_new.png")
@JvmField
val compBackgroundSprite = Sprite(COMP_TEXTURE, Rectangle(40, 8, 32, 32))
@JvmField
val internal8x8 = Point(8,8)
}

@Suppress("PropertyName")
val TEXTURE: IdentifierHolder
get() = COMP_TEXTURE

val backgroundSprite: Sprite
get() = compBackgroundSprite

val eightByEight: Point
get() = Point(8,8)
get() = internal8x8

val slotLocations: Map<Int, Point>
get() {
val screen = Vanilla.screen() as? ContainerScreen<*> ?: return mapOf()
@Suppress("USELESS_ELVIS")
val container = Vanilla.container() ?: return mapOf()
return container.`(slots)`.mapNotNull { slot ->
val playerSlot = vPlayerSlotOf(slot,
screen)
val topLeft =slot.`(topLeft)`
val inv = playerSlot.`(inventoryOrNull)` ?: return@mapNotNull null
return@mapNotNull if (inv is PlayerInventory) playerSlot.`(invSlot)` to topLeft else null
}.toMap()
}

fun onForegroundRender(context: NativeContext) {
if (!enabledForeground) return
Expand All @@ -73,6 +66,12 @@ interface InventoryOverlay {
drawBackground(context)
}

fun onPostRender(context: NativeContext) {
if (!enabledForeground && !enabledBackground) return
postRender(context)
}

fun postRender(context: NativeContext)
fun drawForeground(context: NativeContext)
fun drawConfig(context: NativeContext)
fun drawBackground(context: NativeContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import org.anti_ad.mc.common.vanilla.Vanilla
import org.anti_ad.mc.ipn.api.IPNButton
import org.anti_ad.mc.ipnext.config.GuiSettings
import org.anti_ad.mc.ipnext.config.ModSettings
import org.anti_ad.mc.ipnext.event.AutoRefillHandler
import org.anti_ad.mc.ipnext.event.autorefill.AutoRefillHandler
import org.anti_ad.mc.ipnext.event.LockSlotsHandler
import org.anti_ad.mc.ipnext.event.SlotHighlightHandler
import org.anti_ad.mc.ipnext.event.villagers.VillagerTradeManager
Expand Down Expand Up @@ -140,8 +140,8 @@ object ContainerScreenEventHandler {
}

fun postRender(context: NativeContext) {
LockSlotsHandler.postRender(context)
SlotHighlightHandler.postRender(context)
LockSlotsHandler.onPostRender(context)
SlotHighlightHandler.onPostRender(context)
ContainerClicker.postScreenRender(context)
currentWidgets?.let {
TooltipsManager.renderAll(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package org.anti_ad.mc.ipnext.input
import org.anti_ad.mc.common.IInputHandler
import org.anti_ad.mc.common.config.options.ConfigKeyToggleBoolean
import org.anti_ad.mc.common.extensions.tryCatch
import org.anti_ad.mc.ipnext.event.AutoRefillHandler
import org.anti_ad.mc.ipnext.event.autorefill.AutoRefillHandler
import org.anti_ad.mc.ipnext.event.LockSlotsHandler
import org.anti_ad.mc.ipnext.event.ProfileSwitchHandler
import org.anti_ad.mc.ipnext.event.villagers.VillagerTradeManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import org.anti_ad.mc.ipnext.config.Debugs
import org.anti_ad.mc.ipnext.config.Hotkeys
import org.anti_ad.mc.ipnext.config.ModSettings
import org.anti_ad.mc.ipnext.debug.ModpackInputHandler
import org.anti_ad.mc.ipnext.event.AutoRefillHandler
import org.anti_ad.mc.ipnext.gui.ConfigScreeHelper
import org.anti_ad.mc.ipnext.gui.ConfigScreen
import org.anti_ad.mc.ipnext.gui.DebugScreen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package org.anti_ad.mc.ipnext.inventory

import org.anti_ad.mc.alias.inventory.PlayerInventory
import org.anti_ad.mc.alias.nbt.NbtHelper
import org.anti_ad.mc.alias.nbt.NbtHelper_toFormattedString
import org.anti_ad.mc.alias.screen.BeaconContainer
import org.anti_ad.mc.alias.screen.Container
Expand Down Expand Up @@ -57,16 +56,15 @@ import org.anti_ad.mc.ipnext.inventory.action.moveMatchTo
import org.anti_ad.mc.ipnext.inventory.action.refillStacksTo
import org.anti_ad.mc.ipnext.inventory.action.restockFrom
import org.anti_ad.mc.ipnext.inventory.action.sort
import org.anti_ad.mc.ipnext.inventory.scrolling.ScrollDirection
import org.anti_ad.mc.ipnext.inventory.scrolling.ScrollingUtils
import org.anti_ad.mc.ipn.features.scrolling.ScrollDirection
import org.anti_ad.mc.ipn.features.scrolling.ScrollingUtils
import org.anti_ad.mc.ipnext.item.ComponentUtils.toFullNbtOrNull
import org.anti_ad.mc.ipnext.item.EMPTY
import org.anti_ad.mc.ipnext.item.ItemStack
import org.anti_ad.mc.ipnext.item.fullItemInfoAsJson
import org.anti_ad.mc.ipnext.item.isEmpty
import org.anti_ad.mc.ipnext.item.itemId
import org.anti_ad.mc.ipnext.item.rule.Rule
import org.anti_ad.mc.ipnext.item.vanillaStack

object GeneralInventoryActions {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,11 @@ class ContainerSandbox(items: MutableItemTracker,
// fun copy() = ContainerSandbox(items.copyAsMutable(), clicks)
}

data class SandboxClick(
val clickIndex: Int,
val slotIndex: Int,
val button: Int,
val previousClick: SandboxClick? = null
)
data class SandboxClick(val clickIndex: Int,
val slotIndex: Int,
val button: Int,
val previousClick: SandboxClick? = null)


fun SandboxClick?.toList(): List<SandboxClick> {
val list = mutableListOf<SandboxClick>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import org.anti_ad.mc.common.extensions.ifTrue
import org.anti_ad.mc.common.extensions.loggingPath
import org.anti_ad.mc.common.extensions.sanitized
import org.anti_ad.mc.ipnext.NotificationManager
import org.anti_ad.mc.ipnext.event.AutoRefillHandler
import org.anti_ad.mc.ipnext.event.autorefill.AutoRefillHandler
import org.anti_ad.mc.ipnext.event.ProfileSwitchHandler
import org.anti_ad.mc.ipnext.event.villagers.VillagerDataManager
import java.nio.file.Path
Expand Down
Loading

0 comments on commit 8ef128e

Please sign in to comment.