No playin' no emeralds

This commit is contained in:
skippyall
2026-05-27 00:10:13 +02:00
parent 3788f67a53
commit 86be624b93
2 changed files with 18 additions and 2 deletions
+1 -1
View File
@@ -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
+17 -1
View File
@@ -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;
}
}