Attempt to fix multiple clicks being triggered in chestgui

This commit is contained in:
zontreck 2024-01-15 00:38:37 -07:00
parent d773f34376
commit bef8f89f97
2 changed files with 12 additions and 2 deletions

View file

@ -53,7 +53,7 @@ mod_name=Zontreck Library Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPLv3
# The mod version. See https://semver.org/
mod_version=1.10.011524.0023
mod_version=1.10.011524.0036
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -11,6 +11,7 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.ItemStackHandler;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
@ -155,8 +156,17 @@ public class ChestGUIButton
return (int) Math.floor((position.x * 9) + position.y);
}
private static long lastInvoked = 0;
/**
* Button was clicked!
*/
public void clicked()
{
callback.run(built, container, lore);
if(Instant.now().getEpochSecond() > (lastInvoked + 3))
{
lastInvoked = Instant.now().getEpochSecond();
callback.run(built, container, lore);
}
}
}