Jump to content

Find Block Anywhere in World (or a workaround)


TricliniumAlegorium

Recommended Posts

I though I had found a workaround to this, but I didn't...So, is there a simple way to find a block somewhere in the world? It sounds simple, but it wont work. I want to teleport to a block in another dimension through my custom portal if that block exists. If not, create that block. I have the create a block working, but it always goes to that creating multiple instances of that block in the world right next to each other. It wont recognize that the block exists...Any Help?

Link to comment
Share on other sites

How are you searching right now?

 

- - -

 

Wasn't there originally a thread for this?

-Mitchellbrine

 

Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible.

It may be freaking fucking hard though, but still possible ;)

 

If you create a topic on Modder Support, live by this motto:

I don't want your charity, I want your information
Link to comment
Share on other sites

How are you searching right now?

 

- - -

 

Wasn't there originally a thread for this?

 

There was originally a thread by me, and I thought I found a workaround so I closed it. Now I realized it doesn't work. Right now I am using :

 

if(worldserver.getBlock(entity.chunkCoordX, entity.chunkCoordY, entity.chunkCoordZ) instanceof MyPortal)

 

It doesn't work

Link to comment
Share on other sites

You are checking for a block at the chunk coord, not the player's coord. Check at the player's coord.

 

- - -

 

Also, don't close your thread if you think you've figured it out. Keep it there so people can learn from it.

-Mitchellbrine

 

Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible.

It may be freaking fucking hard though, but still possible ;)

 

If you create a topic on Modder Support, live by this motto:

I don't want your charity, I want your information
Link to comment
Share on other sites

You are checking for a block at the chunk coord, not the player's coord. Check at the player's coord.

 

- - -

 

Also, don't close your thread if you think you've figured it out. Keep it there so people can learn from it.

 

When I do entity.posX, entity.posY, and entity.posZ, it gives me an error, becuase those are doubles but getBlock needs integers.

 

Also, I didn't realize that, next time I will keep my thread open :)

Link to comment
Share on other sites

Learn Java. Learn how to cast. Then, it won't be an issue.

-Mitchellbrine

 

Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible.

It may be freaking fucking hard though, but still possible ;)

 

If you create a topic on Modder Support, live by this motto:

I don't want your charity, I want your information
Link to comment
Share on other sites

Then it's not being called. (I'd also make it:

 

(int)Math.floor(entity.posX)

 

to avoid rounding issues)

 

Is the method being called at all?

-Mitchellbrine

 

Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible.

It may be freaking fucking hard though, but still possible ;)

 

If you create a topic on Modder Support, live by this motto:

I don't want your charity, I want your information
Link to comment
Share on other sites

Then it's not being called. (I'd also make it:

 

(int)Math.floor(entity.posX)

 

to avoid rounding issues)

 

Is the method being called at all?

 

It is inside the onEntityCollidedWithBlock, which I know works because I can add the teleport line of code and it teleports the player to another dimension when they walk into the block. It just isn't working with this...

Link to comment
Share on other sites

Try to print out the name of the block that you do get at that position.

 

Also, if you have it in onEntityCollidedWithBlock why would you check the entity position?  Wouldn't the entity position be same as the block that it just collided with?

 

(Aside: do you really want all entities to be teleported?  If not you might want to check that the entity is a player entity as well.)

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Try to print out the name of the block that you do get at that position.

 

Also, if you have it in onEntityCollidedWithBlock why would you check the entity position?  Wouldn't the entity position be same as the block that it just collided with?

 

(Aside: do you really want all entities to be teleported?  If not you might want to check that the entity is a player entity as well.)

About the onEntityCollidedWithBlock ith block method: yes, the round-of values are thesame coords, but the posX,posY and posZ are doubles so they can be like 6.333, which means it's about a third on that coordinate, so you can be a bit more specific, In this case it might not be useful, but it could be for others.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.