rewrite of interact system, bugfixes, ai tweaks

This commit is contained in:
GameHerobrine 2022-11-01 00:55:49 +03:00
parent f5222be9d2
commit ac1a1b2449
62 changed files with 649 additions and 491 deletions

View file

@ -234,27 +234,27 @@ class EntityAPI{
break;
}while($i < 200);
if($i == 200)
$i = 0;
$data = [
"x" => $pos->x + mt_rand(-10, 10) / 50,
"y" => $pos->y + 0.19 - $i + 1,
"z" => $pos->z + mt_rand(-10, 10) / 50,
"level" => $pos->level,
//"speedX" => mt_rand(-3, 3) / 8,
"speedY" => mt_rand(5, 8) / 2,
//"speedZ" => mt_rand(-3, 3) / 8,
"item" => $item,
];
if($this->server->api->handle("item.drop", $data) !== false){
for($count = $item->count; $count > 0;){
$item->count = min($item->getMaxStackSize(), $count);
$count -= $item->count;
$e = $this->add($pos->level, ENTITY_ITEM, $item->getID(), $data);
$this->spawnToAll($e);
$this->server->api->handle("entity.motion", $e);
}
$i %= 200; //if i >= 200, set to 0..1..2..199
$data = [
"x" => $pos->x + mt_rand(-10, 10) / 50,
"y" => $pos->y + 0.19 + 1 - $i,
"z" => $pos->z + mt_rand(-10, 10) / 50,
"level" => $pos->level,
//"speedX" => mt_rand(-3, 3) / 8,
//"speedY" => mt_rand(5, 8) / 2, speed is handled differently now
//"speedZ" => mt_rand(-3, 3) / 8,
"item" => $item,
];
if($this->server->api->handle("item.drop", $data) !== false){
for($count = $item->count; $count > 0;){
$item->count = min($item->getMaxStackSize(), $count);
$count -= $item->count;
$e = $this->add($pos->level, ENTITY_ITEM, $item->getID(), $data);
$this->spawnToAll($e);
$this->server->api->handle("entity.motion", $e);
}
}
}
public function spawnAll(Player $player){

View file

@ -1,6 +1,9 @@
<?php
class LevelAPI{
/**
* @var Level[]
*/
public $levels;
private $server, $default;

View file

@ -491,4 +491,4 @@ class PlayerAPI{
$data->save();
}
}
}
}