A networking library for LibGDX utilizing Netty allowing easy creation of multiplayer games.

Overview

Lunar

What is Lunar?

Lunar is a networking library for LibGDX. With lunar you can easily create multiplayer games quickly and efficiently. Lunar provides many common utilities such as entities, worlds, protocol, and box2d support!

Lunar is still very early, so please be nice :)

Actual Game Demo

https://github.com/Vrekt/OasisGame

Features

  • Player and entity renderers with animation loading.
  • Partially Networked Box2d worlds.
  • Networked player moving and velocity.
  • Networked player creation/removing.
  • Game lobbies and worlds.
  • Basic entity support
  • A expandable protocol with SSL support.
  • Very customizable and extendable.

Get A Taste

// apply force to another player and send it to others since they were attacked.
this.player.getWorldIn().applyForceToOtherPlayerNetwork(somePlayer, player.getConnection(), fx, fy, px, py, true);

// apply a knock-back force to ourselves.
this.player.getWorldIn().applyForceToPlayerNetwork(player.getConnection(), fx, fy, point.x, point.y, true);
// register a unique custom packet.
this.connection.registerPacket(99, MyCustomPacket::new, packet -> handleEntityPropertiesPacket(packet));
// Create a networked world for others to join us.
// We tell the world to handle physics updates and local player updates for us.
lunarWorld = new BasicLunarWorld(player, world, scaling, true, true, true);
// Spawn our player in the world.
player.spawnEntityInWorld(lunarWorld, 2.0f, 2.0f);
// connect to remote server.
final LunarClientServer server = new LunarClientServer(lunar, "localhost", 6969);
server.connect().join();

// get our connection
final PlayerConnection connection = (PlayerConnection) server.getConnection();

Want to jump in? Check out the Building A Simple Game

Documentation and Examples

Examples

Wiki

Planned Features

  • Networked collision
  • Better movement sync.
  • Better protocol security.
  • Networked entities and other map/world objects.
  • ...

Known Issues

  • Random ghost player blinks next to networked player
  • Initial position seems to be de-synced some way
  • Worlds will need to be disposed when switching between them
  • probably other stuff I don't know about.

Using Lunar

You can find releases in the releases section. Both client and server rely on the Protocol dependency.

You must also add a dependency for netty-all.

Gradle 6.7.2
implementation group: 'io.netty', name: 'netty-all', version: '4.1.48.Final'
Comments
  • Server tasks

    Server tasks

    • [ ] Rewrite lobby system
    • [x] Rewrite world system
    • [x] Rewrite entity system using ashley.
    • [x] Better server structure
    • [ ] - Allow change username
    • [ ] - Allow NULL usernames
    • [ ] - Server example
    opened by Vrekt 1
  • Implement networked states with inputs, trusted, auth, etc.

    Implement networked states with inputs, trusted, auth, etc.

    Implement a new networking model with GameStates full of inputs processed in a single update/tick period.

    • [ ] Implement a GameState interface
    • [ ] Implement a Input interface
    • [ ] Implement an Authorization interface
    • [ ] Handle all of the above.
    opened by Vrekt 1
  • Ghost player rendering next to networked players

    Ghost player rendering next to networked players

    In the basic example sometimes a ghost player can be seen.

    Could be:

    • Drawing artifacts from offsetting Box2d world.
    • Players aren't getting cleared
    • Something else
    opened by Vrekt 1
  • Identify and fix rare memory leaks

    Identify and fix rare memory leaks

    Oct 06, 2021 11:17:01 PM io.netty.util.ResourceLeakDetector reportTracedLeak
    SEVERE: LEAK: ByteBuf.release() was not called before it's garbage-collected. See https://netty.io/wiki/reference-counted-objects.html for more information.
    Recent access records: 
    Created at:
    	io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:363)
    	io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:187)
    	io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:178)
    	io.netty.buffer.AbstractByteBufAllocator.ioBuffer(AbstractByteBufAllocator.java:131)
    	gdx.lunar.protocol.packet.Packet.<init>(Packet.java:19)
    	gdx.lunar.protocol.packet.server.SPacketPlayerVelocity.<init>(SPacketPlayerVelocity.java:43)
    	gdx.lunar.server.world.World.handlePlayerVelocity(World.java:176)
    	gdx.lunar.server.network.PlayerConnection.handlePlayerVelocity(PlayerConnection.java:69)
    	gdx.lunar.protocol.packet.client.CPacketVelocity.handle(CPacketVelocity.java:26)
    	gdx.lunar.protocol.LunarProtocol.lambda$initializeClient$15(LunarProtocol.java:124)
    	gdx.lunar.protocol.LunarProtocol.handleClientPacket(LunarProtocol.java:198)
    	gdx.lunar.server.netty.codec.ClientProtocolPacketDecoder.decode(ClientProtocolPacketDecoder.java:36)
    	io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:332)
    	io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:498)
    	io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:437)
    	io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
    	io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    	io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    	io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    	io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1486)
    	io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1235)
    	io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1282)
    	io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:498)
    	io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:437)
    	io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
    	io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    	io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    	io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    	io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    	io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    	io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    	io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    	io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
    	io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
    	io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
    	io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
    	io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
    	io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    	io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    	io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    	java.lang.Thread.run(Thread.java:748)
    
    opened by Vrekt 0
  • ISAAC Cipher for packets

    ISAAC Cipher for packets

    This network infrastructure reminds me of RuneScape private server designs. I would suggest the ISAAC Cipher for packet security if that's something you're interested in. I also remember RuneScape used RSA for username and password encryption as well, so another thing to look at. Not really an issue, but a suggestion.

    enhancement network netty 
    opened by tehnewb 1
  • Implement networked tiles and maps

    Implement networked tiles and maps

    Start working on implementing networked tiles/textures, objects and maps.

    Ideally, have a general Tile that has a String texture location and position to spawn locally.

    • [ ] Implement Tile class
    • [ ] Implement NetworkedTiledMap class
    • [ ] Implement Tile update packets
    • [ ] Tile IDs
    enhancement world network protocol 
    opened by Vrekt 0
