Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.18 support #2339

Merged
merged 25 commits into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
include:
- javaVersion: 16
mcVersion: '1.17.1'
- javaVersion: 17
mcVersion: '1.18'
fail-fast: false

steps:
Expand Down
59 changes: 32 additions & 27 deletions lib/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"name": "spawner",
"description": "spawner is called spawner",
"versions": ["1.13", "1.17.1"]
"versions": ["1.13", "1.18"]
},
{
"name": "blockMetadata",
Expand All @@ -17,12 +17,12 @@
{
"name": "blockStateId",
"description": "block metadata is encoded as state id",
"versions": ["1.13", "1.17.1"]
"versions": ["1.13", "1.18"]
},
{
"name": "creativeSleepNearMobs",
"description": "can sleep near mobs in creative",
"versions": ["1.13", "1.17.1"]
"versions": ["1.13", "1.18"]
},
{
"name": "fixedPointPosition",
Expand All @@ -32,7 +32,7 @@
{
"name": "doublePosition",
"description": "Entity positions are represented with double",
"versions": ["1.9", "1.17.1"]
"versions": ["1.9", "1.18"]
},
{
"name": "fixedPointDelta",
Expand All @@ -42,7 +42,7 @@
{
"name": "fixedPointDelta128",
"description": "Delta of position are represented with fixed point numbers times 128",
"versions": ["1.9", "1.17.1"]
"versions": ["1.9", "1.18"]
},
{
"name": "customChannelMCPrefixed",
Expand All @@ -52,12 +52,12 @@
{
"name": "customChannelIdentifier",
"description": "custom channel is an identifier starting in minecraft namespace",
"versions": ["1.13", "1.17.1"]
"versions": ["1.13", "1.18"]
},
{
"name": "dimensionDataIsAvailable",
"description": "dimensionData is available, providing an additional information about the current dimension",
"versions": ["1.17", "1.17.1"]
"versions": ["1.17", "1.18"]
},
{
"name": "useItemWithBlockPlace",
Expand All @@ -67,7 +67,7 @@
{
"name": "useItemWithOwnPacket",
"description": "use item is done with its own packet",
"versions": ["1.9", "1.17.1"]
"versions": ["1.9", "1.18"]
},
{
"name": "blockPlaceHasHeldItem",
Expand All @@ -87,7 +87,7 @@
{
"name": "blockPlaceHasInsideBlock",
"description": "block_place packet has inside block",
"versions": ["1.14", "1.17.1"]
"versions": ["1.14", "1.18"]
},
{
"name": "teleportUsesPositionPacket",
Expand All @@ -102,7 +102,7 @@
{
"name": "teleportUsesOwnPacket",
"description": "teleport is done using its own packet",
"versions": ["1.9", "1.17.1"]
"versions": ["1.9", "1.18"]
},
{
"name": "oneBlockForSeveralVariations",
Expand All @@ -112,7 +112,7 @@
{
"name": "blockSchemeIsFlat",
"description": "all variations of a packet have their own id",
"versions": ["1.13", "1.17.1"]
"versions": ["1.13", "1.18"]
},
{
"name": "tabCompleteHasNoToolTip",
Expand All @@ -122,7 +122,7 @@
{
"name": "tabCompleteHasAToolTip",
"description": "tab complete has a tool tip",
"versions": ["1.13", "1.17.1"]
"versions": ["1.13", "1.18"]
},
{
"name": "effectAreMinecraftPrefixed",
Expand All @@ -132,7 +132,7 @@
{
"name": "effectAreNotPrefixed",
"description": "effect are not prefixed",
"versions": ["1.13", "1.17.1"]
"versions": ["1.13", "1.18"]
},
{
"name": "itemsAreAlsoBlocks",
Expand All @@ -142,12 +142,12 @@
{
"name": "itemsAreNotBlocks",
"description": "items are not block",
"versions": ["1.13", "1.17.1"]
"versions": ["1.13", "1.18"]
},
{
"name": "fishingBobberCorrectlyNamed",
"description": "the fishing hook entity is named fishing_bobber",
"versions": ["1.14", "1.17.1"]
"versions": ["1.14", "1.18"]
},
{
"name": "editBookIsPluginChannel",
Expand All @@ -157,7 +157,7 @@
{
"name": "hasEditBookPacket",
"description": "book editing is handled through a packet",
"versions": ["1.13", "1.17.1"]
"versions": ["1.13", "1.18"]
},
{
"name": "clientUpdateBookIdWhenSign",
Expand Down Expand Up @@ -197,12 +197,12 @@
{
"name": "dimensionIsAWorld",
"description": "description is a world name (string)",
"versions": ["1.16.2", "1.17.1"]
"versions": ["1.16.2", "1.18"]
},
{
"name": "dimensionDataIsAvailable",
"description": "dimensionData is available, describing additional dimension information",
"versions": ["1.17", "1.17.1"]
"versions": ["1.17", "1.18"]
},
{
"name": "doesntHaveChestType",
Expand All @@ -227,22 +227,22 @@
{
"name": "hasAttackCooldown",
"description": "if there is a cooldown after attacks to deal full damage",
"versions": ["1.9", "1.17.1"]
"versions": ["1.9", "1.18"]
},
{
"name": "usesLoginPacket",
"description": "uses the login packet as defined in mcData",
"versions": ["1.16", "1.17.1"]
"versions": ["1.16", "1.18"]
},
{
"name": "usesMultiblockSingleLong",
"description": "in the multi_block_change packet is stored as a single number",
"versions": ["1.16.2", "1.17.1"]
"versions": ["1.16.2", "1.18"]
},
{
"name": "usesMultiblock3DChunkCoords",
"description": "in the multi_block_change packet, all 3 axis coords are defined",
"versions": ["1.16.2", "1.17.1"]
"versions": ["1.16.2", "1.18"]
},
{
"name": "setBlockUsesMetadataNumber",
Expand All @@ -257,7 +257,7 @@
{
"name": "selectingTradeMovesItems",
"description": "selecting a trade automatically puts the required items into trading slots",
"versions": ["1.14", "1.17.1"]
"versions": ["1.14", "1.18"]
},
{
"name": "resourcePackUsesHash",
Expand All @@ -272,7 +272,7 @@
{
"name": "teamUsesChatComponents",
"description": "teams use chatcomponents for formatting",
"versions": ["1.13", "1.17.1"]
"versions": ["1.13", "1.18"]
},
{
"name": "teamUsesScoreboard",
Expand All @@ -287,7 +287,7 @@
{
"name": "enderCrystalNameNoCapsWithUnderscore",
"description": "this is when the end_crystal's entity name is end_crystal",
"versions": ["1.14", "1.17.1"]
"versions": ["1.14", "1.18"]
},
{
"name": "entityNameUpperCaseNoUnderscore",
Expand All @@ -307,7 +307,7 @@
{
"name": "stateIdUsed",
"description": "starting in 1.17.1, actionId has been replaced with stateId",
"versions": ["1.17.1", "1.17.1"]
"versions": ["1.17.1", "1.18"]
},
{
"name": "actionIdUsed",
Expand All @@ -317,11 +317,16 @@
{
"name": "setSlotAsTransaction",
"description": "use setslot as transaction instead of just hoping it'll work",
"versions": ["1.17", "1.17.1"]
"versions": ["1.17", "1.18"]
},
{
"name": "armAnimationBeforeUse",
"description": "arm animation packet sent before use entity packet",
"versions": ["1.8", "1.8.9"]
},
{
"name": "tallWorld",
"description": "world starts at -64 and ends at 384",
"versions": ["1.18", "1.18"]
}
]
2 changes: 1 addition & 1 deletion lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function createBot (options = {}) {
options.username = options.username ?? 'Player'
options.version = options.version ?? false
options.plugins = options.plugins ?? {}
options.hideErrors = options.hideErrors ?? true
options.hideErrors = options.hideErrors ?? false
options.logErrors = options.logErrors ?? true
options.loadInternalPlugins = options.loadInternalPlugins ?? true
options.client = options.client ?? null
Expand Down
27 changes: 21 additions & 6 deletions lib/plugins/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ function inject (bot, { version, storageBuilder }) {
delete paintingsByPos[painting.position]
}

function addBlockEntity (nbtData) {
const blockEntity = nbt.simplify(nbtData)
const pos = new Vec3(blockEntity.x, blockEntity.y, blockEntity.z).floored()
function addBlockEntity (nbtData, x, y, z, type) {
const blockEntity = nbtData === undefined ? {} : nbt.simplify(nbtData)
const pos = (x !== undefined ? new Vec3(x, y, z) : new Vec3(blockEntity.x, blockEntity.y, blockEntity.z)).floored()
// Set raw nbt of blockEntity
blockEntity.raw = nbtData
blockEntity.type = type
// Handle signs
if (blockEntity.id === 'minecraft:sign' || blockEntity.id === 'Sign') {
const prepareJson = (i) => {
Expand Down Expand Up @@ -102,6 +103,9 @@ function inject (bot, { version, storageBuilder }) {
if (args.biomes !== undefined) {
column.loadBiomes(args.biomes)
}
if (args.skyLight !== undefined) {
column.loadParsedLight(args.skyLight, args.blockLight, args.skyLightMask, args.blockLightMask, args.emptySkyLightMask, args.emptyBlockLightMask)
}
bot.world.setColumn(args.x, args.z, column)
} catch (e) {
bot.emit('error', e)
Expand Down Expand Up @@ -323,12 +327,23 @@ function inject (bot, { version, storageBuilder }) {
biomes: packet.biomes,
skyLightSent: bot.game.dimension === 'minecraft:overworld',
groundUp: packet.groundUp,
data: packet.chunkData
data: packet.chunkData,
trustEdges: packet.trustEdges,
skyLightMask: packet.skyLightMask,
blockLightMask: packet.blockLightMask,
emptySkyLightMask: packet.emptySkyLightMask,
emptyBlockLightMask: packet.emptyBlockLightMask,
skyLight: packet.skyLight,
blockLight: packet.blockLight
})

if (typeof packet.blockEntities !== 'undefined') {
for (const nbtData of packet.blockEntities) {
addBlockEntity(nbtData)
for (const blockEntity of packet.blockEntities) {
if (blockEntity.x !== undefined) {
addBlockEntity(blockEntity.nbtData, blockEntity.x, blockEntity.y, blockEntity.z, blockEntity.type)
} else {
addBlockEntity(blockEntity)
}
}
}
})
Expand Down
4 changes: 2 additions & 2 deletions lib/version.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
supportedVersions: ['1.8', '1.9', '1.10', '1.11', '1.12', '1.13', '1.14', '1.15', '1.16', '1.17'],
testedVersions: ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1']
supportedVersions: ['1.8', '1.9', '1.10', '1.11', '1.12', '1.13', '1.14', '1.15', '1.16', '1.17', '1.18'],
testedVersions: ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18']
} // when updating testedVersions, make sure to update CI.yml
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
},
"license": "MIT",
"dependencies": {
"minecraft-data": "^2.95.0",
"minecraft-data": "^2.106.0",
"minecraft-protocol": "^1.26.5",
"prismarine-biome": "^1.1.1",
"prismarine-block": "^1.10.3",
"prismarine-chat": "^1.3.3",
"prismarine-chunk": "^1.26.0",
"prismarine-chunk": "^1.28.1",
"prismarine-entity": "^2.0.0",
"prismarine-item": "^1.11.0",
"prismarine-nbt": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions test/externalTests/exampleInventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = () => async (bot) => {
assert.strictEqual(name, 'inventory')
bot.chat('/op inventory') // to counteract spawn protection
bot.chat('/clear inventory')
bot.chat('/setblock 52 4 0 crafting_table') // to make stone bricks stairs
bot.chat(`/setblock 52 ${bot.test.groundY} 0 crafting_table`) // to make stone bricks stairs
bot.chat('/give inventory dirt 64')
bot.chat('/give inventory stick 7')
bot.chat('/give inventory iron_ore 64')
Expand All @@ -67,7 +67,7 @@ module.exports = () => async (bot) => {
await bot.test.wait(100)
}
// cleanup
bot.chat('/setblock 52 4 0 air')
bot.chat(`/setblock 52 ${bot.test.groundY} 0 air`)
cb()

function makeTest (inStr, outStr) {
Expand Down
8 changes: 4 additions & 4 deletions test/externalTests/plugins/testCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function inject (bot) {
const Item = require('prismarine-item')(bot.version)

bot.test = {}
bot.test.groundY = bot.supportFeature('tallWorld') ? -60 : 4
bot.test.sayEverywhere = sayEverywhere
bot.test.clearInventory = callbackify(clearInventory)
bot.test.becomeSurvival = callbackify(becomeSurvival)
Expand Down Expand Up @@ -66,8 +67,7 @@ function inject (bot) {
]

async function resetBlocksToSuperflat () {
const groundY = 4
for (let y = groundY + 4; y >= groundY - 1; y--) {
for (let y = bot.test.groundY + 4; y >= bot.test.groundY - 1; y--) {
bot.chat(`/fill ~-5 ${y} ~-5 ~5 ${y} ~5 ` + layerNames[y])
}
await bot.test.wait(100)
Expand All @@ -85,7 +85,7 @@ function inject (bot) {
await becomeCreative()
await clearInventory()
bot.creative.startFlying()
await teleport(new Vec3(0, 4, 0))
await teleport(new Vec3(0, bot.test.groundY, 0))
await bot.waitForChunksToLoad()
await resetBlocksToSuperflat()
await sleep(1000)
Expand Down Expand Up @@ -197,7 +197,7 @@ function inject (bot) {
checkCondition: message => message.json.translate === 'multiplayer.player.joined'
})
childBotName = message.json.with[0].insertion
bot.chat(`/tp ${childBotName} 50 4 0`)
bot.chat(`/tp ${childBotName} 50 ${bot.test.groundY} 0`)
setTimeout(() => {
bot.chat('loaded')
}, 5000)
Expand Down
12 changes: 7 additions & 5 deletions test/externalTests/useChests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ module.exports = () => async (bot) => {
const mcData = require('minecraft-data')(bot.version)
const Item = require('prismarine-item')(bot.version)

const smallChestLocation = new Vec3(0, 4, -1)
const largeChestLocations = [new Vec3(0, 4, 1), new Vec3(1, 4, 1)]
const smallTrappedChestLocation = new Vec3(1, 4, 0)
bot.test.groundY = bot.supportFeature('tallWorld') ? -60 : 4

const smallChestLocation = new Vec3(0, bot.test.groundY, -1)
const largeChestLocations = [new Vec3(0, bot.test.groundY, 1), new Vec3(1, bot.test.groundY, 1)]
const smallTrappedChestLocation = new Vec3(1, bot.test.groundY, 0)
const largeTrappedChestLocations = [
new Vec3(-1, 4, 1),
new Vec3(-1, 4, 0)
new Vec3(-1, bot.test.groundY, 1),
new Vec3(-1, bot.test.groundY, 0)
]
const chestSlot = 36
const trappedChestSlot = 37
Expand Down
Loading