From 86be624b93b0343ddb5773abfda7ec88bcd13ba6 Mon Sep 17 00:00:00 2001 From: skippyall <121978267+skippyall@users.noreply.github.com> Date: Wed, 27 May 2026 00:10:13 +0200 Subject: [PATCH] No playin' no emeralds --- gradle.properties | 2 +- src/main/java/de/foxgalaxy/villa/VillaMod.java | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index dbc224b..0170d5b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ loader_version=0.19.2 loom_version=1.16-SNAPSHOT # Mod Properties -mod_version=1.0.2 +mod_version=1.0.3 maven_group=de.foxgalaxy.villa # Dependencies diff --git a/src/main/java/de/foxgalaxy/villa/VillaMod.java b/src/main/java/de/foxgalaxy/villa/VillaMod.java index c612e92..b020825 100644 --- a/src/main/java/de/foxgalaxy/villa/VillaMod.java +++ b/src/main/java/de/foxgalaxy/villa/VillaMod.java @@ -18,6 +18,7 @@ import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.tags.TagKey; +import net.minecraft.util.Util; import net.minecraft.world.clock.ClockTimeMarkers; import net.minecraft.world.clock.WorldClocks; import net.minecraft.world.entity.EquipmentSlot; @@ -28,6 +29,8 @@ import net.minecraft.world.item.Items; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.concurrent.TimeUnit; + public class VillaMod implements ModInitializer { public static final String MOD_ID = "villa"; @@ -53,7 +56,7 @@ public class VillaMod implements ModInitializer { } }); ServerTickEvents.END_SERVER_TICK.register(server -> { - if(server.overworld().clockManager().isAtTimeMarker(server.registryAccess().getOrThrow(WorldClocks.OVERWORLD), ClockTimeMarkers.DAY)) { + if(shouldInsertEmeralds(server)) { insertEmeralds(server); } }); @@ -90,4 +93,17 @@ public class VillaMod implements ModInitializer { } } } + + public static boolean shouldInsertEmeralds(MinecraftServer server) { + if(server.clockManager().isAtTimeMarker(server.registryAccess().getOrThrow(WorldClocks.OVERWORLD), ClockTimeMarkers.DAY)) { + if(server.getPlayerList().getPlayerCount() > 0) { + for(ServerPlayer player : server.getPlayerList().getPlayers()) { + if(Util.getMillis() - player.getLastActionTime() < TimeUnit.MINUTES.toMillis(5)) { + return true; + } + } + } + } + return false; + } } \ No newline at end of file