?: add debug lines to the chunk setblock to see more clearly about what is causing error

This commit is contained in:
ChomeNS
2025-03-13 14:58:41 +07:00
parent f6a3cad40a
commit 9ad02a35c9
3 changed files with 33 additions and 8 deletions

View File

@@ -2,18 +2,23 @@ package me.chayapak1.chomens_bot.chunk;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.chunk.ChunkPos;
import net.kyori.adventure.text.Component;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftTypes;
import org.geysermc.mcprotocollib.protocol.data.game.chunk.ChunkSection;
// Author: hhhzzzsss
public class ChunkColumn {
private final Bot bot;
public final ChunkPos pos;
public final ChunkSection[] chunks;
private final int minY;
public ChunkColumn (ChunkPos chunkPos, byte[] data, int worldHeight, int minY) {
public ChunkColumn (Bot bot, ChunkPos chunkPos, byte[] data, int worldHeight, int minY) {
this.bot = bot;
this.pos = chunkPos;
this.minY = minY;
@@ -45,11 +50,27 @@ public class ChunkColumn {
if (yIndex >= chunks.length) return;
if (chunks[yIndex] == null) {
chunks[yIndex] = new ChunkSection();
chunks[yIndex].setBlock(0, 0, 0, 0);
}
try {
if (chunks[yIndex] == null) {
chunks[yIndex] = new ChunkSection();
chunks[yIndex].setBlock(0, 0, 0, 0);
}
chunks[yIndex].setBlock(x, y & 15, z, id);
chunks[yIndex].setBlock(x, y & 15, z, id);
} catch (Exception e) {
// passing bot just for debugging? really?
bot.logger.error(
Component.translatable(
"Failed to set block at %s %s %s with state %s!",
Component.text(x),
Component.text(y),
Component.text(z),
Component.text(id)
)
);
bot.logger.error(e);
}
}
}