?: add debug lines to the chunk setblock to see more clearly about what is causing error
This commit is contained in:
@@ -1 +1 @@
|
||||
1779
|
||||
1780
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.*;
|
||||
import java.util.*;
|
||||
|
||||
public class WorldPlugin extends Bot.Listener {
|
||||
private final Bot bot;
|
||||
|
||||
public int minY = 0;
|
||||
public int maxY = 256;
|
||||
|
||||
@@ -30,6 +32,8 @@ public class WorldPlugin extends Bot.Listener {
|
||||
private final List<Listener> listeners = new ArrayList<>();
|
||||
|
||||
public WorldPlugin (Bot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
bot.addListener(this);
|
||||
}
|
||||
|
||||
@@ -90,7 +94,7 @@ public class WorldPlugin extends Bot.Listener {
|
||||
|
||||
private void packetReceived (ClientboundLevelChunkWithLightPacket packet) {
|
||||
final ChunkPos pos = new ChunkPos(packet.getX(), packet.getZ());
|
||||
final ChunkColumn column = new ChunkColumn(pos, packet.getChunkData(), maxY, minY);
|
||||
final ChunkColumn column = new ChunkColumn(bot, pos, packet.getChunkData(), maxY, minY);
|
||||
chunks.put(pos, column);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user