Merge branch 'master'

# Conflicts:
#	src/API/AchievementAPI.php
#	src/API/BanAPI.php
#	src/API/BlockAPI.php
#	src/API/EntityAPI.php
#	src/API/PlayerAPI.php
#	src/Player.php
#	src/PocketMinecraftServer.php
#	src/config.php
#	src/entity/Animal.php
#	src/entity/Breedable.php
#	src/entity/Creature.php
#	src/entity/Entity.php
#	src/entity/animal/Sheep.php
#	src/entity/monster/Creeper.php
#	src/entity/monster/Zombie.php
#	src/entity/object/Arrow.php
#	src/entity/object/FallingSand.php
#	src/entity/object/ItemEntity.php
#	src/entity/object/Minecart.php
#	src/entity/object/Painting.php
#	src/entity/object/PrimedTNT.php
#	src/material/Block.php
#	src/material/Item.php
#	src/material/Material.php
#	src/material/StaticBlock.php
#	src/material/block/DoorBlock.php
#	src/material/block/GenericBlock.php
#	src/material/block/attachable/WallSignBlock.php
#	src/material/block/liquid/LiquidBlockDynamic.php
#	src/material/block/misc/AirBlock.php
#	src/material/block/misc/BedBlock.php
#	src/material/block/misc/TNTBlock.php
#	src/material/block/nonfull/CarpetBlock.php
#	src/material/block/nonfull/FenceBlock.php
#	src/material/block/nonfull/PoweredRailBlock.php
#	src/material/block/nonfull/RailBlock.php
#	src/material/block/nonfull/SnowLayerBlock.php
#	src/material/block/nonfull/WoodSlabBlock.php
#	src/material/block/plant/BrownMushroomBlock.php
#	src/material/block/plant/DandelionBlock.php
#	src/material/block/plant/MelonStemBlock.php
#	src/material/block/plant/PumpkinStemBlock.php
#	src/material/block/plant/RedMushroomBlock.php
#	src/material/block/plant/SugarcaneBlock.php
#	src/material/block/solid/GrassBlock.php
#	src/material/block/solid/IceBlock.php
#	src/material/block/solid/LeavesBlock.php
#	src/material/block/solid/ObsidianBlock.php
#	src/material/block/solid/PumpkinBlock.php
#	src/material/block/solid/WoolBlock.php
#	src/material/item/base/ItemHoe.php
#	src/material/item/base/ItemTool.php
#	src/material/item/generic/DyeItem.php
#	src/material/item/generic/SpawnEggItem.php
#	src/material/item/tool/FlintSteelItem.php
#	src/material/item/tool/ShearsItem.php
#	src/math/AxisAlignedBB.php
#	src/network/MinecraftInterface.php
#	src/network/UDPSocket.php
#	src/network/protocol/packet/AddItemEntityPacket.php
#	src/network/protocol/packet/ContainerSetContentPacket.php
#	src/network/raknet/RakNetDataPacket.php
#	src/network/raknet/RakNetParser.php
#	src/pmf/PMFLevel.php
#	src/utils/Utils.php
#	src/world/Explosion.php
#	src/world/Level.php
#	src/world/MobSpawner.php
This commit is contained in:
yefengeeeeeeeeeee 2026-04-04 14:52:08 +08:00
commit 3fbab46e60
245 changed files with 6118 additions and 3408 deletions

View file

@ -36,5 +36,14 @@ class AddEntityPacket extends RakNetDataPacket{
$this->putShort((int) ($this->speedZ * 8000));
}
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -6,21 +6,21 @@ class AddItemEntityPacket extends RakNetDataPacket{
public $x;
public $y;
public $z;
public $yaw;
public $pitch;
public $roll;
public $speedX;
public $speedY;
public $speedZ;
public function pid(){
if($this->PROTOCOL < ProtocolInfo6::CURRENT_PROTOCOL_6){
return ProtocolInfo4::ADD_ITEM_ENTITY_PACKET;
}
return ProtocolInfo::ADD_ITEM_ENTITY_PACKET;
}
public function decode(){
}
public function encode(){
$this->reset();
$this->putInt($this->eid);
@ -28,9 +28,16 @@ class AddItemEntityPacket extends RakNetDataPacket{
$this->putFloat($this->x);
$this->putFloat($this->y);
$this->putFloat($this->z);
$this->putByte($this->yaw);
$this->putByte($this->pitch);
$this->putByte($this->roll);
$this->putByte((int)($this->speedX * 128));
$this->putByte((int)($this->speedY * 128));
$this->putByte((int)($this->speedZ * 128));
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -29,5 +29,13 @@ class AddMobPacket extends RakNetDataPacket{
$this->putByte($this->pitch);
$this->put(Utils::writeMetadata($this->metadata));
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -28,5 +28,13 @@ class AddPaintingPacket extends RakNetDataPacket{
$this->putInt($this->direction);
$this->putString($this->title);
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -46,5 +46,13 @@ class AddPlayerPacket extends RakNetDataPacket{
$this->putShort($this->itemAuxValue); //Example: bow shooting power
$this->put(Utils::writeMetadata($this->metadata));
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -35,4 +35,21 @@ class AnimatePacket extends RakNetDataPacket{
$this->putInt($this->eid);
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -2,9 +2,9 @@
class ContainerSetContentPacket extends RakNetDataPacket{
public $windowid;
public $slots = [];
public $hotbar = [];
public $slots = array();
public $hotbar = array();
public function pid(){
if($this->PROTOCOL < ProtocolInfo4::CURRENT_PROTOCOL_4){
return ProtocolInfo3::CONTAINER_SET_CONTENT_PACKET;
@ -21,7 +21,7 @@ class ContainerSetContentPacket extends RakNetDataPacket{
}
return ProtocolInfo::CONTAINER_SET_CONTENT_PACKET;
}
public function decode(){
$this->windowid = $this->getByte();
$count = $this->getShort();
@ -31,14 +31,12 @@ class ContainerSetContentPacket extends RakNetDataPacket{
if($this->PROTOCOL <= ProtocolInfo9::CURRENT_PROTOCOL_9){
return;
}
if($this->windowid === 0){
$count = $this->getShort();
for($s = 0; $s < $count and !$this->feof(); ++$s){
$this->hotbar[$s] = $this->getInt();
}
}
$count = $this->getShort();
for($s = 0; $s < $count and !$this->feof(); ++$s){
$this->hotbar[$s] = $this->getInt();
}
}
public function encode(){
$this->reset();
$this->putByte($this->windowid);
@ -54,7 +52,9 @@ class ContainerSetContentPacket extends RakNetDataPacket{
foreach($this->hotbar as $slot){
$this->putInt($slot);
}
}else{
$this->putShort(0);
}
}
}
}

View file

@ -2,7 +2,7 @@
class DropItemPacket extends RakNetDataPacket{
public $eid;
public $unknown;
public $randomly;
public $item;
public function pid(){
@ -25,7 +25,7 @@ class DropItemPacket extends RakNetDataPacket{
public function decode(){
//if($this->PROTOCOL < ProtocolInfo8::CURRENT_PROTOCOL_8)$this->reset();
$this->eid = $this->getInt();
$this->unknown = $this->getByte();
$this->randomly = $this->getByte();
$this->item = $this->getSlot();
}
@ -35,5 +35,13 @@ class DropItemPacket extends RakNetDataPacket{
$this->putByte($this->unknown);
$this->putSlot($this->item);*/
}
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -6,6 +6,10 @@ class EntityEventPacket extends RakNetDataPacket{
const ENTITY_DAMAGE = 2;
const ENTITY_DEAD = 3;
/**
* Works only for player entities
*/
const ENTITY_COMPLETE_USING_ITEM = 9;
const ENTITY_ANIM_10 = 10;
public function __construct($eid = null, $event = null){
@ -36,5 +40,22 @@ class EntityEventPacket extends RakNetDataPacket{
$this->putInt($this->eid);
$this->putByte($this->event);
}
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -35,5 +35,24 @@ class InteractPacket extends RakNetDataPacket{
$this->putInt($this->eid);
$this->putInt($this->target);
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
$this->target = $p->global2localEID[$this->target] ?? false;
if($this->eid === false || $this->target === false) return false;
}
return true;
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
$this->target = $p->local2GlobalEID[$this->target] ?? false;
if($this->eid === false || $this->target === false) return false;
}
return true;
}
}

View file

@ -35,4 +35,20 @@ class MoveEntityPacket_PosRot extends RakNetDataPacket{
$this->putFloat($this->pitch);
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -43,4 +43,20 @@ class MovePlayerPacket extends RakNetDataPacket{
}
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -38,5 +38,13 @@ class PlayerActionPacket extends RakNetDataPacket{
$this->putInt($this->face);
$this->putInt($this->eid);*/
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -27,5 +27,22 @@ class PlayerArmorEquipmentPacket extends RakNetDataPacket{
$this->putByte($this->slots[2]);
$this->putByte($this->slots[3]);
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -33,5 +33,22 @@ class PlayerEquipmentPacket extends RakNetDataPacket{
$this->putShort($this->meta);
if($this->PROTOCOL === ProtocolInfo::CURRENT_PROTOCOL){$this->putByte($this->slot);}
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -31,4 +31,12 @@ class RemoveBlockPacket extends RakNetDataPacket{
$this->putInt($this->y);*/
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -18,5 +18,13 @@ class RemoveEntityPacket extends RakNetDataPacket{
$this->reset();
$this->putInt($this->eid);
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -18,4 +18,12 @@ class RemovePlayerPacket extends RakNetDataPacket{
$this->putLong($this->clientID);
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -37,5 +37,12 @@ class RespawnPacket extends RakNetDataPacket{
$this->putFloat($this->y);
$this->putFloat($this->z);
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -29,4 +29,21 @@ class RotateHeadPacket extends RakNetDataPacket{
$this->putByte($this->rawYaw ? $this->yaw : ($this->yaw / 360 / 0.0039062)); //wraps 360 angle to 0xff
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -51,5 +51,23 @@ class SendInventoryPacket extends RakNetDataPacket{
}
}
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -28,5 +28,13 @@ class SetEntityDataPacket extends RakNetDataPacket{
$this->putInt($this->eid);
$this->put(Utils::writeMetadata($this->metadata));
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -12,7 +12,9 @@ class SetEntityLinkPacket extends RakNetDataPacket{
public $riding;
public $type;
public function decode() {
$this->rider = $this->getInt();
$this->riding = $this->getInt();
$this->type = $this->getInt();
}
public function encode() {
$this->reset();
@ -28,4 +30,23 @@ class SetEntityLinkPacket extends RakNetDataPacket{
return ProtocolInfo::SET_ENTITY_LINK_PACKET;
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->rider = $p->local2GlobalEID[$this->rider] ?? false;
$this->riding = $p->local2GlobalEID[$this->riding] ?? false;
if($this->rider === false || $this->riding === false) return false;
}
return true;
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->rider = $p->global2localEID[$this->rider] ?? false;
$this->riding = $p->global2localEID[$this->riding] ?? false;
if($this->rider === false || $this->riding === false) return false;
}
return true;
}
}

View file

@ -30,5 +30,12 @@ class SetEntityMotionPacket extends RakNetDataPacket{
$this->putShort((int) ($this->speedY * 8000));
$this->putShort((int) ($this->speedZ * 8000));
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -27,5 +27,13 @@ class StartGamePacket extends RakNetDataPacket{
$this->putFloat($this->y);
$this->putFloat($this->z);
}
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}

View file

@ -21,4 +21,14 @@ class TakeItemEntityPacket extends RakNetDataPacket{
$this->putInt($this->eid);
}
//TODO convert
public function eidsToLocal(Player $p){
if(!$this->localEids){
$this->localEids = true;
$this->eid = $p->global2localEID[$this->eid] ?? false;
$this->target = $p->global2localEID[$this->target] ?? false;
if($this->eid === false || $this->target === false) return false;
}
return true;
}
}

View file

@ -66,5 +66,13 @@ class UseItemPacket extends RakNetDataPacket{
$this->putInt($this->eid);
$this->putInt($this->unknownInt1);*/
}
public function eidsToGlobal(Player $p){
if($this->localEids){
$this->localEids = false;
$this->eid = $p->local2GlobalEID[$this->eid] ?? false;
if($this->eid === false) return false;
}
return true;
}
}