diff options
26 files changed, 241 insertions, 153 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2381ceb8..327c4e17 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,3 @@ /src/main/java/io/github/moulberry/notenoughupdates/recipes/* @romangraef /src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java @romangraef +/*gradle* @romangraef diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3b6d0cbd..630d8288 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,14 +34,14 @@ jobs: ./.github/workflows/send_webhook_update.sh env: STATUS: WORKING - - name: Set up JDK 8 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: - java-version: 8 - distribution: zulu + java-version: 17 + distribution: temurin cache: gradle - name: Build with Gradle - run: chmod +x ./gradlew && ./gradlew setupCIWorkspace build --no-daemon + run: chmod +x ./gradlew && ./gradlew clean test remapJar --no-daemon - uses: actions/upload-artifact@v2 with: path: build/libs/*-dep.jar diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..d2d14086 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,34 @@ +## Before you contribute + + - Please check your feature / bug isn't already fixed in one of our pre-releases or on [the development branch](https://github.com/NotEnoughUpdates/NotEnoughUpdates/tree/master/). + - Consider joining our [Discord](https://discord.gg/moulberry) to check in on newest developments by other people, or to get help with problems you encounter. + - Please check that your feature idea complies with the [Hypixel Rules](https://hypixel.net/rules) + - Check that your feature idea isn't already done in other mods. (E.g. Dungeon Solver) + +## Setting up a development environment + +### Software prerequisites + + - Install a Java Development Kit (You will need both version 8 and version 17) [Eclipse Temurin Download](https://adoptium.net/temurin/releases) for convenience, however any JDK will do. + - Install Git. [Windows download](https://git-scm.com/download/win) + - Install an IDE, such as [Jetbrains IntelliJ IDEA](https://www.jetbrains.com/idea/download). + +### Software configuration + + - Clone the NEU repository using `git clone https://github.com/NotEnoughUpdates/NotEnoughUpdates`. + - Import that folder as a Gradle Project in your IDE (IntelliJ should autodetect it as gradle if you select the `NotEnoughUpdates` folder in the Open dialog) + - Set your project SDK to your 1.8 JDK. This can be done in the modules settings (CTRL+ALT+SHIFT+S) in IntelliJ. + - Set your gradle JVM to your 1.17 JDK. This can be done by searching for `gradle jvm` in the CTRL+SHIFT+A dialog in IntelliJ. + - Run the `gen<IntelliJ/Eclipse>Runs` gradle task. In IntelliJ that can be done in the gradle tab on the right side of your IDE. + - Optionally, run the `genSources` gradle task. + - Run the `Minecraft Client` to make sure that everything works. + + +## Logging into Hypixel in a development environment. + +Use [DevAuth](https://github.com/DJtheRedstoner/DevAuth). Download the `forge-legacy` version, and put it into the `run/mods` folder. Then follow the configuration instructions in the [DevAuth README](https://github.com/DJtheRedstoner/DevAuth#configuration-file) + +## Hot Reloading + +Hot Reloading is possible by first launching using the IntelliJ debugger with [DCEVM 1.8](https://dcevm.github.io/). Then running a regular build and confirming the reload prompt. This can cause issues (especially with commands), so restarting is sometimes still necessary. + @@ -36,6 +36,8 @@ NotEnoughUpdates (NEU) is a feature rich 1.8.9 Minecraft forge mod for Hypixel S ## Getting Started +<i>If you want to install NEU for development purposes, see [CONTRIBUTING](CONTRIBUTING.md)</i> + <u>**Installing Forge:**</u> 1. Run normal Minecraft 1.8.9 and once it reaches the title screen wait about 5 seconds and close it. diff --git a/build.gradle.kts b/build.gradle.kts index b9374fc0..4ebdd218 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,24 +1,25 @@ -import net.minecraftforge.gradle.user.ReobfMappingType import java.io.ByteArrayOutputStream plugins { + idea java - id("net.minecraftforge.gradle.forge") version "6f5327738df" - id("com.github.johnrengelman.shadow") version "6.1.0" - id("org.spongepowered.mixin") version "d75e32e" + id("gg.essential.loom") version "0.10.0.+" + id("dev.architectury.architectury-pack200") version "0.1.3" + id("com.github.johnrengelman.shadow") version "7.1.2" } + +// Build metadata + group = "io.github.moulberry" val baseVersion = "2.1" val buildExtra = mutableListOf<String>() val buildVersion = properties["BUILD_VERSION"] as? String -if (buildVersion != null) - buildExtra.add(buildVersion) +if (buildVersion != null) buildExtra.add(buildVersion) val githubCi = properties["GITHUB_ACTIONS"] as? String -if (githubCi == "true") - buildExtra.add("ci") +if (githubCi == "true") buildExtra.add("ci") val stdout = ByteArrayOutputStream() val execResult = exec { @@ -43,53 +44,58 @@ if (gitDiffStdout.toByteArray().isNotEmpty()) { version = baseVersion + (if (buildExtra.isEmpty()) "" else buildExtra.joinToString(prefix = "+", separator = ".")) -// Toolchains: - -java { - // Forge Gradle currently prevents using the toolchain: toolchain.languageVersion.set(JavaLanguageVersion.of(8)) - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} - -minecraft { - version = "1.8.9-11.15.1.2318-1.8.9" - runDir = "run" - mappings = "stable_22" - makeObfSourceJar = false - clientJvmArgs.addAll( - listOf( - "-Dmixin.debug=true", - "-Dasmhelper.verbose=true" - ) - ) - clientRunArgs.addAll( - listOf( - "--tweakClass org.spongepowered.asm.launch.MixinTweaker", - "--mixin mixins.notenoughupdates.json" - ) - ) +// Minecraft configuration: +loom { + launchConfigs { + "client" { + property("mixin.debug", "true") + property("asmhelper.verbose", "true") + arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker") + arg("--mixin", "mixins.notenoughupdates.json") + } + } + runConfigs { + "server" { + isIdeConfigGenerated = false + } + } + forge { + pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter()) + mixinConfig("mixins.notenoughupdates.json") + } + mixin { + defaultRefmapName.set("mixins.notenoughupdates.refmap.json") + } } -mixin { - add(sourceSets.main.get(), "mixins.notenoughupdates.refmap.json") -} // Dependencies: - repositories { - mavenCentral() - maven("https://repo.spongepowered.org/maven/") + mavenCentral() + mavenLocal() + maven("https://repo.spongepowered.org/maven/") + maven("https://jitpack.io") } dependencies { - implementation("org.spongepowered:mixin:0.7.11-SNAPSHOT") - annotationProcessor("org.spongepowered:mixin:0.7.11-SNAPSHOT") - implementation("com.fasterxml.jackson.core:jackson-core:2.13.1") - implementation("info.bliki.wiki:bliki-core:3.1.0") + minecraft("com.mojang:minecraft:1.8.9") + mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") + forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") + + implementation("org.spongepowered:mixin:0.7.11-SNAPSHOT") + annotationProcessor("org.spongepowered:mixin:0.8.4-SNAPSHOT") + implementation("com.fasterxml.jackson.core:jackson-core:2.13.1") + implementation("info.bliki.wiki:bliki-core:3.1.0") testImplementation("org.junit.jupiter:junit-jupiter:5.8.2") + // modImplementation("io.github.notenoughupdates:MoulConfig:0.0.1") } + +java { + toolchain.languageVersion.set(JavaLanguageVersion.of(8)) +} + // Tasks: tasks.withType(JavaCompile::class) { @@ -97,7 +103,7 @@ tasks.withType(JavaCompile::class) { } tasks.named<Test>("test") { - useJUnitPlatform() + useJUnitPlatform() } tasks.withType(Jar::class) { @@ -108,18 +114,21 @@ tasks.withType(Jar::class) { this["MixinConfigs"] = "mixins.notenoughupdates.json" this["FMLCorePluginContainsFMLMod"] = "true" this["ForceLoadAsMod"] = "true" - this["FMLAT"] = "notenoughupdates_at.cfg" } } -tasks.shadowJar { +val remapJar by tasks.named<net.fabricmc.loom.task.RemapJarTask>("remapJar") { archiveClassifier.set("dep") + from(tasks.shadowJar) +} + +tasks.shadowJar { + archiveClassifier.set("dep-dev") exclude( - "module-info.class", - "LICENSE.txt" + "module-info.class", "LICENSE.txt" ) dependencies { - include(dependency("org.spongepowered:mixin:0.7.11-SNAPSHOT")) + include(dependency("org.spongepowered:mixin:0.8.5")) include(dependency("commons-io:commons-io")) include(dependency("org.apache.commons:commons-lang3")) @@ -137,23 +146,14 @@ tasks.shadowJar { relocate("org.slf4j") } -tasks.build.get().dependsOn(tasks.shadowJar) - -reobf { - create("shadowJar") { - mappingType = ReobfMappingType.SEARGE - } -} +tasks.assemble.get().dependsOn(remapJar) tasks.processResources { - from(sourceSets.main.get().resources.srcDirs) filesMatching("mcmod.info") { expand( - "version" to project.version, - "mcversion" to minecraft.version + "version" to project.version, "mcversion" to "1.8.9" ) } - rename("(.+_at.cfg)".toPattern(), "META-INF/$1") } sourceSets.main { diff --git a/gradle.properties b/gradle.properties index bf86fb71..87c0a7c6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,2 @@ -org.gradle.jvmargs=-Xmx2G
\ No newline at end of file +org.gradle.jvmargs=-Xmx2G +loom.platform=forge diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c1ff7937..eed1d25a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip diff --git a/settings.gradle.kts b/settings.gradle.kts index 44138312..4df48664 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,17 +1,21 @@ pluginManagement { repositories { - mavenCentral() - gradlePluginPortal() - maven(url = "https://jitpack.io/") - maven(url = "https://maven.minecraftforge.net/") - maven(url = "https://repo.spongepowered.org/maven/") - } - resolutionStrategy { - eachPlugin { - when (requested.id.id) { - "net.minecraftforge.gradle.forge" -> useModule("com.github.asbyth:ForgeGradle:${requested.version}") - "org.spongepowered.mixin" -> useModule("com.github.LxGaming:MixinGradle:${requested.version}") - } - } - } + mavenCentral() + gradlePluginPortal() + maven("https://oss.sonatype.org/content/repositories/snapshots") + maven("https://maven.architectury.dev/") + maven("https://maven.fabricmc.net") + maven(url = "https://jitpack.io/") + maven(url = "https://maven.minecraftforge.net/") + maven(url = "https://repo.spongepowered.org/maven/") + maven(url = "https://repo.sk1er.club/repository/maven-releases/") + maven(url = "https://maven.architectury.dev/") + } + resolutionStrategy { + eachPlugin { + when (requested.id.id) { + "gg.essential.loom" -> useModule("gg.essential:architectury-loom:${requested.version}") + } + } + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java index fcba864c..610412ac 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -26,6 +26,7 @@ import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor; import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay; import io.github.moulberry.notenoughupdates.miscgui.TradeWindow; +import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.overlays.AuctionSearchOverlay; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; @@ -333,10 +334,10 @@ public class RenderListener { if (event.gui instanceof GuiContainer) { try { - int xSize = ((GuiContainer) event.gui).xSize; - int ySize = ((GuiContainer) event.gui).ySize; - int guiLeft = ((GuiContainer) event.gui).guiLeft; - int guiTop = ((GuiContainer) event.gui).guiTop; + int xSize = ((AccessorGuiContainer) event.gui).getXSize(); + int ySize = ((AccessorGuiContainer) event.gui).getYSize(); + int guiLeft = ((AccessorGuiContainer) event.gui).getGuiLeft(); + int guiTop = ((AccessorGuiContainer) event.gui).getGuiTop(); hoverInv = event.getMouseX() > guiLeft && event.getMouseX() < guiLeft + xSize && event.getMouseY() > guiTop && event.getMouseY() < guiTop + ySize; @@ -458,10 +459,10 @@ public class RenderListener { GlStateManager.translate(0, 0, zOffset); - int xSize = ((GuiContainer) event.gui).xSize; - int ySize = ((GuiContainer) event.gui).ySize; - int guiLeft = ((GuiContainer) event.gui).guiLeft; - int guiTop = ((GuiContainer) event.gui).guiTop; + int xSize = ((AccessorGuiContainer) event.gui).getXSize(); + int ySize = ((AccessorGuiContainer) event.gui).getYSize(); + int guiLeft = ((AccessorGuiContainer) event.gui).getGuiLeft(); + int guiTop = ((AccessorGuiContainer) event.gui).getGuiTop(); if (!NEUApi.disableInventoryButtons) { for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { @@ -565,10 +566,10 @@ public class RenderListener { if (!doInventoryButtons) return; if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && NotificationHandler.shouldRenderOverlay(event.gui) && event.gui instanceof GuiContainer) { - int xSize = ((GuiContainer) event.gui).xSize; - int ySize = ((GuiContainer) event.gui).ySize; - int guiLeft = ((GuiContainer) event.gui).guiLeft; - int guiTop = ((GuiContainer) event.gui).guiTop; + int xSize = ((AccessorGuiContainer) event.gui).getXSize(); + int ySize = ((AccessorGuiContainer) event.gui).getYSize(); + int guiLeft = ((AccessorGuiContainer) event.gui).getGuiLeft(); + int guiTop = ((AccessorGuiContainer) event.gui).getGuiTop(); if (!NEUApi.disableInventoryButtons) { for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { @@ -644,9 +645,9 @@ public class RenderListener { if (gui instanceof GuiChest && NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc != 2) { try { - int xSize = ((GuiContainer) gui).xSize; - int guiLeft = ((GuiContainer) gui).guiLeft; - int guiTop = ((GuiContainer) gui).guiTop; + int xSize = ((AccessorGuiContainer) gui).getXSize(); + int guiLeft = ((AccessorGuiContainer) gui).getGuiLeft(); + int guiTop = ((AccessorGuiContainer) gui).getGuiTop(); GuiChest eventGui = (GuiChest) gui; ContainerChest cc = (ContainerChest) eventGui.inventorySlots; @@ -899,8 +900,7 @@ public class RenderListener { GuiChest eventGui = (GuiChest) guiScreen; ContainerChest cc = (ContainerChest) eventGui.inventorySlots; containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); - if (containerName.contains(" Profile") && BetterContainers.profileViewerStackIndex != -1 && - eventGui.isMouseOverSlot(cc.inventorySlots.get(BetterContainers.profileViewerStackIndex), mouseX, mouseY) && + if (containerName.contains(" Profile") && BetterContainers.profileViewerStackIndex != -1 && ((AccessorGuiContainer)eventGui).doIsMouseOverSlot(cc.inventorySlots.get(BetterContainers.profileViewerStackIndex), mouseX, mouseY) && Mouse.getEventButton() >= 0) { event.setCanceled(true); if (Mouse.getEventButtonState() && eventGui.inventorySlots.inventorySlots.get(22).getStack() != null && @@ -959,10 +959,10 @@ public class RenderListener { if (!doInventoryButtons) return; if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && NotificationHandler.shouldRenderOverlay(event.gui) && Mouse.getEventButton() >= 0 && event.gui instanceof GuiContainer) { - int xSize = ((GuiContainer) event.gui).xSize; - int ySize = ((GuiContainer) event.gui).ySize; - int guiLeft = ((GuiContainer) event.gui).guiLeft; - int guiTop = ((GuiContainer) event.gui).guiTop; + int xSize = ((AccessorGuiContainer) event.gui).getXSize(); + int ySize = ((AccessorGuiContainer) event.gui).getYSize(); + int guiLeft = ((AccessorGuiContainer) event.gui).getGuiLeft(); + int guiTop = ((AccessorGuiContainer) event.gui).getGuiTop(); if (!NEUApi.disableInventoryButtons) { for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { if (!button.isActive()) continue; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java index 4b526185..5137c90f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java @@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; +import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -57,8 +58,8 @@ public class AuctionSortModeWarning { String warningText = "\u00a7aSort: " + selectedColour + selectedSort; int warningLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(warningText); - int centerX = chest.guiLeft + chest.xSize / 2 + 9; - int centerY = chest.guiTop + 26; + int centerX = ((AccessorGuiContainer)chest).getGuiLeft() + ((AccessorGuiContainer)chest).getXSize() / 2 + 9; + int centerY = ((AccessorGuiContainer)chest).getGuiTop() + 26; RenderUtils.drawFloatingRectDark(centerX - warningLength / 2 - 4, centerY - 6, warningLength + 8, 12, false diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java index 743625f5..9292c0d3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java @@ -5,6 +5,7 @@ import com.google.gson.GsonBuilder; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.KeybindHelper; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; +import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.SBInfo; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.ISound; @@ -200,7 +201,7 @@ public class SlotLocking { int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; - Slot slot = container.getSlotAtPosition(mouseX, mouseY); + Slot slot = ((AccessorGuiContainer) container).doGetSlotAtPosition(mouseX, mouseY); if (slot != null && slot.getSlotIndex() != 8 && slot.inventory == Minecraft.getMinecraft().thePlayer.inventory) { int slotNum = slot.getSlotIndex(); if (slotNum >= 0 && slotNum <= 39) { @@ -280,7 +281,7 @@ public class SlotLocking { int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; - Slot slot = container.getSlotAtPosition(mouseX, mouseY); + Slot slot = ((AccessorGuiContainer) container).doGetSlotAtPosition(mouseX, mouseY); if (slot != null && slot.getSlotIndex() != 8 && slot.inventory == Minecraft.getMinecraft().thePlayer.inventory) { int slotNum = slot.getSlotIndex(); if (slotNum >= 0 && slotNum <= 39) { @@ -378,10 +379,10 @@ public class SlotLocking { if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) { return; } - GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen; + AccessorGuiContainer container = (AccessorGuiContainer) Minecraft.getMinecraft().currentScreen; - int x1 = container.guiLeft + pairingSlot.xDisplayPosition + 8; - int y1 = container.guiTop + pairingSlot.yDisplayPosition + 8; + int x1 = container.getGuiLeft() + pairingSlot.xDisplayPosition + 8; + int y1 = container.getGuiTop() + pairingSlot.yDisplayPosition + 8; int x2 = event.mouseX; int y2 = event.mouseY; @@ -514,7 +515,7 @@ public class SlotLocking { return; } - boolean hoverOverSlot = container.isMouseOverSlot(slot, mouseX, mouseY); + boolean hoverOverSlot = ((AccessorGuiContainer) container).doIsMouseOverSlot(slot, mouseX, mouseY); if (hoverOverSlot || slot.getSlotIndex() >= 9) { Minecraft.getMinecraft().getTextureManager().bindTexture(BOUND); @@ -545,8 +546,8 @@ public class SlotLocking { ); } } else if (pairingSlot != null && lockKeyHeld && slot.getSlotIndex() < 8) { - int x1 = container.guiLeft + pairingSlot.xDisplayPosition; - int y1 = container.guiTop + pairingSlot.yDisplayPosition; + int x1 = ((AccessorGuiContainer)container).getGuiLeft() + pairingSlot.xDisplayPosition; + int y1 = ((AccessorGuiContainer)container).getGuiTop() + pairingSlot.yDisplayPosition; if (mouseX <= x1 || mouseX >= x1 + 16 || mouseY <= y1 || mouseY >= y1 + 16) { @@ -634,8 +635,8 @@ public class SlotLocking { int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; - int x1 = container.guiLeft + pairingSlot.xDisplayPosition; - int y1 = container.guiTop + pairingSlot.yDisplayPosition; + int x1 = ((AccessorGuiContainer)container).getGuiLeft() + pairingSlot.xDisplayPosition; + int y1 = ((AccessorGuiContainer)container).getGuiTop() + pairingSlot.yDisplayPosition; if (mouseX <= x1 || mouseX >= x1 + 16 || mouseY <= y1 || mouseY >= y1 + 16) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java index 25869452..42340259 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java @@ -9,6 +9,7 @@ import io.github.moulberry.notenoughupdates.core.GuiElementTextField; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingFloat; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; +import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.Utils; @@ -945,7 +946,7 @@ public class GuiCustomEnchant extends Gui { GlStateManager.pushMatrix(); GlStateManager.translate(guiLeft + 102 - 8, guiTop + 191 - (inventoryStartIndex / 9 * 18 + 89), 0); Slot slot = cc.getSlot(inventoryStartIndex + i); - chest.drawSlot(slot); + ((AccessorGuiContainer)chest).doDrawSlot(slot); GlStateManager.popMatrix(); if (mouseX >= itemX && mouseX < itemX + 18 && diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java index 107d4db2..5a763411 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java @@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates.miscgui; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.XPInformation; import net.minecraft.client.Minecraft; @@ -61,12 +62,12 @@ public class KatSitterOverlay { int currentWidth = font.getStringWidth(currentText); String upgradedText = "Upgraded pet level: " + upgradedLevel; int upgradedWidth = font.getStringWidth(upgradedText); - int left = gui.guiLeft - 30 - (upgradedLevel == null ? Math.max(upgradedWidth, currentWidth) : currentWidth); + int left = ((AccessorGuiContainer)gui).getGuiLeft() - 30 - (upgradedLevel == null ? Math.max(upgradedWidth, currentWidth) : currentWidth); GlStateManager.disableLighting(); GlStateManager.color(1F, 1F, 1F, 1F); - Utils.drawStringScaled(currentText, font, left, gui.guiTop + 25, false, 0xFFD700, 1F); + Utils.drawStringScaled(currentText, font, left, ((AccessorGuiContainer)gui).getGuiTop() + 25, false, 0xFFD700, 1F); if (upgradedLevel != null) - Utils.drawStringScaled(upgradedText, font, left, gui.guiTop + 45, false, 0xFFD700, 1F); + Utils.drawStringScaled(upgradedText, font, left, ((AccessorGuiContainer)gui).getGuiTop() + 45, false, 0xFFD700, 1F); } public String nextRarity(String currentRarity) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java index ac3ddfb8..cb81589d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java @@ -12,6 +12,7 @@ import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger; import io.github.moulberry.notenoughupdates.miscfeatures.BetterContainers; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; +import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; @@ -737,7 +738,7 @@ public class StorageOverlay extends GuiElement { if (storageId == currentPage) { Utils.hasEffectOverride = true; GlStateManager.translate(storageX - 7, storageY - 17 - 18, 0); - guiChest.drawSlot(containerChest.getSlot(k + 9)); + ((AccessorGuiContainer)guiChest).doDrawSlot(containerChest.getSlot(k + 9)); GlStateManager.translate(-storageX + 7, -storageY + 17 + 18, 0); Utils.hasEffectOverride = false; } else { @@ -752,7 +753,7 @@ public class StorageOverlay extends GuiElement { } else if (storageId == currentPage) { Utils.hasEffectOverride = true; GlStateManager.translate(storageX - 7, storageY - 17 - 18, 0); - guiChest.drawSlot(containerChest.getSlot(k + 9)); + ((AccessorGuiContainer)guiChest).doDrawSlot(containerChest.getSlot(k + 9)); GlStateManager.translate(-storageX + 7, -storageY + 17 + 18, 0); Utils.hasEffectOverride = false; } else { @@ -1268,7 +1269,7 @@ public class StorageOverlay extends GuiElement { GlStateManager.pushMatrix(); GlStateManager.translate(181 - 8, storageViewSize + 18 - (inventoryStartIndex / 9 * 18 + 31), 0); - guiChest.drawSlot(containerChest.inventorySlots.get(inventoryStartIndex + i)); + ((AccessorGuiContainer)guiChest).doDrawSlot(containerChest.inventorySlots.get(inventoryStartIndex + i)); GlStateManager.popMatrix(); if (!searchBar.getText().isEmpty()) { @@ -1302,7 +1303,7 @@ public class StorageOverlay extends GuiElement { //Utils.drawItemStack(playerItems[i+9], itemX, itemY); GlStateManager.pushMatrix(); GlStateManager.translate(181 - 8, storageViewSize + 18 - (inventoryStartIndex / 9 * 18 + 31), 0); - guiChest.drawSlot(containerChest.inventorySlots.get(inventoryStartIndex + 9 + i)); + ((AccessorGuiContainer)guiChest).doDrawSlot(containerChest.inventorySlots.get(inventoryStartIndex + 9 + i)); GlStateManager.popMatrix(); if (!searchBar.getText().isEmpty()) { @@ -2183,8 +2184,7 @@ public class StorageOverlay extends GuiElement { for (Slot slot : container.inventorySlots.inventorySlots) { if (slot != null && - slot.inventory == Minecraft.getMinecraft().thePlayer.inventory && - container.isMouseOverSlot(slot, mouseX, mouseY)) { + slot.inventory == Minecraft.getMinecraft().thePlayer.inventory && ((AccessorGuiContainer)container).doIsMouseOverSlot(slot, mouseX, mouseY)) { SlotLocking.getInstance().toggleLock(slot.getSlotIndex()); return true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java index 1c5bc2e3..1f47e6ee 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java @@ -4,6 +4,7 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.KeybindHelper; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; +import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -559,8 +560,7 @@ public class TradeWindow { int y = 104 + 18 * (index / 9); if (index < 9) y = 180; - chest.drawSlot(new Slot(Minecraft.getMinecraft().thePlayer.inventory, index, guiLeft + x, guiTop + y)); - //Utils.drawItemStack(stack, guiLeft+x, guiTop+y); + ((AccessorGuiContainer)chest).doDrawSlot(new Slot(Minecraft.getMinecraft().thePlayer.inventory, index, guiLeft + x, guiTop + y)); int col = 0x80ffffff; if (SlotLocking.getInstance().isSlotIndexLocked(index)) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorEntityAgeable.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorEntityAgeable.java index 9228f93d..e41c12eb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorEntityAgeable.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorEntityAgeable.java @@ -1,12 +1,14 @@ package io.github.moulberry.notenoughupdates.mixins; import net.minecraft.entity.EntityAgeable; +import net.minecraft.inventory.Slot; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(EntityAgeable.class) public interface AccessorEntityAgeable { - @Accessor(value = "growingAge") - void setGrowingAgeDirect(int newValue); + @Accessor(value = "growingAge") + void setGrowingAgeDirect(int newValue); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorGuiContainer.java new file mode 100644 index 00000000..3966317b --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorGuiContainer.java @@ -0,0 +1,33 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(GuiContainer.class) +public interface AccessorGuiContainer { + + @Invoker("getSlotAtPosition") + Slot doGetSlotAtPosition(int x, int y); + + @Invoker("drawSlot") + void doDrawSlot(Slot slot); + + @Invoker("isMouseOverSlot") + boolean doIsMouseOverSlot(Slot slot, int x, int y); + + @Accessor("guiLeft") + int getGuiLeft(); + + @Accessor("guiTop") + int getGuiTop(); + + @Accessor("xSize") + int getXSize(); + + @Accessor("ySize") + int getYSize(); + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorGuiEditSign.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorGuiEditSign.java new file mode 100644 index 00000000..ea945d5d --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorGuiEditSign.java @@ -0,0 +1,12 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import net.minecraft.client.gui.inventory.GuiEditSign; +import net.minecraft.tileentity.TileEntitySign; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(GuiEditSign.class) +public interface AccessorGuiEditSign { + @Accessor("tileSign") + TileEntitySign getTileSign(); +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java index e15d18eb..280e964e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java @@ -8,7 +8,7 @@ import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.BlockPos; import net.minecraft.world.World; -import org.spongepowered.asm.lib.Opcodes; +import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java index e98c3330..ab448660 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java @@ -9,7 +9,7 @@ import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.Entity; import net.minecraftforge.client.ForgeHooksClient; import org.lwjgl.util.vector.Vector3f; -import org.spongepowered.asm.lib.Opcodes; +import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java index b01e9609..8708afd8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java @@ -2,7 +2,7 @@ package io.github.moulberry.notenoughupdates.mixins; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; import net.minecraft.client.Minecraft; -import org.spongepowered.asm.lib.Opcodes; +import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java index 36b37766..f36c0958 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java @@ -5,6 +5,7 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.GuiElementTextField; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; +import io.github.moulberry.notenoughupdates.mixins.AccessorGuiEditSign; import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.SBInfo; @@ -86,7 +87,7 @@ public class AuctionSearchOverlay { if (lastContainer == null) return false; if (!lastContainer.equals("Auctions Browser") && !lastContainer.startsWith("Auctions: ")) return false; - TileEntitySign tes = ((GuiEditSign) Minecraft.getMinecraft().currentScreen).tileSign; + TileEntitySign tes = ((AccessorGuiEditSign) Minecraft.getMinecraft().currentScreen).getTileSign(); if (tes == null) return false; if (tes.getPos().getY() != 0) return false; @@ -289,7 +290,7 @@ public class AuctionSearchOverlay { } } - TileEntitySign tes = ((GuiEditSign) Minecraft.getMinecraft().currentScreen).tileSign; + TileEntitySign tes = ((AccessorGuiEditSign) Minecraft.getMinecraft().currentScreen).getTileSign(); String search = searchString.trim(); if (searchStringExtra != null && !searchStringExtra.isEmpty()) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java index 94bd53a2..9661812f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java @@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates.overlays; import io.github.moulberry.notenoughupdates.core.GuiElementTextField; import io.github.moulberry.notenoughupdates.core.util.GuiElementSlider; +import io.github.moulberry.notenoughupdates.mixins.AccessorGuiEditSign; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; @@ -31,7 +32,7 @@ public class RancherBootOverlay { if (!(Minecraft.getMinecraft().currentScreen instanceof GuiEditSign)) return false; - TileEntitySign tes = ((GuiEditSign) Minecraft.getMinecraft().currentScreen).tileSign; + TileEntitySign tes = ((AccessorGuiEditSign) Minecraft.getMinecraft().currentScreen).getTileSign(); if (tes == null) return false; if (tes.getPos().getY() != 0) return false; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java index 9d305e1d..45675945 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java @@ -1,6 +1,7 @@ package io.github.moulberry.notenoughupdates.recipes; import io.github.moulberry.notenoughupdates.NEUManager; +import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -49,10 +50,10 @@ public class CraftingOverlay { ) { forEachSlot(chest, (recipeIngredient, slot) -> { if (Utils.isWithinRect( - mouseX, mouseY, - slot.xDisplayPosition + gui.guiLeft, - slot.yDisplayPosition + gui.guiTop, - 16, 16 + mouseX, mouseY, + slot.xDisplayPosition + ((AccessorGuiContainer) gui).getGuiLeft(), + slot.yDisplayPosition + ((AccessorGuiContainer) gui).getGuiTop(), + 16, 16 )) block.accept(recipeIngredient, slot); }); @@ -80,9 +81,9 @@ public class CraftingOverlay { if (currentRecipe.getCraftText() != null) { FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; fontRenderer.drawStringWithShadow( - currentRecipe.getCraftText(), - Utils.peekGuiScale().getScaledWidth() / 2f - fontRenderer.getStringWidth(currentRecipe.getCraftText()) / 2f, - guiChest.guiTop - 15f, 0x808080 + currentRecipe.getCraftText(), + Utils.peekGuiScale().getScaledWidth() / 2f - fontRenderer.getStringWidth(currentRecipe.getCraftText()) / 2f, + ((AccessorGuiContainer) guiChest).getGuiTop() - 15f, 0x808080 ); } renderTooltip(guiChest, chest); @@ -140,8 +141,8 @@ public class CraftingOverlay { } private void drawItemStack(GuiChest gui, Slot slot, ItemStack item) { - int slotX = slot.xDisplayPosition + gui.guiLeft; - int slotY = slot.yDisplayPosition + gui.guiTop; + int slotX = slot.xDisplayPosition + ((AccessorGuiContainer)gui).getGuiLeft(); + int slotY = slot.yDisplayPosition + ((AccessorGuiContainer)gui).getGuiTop(); Gui.drawRect(slotX, slotY, slotX + 16, slotY + 16, 0x64ff0000); if (item != null) Utils.drawItemStack(item, slotX, slotY); diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json index c6ba98b7..ab2c705e 100644 --- a/src/main/resources/mixins.notenoughupdates.json +++ b/src/main/resources/mixins.notenoughupdates.json @@ -1,6 +1,7 @@ { "package": "io.github.moulberry.notenoughupdates.mixins", "refmap": "mixins.notenoughupdates.refmap.json", + "minVersion": "0.7", "compatibilityLevel": "JAVA_8", "mixins": [ "AccessorEntityAgeable", @@ -46,6 +47,8 @@ "MixinWorldClient" ], "client": [ + "AccessorGuiContainer", + "AccessorGuiEditSign", "AccessorMinecraft" ] } diff --git a/src/main/resources/notenoughupdates_at.cfg b/src/main/resources/notenoughupdates_at.cfg deleted file mode 100644 index c3fb5dbc..00000000 --- a/src/main/resources/notenoughupdates_at.cfg +++ /dev/null @@ -1,11 +0,0 @@ -public net.minecraft.client.gui.inventory.GuiContainer field_146999_f #xSize -public net.minecraft.client.gui.inventory.GuiContainer field_147000_g #ySize -public net.minecraft.client.gui.inventory.GuiContainer field_147003_i #guiLeft -public net.minecraft.client.gui.inventory.GuiContainer field_147009_r #guiTop -public net.minecraft.client.gui.inventory.GuiContainer func_146975_c(II)Lnet/minecraft/inventory/Slot; #guiTop -public net.minecraft.client.gui.inventory.GuiEditSign field_146848_f #tileSign -public net.minecraft.client.gui.inventory.GuiContainer func_146977_a(Lnet/minecraft/inventory/Slot;)V #drawSlot -public net.minecraft.client.gui.inventory.GuiContainer func_146981_a(Lnet/minecraft/inventory/Slot;II)Z #isMouseOverSlot -public net.minecraft.client.renderer.RenderGlobal field_72755_R #renderInfos -public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation -public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation field_178036_a #renderChunk
\ No newline at end of file |