Jump to content

Recommended Posts

Posted

I want to make a vehicle that a player can ride in, shoot bullets with, and will auto jump one block. However, I have no clue where to start. Any ideas?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

That's a lot all at once, I'd start with making the car and having it auto-jump one block.  Like the horse.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Try to make minecarts that don't require rails...

 

Unfortunately, the rails handle most of the Minecart movement logic.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Fairly easy start with

public class EntityVehicle extends EntityAnimal {

public EntityVehicle (World par1World) {
	super(par1World);
	this.setSize(1F, 1F);
}

public EntityVehicle (World par1World, double par2, double par4, double par6) {
	this(par1World);
	this.setPosition(par2, par4 + (double) this.yOffset, par6);

}

}

//then look at horse code for the rest in particular pay attention to

 

// this is my customized version for my Bicycle vehicle

@Override
public void moveEntityWithHeading(float moveStrafing, float moveForward) {
	if (this.riddenByEntity != null) {
		this.prevRotationYaw = this.rotationYaw = this.riddenByEntity.rotationYaw;
		this.rotationPitch = this.riddenByEntity.rotationPitch * 0.5F;
		this.setRotation(this.rotationYaw, this.rotationPitch);
		this.rotationYawHead = this.renderYawOffset = this.rotationYaw;
		moveStrafing = 0;	//moveStrafing = strafing. Should be 0, since we don't want the bike to move side to side.
		moveForward = ((EntityLivingBase) this.riddenByEntity).moveForward* bicycleMovementSpeedMultiplier;

		if (moveForward <= 0.0F) {
			moveForward *= 0.25F;	//you move 1/4 of the speed when going backwards

		}

		if(this.onGround){
			this.jumpPower = 0.0f;//(float)this.getBicycleJumpPower();
		}
		if (this.jumpPower > 0.0F && !this.isBicycleJumping() && this.onGround) {

			this.motionY = this.jumpPower;	//getBicycleJumpPower()

			this.onGround = false;
			this.isAirBorne = true;

			this.jumpPower = 0.0F;
		}

		this.stepHeight = 1.0F;
		this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F;

		if (!this.worldObj.isRemote) {
			this.setAIMoveSpeed((float) this.getEntityAttribute(
					SharedMonsterAttributes.movementSpeed)
					.getAttributeValue());
			//System.out.println("moveStrafing: "+moveStrafing+" moveForward: "+moveForward);
			super.moveEntityWithHeading(moveStrafing, moveForward);
		}

		if (this.onGround) {
			this.jumpPower = 0.0F;
			this.setBicycleJumping(false);
			//System.out.println("jumpPower: "+jumpPower+" if (this.onGround)");
		}

	} else {
		this.stepHeight = 0.5F;
		this.jumpMovementFactor = 0.02F;
		super.moveEntityWithHeading(moveStrafing, moveForward);
	}
}

 

and pay attention to

/**
 * Returns true if this entity should push and be pushed by other entities
 * when colliding.
 */
public boolean canBePushed() {
	return this.riddenByEntity == null;
}

/**
 * Called when the mob is falling. Calculates and applies fall damage.
 */
protected void fall(float par1) {
	if (par1 > 1.0F) {
		//this.playSound("mob.Horse.land", 0.4F, 1.0F);
	}

	int i = MathHelper.ceiling_float_int(par1 * 0.5F - 3.0F);

	if (i > 0) {

		this.attackEntityFrom(DamageSource.fall, (float)i);
		if (this.riddenByEntity != null){
                this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float)i);
            }

		Block block = this.worldObj.getBlock(
				MathHelper.floor_double(this.posX),
				MathHelper.floor_double(this.posY - 0.2D
						- (double) this.prevRotationYaw),
						MathHelper.floor_double(this.posZ));

		if (block.getMaterial() != Material.air) {
			Block.SoundType soundtype = block.stepSound;
			this.worldObj.playSoundAtEntity(this,
					soundtype.getStepResourcePath(),
					soundtype.getVolume() * 0.5F,
					soundtype.getPitch() * 0.75F);
		}
	}
}


/**
 * Called when a player interacts with a mob. Here we mount the player on the vehicle when right clicked.
 */
public boolean interact(EntityPlayer par1EntityPlayer) {
}

public void onLivingUpdate() {
	super.onLivingUpdate();
}

public void onUpdate() {
	super.onUpdate();
}

@Override
public EntityAgeable createChild(EntityAgeable par1EntityAgeable) {
	return null;
}

@Override
public double getMountedYOffset(){
	return 1.0;
}
/*
 * Returns true if the new AI system should be used. Should not remove, otherwise the vehicle will use the 
 * AI of a passive mob 
 */
@Override
protected boolean isAIEnabled(){
        return true;
    }

@Override
public boolean isOnLadder() {
	return false;
}

Posted

also [joke alert] the Thank You Btn is located  over here somewhere -------------------------------------------------------------------------------------------------------------------------------------->

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.