Skip to content

Commit

Permalink
fix potential log spam
Browse files Browse the repository at this point in the history
  • Loading branch information
btwonion committed Nov 23, 2024
1 parent c691b01 commit 1fc946b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- add support for 1.21.4 fabric
- correctly deactivate buttons in the config screen
- update config screen translations
- update config screen translations
- fix log spam when items affected by autodrop where moved into your inventory while having a container opened
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions src/main/java/dev/nyon/autodrop/mixins/InventoryMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer> cir
){
if (ConfigHandlerKt.getConfig()
.getTriggerConfig()
.getOnPickup()) AutoDrop.INSTANCE.invokeAutodrop();
}
}
7 changes: 1 addition & 6 deletions src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1fc946b

Please sign in to comment.