Skip to content

Commit

Permalink
update: 尝试完全使用ProtocolLib发送数据
Browse files Browse the repository at this point in the history
  • Loading branch information
BingZi-233 committed Dec 23, 2024
1 parent 023fd05 commit 55f067b
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 260 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=online.bingzi.bilibili.video
version=2.0.3
version=2.0.4-beta1
kotlin.incremental=true
kotlin.incremental.java=true
kotlin.incremental.useClasspathSnapshot=true
Expand Down
2 changes: 1 addition & 1 deletion project/nms/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dependencies {
// 引入 服务端 核心
compileOnly("ink.ptms.core:v12101:12101:mapped")
compileOnly("ink.ptms.core:v12101:12101:universal")
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
compileOnly("com.comphenix.protocol:ProtocolLib:5.3.0")
}

// 子模块
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class ImageMapRenderer(val image: BufferedImage) : MapRenderer() {
// 标记是否已经渲染过
private var renderer = false

// 初始化缓冲区,假设地图大小为128x128
private var buffer: ByteArray = ByteArray(128 * 128)

/**
* Render
* <p>
Expand All @@ -40,7 +43,23 @@ class ImageMapRenderer(val image: BufferedImage) : MapRenderer() {
}
// 在地图画布上绘制图像
mapCanvas.drawImage(0, 0, image)
// 将图像数据转换为缓冲区
for (x in 0 until 128) {
for (y in 0 until 128) {
buffer[x + y * 128] = mapCanvas.getPixel(x, y)
}
}
// 设置为已渲染状态
renderer = true
}

/**
* 获取玩家的地图缓冲区数据
*
* @param player 玩家对象
* @return 地图数据缓冲区
*/
fun getBufferForPlayer(player: Player): ByteArray {
return buffer // 返回缓冲区数据
}
}
Loading

0 comments on commit 55f067b

Please sign in to comment.