Init Commit

This commit is contained in:
yefengeeeeeeeeeee 2026-04-06 14:01:50 +08:00
parent 845ff19ba1
commit 5d0d586ce5
6 changed files with 237 additions and 222 deletions

View file

@ -673,6 +673,30 @@ class BlockAPI{
}
}
}
public static function convertHighItemIdsToOldItemIds(int $protocolId, int $itemId) : int{
if ($protocolId >= ProtocolInfo12::CURRENT_PROTOCOL_12) {
return $itemId;
}
$idMap = [ //default for protocol < 12
LIT_PUMPKIN => MELON_BLOCK, //block
PUMPKIN_SEEDS => MELON_SEEDS, //item
PUMPKIN_PIE => BREAD, //item
BEETROOT => BREAD, //item
BEETROOT_SEEDS => SEEDS, //item
];
if ($protocolId < ProtocolInfo9::CURRENT_PROTOCOL_9) {
$idMap += [
NETHERRACK => OBSIDIAN, //block
NETHER_BRICK => BRICK, //item
NETHER_QUARTZ => BRICK, //item
];
}
return $idMap[$itemId] ?? $itemId;
}
/**
* @deprecated random updates are handled differently now.

View file

@ -522,6 +522,18 @@ class PlayerAPI{
}
}
/**
* @return int
*/
public static function decodeProtocol($ip, $port){
foreach(ServerAPI::request()->clients as $p) {
ConsoleAPI::info($p->ip);
if($p->ip == $ip && $p->port == $port){
return $p->PROTOCOL;
}
}
}
public function remove($CID){
if(isset($this->server->clients[$CID])){
$player = $this->server->clients[$CID];