Skip to content

Commit

Permalink
Initial support of 1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
IdanHo committed Aug 5, 2020
1 parent 781f799 commit 75ffb47
Show file tree
Hide file tree
Showing 15 changed files with 423 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
node-version: [14.x]
mcVersionIndex: [0, 1, 2, 3, 4, 5, 6]
mcVersionIndex: [0, 1, 2, 3, 4, 5, 6, 7, 8]

steps:
- uses: actions/checkout@v2
Expand All @@ -25,5 +25,5 @@ jobs:
- run: npm install
- env:
CIRCLE_NODE_INDEX: ${{ matrix.mcVersionIndex }}
CIRCLE_NODE_TOTAL: 7
CIRCLE_NODE_TOTAL: 9
run: npm test
2 changes: 1 addition & 1 deletion examples/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ mcServer.createMCServer({
},
'everybody-op': true,
'max-entities': 100,
version: '1.15.2'
version: '1.16.1'
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"devDependencies": {
"jest": "^26.0.1",
"longjohn": "^0.2.12",
"minecraft-wrap": "^1.2.3",
"mineflayer": "^2.7.3",
"require-self": "^0.2.3",
"standard": "^14.3.4"
Expand Down
41 changes: 28 additions & 13 deletions src/lib/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"name": "unloadChunkDirect",
"description": "Chunk unloading is done by sending directly an unload chunk packet",
"versions": ["1.9", "1.10", "1.11", "1.12", "1.13", "1.14", "1.15"]
"versions": ["1.9", "1.10", "1.11", "1.12", "1.13", "1.14", "1.15", "1.16"]
},
{
"name": "fixedPointPosition",
Expand All @@ -17,7 +17,7 @@
{
"name": "doublePosition",
"description": "Entity positions are represented with double",
"versions": ["1.9", "1.10", "1.11", "1.12", "1.13", "1.14", "1.15"]
"versions": ["1.9", "1.10", "1.11", "1.12", "1.13", "1.14", "1.15", "1.16"]
},
{
"name": "fixedPointDelta",
Expand All @@ -27,7 +27,7 @@
{
"name": "fixedPointDelta128",
"description": "Delta of position are represented with fixed point numbers times 128",
"versions": ["1.9", "1.10", "1.11", "1.12", "1.13", "1.14", "1.15"]
"versions": ["1.9", "1.10", "1.11", "1.12", "1.13", "1.14", "1.15", "1.16"]
},
{
"name": "entityCamelCase",
Expand All @@ -37,7 +37,7 @@
{
"name": "entitySnakeCase",
"description": "entity name are in snake case",
"versions": ["1.11", "1.12", "1.13", "1.14", "1.15"]
"versions": ["1.11", "1.12", "1.13", "1.14", "1.15", "1.16"]
},
{
"name": "respawnIsPayload",
Expand All @@ -47,7 +47,7 @@
{
"name": "respawnIsActionId",
"description": "respawn field is action id",
"versions": ["1.9", "1.10", "1.11", "1.12", "1.13", "1.14", "1.15"]
"versions": ["1.9", "1.10", "1.11", "1.12", "1.13", "1.14", "1.15", "1.16"]
},
{
"name": "attachStackEntity",
Expand All @@ -57,12 +57,12 @@
{
"name": "setPassengerStackEntity",
"description": "set passengers is used to stack entities",
"versions": ["1.9", "1.10", "1.11", "1.12", "1.13", "1.14", "1.15"]
"versions": ["1.9", "1.10", "1.11", "1.12", "1.13", "1.14", "1.15", "1.16"]
},
{
"name": "theFlattening",
"description": "many items got merged, separated or renamed",
"versions": ["1.13", "1.14", "1.15"]
"versions": ["1.13", "1.14", "1.15", "1.16"]
},
{
"name": "blockPlaceHasIntCursor",
Expand All @@ -72,31 +72,46 @@
{
"name": "updateViewPosition",
"description": "the client's chunk position must be updated to render chunks correctly",
"versions": ["1.14", "1.15"]
"versions": ["1.14", "1.15", "1.16"]
},
{
"name": "lightSentSeparately",
"description": "chunk light data is sent in a separate packet",
"versions": ["1.14", "1.15"]
"versions": ["1.14", "1.15", "1.16"]
},
{
"name": "difficultySentSeparately",
"description": "game difficulty is sent separately from the login packet",
"versions": ["1.14", "1.15"]
"versions": ["1.14", "1.15", "1.16"]
},
{
"name": "acknowledgePlayerDigging",
"description": "player digging packets should be responded to",
"versions": ["1.14", "1.15"]
"versions": ["1.14", "1.15", "1.16"]
},
{
"name": "multiTypeSigns",
"description": "there are 6 types of signs based on the different trees",
"versions": ["1.14", "1.15"]
"versions": ["1.14", "1.15", "1.16"]
},
{
"name": "entityMetadataSentSeparately",
"description": "entity metadata is sent separately from the spawn packets",
"versions": ["1.15"]
"versions": ["1.15", "1.16"]
},
{
"name": "attributeSnakeCase",
"description": "entity attributes are in snake case",
"versions": ["1.16"]
},
{
"name": "allEntityEquipmentInOne",
"description": "entity equipment packet contains all equipment slots instead of just one",
"versions": ["1.16"]
},
{
"name": "dimensionIsAString",
"description": "dimension identifier is a string instead of an id",
"versions": ["1.16"]
}
]
14 changes: 7 additions & 7 deletions src/lib/playerDat.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function read (uuid, spawnPoint, worldFolder) {
}
}

async function save (player, worldFolder) {
async function save (player, worldFolder, snakeCase) {
function playerInventoryToNBT (playerInventory) {
const nbtInventory = []
playerInventory.slots.forEach(item => {
Expand Down Expand Up @@ -130,7 +130,7 @@ async function save (player, worldFolder) {
},
Name: {
type: 'string',
value: 'generic.maxHealth'
value: snakeCase ? 'generic.maxHealth' : 'generic.max_health'
}
},
{
Expand All @@ -140,7 +140,7 @@ async function save (player, worldFolder) {
},
Name: {
type: 'string',
value: 'generic.knockbackResistance'
value: snakeCase ? 'generic.knockbackResistance' : 'generic.knockback_resistance'
}
},
{
Expand All @@ -150,7 +150,7 @@ async function save (player, worldFolder) {
},
Name: {
type: 'string',
value: 'generic.movementSpeed'
value: snakeCase ? 'generic.movementSpeed' : 'generic.movement_speed'
}
},
{
Expand All @@ -170,7 +170,7 @@ async function save (player, worldFolder) {
},
Name: {
type: 'string',
value: 'generic.armorToughness'
value: snakeCase ? 'generic.armorToughness' : 'generic.armor_toughness'
}
},
{
Expand All @@ -180,7 +180,7 @@ async function save (player, worldFolder) {
},
Name: {
type: 'string',
value: 'generic.attackDamage'
value: snakeCase ? 'generic.attackDamage' : 'generic.attack_damage'
}
},
{
Expand All @@ -190,7 +190,7 @@ async function save (player, worldFolder) {
},
Name: {
type: 'string',
value: 'generic.attackSpeed'
value: snakeCase ? 'generic.attackSpeed' : 'generic.attack_speed'
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/lib/plugins/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ module.exports.player = function (player, serv) {

player.chat = message => {
if (typeof message === 'string') message = serv.parseClassic(message)
player._client.write('chat', { message: JSON.stringify(message), position: 0 })
player._client.write('chat', { message: JSON.stringify(message), position: 0, sender: '0' })
}

player.emptyChat = (count = 1) => {
Expand All @@ -156,6 +156,6 @@ module.exports.player = function (player, serv) {

player.system = message => {
if (typeof message === 'string') message = serv.parseClassic(message)
player._client.write('chat', { message: JSON.stringify(message), position: 2 })
player._client.write('chat', { message: JSON.stringify(message), position: 2, sender: '0' })
}
}
40 changes: 30 additions & 10 deletions src/lib/plugins/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ module.exports.player = function (player, serv, { version }) {
player.heldItemSlot = slotId
player.setEquipment(0, player.inventory.slots[36 + player.heldItemSlot])

player._writeOthersNearby('entity_equipment', {
entityId: player.id,
slot: 0,
item: Item.toNotch(player.heldItem)
})
if (serv.supportFeature('allEntityEquipmentInOne')) {
player._writeOthersNearby('entity_equipment', {
entityId: player.id,
equipments: [{
slot: 0,
item: Item.toNotch(player.heldItem)
}]
})
} else {
player._writeOthersNearby('entity_equipment', {
entityId: player.id,
slot: 0,
item: Item.toNotch(player.heldItem)
})
}
})

player._client.on('window_click', function (clickInfo) {
Expand Down Expand Up @@ -163,11 +173,21 @@ module.exports.player = function (player, serv, { version }) {
equipments[player.heldItemSlot] = 0
if (equipments[slot] !== undefined) {
player.setEquipment(equipments[slot], newItem)
player._writeOthersNearby('entity_equipment', {
entityId: player.id,
slot: equipments[slot],
item: Item.toNotch(newItem)
})
if (serv.supportFeature('allEntityEquipmentInOne')) {
player._writeOthersNearby('entity_equipment', {
entityId: player.id,
equipments: [{
slot: equipments[slot],
item: Item.toNotch(newItem)
}]
})
} else {
player._writeOthersNearby('entity_equipment', {
entityId: player.id,
slot: equipments[slot],
item: Item.toNotch(newItem)
})
}
}

player._client.write('set_slot', {
Expand Down
Loading

0 comments on commit 75ffb47

Please sign in to comment.