Jump to content

Recommended Posts

Posted

As i said in the title, i have some problems letting my custom controlled vehicle entity drive up blocks. I tried to achieve this like this:

int x=Math.sin(Math.toRadians(rotationYaw);
int z=Math.cos(Math.toRadians(rotationYaw);

if(worldObj.getBlockState(this.getPosition.add(x,0,z)).getBlock() !=Blocks.air &&worldObj.getBlockState(this.getPosition.add(x,1,z)).getBlock() ==Blocks.air){
   motionY=1;
}else
{
    double fullspeed=Math.sqrt((motionX*motionX)+(motionY*motionY));
    this.applydamage(fullspeed);
}

 

But what happens is that the entity is inside of the block and then outside of the world. I think something is wrong with the collision somehow. cuz the entity does not collide with blocks or entities. Also i think in my movement algorythm is something wrong(in the onUpdate() method), but i can't figure it out. This is the complete entitity class(Without the driveup blocks stuff):

 

http://pastebin.com/yRgNA0Vm

 

Thanks for taking the time too help me :D

Posted

this.posX += this.vehicleX;
this.posY += this.vehicleY;
this.posZ += this.vehicleZ;
this.setPosition(this.posX, this.posY, this.posZ);

Why do you add vehicleX/Y/Z to the position?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

No, don't just add motion when key is pressed. You should check collision before changing position.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

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.