mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
commit
845ff19ba1
300 changed files with 3314 additions and 2026 deletions
27
.github/workflows/main.yml
vendored
Normal file
27
.github/workflows/main.yml
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
codestyle:
|
||||
name: Code Style checks
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP and tools
|
||||
uses: shivammathur/setup-php@2.31.1
|
||||
with:
|
||||
php-version: 8.0
|
||||
tools: php-cs-fixer:3.60
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Run PHP-CS-Fixer
|
||||
run: php-cs-fixer fix --dry-run --diff --ansi
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -10,6 +10,9 @@ server.lock
|
|||
*.txt
|
||||
*.properties
|
||||
|
||||
# php-cs-fixer
|
||||
/.php_cs.cache
|
||||
/.php-cs-fixer.cache
|
||||
|
||||
############
|
||||
## Windows
|
||||
|
|
|
|||
36
.php-cs-fixer.php
Normal file
36
.php-cs-fixer.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__ . '/src');
|
||||
|
||||
return (new PhpCsFixer\Config)
|
||||
->setRules([
|
||||
'array_indentation' => true,
|
||||
'array_syntax' => [
|
||||
'syntax' => 'short'
|
||||
],
|
||||
'binary_operator_spaces' => [
|
||||
'default' => 'single_space'
|
||||
],
|
||||
'blank_line_after_namespace' => true,
|
||||
'blank_line_after_opening_tag' => true,
|
||||
'cast_spaces' => [
|
||||
'space' => 'single'
|
||||
],
|
||||
'elseif' => true,
|
||||
'indentation_type' => true,
|
||||
'no_closing_tag' => true,
|
||||
'no_empty_phpdoc' => true,
|
||||
'no_extra_blank_lines' => true,
|
||||
'no_superfluous_phpdoc_tags' => [
|
||||
'allow_mixed' => true,
|
||||
],
|
||||
'no_trailing_whitespace' => true,
|
||||
'no_trailing_whitespace_in_comment' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
'unary_operator_spaces' => true
|
||||
])
|
||||
->setFinder($finder)
|
||||
->setIndent("\t")
|
||||
->setLineEnding("\n")
|
||||
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect());
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
NostalgiaCore is a fork of Legacy PocketMine-MP 1.3.12, which fixes bugs of Legacy PocketMine-MP, and adds new content
|
||||
|
||||
Supported MCPE versions: 0.8.0, 0.8.1 (maybe 0.8.2)
|
||||
Supported MCPE versions: 0.3.0 ~ 0.8.1 (maybe 0.8.2)
|
||||
|
||||
(Special thx to GullCraft Network and DartMiner43)
|
||||
|
||||
|
|
|
|||
|
|
@ -123,8 +123,6 @@ class ChatAPI{
|
|||
/**
|
||||
* @param mixed $owner Can be either Player object or string username. Boolean false for broadcast.
|
||||
* @param string $text
|
||||
* @param $whitelist
|
||||
* @param $blacklist
|
||||
*/
|
||||
public function send($owner, $text, $whitelist = false, $blacklist = false){
|
||||
$message = [
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ class ConsoleAPI{
|
|||
$this->register("defaultgamemode", "<mode>", [$this, "defaultCommands"]);
|
||||
|
||||
$this->server->api->console->alias("tps", "status");
|
||||
|
||||
|
||||
$this->cmdWhitelist("help");
|
||||
$this->cmdWhitelist("status");
|
||||
$this->cmdWhitelist("?");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whitelists a CMD so everyone can issue it - Even non OPs.
|
||||
* @param string $cmd Command to Whitelist
|
||||
|
|
@ -37,7 +37,7 @@ class ConsoleAPI{
|
|||
public function cmdWhitelist($cmd){
|
||||
$this->server->api->ban->cmdWhitelist[strtolower(trim($cmd))] = true;
|
||||
}
|
||||
|
||||
|
||||
public function register($cmd, $help, $callback){
|
||||
if(!is_callable($callback)){
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class LevelAPI{
|
|||
console("[ERROR] Could not load level \"" . $name . "\"");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(PocketMinecraftServer::$KEEP_CHUNKS_LOADED){
|
||||
for($X = 0; $X < 16; ++$X){
|
||||
for($Z = 0; $Z < 16; ++$Z){
|
||||
|
|
@ -49,8 +49,7 @@ class LevelAPI{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$entities = new Config($path . "entities.yml", CONFIG_YAML);
|
||||
if(file_exists($path . "tileEntities.yml")){
|
||||
@rename($path . "tileEntities.yml", $path . "tiles.yml");
|
||||
|
|
@ -62,13 +61,13 @@ class LevelAPI{
|
|||
if(!isset($entity["id"])){
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$entity["x"] = $entity["Pos"][0];
|
||||
$entity["y"] = $entity["Pos"][1];
|
||||
$entity["z"] = $entity["Pos"][2];
|
||||
$entity["yaw"] = $entity["Rotation"][0];
|
||||
$entity["pitch"] = $entity["Rotation"][1];
|
||||
|
||||
|
||||
if($entity["id"] === 64){ //Item Drop
|
||||
$e = $this->server->api->entity->add($this->levels[$name], ENTITY_ITEM, ENTITY_ITEM_TYPE, [
|
||||
"meta" => $entity["Item"]["Damage"],
|
||||
|
|
@ -106,7 +105,7 @@ class LevelAPI{
|
|||
foreach($blockUpdates->getAll() as $bupdate){
|
||||
if($bupdate["type"] !== BLOCK_UPDATE_RANDOM) $this->server->api->block->scheduleBlockUpdate(new Position((int) $bupdate["x"], (int) $bupdate["y"], (int) $bupdate["z"], $this->levels[$name]), (float) $bupdate["delay"], (int) $bupdate["type"]);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -154,20 +154,20 @@ class PluginAPI extends stdClass{
|
|||
continue;
|
||||
}
|
||||
console("[INFO] Loading PHAR plugin \"".FORMAT_GREEN.$pluginInfo["name"].FORMAT_RESET."\" ".FORMAT_AQUA.$pluginInfo["version"].FORMAT_RESET." by ".FORMAT_AQUA.$pluginInfo["author"].FORMAT_RESET);
|
||||
|
||||
|
||||
$aver = CURRENT_API_VERSION;
|
||||
if(!in_array((string) CURRENT_API_VERSION, $pluginInfo["api"])){
|
||||
if(!in_array((string) CURRENT_API_VERSION, $pluginInfo["api"])){
|
||||
if(is_array($pluginInfo)) $s = implode(",",$pluginInfo["api"]);
|
||||
else $s = $pluginInfo["api"];
|
||||
console("[WARNING] API is not the same as Core, might cause bugs({$s} != {$aver})");
|
||||
}
|
||||
|
||||
|
||||
$phr = "phar://$filePath/";
|
||||
include($phr."/src/".$pluginInfo["classLoader"]);
|
||||
$class = $pluginInfo["CLClass"];
|
||||
$loader = new $class();
|
||||
$loader->loadAll($phr);
|
||||
|
||||
|
||||
$pluginName = PharUtils::getNameSpaceClass($pluginInfo["mainFile"]);
|
||||
include($phr."/src/".$pluginInfo["mainFile"]);
|
||||
$plugin = new $pluginName($this->server->api, false);
|
||||
|
|
@ -272,7 +272,7 @@ class PluginAPI extends stdClass{
|
|||
$names[] = $p[1]["name"];
|
||||
$versions[] = $p[1]["version"];
|
||||
}
|
||||
|
||||
|
||||
foreach($this->plugins as $p){
|
||||
if($p[0] instanceof OtherPluginRequirement){
|
||||
foreach($p[0]->getRequiredPlugins() as $required){
|
||||
|
|
@ -316,4 +316,3 @@ class RequiredPluginEntry{ //Use this as object of requirements array
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class ServerAPI{
|
|||
|
||||
private static $serverRequest = false;
|
||||
public $restart = false;
|
||||
|
||||
|
||||
/**
|
||||
* @var QueryAPI
|
||||
*/
|
||||
|
|
@ -59,7 +59,7 @@ class ServerAPI{
|
|||
* @var QueryHandler
|
||||
*/
|
||||
public $query;
|
||||
|
||||
|
||||
private $asyncCalls = [];
|
||||
private $server;
|
||||
private $config;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class TileAPI{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function invalidateAll(Level $level, $x, $y, $z){
|
||||
$x = (int) $x;
|
||||
$y = (int) $y;
|
||||
|
|
@ -31,14 +31,14 @@ class TileAPI{
|
|||
++$invcnt;
|
||||
$tl->close();
|
||||
}
|
||||
|
||||
|
||||
if($invcnt > 1){
|
||||
ConsoleAPI::warn("{$level->getName()}: ($x $y $z) has more than 1 tile entity! Invalidated ID {$t["ID"]} (Total invaliated: $invcnt)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function get(Position $pos){
|
||||
$tile = $this->server->query("SELECT * FROM tiles WHERE level = '" . $pos->level->getName() . "' AND x = {$pos->x} AND y = {$pos->y} AND z = {$pos->z};", true);
|
||||
if($tile !== false and $tile !== true and ($tile = $this->getByID($tile["ID"])) !== false){
|
||||
|
|
|
|||
|
|
@ -175,5 +175,4 @@ class TimeAPI{
|
|||
return $this->set("sunset");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
class Deprecation{
|
||||
|
||||
public static $events = [
|
||||
|
|
|
|||
609
src/Player.php
609
src/Player.php
File diff suppressed because it is too large
Load diff
|
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
|
||||
class TileNavigator
|
||||
{
|
||||
|
||||
|
||||
const OFFSETS = [
|
||||
[0, 0, 1],
|
||||
[0, 0, -1],
|
||||
[1, 0, 0],
|
||||
[-1, 0, 0],
|
||||
];
|
||||
|
||||
|
||||
public static $pathfinderAccessed = 0;
|
||||
public $entity;
|
||||
public $avoidFallDamage = true;
|
||||
|
|
@ -17,13 +18,13 @@ class TileNavigator
|
|||
$this->entity = $entity;
|
||||
$this->tall = $entity->height > 1;
|
||||
}
|
||||
|
||||
|
||||
public function reconstructPath($path, $current){
|
||||
console("path built");
|
||||
$totalPath = [$current];
|
||||
while (isset($path[(string)$current]))
|
||||
while (isset($path[(string) $current]))
|
||||
{
|
||||
$current = $path[(string)$current];
|
||||
$current = $path[(string) $current];
|
||||
$totalPath[] = $current;
|
||||
}
|
||||
//foreach(array_unique($path) as $k => $p) console($k.":".$p);
|
||||
|
|
@ -33,17 +34,17 @@ class TileNavigator
|
|||
}
|
||||
|
||||
public function isLocBlocked(PMFLevel $level, $loc){
|
||||
|
||||
|
||||
$chunkX = $loc >> 20 & 0xf;
|
||||
$chunkZ = $loc >> 12 & 0xf;
|
||||
$chunkY = $loc >> 4 & 0xf;
|
||||
|
||||
|
||||
$index = $chunkZ << 4 | $chunkX;
|
||||
|
||||
|
||||
$blockX = $loc >> 16 & 0xf;
|
||||
$blockZ = $loc >> 8 & 0xf;
|
||||
$blockY = $loc & 0xf;
|
||||
|
||||
|
||||
$id = $level->fastGetBlockID($chunkX, $chunkY, $chunkZ, $blockX, $blockY, $blockZ, $index);
|
||||
$b = StaticBlock::getIsSolid($id);
|
||||
if($this->tall){
|
||||
|
|
@ -53,33 +54,32 @@ class TileNavigator
|
|||
$id = $level->fastGetBlockID($chunkX, $chunkY, $chunkZ, $blockX, $blockY, $blockZ, $index);
|
||||
return $b || StaticBlock::getIsSolid($id);
|
||||
}
|
||||
|
||||
|
||||
return $b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function navigate(Level $level, $fromX, $fromY, $fromZ, $toX, $toY, $toZ, $maxDist)
|
||||
{
|
||||
$from = $fromX << 16 | $fromZ << 8 | $fromY;
|
||||
$to = $toX << 16 | $toZ << 8 | $toY;
|
||||
|
||||
|
||||
$pmfLevel = $level->level;
|
||||
|
||||
|
||||
$open = new SplPriorityQueue();
|
||||
//$open->insert(, 0);
|
||||
$open->insert($from, 0);
|
||||
$path = [];
|
||||
$gScore = [];
|
||||
$gScore[(string) $from] = 0;
|
||||
$has = [(string)$from, true];
|
||||
$has = [(string) $from, true];
|
||||
if($this->isLocBlocked($pmfLevel, $to)){
|
||||
return null;
|
||||
}
|
||||
$visited = [];
|
||||
$maxDist*=$maxDist; //no square root
|
||||
$maxDist *= $maxDist; //no square root
|
||||
$closestToTarget = null;
|
||||
$closestToTargetDist = INF;
|
||||
|
||||
|
||||
while(!$open->isEmpty())
|
||||
{
|
||||
$current = $open->top();
|
||||
|
|
@ -90,7 +90,7 @@ class TileNavigator
|
|||
if ($current == $to){
|
||||
return $this->reconstructPath($path, $current);
|
||||
}
|
||||
|
||||
|
||||
$points = [];
|
||||
foreach(self::OFFSETS as $offset){
|
||||
$newX = $offset[0] + $currentX;
|
||||
|
|
@ -98,7 +98,7 @@ class TileNavigator
|
|||
$newZ = $offset[2] + $currentZ;
|
||||
if($newX < 0 || $newX > 255 || $newY < 0 || $newY > 255 || $newZ < 0 || $newZ > 255) continue;
|
||||
$new = $newX << 16 | $newZ << 8 | $newY;
|
||||
|
||||
|
||||
if(!$this->isLocBlocked($pmfLevel, $new)){
|
||||
if($newY > 0 && !$this->isLocBlocked($pmfLevel, $new - 1)){
|
||||
if(!$this->avoidFallDamage){
|
||||
|
|
@ -108,60 +108,59 @@ class TileNavigator
|
|||
if($this->isLocBlocked($pmfLevel, $new - 2)){
|
||||
$new -= 1;
|
||||
$newY -= 1;
|
||||
}else if($this->isLocBlocked($pmfLevel, $new - 3)){
|
||||
}elseif($this->isLocBlocked($pmfLevel, $new - 3)){
|
||||
$new -= 2;
|
||||
$newY -= 2;
|
||||
}else if($this->isLocBlocked($pmfLevel, $new - 4)){
|
||||
}elseif($this->isLocBlocked($pmfLevel, $new - 4)){
|
||||
$new -= 3;
|
||||
$newY -= 3;
|
||||
}else{
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
$dist = ($fromX - $newX)*($fromX - $newX) + ($fromY - $newY)*($fromY - $newY) + ($fromZ - $newZ)*($fromZ - $newZ);
|
||||
$dist = ($fromX - $newX) * ($fromX - $newX) + ($fromY - $newY) * ($fromY - $newY) + ($fromZ - $newZ) * ($fromZ - $newZ);
|
||||
if($dist < -$maxDist || $dist > $maxDist){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$points[] = $new;
|
||||
}else if(!$this->isLocBlocked($pmfLevel, $current+1) && !$this->isLocBlocked($pmfLevel, $new+1)){
|
||||
}elseif(!$this->isLocBlocked($pmfLevel, $current + 1) && !$this->isLocBlocked($pmfLevel, $new + 1)){
|
||||
$new += 1;
|
||||
$newY += 1;
|
||||
|
||||
$dist = ($fromX - $newX)*($fromX - $newX) + ($fromY - $newY)*($fromY - $newY) + ($fromZ - $newZ)*($fromZ - $newZ);
|
||||
|
||||
$dist = ($fromX - $newX) * ($fromX - $newX) + ($fromY - $newY) * ($fromY - $newY) + ($fromZ - $newZ) * ($fromZ - $newZ);
|
||||
if($dist < -$maxDist || $dist > $maxDist){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$points[] = $new;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach($points as $neighbor)
|
||||
{
|
||||
if(isset($visited[$neighbor])){
|
||||
continue;
|
||||
}
|
||||
$visited[$neighbor] = true;
|
||||
|
||||
|
||||
$diffX = ($toX - ($neighbor >> 16 & 0xff));
|
||||
$diffY = ($toY - ($neighbor & 0xff));
|
||||
$diffZ = ($toZ - ($neighbor >> 8 & 0xff));
|
||||
$targetDist = $diffX*$diffX + $diffY*$diffY + $diffZ*$diffZ;
|
||||
|
||||
|
||||
$targetDist = $diffX * $diffX + $diffY * $diffY + $diffZ * $diffZ;
|
||||
|
||||
$diffX = ($currentX - ($neighbor >> 16 & 0xff));
|
||||
$diffY = ($currentY - ($neighbor & 0xff));
|
||||
$diffZ = ($currentZ - ($neighbor >> 8 & 0xff));
|
||||
|
||||
$distbetweenCost = $diffX*$diffX + $diffY*$diffY + $diffZ*$diffZ;
|
||||
|
||||
$distbetweenCost = $diffX * $diffX + $diffY * $diffY + $diffZ * $diffZ;
|
||||
$tentativeG = $gScore[$current] + $distbetweenCost;
|
||||
if (!isset($has[$neighbor]))
|
||||
{
|
||||
{
|
||||
//if(isset($open[-$tentativeG])) console("overwriting $tentativeG");
|
||||
//$open[-$tentativeG] = $neighbor;
|
||||
|
||||
|
||||
$open->insert($neighbor, -$tentativeG);
|
||||
$has[$neighbor] = true;
|
||||
}
|
||||
|
|
@ -171,26 +170,25 @@ class TileNavigator
|
|||
}
|
||||
if(!isset($gScore[$neighbor]) || $distbetweenCost < $gScore[$neighbor]){
|
||||
$path[$neighbor] = $current;
|
||||
|
||||
|
||||
if($targetDist < $closestToTargetDist){
|
||||
//console("found new best to target: $neighbor($closestToTargetDist -> $targetDist)");
|
||||
|
||||
|
||||
$closestToTarget = $neighbor;
|
||||
$closestToTargetDist = $targetDist;
|
||||
$closestToTargetDist = $targetDist;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$gScore[$neighbor] = $tentativeG;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($closestToTarget != null){
|
||||
return $this->reconstructPath($path, $closestToTarget);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ define("SOUL_SAND", 88); //doesnt exist
|
|||
define("GLOWSTONE", 89);
|
||||
define("GLOWSTONE_BLOCK", 89);
|
||||
|
||||
|
||||
define("LIT_PUMPKIN", 91);
|
||||
define("JACK_O_LANTERN", 91);
|
||||
define("CAKE_BLOCK", 92);
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ define("ENTITY_OBJECT", 3);
|
|||
|
||||
define("ENTITY_ITEM", 4);
|
||||
define("ENTITY_ITEM_TYPE", 64);
|
||||
|
||||
|
||||
define("ENTITY_FALLING", 5);
|
||||
define("FALLING_SAND", 66);
|
||||
|
||||
|
||||
//TileEntities
|
||||
define("TILE_SIGN", "Sign");
|
||||
define("TILE_CHEST", "Chest");
|
||||
|
|
@ -44,7 +44,7 @@ const CORRECT_ENTITY_CLASSES = [
|
|||
MOB_COW => true,
|
||||
MOB_PIG => true,
|
||||
MOB_SHEEP => true,
|
||||
|
||||
|
||||
MOB_ZOMBIE => true,
|
||||
MOB_SKELETON => true,
|
||||
MOB_SPIDER => true,
|
||||
|
|
@ -64,5 +64,5 @@ const CORRECT_ENTITY_CLASSES = [
|
|||
ENTITY_FALLING => [
|
||||
FALLING_SAND => true
|
||||
]
|
||||
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -98,7 +98,6 @@ require_once(FILE_PATH . "/src/pmf/PMF.php");
|
|||
|
||||
require_once(FILE_PATH . "/src/astarnavigator/TileNavigator.php");
|
||||
|
||||
|
||||
require_once(FILE_PATH . "/src/entity/ai/tasks/TaskBase.php");
|
||||
|
||||
require_once(FILE_PATH . "/src/entity/Rideable.php");
|
||||
|
|
@ -133,8 +132,6 @@ require_once(FILE_PATH . "/src/world/generator/vanilla/feature/Feature.php");
|
|||
|
||||
require_all(FILE_PATH . "src/");
|
||||
|
||||
|
||||
|
||||
$inc = get_included_files();
|
||||
$inc[] = array_shift($inc);
|
||||
$srcdir = realpath(FILE_PATH . "src/");
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
<?php
|
||||
|
||||
abstract class Living extends Entity implements Pathfindable{
|
||||
|
||||
|
||||
public static $despawnMobs, $despawnTimer, $entityPushing = false;
|
||||
|
||||
|
||||
public static $pathfinderTest = false;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @var Entity $target
|
||||
* @var EntityAI $ai
|
||||
|
|
@ -14,14 +13,14 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
public $target, $ai;
|
||||
public $pathFinder, $path = null, $currentIndex = 0, $currentNode, $pathFollower;
|
||||
public $ticksExisted = 0;
|
||||
|
||||
|
||||
public $landMovementFactor = 0.1;
|
||||
public $jumpMovementFactor = 0.02;
|
||||
public $aiMoveSpeed;
|
||||
|
||||
|
||||
public $renderYawOffset = 0.0; //used by head rotation, TODO better name
|
||||
public $jumping, $jumpTicks;
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
$this->target = false;
|
||||
$this->ai = new EntityAI($this);
|
||||
$this->pathFinder = new TileNavigator($this);
|
||||
|
|
@ -30,43 +29,43 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
$this->canBeAttacked = true;
|
||||
$this->hasGravity = true;
|
||||
$this->hasKnockback = true;
|
||||
|
||||
|
||||
//if(self::$despawnMobs) $this->server->schedule(self::$despawnTimer, [$this, "close"]); //900*20
|
||||
}
|
||||
|
||||
|
||||
public function isPickable(){
|
||||
return !$this->dead;
|
||||
}
|
||||
|
||||
|
||||
public function fall(){
|
||||
$dmg = ceil($this->fallDistance - 3);
|
||||
if($dmg > 0){
|
||||
$this->harm($dmg, "fall");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function handlePlayerSearcher(Player $player, $dist){
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getAIMoveSpeed(){
|
||||
return $this->aiMoveSpeed;
|
||||
}
|
||||
|
||||
|
||||
public function getVerticalFaceSpeed(){
|
||||
return 40; //unused in 0.8 but may be useful in 0.9/0.10
|
||||
}
|
||||
|
||||
|
||||
public function setAIMoveSpeed($speed){
|
||||
$this->aiMoveSpeed = $speed;
|
||||
$this->moveForward = $speed;
|
||||
}
|
||||
|
||||
|
||||
public function hasPath(){
|
||||
return $this->path != null;
|
||||
}
|
||||
public function eatGrass(){}
|
||||
|
||||
|
||||
public function close(){
|
||||
parent::close();
|
||||
unset($this->pathFollower->entity);
|
||||
|
|
@ -76,22 +75,22 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
unset($this->parent);
|
||||
unset($this->pathFinder->entity);
|
||||
}
|
||||
|
||||
|
||||
public function canBeShot(){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function isPushable(){
|
||||
return !$this->dead;
|
||||
}
|
||||
|
||||
|
||||
public function collideHandler(){
|
||||
$bb = $this->boundingBox->expand(0.2, 0, 0.2);
|
||||
$minChunkX = ((int)($bb->minX)) >> 4;
|
||||
$minChunkZ = ((int)($bb->minZ)) >> 4;
|
||||
$maxChunkX = ((int)($bb->minX)) >> 4;
|
||||
$maxChunkZ = ((int)($bb->minZ)) >> 4;
|
||||
|
||||
$minChunkX = ((int) ($bb->minX)) >> 4;
|
||||
$minChunkZ = ((int) ($bb->minZ)) >> 4;
|
||||
$maxChunkX = ((int) ($bb->minX)) >> 4;
|
||||
$maxChunkZ = ((int) ($bb->minZ)) >> 4;
|
||||
|
||||
//TODO also index by chunkY?
|
||||
for($chunkX = $minChunkX; $chunkX <= $maxChunkX; ++$chunkX){
|
||||
for($chunkZ = $minChunkZ; $chunkZ <= $maxChunkZ; ++$chunkZ){
|
||||
|
|
@ -106,14 +105,14 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function update($now){
|
||||
if(self::$despawnMobs && ++$this->ticksExisted > self::$despawnTimer){
|
||||
$this->close();
|
||||
return;
|
||||
}
|
||||
if($this->closed) return;
|
||||
|
||||
|
||||
$check = $this->level->mobSpawner->checkDespawn($this);
|
||||
if($check){
|
||||
$this->close();
|
||||
|
|
@ -121,7 +120,7 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
}
|
||||
parent::update($now);
|
||||
}
|
||||
|
||||
|
||||
public $pathEIDS = [];
|
||||
private static $lastPathEID = 10000000;
|
||||
public static $pathfind = true;
|
||||
|
|
@ -139,22 +138,21 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
}
|
||||
if(self::$pathfind){
|
||||
$this->path = $this->pathFinder->navigate(
|
||||
$this->level,
|
||||
(int)$this->x, (int)$this->y, (int)$this->z,
|
||||
//(int)$pl->entity->x, (int)$pl->entity->y, (int)$pl->entity->z,
|
||||
(int)$this->x + mt_rand(-16, 16), (int)$this->y, (int)$this->z + mt_rand(-16, 16),
|
||||
$this->level,
|
||||
(int) $this->x, (int) $this->y, (int) $this->z,
|
||||
//(int)$pl->entity->x, (int)$pl->entity->y, (int)$pl->entity->z,
|
||||
(int) $this->x + mt_rand(-16, 16), (int) $this->y, (int) $this->z + mt_rand(-16, 16),
|
||||
16
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*if($this->path){
|
||||
console("Found path of length ".count($this->path));
|
||||
|
||||
|
||||
foreach($this->path as $node){
|
||||
$eid = self::$lastPathEID++;
|
||||
$this->pathEIDS[] = $eid;
|
||||
|
||||
|
||||
$pk = new AddItemEntityPacket();
|
||||
$pk->eid = $eid;
|
||||
$pk->item = BlockAPI::getItem(GOLD_BLOCK, 0, 1);
|
||||
|
|
@ -171,8 +169,7 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
}
|
||||
$this->pathFollower->followPath();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//not exactly here
|
||||
if($this->jumping){
|
||||
if(!$this->inWater && !$this->inLava){
|
||||
|
|
@ -186,12 +183,11 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
}else{
|
||||
$this->jumpTicks = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->ai->mobController->movementTick();
|
||||
$this->ai->mobController->rotateTick();
|
||||
$this->ai->mobController->jumpTick();
|
||||
|
||||
|
||||
if(abs($this->speedX) < self::MIN_POSSIBLE_SPEED) $this->speedX = 0;
|
||||
if(abs($this->speedZ) < self::MIN_POSSIBLE_SPEED) $this->speedZ = 0;
|
||||
if(abs($this->speedY) < self::MIN_POSSIBLE_SPEED) $this->speedY = 0;
|
||||
|
|
@ -203,24 +199,23 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
$this->landMovementFactor = $savedLandFactor;
|
||||
//Yaw rotation in 1.5 is handled in a bit different place but hopefully this will work too
|
||||
$this->ai->mobController->updateHeadYaw();
|
||||
|
||||
|
||||
if(self::$entityPushing){
|
||||
$this->collideHandler();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function jump(){
|
||||
$this->speedY = 0.42;
|
||||
|
||||
|
||||
//TODO also set AirBorne?
|
||||
}
|
||||
|
||||
|
||||
public function counterUpdate(){
|
||||
parent::counterUpdate();
|
||||
if($this->jumpTicks > 0) --$this->jumpTicks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function moveEntityWithHeading($strafe, $forward){
|
||||
if($this->inWater){ //also check is player, and can it fly or not
|
||||
$prevPosY = $this->y;
|
||||
|
|
@ -230,8 +225,7 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
$this->speedY *= 0.8;
|
||||
$this->speedZ *= 0.8;
|
||||
$this->speedY -= 0.02;
|
||||
|
||||
|
||||
|
||||
if($this->isCollidedHorizontally && $this->isFree($this->speedX, $this->speedY + 0.6 - $this->y + $prevPosY, $this->speedZ)){
|
||||
$this->speedY = 0.3;
|
||||
}
|
||||
|
|
@ -243,69 +237,69 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
$this->speedY *= 0.5;
|
||||
$this->speedZ *= 0.5;
|
||||
$this->speedY -= 0.02;
|
||||
|
||||
|
||||
if($this->isCollidedHorizontally && $this->isFree($this->speedX, $this->speedY + 0.6 - $this->y + $prevPosY, $this->speedZ)){
|
||||
$this->speedY = 0.3;
|
||||
}
|
||||
}else{
|
||||
$friction = 0.91;
|
||||
|
||||
|
||||
if($this->onGround){
|
||||
$friction = 0.546;
|
||||
$blockAt = $this->level->level->getBlockID(floor($this->x), floor($this->boundingBox->minY) - 1, floor($this->z));
|
||||
|
||||
|
||||
if($blockAt > 0) $friction = StaticBlock::getSlipperiness($blockAt) * 0.91;
|
||||
}
|
||||
|
||||
$var8 = 0.16277 / ($friction*$friction*$friction);
|
||||
|
||||
|
||||
$var8 = 0.16277 / ($friction * $friction * $friction);
|
||||
|
||||
if($this->onGround){
|
||||
$var5 = $this->getAIMoveSpeed(); //in vanilla it returns either this.seed or calls getBaseSpeed(depending on useNewAi)
|
||||
$var5 *= $var8; //in vanilla it also multiplies by speedModifer
|
||||
}else{
|
||||
$var5 = $this->jumpMovementFactor;
|
||||
}
|
||||
|
||||
|
||||
$this->moveFlying($strafe, $forward, $var5);
|
||||
//recalculating friction, might be not neccessary
|
||||
$friction = 0.91;
|
||||
|
||||
|
||||
if($this->onGround){
|
||||
$friction = 0.546;
|
||||
$blockAt = $this->level->level->getBlockID(floor($this->x), floor($this->boundingBox->minY) - 1, floor($this->z));
|
||||
|
||||
|
||||
if($blockAt > 0) $friction = StaticBlock::getSlipperiness($blockAt) * 0.91;
|
||||
}
|
||||
|
||||
|
||||
if($this->isOnLadder()){
|
||||
$speedY = $this->speedY;
|
||||
$this->fallDistance = 0;
|
||||
if($speedY < -0.15) $this->speedY = -0.15;
|
||||
}
|
||||
|
||||
|
||||
$this->move($this->speedX, $this->speedY, $this->speedZ);
|
||||
|
||||
|
||||
if($this->isOnLadder() && $this->isCollidedHorizontally){
|
||||
$this->speedY = 0.2;
|
||||
}
|
||||
|
||||
|
||||
$this->speedY -= 0.08; //gravity
|
||||
|
||||
|
||||
$this->speedY *= 0.98;
|
||||
$this->speedX *= $friction;
|
||||
$this->speedZ *= $friction;
|
||||
|
||||
|
||||
if($this->isCollidedHorizontally && $this->enableAutojump){
|
||||
$this->ai->mobController->setJumping(true); //non vanilla
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function sendMoveUpdate(){
|
||||
if($this->counter % 3 != 0){
|
||||
return;
|
||||
}
|
||||
parent::sendMoveUpdate();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
<?php
|
||||
|
||||
class Monster extends Creature{
|
||||
|
||||
|
||||
public $closestPlayerToAttackEID = false;
|
||||
public $closestPlayerToAttackDist = INF;
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
}
|
||||
|
||||
|
||||
public function getAttackDamage(){
|
||||
return 2;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @see Entity::attackEntity()
|
||||
*/
|
||||
public function attackEntity($entity, $distance){
|
||||
|
|
@ -22,11 +23,11 @@ class Monster extends Creature{
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function isPlayerValid(Player $player){
|
||||
return $player->spawned && !$player->entity->dead;
|
||||
}
|
||||
|
||||
|
||||
public function handlePrePlayerSearcher(){
|
||||
parent::handlePrePlayerSearcher();
|
||||
if($this->closestPlayerToAttackEID !== false){
|
||||
|
|
@ -35,15 +36,15 @@ class Monster extends Creature{
|
|||
$this->closestPlayerToAttackEID = false;
|
||||
$this->closestPlayerToAttackDist = INF;
|
||||
}else{
|
||||
$dist = ($this->x - $player->x)*($this->x - $player->x) + ($this->y - $player->y)*($this->y - $player->y) + ($this->z - $player->z)*($this->z - $player->z);
|
||||
$dist = ($this->x - $player->x) * ($this->x - $player->x) + ($this->y - $player->y) * ($this->y - $player->y) + ($this->z - $player->z) * ($this->z - $player->z);
|
||||
$this->closestPlayerToAttackDist = $dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function handlePlayerSearcher(Player $player, $dist){
|
||||
parent::handlePlayerSearcher($player, $dist);
|
||||
|
||||
|
||||
if($this->closestPlayerToAttackDist >= $dist){
|
||||
if($this->isPlayerValid($player)){
|
||||
$this->closestPlayerToAttackDist = $dist;
|
||||
|
|
@ -51,5 +52,5 @@ class Monster extends Creature{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
abstract class Projectile extends Entity{
|
||||
const CLASS_TYPE = ENTITY_OBJECT;
|
||||
public $shooterEID;
|
||||
|
|
@ -7,13 +8,13 @@ abstract class Projectile extends Entity{
|
|||
public $ticksInAir = 0, $ticksInGround = 0;
|
||||
public $xTile = 0, $yTile = 0, $zTile = 0;
|
||||
public $inTile = false;
|
||||
|
||||
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = [])
|
||||
{
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->gravity = 0.03;
|
||||
$this->setSize(0.25, 0.25);
|
||||
|
||||
|
||||
$this->x -= cos($this->yaw / 180 * M_PI) * 0.16;
|
||||
$this->y -= 0.1;
|
||||
$this->z -= cos($this->yaw / 180 * M_PI) * 0.16;
|
||||
|
|
@ -25,7 +26,7 @@ abstract class Projectile extends Entity{
|
|||
$this->xTile = $data["xTile"] ?? $this->xTile;
|
||||
$this->yTile = $data["yTile"] ?? $this->yTile;
|
||||
$this->zTile = $data["zTile"] ?? $this->zTile;
|
||||
|
||||
|
||||
if($shooter instanceof Entity){
|
||||
$this->shooterEID = $shooter->eid;
|
||||
if($shooter->isPlayer()){
|
||||
|
|
@ -44,9 +45,9 @@ abstract class Projectile extends Entity{
|
|||
$this->shoot(, , , $throwPower, 1.0);*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function shoot($d, $d1, $d2, $f, $f1){ //unchecked, may be not same as arrow
|
||||
$f2 = sqrt($d * $d + $d1 * $d1 + $d2 * $d2);
|
||||
$d /= $f2;
|
||||
|
|
@ -66,7 +67,7 @@ abstract class Projectile extends Entity{
|
|||
$this->pitch = (atan2($d1, $f3) * 180) / M_PI;
|
||||
$this->updatePosition();
|
||||
}
|
||||
|
||||
|
||||
public function update($now){
|
||||
$this->lastX = $this->x;
|
||||
$this->lastY = $this->y;
|
||||
|
|
@ -88,32 +89,32 @@ abstract class Projectile extends Entity{
|
|||
$this->fire -= 4;
|
||||
if($this->fire <= 0) $this->fire = 0;
|
||||
}
|
||||
|
||||
|
||||
if($this->fire <= 0){
|
||||
$this->updateMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($this->handleLavaMovement()){
|
||||
if(!$this->isImmuneToFire){
|
||||
$this->harm(4, "fire");
|
||||
$oldOnFire = $this->fire;
|
||||
if($oldOnFire < 20*30) $this->fire = 20*30; //30 seconds
|
||||
if($oldOnFire < 20 * 30) $this->fire = 20 * 30; //30 seconds
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($this->isInVoid()){
|
||||
$this->outOfWorld();
|
||||
}
|
||||
//Entity::update end
|
||||
|
||||
|
||||
if($this->shake > 0) --$this->shake;
|
||||
|
||||
|
||||
if(!$this->inGround){
|
||||
++$this->ticksInAir;
|
||||
goto CHECK_COLLISIONS; //TODO dont use gotos
|
||||
}
|
||||
|
||||
|
||||
$blockID = $this->level->level->getBlockID($this->xTile, $this->yTile, $this->zTile);
|
||||
if($this->inTile != $blockID){
|
||||
$this->speedX += (lcg_value() * 0.2);
|
||||
|
|
@ -122,7 +123,7 @@ abstract class Projectile extends Entity{
|
|||
$this->inGround = false;
|
||||
$this->ticksInAir = $this->ticksInGround = 0;
|
||||
CHECK_COLLISIONS:
|
||||
|
||||
|
||||
$start = new Vector3($this->x, $this->y, $this->z);
|
||||
$end = new Vector3($this->x + $this->speedX, $this->y + $this->speedY, $this->z + $this->speedZ);
|
||||
/**
|
||||
|
|
@ -135,44 +136,44 @@ abstract class Projectile extends Entity{
|
|||
}else{
|
||||
$end = new Vector3($this->x + $this->speedX, $this->y + $this->speedY, $this->z + $this->speedZ);
|
||||
}
|
||||
|
||||
|
||||
$entities = $this->level->getEntitiesInAABB($this->boundingBox->addCoord($this->speedX, $this->speedY, $this->speedZ)->expand(1, 1, 1));
|
||||
$bestDist = 0;
|
||||
$bestEnt = null;
|
||||
|
||||
|
||||
foreach($entities as $eid => $ent){
|
||||
if($eid != $this->eid && $ent->isPickable() && ($eid != $this->shooterEID || $this->ticksInAir >= 5)){
|
||||
|
||||
|
||||
$v12 = $ent->boundingBox->expand(0.3, 0.3, 0.3);
|
||||
$v13 = $v12->calculateIntercept($start, $end);
|
||||
|
||||
|
||||
if($v13 != null){
|
||||
$dist = $start->distance($v13->hitVector);
|
||||
|
||||
|
||||
if($dist < $bestDist || $bestDist == 0){
|
||||
$bestEnt = $ent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($bestEnt != null){
|
||||
$v4 = MovingObjectPosition::fromEntity($bestEnt);
|
||||
}
|
||||
|
||||
|
||||
if($v4 != null){
|
||||
$this->onHit($v4);
|
||||
}
|
||||
$this->x += $this->speedX;
|
||||
$this->y += $this->speedY;
|
||||
$this->z += $this->speedZ;
|
||||
$v21 = sqrt($this->speedX*$this->speedX + $this->speedZ*$this->speedZ);
|
||||
$v21 = sqrt($this->speedX * $this->speedX + $this->speedZ * $this->speedZ);
|
||||
$this->yaw = atan2($this->speedX, $this->speedZ) * 180 / M_PI;
|
||||
$this->pitch = atan2($this->speedY, $v21) * 180 / M_PI;
|
||||
|
||||
|
||||
$this->pitch = $this->lastPitch + ($this->pitch - $this->lastPitch) * 0.2;
|
||||
$this->yaw = $this->lastYaw + ($this->yaw - $this->lastYaw) * 0.2;
|
||||
|
||||
|
||||
$v24 = $this->inWater ? 0.8 : 0.99;
|
||||
$this->speedX *= $v24;
|
||||
$this->speedY *= $v24;
|
||||
|
|
@ -183,19 +184,19 @@ abstract class Projectile extends Entity{
|
|||
$this->boundingBox->setBounds($this->x - $v7, $this->y - $this->yOffset /*+ $this->ySize*/, $this->z - $v7, $this->x + $v7, $this->y - $this->yOffset + $v8 /*+ $this->ySize*/, $this->z + $v7);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function onHit(MovingObjectPosition $hitResult){
|
||||
|
||||
|
||||
}
|
||||
public function createSaveData(){
|
||||
$data = parent::createSaveData();
|
||||
|
||||
|
||||
$data["inTile"] = $this->inTile;
|
||||
$data["inGround"] = $this->inGround;
|
||||
$data["xTile"] = $this->xTile;
|
||||
$data["yTile"] = $this->yTile;
|
||||
$data["zTile"] = $this->zTile;
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
@ -219,5 +220,5 @@ abstract class Projectile extends Entity{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -10,29 +10,27 @@ class EntityAI
|
|||
* @var Living
|
||||
*/
|
||||
public $entity;
|
||||
|
||||
|
||||
/**
|
||||
* @var TaskBase[]
|
||||
*/
|
||||
protected $tasks;
|
||||
|
||||
|
||||
public $lastTask;
|
||||
|
||||
|
||||
public function __construct($entity){
|
||||
$this->entity = $entity;
|
||||
$this->tasks = [];
|
||||
$this->mobController = new MobController($entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function canSee(Entity $entity){
|
||||
//TODO caches
|
||||
return $this->entity->canSee($entity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a task for entity
|
||||
* @param TaskBase $task
|
||||
*/
|
||||
public function addTask(TaskBase $task){
|
||||
$this->tasks[$task->__toString()] = $task;
|
||||
|
|
@ -44,16 +42,16 @@ class EntityAI
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param mixed $id classname
|
||||
* @return TaskBase | false
|
||||
*/
|
||||
public function getTask($id){
|
||||
return $this->tasks[$id] ?? false;
|
||||
}
|
||||
|
||||
|
||||
public function isStarted($id){
|
||||
$task = $this->getTask($id);
|
||||
return $task instanceof TaskBase && $task->isStarted;
|
||||
|
|
@ -75,10 +73,10 @@ class EntityAI
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function __destruct(){
|
||||
unset($this->entity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,24 +13,24 @@ class MobController
|
|||
* @var Living
|
||||
*/
|
||||
public $entity;
|
||||
|
||||
|
||||
public $finalYaw, $finalPitch, $finalHeadYaw;
|
||||
|
||||
|
||||
public $headYaw;
|
||||
public $someTicker = 0;
|
||||
|
||||
|
||||
protected $jumping;
|
||||
|
||||
|
||||
public $moveToX, $moveToY, $moveToZ;
|
||||
public $speedMultiplier;
|
||||
public $updateMove = false;
|
||||
|
||||
|
||||
public $lookX, $lookY, $lookZ;
|
||||
public $deltaLookYaw, $deltaLookPitch;
|
||||
public $isLooking = false;
|
||||
|
||||
|
||||
public $headYawIsYaw = false;
|
||||
|
||||
|
||||
public function __construct($e){
|
||||
$this->entity = $e;
|
||||
}
|
||||
|
|
@ -40,11 +40,11 @@ class MobController
|
|||
public function isJumping(){
|
||||
return $this->jumping;
|
||||
}
|
||||
|
||||
|
||||
public function setJumping($b){
|
||||
$this->jumping = $b;
|
||||
}
|
||||
|
||||
|
||||
public function isRotationCompleted(){
|
||||
return $this->finalHeadYaw === $this->entity->headYaw;
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ class MobController
|
|||
$this->speedMultiplier = $speed;
|
||||
$this->updateMove = true;
|
||||
}
|
||||
|
||||
|
||||
public function setMovingOffset($x, $y, $z, $speed){
|
||||
$this->moveToX = $this->entity->x + ($x);
|
||||
$this->moveToY = $this->entity->y + ($y);
|
||||
|
|
@ -63,45 +63,45 @@ class MobController
|
|||
$this->speedMultiplier = $speed;
|
||||
$this->updateMove = true;
|
||||
}
|
||||
|
||||
|
||||
public function canJump(){
|
||||
return $this->isJumping() && $this->jumpTimeout <= 0 && $this->entity->onGround;
|
||||
}
|
||||
public static function limitAngle2($old, $newA, $limit){
|
||||
$v4 = Utils::wrapAngleTo180($old - $newA);
|
||||
|
||||
|
||||
if($v4 < -$limit) $v4 = -$limit;
|
||||
if($v4 >= $limit) $v4 = $limit;
|
||||
|
||||
|
||||
return $old - $v4;
|
||||
}
|
||||
public static function limitAngle($old, $newA, $limit){
|
||||
$v4 = Utils::wrapAngleTo180($newA - $old);
|
||||
|
||||
|
||||
if($v4 > $limit) $v4 = $limit;
|
||||
if($v4 < -$limit) $v4 = -$limit;
|
||||
|
||||
|
||||
return $old + $v4;
|
||||
}
|
||||
|
||||
|
||||
public function jumpTick(){
|
||||
$this->entity->jumping = $this->jumping;
|
||||
$this->jumping = false;
|
||||
}
|
||||
|
||||
|
||||
public function movementTick(){
|
||||
$this->entity->moveForward = 0;
|
||||
|
||||
if($this->updateMove){
|
||||
$this->updateMove = false;
|
||||
$v1 = floor($this->entity->boundingBox->minY + 0.5);
|
||||
|
||||
|
||||
$diffX = $this->moveToX - $this->entity->x;
|
||||
$diffZ = $this->moveToZ - $this->entity->z;
|
||||
$diffY = $this->moveToY - $v1;
|
||||
|
||||
$v8 = $diffX*$diffX + $diffY*$diffY + $diffZ*$diffZ;
|
||||
|
||||
|
||||
$v8 = $diffX * $diffX + $diffY * $diffY + $diffZ * $diffZ;
|
||||
|
||||
if($v8 >= 0.00000025){
|
||||
$v10 = (atan2($diffZ, $diffX) * 180 / M_PI) - 90;
|
||||
$this->entity->yaw = self::limitAngle($this->entity->yaw, $v10, 30);
|
||||
|
|
@ -119,11 +119,11 @@ class MobController
|
|||
//}
|
||||
//if($this->jumpTimeout > 0) --$this->jumpTimeout;
|
||||
}
|
||||
|
||||
|
||||
public function updateHeadYaw(){
|
||||
$diffX = $this->entity->x - $this->entity->lastX;
|
||||
$diffZ = $this->entity->z - $this->entity->lastZ;
|
||||
if(($diffX*$diffX + $diffZ*$diffZ) > 0.00000025){
|
||||
if(($diffX * $diffX + $diffZ * $diffZ) > 0.00000025){
|
||||
$this->entity->renderYawOffset = $this->entity->yaw;
|
||||
$this->entity->headYaw = self::limitAngle2($this->entity->renderYawOffset, $this->entity->headYaw, 75);
|
||||
$this->headYaw = $this->entity->headYaw;
|
||||
|
|
@ -135,7 +135,7 @@ class MobController
|
|||
$this->headYaw = $this->entity->headYaw;
|
||||
}else{
|
||||
++$this->someTicker;
|
||||
|
||||
|
||||
if($this->someTicker > 10){
|
||||
$v5 = max(1 - ($this->someTicker - 10) / 10, 0) * 75;
|
||||
}
|
||||
|
|
@ -143,30 +143,30 @@ class MobController
|
|||
$this->entity->renderYawOffset = self::limitAngle2($this->entity->headYaw, $this->entity->renderYawOffset, $v5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function rotateTick(){ //TODO handle more rotation
|
||||
|
||||
|
||||
$this->entity->pitch = 0;
|
||||
if($this->isLooking){
|
||||
$this->isLooking = false;
|
||||
|
||||
|
||||
$diffX = $this->lookX - $this->entity->x;
|
||||
$diffY = $this->lookY - ($this->entity->y + $this->entity->getEyeHeight());
|
||||
$diffZ = $this->lookZ - $this->entity->z;
|
||||
$distance = sqrt($diffX*$diffX + $diffZ*$diffZ);
|
||||
|
||||
$v9 = (atan2($diffZ, $diffX)*180 / M_PI) - 90;
|
||||
$v10 = -(atan2($diffY, $distance)*180 / M_PI);
|
||||
|
||||
$distance = sqrt($diffX * $diffX + $diffZ * $diffZ);
|
||||
|
||||
$v9 = (atan2($diffZ, $diffX) * 180 / M_PI) - 90;
|
||||
$v10 = -(atan2($diffY, $distance) * 180 / M_PI);
|
||||
|
||||
$this->entity->pitch = self::limitAngle($this->entity->pitch, $v10, $this->deltaLookPitch);
|
||||
$this->entity->headYaw = self::limitAngle($this->entity->headYaw, $v9, $this->deltaLookYaw);
|
||||
}else{
|
||||
$this->entity->headYaw = self::limitAngle($this->entity->headYaw, $this->entity->renderYawOffset, 10);
|
||||
}
|
||||
|
||||
|
||||
if($this->headYawIsYaw) $this->entity->yaw = $this->entity->headYaw;
|
||||
$this->headYawIsYaw = false;
|
||||
|
||||
|
||||
/* Some stuff for pathfinder - nc doesnt have it now
|
||||
* float var11 = MathHelper.wrapAngleTo180_float(this.entity.rotationYawHead - this.entity.renderYawOffset);
|
||||
|
||||
|
|
@ -183,13 +183,13 @@ class MobController
|
|||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//$this->entity->lastHeadYaw = $this->entity->headYaw;
|
||||
//$w180 = Utils::wrapAngleTo180($this->finalHeadYaw - $this->entity->headYaw);
|
||||
//$w180 = Utils::wrapAngleTo180($this->finalHeadYaw - $this->entity->headYaw);
|
||||
//$w180min = min(abs($w180), 20)*Utils::getSign($w180);
|
||||
//$this->entity->headYaw = Utils::wrapAngleTo360($this->entity->headYaw + $w180min);
|
||||
}
|
||||
|
||||
|
||||
public function setLookPosition($posX, $posY, $posZ, $lookYaw, $lookPitch){
|
||||
$this->lookX = $posX;
|
||||
$this->lookY = $posY;
|
||||
|
|
@ -198,9 +198,9 @@ class MobController
|
|||
$this->deltaLookPitch = $lookPitch;
|
||||
$this->isLooking = true;
|
||||
}
|
||||
|
||||
|
||||
public function faceEntity($x, $y, $z){
|
||||
$len = sqrt($x*$x + $z*$z + $y*$y);
|
||||
$len = sqrt($x * $x + $z * $z + $y * $y);
|
||||
//$d = $len == 0 ?//$v->subtract($this->entity)->normalize();
|
||||
if($len == 0){
|
||||
$dx = 0;
|
||||
|
|
@ -209,38 +209,37 @@ class MobController
|
|||
$dx = $x / $len;
|
||||
$dz = $z / $len;
|
||||
}
|
||||
|
||||
|
||||
$tan = $dz == 0 ? ($dx < 0 ? 180 : 0) : (90 - rad2deg(atan($dx / $dz)));
|
||||
|
||||
$tan = $dz == 0 ? ($dx < 0 ? 180 : 0) : (90 - rad2deg(atan($dx / $dz)));
|
||||
$thetaOffset = $dz < 0 ? 90 : 270;
|
||||
$calcYaw = ($thetaOffset + $tan);
|
||||
$this->finalHeadYaw = $this->entity->yaw = Utils::wrapAngleTo360($calcYaw);
|
||||
}
|
||||
|
||||
|
||||
public function lookOffset($x, $y, $z, $pitch = true){
|
||||
$tan = $z == 0 ? ($x < 0 ? 180 : 0) : (90 - rad2deg(atan($x / $z))); /*arctan(infinity) = pi/2 = (90deg) - 90 = 0*/
|
||||
$thetaOffset = $z < 0 ? 90 : 270;
|
||||
$calcYaw = $tan + $thetaOffset;
|
||||
|
||||
|
||||
$this->entity->yaw = $this->finalHeadYaw = Utils::wrapAngleTo360($calcYaw);
|
||||
|
||||
|
||||
if($pitch){
|
||||
$diff = sqrt($x * $x + $z * $z);
|
||||
$calcPitch = $diff == 0 ? ($y < 0 ? -90 : 90) : rad2deg(atan($y / $diff));
|
||||
$this->entity->pitch = $calcPitch;
|
||||
}
|
||||
|
||||
|
||||
//$this->entity->server->query("UPDATE entities SET pitch = ".$this->entity->pitch.", yaw = ".$this->entity->yaw." WHERE EID = ".$this->entity->eid.";");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function lookOn($x, $y = 0, $z = 0, $pitch = true){
|
||||
if($x instanceof Vector3){
|
||||
return $this->lookOn($x->x, $x->y + $x->getEyeHeight(), $x->z, $pitch);
|
||||
}
|
||||
return $this->lookOffset($x - $this->entity->x, ($this->entity->y + $this->entity->height) - $y, $z - $this->entity->z, $pitch);
|
||||
}
|
||||
|
||||
|
||||
public function __destruct(){
|
||||
unset($this->entity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@ class PathFollower{
|
|||
* @var Living
|
||||
*/
|
||||
public $entity;
|
||||
|
||||
|
||||
public function __construct(Living $entity){
|
||||
$this->entity = $entity;
|
||||
}
|
||||
|
||||
|
||||
public function followPath(){
|
||||
|
||||
|
||||
if(!isset($this->entity) || !($this->entity instanceof Living)) return;
|
||||
if(!$this->entity->hasPath()) return;
|
||||
|
||||
|
||||
if($this->entity->currentNode == null){
|
||||
$this->entity->currentNode = $this->entity->path[$this->entity->currentIndex];
|
||||
}
|
||||
|
|
@ -27,14 +27,13 @@ class PathFollower{
|
|||
//console("next");
|
||||
$this->entity->currentNode = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($this->entity->currentIndex >= count($this->entity->path)){
|
||||
console("path finished.");
|
||||
$this->entity->currentNode = null;
|
||||
$this->entity->path = null;
|
||||
$this->entity->currentIndex = 0;
|
||||
|
||||
|
||||
/*foreach($this->entity->pathEIDS as $eid){
|
||||
$pk = new RemoveEntityPacket();
|
||||
$pk->eid = $eid;
|
||||
|
|
@ -42,9 +41,9 @@ class PathFollower{
|
|||
$player->dataPacket($pk);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,20 +4,19 @@ class TaskAttackPlayer extends TaskBase
|
|||
{
|
||||
public $speedMultiplier;
|
||||
public $rangeSquared;
|
||||
|
||||
|
||||
public $attackCounter;
|
||||
|
||||
|
||||
public function __construct($speed, $range){
|
||||
$this->speedMultiplier = $speed;
|
||||
$this->rangeSquared = $range*$range;
|
||||
$this->rangeSquared = $range * $range;
|
||||
}
|
||||
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
$this->selfCounter = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function onUpdate(EntityAI $ai)
|
||||
{
|
||||
if(!$this->isTargetValid($ai)){
|
||||
|
|
@ -27,7 +26,7 @@ class TaskAttackPlayer extends TaskBase
|
|||
}
|
||||
$ai->mobController->setMovingTarget($ai->entity->target->x, $ai->entity->target->y, $ai->entity->target->z, $this->speedMultiplier);
|
||||
$ai->mobController->setLookPosition($ai->entity->target->x, $ai->entity->target->y + 0.12, $ai->entity->target->z, 10, $ai->entity->getVerticalFaceSpeed());
|
||||
|
||||
|
||||
--$this->attackCounter;
|
||||
$v1 = $ai->entity->width * $ai->entity->width * 4;
|
||||
if($ai->entity instanceof Creeper){
|
||||
|
|
@ -38,16 +37,15 @@ class TaskAttackPlayer extends TaskBase
|
|||
$xDiff = ($t->x - $e->x);
|
||||
$yDiff = ($t->y - $e->y);
|
||||
$zDiff = ($t->z - $e->z);
|
||||
$dist = ($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff);
|
||||
$dist = ($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff);
|
||||
if($dist <= $v1){
|
||||
if($this->attackCounter <= 0){
|
||||
$this->attackCounter = $e->attackEntity($t, sqrt($dist)) ? 20 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function isTargetValid(EntityAI $ai){
|
||||
$e = $ai->entity;
|
||||
if($e->target instanceof Entity && !$e->target->closed && !$e->target->dead){
|
||||
|
|
@ -55,11 +53,11 @@ class TaskAttackPlayer extends TaskBase
|
|||
$xDiff = ($t->x - $e->x);
|
||||
$yDiff = ($t->y - $e->y);
|
||||
$zDiff = ($t->z - $e->z);
|
||||
return ($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->rangeSquared;
|
||||
return ($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->rangeSquared;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function tryTargeting(EntityAI $ai){
|
||||
$e = $ai->entity;
|
||||
if($e->target instanceof Entity){
|
||||
|
|
@ -67,25 +65,25 @@ class TaskAttackPlayer extends TaskBase
|
|||
$xDiff = ($t->x - $e->x);
|
||||
$yDiff = ($t->y - $e->y);
|
||||
$zDiff = ($t->z - $e->z);
|
||||
if(($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->rangeSquared){
|
||||
if(($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->rangeSquared){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$closestTarget = $e->closestPlayerToAttackDist <= $this->rangeSquared ? $e->level->entityList[$e->closestPlayerToAttackEID] : null;
|
||||
|
||||
|
||||
if($closestTarget != null){
|
||||
$e->target = $closestTarget; //TODO dont save entity object ?
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
{
|
||||
return $this->tryTargeting($ai);
|
||||
}
|
||||
|
||||
|
||||
public function onEnd(EntityAI $ai)
|
||||
{
|
||||
$ai->entity->target = false;
|
||||
|
|
|
|||
|
|
@ -3,45 +3,41 @@
|
|||
abstract class TaskBase
|
||||
{
|
||||
public $isStarted = false, $selfCounter = 0;
|
||||
|
||||
|
||||
public function __construct(){}
|
||||
|
||||
|
||||
/**
|
||||
* Executed when entity starts task. It is recommended to set counter here.
|
||||
* @param EntityAI $ai
|
||||
*/
|
||||
abstract function onStart(EntityAI $ai);
|
||||
|
||||
|
||||
/**
|
||||
* Every tick until counter will be not equal to 0. It is recommended to update value of counter here.
|
||||
* @param EntityAI $ai
|
||||
*/
|
||||
abstract function onUpdate(EntityAI $ai);
|
||||
|
||||
|
||||
/**
|
||||
* On task end.
|
||||
* @param EntityAI $ai
|
||||
*/
|
||||
abstract function onEnd(EntityAI $ai);
|
||||
|
||||
|
||||
/**
|
||||
* Can start the task
|
||||
* @param EntityAI $ai
|
||||
*/
|
||||
abstract function canBeExecuted(EntityAI $ai);
|
||||
|
||||
|
||||
/**
|
||||
* @return number ticks
|
||||
*/
|
||||
function getIdleTimeAfterEnd(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function reset(){
|
||||
$this->isStarted = false;
|
||||
$this->selfCounter = 0;
|
||||
}
|
||||
|
||||
|
||||
final function __toString(){
|
||||
return get_class($this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class TaskEatTileGoal extends TaskBase
|
|||
|
||||
public function onEnd(EntityAI $ai)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function onUpdate(EntityAI $ai)
|
||||
|
|
@ -20,7 +20,7 @@ class TaskEatTileGoal extends TaskBase
|
|||
if($ai->isStarted("TaskPanic")){
|
||||
$this->reset();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (--$this->selfCounter == 4)
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ class TaskEatTileGoal extends TaskBase
|
|||
if($id === TALL_GRASS){
|
||||
$ai->entity->level->fastSetBlockUpdate($ai->entity->x, $ai->entity->y, $ai->entity->z, AIR, 0);
|
||||
$ai->entity->eatGrass();
|
||||
|
||||
|
||||
}elseif($idb === GRASS){
|
||||
$ai->entity->level->fastSetBlockUpdate($ai->entity->x, $ai->entity->y - 1, $ai->entity->z, DIRT, 0);
|
||||
$ai->entity->eatGrass();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class TaskFollowParent extends TaskBase
|
|||
public function __construct($speed){
|
||||
$this->speedMultiplier = $speed;
|
||||
}
|
||||
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
$this->selfCounter = 1;
|
||||
|
|
@ -24,19 +24,19 @@ class TaskFollowParent extends TaskBase
|
|||
$ai->entity->parent = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$dist = $ai->entity->distanceSquared($ai->entity->parent);
|
||||
|
||||
|
||||
if($dist > 256 || $dist < 9){ //3-16 blocks
|
||||
$this->reset();
|
||||
return false;
|
||||
}
|
||||
$parent = $ai->entity->parent;
|
||||
|
||||
|
||||
$ai->mobController->setLookPosition($parent->x, $parent->y + $parent->getEyeHeight(), $parent->z, 10, $ai->entity->getVerticalFaceSpeed());
|
||||
$ai->mobController->setMovingTarget($parent->x, $parent->y, $parent->z, $this->speedMultiplier);
|
||||
}
|
||||
|
||||
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
{
|
||||
return $ai->entity->isBaby() && ($ai->entity->parent instanceof Entity) && !$ai->entity->parent->dead; //TODO find a new parent if the current one is dead
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
class TaskLookAround extends TaskBase
|
||||
{
|
||||
public $lookOffsetX, $lookOffsetZ;
|
||||
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
$this->selfCounter = 20 + lcg_value();
|
||||
|
|
@ -19,9 +19,9 @@ class TaskLookAround extends TaskBase
|
|||
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
{
|
||||
return !$ai->entity->inPanic && !$ai->entity->isMoving() && lcg_value() < 0.02 && !$ai->isStarted("TaskLookAtPlayer") && !$ai->isStarted("TaskAttackPlayer") && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskTempt") && !$ai->entity->hasPath(); /*Vanilla value*/
|
||||
return !$ai->entity->inPanic && !$ai->entity->isMoving() && lcg_value() < 0.02 && !$ai->isStarted("TaskLookAtPlayer") && !$ai->isStarted("TaskAttackPlayer") && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskTempt") && !$ai->entity->hasPath(); /*Vanilla value*/
|
||||
}
|
||||
|
||||
|
||||
public function onUpdate(EntityAI $ai)
|
||||
{
|
||||
--$this->selfCounter;
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ class TaskLookAtPlayer extends TaskBase{
|
|||
public function __construct($distance){
|
||||
$this->distance = $distance;
|
||||
}
|
||||
|
||||
|
||||
public function canBeExecuted(EntityAI $ai){
|
||||
return !$ai->entity->inPanic && lcg_value() < 0.02 && !$ai->entity->isMovingHorizontally() && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskTempt") && !$ai->isStarted("TaskPanic") && !$ai->entity->hasPath();
|
||||
return !$ai->entity->inPanic && lcg_value() < 0.02 && !$ai->entity->isMovingHorizontally() && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskTempt") && !$ai->isStarted("TaskPanic") && !$ai->entity->hasPath();
|
||||
}
|
||||
|
||||
protected function findTarget(Creature $e, $r){
|
||||
return $e->closestPlayerDist > $r*$r ? null : $e->level->entityList[$e->closestPlayerEID];
|
||||
return $e->closestPlayerDist > $r * $r ? null : $e->level->entityList[$e->closestPlayerEID];
|
||||
}
|
||||
|
||||
public function onStart(EntityAI $ai){
|
||||
|
|
@ -22,7 +22,7 @@ class TaskLookAtPlayer extends TaskBase{
|
|||
$this->onEnd($ai);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->selfCounter = mt_rand(20, 60);
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ class TaskLookAtPlayer extends TaskBase{
|
|||
$ai->mobController->setLookPosition($this->target->x, $this->target->y + $this->target->getEyeHeight(), $this->target->z, 10, $ai->entity->getVerticalFaceSpeed());
|
||||
$this->selfCounter--;
|
||||
}
|
||||
|
||||
|
||||
public function onEnd(EntityAI $ai){
|
||||
unset($this->target);
|
||||
$ai->entity->pitch = 0;
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ class TaskMate extends TaskBase
|
|||
public function __construct($speed){
|
||||
$this->speedMultiplier = $speed;
|
||||
}
|
||||
|
||||
|
||||
public $targetMateID;
|
||||
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
$this->selfCounter = 60;
|
||||
|
|
@ -28,17 +28,16 @@ class TaskMate extends TaskBase
|
|||
$this->onEnd($ai);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$ai->mobController->setLookPosition($movTo->x, $movTo->y + $movTo->getEyeHeight(), $movTo->z, 10, $ai->entity->getVerticalFaceSpeed());
|
||||
$ai->mobController->setMovingTarget($movTo->x, $movTo->y, $movTo->z, $this->speedMultiplier);
|
||||
|
||||
|
||||
--$this->selfCounter;
|
||||
if($this->selfCounter <= 0 && $ai->entity->distanceSquared($movTo) < 9){
|
||||
$this->createBaby($ai, $movTo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function createBaby(EntityAI $ai, Entity $entpar2){
|
||||
/**
|
||||
* @var Animal $baby
|
||||
|
|
@ -46,20 +45,20 @@ class TaskMate extends TaskBase
|
|||
$baby = $ai->entity->breed($entpar2);
|
||||
//this.theAnimal.setGrowingAge(6000); TODO growing age?
|
||||
//this.targetMate.setGrowingAge(6000);
|
||||
|
||||
|
||||
$ai->entity->loveTimeout = 6000;
|
||||
$entpar2->loveTimeout = 6000;
|
||||
|
||||
|
||||
$ai->entity->resetInLove();
|
||||
$entpar2->resetInLove();
|
||||
$baby->setAge(-24000);
|
||||
}
|
||||
|
||||
|
||||
public function findMate(EntityAI $ai){
|
||||
$distance = 8.0*8.0;
|
||||
$distance = 8.0 * 8.0;
|
||||
$minDist = $distance; //TODO check bb intersection?
|
||||
$matedEID = null;
|
||||
|
||||
|
||||
foreach($ai->entity->level->entitiesInLove as $eid => $_){
|
||||
$e = $ai->entity->level->entityList[$eid] ?? false;
|
||||
if($e instanceof Entity){
|
||||
|
|
@ -72,7 +71,7 @@ class TaskMate extends TaskBase
|
|||
}
|
||||
return $matedEID;
|
||||
}
|
||||
|
||||
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
{
|
||||
return $ai->entity->isInLove() && ($this->targetMateID = $this->findMate($ai)) != null;
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
class TaskPanic extends TaskBase
|
||||
{
|
||||
protected $randX = 2, $randZ = 2;
|
||||
|
||||
|
||||
public $speedMultiplier;
|
||||
public function __construct($speedMultiplier){
|
||||
$this->speedMultiplier = $speedMultiplier;
|
||||
}
|
||||
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
$this->selfCounter = 60;
|
||||
|
|
@ -20,16 +20,16 @@ class TaskPanic extends TaskBase
|
|||
$ai->entity->inPanic = false;
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
|
||||
public function regenerateRandXZ(){
|
||||
$this->randX = (mt_rand(0, 1) ? -1 : 1);
|
||||
$this->randZ = (mt_rand(0, 1) ? -1 : 1);
|
||||
}
|
||||
|
||||
|
||||
public function reset(){
|
||||
$this->randX = $this->randZ = 2;
|
||||
}
|
||||
|
||||
|
||||
public function onUpdate(EntityAI $ai)
|
||||
{
|
||||
--$this->selfCounter;
|
||||
|
|
@ -42,6 +42,5 @@ class TaskPanic extends TaskBase
|
|||
return $ai->entity instanceof Animal && $ai->entity->inPanic && $ai->entity->knockbackTime <= 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class TaskRandomWalk extends TaskBase
|
|||
public function __construct($speedMultiplier){
|
||||
$this->speedMultiplier = $speedMultiplier;
|
||||
}
|
||||
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
$this->x = mt_rand(-1, 1);
|
||||
|
|
@ -30,7 +30,7 @@ class TaskRandomWalk extends TaskBase
|
|||
$this->reset();
|
||||
return false; //TODO Better way: block movement
|
||||
}
|
||||
|
||||
|
||||
--$this->selfCounter;
|
||||
$ai->mobController->setMovingOffset($this->x, 0, $this->z, $this->speedMultiplier);
|
||||
}
|
||||
|
|
@ -40,8 +40,7 @@ class TaskRandomWalk extends TaskBase
|
|||
if(($ai->entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->entity->hasPath() || $ai->isStarted("TaskTempt") || $ai->isStarted("TaskAttackPlayer") || $ai->isStarted("TaskRangedAttack")) {
|
||||
return false;
|
||||
} // i really need mutexBits
|
||||
return !$ai->entity->inPanic && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskEatTileGoal") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskFollowParent") && !$ai->isStarted("TaskLookAtPlayer") && mt_rand(0, 120) == 0;
|
||||
return !$ai->entity->inPanic && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskEatTileGoal") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskFollowParent") && !$ai->isStarted("TaskLookAtPlayer") && mt_rand(0, 120) == 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ class TaskRangedAttack extends \TaskBase
|
|||
public $rangeSquared = 0;
|
||||
public function __construct($speed, $range){
|
||||
$this->speedMultiplier = $speed;
|
||||
$this->rangeSquared = $range*$range;
|
||||
$this->rangeSquared = $range * $range;
|
||||
$this->server = ServerAPI::request();
|
||||
}
|
||||
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
$this->selfCounter = 1;
|
||||
|
|
@ -20,7 +20,7 @@ class TaskRangedAttack extends \TaskBase
|
|||
public function onEnd(EntityAI $ai)
|
||||
{
|
||||
$ai->entity->target = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function onUpdate(EntityAI $ai)
|
||||
|
|
@ -36,24 +36,23 @@ class TaskRangedAttack extends \TaskBase
|
|||
}else{
|
||||
$this->seenTicks = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$dist = $ai->entity->distanceSquared($ai->entity->target);
|
||||
|
||||
|
||||
if($dist > 100 || $this->seenTicks < 20){
|
||||
$ai->mobController->setMovingTarget($ai->entity->target->x, $ai->entity->target->y, $ai->entity->target->z, $this->speedMultiplier);
|
||||
}else{
|
||||
$ai->mobController->headYawIsYaw = true;
|
||||
}
|
||||
|
||||
|
||||
$ai->mobController->setLookPosition($ai->entity->target->x, $ai->entity->target->y + 0.12, $ai->entity->target->z, 10, $ai->entity->getVerticalFaceSpeed());
|
||||
|
||||
|
||||
if($this->attackCounter <= 0 && $this->seenTicks > 0){
|
||||
$this->rangedAttack($ai->entity, $ai->entity->target);
|
||||
$this->attackCounter = 60;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function rangedAttack($selfEntity, $target){
|
||||
$d = [
|
||||
"x" => $selfEntity->x,
|
||||
|
|
@ -88,8 +87,7 @@ class TaskRangedAttack extends \TaskBase
|
|||
$this->server->api->entity->spawnToAll($arrow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function isTargetValid(EntityAI $ai){
|
||||
$e = $ai->entity;
|
||||
if($e->target instanceof Entity && !$e->target->closed && !$e->target->dead){
|
||||
|
|
@ -97,11 +95,11 @@ class TaskRangedAttack extends \TaskBase
|
|||
$xDiff = ($t->x - $e->x);
|
||||
$yDiff = ($t->y - $e->y);
|
||||
$zDiff = ($t->z - $e->z);
|
||||
return ($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->rangeSquared;
|
||||
return ($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->rangeSquared;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function tryTargeting(EntityAI $ai){
|
||||
$e = $ai->entity;
|
||||
if($e->target instanceof Entity){
|
||||
|
|
@ -109,21 +107,20 @@ class TaskRangedAttack extends \TaskBase
|
|||
$xDiff = ($t->x - $e->x);
|
||||
$yDiff = ($t->y - $e->y);
|
||||
$zDiff = ($t->z - $e->z);
|
||||
if(($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->rangeSquared){
|
||||
if(($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->rangeSquared){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$closestTarget = $e->closestPlayerToAttackDist <= $this->rangeSquared ? $e->level->entityList[$e->closestPlayerToAttackEID] : null;
|
||||
|
||||
|
||||
if($closestTarget != null){
|
||||
$e->target = $closestTarget; //TODO dont save entity object ?
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
{
|
||||
return $this->tryTargeting($ai);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class TaskSwimming extends TaskBase
|
|||
|
||||
public function onEnd(EntityAI $ai)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function onUpdate(EntityAI $ai)
|
||||
|
|
@ -18,12 +18,12 @@ class TaskSwimming extends TaskBase
|
|||
$this->reset();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(lcg_value() < 0.8){ #1.5.2 method
|
||||
$ai->mobController->setJumping(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
{
|
||||
return $ai->entity->inWater || $ai->entity->inLava;
|
||||
|
|
|
|||
|
|
@ -6,19 +6,19 @@ class TaskTempt extends TaskBase
|
|||
public $targetDistance;
|
||||
public function __construct($speed){
|
||||
$this->speedMultiplier = $speed;
|
||||
$this->targetDistance = 10*10;
|
||||
$this->targetDistance = 10 * 10;
|
||||
}
|
||||
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
$this->selfCounter = 1;
|
||||
}
|
||||
|
||||
|
||||
public function onEnd(EntityAI $ai)
|
||||
{
|
||||
$ai->entity->target = false;
|
||||
}
|
||||
|
||||
|
||||
public function onUpdate(EntityAI $ai)
|
||||
{
|
||||
if(!$this->isTargetValid($ai) || $ai->entity->inPanic || $ai->isStarted("TaskMate")){
|
||||
|
|
@ -26,22 +26,21 @@ class TaskTempt extends TaskBase
|
|||
$this->onEnd($ai);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$target = $ai->entity->target;
|
||||
$xdiff = ($target->x - $ai->entity->x);
|
||||
$ydiff = ($target->y - $ai->entity->y);
|
||||
$zdiff = ($target->z - $ai->entity->z);
|
||||
$dist = $xdiff*$xdiff + $ydiff*$ydiff + $zdiff*$zdiff;
|
||||
$dist = $xdiff * $xdiff + $ydiff * $ydiff + $zdiff * $zdiff;
|
||||
$ai->mobController->setLookPosition($target->x, $target->y + $target->getEyeHeight(), $target->z, 30, $ai->entity->getVerticalFaceSpeed());
|
||||
if($dist >= 6.25){
|
||||
$ai->mobController->setMovingTarget($target->x, $target->y, $target->z, $this->speedMultiplier);
|
||||
}else{
|
||||
$ai->mobController->headYawIsYaw = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function isTargetValid(EntityAI $ai){
|
||||
$e = $ai->entity;
|
||||
if($e->target instanceof Entity && !$e->target->closed && $e->isFood($e->target->player->getHeldItem()->id)){
|
||||
|
|
@ -49,16 +48,16 @@ class TaskTempt extends TaskBase
|
|||
$xDiff = ($t->x - $e->x);
|
||||
$yDiff = ($t->y - $e->y);
|
||||
$zDiff = ($t->z - $e->z);
|
||||
return ($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->targetDistance;
|
||||
return ($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->targetDistance;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
{
|
||||
return !$ai->entity->inPanic && !$ai->isStarted("TaskMate") && $this->tryTargeting($ai);
|
||||
}
|
||||
|
||||
|
||||
public function tryTargeting(EntityAI $ai){
|
||||
$e = $ai->entity;
|
||||
if($e->target instanceof Entity){
|
||||
|
|
@ -66,13 +65,13 @@ class TaskTempt extends TaskBase
|
|||
$xDiff = ($t->x - $e->x);
|
||||
$yDiff = ($t->y - $e->y);
|
||||
$zDiff = ($t->z - $e->z);
|
||||
if(($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->targetDistance){
|
||||
if(($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->targetDistance){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$closestTarget = $e->closestPlayerThatCanFeedDist <= $this->targetDistance ? $e->level->entityList[$e->closestPlayerThatCanFeedEID] : null;
|
||||
|
||||
|
||||
if($closestTarget != null){
|
||||
$e->target = $closestTarget; //TODO dont save entity object ?
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Chicken extends Animal{
|
|||
$this->setHealth($this->data["Health"] ?? 4, "generic", allowHarm: false);
|
||||
$this->setName('Chicken');
|
||||
$this->setSpeed(0.25);
|
||||
|
||||
|
||||
$this->ai->addTask(new TaskRandomWalk(1.0));
|
||||
$this->ai->addTask(new TaskLookAtPlayer(6));
|
||||
$this->ai->addTask(new TaskPanic(1.5));
|
||||
|
|
@ -23,27 +23,27 @@ class Chicken extends Animal{
|
|||
public function isFood($id){
|
||||
return $id === PUMPKIN_SEEDS || $id === MELON_SEEDS || $id === BEETROOT_SEEDS || $id === WHEAT_SEEDS;
|
||||
}
|
||||
|
||||
|
||||
public function updateEntityMovement(){
|
||||
parent::updateEntityMovement();
|
||||
|
||||
|
||||
if(!$this->onGround && $this->speedY < 0) $this->speedY *= 0.6;
|
||||
|
||||
|
||||
if($this->timeUntilEgg-- <= 0 && !$this->isBaby()){
|
||||
$this->dropAnEgg();
|
||||
$this->timeUntilEgg = mt_rand(0,6000) + 6000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function fall(){} //chickens have no fall dmg?
|
||||
|
||||
|
||||
public function dropAnEgg(){
|
||||
if($this->closed){
|
||||
return;
|
||||
}
|
||||
ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(EGG, 0, 1));
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(){
|
||||
return $this->isBaby() ? parent::getDrops() : [
|
||||
[FEATHER, 0, mt_rand(0,2)],
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ class Cow extends Animal{
|
|||
$this->ai->addTask(new TaskMate(1.0));
|
||||
$this->ai->addTask(new TaskFollowParent(1.1));
|
||||
}
|
||||
|
||||
|
||||
public function isFood($id){
|
||||
return $id === WHEAT;
|
||||
}
|
||||
|
||||
|
||||
public function interactWith(Entity $e, $action){
|
||||
if($e->isPlayer() && $action === InteractPacket::ACTION_HOLD){
|
||||
$slot = $e->player->getHeldItem();
|
||||
|
|
@ -33,9 +33,9 @@ class Cow extends Animal{
|
|||
}
|
||||
parent::interactWith($e, $action);
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(){
|
||||
return $this->isBaby() ? parent::getDrops() : [
|
||||
return $this->isBaby() ? parent::getDrops() : [
|
||||
[LEATHER, 0, mt_rand(0,2)],
|
||||
[($this->fire > 0 ? STEAK : BEEF), 0, mt_rand(0, 3)]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
class Pig extends Animal implements Rideable{
|
||||
const TYPE = MOB_PIG;
|
||||
|
||||
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
$this->setSize(0.9, 0.9);
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
|
|
@ -9,7 +10,7 @@ class Pig extends Animal implements Rideable{
|
|||
$this->server = ServerAPI::request();
|
||||
$this->setName("Pig");
|
||||
$this->setSpeed(0.25);
|
||||
|
||||
|
||||
$this->ai->addTask(new TaskRandomWalk(1.0));
|
||||
$this->ai->addTask(new TaskLookAtPlayer(6));
|
||||
$this->ai->addTask(new TaskPanic(1.5));
|
||||
|
|
@ -25,18 +26,18 @@ class Pig extends Animal implements Rideable{
|
|||
public function isSaddled(){
|
||||
return (boolean) $this->getState();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param boolean $value
|
||||
*/
|
||||
public function setSaddled($value = null){
|
||||
$this->setState($value === null ? !$this->getState() : $value);
|
||||
}
|
||||
|
||||
|
||||
public function canRide($e){
|
||||
return $this->isSaddled() && $this->rider == 0;
|
||||
}
|
||||
|
||||
|
||||
public function updateEntityMovement(){
|
||||
/*if($this->linkedEntity != 0){
|
||||
$e = $this->level->entityList[$this->linkedEntity] ?? false;
|
||||
|
|
@ -47,10 +48,10 @@ class Pig extends Animal implements Rideable{
|
|||
$this->yaw = $e->headYaw;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
parent::updateEntityMovement();
|
||||
}
|
||||
|
||||
|
||||
public function interactWith(Entity $e, $action)
|
||||
{
|
||||
if($e->isPlayer() && $action === InteractPacket::ACTION_HOLD){
|
||||
|
|
@ -59,7 +60,7 @@ class Pig extends Animal implements Rideable{
|
|||
$e->setRiding($this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if($slot->getID() === SADDLE){
|
||||
if(!$this->isSaddled()){
|
||||
$e->player->consumeSingleItem(send: true);
|
||||
|
|
@ -67,15 +68,15 @@ class Pig extends Animal implements Rideable{
|
|||
}
|
||||
return true; //avoid further interactions
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return parent::interactWith($e, $action);
|
||||
}
|
||||
|
||||
|
||||
public function isFood($id){
|
||||
return $id === POTATO || $id === CARROT || $id === BEETROOT;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(){
|
||||
return $this->isBaby() ? parent::getDrops() : ($this->isSaddled() ? [
|
||||
[($this->fire > 0 ? COOKED_PORKCHOP : RAW_PORKCHOP), 0, mt_rand(0,2)],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
class PigZombie extends Monster{ //TODO extends zombie
|
||||
const TYPE = MOB_PIGMAN;
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
class Skeleton extends Monster{
|
||||
const TYPE = MOB_SKELETON;
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
|
|
@ -8,31 +9,31 @@ class Skeleton extends Monster{
|
|||
$this->setName("Skeleton");
|
||||
$this->ai->removeTask("TaskAttackPlayer");
|
||||
$this->setSpeed(0.25);
|
||||
|
||||
|
||||
$this->ai->addTask(new TaskRandomWalk(1.0));
|
||||
$this->ai->addTask(new TaskLookAround());
|
||||
$this->ai->addTask(new TaskSwimming());
|
||||
$this->ai->addTask(new TaskRangedAttack(1.0, 16));
|
||||
}
|
||||
|
||||
|
||||
public function getAttackDamage(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public function updateBurning(){
|
||||
if($this->fire > 0 || !$this->level->isDay() || $this->inWater){
|
||||
return false;
|
||||
}
|
||||
//bad fix for burning in water
|
||||
[$block, $meta] = $this->level->level->getBlock((int)$this->x, (int)$this->y, (int)$this->z);
|
||||
[$block, $meta] = $this->level->level->getBlock((int) $this->x, (int) $this->y, (int) $this->z);
|
||||
if($block == WATER || $block == STILL_WATER){
|
||||
$v16 = ((int)$this->y + 1) - LiquidBlock::getPercentAir($meta);
|
||||
if($this->boundingBox->intersectsWith(new AxisAlignedBB((int)$this->x, (int)$this->y, (int)$this->z, (int)$this->x + 1, $v16, (int)$this->z + 1))){
|
||||
$v16 = ((int) $this->y + 1) - LiquidBlock::getPercentAir($meta);
|
||||
if($this->boundingBox->intersectsWith(new AxisAlignedBB((int) $this->x, (int) $this->y, (int) $this->z, (int) $this->x + 1, $v16, (int) $this->z + 1))){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for($y = (int)$this->y; $y < 129; $y++){
|
||||
|
||||
for($y = (int) $this->y; $y < 129; $y++){
|
||||
$block = $this->level->level->getBlockID($this->x, $y, $this->z);
|
||||
if(StaticBlock::getIsSolid($block)){
|
||||
return false;
|
||||
|
|
@ -49,12 +50,12 @@ class Skeleton extends Monster{
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateEntityMovement(){
|
||||
$this->updateBurning();
|
||||
return parent::updateEntityMovement();
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(){
|
||||
return [
|
||||
[ARROW, 0, mt_rand(0,2)],
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
<?php
|
||||
|
||||
class Spider extends Monster{
|
||||
const TYPE = MOB_SPIDER;
|
||||
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
||||
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
$this->setSize(1.4, 0.9);
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->setHealth($this->data["Health"] ?? 8, "generic", allowHarm: false);
|
||||
|
|
@ -11,35 +12,35 @@ class Spider extends Monster{
|
|||
$this->ai->addTask(new TaskRandomWalk(1.2));
|
||||
$this->ai->addTask(new TaskLookAround());
|
||||
$this->ai->addTask(new TaskSwimming());
|
||||
$this->ai->addTask(new TaskAttackPlayer(1.2, 16));
|
||||
$this->ai->addTask(new TaskAttackPlayer(1.2, 16));
|
||||
}
|
||||
|
||||
|
||||
public function getAttackDamage(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
public function attackEntity($entity, $distance){
|
||||
if($distance > 2.0 && $distance < 6.0){
|
||||
if($this->onGround){
|
||||
$diffX = $entity->x - $this->x;
|
||||
$diffZ = $entity->z - $this->z;
|
||||
$dist = sqrt($diffX*$diffX + $diffZ*$diffZ);
|
||||
|
||||
$this->speedX = $diffX / $dist*0.5*0.8 + $this->speedX*0.2;
|
||||
$this->speedZ = $diffZ / $dist*0.5*0.8 + $this->speedZ*0.2;
|
||||
$dist = sqrt($diffX * $diffX + $diffZ * $diffZ);
|
||||
|
||||
$this->speedX = $diffX / $dist * 0.5 * 0.8 + $this->speedX * 0.2;
|
||||
$this->speedZ = $diffZ / $dist * 0.5 * 0.8 + $this->speedZ * 0.2;
|
||||
$this->speedY = 0.4;
|
||||
}
|
||||
return false;
|
||||
}else{
|
||||
return parent::attackEntity($entity, $distance);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function isOnLadder(){
|
||||
return $this->isCollidedHorizontally;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(){
|
||||
return [
|
||||
[STRING, 0, mt_rand(0,2)]
|
||||
|
|
|
|||
|
|
@ -1,32 +1,32 @@
|
|||
<?php
|
||||
|
||||
class ThrownEgg extends Projectile{
|
||||
const TYPE = OBJECT_EGG;
|
||||
|
||||
|
||||
public function onHit(MovingObjectPosition $hitResult){
|
||||
if($hitResult->typeOfHit == 1){
|
||||
$hitResult->entityHit->harm(0, $this->eid);
|
||||
}
|
||||
|
||||
|
||||
$rand = mt_rand(0, 7);
|
||||
if($rand == 0){
|
||||
$count = mt_rand(0, 31) == 0 ? 4 : 1;
|
||||
$data = [
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z,
|
||||
"z" => $this->z,
|
||||
"yaw" => $this->yaw,
|
||||
"pitch" => 0,
|
||||
"IsBaby" => true
|
||||
];
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$chicken = $this->server->api->entity->add($this->level, ENTITY_MOB, MOB_CHICKEN, $data);
|
||||
|
||||
|
||||
$this->server->api->entity->spawnToAll($chicken);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
|
||||
class ThrownSnowball extends Projectile{
|
||||
const TYPE = OBJECT_SNOWBALL;
|
||||
public function onHit(MovingObjectPosition $hitResult){
|
||||
if($hitResult->typeOfHit == 1){
|
||||
$hitResult->entityHit->harm(0, $this->eid);
|
||||
}
|
||||
|
||||
|
||||
$this->close();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
class TripodCamera extends Entity{
|
||||
const TYPE = OBJECT_TRIPOD_CAMERA;
|
||||
|
||||
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->setHealth(PHP_INT_MAX, "generic", allowHarm: false);
|
||||
}
|
||||
|
||||
|
||||
public function isPickable(){
|
||||
return !$this->dead;
|
||||
}
|
||||
|
||||
|
||||
public function interactWith(Entity $e, $action){
|
||||
if($e->isPlayer() and $action === InteractPacket::ACTION_HOLD){
|
||||
//todo
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
class EntityRegistry{
|
||||
class EntityRegistry{
|
||||
public static $entityList;
|
||||
|
||||
|
||||
/*Register all entities*/
|
||||
public static function registerEntities(){
|
||||
ConsoleAPI::info("Registering entities...");
|
||||
|
|
@ -25,13 +25,13 @@ class EntityRegistry{
|
|||
self::registerEntity(ThrownEgg::class);
|
||||
self::registerEntity(ThrownSnowball::class);
|
||||
}
|
||||
|
||||
|
||||
/*Register an Entity*/
|
||||
public static function registerEntity($className){
|
||||
$class = new \ReflectionClass($className);
|
||||
if(is_a($className, Entity::class, true) and !$class->isAbstract()){
|
||||
//self::$entityList[$className::TYPE] = $className;
|
||||
|
||||
|
||||
self::$entityList->addEntity(new PropertyEntity($className::CLASS_TYPE, $className::TYPE, $className));
|
||||
//self::$shortNames[$className] = $class->getShortName(); what is this even supposed to do?
|
||||
//console("[INFO] Registered a ".$className);
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
class PropertyEntity{
|
||||
private $class,$type,$name;
|
||||
|
||||
|
||||
function __construct($class, $type, $name){
|
||||
$this->class = $class;
|
||||
$this->type = $type;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
public function getEntityClass(){
|
||||
return $this->class;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ abstract class EventHandler{
|
|||
}else{
|
||||
return BaseEvent::ALLOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -44,9 +44,9 @@ abstract class EventPriority{
|
|||
const HIGHEST = 1;
|
||||
/**
|
||||
* Event is listened to purely for monitoring the outcome of an event.
|
||||
*
|
||||
*
|
||||
* No modifications to the event should be made under this priority
|
||||
*/
|
||||
const MONITOR = 0;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Plugins that create events must use this class as the base
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,26 +15,26 @@
|
|||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class DataPacketReceiveEvent extends ServerEvent implements CancellableEvent{
|
||||
public static $handlers;
|
||||
public static $handlerPriority;
|
||||
|
||||
|
||||
private $packet;
|
||||
private $player;
|
||||
|
||||
private $player;
|
||||
|
||||
public function __construct(Player $player, RakNetDataPacket $packet){
|
||||
$this->packet = $packet;
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
|
||||
public function getPacket(){
|
||||
return $this->packet;
|
||||
}
|
||||
|
||||
|
||||
public function getPlayer(){
|
||||
return $this->player;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,26 +15,26 @@
|
|||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class DataPacketSendEvent extends ServerEvent implements CancellableEvent{
|
||||
public static $handlers;
|
||||
public static $handlerPriority;
|
||||
|
||||
|
||||
private $packet;
|
||||
private $player;
|
||||
|
||||
private $player;
|
||||
|
||||
public function __construct(Player $player, RakNetDataPacket $packet){
|
||||
$this->packet = $packet;
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
|
||||
public function getPacket(){
|
||||
return $this->packet;
|
||||
}
|
||||
|
||||
|
||||
public function getPlayer(){
|
||||
return $this->player;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,21 +15,20 @@
|
|||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class PacketReceiveEvent extends ServerEvent implements CancellableEvent{
|
||||
public static $handlers;
|
||||
public static $handlerPriority;
|
||||
|
||||
|
||||
private $packet;
|
||||
|
||||
|
||||
|
||||
public function __construct(Packet $packet){
|
||||
$this->packet = $packet;
|
||||
}
|
||||
|
||||
|
||||
public function getPacket(){
|
||||
return $this->packet;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,21 +15,20 @@
|
|||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class PacketSendEvent extends ServerEvent implements CancellableEvent{
|
||||
public static $handlers;
|
||||
public static $handlerPriority;
|
||||
|
||||
|
||||
private $packet;
|
||||
|
||||
|
||||
|
||||
public function __construct(Packet $packet){
|
||||
$this->packet = $packet;
|
||||
}
|
||||
|
||||
|
||||
public function getPacket(){
|
||||
return $this->packet;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ if(!function_exists("cli_set_process_title")){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function dummy(){
|
||||
|
||||
}
|
||||
|
|
@ -69,8 +68,6 @@ function nullsafe(&$a, $null){
|
|||
return $a ?? $null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function require_all($path, &$count = 0){
|
||||
$dir = dir($path . "/");
|
||||
$dirs = [];
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
const DEFAULT_MEMORY = 128;
|
||||
const DEFAULT_PLAYERS = 20;
|
||||
const DEFAULT_GAMEMODE = SURVIVAL;
|
||||
|
||||
|
||||
private $lang, $config;
|
||||
public function __construct(){
|
||||
echo "[*] NostalgiaCore set-up wizard\n";
|
||||
|
|
@ -34,12 +34,12 @@
|
|||
$this->welcome();
|
||||
$this->generateBaseConfig();
|
||||
$this->generateUserFiles();
|
||||
|
||||
|
||||
$this->networkFunctions();
|
||||
|
||||
|
||||
$this->endWizard();
|
||||
}
|
||||
|
||||
|
||||
private function welcome(){
|
||||
echo $this->lang->welcome_to_pocketmine."\n";
|
||||
echo <<<LICENSE
|
||||
|
|
@ -59,9 +59,9 @@ LICENSE;
|
|||
echo "[*] ".$this->lang->setting_up_server_now."\n";
|
||||
echo "[*] ".$this->lang->default_values_info."\n";
|
||||
echo "[*] ".$this->lang->server_properties."\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function generateBaseConfig(){
|
||||
$config = new Config(DATA_PATH . "server.properties", CONFIG_PROPERTIES);
|
||||
echo "[?] ".$this->lang->name_your_server." (".self::DEFAULT_NAME."): ";
|
||||
|
|
@ -95,7 +95,7 @@ LICENSE;
|
|||
}
|
||||
$config->save();
|
||||
}
|
||||
|
||||
|
||||
private function generateUserFiles(){
|
||||
echo "[*] ".$this->lang->op_info."\n";
|
||||
echo "[?] ".$this->lang->op_who.": ";
|
||||
|
|
@ -118,7 +118,7 @@ LICENSE;
|
|||
}
|
||||
$config->save();
|
||||
}
|
||||
|
||||
|
||||
private function networkFunctions(){
|
||||
$config = new Config(DATA_PATH . "server.properties", CONFIG_PROPERTIES);
|
||||
echo "[!] ".$this->lang->query_warning1."\n";
|
||||
|
|
@ -129,7 +129,7 @@ LICENSE;
|
|||
}else{
|
||||
$config->set("enable-query", true);
|
||||
}
|
||||
|
||||
|
||||
echo "[*] ".$this->lang->rcon_info."\n";
|
||||
echo "[?] ".$this->lang->rcon_enable." (y/N): ";
|
||||
if(strtolower($this->getInput("n")) === "y"){
|
||||
|
|
@ -142,35 +142,33 @@ LICENSE;
|
|||
}
|
||||
|
||||
$config->save();
|
||||
|
||||
|
||||
|
||||
echo "[*] ".$this->lang->ip_get."\n";
|
||||
|
||||
|
||||
$externalIP = Utils::getIP();
|
||||
$internalIP = gethostbyname(trim(`hostname`));
|
||||
|
||||
echo "[!] ".$this->lang->get("ip_warning", array("{{EXTERNAL_IP}}", "{{INTERNAL_IP}}"), array($externalIP, $internalIP))."\n";
|
||||
|
||||
echo "[!] ".$this->lang->get("ip_warning", ["{{EXTERNAL_IP}}", "{{INTERNAL_IP}}"], [$externalIP, $internalIP])."\n";
|
||||
echo "[!] ".$this->lang->ip_confirm;
|
||||
$this->getInput();
|
||||
}
|
||||
|
||||
|
||||
private function endWizard(){
|
||||
echo "[*] ".$this->lang->you_have_finished."\n";
|
||||
echo "[*] ".$this->lang->pocketmine_plugins."\n";
|
||||
echo "[*] ".$this->lang->pocketmine_will_start."\n\n\n";
|
||||
sleep(4);
|
||||
}
|
||||
|
||||
|
||||
private function getInput($default = ""){
|
||||
$input = trim(fgets(STDIN));
|
||||
return $input === "" ? $default:$input;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class InstallerLang{
|
||||
public static $languages = array(
|
||||
public static $languages = [
|
||||
"ru" => "Pyccĸий",
|
||||
"en" => "English",
|
||||
"es" => "Español",
|
||||
|
|
@ -180,7 +178,7 @@ LICENSE;
|
|||
//"vi" => "Tiếng Việt",
|
||||
"ko" => "한국어",
|
||||
"fr" => "Français",
|
||||
"it" => "Italiano",
|
||||
"it" => "Italiano",
|
||||
//"lv" => "Latviešu",
|
||||
"nl" => "Nederlands",
|
||||
//"pt" => "Português",
|
||||
|
|
@ -189,8 +187,8 @@ LICENSE;
|
|||
"tr" => "Türkçe",
|
||||
"uk" => "Український"
|
||||
//"et" => "Eesti",
|
||||
);
|
||||
private $texts = array();
|
||||
];
|
||||
private $texts = [];
|
||||
private $lang;
|
||||
private $langfile;
|
||||
public function __construct($lang = ""){
|
||||
|
|
@ -200,7 +198,7 @@ LICENSE;
|
|||
}else{
|
||||
$l = glob(FILE_PATH."src/lang/Installer/".$lang."_*.ini");
|
||||
if(count($l) > 0){
|
||||
$files = array();
|
||||
$files = [];
|
||||
foreach($l as $file){
|
||||
$files[$file] = filesize($file);
|
||||
}
|
||||
|
|
@ -215,32 +213,32 @@ LICENSE;
|
|||
$this->langfile = FILE_PATH."src/lang/Installer/en.ini";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->loadLang(FILE_PATH."src/lang/Installer/en.ini", "en");
|
||||
if($this->lang !== "en"){
|
||||
$this->loadLang($this->langfile, $this->lang);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getLang(){
|
||||
return ($this->lang);
|
||||
}
|
||||
|
||||
|
||||
public function loadLang($langfile, $lang = "en"){
|
||||
$this->texts[$lang] = array();
|
||||
$texts = explode("\n", str_replace(array("\r", "\/\/"), array("", "//"), file_get_contents($langfile)));
|
||||
$this->texts[$lang] = [];
|
||||
$texts = explode("\n", str_replace(["\r", "\/\/"], ["", "//"], file_get_contents($langfile)));
|
||||
foreach($texts as $line){
|
||||
$line = trim($line);
|
||||
if($line === ""){
|
||||
continue;
|
||||
}
|
||||
$line = explode("=", $line);
|
||||
$this->texts[$lang][array_shift($line)] = str_replace(array("\\n", "\\N",), "\n", implode("=", $line));
|
||||
$this->texts[$lang][array_shift($line)] = str_replace(["\\n", "\\N",], "\n", implode("=", $line));
|
||||
}
|
||||
}
|
||||
|
||||
public function get($name, $search = array(), $replace = array()){
|
||||
|
||||
public function get($name, $search = [], $replace = []){
|
||||
if(!isset($this->texts[$this->lang][$name])){
|
||||
if($this->lang !== "en" and isset($this->texts["en"][$name])){
|
||||
return $this->texts["en"][$name];
|
||||
|
|
@ -253,10 +251,10 @@ LICENSE;
|
|||
return $this->texts[$this->lang][$name];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function __get($name){
|
||||
return $this->get($name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/***REM_END***/
|
||||
|
|
|
|||
|
|
@ -12,10 +12,6 @@ class FallableBlock extends SolidBlock{
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param int $face
|
||||
* @param int $fx
|
||||
* @param int $fy
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ class LiquidBlock extends TransparentBlock{
|
|||
return match(static::$blockID){
|
||||
WATER, STILL_WATER => $id == WATER || $id == STILL_WATER ? $meta : -1,
|
||||
LAVA, STILL_LAVA => $id == LAVA || $id == STILL_LAVA ? $meta : -1,
|
||||
default=> -1
|
||||
default => -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){
|
||||
static::updateLiquid($level, $x, $y, $z);
|
||||
}
|
||||
|
|
@ -40,10 +40,10 @@ class LiquidBlock extends TransparentBlock{
|
|||
$f = ($meta + 1) / 9;
|
||||
return $f;
|
||||
}
|
||||
|
||||
|
||||
public static function getRenderedDepth(Level $level, $x, $y, $z){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
|
||||
|
||||
$cond = match($id){
|
||||
WATER, STILL_WATER => static::$blockID == WATER || static::$blockID == STILL_WATER,
|
||||
LAVA, STILL_LAVA => static::$blockID == LAVA || static::$blockID == STILL_LAVA,
|
||||
|
|
@ -52,23 +52,23 @@ class LiquidBlock extends TransparentBlock{
|
|||
if(!$cond) return -1;
|
||||
return $meta >= 8 ? 0 : $meta;
|
||||
}
|
||||
|
||||
|
||||
public static function shouldRenderFace(Level $level, $x, $y, $z, $face){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
if($id == ICE) return false;
|
||||
if((($id == WATER || $id == STILL_WATER) && (static::$blockID == WATER || static::$blockID == STILL_WATER))) return false;
|
||||
if((($id == LAVA || $id == STILL_LAVA) && (static::$blockID == LAVA || static::$blockID == STILL_LAVA))) return false;
|
||||
|
||||
|
||||
if($face == 1) return true;
|
||||
return StaticBlock::getIsSolid($id);
|
||||
//return parent::shouldRenderFace($level, $x, $y, $z, $face);
|
||||
}
|
||||
|
||||
|
||||
public static function getFlow(Level $level, $x, $y, $z){
|
||||
$flowVector = new Vector3(0, 0, 0);
|
||||
$v6 = static::getRenderedDepth($level, $x, $y, $z);
|
||||
|
||||
|
||||
for($v7 = 0; $v7 < 4; ++$v7){
|
||||
$v8 = $x;
|
||||
$v10 = $z;
|
||||
|
|
@ -86,12 +86,12 @@ class LiquidBlock extends TransparentBlock{
|
|||
++$v10;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$v11 = static::getRenderedDepth($level, $v8, $y, $v10);
|
||||
if($v11 < 0){
|
||||
if(!StaticBlock::getIsSolid($level->level->getBlockID($v8, $y, $v10))){ //TODO material.blocksMovement
|
||||
$v11 = static::getRenderedDepth($level, $v8, $y - 1, $v10);
|
||||
|
||||
|
||||
if($v11 >= 0){
|
||||
$v12 = $v11 - ($v6 - 8);
|
||||
$flowVector->x += ($v8 - $x) * $v12;
|
||||
|
|
@ -99,29 +99,29 @@ class LiquidBlock extends TransparentBlock{
|
|||
$flowVector->z += ($v10 - $z) * $v12;
|
||||
}
|
||||
}
|
||||
}else if($v11 >= 0){
|
||||
}elseif($v11 >= 0){
|
||||
$v12 = $v11 - $v6;
|
||||
$flowVector->x += ($v8 - $x) * $v12;
|
||||
$flowVector->y += ($y - $y) * $v12;
|
||||
$flowVector->z += ($v10 - $z) * $v12;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$meta = $level->level->getBlockDamage($x, $y, $z);
|
||||
|
||||
|
||||
if($meta >= 8){
|
||||
$v13 = //TODO more vanilla way to do it
|
||||
static::shouldRenderFace($level, $x, $y, $z - 1, 2) ||
|
||||
static::shouldRenderFace($level, $x, $y, $z + 1, 3) ||
|
||||
static::shouldRenderFace($level, $x - 1, $y, $z, 4) ||
|
||||
static::shouldRenderFace($level, $x + 1, $y, $z, 5) ||
|
||||
|
||||
|
||||
static::shouldRenderFace($level, $x, $y + 1, $z - 1, 2) ||
|
||||
static::shouldRenderFace($level, $x, $y + 1, $z + 1, 3) ||
|
||||
static::shouldRenderFace($level, $x - 1, $y + 1, $z, 4) ||
|
||||
static::shouldRenderFace($level, $x + 1, $y + 1, $z, 5)
|
||||
;
|
||||
|
||||
|
||||
if($v13){
|
||||
$ln = $flowVector->length();
|
||||
if($ln){
|
||||
|
|
@ -141,37 +141,37 @@ class LiquidBlock extends TransparentBlock{
|
|||
}else{
|
||||
$flowVector->x = $flowVector->y = $flowVector->z = 0;
|
||||
}
|
||||
|
||||
|
||||
return $flowVector;
|
||||
}
|
||||
|
||||
|
||||
public static function addVelocityToEntity(Level $level, $x, $y, $z, Entity $entity, Vector3 $velocityVector){
|
||||
$flow = static::getFlow($level, $x, $y, $z);
|
||||
$velocityVector->x += $flow->x * 0.5;
|
||||
$velocityVector->y += $flow->y * 0.5;
|
||||
$velocityVector->z += $flow->z * 0.5;
|
||||
}
|
||||
|
||||
|
||||
public static function getTickDelay(){
|
||||
throw new RuntimeException("If you see this, something bad happened");
|
||||
}
|
||||
|
||||
|
||||
public static function updateLiquid(Level $level, $x, $y, $z){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
if($id != LAVA && $id != STILL_LAVA) return;
|
||||
|
||||
|
||||
$zNeg = $level->level->getBlockID($x, $y, $z - 1);
|
||||
$zPos = $level->level->getBlockID($x, $y, $z + 1);
|
||||
$xNeg = $level->level->getBlockID($x - 1, $y, $z);
|
||||
$xPos = $level->level->getBlockID($x + 1, $y, $z);
|
||||
$yPos = $level->level->getBlockID($x, $y + 1, $z);
|
||||
|
||||
|
||||
if(
|
||||
$zNeg == WATER || $zNeg == STILL_WATER
|
||||
|| $zPos == WATER || $zPos == STILL_WATER
|
||||
|| $xNeg == WATER || $xNeg == STILL_WATER
|
||||
|| $xPos == WATER || $xPos == STILL_WATER
|
||||
|| $yPos == WATER || $yPos == STILL_WATER
|
||||
|| $zPos == WATER || $zPos == STILL_WATER
|
||||
|| $xNeg == WATER || $xNeg == STILL_WATER
|
||||
|| $xPos == WATER || $xPos == STILL_WATER
|
||||
|| $yPos == WATER || $yPos == STILL_WATER
|
||||
) {
|
||||
if($meta){
|
||||
//if($meta > 4) -> fizz & ret
|
||||
|
|
@ -179,17 +179,16 @@ class LiquidBlock extends TransparentBlock{
|
|||
}else{
|
||||
$replacement = OBSIDIAN;
|
||||
}
|
||||
|
||||
|
||||
$level->fastSetBlockUpdate($x, $y, $z, $replacement, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
public function getLiquidHeight(){
|
||||
return (($this->meta >= 8 ? 0 : $this->meta)+1) / 9;
|
||||
return (($this->meta >= 8 ? 0 : $this->meta) + 1) / 9;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ class SolidBlock extends GenericBlock{
|
|||
$this->isSolid = true;
|
||||
$this->isFullBlock = true;
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,26 +15,26 @@ class StairBlock extends TransparentBlock{
|
|||
}
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
|
||||
public static function isBlocksStairsID($id){
|
||||
return $id > 0 && StaticBlock::getBlock($id) instanceof StairBlock;
|
||||
}
|
||||
|
||||
|
||||
public static function isStairsAtXYZAndAreTheirMetadataSame(Level $level, $x, $y, $z, $meta){
|
||||
$block = $level->level->getBlock($x, $y, $z);
|
||||
return self::isBlocksStairsID($block[0]) && $block[1] == $meta;
|
||||
}
|
||||
|
||||
|
||||
public static function setBaseShape(Level $level, $x, $y, $z){
|
||||
$meta = $level->level->getBlockDamage($x, $y, $z);
|
||||
|
||||
|
||||
if(($meta & 4) != 0){
|
||||
return new AxisAlignedBB(0, 0.5, 0, 1, 1, 1);
|
||||
}else{
|
||||
return new AxisAlignedBB(0, 0, 0, 1, 0.5, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const DEAD_SAPCES = [
|
||||
[2, 6],
|
||||
[3, 7],
|
||||
|
|
@ -45,72 +45,72 @@ class StairBlock extends TransparentBlock{
|
|||
[0, 1],
|
||||
[4, 5]
|
||||
];
|
||||
|
||||
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
if(self::$complexState){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
$cid = self::$complexStateID;
|
||||
StaticBlock::setBlockBounds($id,
|
||||
StaticBlock::setBlockBounds($id,
|
||||
0.5 * ($cid % 2),
|
||||
0.5 * ((int)($cid / 2) % 2),
|
||||
0.5 * ((int)($cid / 4) % 2),
|
||||
0.5 * ((int) ($cid / 2) % 2),
|
||||
0.5 * ((int) ($cid / 4) % 2),
|
||||
0.5 + 0.5 * ($cid % 2),
|
||||
0.5 + 0.5 * ((int)($cid / 2) % 2),
|
||||
0.5 + 0.5 * ((int)($cid / 4) % 2)
|
||||
0.5 + 0.5 * ((int) ($cid / 2) % 2),
|
||||
0.5 + 0.5 * ((int) ($cid / 4) % 2)
|
||||
);
|
||||
}else{
|
||||
StaticBlock::setBlockBounds($level->level->getBlockID($x, $y, $z), 0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static $complexState = false;
|
||||
static $complexStateID = 0;
|
||||
public static function clip(Level $level, $x, $y, $z, Vector3 $start, Vector3 $end){
|
||||
$v7 = [];
|
||||
|
||||
|
||||
$v8 = $level->level->getBlockDamage($x, $y, $z);
|
||||
$v9 = $v8 & 3;
|
||||
$v10 = ($v8 & 4) == 4;
|
||||
$v11 = self::DEAD_SAPCES[$v9 + ($v10 ? 4 : 0)];
|
||||
self::$complexState = true;
|
||||
|
||||
|
||||
for($v12 = 0; $v12 < 8; ++$v12){
|
||||
self::$complexStateID = $v12;
|
||||
|
||||
|
||||
for($v15 = 0; $v15 < /*count($v11}*/ 2; ++$v15){
|
||||
$v16 = $v11[$v15];
|
||||
if($v16 == $v12){
|
||||
//wat
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$v7[$v12] = parent::clip($level, $x, $y, $z, $start, $end);
|
||||
}
|
||||
|
||||
|
||||
for($v14 = 0; $v14 < /*count($v11}*/ 2; ++$v14){
|
||||
$v15 = $v11[$v14];
|
||||
$v7[$v15] = null;
|
||||
}
|
||||
|
||||
|
||||
$v24 = 0;
|
||||
$v22 = null;
|
||||
|
||||
|
||||
for($v17 = 0; $v17 < count($v7); ++$v17){
|
||||
$v18 = $v7[$v17];
|
||||
|
||||
|
||||
if($v18 != null){
|
||||
$v19 = $v18->hitVector->distanceSquared($end);
|
||||
|
||||
|
||||
if($v19 > $v24){
|
||||
$v22 = $v18;
|
||||
$v24 = $v19;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $v22;
|
||||
}
|
||||
|
||||
|
||||
public static function setStepShape(Level $level, $x, $y, $z){
|
||||
$blockMeta = $level->level->getBlockDamage($x, $y, $z);
|
||||
$metaAnd3 = $blockMeta & 3;
|
||||
|
|
@ -120,13 +120,13 @@ class StairBlock extends TransparentBlock{
|
|||
$minY = 0.0;
|
||||
$maxY = 0.5;
|
||||
}
|
||||
|
||||
|
||||
$minX = 0;
|
||||
$maxX = 1;
|
||||
$minZ = 0;
|
||||
$maxZ = 0.5;
|
||||
$v13 = true;
|
||||
|
||||
|
||||
switch($metaAnd3){
|
||||
case 0:
|
||||
$minX = 0.5;
|
||||
|
|
@ -134,10 +134,10 @@ class StairBlock extends TransparentBlock{
|
|||
$blockNearby = $level->level->getBlock($x + 1, $y, $z);
|
||||
$blockIDNearby = $blockNearby[0];
|
||||
$blockMetaNearby = $blockNearby[1];
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($blockIDNearby) && (($blockMeta & 4) == ($blockMetaNearby & 4))){
|
||||
$blockMetaNearbyAnd3 = $blockMetaNearby & 3;
|
||||
|
||||
|
||||
if($blockMetaNearbyAnd3 == 3 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x, $y, $z + 1, $blockMeta)){
|
||||
$maxZ = 0.5;
|
||||
$v13 = false;
|
||||
|
|
@ -153,10 +153,10 @@ class StairBlock extends TransparentBlock{
|
|||
$blockNearby = $level->level->getBlock($x - 1, $y, $z);
|
||||
$blockIDNearby = $blockNearby[0];
|
||||
$blockMetaNearby = $blockNearby[1];
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($blockIDNearby) && (($blockMeta & 4) == ($blockMetaNearby & 4))){
|
||||
$blockMetaNearbyAnd3 = $blockMetaNearby & 3;
|
||||
|
||||
|
||||
if($blockMetaNearbyAnd3 == 3 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x, $y, $z + 1, $blockMeta)){
|
||||
$maxZ = 0.5;
|
||||
$v13 = false;
|
||||
|
|
@ -172,10 +172,10 @@ class StairBlock extends TransparentBlock{
|
|||
$blockNearby = $level->level->getBlock($x, $y, $z + 1);
|
||||
$blockIDNearby = $blockNearby[0];
|
||||
$blockMetaNearby = $blockNearby[1];
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($blockIDNearby) && (($blockMeta & 4) == ($blockMetaNearby & 4))){
|
||||
$blockMetaNearbyAnd3 = $blockMetaNearby & 3;
|
||||
|
||||
|
||||
if($blockMetaNearbyAnd3 == 1 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x + 1, $y, $z, $blockMeta)){
|
||||
$maxX = 0.5;
|
||||
$v13 = false;
|
||||
|
|
@ -191,7 +191,7 @@ class StairBlock extends TransparentBlock{
|
|||
$blockMetaNearby = $blockNearby[1];
|
||||
if(self::isBlocksStairsID($blockIDNearby) && (($blockMeta & 4) == ($blockMetaNearby & 4))){
|
||||
$blockMetaNearbyAnd3 = $blockMetaNearby & 3;
|
||||
|
||||
|
||||
if($blockMetaNearbyAnd3 == 1 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x + 1, $y, $z, $blockMeta)){
|
||||
$maxX = 0.5;
|
||||
$v13 = false;
|
||||
|
|
@ -203,34 +203,34 @@ class StairBlock extends TransparentBlock{
|
|||
break;
|
||||
}
|
||||
return [new AxisAlignedBB($minX, $minY, $minZ, $maxX, $maxY, $maxZ), $v13];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function setInnerPieceShape(Level $level, $x, $y, $z){
|
||||
$meta = $level->level->getBlockDamage($x, $y, $z);
|
||||
$metaAnd3 = $meta & 3;
|
||||
$minY = 0.5;
|
||||
$maxY = 1.0;
|
||||
|
||||
|
||||
if(($meta & 4) != 0){
|
||||
$minY = 0.0;
|
||||
$maxY = 0.5;
|
||||
}
|
||||
|
||||
|
||||
$minX = 0.0;
|
||||
$maxX = 0.5;
|
||||
$minZ = 0.5;
|
||||
$maxZ = 1.0;
|
||||
$v13 = false;
|
||||
|
||||
|
||||
switch($metaAnd3){
|
||||
case 0:
|
||||
$idNearby = $level->level->getBlockID($x - 1, $y, $z);
|
||||
$metaNearby = $level->level->getBlockDamage($x - 1, $y, $z);
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($idNearby) && ($meta & 4) == ($metaNearby & 4)){
|
||||
$metaNearbyAnd3 = $metaNearby & 3;
|
||||
|
||||
|
||||
if($metaNearbyAnd3 == 3 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x, $y, $z - 1, $meta)){
|
||||
$minZ = 0;
|
||||
$maxZ = 0.5;
|
||||
|
|
@ -245,7 +245,7 @@ class StairBlock extends TransparentBlock{
|
|||
case 1:
|
||||
$idNearby = $level->level->getBlockID($x + 1, $y, $z);
|
||||
$metaNearby = $level->level->getBlockDamage($x + 1, $y, $z);
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($idNearby) && ($meta & 4) == ($metaNearby & 4)){
|
||||
$minX = 0.5;
|
||||
$maxX = 1.0;
|
||||
|
|
@ -261,17 +261,17 @@ class StairBlock extends TransparentBlock{
|
|||
$v13 = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 2:
|
||||
$idNearby = $level->level->getBlockID($x, $y, $z - 1);
|
||||
$metaNearby = $level->level->getBlockDamage($x, $y, $z - 1);
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($idNearby) && ($meta & 4) == ($metaNearby & 4)){
|
||||
$minZ = 0;
|
||||
$maxZ = 0.5;
|
||||
$metaNearbyAnd3 = $metaNearby & 3;
|
||||
|
||||
|
||||
if($metaNearbyAnd3 == 1 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x - 1, $y, $z, $meta)){
|
||||
$v13 = true;
|
||||
}elseif($metaNearbyAnd3 == 0 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x + 1, $y, $z, $meta)){
|
||||
|
|
@ -280,16 +280,16 @@ class StairBlock extends TransparentBlock{
|
|||
$v13 = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 3:
|
||||
|
||||
|
||||
$idNearby = $level->level->getBlockID($x, $y, $z + 1);
|
||||
$metaNearby = $level->level->getBlockDamage($x, $y, $z + 1);
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($idNearby) && ($meta & 4) == ($metaNearby & 4)){
|
||||
$metaNearbyAnd3 = $metaNearby & 3;
|
||||
|
||||
|
||||
if($metaNearbyAnd3 == 1 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x - 1, $y, $z, $meta)){
|
||||
$v13 = true;
|
||||
}elseif($metaNearbyAnd3 == 0 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x + 1, $y, $z, $meta)){
|
||||
|
|
@ -300,10 +300,10 @@ class StairBlock extends TransparentBlock{
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return [new AxisAlignedBB($minX, $minY, $minZ, $maxX, $maxY, $maxZ), $v13];
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
$bbs = [self::setBaseShape($level, $x, $y, $z)->offset($x, $y, $z)];
|
||||
$ret = self::setStepShape($level, $x, $y, $z);
|
||||
|
|
@ -314,15 +314,11 @@ class StairBlock extends TransparentBlock{
|
|||
$bbs[] = $ret2[0]->offset($x, $y, $z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $bbs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param int $face
|
||||
* @param int $fx
|
||||
* @param int $fy
|
||||
|
|
@ -331,12 +327,12 @@ class StairBlock extends TransparentBlock{
|
|||
* @return bool|mixed
|
||||
*/
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$faces = array(
|
||||
$faces = [
|
||||
0 => 0,
|
||||
1 => 2,
|
||||
2 => 1,
|
||||
3 => 3,
|
||||
);
|
||||
];
|
||||
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
|
||||
if(($fy > 0.5 and $face !== 1) or $face === 0){
|
||||
$this->meta |= 0x04; //Upside-down stairs
|
||||
|
|
@ -346,18 +342,16 @@ class StairBlock extends TransparentBlock{
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ class TransparentBlock extends GenericBlock{
|
|||
$this->isFlowable = false;
|
||||
$this->isTransparent = true;
|
||||
$this->isReplaceable = false;
|
||||
$this->isPlaceable = true;
|
||||
$this->isPlaceable = true;
|
||||
$this->isSolid = true;
|
||||
$this->boundingBox->setBounds($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + 1);
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class LadderBlock extends TransparentBlock{
|
|||
public static $blockID;
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
|
||||
|
||||
switch($meta){
|
||||
case 2:
|
||||
StaticBlock::setBlockBounds($id, 0.0, 0.0, 0.875, 1.0, 1.0, 1.0);
|
||||
|
|
@ -18,9 +18,9 @@ class LadderBlock extends TransparentBlock{
|
|||
case 5:
|
||||
StaticBlock::setBlockBounds($id, 0, 0.0, 0.0, 0.125, 1.0, 1.0);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return parent::getAABB($level, $x, $y, $z);
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ class LadderBlock extends TransparentBlock{
|
|||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$side = $level->level->getBlockDamage($x, $y, $z);
|
||||
|
||||
|
||||
$attached = match($side){
|
||||
3 => $level->level->getBlockID($x, $y, $z - 1),
|
||||
2 => $level->level->getBlockID($x, $y, $z + 1),
|
||||
|
|
@ -58,7 +58,7 @@ class LadderBlock extends TransparentBlock{
|
|||
4 => $level->level->getBlockID($x + 1, $y, $z),
|
||||
default => 0 //TODO
|
||||
};
|
||||
|
||||
|
||||
if($attached == AIR){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem(LADDER, 0, 1));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
|
|
@ -66,8 +66,8 @@ class LadderBlock extends TransparentBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
}
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class SignPostBlock extends TransparentBlock{
|
|||
$this->breakTime = 1;
|
||||
$this->material = Material::$wood;
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if(($target->isSolid || $target->getID() === SIGN_POST || $target->getID() === WALL_SIGN || $target->getID() === GLASS_PANE || $target->getID() === IRON_BARS || $target->getID() === STONE_WALL) && $face !== 0){
|
||||
if(!isset(self::$faces[$face])){
|
||||
|
|
@ -34,7 +34,7 @@ class SignPostBlock extends TransparentBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if($level->level->getBlockID($x, $y - 1, $z) === AIR){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem(SIGN, 0, 1));
|
||||
|
|
@ -42,15 +42,15 @@ class SignPostBlock extends TransparentBlock{
|
|||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function onBreak(Item $item, Player $player){
|
||||
$this->level->setBlock($this, new AirBlock(), true, true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(SIGN, 0, 1),
|
||||
);
|
||||
}
|
||||
return [
|
||||
[SIGN, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -9,15 +9,15 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
|||
$this->material = Material::$decoration;
|
||||
$this->lightEmission = 14;
|
||||
}
|
||||
|
||||
|
||||
public function getMaxLightValue(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$side = $level->level->getBlockDamage($x, $y, $z);
|
||||
$attach = match($side){
|
||||
|
|
@ -25,9 +25,9 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
|||
2 => $level->level->getBlockID($x + 1, $y, $z),
|
||||
3 => $level->level->getBlockID($x, $y, $z - 1),
|
||||
4 => $level->level->getBlockID($x, $y, $z + 1),
|
||||
default => $level->level->getBlockID($x, $y - 1, $z)
|
||||
default => $level->level->getBlockID($x, $y - 1, $z)
|
||||
};
|
||||
|
||||
|
||||
if(StaticBlock::getIsTransparent($attach) && !($side === 0 && $attach === FENCE)){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem(TORCH, 0, 1));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
|
|
@ -36,13 +36,13 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
|||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($target->isTransparent === false and $face !== 0){
|
||||
$faces = array(
|
||||
$faces = [
|
||||
1 => 5,
|
||||
2 => 4,
|
||||
3 => 3,
|
||||
4 => 2,
|
||||
5 => 1,
|
||||
);
|
||||
];
|
||||
$this->meta = $faces[$face];
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
|
|
@ -54,8 +54,8 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
|||
return false;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -19,25 +19,25 @@ class TrapdoorBlock extends TransparentBlock{
|
|||
$id = $target->getID();
|
||||
return $id === SLAB || $id === GLOWSTONE || $id === SLAB || $id === WOOD_SLAB || (!$target->isTransparent || $target instanceof StairBlock);
|
||||
}
|
||||
|
||||
|
||||
public static function isOpen($meta){
|
||||
return ($meta >> 2) & 1;
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
static::updateShape($level, $x, $y, $z);
|
||||
return StaticBlock::getAABB(static::$blockID, $x, $y, $z);
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [static::getAABB($level, $x, $y, $z)];
|
||||
}
|
||||
|
||||
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
|
||||
|
||||
StaticBlock::setBlockBounds($id, 0.0, 0.0, 0.0, 1.0, 0.1875, 1.0);
|
||||
|
||||
|
||||
if(static::isOpen($meta)){
|
||||
$facing = $meta & 3;
|
||||
switch($facing){
|
||||
|
|
@ -58,24 +58,24 @@ class TrapdoorBlock extends TransparentBlock{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if(($this->canAttachTo($target)) and $face !== 0 and $face !== 1){
|
||||
$faces = array(
|
||||
$faces = [
|
||||
2 => 0,
|
||||
3 => 1,
|
||||
4 => 2,
|
||||
5 => 3,
|
||||
);
|
||||
];
|
||||
$this->meta = $faces[$face] & 0x03;
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$attach = match($level->level->getBlockDamage($x, $y, $z)){
|
||||
|
|
@ -85,13 +85,13 @@ class TrapdoorBlock extends TransparentBlock{
|
|||
3, 7 => $level->level->getBlockID($x - 1, $y, $z),
|
||||
default => 0
|
||||
};
|
||||
|
||||
|
||||
if($attach == AIR){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem(TRAPDOOR, 0, 1));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
$this->meta ^= 0x04;
|
||||
$this->level->setBlock($this, $this, true, false, true);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once("LiquidBlockDynamic.php"); //TODO class loader?
|
||||
|
||||
class LavaBlock extends LiquidBlockDynamic implements LightingBlock{
|
||||
|
|
@ -11,16 +12,16 @@ class LavaBlock extends LiquidBlockDynamic implements LightingBlock{
|
|||
$this->lightEmission = 15;
|
||||
$this->lightBlock = 255;
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$ret = $this->level->setBlock($this, $this, true, false, true);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public static function getTickDelay(){
|
||||
return 30;
|
||||
}
|
||||
|
||||
|
||||
public function getMaxLightValue(){
|
||||
return 15;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ class LiquidBlockStatic extends LiquidBlock{
|
|||
}
|
||||
public static $blockID = 0;
|
||||
//TODO: tick: try spread fire if lava
|
||||
|
||||
|
||||
public static function setDynamic(Level $level, $x, $y, $z){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
$dynamicID = $id - 1; //very unsafe
|
||||
$level->fastSetBlockUpdate($x, $y, $z, $dynamicID, $meta);
|
||||
$level->fastSetBlockUpdate($x, $y, $z, $dynamicID, $meta);
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$oldID = $level->level->getBlockID($x, $y, $z);
|
||||
static::updateLiquid($level, $x, $y, $z);
|
||||
|
|
@ -21,6 +21,5 @@ class LiquidBlockStatic extends LiquidBlock{
|
|||
static::setDynamic($level, $x, $y, $z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once("LiquidBlockStatic.php"); //TODO class loader?
|
||||
|
||||
class StillLavaBlock extends LiquidBlockStatic{
|
||||
|
|
@ -11,9 +12,9 @@ class StillLavaBlock extends LiquidBlockStatic{
|
|||
$this->lightEmission = 15;
|
||||
$this->lightBlock = 255;
|
||||
}
|
||||
|
||||
|
||||
public static function getTickDelay(){
|
||||
return 30;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
/***REM_START***/
|
||||
require_once("WaterBlock.php"); //TODO class loader?
|
||||
require_once("LiquidBlockStatic.php"); //TODO class loader?
|
||||
|
|
@ -16,7 +15,7 @@ class StillWaterBlock extends LiquidBlockStatic{
|
|||
$this->material = Material::$water;
|
||||
$this->lightBlock = 3;
|
||||
}
|
||||
|
||||
|
||||
public static function getTickDelay(){
|
||||
return 5;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
require_once("LiquidBlockDynamic.php"); //TODO class loader?
|
||||
|
||||
class WaterBlock extends LiquidBlockDynamic{
|
||||
public static $blockID = WATER;
|
||||
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WATER, $meta, "Water");
|
||||
$this->hardness = 500;
|
||||
|
|
@ -11,12 +12,12 @@ class WaterBlock extends LiquidBlockDynamic{
|
|||
$this->material = Material::$water;
|
||||
$this->lightBlock = 3;
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$ret = $this->level->setBlock($this, $this, true, false, true);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public static function getTickDelay(){
|
||||
return 5;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class FireBlock extends FlowableBlock implements LightingBlock{
|
|||
public static $blockID;
|
||||
public static $flammability = [];
|
||||
public static $fireCatchingChance = [];
|
||||
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(FIRE, $meta, "Fire");
|
||||
$this->isReplaceable = true;
|
||||
|
|
@ -22,39 +22,39 @@ class FireBlock extends FlowableBlock implements LightingBlock{
|
|||
self::$flammability[$blockID] = $flammability;
|
||||
self::$fireCatchingChance[$blockID] = $v;
|
||||
}
|
||||
|
||||
|
||||
public static function canBurn(Level $level, $x, $y, $z){
|
||||
return self::$flammability[$level->level->getBlockID($x, $y, $z)] > 0;
|
||||
}
|
||||
|
||||
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
if($level->level->getBlockID($x, $y - 1, $z) !== NETHERRACK){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function onPlace(Level $level, $x, $y, $z){
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdateXYZ($level, $x, $y, $z, BLOCK_UPDATE_SCHEDULED, 30);
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
public function getMaxLightValue(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$b = $level->level->getBlockID($x, $y - 1, $z);
|
||||
if(!StaticBlock::getIsSolid($b)) $level->fastSetBlockUpdate($x, $y, $z, 0, 0, true); //TODO more vanilla later?
|
||||
}
|
||||
|
||||
|
||||
public static function onUpdate(Level $level, $x, $y, $z, $type){
|
||||
if($type === BLOCK_UPDATE_SCHEDULED){
|
||||
$idBelow = $level->level->getBlockID($x, $y - 1, $z);
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
$alwaysBurn = $idBelow == NETHERRACK;
|
||||
|
||||
|
||||
if($meta < 15){
|
||||
$newMeta = $meta + 1; //TODO better formula
|
||||
if($newMeta > 15) $newMeta = 15;
|
||||
|
|
@ -68,20 +68,19 @@ class FireBlock extends FlowableBlock implements LightingBlock{
|
|||
}
|
||||
}
|
||||
$chance = self::$fireCatchingChance[$idBelow];
|
||||
|
||||
|
||||
if(mt_rand(0, 249) < $chance){
|
||||
//TODO ignite tnt
|
||||
$level->fastSetBlockUpdate($x, $y - 1, $z, 0, 0, true);
|
||||
goto REMOVE_FIRE;
|
||||
}
|
||||
|
||||
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdateXYZ($level, $x, $y, $z, BLOCK_UPDATE_SCHEDULED, 30); //TODO looks like it also adds mt_rand(0, 9) to it
|
||||
}
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
parent::place($item, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||
$this->level->scheduleBlockUpdate($this, 30, BLOCK_UPDATE_SCHEDULED);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ class NetherReactorBlock extends SolidBlock{
|
|||
$this->material = Material::$metal;
|
||||
$this->lightBlock = 255;
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
//if(($item->getID() === IRON_SWORD || $item->getID() === WOODEN_SWORD || $item->getID() === STONE_SWORD || $item->getID() === DIAMOND_SWORD || $item->getID() === GOLD_SWORD) /*&& $player->gamemode === 0*/){
|
||||
if($this->getMetadata() === 0 && $this->isCorrect($this->getX(),$this->getY(),$this->getZ()) && $this->getY() < 101 && NetherReactorBlock::$enableReactor){
|
||||
|
|
@ -19,58 +19,58 @@ class NetherReactorBlock extends SolidBlock{
|
|||
$this->meta = 1;
|
||||
$this->level->setBlock($this,$this);
|
||||
$server = ServerAPI::request();
|
||||
$server->schedule(40, array($this, "glow"), 1);
|
||||
$server->schedule(60, array($this, "glow"), 2);
|
||||
$server->schedule(80, array($this, "glow"), 3);
|
||||
$server->schedule(140, array($this, "glow"), 4);
|
||||
$server->schedule(200, array($this, "spawnItems"), [0,15,2,true]); //200
|
||||
$server->schedule(260, array($this, "spawnItems"), [0,15,"checkPigmen",true]);
|
||||
$server->schedule(300, array($this, "spawnItems"), [0,15,"checkPigmen",true]);
|
||||
$server->schedule(340, array($this, "spawnItems"), [11,20,"checkPigmen",false]);
|
||||
$server->schedule(400, array($this, "spawnItems"), [0,10,"checkPigmen",false]);
|
||||
$server->schedule(500, array($this, "spawnItems"), [17,32, "checkPigmen",false]); //500
|
||||
$server->schedule(580, array($this, "spawnItems"), [17,32, "checkPigmen",false]);
|
||||
$server->schedule(620, array($this, "spawnItems"), [1,32, "checkPigmen",false]);
|
||||
$server->schedule(660, array($this, "spawnItems"), [1,32,"checkPigmen",false]);
|
||||
$server->schedule(700, array($this, "spawnItems"), [1,32,"checkPigmen",false]);
|
||||
$server->schedule(860, array($this, "glow"), 5);
|
||||
$server->schedule(880, array($this, "glow"), 6);
|
||||
$server->schedule(900, array($this, "glow"), 7);
|
||||
$server->schedule(920, array($this, "destroy"));
|
||||
$server->schedule(40, [$this, "glow"], 1);
|
||||
$server->schedule(60, [$this, "glow"], 2);
|
||||
$server->schedule(80, [$this, "glow"], 3);
|
||||
$server->schedule(140, [$this, "glow"], 4);
|
||||
$server->schedule(200, [$this, "spawnItems"], [0,15,2,true]); //200
|
||||
$server->schedule(260, [$this, "spawnItems"], [0,15,"checkPigmen",true]);
|
||||
$server->schedule(300, [$this, "spawnItems"], [0,15,"checkPigmen",true]);
|
||||
$server->schedule(340, [$this, "spawnItems"], [11,20,"checkPigmen",false]);
|
||||
$server->schedule(400, [$this, "spawnItems"], [0,10,"checkPigmen",false]);
|
||||
$server->schedule(500, [$this, "spawnItems"], [17,32, "checkPigmen",false]); //500
|
||||
$server->schedule(580, [$this, "spawnItems"], [17,32, "checkPigmen",false]);
|
||||
$server->schedule(620, [$this, "spawnItems"], [1,32, "checkPigmen",false]);
|
||||
$server->schedule(660, [$this, "spawnItems"], [1,32,"checkPigmen",false]);
|
||||
$server->schedule(700, [$this, "spawnItems"], [1,32,"checkPigmen",false]);
|
||||
$server->schedule(860, [$this, "glow"], 5);
|
||||
$server->schedule(880, [$this, "glow"], 6);
|
||||
$server->schedule(900, [$this, "glow"], 7);
|
||||
$server->schedule(920, [$this, "destroy"]);
|
||||
return true;
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function destroy(){
|
||||
$this->level->setBlock(new Vector3($this->x, $this->y, $this->z),new NetherReactorBlock(2));
|
||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 0, 17, 16, 2, 34, 1, 0, 17, 1);
|
||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 1, 16, 1, 2, 34, 1, 0, 17, 16);
|
||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 3, 14, 10, 8, 34, 1, 3, 14, 1);
|
||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 4, 13, 1, 8, 34, 1, 3, 14, 10);
|
||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 5, 12, 6, 14, 34, 1, 5, 12, 1);
|
||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 6, 11, 1, 14, 34, 1, 5, 12, 16);
|
||||
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 0, 17, 16, 2, 34, 1, 0, 17, 1);
|
||||
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 1, 16, 1, 2, 34, 1, 0, 17, 16);
|
||||
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 3, 14, 10, 8, 34, 1, 3, 14, 1);
|
||||
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 4, 13, 1, 8, 34, 1, 3, 14, 10);
|
||||
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 5, 12, 6, 14, 34, 1, 5, 12, 1);
|
||||
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 6, 11, 1, 14, 34, 1, 5, 12, 16);
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return [[NETHER_REACTOR, 0, 1]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function decay($x, $y, $z, $aOne, $aTwo, $aThree, $bOne, $bTwo, $bThree, $cOne, $cTwo, $cThree) {
|
||||
for($a = $aOne; $a < $aTwo; $a += $aThree) {
|
||||
for($b = $bOne; $b < $bTwo; $b += $bThree) {
|
||||
for($c = $cOne; $c < $cTwo; $c += $cThree) {
|
||||
if ($this->level->level->getBlockID($x+$a, $y+$b, $z+$c) === NETHERRACK && lcg_value() > 0.75){
|
||||
$this->level->fastSetBlockUpdate($x+$a, $y+$b, $z+$c, 0, 0);
|
||||
if ($this->level->level->getBlockID($x + $a, $y + $b, $z + $c) === NETHERRACK && lcg_value() > 0.75){
|
||||
$this->level->fastSetBlockUpdate($x + $a, $y + $b, $z + $c, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function pigmenCheck($x,$y,$z) {
|
||||
$pigCount = 0;
|
||||
$server = ServerAPI::request();
|
||||
|
|
@ -92,28 +92,28 @@ class NetherReactorBlock extends SolidBlock{
|
|||
$forceAmount = $data[3];
|
||||
$server = ServerAPI::request();
|
||||
if(!$forceAmount){
|
||||
$spawnNumber = $minAmount + floor(lcg_value()*($maxAmount-$minAmount+1));
|
||||
$spawnNumber = $minAmount + floor(lcg_value() * ($maxAmount - $minAmount + 1));
|
||||
}
|
||||
else{
|
||||
$spawnNumber = $maxAmount;
|
||||
}
|
||||
for($i = 0; $i < $spawnNumber; $i++) {
|
||||
$randomRange = floor(lcg_value()*5+3);
|
||||
$shiftX = cos(floor(lcg_value()*360)*(pi()/180));
|
||||
$shiftZ = sin(floor(lcg_value()*360)*(pi()/180));
|
||||
$randomRange = floor(lcg_value() * 5 + 3);
|
||||
$shiftX = cos(floor(lcg_value() * 360) * (pi() / 180));
|
||||
$shiftZ = sin(floor(lcg_value() * 360) * (pi() / 180));
|
||||
if(Utils::chance(5)) $randomID = $this->rarePossibleLoot[array_rand($this->rarePossibleLoot)];
|
||||
else $randomID = $this->possibleLoot[array_rand($this->possibleLoot)];
|
||||
$server->api->entity->drop(new Position($x+($shiftX*$randomRange)+0.5, $y, $z+($shiftZ*$randomRange)+0.5, $this->level), BlockAPI::getItem($randomID, 0, 1));
|
||||
$server->api->entity->drop(new Position($x + ($shiftX * $randomRange) + 0.5, $y, $z + ($shiftZ * $randomRange) + 0.5, $this->level), BlockAPI::getItem($randomID, 0, 1));
|
||||
}
|
||||
for($i = 0; $i < $pigmen; $i++) {
|
||||
$randomRange = floor(lcg_value()*5+3);
|
||||
$shiftX = cos(floor(lcg_value()*360)*(pi()/180));
|
||||
$shiftZ = sin(floor(lcg_value()*360)*(pi()/180));
|
||||
$data = array(
|
||||
"x" => $x+($shiftX*$randomRange)+0.5,
|
||||
"y" => $y,
|
||||
"z" => $z+($shiftZ*$randomRange)+0.5,
|
||||
);
|
||||
$randomRange = floor(lcg_value() * 5 + 3);
|
||||
$shiftX = cos(floor(lcg_value() * 360) * (pi() / 180));
|
||||
$shiftZ = sin(floor(lcg_value() * 360) * (pi() / 180));
|
||||
$data = [
|
||||
"x" => $x + ($shiftX * $randomRange) + 0.5,
|
||||
"y" => $y,
|
||||
"z" => $z + ($shiftZ * $randomRange) + 0.5,
|
||||
];
|
||||
$e = $server->api->entity->add($this->level, ENTITY_MOB, MOB_PIGMAN, $data);
|
||||
$server->api->entity->spawnToAll($e);
|
||||
}
|
||||
|
|
@ -124,63 +124,63 @@ class NetherReactorBlock extends SolidBlock{
|
|||
$z = $this->z;
|
||||
switch($part){
|
||||
case 1:
|
||||
$this->level->setBlock(new Vector3($x, $y-1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y-1, $z+1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y-1, $z-1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y - 1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y - 1, $z + 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y - 1, $z - 1),new GlowingObsidianBlock);
|
||||
break;
|
||||
case 2:
|
||||
$this->level->setBlock(new Vector3($x+1, $y, $z+1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y, $z-1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y, $z+1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y, $z-1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y, $z + 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y, $z - 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y, $z + 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y, $z - 1),new GlowingObsidianBlock);
|
||||
break;
|
||||
case 3:
|
||||
$this->level->setBlock(new Vector3($x, $y+1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y+1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y+1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y+1, $z+1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y+1, $z-1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y + 1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y + 1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y + 1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y + 1, $z + 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y + 1, $z - 1),new GlowingObsidianBlock);
|
||||
break;
|
||||
case 4:
|
||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z+1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z-1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z+1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z-1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z + 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z - 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z + 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z - 1),new GlowingObsidianBlock);
|
||||
break;
|
||||
case 5:
|
||||
$this->level->setBlock(new Vector3($x, $y+1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y+1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y+1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y+1, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y+1, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y+1, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y+1, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y+1, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y+1, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y + 1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y + 1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y + 1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y + 1, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y + 1, $z - 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y + 1, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y + 1, $z - 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y + 1, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y + 1, $z - 1),new ObsidianBlock);
|
||||
break;
|
||||
case 6:
|
||||
$this->level->setBlock(new Vector3($x, $y, $z), new NetherReactorBlock(2));
|
||||
$this->level->setBlock(new Vector3($x+1, $y, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y, $z - 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y, $z - 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y, $z - 1),new ObsidianBlock);
|
||||
break;
|
||||
case 7:
|
||||
$this->level->setBlock(new Vector3($x, $y-1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y-1, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y-1, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y - 1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y - 1, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y - 1, $z - 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z - 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z - 1),new ObsidianBlock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -222,18 +222,18 @@ class NetherReactorBlock extends SolidBlock{
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private $possibleLoot = [
|
||||
GLOWSTONE_DUST, QUARTZ, CACTUS, SUGARCANE, BROWN_MUSHROOM, RED_MUSHROOM, PUMPKIN_SEEDS, MELON_SEEDS
|
||||
];
|
||||
|
||||
|
||||
private $rarePossibleLoot = [
|
||||
BOW, BED, BOWL, ARROW, WOODEN_DOOR, FEATHER, PAINTING, BONE, DANDELION
|
||||
];
|
||||
|
||||
|
||||
private $core = [
|
||||
-1 => ["GCG", "CCC", "GCG"],
|
||||
0 => ["C C", " R ", "C C",],
|
||||
1 =>[" C ", "CCC", " C "]
|
||||
1 => [" C ", "CCC", " C "]
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,18 +11,18 @@ class CakeBlock extends TransparentBlock{
|
|||
$this->breakTime = 0.5;
|
||||
$this->material = Material::$cake;
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
$data = $level->level->getBlockDamage($x, $y, $z);
|
||||
return [new AxisAlignedBB($x + (2*$data + 1) * 0.0625, $y, $z + 0.0625, $x + 0.9375, $y + 0.5, $z + 0.9375)];
|
||||
return [new AxisAlignedBB($x + (2 * $data + 1) * 0.0625, $y, $z + 0.0625, $x + 0.9375, $y + 0.5, $z + 0.9375)];
|
||||
}
|
||||
|
||||
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
[$id, $data] = $level->level->getBlock($x, $y, $z);
|
||||
|
||||
|
||||
StaticBlock::setBlockBounds($id, (2 * $data + 1) * 0.0625, 0.0, 0.0625, 0.9375, 0.5, 0.9375);
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() !== AIR){
|
||||
|
|
@ -31,17 +31,17 @@ class CakeBlock extends TransparentBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if($level->level->getBlockID($x, $y - 1, $z) == AIR){ //Replace with common break method
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($player->entity->getHealth() < 20){
|
||||
++$this->meta;
|
||||
|
|
@ -55,5 +55,5 @@ class CakeBlock extends TransparentBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -13,19 +13,19 @@ class ChestBlock extends TransparentBlock{
|
|||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [new AxisAlignedBB($x + 0.025, $y, $z + 0.025, $x + 0.975, $y + 0.95, $z + 0.975)];
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$server = ServerAPI::request();
|
||||
$faces = array(
|
||||
$faces = [
|
||||
0 => 4,
|
||||
1 => 2,
|
||||
2 => 5,
|
||||
3 => 3,
|
||||
);
|
||||
];
|
||||
|
||||
$chest = false;
|
||||
$this->meta = $faces[$player->entity->getDirection()];
|
||||
|
||||
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
if(($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)){
|
||||
continue;
|
||||
|
|
@ -42,22 +42,22 @@ class ChestBlock extends TransparentBlock{
|
|||
}
|
||||
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
$tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
|
||||
"Items" => array(),
|
||||
$tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, [
|
||||
"Items" => [],
|
||||
"id" => TILE_CHEST,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z
|
||||
));
|
||||
]);
|
||||
$server->api->tile->spawnToAll($tile);
|
||||
|
||||
|
||||
if($chest instanceof Tile){
|
||||
$chest->pairWith($tile);
|
||||
$tile->pairWith($chest);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function onBreak(Item $item, Player $player){
|
||||
$t = ServerAPI::request()->api->tile->get($this);
|
||||
if($t !== false){
|
||||
|
|
@ -66,48 +66,46 @@ class ChestBlock extends TransparentBlock{
|
|||
$this->level->setBlock($this, new AirBlock(), true, true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
$top = $this->getSide(1);
|
||||
if($top->isTransparent !== true){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$server = ServerAPI::request();
|
||||
$t = $server->api->tile->get($this);
|
||||
$chest = false;
|
||||
if($t !== false){
|
||||
$chest = $t;
|
||||
}else{
|
||||
$chest = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
|
||||
"Items" => array(),
|
||||
$chest = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, [
|
||||
"Items" => [],
|
||||
"id" => TILE_CHEST,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z
|
||||
));
|
||||
"z" => $this->z
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return true;
|
||||
}
|
||||
|
||||
$chest->openInventory($player);
|
||||
|
||||
$chest->openInventory($player);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
$drops = array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
$drops = [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
$t = ServerAPI::request()->api->tile->get($this);
|
||||
if($t !== false and $t->class === TILE_CHEST){
|
||||
for($s = 0; $s < CHEST_SLOTS; ++$s){
|
||||
$slot = $t->getSlot($s);
|
||||
if($slot->getID() > AIR and $slot->count > 0){
|
||||
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
|
||||
$drops[] = [$slot->getID(), $slot->getMetadata(), $slot->count];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
class CobwebBlock extends FlowableBlock{
|
||||
public static $blockID;
|
||||
public function __construct(){
|
||||
parent::__construct(COBWEB, 0, "Cobweb");
|
||||
parent::__construct(COBWEB, 0, "Cobweb");
|
||||
$this->isSolid = true;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 30;
|
||||
|
|
@ -11,11 +11,11 @@ class CobwebBlock extends FlowableBlock{
|
|||
$this->material = Material::$web;
|
||||
$this->lightBlock = 1;
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if ($item->isSword()){
|
||||
return [
|
||||
|
|
@ -24,11 +24,11 @@ class CobwebBlock extends FlowableBlock{
|
|||
}
|
||||
elseif ($item->isShears()){
|
||||
return [
|
||||
array(COBWEB, 0, 1),
|
||||
[COBWEB, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function onEntityCollidedWithBlock(Level $level, $x, $y, $z, Entity $entity){
|
||||
$entity->setInWeb();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,27 +9,27 @@ class FarmlandBlock extends TransparentBlock{
|
|||
$this->material = Material::$dirt;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(DIRT, 0, 1),
|
||||
);
|
||||
return [
|
||||
[DIRT, 0, 1],
|
||||
];
|
||||
}
|
||||
public function hasCrops(){
|
||||
//TODO vanilla 0.8.1 detection method
|
||||
$b = $this->getSide(1);
|
||||
return $b->isTransparent && $b->id != 0;
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
|
||||
}
|
||||
|
||||
|
||||
public static function fallOn(Level $level, $x, $y, $z, Entity $entity, $fallDistance){
|
||||
$rv = lcg_value();
|
||||
if($rv < ($fallDistance - 0.5)){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, DIRT, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
for($xx = $x-4; $xx <= $x+4; ++$xx){
|
||||
for($yy = $y; $yy <= $y+1; ++$yy){
|
||||
|
|
@ -71,7 +71,7 @@ class FarmlandBlock extends TransparentBlock{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if(!StaticBlock::getIsTransparent($level->level->getBlockID($x, $y + 1, $z))){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, DIRT, 0, true);
|
||||
|
|
|
|||
|
|
@ -7,21 +7,21 @@ class FenceGateBlock extends TransparentBlock{
|
|||
if($aabb == null) return [];
|
||||
return [$aabb];
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
$data = $level->level->getBlockDamage($x, $y, $z);
|
||||
|
||||
|
||||
if($data & 4){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if($data != 2 && $data != 0){
|
||||
return new AxisAlignedBB($x + 0.375, $y, $z, $x + 0.625, $y + 1.5, $z + 1.0);
|
||||
}else{
|
||||
return new AxisAlignedBB($x, $y, $z + 0.375, $x + 1, $y + 1.5, $z + 0.625);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(FENCE_GATE, $meta, "Fence Gate");
|
||||
$this->isActivable = true;
|
||||
|
|
@ -35,29 +35,29 @@ class FenceGateBlock extends TransparentBlock{
|
|||
$this->material = Material::$wood;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$faces = array(
|
||||
$faces = [
|
||||
0 => 3,
|
||||
1 => 0,
|
||||
2 => 1,
|
||||
3 => 2,
|
||||
);
|
||||
];
|
||||
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
public function onActivate(Item $item, Player $player){
|
||||
|
||||
|
||||
$meta = $this->meta;
|
||||
if(($meta & 4) != 0){
|
||||
$meta ^= 4;
|
||||
}else{
|
||||
$direction = ($player->entity->yaw * 4 / 360) + 0.5;
|
||||
$blockDirection = (int)$direction;
|
||||
$blockDirection = (int) $direction;
|
||||
if($direction < $blockDirection) --$blockDirection;
|
||||
$blockDirection &= 3;
|
||||
if(($meta & 3) == (($blockDirection + 2) & 3)){
|
||||
|
|
@ -65,7 +65,7 @@ class FenceGateBlock extends TransparentBlock{
|
|||
}
|
||||
$meta |= 4;
|
||||
}
|
||||
|
||||
|
||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, $this->id, $meta);
|
||||
$players = $this->level->players;
|
||||
unset($players[$player->CID]);
|
||||
|
|
|
|||
|
|
@ -12,33 +12,33 @@ class GlassPaneBlock extends TransparentBlock{
|
|||
}
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
$minX = 0.4375;
|
||||
$maxX = 0.5625;
|
||||
$minZ = 0.4375;
|
||||
$maxZ = 0.5625;
|
||||
|
||||
|
||||
$var9 = self::canConnectTo($level->level->getBlockID($x, $y, $z - 1));
|
||||
$var10 = self::canConnectTo($level->level->getBlockID($x, $y, $z + 1));
|
||||
$var11 = self::canConnectTo($level->level->getBlockID($x - 1, $y, $z));
|
||||
$var12 = self::canConnectTo($level->level->getBlockID($x + 1, $y, $z));
|
||||
|
||||
|
||||
if((!$var11 || !$var12) && ($var11 || $var12 || $var9 || $var10)){
|
||||
if($var11 && !$var12) $minX = 0;
|
||||
else if(!$var11 && $var12) $maxX = 1;
|
||||
elseif(!$var11 && $var12) $maxX = 1;
|
||||
}else{
|
||||
$minX = 0;
|
||||
$maxX = 1;
|
||||
}
|
||||
|
||||
|
||||
if((!$var9 || !$var10) && ($var11 || $var12 || $var9 || $var10)){
|
||||
if($var9 && !$var10) $minZ = 0;
|
||||
else if(!$var9 && $var10) $maxZ = 1;
|
||||
elseif(!$var9 && $var10) $maxZ = 1;
|
||||
}else{
|
||||
$minZ = 0;
|
||||
$maxZ = 1;
|
||||
}
|
||||
|
||||
|
||||
StaticBlock::setBlockBounds($id, $minX, 0, $minZ, $maxX, 1, $maxZ);
|
||||
}
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
|
|
@ -54,7 +54,7 @@ class GlassPaneBlock extends TransparentBlock{
|
|||
}else{
|
||||
$arr[] = $aabb->addMinMax(0, 0, 0.4375, 1, 1, 0.5625);
|
||||
}
|
||||
|
||||
|
||||
if((!$var8 || !$var9) && ($var10 || $var11 || $var8 || $var9)){
|
||||
if($var8 && !$var9) $arr[] = $aabb->addMinMax(0.4375, 0, 0, 0.5625, 1, 0.5);
|
||||
elseif(!$var8 && $var9) $arr[] = $aabb->addMinMax(0.4375, 0, 0.5, 0.5625, 1, 1);
|
||||
|
|
@ -63,14 +63,14 @@ class GlassPaneBlock extends TransparentBlock{
|
|||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
public static function canConnectTo($blockID) : bool{
|
||||
return StaticBlock::getIsSolid($blockID) || $blockID == GLASS_PANE || $blockID == GLASS;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(GLASS_PANE, 0, 0),
|
||||
);
|
||||
return [
|
||||
[GLASS_PANE, 0, 0],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -10,39 +10,39 @@ class IronBarsBlock extends TransparentBlock{
|
|||
$this->hardness = 30;
|
||||
$this->material = Material::$metal;
|
||||
}
|
||||
|
||||
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
$minX = 0.4375;
|
||||
$maxX = 0.5625;
|
||||
$minZ = 0.4375;
|
||||
$maxZ = 0.5625;
|
||||
|
||||
|
||||
$var9 = self::canConnectTo($level->level->getBlockID($x, $y, $z - 1));
|
||||
$var10 = self::canConnectTo($level->level->getBlockID($x, $y, $z + 1));
|
||||
$var11 = self::canConnectTo($level->level->getBlockID($x - 1, $y, $z));
|
||||
$var12 = self::canConnectTo($level->level->getBlockID($x + 1, $y, $z));
|
||||
|
||||
|
||||
if((!$var11 || !$var12) && ($var11 || $var12 || $var9 || $var10)){
|
||||
if($var11 && !$var12) $minX = 0;
|
||||
else if(!$var11 && $var12) $maxX = 1;
|
||||
elseif(!$var11 && $var12) $maxX = 1;
|
||||
}else{
|
||||
$minX = 0;
|
||||
$maxX = 1;
|
||||
}
|
||||
|
||||
|
||||
if((!$var9 || !$var10) && ($var11 || $var12 || $var9 || $var10)){
|
||||
if($var9 && !$var10) $minZ = 0;
|
||||
else if(!$var9 && $var10) $maxZ = 1;
|
||||
elseif(!$var9 && $var10) $maxZ = 1;
|
||||
}else{
|
||||
$minZ = 0;
|
||||
$maxZ = 1;
|
||||
}
|
||||
|
||||
|
||||
StaticBlock::setBlockBounds($id, $minX, 0, $minZ, $maxX, 1, $maxZ);
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
$var8 = self::canConnectTo($level->level->getBlockID($x, $y, $z - 1));
|
||||
$var9 = self::canConnectTo($level->level->getBlockID($x, $y, $z + 1));
|
||||
|
|
@ -56,7 +56,7 @@ class IronBarsBlock extends TransparentBlock{
|
|||
}else{
|
||||
$arr[] = $aabb->addMinMax(0, 0, 0.4375, 1, 1, 0.5625);
|
||||
}
|
||||
|
||||
|
||||
if((!$var8 || !$var9) && ($var10 || $var11 || $var8 || $var9)){
|
||||
if($var8 && !$var9) $arr[] = $aabb->addMinMax(0.4375, 0, 0, 0.5625, 1, 0.5);
|
||||
elseif(!$var8 && $var9) $arr[] = $aabb->addMinMax(0.4375, 0, 0.5, 0.5625, 1, 1);
|
||||
|
|
@ -65,9 +65,9 @@ class IronBarsBlock extends TransparentBlock{
|
|||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
public static function canConnectTo($blockID) : bool{
|
||||
return StaticBlock::getIsSolid($blockID) || $blockID == IRON_BARS || $blockID == GLASS;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -23,14 +23,14 @@ class IronDoorBlock extends DoorBlock{
|
|||
default => 25,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
array(IRON_DOOR, 0, 1),
|
||||
);
|
||||
return [
|
||||
[IRON_DOOR, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,24 +2,24 @@
|
|||
|
||||
abstract class RailBaseBlock extends FlowableBlock //TODO move some methods here
|
||||
{
|
||||
|
||||
|
||||
public static function isRailBlock(Level $l, $x, $y, $z){
|
||||
$id = $l->level->getBlockID($x, $y, $z);
|
||||
return $id === POWERED_RAIL || $id === RAIL;
|
||||
}
|
||||
|
||||
|
||||
public static function isRailID($id){
|
||||
return $id == POWERED_RAIL || $id == RAIL;
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() !== AIR and $down instanceof SolidBlock){
|
||||
|
||||
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
$logic = new RailLogic($this);
|
||||
$logic->place(false, true);
|
||||
|
|
@ -27,16 +27,16 @@ abstract class RailBaseBlock extends FlowableBlock //TODO move some methods here
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function updateState(){}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
if($id === POWERED_RAIL){
|
||||
$meta &= 7;
|
||||
}
|
||||
if(
|
||||
($level->level->getBlockID($x, $y - 1, $z) === 0) ||
|
||||
($level->level->getBlockID($x, $y - 1, $z) === 0) ||
|
||||
(($meta == 2) && $level->level->getBlockID($x + 1, $y, $z) === 0) ||
|
||||
(($meta == 3) && $level->level->getBlockID($x - 1, $y, $z) === 0) ||
|
||||
(($meta == 4) && $level->level->getBlockID($x, $y, $z - 1) === 0) ||
|
||||
|
|
@ -45,7 +45,7 @@ abstract class RailBaseBlock extends FlowableBlock //TODO move some methods here
|
|||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem($id, $meta, 1));
|
||||
}else{
|
||||
//TODO fix me pls $this->updateState();
|
||||
//TODO fix me pls $this->updateState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,21 +12,21 @@ class SlabBlock extends TransparentBlock{
|
|||
6 => "Quartz",
|
||||
7 => "",
|
||||
];
|
||||
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(SLAB, $meta, "Slab");
|
||||
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . self::$NAMES[$this->meta & 0x07] . " Slab";
|
||||
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . self::$NAMES[$this->meta & 0x07] . " Slab";
|
||||
if(($this->meta & 0x08) === 0x08){
|
||||
$this->isFullBlock = true;
|
||||
}else{
|
||||
$this->isFullBlock = false;
|
||||
}
|
||||
}
|
||||
$this->hardness = 30;
|
||||
$this->breakTime = 2;
|
||||
$this->material = Material::$stone;
|
||||
}
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
|
||||
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
|
||||
if($meta & 0x08 == 0x08){
|
||||
|
|
@ -37,11 +37,11 @@ class SlabBlock extends TransparentBlock{
|
|||
else StaticBlock::setBlockBounds($id, 0, 0.5, 0, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
self::updateShape($level, $x, $y, $z);
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
return [
|
||||
new AxisAlignedBB(
|
||||
$x + StaticBlock::$minXs[$id], $y + StaticBlock::$minYs[$id], $z + StaticBlock::$minZs[$id],
|
||||
|
|
@ -49,7 +49,7 @@ class SlabBlock extends TransparentBlock{
|
|||
)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$this->meta &= 0x07;
|
||||
if($face === 0){
|
||||
|
|
@ -105,14 +105,14 @@ class SlabBlock extends TransparentBlock{
|
|||
default => 10,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
array($this->id, $this->meta & 0x07, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, $this->meta & 0x07, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,45 +17,45 @@ class StoneWallBlock extends TransparentBlock{
|
|||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
public static function connectsTo(Level $level, $x, $y, $z){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
if($id == STONE_WALL || $id == FENCE_GATE) return true;
|
||||
if($id == 0) return false;
|
||||
|
||||
|
||||
if(StaticBlock::getIsSolid($id) && !StaticBlock::getIsTransparent($id)){ //XXX in vanilla it uses Material->isSolidBlocking() and Tile->isCubeShaped()
|
||||
return true; //XXX in vanilla it returns v7->material != Material::vegetable;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [static::getAABB($level, $x, $y, $z)];
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
static::updateShape($level, $x, $y, $z);
|
||||
StaticBlock::$maxYs[$level->level->getBlockID($x, $y, $z)] = 1.5;
|
||||
return parent::getAABB($level, $x, $y, $z);
|
||||
}
|
||||
|
||||
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
$zNeg = self::connectsTo($level, $x, $y, $z - 1);
|
||||
$zPos = self::connectsTo($level, $x, $y, $z + 1);
|
||||
$xNeg = self::connectsTo($level, $x - 1, $y, $z);
|
||||
$xPos = self::connectsTo($level, $x + 1, $y, $z);
|
||||
|
||||
|
||||
$minX = 0.25;
|
||||
$maxY = 1.0;
|
||||
$maxX = 0.75;
|
||||
|
||||
|
||||
$minZ = $zNeg ? 0 : 0.25;
|
||||
$maxZ = $zPos ? 1.0 : 0.75;
|
||||
|
||||
|
||||
if($xNeg) $minX = 0;
|
||||
if($xPos) $maxX = 1.0;
|
||||
|
||||
|
||||
if($zNeg){
|
||||
if($zPos && !$xNeg){
|
||||
if(!$xPos){
|
||||
|
|
@ -64,7 +64,7 @@ class StoneWallBlock extends TransparentBlock{
|
|||
$minX = 0.3125;
|
||||
}
|
||||
}
|
||||
}else if(!$zPos && $zNeg){
|
||||
}elseif(!$zPos && $zNeg){
|
||||
if($xPos){
|
||||
$maxY = 0.8125;
|
||||
$maxZ = 0.6875;
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ class WoodDoorBlock extends DoorBlock{
|
|||
$this->breakTime = 3;
|
||||
$this->material = Material::$wood;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(WOODEN_DOOR, 0, 1),
|
||||
);
|
||||
return [
|
||||
[WOODEN_DOOR, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ class BirchWoodStairsBlock extends StairBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -8,5 +8,5 @@ class BrickStairsBlock extends StairBlock{
|
|||
$this->hardness = 30;
|
||||
$this->material = Material::$stone;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -8,5 +8,5 @@ class CobblestoneStairsBlock extends StairBlock{
|
|||
$this->hardness = 30;
|
||||
$this->material = Material::$stone;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@ class JungleWoodStairsBlock extends StairBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -8,5 +8,5 @@ class NetherBricksStairsBlock extends StairBlock{
|
|||
$this->breakTime = 2;
|
||||
$this->material = Material::$stone;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -8,5 +8,5 @@ class QuartzStairsBlock extends StairBlock{
|
|||
$this->hardness = 4;
|
||||
$this->material = Material::$stone;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -8,5 +8,5 @@ class SandstoneStairsBlock extends StairBlock{
|
|||
$this->breakTime = 0.8;
|
||||
$this->material = Material::$stone;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@ class SpruceWoodStairsBlock extends StairBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -8,5 +8,5 @@ class StoneBrickStairsBlock extends StairBlock{
|
|||
$this->breakTime = 1.5;
|
||||
$this->material = Material::$stone;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -25,8 +25,8 @@ class WoodStairsBlock extends StairBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class CoalOreBlock extends SolidBlock{
|
|||
$this->material = Material::$stone;
|
||||
$this->lightBlock = 255;
|
||||
}
|
||||
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return 0.20;
|
||||
|
|
@ -23,15 +23,15 @@ class CoalOreBlock extends SolidBlock{
|
|||
default => 15,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
array(COAL, 0, 1),
|
||||
);
|
||||
return [
|
||||
[COAL, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class DiamondOreBlock extends SolidBlock{
|
|||
$this->material = Material::$stone;
|
||||
$this->lightBlock = 255;
|
||||
}
|
||||
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return 0.20;
|
||||
|
|
@ -20,14 +20,14 @@ class DiamondOreBlock extends SolidBlock{
|
|||
default => 15,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 4){
|
||||
return array(
|
||||
array(DIAMOND, 0, 1),
|
||||
);
|
||||
return [
|
||||
[DIAMOND, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ class GlowingRedstoneOreBlock extends SolidBlock implements LightingBlock{
|
|||
$this->lightBlock = 255;
|
||||
$this->lightEmission = 9;
|
||||
}
|
||||
|
||||
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, REDSTONE_ORE, 0);
|
||||
}
|
||||
|
||||
|
||||
public function getMaxLightValue(){
|
||||
return 9;
|
||||
}
|
||||
|
|
@ -29,15 +29,15 @@ class GlowingRedstoneOreBlock extends SolidBlock implements LightingBlock{
|
|||
default => 15,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 4){
|
||||
return array(
|
||||
array(REDSTONE_DUST, 0, mt_rand(4, 5)),
|
||||
);
|
||||
return [
|
||||
[REDSTONE_DUST, 0, mt_rand(4, 5)],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@ class GoldOreBlock extends SolidBlock{
|
|||
default => 15,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 4){
|
||||
return array(
|
||||
array(GOLD_ORE, 0, 1),
|
||||
);
|
||||
return [
|
||||
[GOLD_ORE, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ class IronOreBlock extends SolidBlock{
|
|||
default => 15,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= ItemTool::STONE_LEVEL){
|
||||
return array(
|
||||
array(IRON_ORE, 0, 1),
|
||||
);
|
||||
return [
|
||||
[IRON_ORE, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class LapisOreBlock extends SolidBlock{
|
|||
$this->material = Material::$stone;
|
||||
$this->lightBlock = 255;
|
||||
}
|
||||
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return 0.20;
|
||||
|
|
@ -24,12 +24,12 @@ class LapisOreBlock extends SolidBlock{
|
|||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 3){
|
||||
return array(
|
||||
array(DYE, 4, mt_rand(4, 8)),
|
||||
);
|
||||
return [
|
||||
[DYE, 4, mt_rand(4, 8)],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue