This commit is contained in:
Minecon724 2024-07-11 18:38:52 +02:00
parent 7d69e1db4a
commit e1f6bfcf0b
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
3 changed files with 56 additions and 3 deletions

View file

@ -3,6 +3,7 @@ package net.pivipi;
import net.minestom.server.MinecraftServer;
import net.minestom.server.event.GlobalEventHandler;
import net.minestom.server.extras.velocity.VelocityProxy;
import net.minestom.server.instance.InstanceContainer;
import net.minestom.server.instance.InstanceManager;
import net.minestom.server.instance.LightingChunk;
@ -23,6 +24,7 @@ public class Main {
InstanceManager instanceManager = MinecraftServer.getInstanceManager();
GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
SchedulerManager schedulerManager = MinecraftServer.getSchedulerManager();
Key<DimensionType> dimension = FancyDimension.create();
InstanceContainer instanceContainer = instanceManager.createInstanceContainer(dimension);
@ -36,14 +38,16 @@ public class Main {
WorldConstraints worldConstraints = new WorldConstraints();
worldConstraints.setup(globalEventHandler);
new Stats(instanceManager).start(schedulerManager);
/* done */
MinecraftServer.setCompressionThreshold(0);
MinecraftServer.setBrandName("PiViPi");
minecraftServer.start("0.0.0.0", 25565);
System.out.println("started");
minecraftServer.start("127.0.0.1", 25565);
System.out.println("Listening on port 25565");
}
}

View file

@ -0,0 +1,49 @@
package net.pivipi;
import java.time.Duration;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentBuilder;
import net.minestom.server.MinecraftServer;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.InstanceManager;
import net.minestom.server.monitoring.BenchmarkManager;
import net.minestom.server.network.packet.server.play.DeclareRecipesPacket.Ingredient;
import net.minestom.server.timer.SchedulerManager;
import net.minestom.server.timer.TaskSchedule;
public class Stats implements Runnable {
private int tickDelay = 10;
private InstanceManager instanceManager;
private BenchmarkManager benchmarkManager;
private long lastRun;
public Stats(InstanceManager instanceManager) {
this.instanceManager = instanceManager;
}
public void start(SchedulerManager schedulerManager) {
this.benchmarkManager = MinecraftServer.getBenchmarkManager();
schedulerManager.scheduleTask(this, TaskSchedule.immediate(), TaskSchedule.tick(tickDelay));
}
@Override
public void run() {
long now = System.currentTimeMillis();
long delay = now - lastRun;
lastRun = now;
double mspt = (double)delay / tickDelay;
double tps = 1000 / mspt;
long mem = benchmarkManager.getUsedMemory() / 1024 / 1024;
Component footer = Component.text("MSPT: %f | TPS: %f | Mem: %dMB".formatted(mspt, tps, mem)).appendNewline().append(benchmarkManager.getCpuMonitoringMessage());
instanceManager.getInstances().forEach(instance -> {
instance.getPlayers().forEach(player -> {
player.sendPlayerListFooter(footer);
});
});
}
}

View file

@ -14,7 +14,7 @@ public class SoccerGenerator implements Generator {
public void generate(@NotNull GenerationUnit unit) {
UnitModifier modifier = unit.modifier();
modifier.fillBiome(Biome.CRIMSON_FOREST);
modifier.fillBiome(Biome.PLAINS);
modifier.fillHeight(63, 64, Block.WHITE_WOOL);
modifier.fill(unit.absoluteStart().withY(63).add(1, 0, 1), unit.absoluteEnd().withY(64), Block.GREEN_CONCRETE_POWDER);