Player can now handled and showed the item on hand

This commit is contained in:
yefengeeeeeeeeeee 2026-07-10 13:57:23 +08:00
parent 8aacc27795
commit 1c117883ab
5 changed files with 843 additions and 22 deletions

View file

@ -481,7 +481,7 @@ class BlockAPI{
private function cancelAction(Block $block, Player $player, $send = true){
$player->addBlockUpdateIntoQueue($block->x, $block->y, $block->z, $block->getID(), $block->getMetadata());
if($send === true){
if($send === true && $player->PROTOCOL >= ProtocolInfo12::CURRENT_PROTOCOL_12){
$player->sendInventory();
}
return false;
@ -674,7 +674,7 @@ class BlockAPI{
}
}
public static function convertHighItemIdsToOldItemIds(int $protocolId, int $itemId) : int{
public static function convertHighItemIdsToOldItemIds(int $protocolId, int $itemId, int $metaData = 0) : int{
if ($protocolId >= ProtocolInfo12::CURRENT_PROTOCOL_12) {
return $itemId;
}
@ -689,9 +689,14 @@ class BlockAPI{
BEETROOT_SEEDS => SEEDS,
];
if ($protocolId <= ProtocolInfo9::CURRENT_PROTOCOL_9) {
$idMap += [
SPAWN_EGG => AIR,
];
}
if ($protocolId < ProtocolInfo9::CURRENT_PROTOCOL_9) {
$idMap += [
SPAWN_EGG => AIR,
NETHERRACK => OBSIDIAN,
NETHER_BRICK => BRICK,
NETHER_QUARTZ => BRICK,

View file

@ -42,6 +42,13 @@ class PlayerAPI{
public function handle($data, $event){
switch($event){
case "player.death":
if($data["player"]->PROTOCOL <= ProtocolInfo9::CURRENT_PROTOCOL_9){
$data["player"]->isWorkBench = false;
$data["player"]->isStoneCutter = false;
if($data["player"]->PROTOCOL < ProtocolInfo6::CURRENT_PROTOCOL_6){
$data["player"]->isOre = [];
}
}
if(is_numeric($data["cause"])){
$e = $this->server->api->entity->get($data["cause"]);
if($e instanceof Entity){