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

Nether Portal Jumping & Creation Code #2162

Merged
merged 1 commit into from Jun 10, 2015

Conversation

Projects
None yet
6 participants
@lkolbly
Contributor

lkolbly commented May 29, 2015

Per #1856, this code implements a portal scanner which finds and creates nether portals when entities move between the overworld and the nether.

It also changes dae9e57#diff-97bcf8a96a22aec81982926aa1462363R298 because StringToInteger returns true if the conversion was successful. I think.

Show outdated Hide outdated src/BlockID.cpp
Show outdated Hide outdated src/Chunk.cpp
@madmaxoft

This comment has been minimized.

Show comment
Hide comment
@madmaxoft

madmaxoft May 29, 2015

Member

Please try to use the same coding style. We use a space after all commas, and a space around pointer and reference declarations (cWorld * a_World etc.) There's too many of these to report each one. Unfortunately the basic stylechecking script cannot detect these reliably, so you'll need to do it by hand.

Member

madmaxoft commented May 29, 2015

Please try to use the same coding style. We use a space after all commas, and a space around pointer and reference declarations (cWorld * a_World etc.) There's too many of these to report each one. Unfortunately the basic stylechecking script cannot detect these reliably, so you'll need to do it by hand.

@lkolbly

This comment has been minimized.

Show comment
Hide comment
@lkolbly

lkolbly May 29, 2015

Contributor

Okay, I'll go back through as I move it to a new file.

Contributor

lkolbly commented May 29, 2015

Okay, I'll go back through as I move it to a new file.

@lkolbly

This comment has been minimized.

Show comment
Hide comment
@lkolbly

lkolbly May 30, 2015

Contributor

Okay, I think I got it compliant with the coding convention in bad47a8, except maybe local variable names, I don't know what the convention is for those. I didn't see any commas without spaces, though, so I'm probably looking at the wrong commas?

Contributor

lkolbly commented May 30, 2015

Okay, I think I got it compliant with the coding convention in bad47a8, except maybe local variable names, I don't know what the convention is for those. I didn't see any commas without spaces, though, so I'm probably looking at the wrong commas?

@lkolbly

This comment has been minimized.

Show comment
Hide comment
@lkolbly

lkolbly May 30, 2015

Contributor

What's the preferred way to convert between Vector types, e.g. from Vector3i to a Vector3d?

Contributor

lkolbly commented May 30, 2015

What's the preferred way to convert between Vector types, e.g. from Vector3i to a Vector3d?

@madmaxoft

This comment has been minimized.

Show comment
Hide comment
@madmaxoft

madmaxoft May 31, 2015

Member

I don't think there's any preference. There's a simple copy-constructor provided within the vector template, and for converting to a Vector3i there's also the Floor() function defined on the class (Ceil() is missing right now, but could be added with minimal effort).

Member

madmaxoft commented May 31, 2015

I don't think there's any preference. There's a simple copy-constructor provided within the vector template, and for converting to a Vector3i there's also the Floor() function defined on the class (Ceil() is missing right now, but could be added with minimal effort).

@lkolbly

This comment has been minimized.

Show comment
Hide comment
@lkolbly

lkolbly Jun 2, 2015

Contributor

Okay. I think I've fixed the convention errors.

Contributor

lkolbly commented Jun 2, 2015

Okay. I think I've fixed the convention errors.

@lkolbly

This comment has been minimized.

Show comment
Hide comment
@lkolbly

lkolbly Jun 6, 2015

Contributor

Alright, I just refactored m_Dir to use a Direction type which is either X or Y (I considered NORTH_SOUTH and EAST_WEST, but that didn't seem to map to the code as well).

Contributor

lkolbly commented Jun 6, 2015

Alright, I just refactored m_Dir to use a Direction type which is either X or Y (I considered NORTH_SOUTH and EAST_WEST, but that didn't seem to map to the code as well).

@madmaxoft

This comment has been minimized.

Show comment
Hide comment
@madmaxoft

madmaxoft Jun 8, 2015

Member

Is there any chance you could get this rebased onto current master and squashed into a single commit?

Member

madmaxoft commented Jun 8, 2015

Is there any chance you could get this rebased onto current master and squashed into a single commit?

@lkolbly

This comment has been minimized.

Show comment
Hide comment
@lkolbly

lkolbly Jun 8, 2015

Contributor

Sure thing. Done.

Contributor

lkolbly commented Jun 8, 2015

Sure thing. Done.

@madmaxoft

This comment has been minimized.

Show comment
Hide comment
@madmaxoft

madmaxoft Jun 9, 2015

Member

I think this is merge-worthy. Opinions?

Member

madmaxoft commented Jun 9, 2015

I think this is merge-worthy. Opinions?

Show outdated Hide outdated src/Entities/Entity.h
@NiLSPACE

This comment has been minimized.

Show comment
Hide comment
@NiLSPACE

NiLSPACE Jun 9, 2015

Member

Apart from the question I have about the m_IsWorldChangeScheduled initialization it looks really good.

Member

NiLSPACE commented Jun 9, 2015

Apart from the question I have about the m_IsWorldChangeScheduled initialization it looks really good.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jun 9, 2015

Please add yourself to the contributors file.

ghost commented Jun 9, 2015

Please add yourself to the contributors file.

@sphinxc0re

This comment has been minimized.

Show comment
Hide comment
@sphinxc0re

sphinxc0re Jun 10, 2015

Contributor

Looks like it's ready for merge

Contributor

sphinxc0re commented Jun 10, 2015

Looks like it's ready for merge

madmaxoft added a commit that referenced this pull request Jun 10, 2015

Merge pull request #2162 from lkolbly/master
Nether Portal Jumping & Creation Code

@madmaxoft madmaxoft merged commit d436a71 into cuberite:master Jun 10, 2015

2 checks passed

continuous-integration/appveyor AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@NiLSPACE

This comment has been minimized.

Show comment
Hide comment
@NiLSPACE

NiLSPACE Jun 13, 2015

Member

After almost a month I finally updated my MCServer and tried this, and I noticed that when teleporting to an portal I get teleported 1 block next to it. That probably isn't intended right? You're supposed to teleport in another portal.

EDIT:
I also noticed that if I create a portal on the top of the nether, go through it, and then go back in the portal I get teleported to the top of the nether. Vanilla doesn't allow this to happen.

Member

NiLSPACE commented Jun 13, 2015

After almost a month I finally updated my MCServer and tried this, and I noticed that when teleporting to an portal I get teleported 1 block next to it. That probably isn't intended right? You're supposed to teleport in another portal.

EDIT:
I also noticed that if I create a portal on the top of the nether, go through it, and then go back in the portal I get teleported to the top of the nether. Vanilla doesn't allow this to happen.

@sphinxc0re

This comment has been minimized.

Show comment
Hide comment
@sphinxc0re

sphinxc0re Jun 13, 2015

Contributor

Also, you get teleported instantly but I think this is another issue

Contributor

sphinxc0re commented Jun 13, 2015

Also, you get teleported instantly but I think this is another issue

@NiLSPACE

This comment has been minimized.

Show comment
Hide comment
@NiLSPACE

NiLSPACE Jun 13, 2015

Member

That's only in creative gamemode right? Because in vanilla you also get teleported instantly in creative mode.

Member

NiLSPACE commented Jun 13, 2015

That's only in creative gamemode right? Because in vanilla you also get teleported instantly in creative mode.

m_World->GetChunkBlockTypes(a_ChunkX, a_ChunkZ, blocks);
// Iterate through all of the blocks in the chunk
for (unsigned int i = 0; i < cChunkDef::NumBlocks; i++)

This comment has been minimized.

@NiLSPACE

NiLSPACE Jun 13, 2015

Member

Looking at this again, shouldn't this be i += 2 as suggested by @madmaxoft here? It would speed up the search for a nether portal by quite allot since it wouldn't have to check every block in the chunk.

@NiLSPACE

NiLSPACE Jun 13, 2015

Member

Looking at this again, shouldn't this be i += 2 as suggested by @madmaxoft here? It would speed up the search for a nether portal by quite allot since it wouldn't have to check every block in the chunk.

This comment has been minimized.

@lkolbly

lkolbly Jun 13, 2015

Contributor

Because of the way the chunks are stored (XZY?), doing i+2 here would result in a pattern that skips every other row. Note that it's iterating from 0 to NumBlocks, not 0 to 16 each axis - this results in a speedup in not having to call CoordinateToIndex.

@lkolbly

lkolbly Jun 13, 2015

Contributor

Because of the way the chunks are stored (XZY?), doing i+2 here would result in a pattern that skips every other row. Note that it's iterating from 0 to NumBlocks, not 0 to 16 each axis - this results in a speedup in not having to call CoordinateToIndex.

This comment has been minimized.

@madmaxoft

madmaxoft Jun 13, 2015

Member

It would have been possible to have two loops, the inner one iterating over the 256 blocks in a single Y slice, and the outer one iterating over Y slices, skipping 2 slices out of each 3:

for (unsigned y = 0; y < cChunkDef::Height; y += 3)
{
  unsigned BaseY = cChunkDef::Width * cChunkDef::Width * y;
  for (unsigned i = 0; i < 256; i++)
  {
    // Check block at index [BaseY + i]
  }
}
@madmaxoft

madmaxoft Jun 13, 2015

Member

It would have been possible to have two loops, the inner one iterating over the 256 blocks in a single Y slice, and the outer one iterating over Y slices, skipping 2 slices out of each 3:

for (unsigned y = 0; y < cChunkDef::Height; y += 3)
{
  unsigned BaseY = cChunkDef::Width * cChunkDef::Width * y;
  for (unsigned i = 0; i < 256; i++)
  {
    // Check block at index [BaseY + i]
  }
}
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jun 13, 2015

I tested this, I can not get back to the world from the nether trough the portal. Used the FAQ for creating a nether world.

ghost commented Jun 13, 2015

I tested this, I can not get back to the world from the nether trough the portal. Used the FAQ for creating a nether world.

@NiLSPACE

This comment has been minimized.

Show comment
Hide comment
@NiLSPACE

NiLSPACE Jun 13, 2015

Member

That's probably because you haven't configured the world linking in the world.ini. The FAQ only describes how you can generate such a world.

Member

NiLSPACE commented Jun 13, 2015

That's probably because you haven't configured the world linking in the world.ini. The FAQ only describes how you can generate such a world.

@sphinxc0re

This comment has been minimized.

Show comment
Hide comment
@sphinxc0re

sphinxc0re Jun 13, 2015

Contributor

Yes, this is a problem. You have to stand right in the portal to teleport. in vanilla you only need partial contact with the portal.

Also, you are getting damage for travelling to the nether

Contributor

sphinxc0re commented Jun 13, 2015

Yes, this is a problem. You have to stand right in the portal to teleport. in vanilla you only need partial contact with the portal.

Also, you are getting damage for travelling to the nether

@tigerw

This comment has been minimized.

Show comment
Hide comment
@tigerw

tigerw Jun 13, 2015

Member

Yes, this is a problem. You have to stand right in the portal to teleport. in vanilla you only need partial contact with the portal.

This is to do with lack of bounding box detection in MCS at the present.

Member

tigerw commented Jun 13, 2015

Yes, this is a problem. You have to stand right in the portal to teleport. in vanilla you only need partial contact with the portal.

This is to do with lack of bounding box detection in MCS at the present.

@lkolbly

This comment has been minimized.

Show comment
Hide comment
@lkolbly

lkolbly Jun 13, 2015

Contributor

@NiLSPACE

... and I noticed that when teleporting to an portal I get teleported 1 block next to it.

That was intended, but can be changed easily.

Contributor

lkolbly commented Jun 13, 2015

@NiLSPACE

... and I noticed that when teleporting to an portal I get teleported 1 block next to it.

That was intended, but can be changed easily.

@NiLSPACE

This comment has been minimized.

Show comment
Hide comment
@NiLSPACE

NiLSPACE Jun 13, 2015

Member

I think it should be changed, because I got teleported in the portal frame once. It could also be possible to be teleported inside a wall if the portal is next to it.

Member

NiLSPACE commented Jun 13, 2015

I think it should be changed, because I got teleported in the portal frame once. It could also be possible to be teleported inside a wall if the portal is next to it.

@lkolbly

This comment has been minimized.

Show comment
Hide comment
@lkolbly

lkolbly Jun 13, 2015

Contributor

I'm not sure you can since it places the portal in a 3x4x5 empty space, so there's always air on either side of the portal. But I can change it anyway.

Contributor

lkolbly commented Jun 13, 2015

I'm not sure you can since it places the portal in a 3x4x5 empty space, so there's always air on either side of the portal. But I can change it anyway.

@NiLSPACE

This comment has been minimized.

Show comment
Hide comment
@NiLSPACE

NiLSPACE Jun 13, 2015

Member

But if I build a portal against a wall then there isn't an empty space around it. ^^

Member

NiLSPACE commented Jun 13, 2015

But if I build a portal against a wall then there isn't an empty space around it. ^^

@lkolbly

This comment has been minimized.

Show comment
Hide comment
@lkolbly

lkolbly Jun 13, 2015

Contributor

Oh, that's true. I hadn't thought about manually created portals. I will change that & the Y limit and make a PR after #2237 is closed. Having multiple forks is so much effort.

Contributor

lkolbly commented Jun 13, 2015

Oh, that's true. I hadn't thought about manually created portals. I will change that & the Y limit and make a PR after #2237 is closed. Having multiple forks is so much effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment