No playin' no emeralds
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ loader_version=0.19.2
|
|||||||
loom_version=1.16-SNAPSHOT
|
loom_version=1.16-SNAPSHOT
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.0.2
|
mod_version=1.0.3
|
||||||
maven_group=de.foxgalaxy.villa
|
maven_group=de.foxgalaxy.villa
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import net.minecraft.resources.Identifier;
|
|||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
|
import net.minecraft.util.Util;
|
||||||
import net.minecraft.world.clock.ClockTimeMarkers;
|
import net.minecraft.world.clock.ClockTimeMarkers;
|
||||||
import net.minecraft.world.clock.WorldClocks;
|
import net.minecraft.world.clock.WorldClocks;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
@@ -28,6 +29,8 @@ import net.minecraft.world.item.Items;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class VillaMod implements ModInitializer {
|
public class VillaMod implements ModInitializer {
|
||||||
public static final String MOD_ID = "villa";
|
public static final String MOD_ID = "villa";
|
||||||
|
|
||||||
@@ -53,7 +56,7 @@ public class VillaMod implements ModInitializer {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
ServerTickEvents.END_SERVER_TICK.register(server -> {
|
ServerTickEvents.END_SERVER_TICK.register(server -> {
|
||||||
if(server.overworld().clockManager().isAtTimeMarker(server.registryAccess().getOrThrow(WorldClocks.OVERWORLD), ClockTimeMarkers.DAY)) {
|
if(shouldInsertEmeralds(server)) {
|
||||||
insertEmeralds(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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user