mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
tnt will not regenerate you now + will add knockback to players
This commit is contained in:
parent
a10c6a1d57
commit
2678243d8b
4 changed files with 50 additions and 32 deletions
|
|
@ -13,7 +13,6 @@ class PrimedTNT extends Entity{
|
|||
$this->setSize(0.98, 0.98);
|
||||
$this->yOffset = $this->height / 2;
|
||||
$this->setHealth(10000000, "generic");
|
||||
//$this->server->schedule(5, [$this, "updateFuse"], [], true);
|
||||
}
|
||||
|
||||
public function isPickable(){
|
||||
|
|
@ -66,20 +65,6 @@ class PrimedTNT extends Entity{
|
|||
$this->lastUpdate = $now;
|
||||
}
|
||||
|
||||
/*public function updateFuse(){
|
||||
if($this->closed === true){
|
||||
return false;
|
||||
}
|
||||
if($this->type === OBJECT_PRIMEDTNT){
|
||||
$this->updateMetadata();
|
||||
if(((microtime(true) - $this->spawntime) * 20) >= $this->data["fuse"]){
|
||||
$this->close();
|
||||
$explosion = new Explosion($this, $this->data["power"]);
|
||||
$explosion->explode();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public function spawn($player){
|
||||
$pk = new AddEntityPacket;
|
||||
$pk->eid = $this->eid;
|
||||
|
|
|
|||
|
|
@ -60,10 +60,32 @@ class Explosion{
|
|||
$radius = 2 * $this->size;
|
||||
$server = ServerAPI::request();
|
||||
if(!Explosion::$enableExplosions){ /*Disable Explosions*/
|
||||
foreach($server->api->entity->getRadius($this->source, $radius) as $entity){
|
||||
$impact = (1 - $this->source->distance($entity) / $radius) * 0.5; //pla>
|
||||
$damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1);
|
||||
$entity->harm($damage, "explosion");
|
||||
foreach($server->api->entity->getRadius($this->source, $radius+1) as $entity){
|
||||
$distance = $this->source->distance($entity);
|
||||
$distByRad = $distance / $this->size;
|
||||
if($distByRad <= 1 && $distance != 0){
|
||||
$diffX = ($entity->x - $this->source->x) / $distance;
|
||||
$diffY = ($entity->y + $entity->getEyeHeight() - $this->source->y) / $distance;
|
||||
$diffZ = ($entity->z - $this->source->z) / $distance;
|
||||
|
||||
$impact = (1 - $distByRad) * 0.5; //TODO calculate block density around the entity instead of 0.5
|
||||
$damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1);
|
||||
if($damage > 0){
|
||||
$entity->harm($damage, "explosion");
|
||||
$entity->speedX = $diffX * $impact;
|
||||
$entity->speedY = $diffY * $impact;
|
||||
$entity->speedZ = $diffZ * $impact;
|
||||
|
||||
if($entity->isPlayer()){
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk->eid = 0; //XXX change
|
||||
$pk->speedX = $entity->speedX;
|
||||
$pk->speedY = $entity->speedY;
|
||||
$pk->speedZ = $entity->speedZ;
|
||||
$entity->player->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$pk = new ExplodePacket; //sound fix
|
||||
$pk->x = $this->source->x;
|
||||
|
|
@ -136,10 +158,21 @@ class Explosion{
|
|||
|
||||
$impact = (1 - $distByRad) * 0.5; //TODO calculate block density around the entity instead of 0.5
|
||||
$damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1);
|
||||
$entity->harm($damage, "explosion");
|
||||
$entity->speedX = $diffX * $impact; //TODO check is needed for player?
|
||||
$entity->speedY = $diffY * $impact;
|
||||
$entity->speedZ = $diffZ * $impact;
|
||||
if($damage > 0){
|
||||
$entity->harm($damage, "explosion");
|
||||
$entity->speedX = $diffX * $impact;
|
||||
$entity->speedY = $diffY * $impact;
|
||||
$entity->speedZ = $diffZ * $impact;
|
||||
|
||||
if($entity->isPlayer()){
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk->eid = 0; //XXX change
|
||||
$pk->speedX = $entity->speedX;
|
||||
$pk->speedY = $entity->speedY;
|
||||
$pk->speedZ = $entity->speedZ;
|
||||
$entity->player->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -494,8 +494,15 @@ class Level{
|
|||
}
|
||||
$this->totalMobsAmount = 0;
|
||||
$post = [];
|
||||
//console($this->getName());
|
||||
|
||||
foreach($this->entityList as $k => $e){
|
||||
if(!($e instanceof Entity)){
|
||||
unset($this->entityList[$k]);
|
||||
unset($this->server->entities[$k]);
|
||||
//TODO try to remove from $entityListPositioned?
|
||||
continue;
|
||||
}
|
||||
|
||||
$dd = CORRECT_ENTITY_CLASSES[$e->class] ?? false;
|
||||
if($dd === false || ($dd !== true && !isset($dd[$e->type]))){
|
||||
ConsoleAPI::warn("Entity $k has invalid entity! {$e->class} {$e->type}");
|
||||
|
|
@ -514,13 +521,6 @@ class Level{
|
|||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!($e instanceof Entity)){
|
||||
unset($this->entityList[$k]);
|
||||
unset($this->server->entities[$k]);
|
||||
//TODO try to remove from $entityListPositioned?
|
||||
continue;
|
||||
}
|
||||
$curChunkX = (int)$e->x >> 4;
|
||||
$curChunkZ = (int)$e->z >> 4;
|
||||
if($e->class === ENTITY_MOB && !$e->isPlayer()){
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class MobSpawner{
|
|||
$type = mt_rand(10, 13);
|
||||
$baby = false;
|
||||
$grassOnly = true;
|
||||
}elseif(self::$spawnMobs && ($phase == "night" || $phase == "sunset")){ //Monster, true night
|
||||
}elseif(self::$spawnMobs && ($phase == "night" || $phase == "sunset") && $this->server->difficulty > 0){ //Monster, true night
|
||||
$type = mt_rand(32, 35);
|
||||
$grassOnly = false;
|
||||
$baby = 2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue