Skip to content

Commit

Permalink
Fix attempting to access unloaded chunks (#3107)
Browse files Browse the repository at this point in the history
Co-authored-by: Frej Alexander Nielsen <frej@valoks.com>
  • Loading branch information
frej4189 and Frej Alexander Nielsen authored Jul 14, 2023
1 parent 02d67b2 commit 018beaf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/plugins/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,13 @@ function inject (bot, { version, storageBuilder, hideErrors }) {
bot._client.on('tile_entity_data', (packet) => {
if (packet.location !== undefined) {
const column = bot.world.getColumn(packet.location.x >> 4, packet.location.z >> 4)
if (!column) return
const pos = new Vec3(packet.location.x & 0xf, packet.location.y, packet.location.z & 0xf)
column.setBlockEntity(pos, packet.nbtData)
} else {
const tag = packet.nbtData
const column = bot.world.getColumn(tag.value.x.value >> 4, tag.value.z.value >> 4)
if (!column) return
const pos = new Vec3(tag.value.x.value & 0xf, tag.value.y.value, tag.value.z.value & 0xf)
column.setBlockEntity(pos, tag)
}
Expand Down

0 comments on commit 018beaf

Please sign in to comment.