diff options
Diffstat (limited to 'server')
| -rw-r--r-- | server/block_def.go | 17 | ||||
| -rw-r--r-- | server/blocks.go | 19 | ||||
| -rw-r--r-- | server/server.go | 2 |
3 files changed, 38 insertions, 0 deletions
diff --git a/server/block_def.go b/server/block_def.go index cbd4596..631a388 100644 --- a/server/block_def.go +++ b/server/block_def.go @@ -245,3 +245,20 @@ func getBlockDefPackets() iter.Seq[classic.Packet] { } } } + +func getInventoryPackets(inventoryList []blockType) iter.Seq[classic.Packet] { + return func(yield func(classic.Packet) bool) { + for i := 0; i < 256; i++ { // clear inventory first + yield(&classic.InventoryOrder { + Order: 0, + BlockId: byte(i), + }) + } + for i, block := range inventoryList { + yield(&classic.InventoryOrder { + Order: byte(i + 1), + BlockId: byte(block), + }) + } + } +} diff --git a/server/blocks.go b/server/blocks.go index c31d548..bd4bbda 100644 --- a/server/blocks.go +++ b/server/blocks.go @@ -158,3 +158,22 @@ func init() { makeSlabs(blockPlanks, blockWoodSlab, "") makeSlabs(blockStone, blockStoneSlab, "") } + +var inventoryList = []blockType { + blockStone, blockGrass, blockDirt, blockCobblestone, blockPlanks, + blockSapling, blockBedrock, blockWater, blockLava, blockSand, blockGravel, + blockGoldOre, blockIronOre, blockCoalOre, blockWood, blockLeaves, + blockSponge, blockGlass, blockGold, blockIron, blockRedWool, + blockOrangeWool, blockYellowWool, blockLimeWool, blockGreenWool, + blockTealWool, blockAquaWool, blockCyanWool, blockBlueWool, + blockIndigoWool, blockVioletWool, blockMagentaWool, blockPinkWool, + blockBlackWool, blockGrayWool, blockWhiteWool, blockLightPinkWool, + blockForestGreenWool, blockBrownWool, blockDeepBlueWool, + blockTurquoiseWool, blockDandelion, blockRose, blockBrownMushroom, + blockRedMushroom, blockBricks, blockTnt, blockBookshelf, blockMossyRocks, + blockObsidian, blockRope, blockSandstone, blockSnow, blockFire, blockIce, + blockTile, blockMagma, blockPillar, blockCrate, blockStoneBricks, + blockMossyStoneBricks, blockCrackedStoneBricks, blockPolishedStone, + blockDoubleSlab, blockSlab, blockStoneSlab, blockCobblestoneSlab, + blockWoodSlab, blockPumpkin, blockJackOLantern, +} diff --git a/server/server.go b/server/server.go index 00e7cef..1ee7994 100644 --- a/server/server.go +++ b/server/server.go @@ -25,6 +25,7 @@ var supportedExtensions = []string { "ExtPlayerList.2", "BlockDefinitions", "BlockDefinitionsExt.2", + "InventoryOrder", } var requiredExtensions = []string { "ExtEntityPositions", @@ -556,6 +557,7 @@ func (cl *client) cpeHandshake(conn net.Conn, ext map[string]bool) bool { } cl.SendPackets(nil, getBlockDefPackets()) + cl.SendPackets(nil, getInventoryPackets(inventoryList)) cl.extensions = ext return true |
