diff --git a/build.gradle b/build.gradle index 919b856..1fa1a5c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.2-SNAPSHOT' + id 'fabric-loom' version '1.4-SNAPSHOT' id 'com.diffplug.spotless' version '6.19.0' id "com.modrinth.minotaur" version "2.+" } @@ -11,13 +11,16 @@ repositories { maven { url 'https://masa.dy.fi/maven' } maven { url 'https://maven.terraformersmc.com/releases/' } maven { url 'https://jitpack.io' } + flatDir { + dirs '.' + } } dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.mappings_version}:v2" modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}" - modImplementation "com.github.Nyan-Work:malilib:${project.malilib_version}" + modImplementation "fi.dy.masa.malilib:malilib-fabric-${project.minecraft_version_out}:${project.malilib_version}" modCompileOnly "com.terraformersmc:modmenu:${project.mod_menu_version}" } @@ -58,7 +61,7 @@ modrinth { syncBodyFrom = rootProject.file("README.md").text projectId = 'C1naQCmt' uploadFile = remapJar - gameVersions = ['1.20.2'] + gameVersions = ['1.20.3','1.20.4'] loaders = ['fabric'] dependencies = [] } diff --git a/gradle.properties b/gradle.properties index e1fcd4f..bf16082 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,12 +7,12 @@ mod_name = AutoTrade author = sebseb7 mod_file_name = autotrade-fabric -mod_version = 0.0.5 +mod_version = 0.0.6 -malilib_version = 0.16.2-nyan.6 +malilib_version = 0.18.0 -minecraft_version_out = 1.20.2 -minecraft_version = 1.20.2 -mappings_version = 1.20.2+build.4 -fabric_loader_version = 0.14.22 -mod_menu_version = 8.0.0 +minecraft_version_out = 1.20.4 +minecraft_version = 1.20.4 +mappings_version = 1.20.4+build.1 +fabric_loader_version = 0.15.1 +mod_menu_version = 9.0.0-pre.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 87048d3..6fa1395 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/github/sebseb7/autotrade/AutoTrade.java b/src/main/java/com/github/sebseb7/autotrade/AutoTrade.java index d4c4002..8af15b0 100644 --- a/src/main/java/com/github/sebseb7/autotrade/AutoTrade.java +++ b/src/main/java/com/github/sebseb7/autotrade/AutoTrade.java @@ -7,6 +7,9 @@ import org.apache.logging.log4j.Logger; public class AutoTrade implements ModInitializer { public static final Logger logger = LogManager.getLogger(Reference.MOD_ID); + public static long sessionStart = 0; + public static int sold = 0; + public static int bought = 0; @Override public void onInitialize() { diff --git a/src/main/java/com/github/sebseb7/autotrade/event/KeybindCallbacks.java b/src/main/java/com/github/sebseb7/autotrade/event/KeybindCallbacks.java index 6236d9e..6e2977c 100644 --- a/src/main/java/com/github/sebseb7/autotrade/event/KeybindCallbacks.java +++ b/src/main/java/com/github/sebseb7/autotrade/event/KeybindCallbacks.java @@ -1,5 +1,6 @@ package com.github.sebseb7.autotrade.event; +import com.github.sebseb7.autotrade.AutoTrade; import com.github.sebseb7.autotrade.config.Configs; import com.github.sebseb7.autotrade.config.Hotkeys; import com.github.sebseb7.autotrade.gui.GuiConfigs; @@ -52,6 +53,7 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler { private boolean outputOpened = false; private int tickCount = 0; private int voidDelay = 0; + private int screenOpened = 0; public static KeybindCallbacks getInstance() { return INSTANCE; @@ -152,6 +154,11 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler { ? "autotrade.message.toggled_mod_on" : "autotrade.message.toggled_mod_off"; InfoUtils.showGuiOrInGameMessage(Message.MessageType.INFO, msg); + if (this.functionalityEnabled()) { + AutoTrade.sold = 0; + AutoTrade.bought = 0; + AutoTrade.sessionStart = System.currentTimeMillis() / 1000L; + } } else if (key == Hotkeys.OPEN_GUI_SETTINGS.getKeybind()) { GuiBase.openGui(new GuiConfigs()); return true; @@ -224,6 +231,7 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler { handler.switchTo(i); handler.setRecipeIndex(i); mc.getNetworkHandler().sendPacket(new SelectMerchantTradeC2SPacket(i)); + AutoTrade.sold += offer.getMaxUses(); try { mc.interactionManager.clickSlot(handler.syncId, slot.id, 0, SlotActionType.QUICK_MOVE, mc.player); @@ -236,6 +244,7 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler { Slot slot = handler.getSlot(2); handler.switchTo(i); handler.setRecipeIndex(i); + AutoTrade.bought += offer.getMaxUses(); mc.getNetworkHandler().sendPacket(new SelectMerchantTradeC2SPacket(i)); try { mc.interactionManager.clickSlot(handler.syncId, slot.id, 0, SlotActionType.QUICK_MOVE, @@ -285,7 +294,7 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler { for (Entity entity : mc.player.clientWorld.getEntities()) { if (entity instanceof VillagerEntity) { - if (entity.getPos().distanceTo(mc.player.getPos()) < 3) { + if (entity.getPos().distanceTo(mc.player.getPos()) < 2.5f) { if (found == false) { if (newVillagersInRange.contains(entity) == false) { found = true; @@ -352,6 +361,15 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler { villagersInRange = new Vector(); inputInRange = false; outputInRange = false; + if (GuiUtils.getCurrentScreen() instanceof MerchantScreen) { + GuiUtils.getCurrentScreen().close(); + } + if (GuiUtils.getCurrentScreen() instanceof ShulkerBoxScreen) { + GuiUtils.getCurrentScreen().close(); + } + if (GuiUtils.getCurrentScreen() instanceof GenericContainerScreen) { + GuiUtils.getCurrentScreen().close(); + } } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a82fd08..16d9dea 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,7 +30,7 @@ ], "depends": { - "minecraft": "1.20.2", - "malilib": "0.16.x" + "minecraft": ">=1.20.3", + "malilib": ">=0.18.0" } }