mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
Minecart is in separated class
This commit is contained in:
parent
5596f58a0a
commit
a75e286337
11 changed files with 515 additions and 32 deletions
58
src/world/MocingObjectPosition.php
Normal file
58
src/world/MocingObjectPosition.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
class MovingObjectPosition{
|
||||
|
||||
/** 0 = block, 1 = entity */
|
||||
public $typeOfHit;
|
||||
|
||||
public $blockX;
|
||||
public $blockY;
|
||||
public $blockZ;
|
||||
|
||||
/**
|
||||
* Which side was hit. If its -1 then it went the full length of the ray trace.
|
||||
* Bottom = 0, Top = 1, East = 2, West = 3, North = 4, South = 5.
|
||||
*/
|
||||
public $sideHit;
|
||||
|
||||
/** @var Vector3 */
|
||||
public $hitVector;
|
||||
|
||||
/** @var Entity */
|
||||
public $entityHit = null;
|
||||
|
||||
protected function __construct(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
* @param int $side
|
||||
* @param Vector3 $hitVector
|
||||
*
|
||||
* @return MovingObjectPosition
|
||||
*/
|
||||
public static function fromBlock($x, $y, $z, $side, Vector3 $hitVector){
|
||||
$ob = new MovingObjectPosition;
|
||||
$ob->typeOfHit = 0;
|
||||
$ob->blockX = $x;
|
||||
$ob->blockY = $y;
|
||||
$ob->blockZ = $z;
|
||||
$ob->hitVector = new Vector3($hitVector->x, $hitVector->y, $hitVector->z);
|
||||
return $ob;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Entity $entity
|
||||
*
|
||||
* @return MovingObjectPosition
|
||||
*/
|
||||
public static function fromEntity(Entity $entity){
|
||||
$ob = new MovingObjectPosition;
|
||||
$ob->typeOfHit = 1;
|
||||
$ob->entityHit = $entity;
|
||||
$ob->hitVector = new Vector3($entity->x, $entity->y, $entity->z);
|
||||
return $ob;
|
||||
}
|
||||
}
|
||||
61
src/world/generator/VoidGenerator.php
Normal file
61
src/world/generator/VoidGenerator.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/***REM_START***/
|
||||
require_once("LevelGenerator.php");
|
||||
/***REM_END***/
|
||||
|
||||
class VoidGenerator implements LevelGenerator{
|
||||
private $level, $random, $structure, $chunks, $options, $floorLevel, $populators = array();
|
||||
|
||||
public function __construct(array $options = array()){
|
||||
$this->options = $options;
|
||||
/*if(isset($this->options["mineshaft"])){
|
||||
$this->populators[] = new MineshaftPopulator(isset($this->options["mineshaft"]["chance"]) ? floatval($this->options["mineshaft"]["chance"]) : 0.01);
|
||||
}*/
|
||||
}
|
||||
|
||||
public function init(Level $level, Random $random){
|
||||
$this->level = $level;
|
||||
$this->random = $random;
|
||||
}
|
||||
|
||||
public function generateChunk($chunkX, $chunkZ){
|
||||
for($Y = 0; $Y < 8; ++$Y){
|
||||
$this->level->setMiniChunk($chunkX, $chunkZ, $Y, $this->chunks[$Y]);
|
||||
}
|
||||
}
|
||||
|
||||
public function populateChunk($chunkX, $chunkZ){
|
||||
foreach($this->populators as $populator){
|
||||
$this->random->setSeed((int) ($chunkX * 0xdead + $chunkZ * 0xbeef) ^ $this->level->getSeed());
|
||||
$populator->populate($this->level, $chunkX, $chunkZ, $this->random);
|
||||
}
|
||||
}
|
||||
|
||||
public function populateLevel(){
|
||||
$this->random->setSeed($this->level->getSeed());
|
||||
}
|
||||
|
||||
public function getSpawn(){
|
||||
return new Vector3(128, $this->floorLevel, 128);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue