mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-05 15:01:46 +01:00
LWJGL is now an optional dependency (example project to use it incoming)
This commit is contained in:
parent
3144f64b06
commit
5533e3f9e7
35
build.gradle
35
build.gradle
@ -51,6 +51,21 @@ sourceSets {
|
||||
compileClasspath += sourceSets.main.runtimeClasspath
|
||||
runtimeClasspath += sourceSets.main.runtimeClasspath
|
||||
}
|
||||
lwjgl {
|
||||
java {
|
||||
srcDir 'src/lwjgl/java'
|
||||
}
|
||||
|
||||
compileClasspath += sourceSets.main.runtimeClasspath
|
||||
runtimeClasspath += sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
// Minestom uses LWJGL libs as optional dependency if interfacing with a GPU is asked
|
||||
java {
|
||||
registerFeature("lwjgl") {
|
||||
usingSourceSet(sourceSets.lwjgl)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -95,15 +110,15 @@ dependencies {
|
||||
api 'com.github.jglrxavpok:Hephaistos:v1.0.4'
|
||||
|
||||
// LWJGL, for map rendering
|
||||
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
|
||||
lwjglApi platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
|
||||
|
||||
api "org.lwjgl:lwjgl"
|
||||
api "org.lwjgl:lwjgl-egl"
|
||||
api "org.lwjgl:lwjgl-opengl"
|
||||
api "org.lwjgl:lwjgl-opengles"
|
||||
api "org.lwjgl:lwjgl-glfw"
|
||||
runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-opengles::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
|
||||
lwjglApi "org.lwjgl:lwjgl"
|
||||
lwjglApi "org.lwjgl:lwjgl-egl"
|
||||
lwjglApi "org.lwjgl:lwjgl-opengl"
|
||||
lwjglApi "org.lwjgl:lwjgl-opengles"
|
||||
lwjglApi "org.lwjgl:lwjgl-glfw"
|
||||
lwjglRuntimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
|
||||
lwjglRuntimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
|
||||
lwjglRuntimeOnly "org.lwjgl:lwjgl-opengles::$lwjglNatives"
|
||||
lwjglRuntimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
|
||||
}
|
||||
|
4
src/lwjgl/README.md
Normal file
4
src/lwjgl/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Minestom LWJGL code
|
||||
|
||||
Here is all LWJGL-related code in Minestom.
|
||||
Accessible when using "lwjgl" as an optional dependency in Gradle when declaring Minestom as a dependency
|
@ -1,5 +1,6 @@
|
||||
package fr.themode.demo.map;
|
||||
|
||||
import fr.themode.demo.Main;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.event.player.PlayerSpawnEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
@ -131,4 +132,12 @@ public class MapAnimationDemo {
|
||||
p.getPlayerConnection().sendPacket(mapDataPacket);
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
MinecraftServer.init();
|
||||
|
||||
MinecraftServer.getCommandManager().register(new TestItemFrame());
|
||||
init();
|
||||
Main.main(args);
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package fr.themode.demo.commands;
|
||||
package fr.themode.demo.map;
|
||||
|
||||
import fr.themode.demo.map.MapAnimationDemo;
|
||||
import net.minestom.server.command.CommandProcessor;
|
||||
import net.minestom.server.command.CommandSender;
|
||||
import net.minestom.server.entity.Player;
|
@ -10,12 +10,11 @@ import org.lwjgl.PointerBuffer;
|
||||
import org.lwjgl.glfw.GLFWErrorCallback;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
/**
|
||||
* GLFW-based framebuffer.
|
||||
@ -31,6 +30,8 @@ import static org.lwjgl.glfw.GLFW.*;
|
||||
*
|
||||
* GLFWFramebuffer does not provide guarantee that the result of {@link #toMapColors()} is synchronized with rendering, but
|
||||
* it will be updated after each frame rendered through {@link #render(Runnable)} or {@link #setupRenderLoop(long, TimeUnit, Runnable)}.
|
||||
*
|
||||
* This framebuffer is meant to render to a single map (ie it is only compatible with 128x128 rendering)
|
||||
*/
|
||||
public class GLFWFramebuffer implements Framebuffer {
|
||||
|
@ -4,7 +4,6 @@ import fr.themode.demo.blocks.BurningTorchBlock;
|
||||
import fr.themode.demo.blocks.StoneBlock;
|
||||
import fr.themode.demo.blocks.UpdatableBlockDemo;
|
||||
import fr.themode.demo.commands.*;
|
||||
import fr.themode.demo.map.MapAnimationDemo;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.command.CommandManager;
|
||||
import net.minestom.server.instance.block.BlockManager;
|
||||
@ -35,9 +34,6 @@ public class Main {
|
||||
commandManager.register(new GamemodeCommand());
|
||||
commandManager.register(new DimensionCommand());
|
||||
commandManager.register(new ShutdownCommand());
|
||||
commandManager.register(new TestItemFrame());
|
||||
|
||||
MapAnimationDemo.init();
|
||||
|
||||
/*RecipeManager recipeManager = MinecraftServer.getRecipeManager();
|
||||
ShapelessRecipe shapelessRecipe = new ShapelessRecipe("test", "groupname") {
|
||||
|
@ -127,6 +127,8 @@ public class MinecraftServer {
|
||||
private static MinecraftSessionService sessionService = authService.createMinecraftSessionService();
|
||||
|
||||
public static MinecraftServer init() {
|
||||
if(minecraftServer != null) // don't init twice
|
||||
return minecraftServer;
|
||||
// warmup/force-init registries
|
||||
// without this line, registry types that are not loaded explicitly will have an internal empty registry in Registries
|
||||
// That can happen with PotionType for instance, if no code tries to access a PotionType field
|
||||
|
Loading…
Reference in New Issue
Block a user