Compare commits

..

122 Commits

Author SHA1 Message Date
891eeff75a PocketMine 1.4.1 2015-03-17 18:01:58 +01:00
b4f62bf423 Fixed salling sand breaking on full BB partial blocks, closes #2770 2015-03-17 18:00:19 +01:00
7c76c1e3d7 Changed generator choosing logic, add proper preset if needed, fixes #2751 2015-03-17 18:00:19 +01:00
37bc1273ee Implemented double chest fix, closes #2744, fixes #2493 2015-03-17 18:00:19 +01:00
ffcdf49912 Allow plugins to cancel some kicks better, closes #2743 2015-03-17 18:00:18 +01:00
3e893ed0f7 Implemented hardcore banning, closes #2574 2015-03-17 18:00:18 +01:00
bfb7e8bb9e Merge pull request #2776 from PEMapModder/armor-fix
Implemented proportional armor modifier, applied armor in other damage types and consume armor when player is damaged
2015-03-17 17:57:28 +01:00
5067b96184 Merge pull request #2631 from 64FF00/master
TallGrass blocks should be only placed on grass blocks
2015-03-17 17:49:46 +01:00
cb2157ea80 Merge pull request #2614 from mmlmml1/master
Fixed for Iron bars and stonecutter
2015-03-17 17:36:01 +01:00
5b3e65345f Fixed a typo
`$source->isCancelled()` shouldn't be checked twice
2015-03-17 22:20:33 +08:00
8aa8ae5094 Implemented proportional armor modifier, applied armor in other damage types and consume armor when player is damaged 2015-03-17 20:04:59 +08:00
220d2b7bee Fixed NBT IntArray off-by-one reading 2015-03-15 16:40:44 +01:00
807107e581 Fixed constructors, default memory to -1, default async generator 2015-03-14 15:51:21 +01:00
9158cc4f19 Implemented Threaded ClassLoader, improves class loading while on different threads (no need to synchronize states) 2015-03-14 15:22:42 +01:00
2cd757d80a Fixed formatting of #2771 2015-03-13 09:26:45 +01:00
be20f61a93 Merge pull request #2771 from alejandroliu/ChunkCorruption
Fix some Chunk corruption due to Chunk overlap
2015-03-13 09:24:24 +01:00
59e9446fe5 Added another place where the same happens 2015-03-13 08:19:47 +01:00
4f47dac8ec Fix some Chunk corrumption due to Chunk overlap 2015-03-13 06:23:32 +01:00
b54c0835b7 Update RakLib 2015-03-12 18:40:12 +01:00
9ca3ad8971 Merge pull request #2767 from alejandroliu/blockskylight
Fixed some typos in Anvil
2015-03-10 09:57:48 +01:00
a644b46ec4 Fixed some typos 2015-03-09 23:57:53 +01:00
9d3f59fab6 Merge pull request #2750 from LDX-MCPE/patch-2
Fixed Dark Oak Fence's name
2015-03-09 11:10:17 +01:00
6309d4abf1 Fixed #2762 2015-03-08 15:53:01 +01:00
LDX
39291e4061 Fixed Dark Oak Fence's name 2015-03-02 16:14:31 -05:00
bb71a3c4a6 Added Entity->fastMove() for players and direct-controlled entities, improved speed checking 2015-02-22 21:16:05 +01:00
eb0525e892 Ignore spawn protection when no ops are set 2015-02-22 19:07:45 +01:00
f49db47b2e Added basic speed protection 2015-02-18 00:37:57 +01:00
3ff5e12302 Updated RakLib 2015-02-17 21:12:28 +01:00
99ad65ba44 Catch file saving exceptions 2015-02-15 20:01:47 +01:00
5f4f996efe Fixed #2599 2015-02-15 19:01:25 +01:00
21e0739845 Fixed #2598 2015-02-15 18:48:30 +01:00
3a157d0f02 Future workaround for #2626 2015-02-15 18:45:25 +01:00
8e56782138 Fixed #2619 BlockMetadataStore 2015-02-15 18:25:40 +01:00
116ede3679 Improved flight detection, added Entity->resetFallDistance(), closes #2632 2015-02-15 17:40:17 +01:00
7c0f5987d3 Fixed players getting kicked for flying when going through special blocks 2015-02-15 16:26:05 +01:00
547e152e40 Fixed #2615, closes #2634 invalid pull request 2015-02-15 15:12:33 +01:00
7905fbdd29 TallGrass blocks should be only placed on grass blocks 2015-02-12 19:33:44 +09:00
ae65701a23 Update IronBars.php 2015-02-05 20:11:08 +08:00
9134a69936 Merge pull request #2613 from 64FF00/master
OH-GAWD-WHY blame @PEMapModder
2015-02-05 12:57:44 +01:00
907fe8aff6 Fixed for wrong hardness and stonecutter 2015-02-05 19:05:00 +08:00
afa9acf22f OH-GAWD-WHY 2015-02-05 19:30:52 +09:00
9a5afff4ab Merge pull request #2612 from PEMapModder/patch-1
Added Location::__toString()
2015-02-05 11:06:52 +01:00
2f8c281a2e Added Location::__toString() 2015-02-05 18:00:25 +08:00
2096dace68 fixed for some bugs
Signed-off-by: mmlmml1 <mmlmml1@126.com>
2015-02-04 23:12:06 +08:00
8421985102 Merge pull request #2577 from Falkirks/master
Improve FallingSand behaviour
2015-01-28 08:48:01 +01:00
f63e859b3a Falling sand will become block when in contact with a Liquid
This replicates the behaviour of MCPE.
2015-01-27 17:09:31 -08:00
c56eb0b9df Merge pull request #2566 from sekjun9878/master
Fixed #2565
2015-01-26 19:01:22 +10:30
3f2e5bbef4 Fixed #2565 2015-01-26 18:59:56 +10:30
9886eb4768 Return on Level->getSafeSpawn() in case of invalid position 2015-01-25 10:23:04 +01:00
ea44eee5df Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2015-01-24 10:35:24 +01:00
9173f930ca Fixed #2541 server not saving chunks on chunk unloading 2015-01-24 10:35:08 +01:00
80b6a8ebaf Merge pull request #2555 from Striker209MPE/patch-6
Removed useless spawned check...
2015-01-24 10:29:18 +01:00
7c64a33389 Fixed #2557 2015-01-21 14:48:31 +01:00
9fac896f28 Removed useless spawned check...
because it has already be done before
2015-01-20 16:29:29 +01:00
5bd76e955c Added rotation transformations to remaining packet 2015-01-16 01:43:40 +01:00
63f1a50be4 Added new predictive flight protection 2015-01-14 23:47:01 +01:00
24c6cca664 Updated RakLib, fixed help message not showing command, added documentation to Plugin->getResource() 2015-01-14 17:23:16 +01:00
9fac990b19 Throw exception when RakLib crashes 2015-01-13 18:44:15 +01:00
e8e7938490 Fixed PHPRC env. variable being set 2015-01-13 17:25:52 +01:00
f6c4a726b3 Bump Minecraft version to 0.10.5 2015-01-12 20:00:11 +01:00
8eec5e6b5e Allow placing Snow Layers on top of solid transparent blocks 2015-01-12 02:18:02 +01:00
bd7fa71d7f Updated RakLib 2015-01-11 20:33:17 +01:00
7d406066a7 Added outdated event static properties 2015-01-11 19:37:21 +01:00
3e9196d224 Changed max speed per tick from 100 to 10 blocks 2015-01-11 17:31:34 +01:00
f30986d187 Block saving chunks too big 2015-01-11 15:48:08 +01:00
f8c144be31 Fixed #2529 2015-01-11 15:06:16 +01:00
c61e4adcf1 Improved chunk ticking a bit more 2015-01-08 23:27:14 +01:00
5a55040ab9 Improved chunk ticking 2015-01-08 23:22:47 +01:00
83360187c9 Removed fence classes, added fence damage (¬¬ Mojang) 2015-01-08 17:51:29 +01:00
9d97a940a6 Merge pull request #2517 from PEMapModder/patch-1
Fixed /timings off
2015-01-07 14:42:17 +01:00
cd21c28d46 Fixed /timings off
When issuing `/timings off`, the message `Please enable timings by typing /timings on` is sent to the issuer. This commit fixes this issue.
2015-01-07 17:34:45 +08:00
37fd0372cc Added GarbageCollectionTask, workaround for weird PHP behaviour when using --disable-ansi 2015-01-06 19:45:41 +01:00
ed02026815 Improved file resource usage 2015-01-06 19:04:24 +01:00
042a143dd6 Unload unused regions after 5 minutes 2015-01-06 18:59:21 +01:00
4b73dbd9f8 Fixed Flat generator on existing chunks, region issues 2015-01-06 18:46:18 +01:00
d4e4430df0 Fixed Entities being placed in recreated chunks 2015-01-06 18:45:08 +01:00
469ef84733 Fixed issue where plugins schedule a Player update before log in 2015-01-06 00:25:40 +01:00
efe75f2836 Catch more coruption issues in Region-based worlds, fixed first chunk being generated on an invalid sector 2015-01-06 00:11:38 +01:00
53f2f21f2d Fixed #2511 2015-01-05 16:15:57 +01:00
9c28f0a5be Decrease async worker task amount after crashed task 2015-01-05 02:41:14 +01:00
5bf5014b60 Added Async Task crash warning 2015-01-05 00:16:47 +01:00
f37e79b611 Added Level->getChunks(), fixed some Doc Comments 2015-01-04 23:16:03 +01:00
7a0118820c Improved chunk saving times by not marking it as changed when Players are added/removed 2015-01-04 23:07:08 +01:00
c8b5c023cd Fixed visual typo in /ban-ip, closes #2503 2015-01-04 09:36:07 +01:00
f9dd929e04 Fixed phar check 2015-01-03 16:49:10 +01:00
87970726e4 Added PlayerCreationEvent->setBaseClass() 2015-01-03 16:46:00 +01:00
1daf9a96a3 Added PlayerCreationEvent->setBaseClass() 2015-01-03 16:45:43 +01:00
6c8b33fcc8 Fixed PlayerCreationEvent 2015-01-03 16:41:14 +01:00
438591bd75 API 1.11.0, fixed phar check 2015-01-03 16:38:36 +01:00
7ef8edccf4 Added PlayerCreationEvent 2015-01-03 16:38:00 +01:00
074c8b876d Cleaned up code 2015-01-03 16:07:49 +01:00
f9762c870a Cleaned up BanEntry creation 2015-01-03 15:47:03 +01:00
4039895d3c Fixed #2489 2015-01-03 03:43:41 +01:00
d207a5daea WTF, ghost objects and why does this fix it? (and btw, fixes #2488) 2015-01-03 03:38:25 +01:00
8e3667c95b Fixed messages and default settings 2015-01-03 02:56:46 +01:00
0da628deca Fixed some crashes related to crashing 2015-01-02 19:19:34 +01:00
04bdb13103 Improved move offset check 2015-01-02 19:14:18 +01:00
e8ad828498 Catch exceptions on level generation 2015-01-02 18:56:27 +01:00
f46473bbe8 Removed all @mkdir() calls 2015-01-02 18:52:45 +01:00
692045d714 Improved threading and resource usage, new defaults 2015-01-02 18:46:39 +01:00
47cbf56725 Version bump 2015-01-02 07:04:20 +01:00
3de14d8ba6 Preparing release 2015-01-02 01:37:33 +01:00
5fffabe05b Fixed players not calculating onGround correctly 2015-01-02 01:22:33 +01:00
3128ae9736 Improved exception handling and trace creation 2015-01-01 22:50:45 +01:00
7be4e2fa81 Merge pull request #2438 from PocketMine/new-version-format
New release version format
2014-12-31 17:53:12 +01:00
95b305ce87 Detect really big corrupted chunks, closes #2471 2014-12-31 12:40:11 +01:00
767800662c Added chunk check on Level 2014-12-30 15:54:12 +01:00
fe32e6f5d0 Merge branch 'master' into new-version-format 2014-12-29 12:43:15 +01:00
2cec0d9f36 Improved Simplex 2D noise 2014-12-28 03:51:08 +01:00
d800a21bd4 Higher chunk defaults 2014-12-28 02:58:17 +01:00
8d9fbec4ce Fixed memory leak issues on chunk generation under 32-bit hosts, fixed issue with generated chunks not having a provider. Closes #2419, fixes #2308, closes #2421 2014-12-28 02:22:13 +01:00
ab72c32769 Improved Normal generator speed 2014-12-28 02:12:48 +01:00
346626305c Corrected fence crafting recipes, closes #2457 2014-12-28 01:49:42 +01:00
fafbd500e1 Added typehints to HelpCommand 2014-12-28 01:49:10 +01:00
2db2e8cfc4 Block IP addresses on ban-ip 2014-12-26 13:56:35 +01:00
854479180f Move Query exceptions to debug level > 1 2014-12-26 13:47:15 +01:00
902ba81e02 Added automatic/manual RakLib IP address, block addresses when exceptions are thrown 2014-12-26 13:33:41 +01:00
1ac17abec0 Fixed #2446 2014-12-24 23:00:11 +01:00
714ea54121 Players won't take damage 60 ticks after spawning / respawning. 2014-12-24 20:44:22 +01:00
aa992684ba Possible workaround for some PHP bug 2014-12-24 00:55:23 +01:00
0c58de86b7 New version format 2014-12-23 14:02:35 +01:00
7ecac019a9 Bitmask block state 2014-12-23 13:58:30 +01:00
190 changed files with 1519 additions and 2312 deletions

View File

@ -42,7 +42,10 @@ class CrashDump{
$this->time = time();
$this->server = $server;
$this->path = $this->server->getDataPath() . "CrashDump_" . date("D_M_j-H.i.s-T_Y", $this->time) . ".log";
$this->fp = fopen($this->path, "wb");
$this->fp = @fopen($this->path, "wb");
if(!is_resource($this->fp)){
throw new \RuntimeException("Could not create Crash Dump");
}
$this->data["time"] = $this->time;
$this->addLine($this->server->getName() . " Crash Dump " . date("D M j H:i:s T Y", $this->time));
$this->addLine();
@ -137,7 +140,7 @@ class CrashDump{
$error = $lastExceptionError;
}else{
$error = (array) error_get_last();
$error["trace"] = @getTrace(4);
$error["trace"] = @getTrace(3);
$errorConversion = [
E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING",

View File

@ -68,6 +68,7 @@ use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\inventory\SimpleTransactionGroup;
use pocketmine\inventory\StonecutterShapelessRecipe;
use pocketmine\item\Armor;
use pocketmine\item\Item;
use pocketmine\level\format\FullChunk;
use pocketmine\level\format\LevelProvider;
@ -147,6 +148,9 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
protected $moveToSend = [];
protected $motionToSend = [];
/** @var Vector3 */
public $speed = null;
public $blocked = false;
public $achievements = [];
public $lastCorrect;
@ -191,6 +195,9 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
private $inAction = false;
protected $inAirTicks = 0;
protected $lastSpeedTick = 0;
protected $speedTicks = 0;
protected $highSpeedTicks = 0;
private $needACK = [];
@ -210,6 +217,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
public function setBanned($value){
if($value === true){
$this->server->getNameBans()->addBan($this->getName(), null, null, null);
$this->kick("You have been banned");
}else{
$this->server->getNameBans()->remove($this->getName());
}
@ -314,6 +322,11 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
return false;
}
public function resetFallDistance(){
parent::resetFallDistance();
$this->inAirTicks = 0;
}
/**
* @return bool
*/
@ -660,6 +673,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->server->broadcastMessage($ev->getJoinMessage());
}
$this->noDamageTicks = 60;
$this->spawnToAll();
if($this->server->getUpdater()->hasUpdate() and $this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE)){
@ -1060,6 +1075,13 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
protected function processMovement($currentTick){
if($this->dead or !$this->spawned or !($this->newPosition instanceof Vector3)){
$diff = ($currentTick - $this->lastSpeedTick);
if($diff >= 10){
$this->speed = new Vector3(0, 0, 0);
}elseif($diff > 5 and $this->speedTicks < 20){
++$this->speedTicks;
}
return;
}
@ -1067,7 +1089,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$revert = false;
if($distanceSquared > 10000){
if($distanceSquared > 100){
$revert = true;
}else{
if($this->chunk === null or !$this->chunk->isGenerated()){
@ -1089,8 +1111,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$dy = $this->newPosition->y - $this->y;
$dz = $this->newPosition->z - $this->z;
//$this->inBlock = $this->checkObstruction($this->x, ($this->boundingBox->minY + $this->boundingBox->maxY) / 2, $this->z);
$this->move($dx, $dy, $dz);
$this->fastMove($dx, $dy, $dz);
$diffX = $this->x - $this->newPosition->x;
$diffZ = $this->z - $this->newPosition->z;
@ -1101,17 +1122,19 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$diff = $diffX ** 2 + $diffY ** 2 + $diffZ ** 2;
if(!$revert and !$this->isSleeping() and $this->isSurvival()){
if($diff > 0.0625){
$revert = true;
//$this->server->getLogger()->warning($this->getName()." moved wrongly!");
}elseif($diff > 0){
$this->x = $this->newPosition->x;
$this->y = $this->newPosition->y;
$this->z = $this->newPosition->z;
$radius = $this->width / 2;
$this->boundingBox->setBounds($this->x - $radius, $this->y + $this->ySize, $this->z - $radius, $this->x + $radius, $this->y + $this->height + $this->ySize, $this->z + $radius);
if($this->isSurvival()){
if(!$revert and !$this->isSleeping()){
if($diff > 0.0625){
$revert = true;
$this->server->getLogger()->warning($this->getName()." moved wrongly!");
}
}
}elseif($diff > 0){
$this->x = $this->newPosition->x;
$this->y = $this->newPosition->y;
$this->z = $this->newPosition->z;
$radius = $this->width / 2;
$this->boundingBox->setBounds($this->x - $radius, $this->y + $this->ySize, $this->z - $radius, $this->x + $radius, $this->y + $this->height + $this->ySize, $this->z + $radius);
}
}
@ -1154,6 +1177,20 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
}
}
$ticks = min(20, $currentTick - $this->lastSpeedTick + 0.5);
if($this->speedTicks > 0){
$ticks += $this->speedTicks;
}
$this->speed = $from->subtract($to)->divide($ticks);
$this->lastSpeedTick = $currentTick;
}elseif($distanceSquared == 0){
$this->speed = new Vector3(0, 0, 0);
$this->lastSpeedTick = $currentTick;
}
if($this->speedTicks > 0){
--$this->speedTicks;
}
if($revert){
@ -1176,13 +1213,14 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$pk->teleport = true;
$this->directDataPacket($pk);
$this->forceMovement = new Vector3($from->x, $from->y, $from->z);
$this->newPosition = null;
}else{
$this->forceMovement = null;
if($distanceSquared != 0 and $this->nextChunkOrderRun > 20){
$this->nextChunkOrderRun = 20;
}
}
$this->newPosition = null;
}
public function updateMovement(){
@ -1190,6 +1228,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
public function onUpdate($currentTick){
if(!$this->loggedIn){
return false;
}
if($this->dead === true and $this->spawned){
++$this->deadTicks;
if($this->deadTicks >= 10){
@ -1207,15 +1249,43 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->entityBaseTick(1);
if($this->speed and $this->forceMovement === null and $this->isSurvival()){
$speed = sqrt($this->speed->x ** 2 + $this->speed->z ** 2);
if($speed > 0.45){
$this->highSpeedTicks += $speed > 3 ? 2 : 1;
if($this->highSpeedTicks > 40 and !$this->server->getAllowFlight()){
if($this->kick("Flying is not enabled on this server")){
return false;
}
}elseif($this->highSpeedTicks >= 10 and $this->highSpeedTicks % 4 === 0){
$this->forceMovement = $this->getPosition();
}
}elseif($this->highSpeedTicks > 0){
if($speed < 22){
$this->highSpeedTicks = 0;
}else{
$this->highSpeedTicks--;
}
}
}
if($this->onGround){
$this->inAirTicks = 0;
}else{
if($this->inAirTicks > 100 and $this->isSurvival() and !$this->isSleeping() and $this->spawned and !$this->server->getAllowFlight()){
$this->kick("Flying is not enabled on this server");
return false;
}else{
++$this->inAirTicks;
if($this->inAirTicks > 10 and $this->isSurvival() and !$this->isSleeping()){
$expectedVelocity = (-$this->gravity) / $this->drag - ((-$this->gravity) / $this->drag) * exp(-$this->drag * ($this->inAirTicks - 2));
$diff = sqrt(abs($this->speed->y - $expectedVelocity));
if($diff > 0.6 and $expectedVelocity < $this->speed->y and !$this->server->getAllowFlight()){
if($this->inAirTicks < 100){
$this->setMotion(new Vector3(0, $expectedVelocity, 0));
}elseif($this->kick("Flying is not enabled on this server")){
return false;
}
}
}
++$this->inAirTicks;
}
foreach($this->level->getNearbyEntities($this->boundingBox->grow(1, 0.5, 1), $this) as $entity){
@ -1514,6 +1584,13 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
if($this->spawned === false or $this->dead === true){
break;
}
$packet->yaw %= 360;
$packet->pitch %= 360;
if($packet->yaw < 0){
$packet->yaw += 360;
}
$this->setRotation($packet->yaw, $this->pitch);
break;
case ProtocolInfo::MOVE_PLAYER_PACKET:
@ -1526,7 +1603,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->forceMovement = new Vector3($this->x, $this->y, $this->z);
}
if($this->forceMovement instanceof Vector3 and ($revert or $newPos->distanceSquared($this->forceMovement) > 0.04)){
if($this->forceMovement instanceof Vector3 and (($dist = $newPos->distanceSquared($this->forceMovement)) > 0.04 or $revert)){
$pk = new MovePlayerPacket();
$pk->eid = 0;
$pk->x = $this->forceMovement->x;
@ -1906,6 +1983,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1,
];
$points = 0;
if($this->distance($target) > 8){
$cancelled = true;
}elseif($target instanceof Player){
@ -1915,34 +1993,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$cancelled = true;
}
$armorValues = [
Item::LEATHER_CAP => 1,
Item::LEATHER_TUNIC => 3,
Item::LEATHER_PANTS => 2,
Item::LEATHER_BOOTS => 1,
Item::CHAIN_HELMET => 1,
Item::CHAIN_CHESTPLATE => 5,
Item::CHAIN_LEGGINGS => 4,
Item::CHAIN_BOOTS => 1,
Item::GOLD_HELMET => 1,
Item::GOLD_CHESTPLATE => 5,
Item::GOLD_LEGGINGS => 3,
Item::GOLD_BOOTS => 1,
Item::IRON_HELMET => 2,
Item::IRON_CHESTPLATE => 6,
Item::IRON_LEGGINGS => 5,
Item::IRON_BOOTS => 2,
Item::DIAMOND_HELMET => 3,
Item::DIAMOND_CHESTPLATE => 8,
Item::DIAMOND_LEGGINGS => 6,
Item::DIAMOND_BOOTS => 3,
];
$points = 0;
foreach($target->getInventory()->getArmorContents() as $index => $i){
if(isset($armorValues[$i->getId()])){
$points += $armorValues[$i->getId()];
}
}
$points = $target->getInventory()->getArmorPoints();
$damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
}
@ -1970,7 +2021,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
}
break;
case ProtocolInfo::ANIMATE_PACKET:
if($this->spawned === false or $this->dead === true){
@ -2001,6 +2051,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->fireTicks = 0;
$this->airTicks = 300;
$this->deadTicks = 0;
$this->noDamageTicks = 60;
$this->setHealth(20);
$this->dead = false;
@ -2569,6 +2620,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
if($ev->getDeathMessage() != ""){
$this->server->broadcast($ev->getDeathMessage(), Server::BROADCAST_CHANNEL_USERS);
}
if($this->server->isHardcore()){
$this->setBanned(true);
}
}
public function setHealth($amount){
@ -2607,8 +2662,24 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
parent::attack($damage, $source);
if($source instanceof EntityDamageEvent and $source->isCancelled()){
return;
if($source instanceof EntityDamageEvent){
if($source->isCancelled()){
return;
}
if($source->getDamage(EntityDamageEvent::MODIFIER_ARMOR) > 0){
for($i = 0; $i < 4; $i++){
$piece = $this->getInventory()->getArmorItem($i);
if($piece instanceof Armor){
$damage = $piece->getDamage();
if($damage >= $piece->getMaxDurability()){
$this->getInventory()->setArmorItem($i, Item::get(Item::AIR));
}else{
$piece->setDamage($damage + 1);
$this->getInventory()->setArmorItem($i, $piece);
}
}
}
}
}
if($this->getLastDamageCause() === $source){
@ -2617,6 +2688,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$pk->event = 2;
$this->dataPacket($pk);
}
}
public function getData(){ //TODO
@ -2652,7 +2725,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
$this->airTicks = 300;
$this->fallDistance = 0;
$this->resetFallDistance();
$this->orderChunks();
$this->nextChunkOrderRun = 0;
$this->forceMovement = new Vector3($this->x, $this->y, $this->z);

View File

@ -70,10 +70,10 @@ namespace pocketmine {
use pocketmine\utils\Utils;
use pocketmine\wizard\Installer;
const VERSION = "Alpha_1.4dev";
const API_VERSION = "1.9.0";
const VERSION = "1.4.1";
const API_VERSION = "1.11.0";
const CODENAME = "絶好(Zekkou)ケーキ(Cake)";
const MINECRAFT_VERSION = "v0.10.4 alpha";
const MINECRAFT_VERSION = "v0.10.5 alpha";
/*
* Startup code. Do not look at it, it may harm you.
@ -95,6 +95,7 @@ namespace pocketmine {
}
if(!class_exists("ClassLoader", false)){
require_once(\pocketmine\PATH . "src/spl/ThreadedFactory.php");
require_once(\pocketmine\PATH . "src/spl/ClassLoader.php");
require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
require_once(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
@ -103,7 +104,6 @@ namespace pocketmine {
$autoloader = new CompatibleClassLoader();
$autoloader->addPath(\pocketmine\PATH . "src");
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl");
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "raklib");
$autoloader->register(true);
@ -116,7 +116,7 @@ namespace pocketmine {
ini_set("display_startup_errors", 1);
ini_set("default_charset", "utf-8");
ini_set("memory_limit", "256M"); //Default
ini_set("memory_limit", -1);
define("pocketmine\\START_TIME", microtime(true));
$opts = getopt("", ["enable-ansi", "disable-ansi", "data:", "plugins:", "no-wizard", "enable-profiler"]);
@ -127,7 +127,9 @@ namespace pocketmine {
define("pocketmine\\ANSI", (Utils::getOS() !== "win" or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"]));
@mkdir(\pocketmine\DATA, 0777, true);
if(!file_exists(\pocketmine\DATA)){
mkdir(\pocketmine\DATA, 0777, true);
}
//Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone.
date_default_timezone_set("UTC");
@ -331,7 +333,7 @@ namespace pocketmine {
$args = $trace[$i]["params"];
}
foreach($args as $name => $value){
$params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . @strval($value)) . ", ";
$params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . (is_array($value) ? "Array()" : @strval($value))) . ", ";
}
}
$messages[] = "#$j " . (isset($trace[$i]["file"]) ? cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . substr($params, 0, -2) . ")";
@ -432,7 +434,7 @@ namespace pocketmine {
new Installer();
}
if(substr(__FILE__, 0, 7) !== "phar://"){
if(\Phar::running(true) === ""){
$logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production.");
}

View File

@ -86,6 +86,7 @@ use pocketmine\plugin\Plugin;
use pocketmine\plugin\PluginLoadOrder;
use pocketmine\plugin\PluginManager;
use pocketmine\scheduler\CallbackTask;
use pocketmine\scheduler\GarbageCollectionTask;
use pocketmine\scheduler\SendUsageTask;
use pocketmine\scheduler\ServerScheduler;
use pocketmine\tile\Chest;
@ -300,7 +301,7 @@ class Server{
* @return int
*/
public function getViewDistance(){
return max(56, $this->getProperty("chunk-sending.max-chunks", 96));
return max(56, $this->getProperty("chunk-sending.max-chunks", 256));
}
/**
@ -622,6 +623,16 @@ class Server{
$this->mainInterface->putRaw($address, $port, $payload);
}
/**
* Blocks an IP address from the main interface. Setting timeout to -1 will block it forever
*
* @param string $address
* @param int $timeout
*/
public function blockAddress($address, $timeout = 300){
$this->mainInterface->blockAddress($address, $timeout);
}
/**
* @param string $address
* @param int $port
@ -633,9 +644,13 @@ class Server{
$this->queryHandler->handle($address, $port, $payload);
}
}catch(\Exception $e){
if($this->logger instanceof MainLogger){
$this->logger->logException($e);
if(\pocketmine\DEBUG > 1){
if($this->logger instanceof MainLogger){
$this->logger->logException($e);
}
}
$this->blockAddress($address, 600);
}
//TODO: add raw packet events
}
@ -668,7 +683,7 @@ class Server{
$result = $this->getPlayerExact($name);
if($result === null){
return new OfflinePlayer($this, $name);
$result = new OfflinePlayer($this, $name);
}
return $result;
@ -796,8 +811,15 @@ class Server{
*/
public function saveOfflinePlayerData($name, Compound $nbtTag){
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->setData($nbtTag);
file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed());
try{
$nbt->setData($nbtTag);
file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed());
}catch(\Exception $e){
$this->logger->critical("Could not save player " . $name . ": " . $e->getMessage());
if(\pocketmine\DEBUG > 1 and $this->logger instanceof MainLogger){
$this->logger->logException($e);
}
}
}
/**
@ -1117,10 +1139,11 @@ class Server{
$seed = $seed === null ? Binary::readInt(@Utils::getRandomBytes(4, false)) : (int) $seed;
if($generator !== null and class_exists($generator) and is_subclass_of($generator, Generator::class)){
$generator = new $generator($options);
}else{
if(!isset($options["presey"])){
$options["preset"] = $this->getConfigString("generator-settings", "");
}
if(!($generator !== null and class_exists($generator, true) and is_subclass_of($generator, Generator::class))){
$generator = Generator::getGenerator($this->getLevelType());
}
@ -1128,14 +1151,22 @@ class Server{
$provider = LevelProviderManager::getProviderByName($providerName = "mcregion");
}
$path = $this->getDataPath() . "worlds/" . $name . "/";
/** @var \pocketmine\level\format\LevelProvider $provider */
$provider::generate($path, $name, $seed, $generator, $options);
try{
$path = $this->getDataPath() . "worlds/" . $name . "/";
/** @var \pocketmine\level\format\LevelProvider $provider */
$provider::generate($path, $name, $seed, $generator, $options);
$level = new Level($this, $name, $path, $provider);
$this->levels[$level->getId()] = $level;
$level = new Level($this, $name, $path, $provider);
$this->levels[$level->getId()] = $level;
$level->initLevel();
$level->initLevel();
}catch(\Exception $e){
$this->logger->error("Could not generate level \"" . $name . "\": " . $e->getMessage());
if($this->logger instanceof MainLogger){
$this->logger->logException($e);
}
return false;
}
$this->getPluginManager()->callEvent(new LevelInitEvent($level));
@ -1444,31 +1475,22 @@ class Server{
$this->autoloader = $autoloader;
$this->logger = $logger;
$this->filePath = $filePath;
@mkdir($dataPath . "worlds/", 0777);
@mkdir($dataPath . "players/", 0777);
@mkdir($pluginPath, 0777);
if(!file_exists($dataPath . "worlds/")){
mkdir($dataPath . "worlds/", 0777);
}
if(!file_exists($dataPath . "players/")){
mkdir($dataPath . "players/", 0777);
}
if(!file_exists($pluginPath)){
mkdir($pluginPath, 0777);
}
$this->dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR;
$this->pluginPath = realpath($pluginPath) . DIRECTORY_SEPARATOR;
$this->entityMetadata = new EntityMetadataStore();
$this->playerMetadata = new PlayerMetadataStore();
$this->levelMetadata = new LevelMetadataStore();
$this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM);
$this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM);
if(file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")){
@rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt");
}
@touch($this->dataPath . "banned-players.txt");
$this->banByName = new BanList($this->dataPath . "banned-players.txt");
$this->banByName->load();
@touch($this->dataPath . "banned-ips.txt");
$this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
$this->banByIP->load();
$this->consoleThreaded = new \Threaded();
$this->console = new CommandReader($this->consoleThreaded);
$this->console = new CommandReader();
$version = new VersionString($this->getPocketMineVersion());
$this->logger->info("Starting Minecraft: PE server version " . TextFormat::AQUA . $this->getVersion());
@ -1487,7 +1509,7 @@ class Server{
$this->properties = new Config($this->dataPath . "server.properties", Config::PROPERTIES, [
"motd" => "Minecraft: PE Server",
"server-port" => 19132,
"memory-limit" => "256M",
"memory-limit" => -1,
"white-list" => false,
"announce-player-achievements" => true,
"spawn-protection" => 16,
@ -1518,18 +1540,34 @@ class Server{
$this->rcon = new RCON($this, $this->getConfigString("rcon.password", ""), $this->getConfigInt("rcon.port", $this->getPort()), ($ip = $this->getIp()) != "" ? $ip : "0.0.0.0", $this->getConfigInt("rcon.threads", 1), $this->getConfigInt("rcon.clients-per-thread", 50));
}
$this->entityMetadata = new EntityMetadataStore();
$this->playerMetadata = new PlayerMetadataStore();
$this->levelMetadata = new LevelMetadataStore();
$this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM);
$this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM);
if(file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")){
@rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt");
}
@touch($this->dataPath . "banned-players.txt");
$this->banByName = new BanList($this->dataPath . "banned-players.txt");
$this->banByName->load();
@touch($this->dataPath . "banned-ips.txt");
$this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
$this->banByIP->load();
$this->maxPlayers = $this->getConfigInt("max-players", 20);
$this->setAutoSave($this->getConfigBoolean("auto-save", true));
if(($memory = str_replace("B", "", strtoupper($this->getConfigString("memory-limit", "256M")))) !== false){
if(($memory = str_replace("B", "", strtoupper($this->getConfigString("memory-limit", -1)))) !== false and $memory > 1){
$value = ["M" => 1, "G" => 1024];
$real = ((int) substr($memory, 0, -1)) * $value[substr($memory, -1)];
if($real < 128){
$this->logger->warning($this->getName() . " may not work right with less than 128MB of RAM", true, true, 0);
$this->logger->warning($this->getName() . " may not work right with less than 128MB of RAM");
}
@ini_set("memory_limit", $memory);
}else{
$this->setConfigString("memory-limit", "256M");
$this->setConfigString("memory-limit", -1);
}
if($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3){
@ -1658,6 +1696,8 @@ class Server{
$this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask([$this, "doLevelGC"]), $this->getProperty("chunk-gc.period-in-ticks", 600), $this->getProperty("chunk-gc.period-in-ticks", 600));
}
$this->scheduler->scheduleRepeatingTask(new GarbageCollectionTask(), 900);
$this->enablePlugins(PluginLoadOrder::POSTWORLD);
$this->start();
@ -1665,7 +1705,7 @@ class Server{
/**
* @param $message
* @param Player[]|null $recipients
* @param Player[] $recipients
*
* @return int
*/
@ -1673,6 +1713,8 @@ class Server{
if(!is_array($recipients)){
return $this->broadcast($message, self::BROADCAST_CHANNEL_USERS);
}
/** @var Player[] $recipients */
foreach($recipients as $recipient){
$recipient->sendMessage($message);
}
@ -1810,7 +1852,7 @@ class Server{
$this->properties->reload();
$this->maxPlayers = $this->getConfigInt("max-players", 20);
if(($memory = str_replace("B", "", strtoupper($this->getConfigString("memory-limit", "256M")))) !== false){
if(($memory = str_replace("B", "", strtoupper($this->getConfigString("memory-limit", -1)))) !== false and $memory > 1){
$value = ["M" => 1, "G" => 1024];
$real = ((int) substr($memory, 0, -1)) * $value[substr($memory, -1)];
if($real < 256){
@ -1818,7 +1860,7 @@ class Server{
}
@ini_set("memory_limit", $memory);
}else{
$this->setConfigString("memory-limit", "256M");
$this->setConfigString("memory-limit", -1);
}
if($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3){
@ -1830,6 +1872,9 @@ class Server{
$this->reloadWhitelist();
$this->operators->reload();
foreach($this->getIPBans()->getEntries() as $entry){
$this->blockAddress($entry->getName(), -1);
}
$this->pluginManager->registerInterface(PharPluginLoader::class);
$this->pluginManager->loadPlugins($this->pluginPath);
@ -1907,6 +1952,9 @@ class Server{
}
foreach($this->getIPBans()->getEntries() as $entry){
$this->blockAddress($entry->getName(), -1);
}
if($this->getProperty("settings.send-usage", true) !== false){
$this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask([$this, "sendUsage"]), 6000, 6000);
@ -1953,16 +2001,6 @@ class Server{
}
}
public function checkMemory(){
//TODO
$info = $this->debugInfo();
$data = $info["memory_usage"] . "," . $info["players"] . "," . $info["entities"];
$i = count($this->memoryStats) - 1;
if($i < 0 or $this->memoryStats[$i] !== $data){
$this->memoryStats[] = $data;
}
}
public function exceptionHandler(\Exception $e, $trace = null){
if($e === null){
return;
@ -1970,6 +2008,10 @@ class Server{
global $lastError;
if($trace === null){
$trace = $e->getTrace();
}
$errstr = $e->getMessage();
$errfile = $e->getFile();
$errno = $e->getCode();
@ -1992,7 +2034,7 @@ class Server{
"fullFile" => $e->getFile(),
"file" => $errfile,
"line" => $errline,
"trace" => @getTrace($trace === null ? 3 : 0, $trace)
"trace" => @getTrace(1, $trace)
];
global $lastExceptionError, $lastError;
@ -2010,7 +2052,12 @@ class Server{
ini_set("error_reporting", 0);
ini_set("memory_limit", -1); //Fix error dump not dumped on memory problems
$this->logger->emergency("An unrecoverable error has occurred and the server has crashed. Creating a crash dump");
$dump = new CrashDump($this);
try{
$dump = new CrashDump($this);
}catch(\Exception $e){
$this->logger->critical("Could not create Crash Dump: " . $e->getMessage());
return;
}
$this->logger->emergency("Please submit the \"" . $dump->getPath() . "\" file to the Bug Reporting page. Give as much info as you can.");
@ -2077,7 +2124,7 @@ class Server{
$level->doTick($currentTick);
}catch(\Exception $e){
$this->logger->critical("Could not tick level " . $level->getName() . ": " . $e->getMessage());
if($this->logger instanceof MainLogger){
if(\pocketmine\DEBUG > 1 and $this->logger instanceof MainLogger){
$this->logger->logException($e);
}
}
@ -2110,7 +2157,7 @@ class Server{
public function sendUsage(){
if($this->lastSendUsage instanceof SendUsageTask){
if(!$this->lastSendUsage->isFinished()){ //do not call multiple times
if(!$this->lastSendUsage->isGarbage()){ //do not call multiple times
return;
}
}
@ -2122,7 +2169,7 @@ class Server{
}
$version = new VersionString();
$this->lastSendUsage = new SendUsageTask("http://stats.pocketmine.net/usage.php", [
$this->lastSendUsage = new SendUsageTask("https://stats.pocketmine.net/usage.php", [
"serverid" => $this->serverID,
"port" => $this->getPort(),
"os" => Utils::getOS(),

View File

@ -26,9 +26,13 @@ namespace pocketmine;
*/
abstract class Thread extends \Thread{
public final function start($options = PTHREADS_INHERIT_ALL){
public function start($options = PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this);
return parent::start($options);
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
return parent::start($options);
}
return false;
}
}

View File

@ -26,9 +26,13 @@ namespace pocketmine;
*/
abstract class Worker extends \Worker{
public final function start($options = PTHREADS_INHERIT_ALL){
public function start($options = PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this);
return parent::start($options);
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated() and !$this->isShutdown()){
return parent::start($options);
}
return false;
}
}

View File

@ -144,7 +144,6 @@ class Block extends Position implements Metadatable{
const SUGARCANE_BLOCK = 83;
const FENCE = 85;
const FENCE_OAK = 85;
const PUMPKIN = 86;
const NETHERRACK = 87;
const SOUL_SAND = 88;
@ -236,11 +235,6 @@ class Block extends Position implements Metadatable{
const FENCE_GATE_JUNGLE = 185;
const FENCE_GATE_DARK_OAK = 186;
const FENCE_GATE_ACACIA = 187;
const FENCE_SPRUCE = 188;
const FENCE_BIRCH = 189;
const FENCE_JUNGLE = 190;
const FENCE_DARK_OAK = 191;
const FENCE_ACACIA = 192;
const PODZOL = 243;
const BEETROOT_BLOCK = 244;
@ -368,10 +362,11 @@ class Block extends Position implements Metadatable{
[Item::WOODEN_DOOR, 0],
[Item::TRAPDOOR, 0],
[Item::FENCE, 0],
[Item::FENCE_SPRUCE, 0],
[Item::FENCE_BIRCH, 0],
[Item::FENCE_DARK_OAK, 0],
[Item::FENCE_JUNGLE, 0],
[Item::FENCE, 1],
[Item::FENCE, 2],
[Item::FENCE, 3],
[Item::FENCE, 4],
[Item::FENCE, 5],
[Item::FENCE_GATE, 0],
[Item::FENCE_GATE_BIRCH, 0],
[Item::FENCE_GATE_SPRUCE, 0],
@ -723,11 +718,6 @@ class Block extends Position implements Metadatable{
self::$list[self::FENCE_GATE_JUNGLE] = FenceGateJungle::class;
self::$list[self::FENCE_GATE_DARK_OAK] = FenceGateDarkOak::class;
self::$list[self::FENCE_GATE_ACACIA] = FenceGateAcacia::class;
self::$list[self::FENCE_SPRUCE] = FenceSpruce::class;
self::$list[self::FENCE_BIRCH] = FenceBirch::class;
self::$list[self::FENCE_DARK_OAK] = FenceDarkOak::class;
self::$list[self::FENCE_JUNGLE] = FenceJungle::class;
self::$list[self::FENCE_ACACIA] = FenceAcacia::class;
self::$list[self::PODZOL] = Podzol::class;
self::$list[self::BEETROOT_BLOCK] = Beetroot::class;
@ -987,6 +977,7 @@ class Block extends Position implements Metadatable{
$this->y = (int) $v->y;
$this->z = (int) $v->z;
$this->level = $v->level;
$this->boundingBox = null;
}
/**
@ -1030,7 +1021,7 @@ class Block extends Position implements Metadatable{
return $this->getLevel()->getBlock(Vector3::getSide($side, $step));
}
return Block::get(Item::AIR, 0, new Position($v->x, $v->y, $v->z, null));
return Block::get(Item::AIR, 0, Position::fromObject(Vector3::getSide($side, $step)));
}
/**
@ -1048,7 +1039,7 @@ class Block extends Position implements Metadatable{
*/
public function collidesWithBB(AxisAlignedBB $bb, &$list = []){
$bb2 = $this->getBoundingBox();
if($bb2 !== null and $bb2->intersectsWith($bb)){
if($bb2 !== null and $bb->intersectsWith($bb2)){
$list[] = $bb2;
}
}
@ -1064,11 +1055,10 @@ class Block extends Position implements Metadatable{
* @return AxisAlignedBB
*/
public function getBoundingBox(){
if($this->boundingBox !== null){
return $this->boundingBox;
}else{
return $this->boundingBox = $this->recalculateBoundingBox();
if($this->boundingBox === null){
$this->boundingBox = $this->recalculateBoundingBox();
}
return $this->boundingBox;
}
/**

View File

@ -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/
*
*
*
*/
@ -25,6 +25,8 @@ use pocketmine\entity\Entity;
use pocketmine\event\block\BlockGrowEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
@ -65,7 +67,14 @@ class Cactus extends Transparent{
}
public function onEntityCollide(Entity $entity){
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
$damage = [EntityDamageEvent::MODIFIER_BASE => 1];
if($entity instanceof InventoryHolder){
$inventory = $entity->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, $damage);
$entity->attack($ev->getFinalDamage(), $ev);
}
@ -77,7 +86,7 @@ class Cactus extends Transparent{
}else{
for($side = 2; $side <= 5; ++$side){
$b = $this->getSide($side);
if(!$b->isFlowable){
if(!$b->canBeFlowedInto()){
$this->getLevel()->useBreakOn($this);
}
}
@ -128,4 +137,4 @@ class Cactus extends Transparent{
[$this->id, 0, 1],
];
}
}
}

View File

@ -45,7 +45,7 @@ class Cobweb extends Flowable{
}
public function onEntityCollide(Entity $entity){
$entity->fallDistance = 0;
$entity->resetFallDistance();
}
public function getDrops(Item $item){

View File

@ -27,16 +27,27 @@ class Fence extends Transparent{
protected $id = self::FENCE;
public function __construct(){
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getHardness(){
return 15;
}
public function getName(){
return "Oak Fence";
static $names = [
0 => "Oak Fence",
1 => "Spruce Fence",
2 => "Birch Fence",
3 => "Jungle Fence",
4 => "Acacia Fence",
5 => "Dark Oak Fence",
"",
""
];
return $names[$this->meta & 0x07];
}
protected function recalculateBoundingBox(){
@ -65,4 +76,4 @@ class Fence extends Transparent{
return (!($block instanceof Fence) and !($block instanceof FenceGate)) ? $block->isSolid() : true;
}
}
}

View File

@ -1,31 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
class FenceAcacia extends Fence{
protected $id = self::FENCE_ACACIA;
public function getName(){
return "Acacia Fence";
}
}

View File

@ -1,31 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
class FenceDarkOak extends Fence{
protected $id = self::FENCE_DARK_OAK;
public function getName(){
return "Dark Oak Fence";
}
}

View File

@ -1,31 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
class FenceJungle extends Fence{
protected $id = self::FENCE_JUNGLE;
public function getName(){
return "Jungle Fence";
}
}

View File

@ -1,31 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
class FenceSpruce extends Fence{
protected $id = self::FENCE_SPRUCE;
public function getName(){
return "Spruce Fence";
}
}

View File

@ -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/
*
*
*
*/
@ -25,6 +25,8 @@ use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityCombustByBlockEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Server;
@ -58,7 +60,14 @@ class Fire extends Flowable{
}
public function onEntityCollide(Entity $entity){
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
$damage = [EntityDamageEvent::MODIFIER_BASE => 1];
if($entity instanceof InventoryHolder){
$inventory = $entity->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, $damage);
$entity->attack($ev->getFinalDamage(), $ev);
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
@ -94,4 +103,4 @@ class Fire extends Flowable{
return false;
}
}
}

View File

@ -22,6 +22,8 @@
namespace pocketmine\block;
use pocketmine\item\Item;
class GlassPane extends Thin{
protected $id = self::GLASS_PANE;
@ -38,4 +40,7 @@ class GlassPane extends Thin{
return 1.5;
}
public function getDrops(Item $item){
return [];
}
}

View File

@ -21,6 +21,7 @@
namespace pocketmine\block;
use pocketmine\item\Item;
class IronBars extends Thin{
@ -33,5 +34,36 @@ class IronBars extends Thin{
public function getName(){
return "Iron Bars";
}
public function getHardness(){
return 5;
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.95;
case 4:
return 1.25;
case 3:
return 1.9;
case 2:
return 0.65;
case 1:
return 3.75;
default:
return 5;
}
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return [
[Item::IRON_BARS, 0, 1],
];
}else{
return [];
}
}
}
}

View File

@ -52,7 +52,7 @@ class Ladder extends Transparent{
}
public function onEntityCollide(Entity $entity){
$entity->fallDistance = 0;
$entity->resetFallDistance();
$entity->onGround = true;
}

View File

@ -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/
*
*
*
*/
@ -25,6 +25,8 @@ use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityCombustByBlockEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item;
use pocketmine\Player;
use pocketmine\Server;
@ -51,7 +53,14 @@ class Lava extends Liquid{
public function onEntityCollide(Entity $entity){
$entity->fallDistance *= 0.5;
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
$damage = [EntityDamageEvent::MODIFIER_BASE => 1];
if($entity instanceof InventoryHolder){
$inventory = $entity->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, $damage);
$entity->attack($ev->getFinalDamage(), $ev);
$ev = new EntityCombustByBlockEvent($this, $entity, 15);

View File

@ -38,7 +38,7 @@ class Sapling extends Flowable{
protected $id = self::SAPLING;
public function __construct($meta = 0){
$this->meta = 0;
$this->meta = $meta;
}
public function canBeActivated(){

View File

@ -48,7 +48,7 @@ class SnowLayer extends Flowable{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down instanceof Solid){
if($down->isSolid()){
$this->getLevel()->setBlock($block, $this, true);
return true;

View File

@ -50,8 +50,12 @@ class Stonecutter extends Solid{
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
if($item->isPickaxe() >= 1){
return [
[Item::STONECUTTER, 0, 1],
];
}else{
return [];
}
}
}

View File

@ -23,6 +23,7 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Player;
class TallGrass extends Flowable{
@ -45,6 +46,17 @@ class TallGrass extends Flowable{
];
return $names[$this->meta & 0x03];
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getId() === self::GRASS){
$this->getLevel()->setBlock($block, $this, true);
return true;
}
return false;
}
public function onUpdate($type){
@ -67,4 +79,4 @@ class TallGrass extends Flowable{
return [];
}
}
}

View File

@ -44,6 +44,7 @@ class Torch extends Flowable{
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$below = $this->getSide(0);
$side = $this->getDamage();
$faces = [
1 => 4,
@ -55,7 +56,7 @@ class Torch extends Flowable{
0 => 0,
];
if($this->getSide($faces[$side])->isTransparent() === true and !($side === 0 and $this->getSide(0)->getId() === self::FENCE)){
if($this->getSide($faces[$side])->isTransparent() === true and !($side === 0 and ($below->getId() === self::FENCE or $below->getId() === self::COBBLE_WALL))){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
@ -66,6 +67,8 @@ class Torch extends Flowable{
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$below = $this->getSide(0);
if($target->isTransparent() === false and $face !== 0){
$faces = [
1 => 5,
@ -78,7 +81,7 @@ class Torch extends Flowable{
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}elseif($this->getSide(0)->isTransparent() === false or $this->getSide(0)->getId() === self::FENCE){
}elseif($below->isTransparent() === false or $below->getId() === self::FENCE or $below->getId() === self::COBBLE_WALL){
$this->meta = 0;
$this->getLevel()->setBlock($block, $this, true, true);

View File

@ -53,7 +53,7 @@ class Vine extends Transparent{
}
public function onEntityCollide(Entity $entity){
$entity->fallDistance = 0;
$entity->resetFallDistance();
}
protected function recalculateBoundingBox(){

View File

@ -42,7 +42,7 @@ class Water extends Liquid{
}
public function onEntityCollide(Entity $entity){
$entity->fallDistance = 0;
$entity->resetFallDistance();
if($entity->fireTicks > 0){
$entity->extinguish();
}

View File

@ -24,10 +24,6 @@ namespace pocketmine\command;
use pocketmine\Thread;
class CommandReader extends Thread{
public $stream;
/** @var resource */
private $fp;
private $readline;
/** @var \Threaded */
@ -35,17 +31,15 @@ class CommandReader extends Thread{
/**
* @param \Threaded $threaded
* @param string $stream
*/
public function __construct(\Threaded $threaded, $stream = "php://stdin"){
$this->stream = $stream;
$this->buffer = $threaded;
public function __construct(){
$this->buffer = \ThreadedFactory::create();
$this->start();
}
private function readLine(){
if(!$this->readline){
$line = trim(fgets($this->fp));
$line = trim(fgets(fopen("php://stdin", "r")));
}else{
$line = trim(readline("> "));
if($line != ""){
@ -73,12 +67,10 @@ class CommandReader extends Thread{
public function run(){
$opts = getopt("", ["disable-readline"]);
if(extension_loaded("readline") and $this->stream === "php://stdin" and !isset($opts["disable-readline"])){
if(extension_loaded("readline") and !isset($opts["disable-readline"])){
$this->readline = true;
}else{
$this->readline = false;
$this->fp = fopen($this->stream, "r");
stream_set_blocking($this->fp, 1); //Non-blocking STDIN won't work on Windows
}
$lastLine = microtime(true);
@ -94,4 +86,4 @@ class CommandReader extends Thread{
$lastLine = microtime(true);
}
}
}
}

View File

@ -50,7 +50,8 @@ class FormattedCommandAlias extends Command{
$sender->sendMessage(TextFormat::RED . $e->getMessage());
}else{
$sender->sendMessage(TextFormat::RED . "An internal error occurred while attempting to perform this command");
if(($logger = $sender->getServer()->getLogger()) instanceof MainLogger){
$logger = $sender->getServer()->getLogger();
if($logger instanceof MainLogger){
$logger->logException($e);
}
}

View File

@ -183,7 +183,8 @@ class SimpleCommandMap implements CommandMap{
$target->execute($sender, $sentCommandLabel, $args);
}catch(\Exception $e){
$this->server->getLogger()->critical("Unhandled exception executing command '" . $commandLine . "' in " . $target . ": " . $e->getMessage());
if(($logger = $sender->getServer()->getLogger()) instanceof MainLogger){
$logger = $sender->getServer()->getLogger();
if($logger instanceof MainLogger){
$logger->logException($e);
}
}

View File

@ -32,7 +32,7 @@ class BanIpCommand extends VanillaCommand{
parent::__construct(
$name,
"Prevents the specified IP address from using this server",
"/ban <address|player> [reason...]"
"/ban-ip <address|player> [reason...]"
);
$this->setPermission("pocketmine.command.ban.ip");
}
@ -75,6 +75,8 @@ class BanIpCommand extends VanillaCommand{
}
}
$sender->getServer()->blockAddress($ip, -1);
Command::broadcastCommandMessage($sender, "Banned IP Address " . $ip);
}
}

View File

@ -64,6 +64,7 @@ class HelpCommand extends VanillaCommand{
}
if($command === ""){
/** @var Command[][] $commands */
$commands = [];
foreach($sender->getServer()->getCommandMap()->getCommands() as $command){
if($command->testPermissionSilent($sender)){
@ -86,11 +87,11 @@ class HelpCommand extends VanillaCommand{
return true;
}else{
if(($command = $sender->getServer()->getCommandMap()->getCommand(strtolower($command))) instanceof Command){
if($command->testPermissionSilent($sender)){
$message = TextFormat::YELLOW . "--------- " . TextFormat::WHITE . " Help: /" . $command->getName() . TextFormat::YELLOW . " ---------\n";
$message .= TextFormat::GOLD . "Description: " . TextFormat::WHITE . $command->getDescription() . "\n";
$message .= TextFormat::GOLD . "Usage: " . TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $command->getUsage())) . "\n";
if(($cmd = $sender->getServer()->getCommandMap()->getCommand(strtolower($command))) instanceof Command){
if($cmd->testPermissionSilent($sender)){
$message = TextFormat::YELLOW . "--------- " . TextFormat::WHITE . " Help: /" . $cmd->getName() . TextFormat::YELLOW . " ---------\n";
$message .= TextFormat::GOLD . "Description: " . TextFormat::WHITE . $cmd->getDescription() . "\n";
$message .= TextFormat::GOLD . "Usage: " . TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $cmd->getUsage())) . "\n";
$sender->sendMessage($message);
return true;

View File

@ -60,6 +60,7 @@ class TimingsCommand extends VanillaCommand{
}elseif($mode === "off"){
$sender->getServer()->getPluginManager()->setUseTimings(false);
$sender->sendMessage("Disabled Timings");
return true;
}
if(!$sender->getServer()->getPluginManager()->useTimings()){
@ -78,7 +79,10 @@ class TimingsCommand extends VanillaCommand{
$sampleTime = microtime(true) - self::$timingStart;
$index = 0;
$timingFolder = $sender->getServer()->getDataPath() . "timings/";
@mkdir($timingFolder, 0777);
if(!file_exists($timingFolder)){
mkdir($timingFolder, 0777);
}
$timings = $timingFolder . "timings.txt";
while(file_exists($timings)){
$timings = $timingFolder . "timings" . (++$index) . ".txt";
@ -130,4 +134,4 @@ class TimingsCommand extends VanillaCommand{
return true;
}
}
}

View File

@ -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/
*
*
*
*/
@ -33,6 +33,8 @@ use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\event\entity\EntitySpawnEvent;
use pocketmine\event\entity\EntityTeleportEvent;
use pocketmine\event\Timings;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\level\format\Chunk;
use pocketmine\level\format\FullChunk;
use pocketmine\level\Level;
@ -709,6 +711,10 @@ abstract class Entity extends Location implements Metadatable{
return true;
}
public function resetFallDistance(){
$this->fallDistance = 0;
}
protected function updateFallState($distanceThisTick, $onGround){
if($onGround === true){
if($this->fallDistance > 0){
@ -717,7 +723,7 @@ abstract class Entity extends Location implements Metadatable{
}
$this->fall($this->fallDistance);
$this->fallDistance = 0;
$this->resetFallDistance();
}
}elseif($distanceThisTick < 0){
$this->fallDistance -= $distanceThisTick;
@ -731,6 +737,13 @@ abstract class Entity extends Location implements Metadatable{
public function fall($fallDistance){
$damage = floor($fallDistance - 3);
if($damage > 0){
$damage = [EntityDamageEvent::MODIFIER_BASE => $damage];
if($this instanceof InventoryHolder){
$inventory = $this->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FALL, $damage);
$this->attack($ev->getFinalDamage(), $ev);
}
@ -766,8 +779,6 @@ abstract class Entity extends Location implements Metadatable{
$this->despawnFromAll();
if($this instanceof Player){
foreach($this->usedChunks as $index => $d){
$X = null;
$Z = null;
Level::getXZ($index, $X, $Z);
$this->unloadChunk($X, $Z);
}
@ -817,6 +828,53 @@ abstract class Entity extends Location implements Metadatable{
return false;
}
public function fastMove($dx, $dy, $dz){
if($dx == 0 and $dz == 0 and $dy == 0){
return true;
}
Timings::$entityMoveTimer->startTiming();
$axisalignedbb = clone $this->boundingBox;
$newBB = $this->boundingBox->getOffsetBoundingBox($dx, $dy, $dz);
$list = $this->level->getCollisionCubes($this, $newBB->expand(-0.01, -0.01, -0.01));
if(count($list) === 0){
$this->boundingBox = $newBB;
}
$pos = new Vector3(
($this->boundingBox->minX + $this->boundingBox->maxX) / 2,
$this->boundingBox->minY + $this->ySize,
($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2
);
$result = true;
if(!$this->setPosition($pos)){
$this->boundingBox->setBB($axisalignedbb);
$result = false;
}else{
if(!$this->onGround or $dy != 0){
$bb = clone $this->boundingBox;
$bb->minY -= 0.75;
$this->onGround = false;
if(count($this->level->getCollisionBlocks($bb)) > 0){
$this->onGround = true;
}
}
$this->isCollided = $this->onGround;
$this->updateFallState($dy, $this->onGround);
}
Timings::$entityMoveTimer->stopTiming();
return $result;
}
public function move($dx, $dy, $dz){
if($dx == 0 and $dz == 0 and $dy == 0){
@ -827,6 +885,7 @@ abstract class Entity extends Location implements Metadatable{
$this->boundingBox->offset($dx, $dy, $dz);
$this->setPosition(new Vector3(($this->boundingBox->minX + $this->boundingBox->maxX) / 2, $this->boundingBox->minY, ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2));
$this->onGround = $this instanceof Player ? true : false;
return true;
}else{
Timings::$entityMoveTimer->startTiming();
@ -877,7 +936,7 @@ abstract class Entity extends Location implements Metadatable{
//TODO: big messy loop
}*/
$list = $this->level->getCollisionCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz));
$list = $this->level->getCollisionCubes($this, $this->boundingBox->getOffsetBoundingBox($dx, $dy, $dz));
foreach($list as $bb){
@ -931,18 +990,13 @@ abstract class Entity extends Location implements Metadatable{
$this->boundingBox->setBB($axisalignedbb);
$list = $this->level->getCollisionCubes($this, $this->boundingBox->addCoord($movX, $dy, $movZ), false);
$list = $this->level->getCollisionCubes($this, $this->boundingBox->getOffsetBoundingBox($dx, $dy, $dz), false);
foreach($list as $bb){
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
}
$this->boundingBox->offset(0, $dy, 0);
if($movY != $dy){
$dx = 0;
$dy = 0;
$dz = 0;
}
foreach($list as $bb){
$dx = $bb->calculateXOffset($this->boundingBox, $dx);
@ -966,7 +1020,7 @@ abstract class Entity extends Location implements Metadatable{
$dz = 0;
}
if($movY != $dy){
if($dy == 0){
$dx = 0;
$dy = 0;
$dz = 0;
@ -1009,8 +1063,8 @@ abstract class Entity extends Location implements Metadatable{
if($this instanceof Player){
if(!$this->onGround or $movY != 0){
$bb = clone $this->boundingBox;
$bb->maxY = $bb->minY + 1;
if(count($this->level->getCollisionBlocks($bb->expand(0.01, 0.01, 0.01))) > 0){
$bb->minY -= 1;
if(count($this->level->getCollisionBlocks($bb)) > 0){
$this->onGround = true;
}else{
$this->onGround = false;
@ -1120,7 +1174,7 @@ abstract class Entity extends Location implements Metadatable{
$this->chunk->removeEntity($this);
}
$this->level->loadChunk($this->x >> 4, $this->z >> 4);
$this->chunk = $this->level->getChunk($this->x >> 4, $this->z >> 4);
$this->chunk = $this->level->getChunk($this->x >> 4, $this->z >> 4, true);
$this->chunkX = $this->chunk->getX();
$this->chunkZ = $this->chunk->getZ();
@ -1206,7 +1260,7 @@ abstract class Entity extends Location implements Metadatable{
$this->setMotion(new Vector3(0, 0, 0));
if($this->setPositionAndRotation($pos, $yaw === null ? $this->yaw : $yaw, $pitch === null ? $this->pitch : $pitch, true) !== false){
$this->fallDistance = 0;
$this->resetFallDistance();
$this->onGround = true;
$this->lastX = $this->x;
@ -1248,8 +1302,7 @@ abstract class Entity extends Location implements Metadatable{
if(!$this->closed){
$this->server->getPluginManager()->callEvent(new EntityDespawnEvent($this));
$this->closed = true;
unset($this->level->updateEntities[$this->id]);
if($this->chunk instanceof FullChunk){
if($this->chunk !== null){
$this->chunk->removeEntity($this);
}
if($this->level instanceof Level){

View File

@ -23,6 +23,8 @@ namespace pocketmine\entity;
use pocketmine\block\Block;
use pocketmine\block\Flowable;
use pocketmine\block\Liquid;
use pocketmine\event\entity\EntityBlockChangeEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityRegainHealthEvent;
@ -111,7 +113,7 @@ class FallingSand extends Entity{
if($this->onGround){
$this->kill();
$block = $this->level->getBlock($pos);
if(!$block->isFullBlock){
if($block->getId() > 0 and !$block->isSolid() and !($block instanceof Liquid)){
$this->getLevel()->dropItem($this, ItemItem::get($this->getBlock(), $this->getDamage(), 1));
}else{
$this->server->getPluginManager()->callEvent($ev = new EntityBlockChangeEvent($this, $block, Block::get($this->getBlock(), $this->getDamage())));

View File

@ -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/
*
*
*
*/
@ -28,6 +28,8 @@ use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityDeathEvent;
use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\event\Timings;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item as ItemItem;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\Short;
@ -164,19 +166,35 @@ abstract class Living extends Entity implements Damageable{
return $this->deadTicks < 10;
}
parent::entityBaseTick($tickDiff);
$hasUpdate = parent::entityBaseTick($tickDiff);
if($this->dead !== true and $this->isInsideOfSolid()){
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1);
$hasUpdate = true;
$damage = [EntityDamageEvent::MODIFIER_BASE => 1];
if($this instanceof InventoryHolder){
$inventory = $this->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory;
}
}
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, $damage);
$this->attack($ev->getFinalDamage(), $ev);
}
if($this->dead !== true and $this->isInsideOfWater()){
$hasUpdate = true;
$this->airTicks -= $tickDiff;
if($this->airTicks <= -20){
$this->airTicks = 0;
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2);
$damage = [EntityDamageEvent::MODIFIER_BASE => 2];
if($this instanceof InventoryHolder){
$inventory = $this->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, $damage);
$this->attack($ev->getFinalDamage(), $ev);
}
}else{
@ -188,6 +206,8 @@ abstract class Living extends Entity implements Damageable{
}
Timings::$timerEntityBaseTick->stopTiming();
return $hasUpdate;
}
/**

View File

@ -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/
*
*
*
*/
@ -24,10 +24,11 @@ namespace pocketmine\entity;
use pocketmine\event\entity\EntityCombustByEntityEvent;
use pocketmine\event\entity\EntityDamageByChildEntityEvent;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\event\entity\ProjectileHitEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\level\MovingObjectPosition;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\Short;
@ -136,15 +137,22 @@ abstract class Projectile extends Entity{
$this->server->getPluginManager()->callEvent(new ProjectileHitEvent($this));
$motion = sqrt($this->motionX ** 2 + $this->motionY ** 2 + $this->motionZ ** 2);
$damage = ceil($motion * $this->damage);
if($this->shootingEntity === null){
$ev = new EntityDamageByEntityEvent($this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
}else{
$ev = new EntityDamageByChildEntityEvent($this->shootingEntity, $this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
$damage = [EntityDamageEvent::MODIFIER_BASE => ceil($motion * $this->damage)];
$hit = $movingObjectPosition->entityHit;
if($hit instanceof InventoryHolder){
$inventory = $hit->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$movingObjectPosition->entityHit->attack($ev->getFinalDamage(), $ev);
if($this->shootingEntity === null){
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
}else{
$ev = new EntityDamageByChildEntityEvent($this->shootingEntity, $this, $hit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
}
$hit->attack($ev->getFinalDamage(), $ev);
if($this->fireTicks > 0){
@ -188,4 +196,4 @@ abstract class Projectile extends Entity{
return $hasUpdate;
}
}
}

View File

@ -28,8 +28,6 @@ use pocketmine\Player;
class BlockBreakEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var \pocketmine\Player */
protected $player;

View File

@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
class BlockFormEvent extends BlockGrowEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
public function __construct(Block $block, Block $newState){
parent::__construct($block, $newState);

View File

@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
class BlockGrowEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Block */
private $newState;

View File

@ -31,8 +31,6 @@ use pocketmine\Player;
*/
class BlockPlaceEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var \pocketmine\Player */
protected $player;

View File

@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
class BlockSpreadEvent extends BlockFormEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Block */
private $source;

View File

@ -28,7 +28,5 @@ use pocketmine\event\Cancellable;
*/
class BlockUpdateEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
}

View File

@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
class LeavesDecayEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
public function __construct(Block $block){
parent::__construct($block);

View File

@ -30,8 +30,6 @@ use pocketmine\Player;
*/
class SignChangeEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var \pocketmine\Player */
private $player;

View File

@ -28,8 +28,6 @@ use pocketmine\item\Item;
class EntityArmorChangeEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $oldItem;
private $newItem;

View File

@ -30,8 +30,6 @@ use pocketmine\event\Cancellable;
*/
class EntityBlockChangeEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $from;
private $to;

View File

@ -25,8 +25,6 @@ use pocketmine\block\Block;
use pocketmine\entity\Entity;
class EntityCombustByBlockEvent extends EntityCombustEvent{
public static $eventPool = [];
public static $nextEvent = 0;
protected $combuster;

View File

@ -24,8 +24,6 @@ namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
class EntityCombustByEntityEvent extends EntityCombustEvent{
public static $eventPool = [];
public static $nextEvent = 0;
protected $combuster;

View File

@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
class EntityCombustEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
protected $duration;

View File

@ -25,8 +25,6 @@ use pocketmine\block\Block;
use pocketmine\entity\Entity;
class EntityDamageByBlockEvent extends EntityDamageEvent{
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Block */
private $damager;
@ -51,4 +49,4 @@ class EntityDamageByBlockEvent extends EntityDamageEvent{
}
}
}

View File

@ -24,8 +24,6 @@ namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
class EntityDamageByChildEntityEvent extends EntityDamageByEntityEvent{
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Entity */
private $childEntity;

View File

@ -24,8 +24,6 @@ namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
class EntityDamageByEntityEvent extends EntityDamageEvent{
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Entity */
private $damager;

View File

@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
class EntityDamageEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
const MODIFIER_BASE = 0;
const MODIFIER_ARMOR = 1;

View File

@ -26,8 +26,6 @@ use pocketmine\item\Item;
class EntityDeathEvent extends EntityEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Item[] */
private $drops = [];

View File

@ -33,8 +33,6 @@ use pocketmine\entity\Vehicle;
*/
class EntityDespawnEvent extends EntityEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $entityType;

View File

@ -31,8 +31,6 @@ use pocketmine\level\Position;
*/
class EntityExplodeEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Position */
protected $position;

View File

@ -28,8 +28,6 @@ use pocketmine\item\Item;
class EntityInventoryChangeEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $oldItem;
private $newItem;

View File

@ -28,8 +28,6 @@ use pocketmine\level\Level;
class EntityLevelChangeEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $originLevel;
private $targetLevel;

View File

@ -28,8 +28,6 @@ use pocketmine\math\Vector3;
class EntityMotionEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $mot;

View File

@ -31,8 +31,6 @@ use pocketmine\math\Vector3;
*/
class EntityMoveEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var \pocketmine\math\Vector3 */
private $pos;

View File

@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
class EntityRegainHealthEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
const CAUSE_REGEN = 0;
const CAUSE_EATING = 1;

View File

@ -29,8 +29,6 @@ use pocketmine\item\Item;
class EntityShootBowEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Item */
private $bow;

View File

@ -33,8 +33,6 @@ use pocketmine\entity\Vehicle;
*/
class EntitySpawnEvent extends EntityEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $entityType;

View File

@ -28,8 +28,6 @@ use pocketmine\level\Position;
class EntityTeleportEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Position */
private $from;

View File

@ -29,8 +29,6 @@ use pocketmine\event\Cancellable;
*/
class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
protected $force;
private $blockBreaking;

View File

@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
class ItemDespawnEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/**
* @param Item $item

View File

@ -25,8 +25,6 @@ use pocketmine\entity\Item;
class ItemSpawnEvent extends EntityEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/**
* @param Item $item

View File

@ -25,8 +25,6 @@ use pocketmine\entity\Projectile;
class ProjectileHitEvent extends EntityEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/**
* @param Projectile $entity

View File

@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
class ProjectileLaunchEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/**
* @param Projectile $entity

View File

@ -28,8 +28,6 @@ use pocketmine\inventory\Recipe;
class CraftItemEvent extends Event implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var CraftingTransactionGroup */
private $ts;

View File

@ -28,8 +28,6 @@ use pocketmine\tile\Furnace;
class FurnaceBurnEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $furnace;
private $fuel;

View File

@ -28,8 +28,6 @@ use pocketmine\tile\Furnace;
class FurnaceSmeltEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $furnace;
private $source;

View File

@ -26,8 +26,6 @@ use pocketmine\Player;
class InventoryCloseEvent extends InventoryEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Player */
private $who;

View File

@ -27,8 +27,6 @@ use pocketmine\Player;
class InventoryOpenEvent extends InventoryEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Player */
private $who;

View File

@ -27,8 +27,6 @@ use pocketmine\inventory\Inventory;
class InventoryPickupArrowEvent extends InventoryEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Arrow */
private $arrow;

View File

@ -27,8 +27,6 @@ use pocketmine\inventory\Inventory;
class InventoryPickupItemEvent extends InventoryEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Item */
private $item;

View File

@ -31,8 +31,6 @@ use pocketmine\inventory\TransactionGroup;
*/
class InventoryTransactionEvent extends Event implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var TransactionGroup */
private $ts;

View File

@ -28,8 +28,6 @@ use pocketmine\level\format\FullChunk;
*/
class ChunkLoadEvent extends ChunkEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $newChunk;

View File

@ -26,6 +26,4 @@ namespace pocketmine\event\level;
*/
class ChunkPopulateEvent extends ChunkEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
}

View File

@ -28,6 +28,4 @@ use pocketmine\event\Cancellable;
*/
class ChunkUnloadEvent extends ChunkEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
}

View File

@ -26,6 +26,4 @@ namespace pocketmine\event\level;
*/
class LevelInitEvent extends LevelEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
}

View File

@ -26,6 +26,4 @@ namespace pocketmine\event\level;
*/
class LevelLoadEvent extends LevelEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
}

View File

@ -26,6 +26,4 @@ namespace pocketmine\event\level;
*/
class LevelSaveEvent extends LevelEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
}

View File

@ -28,6 +28,4 @@ use pocketmine\event\Cancellable;
*/
class LevelUnloadEvent extends LevelEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
}

View File

@ -30,8 +30,6 @@ use pocketmine\level\Position;
*/
class SpawnChangeEvent extends LevelEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Position */
private $previousSpawn;

View File

@ -29,8 +29,6 @@ use pocketmine\Player;
*/
class PlayerAchievementAwardedEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var string */
protected $achievement;

View File

@ -29,8 +29,6 @@ use pocketmine\Player;
*/
class PlayerAnimationEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
const ARM_SWING = 1;

View File

@ -27,8 +27,6 @@ use pocketmine\Player;
class PlayerBedEnterEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $bed;

View File

@ -26,8 +26,6 @@ use pocketmine\Player;
class PlayerBedLeaveEvent extends PlayerEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $bed;

View File

@ -27,8 +27,6 @@ use pocketmine\Player;
class PlayerBucketEmptyEvent extends PlayerBucketEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
public function __construct(Player $who, Block $blockClicked, $blockFace, Item $bucket, Item $itemInHand){
parent::__construct($who, $blockClicked, $blockFace, $bucket, $itemInHand);

View File

@ -27,8 +27,6 @@ use pocketmine\Player;
class PlayerBucketFillEvent extends PlayerBucketEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
public function __construct(Player $who, Block $blockClicked, $blockFace, Item $bucket, Item $itemInHand){
parent::__construct($who, $blockClicked, $blockFace, $bucket, $itemInHand);

View File

@ -30,8 +30,6 @@ use pocketmine\Server;
*/
class PlayerChatEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var string */
protected $message;

View File

@ -34,8 +34,6 @@ use pocketmine\Player;
*/
class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var string */
protected $message;

View File

@ -0,0 +1,139 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\event\player;
use pocketmine\event\Event;
use pocketmine\network\SourceInterface;
use pocketmine\Player;
/**
* Allows the creation of players overriding the base Player class
*/
class PlayerCreationEvent extends Event{
public static $handlerList = null;
/** @var SourceInterface */
private $interface;
/** @var mixed */
private $clientId;
/** @var string */
private $address;
/** @var int */
private $port;
/** @var Player::class */
private $baseClass;
/** @var Player::class */
private $playerClass;
/**
* @param SourceInterface $interface
* @param Player::class $baseClass
* @param Player::class $playerClass
* @param mixed $clientId
* @param string $address
* @param int $port
*/
public function __construct(SourceInterface $interface, $baseClass, $playerClass, $clientId, $address, $port){
$this->interface = $interface;
$this->clientId = $clientId;
$this->address = $address;
$this->port = $port;
if(!is_a($baseClass, Player::class, true)){
throw new \RuntimeException("Base class $baseClass must extend " . Player::class);
}
$this->baseClass = $baseClass;
if(!is_a($playerClass, Player::class, true)){
throw new \RuntimeException("Class $playerClass must extend " . Player::class);
}
$this->playerClass = $playerClass;
}
/**
* @return SourceInterface
*/
public function getInterface(){
return $this->interface;
}
/**
* @return string
*/
public function getAddress(){
return $this->address;
}
/**
* @return int
*/
public function getPort(){
return $this->port;
}
/**
* @return mixed
*/
public function getClientId(){
return $this->clientId;
}
/**
* @return Player::class
*/
public function getBaseClass(){
return $this->baseClass;
}
/**
* @param Player::class $class
*/
public function setBaseClass($class){
if(!is_a($class, $this->baseClass, true)){
throw new \RuntimeException("Base class $class must extend " . $this->baseClass);
}
$this->baseClass = $class;
}
/**
* @return Player::class
*/
public function getPlayerClass(){
return $this->playerClass;
}
/**
* @param Player::class $class
*/
public function setPlayerClass($class){
if(!is_a($class, $this->baseClass, true)){
throw new \RuntimeException("Class $class must extend " . $this->baseClass);
}
$this->playerClass = $class;
}
}

View File

@ -27,8 +27,6 @@ use pocketmine\Player;
class PlayerDeathEvent extends EntityDeathEvent{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $deathMessage;
private $keepInventory = false;

View File

@ -30,8 +30,6 @@ use pocketmine\Player;
*/
class PlayerDropItemEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Item */
private $drop;

View File

@ -29,8 +29,6 @@ use pocketmine\Player;
*/
class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var int */
protected $gamemode;

View File

@ -31,8 +31,6 @@ use pocketmine\Player;
*/
class PlayerInteractEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/**
* @var \pocketmine\block\Block;

View File

@ -30,8 +30,6 @@ use pocketmine\Player;
*/
class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
/** @var Item */
private $item;

View File

@ -28,8 +28,6 @@ use pocketmine\Player;
class PlayerItemHeldEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
public static $eventPool = [];
public static $nextEvent = 0;
private $item;
private $slot;

Some files were not shown because too many files have changed in this diff Show More