mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-15 16:05:28 +00:00
Fixed several Cake bugs
fixed cake flat-out doesn't work fixed last slice of cake vanishing (NOOOOO) fixed EntityEatBlockEvent not getting called made AABB calculation less confusing
This commit is contained in:
parent
58bf5d6679
commit
bb9299070d
@ -50,10 +50,10 @@ class Cake extends Transparent implements FoodSource{
|
|||||||
|
|
||||||
protected function recalculateBoundingBox(){
|
protected function recalculateBoundingBox(){
|
||||||
|
|
||||||
$f = (1 + $this->getDamage() * 2) / 16;
|
$f = $this->getDamage() * 0.125; //1 slice width
|
||||||
|
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + $f,
|
$this->x + 0.0625 + $f,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z + 0.0625,
|
$this->z + 0.0625,
|
||||||
$this->x + 1 - 0.0625,
|
$this->x + 1 - 0.0625,
|
||||||
@ -90,10 +90,17 @@ class Cake extends Transparent implements FoodSource{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null) : bool{
|
public function onActivate(Item $item, Player $player = null) : bool{
|
||||||
if($player instanceof Player and $player->getHealth() < $player->getMaxHealth()){
|
//TODO: refactor this into generic food handling
|
||||||
$ev = new EntityEatBlockEvent($player, $this);
|
if($player instanceof Player and $player->getFood() < $player->getMaxFood()){
|
||||||
|
$player->getServer()->getPluginManager()->callEvent($ev = new EntityEatBlockEvent($player, $this));
|
||||||
|
|
||||||
if(!$ev->isCancelled()){
|
if(!$ev->isCancelled()){
|
||||||
|
$player->addFood($ev->getFoodRestore());
|
||||||
|
$player->addSaturation($ev->getSaturationRestore());
|
||||||
|
foreach($ev->getAdditionalEffects() as $effect){
|
||||||
|
$player->addEffect($effect);
|
||||||
|
}
|
||||||
|
|
||||||
$this->getLevel()->setBlock($this, $ev->getResidue());
|
$this->getLevel()->setBlock($this, $ev->getResidue());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -113,7 +120,7 @@ class Cake extends Transparent implements FoodSource{
|
|||||||
public function getResidue(){
|
public function getResidue(){
|
||||||
$clone = clone $this;
|
$clone = clone $this;
|
||||||
$clone->meta++;
|
$clone->meta++;
|
||||||
if($clone->meta >= 0x06){
|
if($clone->meta > 0x06){
|
||||||
$clone = BlockFactory::get(Block::AIR);
|
$clone = BlockFactory::get(Block::AIR);
|
||||||
}
|
}
|
||||||
return $clone;
|
return $clone;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user