mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
Some structure fixes
This commit is contained in:
parent
1a383de853
commit
a07a3ed486
3 changed files with 14 additions and 9 deletions
|
|
@ -15,11 +15,13 @@ class MyceliumBlock extends SolidBlock{
|
|||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){ //uwu
|
||||
/*if(mt_rand(0, 1) === 0){
|
||||
Structures::$SMALLFARM_VILLAGE->rotate90deg($this->level, $this->x, $this->y, $this->z)->build($this->level, $this->x, $this->y, $this->z);
|
||||
/*$oldtime = microtime(1);
|
||||
if(mt_rand(0, 1) === 0){
|
||||
$time = Structures::$SMALLFARM_VILLAGE->rotate90deg($this->level, $this->x, $this->y, $this->z)->build($this->level, $this->x, $this->y, $this->z);
|
||||
}else{
|
||||
Structures::$SMALLFARM_VILLAGE->build($this->level, $this->x, $this->y, $this->z);
|
||||
}*/
|
||||
$time = Structures::$SMALLFARM_VILLAGE->build($this->level, $this->x, $this->y, $this->z);
|
||||
}
|
||||
console("builded in ".($time - $oldtime));*/
|
||||
|
||||
//(new WoodHutStructure())->build($this->level, $this->getX(), $this->getY(), $this->getZ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ abstract class Structure{
|
|||
if($char === "" || (($mk = $this->getMappingFor($char)) === self::MAP_NO_KEY)) return;
|
||||
$id = is_array($mk) ? $mk[0] : $mk;
|
||||
$meta = is_array($mk) ? $mk[1] : 0;
|
||||
return $level->setBlock($vector, BlockAPI::get($id, $meta));
|
||||
return $level->setBlockRaw($vector, BlockAPI::get($id, $meta));
|
||||
}
|
||||
|
||||
protected function init(){}
|
||||
|
|
@ -38,6 +38,7 @@ abstract class Structure{
|
|||
protected function getFinalStructure(Level $level, $x, $y, $z){
|
||||
return $this->structure;
|
||||
}
|
||||
|
||||
public function rotate90deg(Level $level, $x, $y, $z){
|
||||
$str = $this->getFinalStructure($level, $x, $y, $z);
|
||||
foreach($str as &$arr){
|
||||
|
|
@ -52,13 +53,15 @@ abstract class Structure{
|
|||
}
|
||||
return (clone $this)->setStructure($str, $this->length, $this->width);
|
||||
}
|
||||
|
||||
private function setStructure($struct, $width, $length){
|
||||
$this->structure = $struct;
|
||||
$this->width = $width;
|
||||
$this->length = $length;
|
||||
console("Modifed");
|
||||
//console("Modifed");
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function build(Level $level, $centerX, $centerY, $centerZ){
|
||||
$offsetX = $offsetZ = 0;
|
||||
$centWidth = floor($this->width / 2);
|
||||
|
|
@ -76,6 +79,7 @@ abstract class Structure{
|
|||
}
|
||||
$offsetZ = 0;
|
||||
}
|
||||
return microtime(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -36,8 +36,8 @@ class SmallFarmStructure extends Structure{
|
|||
" " => 0,
|
||||
"D" => DIRT
|
||||
];
|
||||
protected function getFinalStructure(Level $level, $x, $y, $z)
|
||||
{
|
||||
|
||||
protected function getFinalStructure(Level $level, $x, $y, $z){
|
||||
if(!$level->getBlockWithoutVector($x, $y - 1, $z)->isSolid){
|
||||
$structCopy = $this->structure;
|
||||
$structCopy[-1] = array_fill(0, $this->length, str_repeat("D", $this->width)); //TODO sand or clay, check for the whole row of water?
|
||||
|
|
@ -46,7 +46,6 @@ class SmallFarmStructure extends Structure{
|
|||
return parent::getFinalStructure($level, $x, $y, $z);
|
||||
}
|
||||
|
||||
|
||||
protected function getMappingFor($char){
|
||||
if($char === "R"){
|
||||
$f = Utils::randomFloat();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue