mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
item entities will try to combine with neatby items of the same type
This commit is contained in:
parent
6ba62666c3
commit
4b17edfc05
4 changed files with 88 additions and 29 deletions
|
|
@ -355,8 +355,6 @@ class Level{
|
|||
}
|
||||
|
||||
public function onTick(PocketMinecraftServer $server, $currentTime){
|
||||
safe_var_dump($this->players);
|
||||
console($this->getName());
|
||||
if(!$this->stopTime) ++$this->time;
|
||||
for($cX = 0; $cX < 16; ++$cX){
|
||||
for($cZ = 0; $cZ < 16; ++$cZ){
|
||||
|
|
@ -473,6 +471,28 @@ class Level{
|
|||
|
||||
return false;
|
||||
}
|
||||
public function getEntitiesInAABBOfType(AxisAlignedBB $bb, $class){
|
||||
$minChunkX = ((int)($bb->minX)) >> 4;
|
||||
$minChunkZ = ((int)($bb->minZ)) >> 4;
|
||||
$maxChunkX = ((int)($bb->maxX)) >> 4;
|
||||
$maxChunkZ = ((int)($bb->maxZ)) >> 4;
|
||||
$ents = [];
|
||||
console("nya $minChunkX $minChunkZ $maxChunkX $maxChunkZ");
|
||||
for($chunkX = $minChunkX; $chunkX <= $maxChunkX; ++$chunkX){
|
||||
for($chunkZ = $minChunkZ; $chunkZ <= $maxChunkZ; ++$chunkZ){
|
||||
$ind = "$chunkX $chunkZ";
|
||||
foreach($this->entityListPositioned[$ind] ?? [] as $ind2 => $entid){
|
||||
if(isset($this->entityList[$entid]) && $this->entityList[$entid] instanceof Entity && $this->entityList[$entid]->class === $class && $this->entityList[$entid]->boundingBox->intersectsWith($bb)){
|
||||
$ents[$entid] = $this->entityList[$entid];
|
||||
}else if(!isset($this->entityList[$entid])){
|
||||
ConsoleAPI::debug("Removing entity from level array at index $ind/$ind2: $entid");
|
||||
unset($this->entityListPositioned[$ind][$ind2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ents;
|
||||
}
|
||||
|
||||
public function getEntitiesInAABB(AxisAlignedBB $bb){
|
||||
$minChunkX = ((int)($bb->minX)) >> 4;
|
||||
|
|
@ -484,9 +504,12 @@ class Level{
|
|||
for($chunkX = $minChunkX; $chunkX <= $maxChunkX; ++$chunkX){
|
||||
for($chunkZ = $minChunkZ; $chunkZ <= $maxChunkZ; ++$chunkZ){
|
||||
$ind = "$chunkX $chunkZ";
|
||||
foreach($this->level->entityListPositioned[$ind] ?? [] as $entid){
|
||||
if($this->entityList[$entid] instanceof Entity && $this->entityList[$entid]->boundingBox->intersectsWith($bb)){
|
||||
foreach($this->entityListPositioned[$ind] ?? [] as $ind2 => $entid){
|
||||
if(isset($this->entityList[$entid]) && $this->entityList[$entid] instanceof Entity && $this->entityList[$entid]->boundingBox->intersectsWith($bb)){
|
||||
$ents[$entid] = $this->entityList[$entid];
|
||||
}else if(!isset($this->entityList[$entid])){
|
||||
ConsoleAPI::debug("Removing entity from level array at index $ind/$ind2: $entid");
|
||||
unset($this->entityListPositioned[$ind][$ind2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue