mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 20:19:44 +00:00
Added MonsterRoom Structure
This commit is contained in:
parent
762ff1b3eb
commit
022664c402
5 changed files with 100 additions and 4 deletions
|
|
@ -80,6 +80,7 @@ class NetherReactorBlock extends SolidBlock{
|
|||
}
|
||||
return $pigCount < 3 ? $pigCount < 2 ? 2 : 1 : 0;
|
||||
}
|
||||
|
||||
public function spawnItems($data) {
|
||||
$x = $this->x;
|
||||
$y = $this->y;
|
||||
|
|
@ -116,6 +117,7 @@ class NetherReactorBlock extends SolidBlock{
|
|||
$server->api->entity->spawnToAll($e);
|
||||
}
|
||||
}
|
||||
|
||||
public function glow($part){
|
||||
$x = $this->x;
|
||||
$y = $this->y;
|
||||
|
|
@ -182,6 +184,7 @@ class NetherReactorBlock extends SolidBlock{
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function isCorrect($x, $y, $z){
|
||||
$offsetX = -1;
|
||||
$offsetZ = -1;
|
||||
|
|
|
|||
|
|
@ -18,16 +18,17 @@ class BurningFurnaceBlock extends SolidBlock implements LightingBlock{
|
|||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getMaxLightValue(){
|
||||
return 13;
|
||||
}
|
||||
|
||||
public function onBreak(Item $item, Player $player){
|
||||
$this->level->setBlock($this, new AirBlock(), true, true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
|
||||
$server = ServerAPI::request();
|
||||
$t = $server->api->tile->get($this);
|
||||
$furnace = false;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ class MyceliumBlock extends SolidBlock{
|
|||
return BLOCK_UPDATE_RANDOM;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
//MonsterRoomStructure::buildStructure($this->level, $this->getX(), $this->getY(), $this->getZ());
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(DIRT, 0, 1),
|
||||
|
|
|
|||
88
src/structure/MonsterRoomStructure.php
Normal file
88
src/structure/MonsterRoomStructure.php
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
class MonsterRoomStructure{
|
||||
public static $width = -1;
|
||||
public static $structure = [];
|
||||
|
||||
public static function getWidth(){
|
||||
self::$structure = [-1 => [], 0 => [], 1 => [], 2 => [], 3 => [], 4 => []];
|
||||
return mt_rand(0, 1) === 1 ? self::$width = 7 : self::$width = 9;
|
||||
}
|
||||
|
||||
public static function generateFloor(){
|
||||
for($i = 0; $i < self::$width; $i++){
|
||||
$line = "";
|
||||
for($j = 0; $j < self::$width; $j++){
|
||||
$line .= Utils::chance(75) ? "M" : "C";
|
||||
}
|
||||
array_push(self::$structure[-1], $line);
|
||||
}
|
||||
}
|
||||
|
||||
public static function generateWalls(){
|
||||
for($wallsLevel = 0; $wallsLevel < 5; $wallsLevel++){
|
||||
for($i = 0; $i < self::$width; $i++){
|
||||
$line = "";
|
||||
if($i == 0 or ($i == self::$width - 1)){
|
||||
$line = str_repeat("C", self::$width);
|
||||
}
|
||||
else{
|
||||
$line = self::$width == 7 ? "C C" : "C C";
|
||||
}
|
||||
if($wallsLevel == 0){
|
||||
self::generateChests();
|
||||
}
|
||||
array_push(self::$structure[$wallsLevel], $line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function generateChests(){}
|
||||
|
||||
public static function getSpawnerMob(){
|
||||
$rand = Utils::randomFloat();
|
||||
if($rand <= 0.5) return MOB_ZOMBIE;
|
||||
elseif($rand <= 0.75) return MOB_SKELETON;
|
||||
else return MOB_SPIDER;
|
||||
}
|
||||
|
||||
public static function buildStructure($level, $x, $y, $z){ /*use CENTER positions*/
|
||||
console("building!");
|
||||
self::getWidth();
|
||||
self::generateFloor();
|
||||
self::generateWalls();
|
||||
//console(var_dump(self::$structure));
|
||||
$offsetX = 0;
|
||||
$offsetZ = 0;
|
||||
foreach(self::$structure as $layerCount => $layer){
|
||||
foreach($layer as $line){
|
||||
$line = rtrim($line); //remove useless spaces(only from right)
|
||||
foreach(str_split($line) as $char){
|
||||
switch($char){
|
||||
case "C":
|
||||
$level->setBlockRaw(new Vector3($x - floor(self::$width / 2) + $offsetX, $y + $layerCount, $z - floor(self::$width / 2) + $offsetZ), new CobblestoneBlock());
|
||||
break;
|
||||
case "M":
|
||||
$level->setBlockRaw(new Vector3($x - floor(self::$width / 2) + $offsetX, $y + $layerCount, $z - floor(self::$width / 2) + $offsetZ), new MossStoneBlock());
|
||||
break;
|
||||
case "H":
|
||||
$level->setBlockRaw(new Vector3($x - floor(self::$width / 2) + $offsetX, $y + $layerCount, $z - floor(self::$width / 2) + $offsetZ), new ChestBlock());
|
||||
break;
|
||||
case " ":
|
||||
$block = $level->getBlock(new Vector3($x - floor(self::$width / 2) + $offsetX, $y + $layerCount, $z - floor(self::$width / 2) + $offsetZ))->getID();
|
||||
if($block == 0){
|
||||
break;
|
||||
}
|
||||
$level->setBlockRaw(new Vector3($x - floor(self::$width / 2) + $offsetX, $y + $layerCount, $z - floor(self::$width / 2) + $offsetZ), new AirBlock());
|
||||
break;
|
||||
}
|
||||
++$offsetX;
|
||||
}
|
||||
++$offsetZ;
|
||||
$offsetX = 0;
|
||||
}
|
||||
$offsetZ = 0;
|
||||
}
|
||||
$level->setBlockRaw(new Vector3($x, $y, $z), new MonsterSpawnerBlock(self::getSpawnerMob()));
|
||||
}
|
||||
}
|
||||
|
|
@ -601,14 +601,14 @@ class NetherReactorStructure{
|
|||
foreach(str_split($line) as $char){
|
||||
switch($char){
|
||||
case "N": //Netherrack
|
||||
$level->setBlockRaw(new Vector3($x - 8 + $offsetX, $y - 1 + $layerCount, $z - 8 + $offsetZ), new NetherrackBlock());
|
||||
$level->setBlockRaw(new Vector3($x - 8 + $offsetX, $y + $layerCount, $z - 8 + $offsetZ), new NetherrackBlock());
|
||||
break;
|
||||
case " ":
|
||||
$block = $level->getBlock(new Vector3($x - 8 + $offsetX, $y - 1 + $layerCount, $z - 8 + $offsetZ))->getID();
|
||||
$block = $level->getBlock(new Vector3($x - 8 + $offsetX, $y + $layerCount, $z - 8 + $offsetZ))->getID();
|
||||
if($block == 0){
|
||||
break;
|
||||
}
|
||||
$level->setBlockRaw(new Vector3($x - 8 + $offsetX, $y - 1 + $layerCount, $z - 8 + $offsetZ), new AirBlock());
|
||||
$level->setBlockRaw(new Vector3($x - 8 + $offsetX, $y + $layerCount, $z - 8 + $offsetZ), new AirBlock());
|
||||
break;
|
||||
}
|
||||
++$offsetX;
|
||||
Loading…
Add table
Add a link
Reference in a new issue