mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 09:10:00 +00:00
Merge remote-tracking branch 'origin/minor-next' into major-next
This commit is contained in:
commit
c878bd8289
@ -118,6 +118,7 @@ abstract class Entity{
|
|||||||
protected Vector3 $motion;
|
protected Vector3 $motion;
|
||||||
protected Vector3 $lastMotion;
|
protected Vector3 $lastMotion;
|
||||||
protected bool $forceMovementUpdate = false;
|
protected bool $forceMovementUpdate = false;
|
||||||
|
private bool $checkBlockIntersectionsNextTick = true;
|
||||||
|
|
||||||
public AxisAlignedBB $boundingBox;
|
public AxisAlignedBB $boundingBox;
|
||||||
public bool $onGround = false;
|
public bool $onGround = false;
|
||||||
@ -620,7 +621,10 @@ abstract class Entity{
|
|||||||
|
|
||||||
$hasUpdate = false;
|
$hasUpdate = false;
|
||||||
|
|
||||||
|
if($this->checkBlockIntersectionsNextTick){
|
||||||
$this->checkBlockIntersections();
|
$this->checkBlockIntersections();
|
||||||
|
}
|
||||||
|
$this->checkBlockIntersectionsNextTick = true;
|
||||||
|
|
||||||
if($this->location->y <= World::Y_MIN - 16 && $this->isAlive()){
|
if($this->location->y <= World::Y_MIN - 16 && $this->isAlive()){
|
||||||
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_VOID, 10);
|
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_VOID, 10);
|
||||||
@ -1279,6 +1283,7 @@ abstract class Entity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function checkBlockIntersections() : void{
|
protected function checkBlockIntersections() : void{
|
||||||
|
$this->checkBlockIntersectionsNextTick = false;
|
||||||
$vectors = [];
|
$vectors = [];
|
||||||
|
|
||||||
foreach($this->getBlocksAroundWithEntityInsideActions() as $block){
|
foreach($this->getBlocksAroundWithEntityInsideActions() as $block){
|
||||||
@ -1290,12 +1295,14 @@ abstract class Entity{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(count($vectors) > 0){
|
||||||
$vector = Vector3::sum(...$vectors);
|
$vector = Vector3::sum(...$vectors);
|
||||||
if($vector->lengthSquared() > 0){
|
if($vector->lengthSquared() > 0){
|
||||||
$d = 0.014;
|
$d = 0.014;
|
||||||
$this->motion = $this->motion->addVector($vector->normalize()->multiply($d));
|
$this->motion = $this->motion->addVector($vector->normalize()->multiply($d));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getPosition() : Position{
|
public function getPosition() : Position{
|
||||||
return $this->location->asPosition();
|
return $this->location->asPosition();
|
||||||
|
@ -57,9 +57,12 @@ class RegisteredListener{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->timings->startTiming();
|
$this->timings->startTiming();
|
||||||
|
try{
|
||||||
($this->handler)($event);
|
($this->handler)($event);
|
||||||
|
}finally{
|
||||||
$this->timings->stopTiming();
|
$this->timings->stopTiming();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function isHandlingCancelled() : bool{
|
public function isHandlingCancelled() : bool{
|
||||||
return $this->handleCancelled;
|
return $this->handleCancelled;
|
||||||
|
@ -337,30 +337,35 @@ class Item implements \JsonSerializable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function serializeCompoundTag(CompoundTag $tag) : void{
|
protected function serializeCompoundTag(CompoundTag $tag) : void{
|
||||||
$display = $tag->getCompoundTag(self::TAG_DISPLAY) ?? new CompoundTag();
|
$display = $tag->getCompoundTag(self::TAG_DISPLAY);
|
||||||
|
|
||||||
$this->hasCustomName() ?
|
if($this->customName !== ""){
|
||||||
$display->setString(self::TAG_DISPLAY_NAME, $this->getCustomName()) :
|
$display ??= new CompoundTag();
|
||||||
$display->removeTag(self::TAG_DISPLAY_NAME);
|
$display->setString(self::TAG_DISPLAY_NAME, $this->customName);
|
||||||
|
}else{
|
||||||
|
$display?->removeTag(self::TAG_DISPLAY_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
if(count($this->lore) > 0){
|
if(count($this->lore) > 0){
|
||||||
$loreTag = new ListTag();
|
$loreTag = new ListTag();
|
||||||
foreach($this->lore as $line){
|
foreach($this->lore as $line){
|
||||||
$loreTag->push(new StringTag($line));
|
$loreTag->push(new StringTag($line));
|
||||||
}
|
}
|
||||||
|
$display ??= new CompoundTag();
|
||||||
$display->setTag(self::TAG_DISPLAY_LORE, $loreTag);
|
$display->setTag(self::TAG_DISPLAY_LORE, $loreTag);
|
||||||
}else{
|
}else{
|
||||||
$display->removeTag(self::TAG_DISPLAY_LORE);
|
$display?->removeTag(self::TAG_DISPLAY_LORE);
|
||||||
}
|
}
|
||||||
$display->count() > 0 ?
|
$display !== null && $display->count() > 0 ?
|
||||||
$tag->setTag(self::TAG_DISPLAY, $display) :
|
$tag->setTag(self::TAG_DISPLAY, $display) :
|
||||||
$tag->removeTag(self::TAG_DISPLAY);
|
$tag->removeTag(self::TAG_DISPLAY);
|
||||||
|
|
||||||
if($this->hasEnchantments()){
|
if(count($this->enchantments) > 0){
|
||||||
$ench = new ListTag();
|
$ench = new ListTag();
|
||||||
foreach($this->getEnchantments() as $enchantmentInstance){
|
$enchantmentIdMap = EnchantmentIdMap::getInstance();
|
||||||
|
foreach($this->enchantments as $enchantmentInstance){
|
||||||
$ench->push(CompoundTag::create()
|
$ench->push(CompoundTag::create()
|
||||||
->setShort(self::TAG_ENCH_ID, EnchantmentIdMap::getInstance()->toId($enchantmentInstance->getType()))
|
->setShort(self::TAG_ENCH_ID, $enchantmentIdMap->toId($enchantmentInstance->getType()))
|
||||||
->setShort(self::TAG_ENCH_LVL, $enchantmentInstance->getLevel())
|
->setShort(self::TAG_ENCH_LVL, $enchantmentInstance->getLevel())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -369,8 +374,8 @@ class Item implements \JsonSerializable{
|
|||||||
$tag->removeTag(self::TAG_ENCH);
|
$tag->removeTag(self::TAG_ENCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
($blockData = $this->getCustomBlockData()) !== null ?
|
$this->blockEntityTag !== null ?
|
||||||
$tag->setTag(self::TAG_BLOCK_ENTITY_TAG, clone $blockData) :
|
$tag->setTag(self::TAG_BLOCK_ENTITY_TAG, clone $this->blockEntityTag) :
|
||||||
$tag->removeTag(self::TAG_BLOCK_ENTITY_TAG);
|
$tag->removeTag(self::TAG_BLOCK_ENTITY_TAG);
|
||||||
|
|
||||||
if(count($this->canPlaceOn) > 0){
|
if(count($this->canPlaceOn) > 0){
|
||||||
|
@ -114,9 +114,11 @@ use function base64_encode;
|
|||||||
use function bin2hex;
|
use function bin2hex;
|
||||||
use function count;
|
use function count;
|
||||||
use function get_class;
|
use function get_class;
|
||||||
|
use function implode;
|
||||||
use function in_array;
|
use function in_array;
|
||||||
use function json_encode;
|
use function json_encode;
|
||||||
use function random_bytes;
|
use function random_bytes;
|
||||||
|
use function str_split;
|
||||||
use function strcasecmp;
|
use function strcasecmp;
|
||||||
use function strlen;
|
use function strlen;
|
||||||
use function strtolower;
|
use function strtolower;
|
||||||
@ -648,7 +650,7 @@ class NetworkSession{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function disconnectWithError(Translatable|string $reason) : void{
|
public function disconnectWithError(Translatable|string $reason) : void{
|
||||||
$this->disconnect(KnownTranslationFactory::pocketmine_disconnect_error($reason, bin2hex(random_bytes(6))));
|
$this->disconnect(KnownTranslationFactory::pocketmine_disconnect_error($reason, implode("-", str_split(bin2hex(random_bytes(6)), 4))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disconnectIncompatibleProtocol(int $protocolVersion) : void{
|
public function disconnectIncompatibleProtocol(int $protocolVersion) : void{
|
||||||
|
@ -173,9 +173,11 @@ class TypeConverter{
|
|||||||
if($itemStack->isNull()){
|
if($itemStack->isNull()){
|
||||||
return ItemStack::null();
|
return ItemStack::null();
|
||||||
}
|
}
|
||||||
|
$nbt = $itemStack->getNamedTag();
|
||||||
|
if($nbt->count() === 0){
|
||||||
$nbt = null;
|
$nbt = null;
|
||||||
if($itemStack->hasNamedTag()){
|
}else{
|
||||||
$nbt = clone $itemStack->getNamedTag();
|
$nbt = clone $nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
$idMeta = ItemTranslator::getInstance()->toNetworkIdQuiet($itemStack);
|
$idMeta = ItemTranslator::getInstance()->toNetworkIdQuiet($itemStack);
|
||||||
|
@ -24,12 +24,10 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\tools\simulate_chunk_selector;
|
namespace pocketmine\tools\simulate_chunk_selector;
|
||||||
|
|
||||||
use pocketmine\player\ChunkSelector;
|
use pocketmine\player\ChunkSelector;
|
||||||
use pocketmine\utils\AssumptionFailedError;
|
|
||||||
use pocketmine\utils\Utils;
|
use pocketmine\utils\Utils;
|
||||||
use pocketmine\world\format\Chunk;
|
use pocketmine\world\format\Chunk;
|
||||||
use pocketmine\world\World;
|
use pocketmine\world\World;
|
||||||
use Symfony\Component\Filesystem\Path;
|
use Symfony\Component\Filesystem\Path;
|
||||||
use function assert;
|
|
||||||
use function count;
|
use function count;
|
||||||
use function dirname;
|
use function dirname;
|
||||||
use function fwrite;
|
use function fwrite;
|
||||||
@ -128,7 +126,12 @@ if(count(getopt("", ["help"])) !== 0){
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Utils::stringifyKeys(getopt("", ["radius:", "baseX:", "baseZ:", "scale:", "chunksPerStep:"])) as $name => $value){
|
$opts = getopt("", ["radius:", "baseX:", "baseZ:", "scale:", "chunksPerStep:", "output:"]);
|
||||||
|
foreach(["radius", "baseX", "baseZ", "scale", "chunksPerStep"] as $name){
|
||||||
|
$value = $opts[$name] ?? null;
|
||||||
|
if($value === null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(!is_string($value) || (string) ((int) $value) !== $value){
|
if(!is_string($value) || (string) ((int) $value) !== $value){
|
||||||
fwrite(STDERR, "Value for --$name must be an integer\n");
|
fwrite(STDERR, "Value for --$name must be an integer\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -139,8 +142,7 @@ foreach(Utils::stringifyKeys(getopt("", ["radius:", "baseX:", "baseZ:", "scale:"
|
|||||||
"baseX" => ($baseX = $value),
|
"baseX" => ($baseX = $value),
|
||||||
"baseZ" => ($baseZ = $value),
|
"baseZ" => ($baseZ = $value),
|
||||||
"scale" => ($scale = $value),
|
"scale" => ($scale = $value),
|
||||||
"chunksPerStep" => ($nChunksPerStep = $value),
|
"chunksPerStep" => ($nChunksPerStep = $value)
|
||||||
default => throw new AssumptionFailedError("getopt() returned unknown option")
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if($radius === null){
|
if($radius === null){
|
||||||
@ -149,10 +151,10 @@ if($radius === null){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$outputDirectory = null;
|
$outputDirectory = null;
|
||||||
foreach(Utils::stringifyKeys(getopt("", ["output:"])) as $name => $value){
|
if(isset($opts["output"])){
|
||||||
assert($name === "output");
|
$value = $opts["output"];
|
||||||
if(!is_string($value)){
|
if(!is_string($value)){
|
||||||
fwrite(STDERR, "Value for --$name must be a string\n");
|
fwrite(STDERR, "Value for --output be a string\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if(!@mkdir($value) && !is_dir($value)){
|
if(!@mkdir($value) && !is_dir($value)){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user