mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
some tweaks
This commit is contained in:
parent
b94d0f2ba1
commit
3d6c4feb0f
7 changed files with 37 additions and 44 deletions
|
|
@ -219,7 +219,7 @@ abstract class Block extends Position{
|
||||||
|
|
||||||
return MovingObjectPosition::fromBlock($x, $y, $z, $v14, $v13->add($x, $y, $z));
|
return MovingObjectPosition::fromBlock($x, $y, $z, $v14, $v13->add($x, $y, $z));
|
||||||
}
|
}
|
||||||
|
public static function onPlace(Level $level, $x, $y, $z){}
|
||||||
public static function addVelocityToEntity(Level $level, $x, $y, $z, Entity $entity, Vector3 $velocityVector){}
|
public static function addVelocityToEntity(Level $level, $x, $y, $z, Entity $entity, Vector3 $velocityVector){}
|
||||||
public static function onRandomTick(Level $level, $x, $y, $z){}
|
public static function onRandomTick(Level $level, $x, $y, $z){}
|
||||||
public static function onUpdate(Level $level, $x, $y, $z, $type){}
|
public static function onUpdate(Level $level, $x, $y, $z, $type){}
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,17 @@ class LiquidBlock extends TransparentBlock{
|
||||||
$this->hardness = 500;
|
$this->hardness = 500;
|
||||||
}
|
}
|
||||||
public static $blockID = 0;
|
public static $blockID = 0;
|
||||||
|
|
||||||
public static function getDepth(Level $level, $x, $y, $z){
|
public static function getDepth(Level $level, $x, $y, $z){
|
||||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||||
|
|
||||||
if($id == static::$blockID) return $meta;
|
if($id == static::$blockID) return $meta;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function onPlace(Level $level, $x, $y, $z){
|
||||||
|
static::updateLiquid($level, $x, $y, $z);
|
||||||
|
}
|
||||||
|
|
||||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||||
static::updateLiquid($level, $x, $y, $z);
|
static::updateLiquid($level, $x, $y, $z);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
require_once("LiquidBlockDynamic.php"); //TODO class loader?
|
require_once("LiquidBlockDynamic.php"); //TODO class loader?
|
||||||
|
|
||||||
class LavaBlock extends LiquidBlockDynamic implements LightingBlock{
|
class LavaBlock extends LiquidBlockDynamic implements LightingBlock{
|
||||||
|
public static $blockID = LAVA;
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(LAVA, $meta, "Lava");
|
parent::__construct(LAVA, $meta, "Lava");
|
||||||
$this->hardness = 500;
|
$this->hardness = 500;
|
||||||
|
|
|
||||||
|
|
@ -10,24 +10,18 @@ class LiquidBlockDynamic extends LiquidBlock{
|
||||||
public static $spread = [0, 0, 0, 0];
|
public static $spread = [0, 0, 0, 0];
|
||||||
|
|
||||||
public static function getHighest(Level $level, $x, $y, $z, $highest){
|
public static function getHighest(Level $level, $x, $y, $z, $highest){
|
||||||
$depth = self::getDepth($level, $x, $y, $z);
|
$depth = static::getDepth($level, $x, $y, $z);
|
||||||
|
if($depth < 0) return $highest;
|
||||||
|
if($depth == 0) ++static::$f_d8;
|
||||||
|
if($depth >= 8) $depth = 0;
|
||||||
|
|
||||||
if($depth >= 0){
|
return $highest >= 0 && $depth >= $highest ? $highest : $depth;
|
||||||
if($depth > 7) $depth = 0;
|
|
||||||
}else{
|
|
||||||
++self::$f_d8;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($highest < 0) return $depth;
|
|
||||||
else if($highest >= $depth) return $depth;
|
|
||||||
|
|
||||||
return $highest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setStatic(Level $level, $x, $y, $z){
|
public static function setStatic(Level $level, $x, $y, $z){
|
||||||
$meta = $level->level->getBlockDamage($x, $y, $z);
|
$meta = $level->level->getBlockDamage($x, $y, $z);
|
||||||
|
|
||||||
$level->fastSetBlockUpdate($x, $y, $z, self::$blockID + 1, $meta);
|
$level->fastSetBlockUpdate($x, $y, $z, static::$blockID + 1, $meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isWaterBlocking(Level $level, $x, $y, $z){
|
public static function isWaterBlocking(Level $level, $x, $y, $z){
|
||||||
|
|
@ -53,7 +47,6 @@ class LiquidBlockDynamic extends LiquidBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSpread(Level $level, $x, $y, $z){
|
public static function getSpread(Level $level, $x, $y, $z){
|
||||||
//TODO get rid of gotos
|
|
||||||
for($i = 0; $i < 4; ++$i){
|
for($i = 0; $i < 4; ++$i){
|
||||||
static::$spread[$i] = 1000;
|
static::$spread[$i] = 1000;
|
||||||
$xs = $x;
|
$xs = $x;
|
||||||
|
|
@ -78,11 +71,7 @@ class LiquidBlockDynamic extends LiquidBlock{
|
||||||
if(static::isWaterBlocking($level, $xs, $ys, $zs)) continue;
|
if(static::isWaterBlocking($level, $xs, $ys, $zs)) continue;
|
||||||
[$id, $meta] = $level->level->getBlock($xs, $ys, $zs);
|
[$id, $meta] = $level->level->getBlock($xs, $ys, $zs);
|
||||||
|
|
||||||
if(
|
if(((static::$blockID == WATER && ($id == WATER || $id == STILL_WATER)) || (static::$blockID == LAVA && ($id == LAVA || $id == STILL_LAVA))) && $meta == 0){
|
||||||
(((static::$blockID == WATER || static::$blockID == STILL_WATER) && ($id == WATER || $id == STILL_WATER)) ||
|
|
||||||
((static::$blockID == LAVA || static::$blockID == STILL_LAVA) && ($id == LAVA || $id == STILL_LAVA))) &&
|
|
||||||
$meta == 0
|
|
||||||
){
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,18 +136,24 @@ class LiquidBlockDynamic extends LiquidBlock{
|
||||||
$id = $level->level->getBlockID($x, $y, $z);
|
$id = $level->level->getBlockID($x, $y, $z);
|
||||||
|
|
||||||
if($id > 0){
|
if($id > 0){
|
||||||
if(($id == LAVA || $id == STILL_LAVA) && (self::$id == LAVA || self::$id == STILL_LAVA)); //fizz
|
if(($id == LAVA || $id == STILL_LAVA) && (static::$blockID == LAVA || static::$blockID == STILL_LAVA)); //fizz
|
||||||
else{
|
else{
|
||||||
//TODO spawnResources
|
//TODO spawnResources
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$level->fastSetBlockUpdate($x, $y, $z, self::$blockID, $meta, true);
|
$level->fastSetBlockUpdate($x, $y, $z, static::$blockID, $meta, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function onPlace(Level $level, $x, $y, $z){
|
||||||
|
static::updateLiquid($level, $x, $y, $z);
|
||||||
|
$id = $level->level->getBlockID($x, $y, $z);
|
||||||
|
if($id == static::$blockID) ServerAPI::request()->api->block->scheduleBlockUpdateXYZ($level, $x, $y, $z, BLOCK_UPDATE_SCHEDULED, static::getTickDelay());
|
||||||
|
}
|
||||||
|
|
||||||
public static function onUpdate(Level $level, $x, $y, $z, $type){
|
public static function onUpdate(Level $level, $x, $y, $z, $type){
|
||||||
static::$blockID = $id = $level->level->getBlockID($x, $y, $z);
|
$id = $level->level->getBlockID($x, $y, $z);
|
||||||
$depth = static::getDepth($level, $x, $y, $z);
|
$depth = static::getDepth($level, $x, $y, $z);
|
||||||
if($id == LAVA || $id == STILL_LAVA){
|
if($id == LAVA || $id == STILL_LAVA){
|
||||||
$spreadAdder = 2; //XXX nether has 1
|
$spreadAdder = 2; //XXX nether has 1
|
||||||
|
|
@ -169,7 +164,7 @@ class LiquidBlockDynamic extends LiquidBlock{
|
||||||
|
|
||||||
$tickDelay = static::getTickDelay();
|
$tickDelay = static::getTickDelay();
|
||||||
if($depth > 0){
|
if($depth > 0){
|
||||||
self::$f_d8 = 0;
|
static::$f_d8 = 0;
|
||||||
$highest = static::getHighest($level, $x - 1, $y, $z, -100);
|
$highest = static::getHighest($level, $x - 1, $y, $z, -100);
|
||||||
$highest = static::getHighest($level, $x + 1, $y, $z, $highest);
|
$highest = static::getHighest($level, $x + 1, $y, $z, $highest);
|
||||||
|
|
||||||
|
|
@ -187,15 +182,16 @@ class LiquidBlockDynamic extends LiquidBlock{
|
||||||
else $v16 = $dpth + 8;
|
else $v16 = $dpth + 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(static::$f_d8 && (static::$blockID == WATER || static::$blockID == STILL_WATER)){
|
if(static::$f_d8 && (static::$blockID == WATER)){
|
||||||
//XXX Level::isSolidBlockingTile
|
//XXX Level::isSolidBlockingTile
|
||||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
$idb = $level->level->getBlockID($x, $y - 1, $z);
|
||||||
if(StaticBlock::getIsFlowable($id) || ($id == WATER || $id == STILL_WATER) && $meta != 0){
|
$metab = $level->level->getBlockDamage($x, $y, $z);
|
||||||
$v16 = 0;
|
if(StaticBlock::getIsFlowable($idb) || (($idb == WATER || $idb == STILL_WATER) && $metab != 0)){
|
||||||
|
//$v16 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((static::$blockID == LAVA || static::$blockID == STILL_LAVA) && $depth <= 7){
|
if(static::$blockID == LAVA && $depth <= 7){
|
||||||
if($v16 > 7) goto LABEL_32; //TODO remove gotos
|
if($v16 > 7) goto LABEL_32; //TODO remove gotos
|
||||||
|
|
||||||
if($v16 > $depth){
|
if($v16 > $depth){
|
||||||
|
|
@ -209,6 +205,7 @@ class LiquidBlockDynamic extends LiquidBlock{
|
||||||
goto LABEL_35;
|
goto LABEL_35;
|
||||||
}
|
}
|
||||||
LABEL_32:
|
LABEL_32:
|
||||||
|
ConsoleAPI::debug("v16 is $v16");
|
||||||
$level->fastSetBlockUpdateMeta($x, $y, $z, $v16, false);
|
$level->fastSetBlockUpdateMeta($x, $y, $z, $v16, false);
|
||||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($x, $y, $z, $level), $tickDelay); //TODO get rid of new Position
|
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($x, $y, $z, $level), $tickDelay); //TODO get rid of new Position
|
||||||
$level->updateNeighborsAt($x, $y, $z, static::$blockID);
|
$level->updateNeighborsAt($x, $y, $z, static::$blockID);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
require_once("LiquidBlockDynamic.php"); //TODO class loader?
|
require_once("LiquidBlockDynamic.php"); //TODO class loader?
|
||||||
|
|
||||||
class WaterBlock extends LiquidBlockDynamic{
|
class WaterBlock extends LiquidBlockDynamic{
|
||||||
|
|
||||||
|
public static $blockID = WATER;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(WATER, $meta, "Water");
|
parent::__construct(WATER, $meta, "Water");
|
||||||
$this->hardness = 500;
|
$this->hardness = 500;
|
||||||
|
|
|
||||||
|
|
@ -500,13 +500,8 @@ class PMFLevel extends PMF{
|
||||||
++$this->chunkChange[$index][$Y];
|
++$this->chunkChange[$index][$Y];
|
||||||
}
|
}
|
||||||
$this->chunkChange[$index][-1] = true;
|
$this->chunkChange[$index][-1] = true;
|
||||||
if($old_b instanceof LiquidBlock){
|
|
||||||
$pos = new Position($x, $y, $z, $this->level);
|
if($block > 0) StaticBlock::getBlock($block)::onPlace($this->level, $x, $y, $z);
|
||||||
for($side = 0; $side <= 5; ++$side){
|
|
||||||
$b = $pos->getSide($side);
|
|
||||||
ServerAPI::request()->api->block->scheduleBlockUpdate($b, ($b instanceof LavaBlock ? 40: 10), BLOCK_UPDATE_NORMAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -468,24 +468,18 @@ class Level{
|
||||||
|
|
||||||
public function updateNeighborsAt($x, $y, $z, $oldID){
|
public function updateNeighborsAt($x, $y, $z, $oldID){
|
||||||
$block = $this->level->getBlockID($x - 1, $y, $z);
|
$block = $this->level->getBlockID($x - 1, $y, $z);
|
||||||
ConsoleAPI::debug(StaticBlock::getBlock($block));
|
|
||||||
if($block) StaticBlock::getBlock($block)::neighborChanged($this, $x - 1, $y, $z, $x, $y, $z, $oldID);
|
if($block) StaticBlock::getBlock($block)::neighborChanged($this, $x - 1, $y, $z, $x, $y, $z, $oldID);
|
||||||
$block = $this->level->getBlockID($x + 1, $y, $z);
|
$block = $this->level->getBlockID($x + 1, $y, $z);
|
||||||
ConsoleAPI::debug(StaticBlock::getBlock($block));
|
|
||||||
if($block) StaticBlock::getBlock($block)::neighborChanged($this, $x + 1, $y, $z, $x, $y, $z, $oldID);
|
if($block) StaticBlock::getBlock($block)::neighborChanged($this, $x + 1, $y, $z, $x, $y, $z, $oldID);
|
||||||
|
|
||||||
$block = $this->level->getBlockID($x, $y - 1, $z);
|
$block = $this->level->getBlockID($x, $y - 1, $z);
|
||||||
ConsoleAPI::debug(StaticBlock::getBlock($block));
|
|
||||||
if($block) StaticBlock::getBlock($block)::neighborChanged($this, $x, $y - 1, $z, $x, $y, $z, $oldID);
|
if($block) StaticBlock::getBlock($block)::neighborChanged($this, $x, $y - 1, $z, $x, $y, $z, $oldID);
|
||||||
$block = $this->level->getBlockID($x, $y + 1, $z);
|
$block = $this->level->getBlockID($x, $y + 1, $z);
|
||||||
ConsoleAPI::debug(StaticBlock::getBlock($block));
|
|
||||||
if($block) StaticBlock::getBlock($block)::neighborChanged($this, $x, $y + 1, $z, $x, $y, $z, $oldID);
|
if($block) StaticBlock::getBlock($block)::neighborChanged($this, $x, $y + 1, $z, $x, $y, $z, $oldID);
|
||||||
|
|
||||||
$block = $this->level->getBlockID($x, $y, $z - 1);
|
$block = $this->level->getBlockID($x, $y, $z - 1);
|
||||||
ConsoleAPI::debug(StaticBlock::getBlock($block));
|
|
||||||
if($block) StaticBlock::getBlock($block)::neighborChanged($this, $x, $y, $z - 1, $x, $y, $z, $oldID);
|
if($block) StaticBlock::getBlock($block)::neighborChanged($this, $x, $y, $z - 1, $x, $y, $z, $oldID);
|
||||||
$block = $this->level->getBlockID($x, $y, $z + 1);
|
$block = $this->level->getBlockID($x, $y, $z + 1);
|
||||||
ConsoleAPI::debug(StaticBlock::getBlock($block));
|
|
||||||
if($block) StaticBlock::getBlock($block)::neighborChanged($this, $x, $y, $z + 1, $x, $y, $z, $oldID);
|
if($block) StaticBlock::getBlock($block)::neighborChanged($this, $x, $y, $z + 1, $x, $y, $z, $oldID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue