From 6af453dcc3e31fdc03adf8000dc40607ffad9fd2 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Tue, 6 Jan 2026 08:58:35 +0300 Subject: [PATCH] better bed head block detection, fixed bonemeal not decrementing from slot when used, fixed players seeing teleport to -256,128,-256 when dying --- src/entity/Entity.php | 2 +- src/material/block/misc/BedBlock.php | 17 ++++------------- src/material/block/plant/BeetrootBlock.php | 2 +- src/material/block/plant/CarrotBlock.php | 2 +- src/material/block/plant/CyanFlowerBlock.php | 2 +- src/material/block/plant/DandelionBlock.php | 2 +- src/material/block/plant/MelonStemBlock.php | 2 +- src/material/block/plant/PotatoBlock.php | 2 +- src/material/block/plant/PumpkinStemBlock.php | 2 +- src/material/block/plant/SaplingBlock.php | 2 +- src/material/block/plant/SugarcaneBlock.php | 2 +- src/material/block/plant/WheatBlock.php | 2 +- 12 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index e5097253..bfb6a2b1 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1724,7 +1724,7 @@ class Entity extends Position $pk->yaw = 0; $pk->pitch = 0; foreach($this->level->players as $player){ - if($player->hasEntity($this)) $player->entityQueueDataPacket(clone $pk); + if($player->hasEntity($this) && $player != $this->player) $player->entityQueueDataPacket(clone $pk); } }else{ $pk = new EntityEventPacket; diff --git a/src/material/block/misc/BedBlock.php b/src/material/block/misc/BedBlock.php index 8c63f82b..be845c70 100644 --- a/src/material/block/misc/BedBlock.php +++ b/src/material/block/misc/BedBlock.php @@ -84,22 +84,13 @@ class BedBlock extends TransparentBlock{ return true; } - $blockNorth = $this->getSide(2); //Gets the blocks around them - $blockSouth = $this->getSide(3); - $blockEast = $this->getSide(5); - $blockWest = $this->getSide(4); if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed $b = $this; }else{ //Bottom Part of Bed - if($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x08) === 0x08){ - $b = $blockNorth; - }elseif($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x08) === 0x08){ - $b = $blockSouth; - }elseif($blockEast->getID() === $this->id and ($blockEast->meta & 0x08) === 0x08){ - $b = $blockEast; - }elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){ - $b = $blockWest; - }else{ + $dir = ($this->meta & 3); + $o = BedBlock::HEAD_DIRECTION_OFFSETS[$dir]; + $b = $this->level->getBlockWithoutVector($this->x + $o[0], $this->y, $this->z + $o[1]); + if($b->getID() != BED_BLOCK){ $player->sendChat("This bed is incomplete"); return true; } diff --git a/src/material/block/plant/BeetrootBlock.php b/src/material/block/plant/BeetrootBlock.php index 312b63bd..0c68a3b4 100644 --- a/src/material/block/plant/BeetrootBlock.php +++ b/src/material/block/plant/BeetrootBlock.php @@ -33,7 +33,7 @@ class BeetrootBlock extends FlowableBlock{ $this->meta = 7; } $this->level->setBlock($this, $this, true, false, true); - $player->consumeSingleItem(); + $player->consumeSingleItem(send:true); return true; } return false; diff --git a/src/material/block/plant/CarrotBlock.php b/src/material/block/plant/CarrotBlock.php index 4bcd86b9..5abe9ad8 100644 --- a/src/material/block/plant/CarrotBlock.php +++ b/src/material/block/plant/CarrotBlock.php @@ -26,7 +26,7 @@ class CarrotBlock extends FlowableBlock{ $this->meta = 7; } $this->level->setBlock($this, $this, true, false, true); - $player->consumeSingleItem(); + $player->consumeSingleItem(send:true); return true; } return false; diff --git a/src/material/block/plant/CyanFlowerBlock.php b/src/material/block/plant/CyanFlowerBlock.php index c48704e0..2674620b 100644 --- a/src/material/block/plant/CyanFlowerBlock.php +++ b/src/material/block/plant/CyanFlowerBlock.php @@ -38,7 +38,7 @@ class CyanFlowerBlock extends FlowableBlock{ if($item->getID() === DYE and $item->getMetadata() === 0x0F){ $random = new Random(); self::placeFlowers($this->level, new Vector3($this->x, $this->y, $this->z), $random, $random->nextRange(2, 5), 2); - $player->consumeSingleItem(); + $player->consumeSingleItem(send:true); return true; } return false; diff --git a/src/material/block/plant/DandelionBlock.php b/src/material/block/plant/DandelionBlock.php index bc4d56f2..7388a132 100644 --- a/src/material/block/plant/DandelionBlock.php +++ b/src/material/block/plant/DandelionBlock.php @@ -33,7 +33,7 @@ class DandelionBlock extends FlowableBlock{ if($item->getID() === DYE and $item->getMetadata() === 0x0F){ $random = new Random(); self::placeFlowers($this->level, new Vector3($this->x, $this->y, $this->z), $random, $random->nextRange(2, 5), 2); - $player->consumeSingleItem(); + $player->consumeSingleItem(send:true); return true; } return false; diff --git a/src/material/block/plant/MelonStemBlock.php b/src/material/block/plant/MelonStemBlock.php index 8042d889..fc4fb4be 100644 --- a/src/material/block/plant/MelonStemBlock.php +++ b/src/material/block/plant/MelonStemBlock.php @@ -104,7 +104,7 @@ class MelonStemBlock extends FlowableBlock{ $this->meta = 7; } $this->level->setBlock($this, $this, true, false, true); - $player->consumeSingleItem(); + $player->consumeSingleItem(send:true); return true; } return false; diff --git a/src/material/block/plant/PotatoBlock.php b/src/material/block/plant/PotatoBlock.php index 15866171..9af1dbb3 100644 --- a/src/material/block/plant/PotatoBlock.php +++ b/src/material/block/plant/PotatoBlock.php @@ -35,7 +35,7 @@ class PotatoBlock extends FlowableBlock{ $this->meta = 7; } $this->level->setBlock($this, $this, true, false, true); - $player->consumeSingleItem(); + $player->consumeSingleItem(send:true); return true; } return false; diff --git a/src/material/block/plant/PumpkinStemBlock.php b/src/material/block/plant/PumpkinStemBlock.php index 874e1a8e..42c966a1 100644 --- a/src/material/block/plant/PumpkinStemBlock.php +++ b/src/material/block/plant/PumpkinStemBlock.php @@ -103,7 +103,7 @@ class PumpkinStemBlock extends FlowableBlock{ $this->meta = 7; } $this->level->setBlock($this, $this, true, false, true); - $player->consumeSingleItem(); + $player->consumeSingleItem(send:true); return true; } return false; diff --git a/src/material/block/plant/SaplingBlock.php b/src/material/block/plant/SaplingBlock.php index 49ae119e..d622130a 100644 --- a/src/material/block/plant/SaplingBlock.php +++ b/src/material/block/plant/SaplingBlock.php @@ -37,7 +37,7 @@ class SaplingBlock extends FlowableBlock{ public function onActivate(Item $item, Player $player){ if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x03); - $player->consumeSingleItem(); + $player->consumeSingleItem(send:true); return true; } return false; diff --git a/src/material/block/plant/SugarcaneBlock.php b/src/material/block/plant/SugarcaneBlock.php index 279952e2..6e5bcb94 100644 --- a/src/material/block/plant/SugarcaneBlock.php +++ b/src/material/block/plant/SugarcaneBlock.php @@ -31,7 +31,7 @@ class SugarcaneBlock extends FlowableBlock{ $this->level->fastSetBlockUpdateMeta($this->x, $this->y, $this->z, $this->meta, true); } - $player->consumeSingleItem(); + $player->consumeSingleItem(send:true); return true; } return false; diff --git a/src/material/block/plant/WheatBlock.php b/src/material/block/plant/WheatBlock.php index 3e25d2ea..caaab02a 100644 --- a/src/material/block/plant/WheatBlock.php +++ b/src/material/block/plant/WheatBlock.php @@ -26,7 +26,7 @@ class WheatBlock extends FlowableBlock{ $this->meta = 7; } $this->level->setBlock($this, $this, true, false, true); - $player->consumeSingleItem(); + $player->consumeSingleItem(send:true); return true; } return false;