Releases(2.0)
Owner
Vrekt
Java developer, 4+ years making stuff with Minecraft, Fortnite, JDA, etc.
Vrekt
A set of example projects utilizing Discord4J

Discord4J Example Projects Provided are a set of very simple example projects showcasing two simple slash commands: ping-pong and greet using Discord4

null 17 Nov 8, 2022
Automatic creation of simple CRUD API of Spring boot and JPA project.

fast-crud Automatic creation of simple CRUD API of Spring boot and JPA project.

JinHwanKim 18 Oct 23, 2022
Caches datapack- and server resources to make world creation faster.

antiresourcereload Caches datapack- and server resources to make world creation faster. Legalisation Status Legal (1.0.2) Description I found out abou

Wurgo 13 Nov 18, 2022
This is a Maven plugin designed to help developers automatizing the creation of code classes from YML files based on AsyncApi and OpenAPI.

SCS MultiApi Maven Plugin This is a Maven plugin designed to help developers automatizing the creation of code classes from YML files based on AsyncAp

Corunet 0 Dec 20, 2022
LibGDX PSX-style render features

gdx-psx gdx-psx its a library for LibGDX designed to assist you in simulation of PlayStation 1 graphics with few simple steps! If you have questions o

Matvey 27 Dec 10, 2022
An open source civilization like game made in LibGDX

OpenCiv A turn based strategy game built on LibGDX, with a rouge-like tile set. About OpenCiv is a love letter to turn based strategy games inspired b

Rhin 58 Dec 26, 2022
Kotlin/LibGDX port of my Unity 2D Sandbox

TileRPG Kotlin port/continuation of my Unity TileRPG game, which was in itself a rewrite of my first attempt at making a 2D sandbox game. A libGDX pro

null 1 Jan 23, 2022
Brain/out is a multiplayer shooter with a nostalgic post-soviet feel

Brain / Out Source code for Brain / Out, the game. How To Build From Source First, clone this repo. Use Gradle Wrapper: ./gradlew <command> on mac/lin

Alex Siryi 69 Jan 7, 2023
Source code of the standalone multiplayer server software of the game "Celaria"

Celaria Server This is the source code of the standalone multiplayer server for the Game "Celaria". (https://www.celaria.com) of modding the server si

Lewa 3 Nov 14, 2021
Java library allowing for quick development of Discord bots

Discord-Bot-Library Java library that acts as an abstraction of Discord4J, allowing for quick development of Discord bots The goal for this project wa

null 20 Apr 20, 2022
This is the VapeCloud project, it is a Minecraft Dynamic CloudSystem based on Nio-Networking.

This is the VapeCloud project, it is a Minecraft Dynamic CloudSystem based on Nio-Networking. IMPORTENT: this Cloudsystem is still in Development Requ

RauchigesEtwas 2 Dec 19, 2022
Java - Packet Analyzer Application based on Java, Networking and Swing UI

Network-Packet-Tracer-using-Java Java - Packet Analyzer / Sniffing System Application based on Java, Networking and Swing UI Java - Packet Analyzer Ap

Muhammad Asad 6 Feb 3, 2022
Some anti afk bot which prevents you from getting punished for going afk in games. Way of stopping the bot is slightly flawed but we'll ignore that.

AntiAFK Some anti afk bot which prevents you from getting punished for going afk in games. Gui mode coming soon... Installation Install Java 17. Downl

flasky 1 Jan 13, 2022
A tool to create flags for Paradox Interactive games.

Iron Workshop Flag Creator Instllation and Usage Instructions Instructional video here: https://youtu.be/0a8xXvN_ygk Flag Creator Purpose and Use The

null 5 Sep 11, 2022
fork of autoGG for fabric to pay respect to Techno after games.

AutoTechno Description: This mod is a tribute to the youtuber Technoblade and to their family which takes on a new spin to the usual auto gg mods by i

ZtereoHYPE 4 Jul 23, 2022
An open-source reverse-engineered dedicated server for Frostbite games

FrostbiteServer An open-source reverse-engineered dedicated server for games running on the Frostbite engine. When finished, this will be used to host

Sean Kahler 26 Jan 5, 2023
Pandora - allowing to control different agents (Windows & Linux machine) from server(s) and master

Pandora Pandora is now an open-source project allowing to control different agents (Windows & Linux machine) from server(s) and master. Features Auto-

nz 75 Dec 22, 2022
High performance RPC framework based on netty

RPC(Remote Procedure Call)实战 @desc: 仅用于个人学习、了解RPC @date: 2021/01/16 技术组成: 版本一 版本二 版本三 传输层 Netty4 * * 编码层 Kryo * * 应用层 JDK动态代理 * * 服务注册与发现 手动注册+guava缓存

XDD 10 Nov 22, 2022
✈A high-performance RPC based on Java & Netty.

bRPC README 中文版本 一个基于netty的RPC框架 基于netty NIO、IO多路复用。 client与server端建立心跳包保活机制。发生未知断连时,重连保证可靠长连接。 使用kryo序列化,自定义传输包,及传输格式,避免TCP沾包问题。 支持zookeeper或nacos做服务

vincent 238 Dec 16, 2022