mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
code style fix
This commit is contained in:
parent
fc5c5625cb
commit
5e8e9330e2
361 changed files with 4766 additions and 4650 deletions
|
|
@ -3,23 +3,23 @@
|
|||
class Painting extends Entity{
|
||||
const CLASS_TYPE = ENTITY_OBJECT;
|
||||
const TYPE = OBJECT_PAINTING;
|
||||
|
||||
|
||||
public $motive;
|
||||
public $direction;
|
||||
public $xPos, $yPos, $zPos;
|
||||
|
||||
|
||||
public $isValid = true;
|
||||
|
||||
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->x = $this->data["TileX"] ?? $this->x;
|
||||
$this->y = $this->data["TileY"] ?? $this->y;
|
||||
$this->z = $this->data["TileZ"] ?? $this->z;
|
||||
|
||||
$this->xPos = $this->data["xPos"] ?? (int)$this->x;
|
||||
$this->zPos = $this->data["zPos"] ?? (int)$this->z;
|
||||
$this->yPos = $this->data["yPos"] ?? (int)$this->y;
|
||||
|
||||
|
||||
$this->xPos = $this->data["xPos"] ?? (int) $this->x;
|
||||
$this->zPos = $this->data["zPos"] ?? (int) $this->z;
|
||||
$this->yPos = $this->data["yPos"] ?? (int) $this->y;
|
||||
|
||||
$this->health = 1;
|
||||
$this->canBeAttacked = true;
|
||||
$this->width = 1;
|
||||
|
|
@ -30,30 +30,30 @@ class Painting extends Entity{
|
|||
if($dir === false){
|
||||
$dir = floor($this->yaw / 90);
|
||||
}
|
||||
|
||||
|
||||
if($mot === false){
|
||||
$this->setRandomMotive($dir);
|
||||
|
||||
|
||||
}else{
|
||||
$this->motive = $mot;
|
||||
$this->direction = $dir;
|
||||
$this->setDirection($dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public $counter = 0;
|
||||
public function update($now){
|
||||
if($this->closed === true){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->closed === true){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(++$this->counter >= 100){
|
||||
$this->counter = 0;
|
||||
if(!$this->survives() && !$this->dead){ //maybe dont check entity collision?
|
||||
$this->makeDead("nosurvive");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -62,34 +62,34 @@ class Painting extends Entity{
|
|||
foreach(PaintingItem::$motives as $name => $motive){
|
||||
$this->motive = $name;
|
||||
$this->setDirection($dir);
|
||||
|
||||
|
||||
if($this->survives()){
|
||||
$tochoose[] = $name;
|
||||
}
|
||||
}
|
||||
if(count($tochoose) > 0){
|
||||
$ind = mt_rand(0, count($tochoose)-1);
|
||||
$ind = mt_rand(0, count($tochoose) - 1);
|
||||
}else{
|
||||
$this->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->motive = $tochoose[$ind];
|
||||
$this->setDirection($dir);
|
||||
}
|
||||
|
||||
|
||||
public static function offs($n){
|
||||
if($n == 32 || $n == 64) return 0.5;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const DIRECTION_OPPOSITE = [2, 3, 0, 1];
|
||||
public function setDirection($dir){
|
||||
$this->direction = $dir;
|
||||
$this->lastYaw = $this->yaw = $dir * 90;
|
||||
$size = PaintingItem::$motives[$this->motive] ?? array(1, 1);
|
||||
$width = $size[0]*16;
|
||||
$height = $size[1]*16;
|
||||
$size = PaintingItem::$motives[$this->motive] ?? [1, 1];
|
||||
$width = $size[0] * 16;
|
||||
$height = $size[1] * 16;
|
||||
if($dir == 2 || $dir == 0){
|
||||
$v10 = 2;
|
||||
$v9 = $width;
|
||||
|
|
@ -98,28 +98,28 @@ class Painting extends Entity{
|
|||
$v9 = 2;
|
||||
$v10 = $width;
|
||||
}
|
||||
|
||||
|
||||
$v12 = $v9 * 0.03125;
|
||||
$v13 = $height * 0.03125;
|
||||
$v14 = $v10 * 0.03125;
|
||||
$v15 = $this->xPos + 0.5;
|
||||
$v16 = $this->yPos + 0.5;
|
||||
$v17 = $this->zPos + 0.5; //XXX check
|
||||
|
||||
|
||||
if($dir == 2){
|
||||
$v17 = $v17 - 0.5625;
|
||||
$v15 = $v15 - self::offs($width);
|
||||
}else if($dir == 1){
|
||||
}elseif($dir == 1){
|
||||
$v15 = $v15 - 0.5625;
|
||||
$v17 = $v17 + self::offs($width);
|
||||
}else if($dir == 3){
|
||||
}elseif($dir == 3){
|
||||
$v15 = $v15 + 0.5625;
|
||||
$v17 = $v17 - self::offs($width);
|
||||
}else{
|
||||
$v17 = $v17 + 0.5625;
|
||||
$v15 = $v15 + self::offs($width);
|
||||
}
|
||||
|
||||
|
||||
$v23 = $v16 + self::offs($height);
|
||||
$this->setPos($v15, $v23, $v17);
|
||||
$this->boundingBox->minX = ($v15 - $v12) + 0.03125;
|
||||
|
|
@ -129,35 +129,35 @@ class Painting extends Entity{
|
|||
$this->boundingBox->maxY = ($v23 + $v13) - 0.03125;
|
||||
$this->boundingBox->maxZ = ($v17 + $v14) - 0.03125;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(){
|
||||
return [
|
||||
[PAINTING, 0, 1]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function isPickable(){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function survives(){
|
||||
$cubes = $this->level->getCubes($this, $this->boundingBox);
|
||||
if(count($cubes) == 0){
|
||||
|
||||
$size = PaintingItem::$motives[$this->motive] ?? array(1, 1);
|
||||
|
||||
$size = PaintingItem::$motives[$this->motive] ?? [1, 1];
|
||||
$width = $size[0];
|
||||
$width2 = $width*16/32;
|
||||
$width2 = $width * 16 / 32;
|
||||
$height = $size[1];
|
||||
$height2 = $height*16/32;
|
||||
$height2 = $height * 16 / 32;
|
||||
if($width < 1) $width = 1;
|
||||
if($height < 1) $height = 1;
|
||||
$positionX = $this->xPos;
|
||||
$positionZ = $this->zPos;
|
||||
if($this->direction == 2 || $this->direction == 0) $positionX = floor($this->x - $width2);
|
||||
if($this->direction == 1 || $this->direction == 3) $positionZ = floor($this->z - $width2);
|
||||
|
||||
|
||||
$minY = floor($this->y - $height2);
|
||||
|
||||
|
||||
for($off = 0; $off < $width; ++$off){
|
||||
for($yoff = 0; $yoff < $height; ++$yoff){
|
||||
$y = $minY + $yoff;
|
||||
|
|
@ -166,13 +166,13 @@ class Painting extends Entity{
|
|||
}else{
|
||||
$id = $this->level->level->getBlockId($positionX + $off, $y, $this->zPos);
|
||||
}
|
||||
|
||||
|
||||
if(!StaticBlock::getIsSolid($id)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ents = $this->level->getEntitiesInAABBOfType($this->boundingBox, ENTITY_OBJECT);
|
||||
foreach($ents as $e){
|
||||
if($e->eid == $this->eid) continue;
|
||||
|
|
@ -182,13 +182,13 @@ class Painting extends Entity{
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function createSaveData(){
|
||||
$data = parent::createSaveData();
|
||||
|
||||
|
||||
$data["Motive"] = $this->motive;
|
||||
$data["Direction"] = $this->direction;
|
||||
$data["xPos"] = $this->xPos;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue