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

Conversation

svilex
Copy link
Contributor

@svilex svilex commented Oct 16, 2016

$diffX,Y,Z variables were not needed since they were the same as $dx,y,z with an opposite sign and were used as a power of 2 ( $diffX,Y,Z ** 2 ) that's always positive. $diffY was also used in a condition, to check if the value was inside the interval ( -$yS < $diffY < $yS ) , so, the sign is not needed to check if it's inside this interval.

The default mcr/mca spawn was not centered in the 0,0 region causing the generation of not needed regions walking just a bit

… in the center of the r.0.0.mc* region file

$diffX,Y,Z variables were not needed since they were the same as $dx,y,z with an opposite sign and were used as a power of 2 ( $diffX,Y,Z ** 2 ) that's always positive. $diffY was also used in a condition, to check if the value was inside the interval ( -$yS < $diffY < $yS ) , so, the sign is not needed to check if it's inside this interval.

The default mcr/mca spawn was not centered in the 0,0 region causing the generation of not needed regions walking just a bit
@dktapps
Copy link
Member

dktapps commented Oct 16, 2016

Please try to keep your changes to separate commits/PRs.

@svilex
Copy link
Contributor Author

svilex commented Oct 16, 2016

@dktapps Ok, sorry. Should i make a new PR ?

@dktapps
Copy link
Member

dktapps commented Oct 16, 2016

Leave it this time, the changes are small enough to be reviewed easily. But for future reference please keep changes separate.

@@ -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.

Copy link
Member

@SOF3 SOF3 left a comment

Choose a reason for hiding this comment

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

I think the original code already contains some logic problems.

@@ -1356,16 +1356,12 @@ protected function processMovement($tickDiff){

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

$diffX = $this->x - $newPos->x;
$diffY = $this->y - $newPos->y;
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 😕

$yS = 0.5 + $this->ySize;
if($diffY >= -$yS or $diffY <= $yS){
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

$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.

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.

@svilex
Copy link
Contributor Author

svilex commented Oct 16, 2016

@SOF3 I can't add commits to this pull request, i deleted my fork . Is there another way?

@dktapps
Copy link
Member

dktapps commented Oct 16, 2016

@svilex That's very bad practice. You should always retain it until the PR is merged. Deleting it simply makes it unchangeable.

@SOF3
Copy link
Member

SOF3 commented Oct 16, 2016

@svilex close this pull request.

Your new fork still shares the same Git tree, so you can still create a new branch in your new fork and merge the new commit 38d328a into your branch:

git clone https://github.com/svilex/PocketMine-MP.git --recursive && cd PocketMine-MP
git checkout 38d328a31053399f0968a2dec63dc943ba62167c
git checkout -b my-new-branch
git push -u origin my-new-branch

@SOF3 SOF3 added the Type: Fix Bug fix, typo fix, or any other fix label Oct 16, 2016
@SOF3
Copy link
Member

SOF3 commented Oct 16, 2016

Edit: Better not merge this commit directly. Make two new pull requests instead.

@SOF3 SOF3 closed this Oct 16, 2016
@dktapps dktapps added the Resolution: Obsolete Superseded by other changes label Oct 18, 2016
@Renual1337 Renual1337 mentioned this pull request May 7, 2017
@noouilles noouilles mentioned this pull request Apr 23, 2019
This was referenced Jul 13, 2019
@ghost ghost mentioned this pull request Jul 19, 2020
@Willtom999 Willtom999 mentioned this pull request Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Obsolete Superseded by other changes Type: Fix Bug fix, typo fix, or any other fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants