Skip to content

Commit

Permalink
Releasing v2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
blackd committed Jul 28, 2024
1 parent a219d4c commit 41081da
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 22 deletions.
12 changes: 9 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<!-- latest begin -->

### 2.0.2
- Added support for NeoForge 1.21. No backports will happen!
- Fixed a crash when showing the overlay editor.
### 2.0.3

- To prove a worthy successor of Forge, NeoForge have broken the API keeping the same major version!
- Fixed locked slot rendering in hotbar for bot Forge and NeoForge.
- Minor bugfixes

#### Forge
- The forge build is still unstable and the gui overlay of the hotbar is currently missing.
Expand All @@ -19,6 +21,10 @@ This is still early beta please report problems. Also has the same problem as th

<!-- latest end -->

### 2.0.2
- Added support for NeoForge 1.21. No backports will happen!
- Fixed a crash when showing the overlay editor.

### 2.0.1

- Support for Forge 1.21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected void preRenderHotbar(DrawContext drawContext,
CallbackInfo ci) {
var context = new NativeContext(drawContext);
LockSlotsHandler.INSTANCE.preRenderHud(context);
AutoRefillHandler.INSTANCE.preRenderHud(context);
//AutoRefillHandler.INSTANCE.preRenderHud(context);
}


Expand All @@ -52,7 +52,7 @@ protected void postRenderHotbar(DrawContext drawContext,
CallbackInfo ci) {
var context = new NativeContext(drawContext);
LockSlotsHandler.INSTANCE.postRenderHud(context);
AutoRefillHandler.INSTANCE.postRenderHud(context);
//AutoRefillHandler.INSTANCE.postRenderHud(context);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,50 @@
package org.anti_ad.mc.ipnext.specific.event

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.alias.MatrixStack
import org.anti_ad.mc.common.vanilla.alias.RenderSystem
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.config.LockedSlotsSettings
import org.anti_ad.mc.ipnext.ingame.`(containerBounds)`
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 PLockSlotHandler {

val enabled: Boolean

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

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

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 (!enabled) return
val screen = Vanilla.screen() as? ContainerScreen<*> ?: return
Expand Down
2 changes: 1 addition & 1 deletion platforms/neoforge-1.21/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ val mod_loader = "neoforge"
val mod_version = project.version
val minecraft_version = "1.21"
val minecraft_version_string = "1.21"
val forge_version = "21.0.61-beta"
val forge_version = "21.0.141-beta"
val mod_artefact_version = project.ext["mod_artefact_version"]
val kotlin_for_forge_version = "5.3.0"
val mappingsMap = mapOf("channel" to "official",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@

package org.anti_ad.mc.ipnext.neoforge

import net.neoforged.fml.ModContainer
import net.neoforged.fml.ModLoadingContext
import net.neoforged.neoforge.client.gui.IConfigScreenFactory
import net.neoforged.neoforge.client.gui.ModListScreen
import net.neoforged.neoforge.common.NeoForge
import org.anti_ad.mc.alias.client.gui.screen.Screen
import org.anti_ad.mc.ipnext.gui.ConfigScreen
import org.anti_ad.mc.ipnext.init as inventoryProfilesInit

class KotlinClientInit: Runnable {

override fun run() {
ModLoadingContext.get().registerExtensionPoint(IConfigScreenFactory::class.java) {
IConfigScreenFactory { _, _ ->
IConfigScreenFactory { container: ModContainer, sc: Screen ->
ConfigScreen()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,50 @@
package org.anti_ad.mc.ipnext.specific.event

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.alias.MatrixStack
import org.anti_ad.mc.common.vanilla.alias.RenderSystem
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.config.LockedSlotsSettings
import org.anti_ad.mc.ipnext.ingame.`(containerBounds)`
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 PLockSlotHandler {

val enabled: Boolean

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

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

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 (!enabled) return
val screen = Vanilla.screen() as? ContainerScreen<*> ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ object AutoRefillHandler: PLockSlotHandler {
data object WatchIds {

const val MAIN_HAND_OFFSET = 36
val mainHandSelected: () -> Int = { MAIN_HAND_OFFSET + vMainhandIndex() }
val mainHandSelected: () -> Int = { MAIN_HAND_OFFSET + if (VanillaUtil.inGame()) vMainhandIndex() else 0}
val offHand: () -> Int = { 45 }
val head: () -> Int = { 5 }
val chest: () -> Int = { 6 }
Expand Down Expand Up @@ -740,10 +740,8 @@ object AutoRefillHandler: PLockSlotHandler {
@Suppress("USELESS_ELVIS")
val container = Vanilla.container() ?: return mapOf()
return container.`(slots)`.mapNotNull { slot ->
val playerSlot = vPlayerSlotOf(
slot, screen
)
if (playerSlot.id in allIds) {
val playerSlot = vPlayerSlotOf(slot, screen)
if (playerSlot.`(id)` in allIds) {
val topLeft = slot.`(topLeft)`
val inv = playerSlot.`(inventoryOrNull)` ?: return@mapNotNull null
return@mapNotNull if (inv is PlayerInventory) playerSlot.`(invSlot)` to topLeft else null
Expand Down Expand Up @@ -797,4 +795,17 @@ object AutoRefillHandler: PLockSlotHandler {
fun preRenderHud(context: NativeContext) {
}

fun onInput(lastKey: Int, lastAction: Int): Boolean {
if (!VanillaUtil.inGame() || Vanilla.screen() != null) return false
if (AutoRefillSettings.AUTO_REFILL_DISABLE_FOR_SLOT.isActivated()) {
toggleRefillHotbarSlot()
return true
}
return false
}

private fun toggleRefillHotbarSlot() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class ConfigScreen(private val gui: Boolean = false) : ConfigScreenBase(getTrans
override fun closeScreen() {
storedSelectedIndex = selectedIndex
SaveLoadManager.save()
AutoRefillHandler.init() // update
if (VanillaUtil.inGame()) AutoRefillHandler.init() // update
super.closeScreen()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ object ContainerScreenEventHandler {
}
LockSlotsHandler.onForegroundRender(context)
SlotHighlightHandler.onForegroundRender(context)
AutoRefillHandler.onForegroundRender(context)
//AutoRefillHandler.onForegroundRender(context)
}

fun postRender(context: NativeContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ 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 All @@ -50,14 +51,12 @@ object InputHandler : IInputHandler {
if (Hotkeys.OPEN_CONFIG_MENU.isActivated()) {
VanillaScreenUtil.openScreen(ConfigScreen().also { it.dumpWidgetTree() })
}
/*
if (ProfileSwitchHandler.onInput(lastKey, lastAction)) {

if (ModpackInputHandler.onInput(lastKey, lastAction)) {
return true
}

*/

if (ModpackInputHandler.onInput(lastKey, lastAction)) {
if (AutoRefillHandler.onInput(lastKey, lastAction)) {
return true
}

Expand All @@ -71,6 +70,7 @@ object InputHandler : IInputHandler {
ContainerScreenEventHandler.showEditor()
return true
}

// todo fix hotkey while typing text field
if (InventoryInputHandler.onInput(lastKey,
lastAction)) {
Expand Down
2 changes: 1 addition & 1 deletion proguard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#-keepnames class org.anti_ad.mc.ipnext.config.**

#-ignorewarnings
-optimizationpasses 100 # (828K -> 811K)
-optimizationpasses 10 # (828K -> 811K)

-dontwarn org.jetbrains.annotations.**
-dontwarn javax.annotation.**
Expand Down
3 changes: 1 addition & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

rootProject.name = "InventoryProfilesNext"
include("platforms:fabric-1.21")
/*
include("platforms:forge-1.21")
include("platforms:neoforge-1.21")
*/


pluginManagement {
repositories {
Expand Down

0 comments on commit 41081da

Please sign in to comment.