mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-07 10:31:51 +00:00
Added Fire, Lava damage
This commit is contained in:
parent
e608acbd1c
commit
e9a2f88847
@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use pocketmine\entity\Entity;
|
||||||
use pocketmine\entity\Villager;
|
use pocketmine\entity\Villager;
|
||||||
use pocketmine\entity\Zombie;
|
use pocketmine\entity\Zombie;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
@ -832,6 +833,13 @@ abstract class Block extends Position implements Metadatable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Entity $entity
|
||||||
|
*/
|
||||||
|
public function onEntityCollide(Entity $entity){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return AxisAlignedBB
|
* @return AxisAlignedBB
|
||||||
*/
|
*/
|
||||||
|
@ -42,7 +42,7 @@ class FenceGate extends Transparent{
|
|||||||
if(($this->getDamage() & 0x04) > 0){
|
if(($this->getDamage() & 0x04) > 0){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = ($this->getDamage() & 0x03);
|
$i = ($this->getDamage() & 0x03);
|
||||||
if($i === 2 and $i === 0){
|
if($i === 2 and $i === 0){
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
|
@ -22,7 +22,10 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\entity\Entity;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
|
use pocketmine\Server;
|
||||||
|
|
||||||
class Fire extends Flowable{
|
class Fire extends Flowable{
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
@ -37,6 +40,14 @@ class Fire extends Flowable{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onEntityCollide(Entity $entity){
|
||||||
|
$entity->setOnFire(8);
|
||||||
|
$ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_FIRE, 1);
|
||||||
|
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||||
|
if(!$ev->isCancelled()){
|
||||||
|
$entity->attack($ev->getFinalDamage(), $ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
return [];
|
return [];
|
||||||
|
@ -22,10 +22,12 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\entity\Entity;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\level\Position;
|
use pocketmine\level\Position;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
|
|
||||||
class Lava extends Liquid{
|
class Lava extends Liquid{
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
@ -37,6 +39,15 @@ class Lava extends Liquid{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onEntityCollide(Entity $entity){
|
||||||
|
$entity->setOnFire(15);
|
||||||
|
$ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_LAVA, 4);
|
||||||
|
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||||
|
if(!$ev->isCancelled()){
|
||||||
|
$entity->attack($ev->getFinalDamage(), $ev);
|
||||||
|
}
|
||||||
|
$entity->attack(4, EntityDamageEvent::CAUSE_LAVA);
|
||||||
|
}
|
||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
$ret = $this->getLevel()->setBlock($this, $this, true);
|
$ret = $this->getLevel()->setBlock($this, $this, true);
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
|
use pocketmine\Server;
|
||||||
|
use pocketmine\entity\Entity;
|
||||||
|
|
||||||
class StillLava extends Liquid{
|
class StillLava extends Liquid{
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
@ -28,4 +31,18 @@ class StillLava extends Liquid{
|
|||||||
$this->hardness = 500;
|
$this->hardness = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBoundingBox(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onEntityCollide(Entity $entity){
|
||||||
|
$entity->setOnFire(15);
|
||||||
|
$ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_LAVA, 4);
|
||||||
|
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||||
|
if(!$ev->isCancelled()){
|
||||||
|
$entity->attack($ev->getFinalDamage(), $ev);
|
||||||
|
}
|
||||||
|
$entity->attack(4, EntityDamageEvent::CAUSE_LAVA);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -460,6 +460,8 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
$hasUpdate = false;
|
$hasUpdate = false;
|
||||||
$this->updateMovement();
|
$this->updateMovement();
|
||||||
|
|
||||||
|
$this->checkBlockCollision();
|
||||||
|
|
||||||
if($this->handleWaterMovement()){
|
if($this->handleWaterMovement()){
|
||||||
$this->fallDistance = 0;
|
$this->fallDistance = 0;
|
||||||
$this->inWater = true;
|
$this->inWater = true;
|
||||||
@ -483,7 +485,11 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(($this->fireTicks % 20) === 0){
|
if(($this->fireTicks % 20) === 0){
|
||||||
$this->attack(1, EntityDamageEvent::CAUSE_FIRE_TICK);
|
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FIRE_TICK, 1);
|
||||||
|
$this->server->getPluginManager()->callEvent($ev);
|
||||||
|
if(!$ev->isCancelled()){
|
||||||
|
$this->attack($ev->getFinalDamage(), $ev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
--$this->fireTicks;
|
--$this->fireTicks;
|
||||||
}
|
}
|
||||||
@ -491,8 +497,8 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($this->handleLavaMovement()){
|
if($this->handleLavaMovement()){
|
||||||
$this->attack(4, EntityDamageEvent::CAUSE_LAVA);
|
//$this->attack(4, EntityDamageEvent::CAUSE_LAVA);
|
||||||
$this->setOnFire(15);
|
//$this->setOnFire(15);
|
||||||
$hasUpdate = true;
|
$hasUpdate = true;
|
||||||
$this->fallDistance *= 0.5;
|
$this->fallDistance *= 0.5;
|
||||||
}
|
}
|
||||||
@ -712,8 +718,7 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function move($dx, $dy, $dz){
|
public function move($dx, $dy, $dz){
|
||||||
//$collision = [];
|
|
||||||
//$this->checkBlockCollision($collision);
|
|
||||||
if($dx == 0 and $dz == 0 and $dy == 0){
|
if($dx == 0 and $dz == 0 and $dy == 0){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -932,12 +937,7 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function checkBlockCollision(){
|
||||||
* @param Block[] $list
|
|
||||||
*
|
|
||||||
* @return Block[]
|
|
||||||
*/
|
|
||||||
protected function checkBlockCollision(&$list = []){
|
|
||||||
$minX = floor($this->boundingBox->minX + 0.001);
|
$minX = floor($this->boundingBox->minX + 0.001);
|
||||||
$minY = floor($this->boundingBox->minY + 0.001);
|
$minY = floor($this->boundingBox->minY + 0.001);
|
||||||
$minZ = floor($this->boundingBox->minZ + 0.001);
|
$minZ = floor($this->boundingBox->minZ + 0.001);
|
||||||
@ -948,12 +948,13 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
for($z = $minZ; $z <= $maxZ; ++$z){
|
for($z = $minZ; $z <= $maxZ; ++$z){
|
||||||
for($x = $minX; $x <= $maxX; ++$x){
|
for($x = $minX; $x <= $maxX; ++$x){
|
||||||
for($y = $minY; $y <= $maxY; ++$y){
|
for($y = $minY; $y <= $maxY; ++$y){
|
||||||
$this->getLevel()->getBlock(new Vector3($x, $y, $z))->collidesWithBB($this->boundingBox, $list);
|
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
|
||||||
|
if($block !== null and $block->getID() > 0){
|
||||||
|
$block->onEntityCollide($this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPositionAndRotation(Vector3 $pos, $yaw, $pitch, $force = false){
|
public function setPositionAndRotation(Vector3 $pos, $yaw, $pitch, $force = false){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user