Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Ok.  I got my vehicle to move in the directions I was trying to get it to work.  Now, the only problem is, the movement is extremely choppy and "warp" like. 

 

I am sure someone here has experienced this and can point me in the right direction to solving this.

 

 

package powell.rasterland.entity;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;

public class EntityRasterBike3 extends Entity
{
private int timeSinceRight =0;
private int timeSinceLeft = 0;
private int timeSinceForward = 0;
private int timeSinceBackward = 0;
private double velocity;
private double maxVelocity = 5;
private double velocityBoost = 0;
int direction = 0;

public EntityRasterBike3(World par1World)
{
	super(par1World);
	setSize(1.5F, 0.6F);
}

@Override
protected void entityInit()
{
	// TODO Auto-generated method stub

}

@Override
protected void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
	// TODO Auto-generated method stub

}

@Override
protected void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
	// TODO Auto-generated method stub

}

@Override
public AxisAlignedBB getBoundingBox() 
{
	return boundingBox;
}	

@Override
public AxisAlignedBB getCollisionBox(Entity entity)
{
	if (entity != riddenByEntity) 
	{
		return entity.boundingBox;
	}
	else
	{
		return null;
	}
}	

@Override
public boolean canBeCollidedWith()
{
	return !isDead;
}	

public boolean interactFirst(EntityPlayer par1EntityPlayer)
{
	if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer)
	{
		return true;
	}
	else
	{
		if (!this.worldObj.isRemote)
		{
			par1EntityPlayer.rotationYaw = this.rotationYaw;
			par1EntityPlayer.rotationPitch = this.rotationPitch;
			par1EntityPlayer.mountEntity(this);
		}

		return true;
	}
}

@Override
public double getMountedYOffset() 
{
	return -0.35;
}


@Override
public void onUpdate()
{
	if(timeSinceRight > 0)
		timeSinceRight--;
	if(timeSinceLeft > 0)
		timeSinceLeft--;
	if(timeSinceForward > 0)
		timeSinceForward--;
	if(timeSinceBackward >0)
		timeSinceBackward--;

	super.onUpdate();
	if(!worldObj.isRemote && this.riddenByEntity != null)
	{

		if(Minecraft.getMinecraft().gameSettings.keyBindForward.pressed && timeSinceForward == 0)
		{
			System.out.println("Forward was pressed");
			if(velocity < maxVelocity)
				velocity = velocity + .1 + velocityBoost;
		}
		if(Minecraft.getMinecraft().gameSettings.keyBindRight.pressed && timeSinceRight == 0)
		{
			System.out.println("Right was pressed");
			this.setRotation(this.rotationYaw + 90, this.rotationPitch);
			timeSinceRight = 10;
			direction = direction < 3 ? ++direction : 0;System.out.println("Direction = " + direction);
		}
		if(Minecraft.getMinecraft().gameSettings.keyBindLeft.pressed && timeSinceLeft == 0)
		{
			System.out.println("Left was pressed");
			this.setRotation(this.rotationYaw - 90, this.rotationPitch);
			timeSinceLeft = 10;
			direction = direction > 0 ? --direction : 3;System.out.println("Direction = " + direction);
		}
		if(Minecraft.getMinecraft().gameSettings.keyBindBack.pressed && timeSinceBackward == 0)
		{
			System.out.println("Backward was pressed");
			if(velocity > 0)
				velocity = velocity - .1;
		}

	}

	if(this.riddenByEntity != null)
	{
		this.riddenByEntity.rotationYaw = this.rotationYaw;
	}

	switch(direction)
	{
		case 0: setPosition(posX, posY + motionY, posZ + velocity);
				break;
		case 1:	setPosition(posX - velocity, posY + motionY, posZ);
				break;
		case 2:	setPosition(posX, posY + motionY, posZ - velocity);
				break;
		case 3: setPosition(posX + velocity, posY + motionY, posZ);
				break;
	}


}


}

 

if(!worldObj.isRemote && this.riddenByEntity != null)
	{

		if(Minecraft.getMinecraft().gameSettings.keyBindForward.pressed

Ultimate server crash.

Use a TickHandler to catch the keys and send packets to update the entity.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.