Slipstream 图标

Slipstream

作者:rebot | 分类:模组

价格:0 墨喵币 下载量:0 点赞:0 版本 2.0.0
本资源为搬运资源,原资源地址: https://modrinth.com/mod/slipstreamengine
资源信息

Minecraft 版本: 1.21 1.21.1 1.21.2 1.21.3 1.21.4 1.21.5 1.21.6 1.21.7 1.21.8 1.21.9 1.21.10 1.21.11

平台: paper

标签: library optimization utility

资源介绍

⚡ Slipstream Engine (v2.0.0)

Slipstream is a Next-Gen framework for packet interception and physics simulation in Minecraft (Paper).
Built as an ultra-fast, modern alternative to heavy libraries (like ProtocolLib), designed specifically for Kotlin developers with an absolute focus on maximum performance and production stability.

Starting with v2.0.0, Slipstream utilizes a Multi-Module Architecture with automatic generation of @JvmInline value class wrappers directly from NMS, providing 100% type safety, Java Records support, and Zero-Allocation access without polluting the global namespace.

? Why Slipstream?

  • ? Zero-Reflection Bytecode Bridge: Uses MethodHandles and Kotlin value classes. Packets are processed at the speed of compiled JIT bytecode.
  • ?️ Type-Safe & Clean API: Forget packet.isMovePacket(). Use our beautifully crafted packet.wrapAs<WrapperMovePacket>() which uses inline reified magic to guarantee zero runtime overhead and a clean autocomplete scope.
  • ? Zero-Allocation Nested Structures: Automatically generated wrappers for internal NMS types like BlockPos, Vec3, ItemStack ensure no objects are unnecessarily instantiated in the heap.
  • ? Coroutine-First & Lazy Suspend: Asynchronous packet processing directly in the Netty thread. Slipstream only launches coroutines when a listener is interested, otherwise, it stays 100% synchronous.
  • ? Full Packet Mutation: Mutate packets easily via generated setters for mutable fields, or via .copy() for immutable Java Records.
  • ?️ Native Mojang Mappings: Deeply integrated with Paper's native Mojang-mapped environment (1.21+).

? Documentation & Wiki

  • ?️ Architecture — Multi-module design, Code Generation, and Pipeline internals.
  • ? API Guide — Listeners, Awaiters, wrapAs, and Modifiers.
  • ⏱️ Performance — JMH Benchmarks, Inline Reified optimizations, and MethodHandles.

    ? Quick Start

Gradle (JitPack)

repositories {
    maven("https://jitpack.io")
}

dependencies {
    // You only need to depend on the core module, the generated wrappers are pulled automatically!
    implementation("com.github.ClCody.Slipstream:slipstream-core:2.0.0")
}

? Usage Examples (API)

1. Type-Safe Casts (wrapAs) & Synchronous Listeners

The core of Slipstream's DX. Check and cast a packet in one single zero-overhead line:

val manager = SlipstreamPlugin.instance.manager

manager.registerListener(object : PacketListener {
    override fun onPacketIn(player: Player, packet: Any): Boolean {
        // wrapAs<T>() returns null if it's the wrong packet. 
        // Powered by inline reified, so 0 overhead!
        packet.wrapAs<WrapperServerboundMovePlayerPacket>()?.let { movePacket ->
            val pos = movePacket.pos // Returns a WrapperBlockPos (zero-allocation)
            println("Player moved to X: ${pos.x}, Y: ${pos.y}")
        }
        return true
    }
})

2. Asynchronous Listeners (Suspend Listeners)

Don't block the server and Netty! Make database queries right during packet processing:

manager.registerSuspendListener(object : SuspendablePacketListener {
    override fun interestsInbound(packet: Any): Boolean = packet.wrapAs<WrapperServerboundChatPacket>() != null

    override suspend fun onPacketInSuspend(player: Player, packet: Any): Boolean {
        // The coroutine can suspend, the order of following packets is strictly preserved!
        val isMuted = database.checkPlayerMute(player.uniqueId)
        return !isMuted // false = cancel packet
    }
})

3. Packet Awaiter

Linear, non-blocking packet awaiting (e.g., waiting for client transactions):

// Send a transaction to the client
player.sendPacket(TransactionPacket(id = 1337))

// The coroutine suspends until the client sends a response with the target ID
val response = manager.awaitPacket<WrapperServerboundPongPacket>(player) { 
    it.packet.id == 1337 
}

4. Modifying Packets (Setters & Records)

packet.wrapAs<WrapperClientboundSetEntityDataPacket>()?.let { dataPacket ->
    // Modifying a mutable packet using generated MethodHandle setters
    dataPacket.id = 999 
}

packet.wrapAs<WrapperServerboundSwingPacket>()?.let { swingPacket ->
    // For immutable Java Records, a copy() method is generated (just like Kotlin data classes)
    val modified = swingPacket.copy(hand = InteractionHand.OFF_HAND)
}

? License

MIT License.

下载太慢?试试 墨喵加速站,支持 Modrinth 和外网直链高速下载! 用的人越多,下载的越快!
下载与版本
评论(0)
登录 后发表评论。

暂无评论,抢个沙发吧~

举报此资源

请登录后举报

🔥 相关推荐
MTR Low Effort Retextured Trains

价格:0 墨喵币
下载量:0

查看详情
Passive Skill Tree Mob Kill Points

价格:0 墨喵币
下载量:0

查看详情
Minechat

价格:0 墨喵币
下载量:0

查看详情
Kill Factor

价格:0 墨喵币
下载量:0

查看详情