mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 15:41:33 +00:00
Blocks now save their bounding box, fixed entity block collision check
This commit is contained in:
@@ -1040,9 +1040,9 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$vector = Vector3::createVector(0, 0, 0);
|
||||
$v = Vector3::createVector(0, 0, 0);
|
||||
|
||||
for($v->z = $minZ; $v->z < $maxZ; ++$v->z){
|
||||
for($v->x = $minX; $v->x < $maxX; ++$v->x){
|
||||
for($v->y = $minY; $v->y < $maxY; ++$v->y){
|
||||
for($v->z = $minZ; $v->z <= $maxZ; ++$v->z){
|
||||
for($v->x = $minX; $v->x <= $maxX; ++$v->x){
|
||||
for($v->y = $minY; $v->y <= $maxY; ++$v->y){
|
||||
$block = $this->level->getBlock($v);
|
||||
if($block !== null and $block->hasEntityCollision){
|
||||
$block->onEntityCollide($this);
|
||||
|
@@ -69,9 +69,26 @@ abstract class Living extends Entity implements Damageable{
|
||||
}
|
||||
|
||||
public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){
|
||||
|
||||
|
||||
if($this->attackTime > 0){
|
||||
$lastCause = $this->getLastDamageCause();
|
||||
if($lastCause instanceof EntityDamageEvent and $lastCause->getDamage() >= $damage){
|
||||
if($source instanceof EntityDamageEvent){
|
||||
$source->setCancelled();
|
||||
$this->server->getPluginManager()->callEvent($source);
|
||||
$damage = $source->getFinalDamage();
|
||||
if($source->isCancelled()){
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}elseif($source instanceof EntityDamageEvent){
|
||||
$this->server->getPluginManager()->callEvent($source);
|
||||
$damage = $source->getFinalDamage();
|
||||
if($source->isCancelled()){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user