From 1fc946b1cf84b5e388cc3f46ba20145be9f328ca Mon Sep 17 00:00:00 2001 From: btwonion Date: Sat, 23 Nov 2024 19:24:37 +0100 Subject: [PATCH] fix potential log spam --- changelog.md | 3 ++- gradle.properties | 2 +- .../dev/nyon/autodrop/mixins/InventoryMixin.java | 14 ++++++++++++++ src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt | 7 +------ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index ff533e4..e4a0360 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,4 @@ - add support for 1.21.4 fabric - correctly deactivate buttons in the config screen -- update config screen translations \ No newline at end of file +- update config screen translations +- fix log spam when items affected by autodrop where moved into your inventory while having a container opened \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index d87d28c..fad26b2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,6 +12,6 @@ mod.id=autodrop mod.name=autodrop mod.description=Simply drops specific items after pickup mod.beta=0 -mod.major-version=2.1.0 +mod.major-version=2.2.0 mod.mixins=autodrop.mixins.json mod.supported-loaders=fabric,quilt,neoforge \ No newline at end of file diff --git a/src/main/java/dev/nyon/autodrop/mixins/InventoryMixin.java b/src/main/java/dev/nyon/autodrop/mixins/InventoryMixin.java index 3a672ec..ffc3332 100644 --- a/src/main/java/dev/nyon/autodrop/mixins/InventoryMixin.java +++ b/src/main/java/dev/nyon/autodrop/mixins/InventoryMixin.java @@ -40,4 +40,18 @@ public void invokeOnTake( .getTriggerConfig() .getOnPickup()) AutoDrop.INSTANCE.invokeAutodrop(); } + + @Inject( + method = "addResource(ILnet/minecraft/world/item/ItemStack;)I", + at = @At("RETURN") + ) + public void invokeOnResourceTake( + int slot, + ItemStack stack, + CallbackInfoReturnable cir + ){ + if (ConfigHandlerKt.getConfig() + .getTriggerConfig() + .getOnPickup()) AutoDrop.INSTANCE.invokeAutodrop(); + } } diff --git a/src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt b/src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt index 6ed1c4b..a878570 100644 --- a/src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt +++ b/src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt @@ -49,7 +49,6 @@ object AutoDrop { val amountValid = itemStack.count >= identifier.amount /*? if >=1.21 {*/ - val componentValid = identifier.components.isEmpty || identifier.components.entrySet().all { (key, component) -> val identifierComponent = component.get() @@ -90,11 +89,7 @@ object AutoDrop { } - if (!isValid) return@forEach - - minecraft.gameMode?.handleInventoryMouseClick( - screen.menu.containerId, slot.index, 1, ClickType.THROW, player - ) + if (isValid) minecraft.gameMode?.handleInventoryMouseClick(player.containerMenu.containerId, slot.index, 1, ClickType.THROW, player) } jobWaiting = false