Jump to content

Players Coords Not Working Forge Modding


314owen

Recommended Posts

When I do:

world.setBlock((int) player.posX, (int) player.posY - 1, (int) player.posZ, 0);

It doesn't set the block under you to air, its sets one over to air, what causes this? Is it the changing from double to int? If so, how would I get player coords correctly.

Link to comment
Share on other sites

Hi

 

The player Y position is at your feet or at your eyes depending on whether you're on the server or on the client.  I forget which.  The eye height is found using EntityPlayer.getDefaultEyeHeight();

 

I'm pretty sure you don't need it though, if you are setting blocks on the server.  Are you calling this method on the client side?

 

-TGG

 

 

 

Link to comment
Share on other sites

Looking at the code in Entity that calls the onEntityWalking() method, this is how it detects the block being walked on.  Note that they include yOffset plus some other fixed displacement.

 

int j1 = MathHelper.floor_double(this.posX);
k = [color=blue]MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset);[/color]
int l = MathHelper.floor_double(this.posZ);
Block block = this.worldObj.getBlock(j1, k, l);
int i1 = this.worldObj.getBlock(j1, k - 1, l).getRenderType();

if (i1 == 11 || i1 == 32 || i1 == 21)
{
    block = this.worldObj.getBlock(j1, k - 1, l);
}

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

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.