Moved the demo server to the test directory

This commit is contained in:
themode 2020-10-11 16:02:26 +02:00
parent e783d33767
commit 551bd42b48
22 changed files with 116 additions and 41 deletions

View File

@ -1,6 +1,5 @@
package net.minestom.demo.largeframebuffers; package net.minestom.demo.largeframebuffers;
import fr.themode.demo.MainDemo;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.chat.ColoredText; import net.minestom.server.chat.ColoredText;
import net.minestom.server.entity.GameMode; import net.minestom.server.entity.GameMode;
@ -51,7 +50,8 @@ public class Demo {
// renderingLoop(0, directFramebuffer, Demo::directRendering); // renderingLoop(0, directFramebuffer, Demo::directRendering);
// renderingLoop(101, graphics2DFramebuffer, Demo::graphics2DRendering); // renderingLoop(101, graphics2DFramebuffer, Demo::graphics2DRendering);
renderingLoop(201, glfwFramebuffer, f -> {}); renderingLoop(201, glfwFramebuffer, f -> {
});
glfwFramebuffer.setupRenderLoop(15, TimeUnit.MILLISECOND, renderer); glfwFramebuffer.setupRenderLoop(15, TimeUnit.MILLISECOND, renderer);

View File

@ -0,0 +1,75 @@
package net.minestom.demo.largeframebuffers;
import net.minestom.server.MinecraftServer;
import net.minestom.server.entity.GameMode;
import net.minestom.server.event.player.PlayerLoginEvent;
import net.minestom.server.event.player.PlayerSpawnEvent;
import net.minestom.server.instance.*;
import net.minestom.server.instance.batch.ChunkBatch;
import net.minestom.server.instance.block.Block;
import net.minestom.server.network.ConnectionManager;
import net.minestom.server.utils.Position;
import net.minestom.server.world.biomes.Biome;
import java.util.Arrays;
import java.util.List;
public class MainDemo {
public static void main(String[] args) {
// Initialization
MinecraftServer minecraftServer = MinecraftServer.init();
InstanceManager instanceManager = MinecraftServer.getInstanceManager();
// Create the instance
InstanceContainer instanceContainer = instanceManager.createInstanceContainer();
// Set the ChunkGenerator
instanceContainer.setChunkGenerator(new GeneratorDemo());
// Enable the auto chunk loading (when players come close)
instanceContainer.enableAutoChunkLoad(true);
// Add event listeners
ConnectionManager connectionManager = MinecraftServer.getConnectionManager();
connectionManager.addPlayerInitialization(player -> {
// Set the spawning instance
player.addEventCallback(PlayerLoginEvent.class, event -> {
event.setSpawningInstance(instanceContainer);
player.setRespawnPoint(new Position(0,45,0));
});
// Teleport the player at spawn
player.addEventCallback(PlayerSpawnEvent.class, event -> {
player.teleport(new Position(0, 45, 0));
player.setGameMode(GameMode.CREATIVE);
});
});
// Start the server
minecraftServer.start("localhost", 25565);
}
private static class GeneratorDemo implements ChunkGenerator {
@Override
public void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ) {
// Set chunk blocks
for (byte x = 0; x < Chunk.CHUNK_SIZE_X; x++)
for (byte z = 0; z < Chunk.CHUNK_SIZE_Z; z++) {
for (byte y = 0; y < 40; y++) {
batch.setBlock(x, y, z, Block.STONE);
}
}
}
@Override
public void fillBiomes(Biome[] biomes, int chunkX, int chunkZ) {
Arrays.fill(biomes, MinecraftServer.getBiomeManager().getById(0));
}
@Override
public List<ChunkPopulator> getPopulators() {
return null;
}
}
}

View File

@ -1,9 +1,9 @@
package fr.themode.demo; package demo;
import fr.themode.demo.blocks.BurningTorchBlock; import demo.blocks.BurningTorchBlock;
import fr.themode.demo.blocks.StoneBlock; import demo.blocks.StoneBlock;
import fr.themode.demo.blocks.UpdatableBlockDemo; import demo.blocks.UpdatableBlockDemo;
import fr.themode.demo.commands.*; import demo.commands.*;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.command.CommandManager; import net.minestom.server.command.CommandManager;
import net.minestom.server.instance.block.BlockManager; import net.minestom.server.instance.block.BlockManager;

View File

@ -1,4 +1,4 @@
package fr.themode.demo; package demo;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.entity.GameMode; import net.minestom.server.entity.GameMode;

View File

@ -1,8 +1,8 @@
package fr.themode.demo; package demo;
import fr.themode.demo.blocks.StoneBlock; import demo.blocks.StoneBlock;
import fr.themode.demo.generator.ChunkGeneratorDemo; import demo.generator.ChunkGeneratorDemo;
import fr.themode.demo.generator.NoiseTestGenerator; import demo.generator.NoiseTestGenerator;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.attribute.Attribute; import net.minestom.server.attribute.Attribute;
import net.minestom.server.attribute.AttributeOperation; import net.minestom.server.attribute.AttributeOperation;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.blocks; package demo.blocks;
import net.minestom.server.data.Data; import net.minestom.server.data.Data;
import net.minestom.server.entity.Entity; import net.minestom.server.entity.Entity;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.blocks; package demo.blocks;
import net.minestom.server.data.Data; import net.minestom.server.data.Data;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.blocks; package demo.blocks;
import net.minestom.server.data.Data; import net.minestom.server.data.Data;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.commands; package demo.commands;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.command.CommandProcessor; import net.minestom.server.command.CommandProcessor;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.commands; package demo.commands;
import net.minestom.server.command.CommandSender; import net.minestom.server.command.CommandSender;
import net.minestom.server.command.builder.Arguments; import net.minestom.server.command.builder.Arguments;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.commands; package demo.commands;
import net.minestom.server.command.CommandSender; import net.minestom.server.command.CommandSender;
import net.minestom.server.command.builder.Arguments; import net.minestom.server.command.builder.Arguments;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.commands; package demo.commands;
import net.minestom.server.command.CommandSender; import net.minestom.server.command.CommandSender;
import net.minestom.server.command.builder.Arguments; import net.minestom.server.command.builder.Arguments;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.commands; package demo.commands;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.command.CommandProcessor; import net.minestom.server.command.CommandProcessor;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.commands; package demo.commands;
import net.minestom.server.command.CommandProcessor; import net.minestom.server.command.CommandProcessor;
import net.minestom.server.command.CommandSender; import net.minestom.server.command.CommandSender;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.commands; package demo.commands;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.command.builder.Command; import net.minestom.server.command.builder.Command;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.commands; package demo.commands;
import net.minestom.server.command.CommandSender; import net.minestom.server.command.CommandSender;
import net.minestom.server.command.builder.Arguments; import net.minestom.server.command.builder.Arguments;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.entity; package demo.entity;
import net.minestom.server.attribute.Attribute; import net.minestom.server.attribute.Attribute;
import net.minestom.server.entity.LivingEntity; import net.minestom.server.entity.LivingEntity;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.entity; package demo.entity;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.LivingEntity; import net.minestom.server.entity.LivingEntity;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.entity; package demo.entity;
import net.minestom.server.entity.ai.goal.RandomLookAroundGoal; import net.minestom.server.entity.ai.goal.RandomLookAroundGoal;
import net.minestom.server.entity.type.monster.EntityZombie; import net.minestom.server.entity.type.monster.EntityZombie;

View File

@ -1,12 +1,12 @@
package fr.themode.demo.generator; package demo.generator;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.world.biomes.Biome;
import net.minestom.server.instance.Chunk; import net.minestom.server.instance.Chunk;
import net.minestom.server.instance.ChunkGenerator; import net.minestom.server.instance.ChunkGenerator;
import net.minestom.server.instance.ChunkPopulator; import net.minestom.server.instance.ChunkPopulator;
import net.minestom.server.instance.batch.ChunkBatch; import net.minestom.server.instance.batch.ChunkBatch;
import net.minestom.server.instance.block.Block; import net.minestom.server.instance.block.Block;
import net.minestom.server.world.biomes.Biome;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.generator; package demo.generator;
import de.articdive.jnoise.JNoise; import de.articdive.jnoise.JNoise;
import de.articdive.jnoise.interpolation.InterpolationType; import de.articdive.jnoise.interpolation.InterpolationType;

View File

@ -1,4 +1,4 @@
package fr.themode.demo.generator; package demo.generator;
import lombok.Data; import lombok.Data;
import net.minestom.server.instance.Chunk; import net.minestom.server.instance.Chunk;