Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed some not needed code. Moved the default mcr/mca worlds' spawn in the center of the r.0.0.mc* region file #27

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/pocketmine/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -1356,16 +1356,12 @@ protected function processMovement($tickDiff){

$this->move($dx, $dy, $dz);

$diffX = $this->x - $newPos->x;
$diffY = $this->y - $newPos->y;
$diffZ = $this->z - $newPos->z;

$yS = 0.5 + $this->ySize;
if($diffY >= -$yS or $diffY <= $yS){
$diffY = 0;
if(-$yS <= $dy or $dy <= $yS){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$diffY is equivalent to -$dy not $dy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's what i said 😕

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So -$yS <= $dy and $dy <= $yS can be expressed as -yS <= dy <= yS mathematically, which is much more reasonable ($yS > 0 assumed). Otherwise, this statement is always true.

$dy = 0;
}

$diff = ($diffX ** 2 + $diffY ** 2 + $diffZ ** 2) / ($tickDiff ** 2);
$diff = ($dx ** 2 + $dy ** 2 + $dz ** 2) / ($tickDiff ** 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code seems to have logic problems. I think it should be an and operator such that it can be expressed as -$yS <= $diffY <= $yS mathematically


if($this->isSurvival()){
if(!$revert and !$this->isSleeping()){
Expand Down
4 changes: 2 additions & 2 deletions src/pocketmine/level/format/mcregion/McRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public static function generate($path, $name, $seed, $generator, array $options
"initialized" => new ByteTag("initialized", 1),
"GameType" => new IntTag("GameType", 0),
"generatorVersion" => new IntTag("generatorVersion", 1), //2 in MCPE
"SpawnX" => new IntTag("SpawnX", 128),
"SpawnX" => new IntTag("SpawnX", 255),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be 256, if the old was 128 (not 127)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A region contains 32 * 32 chunks.
A chunk is 16 * 16 * 128.
16 * 32 / 2 - 1 = 255

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then why was it 128 before?

There are 512 blocks horizontally, so you want the coordinate between the 256th and 257th, i.e. index 255 and 256. The middle of the index-255 block is 255.5, so this should be 256.

"SpawnY" => new IntTag("SpawnY", 70),
"SpawnZ" => new IntTag("SpawnZ", 128),
"SpawnZ" => new IntTag("SpawnZ", 255),
"version" => new IntTag("version", 19133),
"DayTime" => new IntTag("DayTime", 0),
"LastPlayed" => new LongTag("LastPlayed", microtime(true) * 1000),
Expand Down