Jump to content

Recommended Posts

Posted

I am making a Rideable Vehicle called Bicycle and so Far I have it rendering on the ground and in the players hand as a 3D item. I also have it so that upon right click I "mount the vehicle. But I cannot figure out why it wont move once I have mounted it. I based my code off of the boat code and the horse class.

 

Entity Bicycle class

 

 

 public class EntityBicycle extends EntityAnimal {
private static final IEntitySelector BicycleBreedingSelector = new IEntitySelector() {

	/**
	 * Return whether the specified entity is applicable to this filter.
	 */
	public boolean isEntityApplicable(Entity par1Entity) {
		return par1Entity instanceof EntityBicycle
				&& ((EntityBicycle) par1Entity).func_110205_ce();
	}
};
private static final IAttribute BicycleJumpStrength = (new RangedAttribute(
		"Bicycle.jumpStrength", 0.7D, 0.0D, 2.0D)).setDescription(
		"Jump Strength").setShouldWatch(true);
private static final String[] BicycleArmorTextures = new String[] { null,
		"textures/entity/Bicycle/armor/Bicycle_armor_iron.png",
		"textures/entity/Bicycle/armor/Bicycle_armor_gold.png",
		"textures/entity/Bicycle/armor/Bicycle_armor_diamond.png" };
private static final String[] field_110273_bx = new String[] { "", "meo",
		"goo", "dio" };
private static final int[] armorValues = new int[] { 0, 5, 7, 11 };
private static final String[] BicycleTextures = new String[] {
		"textures/entity/Bicycle/Bicycle_white.png",
		"textures/entity/Bicycle/Bicycle_creamy.png",
		"textures/entity/Bicycle/Bicycle_chestnut.png",
		"textures/entity/Bicycle/Bicycle_brown.png",
		"textures/entity/Bicycle/Bicycle_black.png",
		"textures/entity/Bicycle/Bicycle_gray.png",
		"textures/entity/Bicycle/Bicycle_darkbrown.png" };
private static final String[] field_110269_bA = new String[] { "hwh",
		"hcr", "hch", "hbr", "hbl", "hgr", "hdb" };
private static final String[] BicycleMarkingTextures = new String[] { null,
		"textures/entity/Bicycle/Bicycle_markings_white.png",
		"textures/entity/Bicycle/Bicycle_markings_whitefield.png",
		"textures/entity/Bicycle/Bicycle_markings_whitedots.png",
		"textures/entity/Bicycle/Bicycle_markings_blackdots.png" };
private static final String[] field_110292_bC = new String[] { "", "wo_",
		"wmo", "wdo", "bdo" };
private int eatingHaystackCounter;
private int openMouthCounter;
private int jumpRearingCounter;
public int field_110278_bp;
public int field_110279_bq;
protected boolean BicycleJumping;
private AnimalChest BicycleChest;
private boolean hasReproduced;
/**
 * "The higher this value, the more likely the Bicycle is to be tamed next time a player rides it."
 */
protected int temper;
protected float jumpPower;
private boolean field_110294_bI;
private float headLean;
private float prevHeadLean;
private float rearingAmount;
private float prevRearingAmount;
private float mouthOpenness;
private float prevMouthOpenness;
private int field_110285_bP;
private String field_110286_bQ;
private String[] field_110280_bR = new String[3];
private static final String __OBFID = "CL_00001641";

public EntityBicycle(World par1World) {
	super(par1World);
	this.setSize(1.4F, 1.6F);

}

public EntityBicycle(World par1World, double par2, double par4, double par6) {
	this(par1World);
	this.setPosition(par2, par4 + (double) this.yOffset, par6);
	this.motionX = 0.0D;
	this.motionY = 0.0D;
	this.motionZ = 0.0D;
	this.prevPosX = par2;
	this.prevPosY = par4;
	this.prevPosZ = par6;
}

protected void entityInit() {
	super.entityInit();
	this.dataWatcher.addObject(16, Integer.valueOf(0));
	this.dataWatcher.addObject(19, Byte.valueOf((byte) 0));
	this.dataWatcher.addObject(20, Integer.valueOf(0));
	this.dataWatcher.addObject(21, String.valueOf(""));
	this.dataWatcher.addObject(22, Integer.valueOf(0));
}

public void setBicycleType(int par1) {
	this.dataWatcher.updateObject(19, Byte.valueOf((byte) par1));
	this.func_110230_cF();
}

/**
 * returns the Bicycle type
 */
public int getBicycleType() {
	return this.dataWatcher.getWatchableObjectByte(19);
}

public void setBicycleVariant(int par1) {
	this.dataWatcher.updateObject(20, Integer.valueOf(par1));
	this.func_110230_cF();
}

public int getBicycleVariant() {
	return this.dataWatcher.getWatchableObjectInt(20);
}

/**
 * Gets the name of this command sender (usually username, but possibly
 * "Rcon")
 */
public String getCommandSenderName() {
	if (this.hasCustomNameTag()) {
		return this.getCustomNameTag();
	} else {
		int i = this.getBicycleType();

		switch (i) {
		case 0:
		default:
			return StatCollector.translateToLocal("entity.Bicycle.name");
		case 1:
			return StatCollector.translateToLocal("entity.donkey.name");
		case 2:
			return StatCollector.translateToLocal("entity.mule.name");
		case 3:
			return StatCollector
					.translateToLocal("entity.zombieBicycle.name");
		case 4:
			return StatCollector
					.translateToLocal("entity.skeletonBicycle.name");
		}
	}
}

private boolean getBicycleWatchableBoolean(int par1) {
	return (this.dataWatcher.getWatchableObjectInt(16) & par1) != 0;
}

private void setBicycleWatchableBoolean(int par1, boolean par2) {
	int j = this.dataWatcher.getWatchableObjectInt(16);

	if (par2) {
		this.dataWatcher.updateObject(16, Integer.valueOf(j | par1));
	} else {
		this.dataWatcher.updateObject(16, Integer.valueOf(j & ~par1));
	}
}

public boolean isAdultBicycle() {
	return !this.isChild();
}

public boolean isTame() {
	return this.getBicycleWatchableBoolean(2);
}

public boolean func_110253_bW() {
	return this.isAdultBicycle();
}

public String getOwnerName() {
	return this.dataWatcher.getWatchableObjectString(21);
}

public void setOwnerName(String par1Str) {
	this.dataWatcher.updateObject(21, par1Str);
}

public float getBicycleSize() {
	int i = this.getGrowingAge();
	return i >= 0 ? 1.0F : 0.5F + (float) (-24000 - i) / -24000.0F * 0.5F;
}

/**
 * "Sets the scale for an ageable entity according to the boolean parameter, which says if it's a child."
 */
public void setScaleForAge(boolean par1) {
	if (par1) {
		this.setScale(this.getBicycleSize());
	} else {
		this.setScale(1.0F);
	}
}

public boolean isBicycleJumping() {
	return this.BicycleJumping;
}

public void setBicycleTamed(boolean par1) {
	this.setBicycleWatchableBoolean(2, par1);
}

public void setBicycleJumping(boolean par1) {
	this.BicycleJumping = par1;
}

public boolean allowLeashing() {
	return !this.func_110256_cu() && super.allowLeashing();
}

protected void func_142017_o(float par1) {
	if (par1 > 6.0F && this.isEatingHaystack()) {
		this.setEatingHaystack(false);
	}
}

public boolean isChested() {
	return this.getBicycleWatchableBoolean(;
}

public int func_110241_cb() {
	return this.dataWatcher.getWatchableObjectInt(22);
}

public boolean isEatingHaystack() {
	return this.getBicycleWatchableBoolean(32);
}

public boolean isRearing() {
	return this.getBicycleWatchableBoolean(64);
}

public boolean func_110205_ce() {
	return this.getBicycleWatchableBoolean(16);
}

public boolean getHasReproduced() {
	return this.hasReproduced;
}

public void func_110242_l(boolean par1) {
	this.setBicycleWatchableBoolean(16, par1);
}

/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) {
	Entity entity = par1DamageSource.getEntity();
	return this.riddenByEntity != null
			&& this.riddenByEntity.equals(entity) ? false : super
			.attackEntityFrom(par1DamageSource, par2);
}

/**
 * Returns the current armor value as determined by a call to
 * InventoryPlayer.getTotalArmorValue
 */
public int getTotalArmorValue() {
	return armorValues[this.func_110241_cb()];
}

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

public boolean prepareChunkForSpawn() {
	int i = MathHelper.floor_double(this.posX);
	int j = MathHelper.floor_double(this.posZ);
	this.worldObj.getBiomeGenForCoords(i, j);
	return true;
}

/**
 * Called when the mob is falling. Calculates and applies fall damage.
 */
protected void fall(float par1) {
	if (par1 > 1.0F) {
		this.playSound("mob.Bicycle.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);
		}
	}
}

private int func_110225_cC() {
	int i = this.getBicycleType();
	return this.isChested() && (i == 1 || i == 2) ? 17 : 2;
}

/**
 * Checks if the entity's current position is a valid location to spawn this
 * entity.
 */
public boolean getCanSpawnHere() {
	this.prepareChunkForSpawn();
	return super.getCanSpawnHere();
}

protected EntityBicycle getClosestBicycle(Entity par1Entity, double par2) {
	double d1 = Double.MAX_VALUE;
	Entity entity1 = null;
	List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(
			par1Entity, par1Entity.boundingBox.addCoord(par2, par2, par2),
			BicycleBreedingSelector);
	Iterator iterator = list.iterator();

	while (iterator.hasNext()) {
		Entity entity2 = (Entity) iterator.next();
		double d2 = entity2.getDistanceSq(par1Entity.posX, par1Entity.posY,
				par1Entity.posZ);

		if (d2 < d1) {
			entity1 = entity2;
			d1 = d2;
		}
	}

	return (EntityBicycle) entity1;
}

public double getBicycleJumpStrength() {
	return this.getEntityAttribute(BicycleJumpStrength).getAttributeValue();
}

/**
 * Returns the sound this mob makes on death.
 */
protected String getDeathSound() {
	this.openBicycleMouth();
	int i = this.getBicycleType();
	return i == 3 ? "mob.Bicycle.zombie.death"
			: (i == 4 ? "mob.Bicycle.skeleton.death"
					: (i != 1 && i != 2 ? "mob.Bicycle.death"
							: "mob.Bicycle.donkey.death"));
}

protected Item getDropItem() {
	boolean flag = this.rand.nextInt(4) == 0;
	int i = this.getBicycleType();
	return i == 4 ? Items.bone : (i == 3 ? (flag ? Item.getItemById(0)
			: Items.rotten_flesh) : Items.leather);
}

/**
 * Returns the sound this mob makes when it is hurt.
 */
protected String getHurtSound() {
	this.openBicycleMouth();

	if (this.rand.nextInt(3) == 0) {
		this.makeBicycleRear();
	}

	int i = this.getBicycleType();
	return i == 3 ? "mob.Bicycle.zombie.hit"
			: (i == 4 ? "mob.Bicycle.skeleton.hit"
					: (i != 1 && i != 2 ? "mob.Bicycle.hit"
							: "mob.Bicycle.donkey.hit"));
}

public boolean isBicycleSaddled() {
	return this.getBicycleWatchableBoolean(4);
}

/**
 * Returns the sound this mob makes while it's alive.
 */
protected String getLivingSound() {
	this.openBicycleMouth();

	if (this.rand.nextInt(10) == 0 && !this.isMovementBlocked()) {
		this.makeBicycleRear();
	}

	int i = this.getBicycleType();
	return i == 3 ? "mob.Bicycle.zombie.idle"
			: (i == 4 ? "mob.Bicycle.skeleton.idle"
					: (i != 1 && i != 2 ? "mob.Bicycle.idle"
							: "mob.Bicycle.donkey.idle"));
}

protected String getAngrySoundName() {
	this.openBicycleMouth();
	this.makeBicycleRear();
	int i = this.getBicycleType();
	return i != 3 && i != 4 ? (i != 1 && i != 2 ? "mob.Bicycle.angry"
			: "mob.Bicycle.donkey.angry") : null;
}

protected void func_145780_a(int p_145780_1_, int p_145780_2_,
		int p_145780_3_, Block p_145780_4_) {
	Block.SoundType soundtype = p_145780_4_.stepSound;

	if (this.worldObj.getBlock(p_145780_1_, p_145780_2_ + 1, p_145780_3_) == Blocks.snow_layer) {
		soundtype = Blocks.snow_layer.stepSound;
	}

	if (!p_145780_4_.getMaterial().isLiquid()) {
		int l = this.getBicycleType();

		if (this.riddenByEntity != null && l != 1 && l != 2) {
			++this.field_110285_bP;

			if (this.field_110285_bP > 5 && this.field_110285_bP % 3 == 0) {
				this.playSound("mob.Bicycle.gallop",
						soundtype.getVolume() * 0.15F, soundtype.getPitch());

				if (l == 0 && this.rand.nextInt(10) == 0) {
					this.playSound("mob.Bicycle.breathe",
							soundtype.getVolume() * 0.6F,
							soundtype.getPitch());
				}
			} else if (this.field_110285_bP <= 5) {
				this.playSound("mob.Bicycle.wood",
						soundtype.getVolume() * 0.15F, soundtype.getPitch());
			}
		} else if (soundtype == Block.soundTypeWood) {
			this.playSound("mob.Bicycle.wood",
					soundtype.getVolume() * 0.15F, soundtype.getPitch());
		} else {
			this.playSound("mob.Bicycle.soft",
					soundtype.getVolume() * 0.15F, soundtype.getPitch());
		}
	}
}

protected void applyEntityAttributes() {
	super.applyEntityAttributes();
	this.getAttributeMap().registerAttribute(BicycleJumpStrength);
	this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.setBaseValue(53.0D);
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
			.setBaseValue(0.22499999403953552D);
}

/**
 * Will return how many at most can spawn in a chunk at once.
 */
public int getMaxSpawnedInChunk() {
	return 6;
}

public int getMaxTemper() {
	return 100;
}

/**
 * Returns the volume for the sounds this mob makes.
 */
protected float getSoundVolume() {
	return 0.8F;
}

/**
 * Get number of ticks, at least during which the living entity will be
 * silent.
 */
public int getTalkInterval() {
	return 400;
}

@SideOnly(Side.CLIENT)
public boolean func_110239_cn() {
	return this.getBicycleType() == 0 || this.func_110241_cb() > 0;
}

private void func_110230_cF() {
	this.field_110286_bQ = null;
}

@SideOnly(Side.CLIENT)
private void setBicycleTexturePaths() {
	this.field_110286_bQ = "Bicycle/";
	this.field_110280_bR[0] = null;
	this.field_110280_bR[1] = null;
	this.field_110280_bR[2] = null;
	int i = this.getBicycleType();
	int j = this.getBicycleVariant();
	int k;

	if (i == 0) {
		k = j & 255;
		int l = (j & 65280) >> 8;
		this.field_110280_bR[0] = BicycleTextures[k];
		this.field_110286_bQ = this.field_110286_bQ + field_110269_bA[k];
		this.field_110280_bR[1] = BicycleMarkingTextures[l];
		this.field_110286_bQ = this.field_110286_bQ + field_110292_bC[l];
	} else {
		this.field_110280_bR[0] = "";
		this.field_110286_bQ = this.field_110286_bQ + "_" + i + "_";
	}

	k = this.func_110241_cb();
	this.field_110280_bR[2] = BicycleArmorTextures[k];
	this.field_110286_bQ = this.field_110286_bQ + field_110273_bx[k];
}

@SideOnly(Side.CLIENT)
public String getBicycleTexture() {
	if (this.field_110286_bQ == null) {
		this.setBicycleTexturePaths();
	}

	return this.field_110286_bQ;
}

@SideOnly(Side.CLIENT)
public String[] getVariantTexturePaths() {
	if (this.field_110286_bQ == null) {
		this.setBicycleTexturePaths();
	}

	return this.field_110280_bR;
}

/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow,
 * gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer par1EntityPlayer) {
	ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();

	if (itemstack != null && itemstack.getItem() == Items.spawn_egg) {
		return super.interact(par1EntityPlayer);
	} else if (!this.isTame() && this.func_110256_cu()) {
		return false;
	}

	else if (this.func_110253_bW() && this.riddenByEntity != null) {
		return super.interact(par1EntityPlayer);
	} else {
		if (itemstack != null) {
			boolean flag = false;

		}

	}

	if (this.func_110253_bW() && this.riddenByEntity == null) {
		if (itemstack != null
				&& itemstack.interactWithEntity(par1EntityPlayer, this)) {
			return true;
		} else {
			this.func_110237_h(par1EntityPlayer);
			return true;
		}
	} else {
		return super.interact(par1EntityPlayer);
	}
}

private void func_110237_h(EntityPlayer par1EntityPlayer) {
	par1EntityPlayer.rotationYaw = this.rotationYaw;
	par1EntityPlayer.rotationPitch = this.rotationPitch;
	this.setEatingHaystack(false);
	this.setRearing(false);

	if (!this.worldObj.isRemote) {
		par1EntityPlayer.mountEntity(this);
	}
}

public boolean func_110259_cr() {
	return this.getBicycleType() == 0;
}

public boolean func_110229_cs() {
	int i = this.getBicycleType();
	return i == 2 || i == 1;
}

/**
 * Dead and sleeping entities cannot move
 */
protected boolean isMovementBlocked() {
	return this.riddenByEntity != null && this.isBicycleSaddled() ? true
			: this.isEatingHaystack() || this.isRearing();
}

public boolean func_110256_cu() {
	int i = this.getBicycleType();
	return i == 3 || i == 4;
}

public boolean func_110222_cv() {
	return this.func_110256_cu() || this.getBicycleType() == 2;
}

/**
 * Checks if the parameter is an item which this animal can be fed to breed
 * it (wheat, carrots or seeds depending on the animal type)
 */
public boolean isBreedingItem(ItemStack par1ItemStack) {
	return false;
}

private void func_110210_cH() {
	this.field_110278_bp = 1;
}

/**
 * Called frequently so the entity can update its state every tick as
 * required. For example, zombies and skeletons use this to react to
 * sunlight and start to burn.
 */
public void onLivingUpdate() {
	if (this.rand.nextInt(200) == 0) {
		this.func_110210_cH();
	}

	super.onLivingUpdate();

	if (!this.worldObj.isRemote) {
		if (this.rand.nextInt(900) == 0 && this.deathTime == 0) {
			this.heal(1.0F);
		}

		if (!this.isEatingHaystack()
				&& this.riddenByEntity == null
				&& this.rand.nextInt(300) == 0
				&& this.worldObj.getBlock(
						MathHelper.floor_double(this.posX),
						MathHelper.floor_double(this.posY) - 1,
						MathHelper.floor_double(this.posZ)) == Blocks.grass) {
			this.setEatingHaystack(true);
		}

		if (this.isEatingHaystack() && ++this.eatingHaystackCounter > 50) {
			this.eatingHaystackCounter = 0;
			this.setEatingHaystack(false);
		}

		if (this.func_110205_ce() && !this.isAdultBicycle()
				&& !this.isEatingHaystack()) {
			EntityBicycle entityBicycle = this.getClosestBicycle(this,
					16.0D);

			if (entityBicycle != null
					&& this.getDistanceSqToEntity(entityBicycle) > 4.0D) {
				PathEntity pathentity = this.worldObj
						.getPathEntityToEntity(this, entityBicycle, 16.0F,
								true, false, false, true);
				this.setPathToEntity(pathentity);
			}
		}
	}
}

/**
 * Called to update the entity's position/logic.
 */
public void onUpdate() {
	super.onUpdate();

	if (this.worldObj.isRemote && this.dataWatcher.hasChanges()) {
		this.dataWatcher.func_111144_e();
		this.func_110230_cF();
	}

	if (this.openMouthCounter > 0 && ++this.openMouthCounter > 30) {
		this.openMouthCounter = 0;
		this.setBicycleWatchableBoolean(128, false);
	}

	if (!this.worldObj.isRemote && this.jumpRearingCounter > 0
			&& ++this.jumpRearingCounter > 20) {
		this.jumpRearingCounter = 0;
		this.setRearing(false);
	}

	if (this.field_110278_bp > 0 && ++this.field_110278_bp >  {
		this.field_110278_bp = 0;
	}

	if (this.field_110279_bq > 0) {
		++this.field_110279_bq;

		if (this.field_110279_bq > 300) {
			this.field_110279_bq = 0;
		}
	}

	this.prevHeadLean = this.headLean;

	if (this.isEatingHaystack()) {
		this.headLean += (1.0F - this.headLean) * 0.4F + 0.05F;

		if (this.headLean > 1.0F) {
			this.headLean = 1.0F;
		}
	} else {
		this.headLean += (0.0F - this.headLean) * 0.4F - 0.05F;

		if (this.headLean < 0.0F) {
			this.headLean = 0.0F;
		}
	}

	this.prevRearingAmount = this.rearingAmount;

	if (this.isRearing()) {
		this.prevHeadLean = this.headLean = 0.0F;
		this.rearingAmount += (1.0F - this.rearingAmount) * 0.4F + 0.05F;

		if (this.rearingAmount > 1.0F) {
			this.rearingAmount = 1.0F;
		}
	} else {
		this.field_110294_bI = false;
		this.rearingAmount += (0.8F * this.rearingAmount
				* this.rearingAmount * this.rearingAmount - this.rearingAmount) * 0.6F - 0.05F;

		if (this.rearingAmount < 0.0F) {
			this.rearingAmount = 0.0F;
		}
	}

	this.prevMouthOpenness = this.mouthOpenness;

	if (this.getBicycleWatchableBoolean(128)) {
		this.mouthOpenness += (1.0F - this.mouthOpenness) * 0.7F + 0.05F;

		if (this.mouthOpenness > 1.0F) {
			this.mouthOpenness = 1.0F;
		}
	} else {
		this.mouthOpenness += (0.0F - this.mouthOpenness) * 0.7F - 0.05F;

		if (this.mouthOpenness < 0.0F) {
			this.mouthOpenness = 0.0F;
		}
	}
}

private void openBicycleMouth() {
	if (!this.worldObj.isRemote) {
		this.openMouthCounter = 1;
		this.setBicycleWatchableBoolean(128, true);
	}
}

private boolean func_110200_cJ() {
	return this.riddenByEntity == null && this.ridingEntity == null
			&& this.isTame() && this.isAdultBicycle()
			&& !this.func_110222_cv()
			&& this.getHealth() >= this.getMaxHealth();
}

public void setEating(boolean par1) {
	this.setBicycleWatchableBoolean(32, par1);
}

public void setEatingHaystack(boolean par1) {
	this.setEating(par1);
}

public void setRearing(boolean par1) {
	if (par1) {
		this.setEatingHaystack(false);
	}

	this.setBicycleWatchableBoolean(64, par1);
}

private void makeBicycleRear() {
	if (!this.worldObj.isRemote) {
		this.jumpRearingCounter = 1;
		this.setRearing(true);
	}
}

public void makeBicycleRearWithSound() {
	this.makeBicycleRear();
	String s = this.getAngrySoundName();

	if (s != null) {
		this.playSound(s, this.getSoundVolume(), this.getSoundPitch());
	}
}

private void dropItemsInChest(Entity par1Entity, AnimalChest par2AnimalChest) {
	if (par2AnimalChest != null && !this.worldObj.isRemote) {
		for (int i = 0; i < par2AnimalChest.getSizeInventory(); ++i) {
			ItemStack itemstack = par2AnimalChest.getStackInSlot(i);

			if (itemstack != null) {
				this.entityDropItem(itemstack, 0.0F);
			}
		}
	}
}

public boolean setTamedBy(EntityPlayer par1EntityPlayer) {
	this.setOwnerName(par1EntityPlayer.getCommandSenderName());
	this.setBicycleTamed(true);
	return true;
}

/**
 * Moves the entity based on the specified heading. Args: strafe, forward
 */
public void moveEntityWithHeading(float par1, float par2) {
	if (this.riddenByEntity != null && this.isBicycleSaddled()) {
		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;
		par1 = ((EntityLivingBase) this.riddenByEntity).moveStrafing * 0.5F;
		par2 = ((EntityLivingBase) this.riddenByEntity).moveForward;

		if (par2 <= 0.0F) {
			par2 *= 0.25F;
			this.field_110285_bP = 0;
		}

		if (this.onGround && this.jumpPower == 0.0F && this.isRearing()
				&& !this.field_110294_bI) {
			par1 = 0.0F;
			par2 = 0.0F;
		}

		if (this.jumpPower > 0.0F && !this.isBicycleJumping()
				&& this.onGround) {
			this.motionY = this.getBicycleJumpStrength()
					* (double) this.jumpPower;

			if (this.isPotionActive(Potion.jump)) {
				this.motionY += (double) ((float) (this
						.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
			}

			this.setBicycleJumping(true);
			this.isAirBorne = true;

			if (par2 > 0.0F) {
				float f2 = MathHelper.sin(this.rotationYaw
						* (float) Math.PI / 180.0F);
				float f3 = MathHelper.cos(this.rotationYaw
						* (float) Math.PI / 180.0F);
				this.motionX += (double) (-0.4F * f2 * this.jumpPower);
				this.motionZ += (double) (0.4F * f3 * this.jumpPower);
				this.playSound("mob.Bicycle.jump", 0.4F, 1.0F);
			}

			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());
			super.moveEntityWithHeading(par1, par2);
		}

		if (this.onGround) {
			this.jumpPower = 0.0F;
			this.setBicycleJumping(false);
		}

		this.prevLimbSwingAmount = this.limbSwingAmount;
		double d1 = this.posX - this.prevPosX;
		double d0 = this.posZ - this.prevPosZ;
		float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;

		if (f4 > 1.0F) {
			f4 = 1.0F;
		}

		this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
		this.limbSwing += this.limbSwingAmount;
	} else {
		this.stepHeight = 0.5F;
		this.jumpMovementFactor = 0.02F;
		super.moveEntityWithHeading(par1, par2);
	}
}

/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
	super.writeEntityToNBT(par1NBTTagCompound);
	par1NBTTagCompound
			.setBoolean("EatingHaystack", this.isEatingHaystack());
	par1NBTTagCompound.setBoolean("ChestedBicycle", this.isChested());
	par1NBTTagCompound.setBoolean("HasReproduced", this.getHasReproduced());
	par1NBTTagCompound.setBoolean("Bred", this.func_110205_ce());
	par1NBTTagCompound.setInteger("Type", this.getBicycleType());
	par1NBTTagCompound.setInteger("Variant", this.getBicycleVariant());
	par1NBTTagCompound.setBoolean("Tame", this.isTame());
	par1NBTTagCompound.setString("OwnerName", this.getOwnerName());

	if (this.isChested()) {
		NBTTagList nbttaglist = new NBTTagList();

		for (int i = 2; i < this.BicycleChest.getSizeInventory(); ++i) {
			ItemStack itemstack = this.BicycleChest.getStackInSlot(i);

			if (itemstack != null) {
				NBTTagCompound nbttagcompound1 = new NBTTagCompound();
				nbttagcompound1.setByte("Slot", (byte) i);
				itemstack.writeToNBT(nbttagcompound1);
				nbttaglist.appendTag(nbttagcompound1);
			}
		}

		par1NBTTagCompound.setTag("Items", nbttaglist);
	}


}

/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
	super.readEntityFromNBT(par1NBTTagCompound);
	this.setEatingHaystack(par1NBTTagCompound.getBoolean("EatingHaystack"));
	this.func_110242_l(par1NBTTagCompound.getBoolean("Bred"));
	this.setBicycleType(par1NBTTagCompound.getInteger("Type"));
	this.setBicycleVariant(par1NBTTagCompound.getInteger("Variant"));
	this.setBicycleTamed(par1NBTTagCompound.getBoolean("Tame"));

	if (par1NBTTagCompound.hasKey("OwnerName", ) {
		this.setOwnerName(par1NBTTagCompound.getString("OwnerName"));
	}

	IAttributeInstance iattributeinstance = this.getAttributeMap()
			.getAttributeInstanceByName("Speed");

	if (iattributeinstance != null) {
		this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
				.setBaseValue(iattributeinstance.getBaseValue() * 0.25D);
	}

	ItemStack itemstack;

	if (par1NBTTagCompound.hasKey("SaddleItem", 10)) {
		itemstack = ItemStack.loadItemStackFromNBT(par1NBTTagCompound
				.getCompoundTag("SaddleItem"));

		if (itemstack != null && itemstack.getItem() == Items.saddle) {
			this.BicycleChest.setInventorySlotContents(0, itemstack);
		}
	} else if (par1NBTTagCompound.getBoolean("Saddle")) {
		this.BicycleChest.setInventorySlotContents(0, new ItemStack(
				Items.saddle));
	}

}

/**
 * Returns true if the mob is currently able to mate with the specified mob.
 */
public boolean canMateWith(EntityAnimal par1EntityAnimal) {
	if (par1EntityAnimal == this) {
		return false;
	} else if (par1EntityAnimal.getClass() != this.getClass()) {
		return false;
	} else {
		EntityBicycle entityBicycle = (EntityBicycle) par1EntityAnimal;

		if (this.func_110200_cJ() && entityBicycle.func_110200_cJ()) {
			int i = this.getBicycleType();
			int j = entityBicycle.getBicycleType();
			return i == j || i == 0 && j == 1 || i == 1 && j == 0;
		} else {
			return false;
		}
	}
}

public EntityAgeable createChild(EntityAgeable par1EntityAgeable) {
	EntityBicycle entityBicycle = (EntityBicycle) par1EntityAgeable;
	EntityBicycle entityBicycle1 = new EntityBicycle(this.worldObj);
	int i = this.getBicycleType();
	int j = entityBicycle.getBicycleType();
	int k = 0;

	if (i == j) {
		k = i;
	} else if (i == 0 && j == 1 || i == 1 && j == 0) {
		k = 2;
	}

	if (k == 0) {
		int i1 = this.rand.nextInt(9);
		int l;

		if (i1 < 4) {
			l = this.getBicycleVariant() & 255;
		} else if (i1 <  {
			l = entityBicycle.getBicycleVariant() & 255;
		} else {
			l = this.rand.nextInt(7);
		}

		int j1 = this.rand.nextInt(5);

		if (j1 < 2) {
			l |= this.getBicycleVariant() & 65280;
		} else if (j1 < 4) {
			l |= entityBicycle.getBicycleVariant() & 65280;
		} else {
			l |= this.rand.nextInt(5) << 8 & 65280;
		}

		entityBicycle1.setBicycleVariant(l);
	}

	entityBicycle1.setBicycleType(k);
	double d1 = this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.getBaseValue()
			+ par1EntityAgeable.getEntityAttribute(
					SharedMonsterAttributes.maxHealth).getBaseValue()
			+ (double) this.func_110267_cL();
	entityBicycle1.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.setBaseValue(d1 / 3.0D);
	double d2 = this.getEntityAttribute(BicycleJumpStrength).getBaseValue()
			+ par1EntityAgeable.getEntityAttribute(BicycleJumpStrength)
					.getBaseValue() + this.func_110245_cM();
	entityBicycle1.getEntityAttribute(BicycleJumpStrength).setBaseValue(
			d2 / 3.0D);
	double d0 = this.getEntityAttribute(
			SharedMonsterAttributes.movementSpeed).getBaseValue()
			+ par1EntityAgeable.getEntityAttribute(
					SharedMonsterAttributes.movementSpeed).getBaseValue()
			+ this.func_110203_cN();
	entityBicycle1
			.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
			.setBaseValue(d0 / 3.0D);
	return entityBicycle1;
}

public IEntityLivingData onSpawnWithEgg(
		IEntityLivingData par1EntityLivingData) {
	Object p_110161_1_1 = super.onSpawnWithEgg(par1EntityLivingData);
	boolean flag = false;
	int i = 0;
	int l;

	if (p_110161_1_1 instanceof EntityBicycle.GroupData) {
		l = ((EntityBicycle.GroupData) p_110161_1_1).field_111107_a;
		i = ((EntityBicycle.GroupData) p_110161_1_1).field_111106_b & 255
				| this.rand.nextInt(5) << 8;
	} else {
		if (this.rand.nextInt(10) == 0) {
			l = 1;
		} else {
			int j = this.rand.nextInt(7);
			int k = this.rand.nextInt(5);
			l = 0;
			i = j | k << 8;
		}

		p_110161_1_1 = new EntityBicycle.GroupData(l, i);
	}

	this.setBicycleType(l);
	this.setBicycleVariant(i);

	if (this.rand.nextInt(5) == 0) {
		this.setGrowingAge(-24000);
	}

	if (l != 4 && l != 3) {
		this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
				.setBaseValue((double) this.func_110267_cL());

		if (l == 0) {
			this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
					.setBaseValue(this.func_110203_cN());
		} else {
			this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
					.setBaseValue(0.17499999701976776D);
		}
	} else {
		this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
				.setBaseValue(15.0D);
		this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
				.setBaseValue(0.20000000298023224D);
	}

	if (l != 2 && l != 1) {
		this.getEntityAttribute(BicycleJumpStrength).setBaseValue(
				this.func_110245_cM());
	} else {
		this.getEntityAttribute(BicycleJumpStrength).setBaseValue(0.5D);
	}

	this.setHealth(this.getMaxHealth());
	return (IEntityLivingData) p_110161_1_1;
}

@SideOnly(Side.CLIENT)
public float getGrassEatingAmount(float par1) {
	return this.prevHeadLean + (this.headLean - this.prevHeadLean) * par1;
}

@SideOnly(Side.CLIENT)
public float getRearingAmount(float par1) {
	return this.prevRearingAmount
			+ (this.rearingAmount - this.prevRearingAmount) * par1;
}

@SideOnly(Side.CLIENT)
public float func_110201_q(float par1) {
	return this.prevMouthOpenness
			+ (this.mouthOpenness - this.prevMouthOpenness) * par1;
}

/**
 * Returns true if the newer Entity AI code should be run
 */
protected boolean isAIEnabled() {
	return true;
}

public void setJumpPower(int par1) {
	if (this.isBicycleSaddled()) {
		if (par1 < 0) {
			par1 = 0;
		} else {
			this.field_110294_bI = true;
			this.makeBicycleRear();
		}

		if (par1 >= 90) {
			this.jumpPower = 1.0F;
		} else {
			this.jumpPower = 0.4F + 0.4F * (float) par1 / 90.0F;
		}
	}
}

/**
 * "Spawns particles for the Bicycle entity. par1 tells whether to spawn hearts. If it is false, it spawns smoke."
 */
@SideOnly(Side.CLIENT)
protected void spawnBicycleParticles(boolean par1) {
	String s = par1 ? "heart" : "smoke";

	for (int i = 0; i < 7; ++i) {
		double d0 = this.rand.nextGaussian() * 0.02D;
		double d1 = this.rand.nextGaussian() * 0.02D;
		double d2 = this.rand.nextGaussian() * 0.02D;
		this.worldObj
				.spawnParticle(
						s,
						this.posX
								+ (double) (this.rand.nextFloat()
										* this.width * 2.0F)
								- (double) this.width,
						this.posY
								+ 0.5D
								+ (double) (this.rand.nextFloat() * this.height),
						this.posZ
								+ (double) (this.rand.nextFloat()
										* this.width * 2.0F)
								- (double) this.width, d0, d1, d2);
	}
}

@SideOnly(Side.CLIENT)
public void handleHealthUpdate(byte par1) {
	if (par1 == 7) {
		this.spawnBicycleParticles(true);
	} else if (par1 == 6) {
		this.spawnBicycleParticles(false);
	} else {
		super.handleHealthUpdate(par1);
	}
}

public void updateRiderPosition() {
	super.updateRiderPosition();

	if (this.prevRearingAmount > 0.0F) {
		float f = MathHelper.sin(this.renderYawOffset * (float) Math.PI
				/ 180.0F);
		float f1 = MathHelper.cos(this.renderYawOffset * (float) Math.PI
				/ 180.0F);
		float f2 = 0.7F * this.prevRearingAmount;
		float f3 = 0.15F * this.prevRearingAmount;
		this.riddenByEntity.setPosition(
				this.posX + (double) (f2 * f),
				this.posY + this.getMountedYOffset()
						+ this.riddenByEntity.getYOffset() + (double) f3,
				this.posZ - (double) (f2 * f1));

		if (this.riddenByEntity instanceof EntityLivingBase) {
			((EntityLivingBase) this.riddenByEntity).renderYawOffset = this.renderYawOffset;
		}
	}
}

private float func_110267_cL() {
	return 15.0F + (float) this.rand.nextInt(
			+ (float) this.rand.nextInt(9);
}

private double func_110245_cM() {
	return 0.4000000059604645D + this.rand.nextDouble() * 0.2D
			+ this.rand.nextDouble() * 0.2D + this.rand.nextDouble() * 0.2D;
}

private double func_110203_cN() {
	return (0.44999998807907104D + this.rand.nextDouble() * 0.3D
			+ this.rand.nextDouble() * 0.3D + this.rand.nextDouble() * 0.3D) * 0.25D;
}

/**
 * returns true if this entity is by a ladder, false otherwise
 */
public boolean isOnLadder() {
	return false;
}

public static class GroupData implements IEntityLivingData {
	public int field_111107_a;
	public int field_111106_b;
	private static final String __OBFID = "CL_00001643";

	public GroupData(int par1, int par2) {
		this.field_111107_a = par1;
		this.field_111106_b = par2;
	}
}
} 

 

 

 

VehicleRenderBicyclce class

 

 

 @SideOnly(Side.CLIENT)
public class VehicleRenderBicycle extends Render
{
    private static final ResourceLocation bicycleTextures = new ResourceLocation("mymod:textures/items/bicycle.png");
    /** instance of ModelBoat for rendering */
    protected ModelBase modelBicycle;
  

    public VehicleRenderBicycle()
    {
        this.shadowSize = 0.5F;
        this.modelBicycle = new VehicleModelBicycle();
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(EntityBicycle par1EntityBicycle, double par2, double par4, double par6, float par8, float par9)
    {
        GL11.glPushMatrix();
        GL11.glTranslatef((float)par2, (float)par4, (float)par6);
        GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(0F, 0.6F, 0.8F);
        GL11.glScalef(-0.6F, -0.6F, 0.6F);
        this.bindEntityTexture(par1EntityBicycle);
        this.modelBicycle.render(par1EntityBicycle, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        GL11.glPopMatrix();
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(EntityBicycle par1EntityBicycle)
    {
        return bicycleTextures;
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(Entity par1Entity)
    {
        return this.getEntityTexture((EntityBicycle)par1Entity);
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
        this.doRender((EntityBicycle)par1Entity, par2, par4, par6, par8, par9);
    }
}

 

 

 

Bicycle Item Class

 

 

 public class Bicycle extends Item
{
     public Bicycle()
    {
        this.maxStackSize = 1;
       
    }

    /**
     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
     */
    public ItemStack onItemRightClick(ItemStack par1ItemStack, World world, EntityPlayer par3EntityPlayer)
    {
        float f = 1.0F;
        float f1 = par3EntityPlayer.prevRotationPitch + (par3EntityPlayer.rotationPitch - par3EntityPlayer.prevRotationPitch) * f;
        float f2 = par3EntityPlayer.prevRotationYaw + (par3EntityPlayer.rotationYaw - par3EntityPlayer.prevRotationYaw) * f;
        double d0 = par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * (double)f;
        double d1 = par3EntityPlayer.prevPosY + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * (double)f + 1.62D - (double)par3EntityPlayer.yOffset;
        double d2 = par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * (double)f;
        Vec3 vec3 = world.getWorldVec3Pool().getVecFromPool(d0, d1, d2);
        float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
        float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
        float f5 = -MathHelper.cos(-f1 * 0.017453292F);
        float f6 = MathHelper.sin(-f1 * 0.017453292F);
        float f7 = f4 * f5;
        float f8 = f3 * f5;
        double d3 = 5.0D;
        Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3);
        MovingObjectPosition movingobjectposition = world.rayTraceBlocks(vec3, vec31, true);

        if (movingobjectposition == null)
        {
            return par1ItemStack;
        }
        else
        {
            Vec3 vec32 = par3EntityPlayer.getLook(f);
            boolean flag = false;
            float f9 = 1.0F;
            List list = world.getEntitiesWithinAABBExcludingEntity(par3EntityPlayer, par3EntityPlayer.boundingBox.addCoord(vec32.xCoord * d3, vec32.yCoord * d3, vec32.zCoord * d3).expand((double)f9, (double)f9, (double)f9));
            int i;

            for (i = 0; i < list.size(); ++i)
            {
                Entity entity = (Entity)list.get(i);

                if (entity.canBeCollidedWith())
                {
                    float f10 = entity.getCollisionBorderSize();
                    AxisAlignedBB axisalignedbb = entity.boundingBox.expand((double)f10, (double)f10, (double)f10);

                    if (axisalignedbb.isVecInside(vec3))
                    {
                        flag = true;
                    }
                }
            }

            if (flag)
            {
                return par1ItemStack;
            }
            else
            {
                if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
                {
                    i = movingobjectposition.blockX;
                    int j = movingobjectposition.blockY;
                    int k = movingobjectposition.blockZ;

                    if (world.getBlock(i, j, k) == Blocks.snow_layer)
                    {
                        --j;
                    }

                    EntityBicycle entityBicycle = new EntityBicycle(world, (double)((float)i + 0.5F), (double)((float)j + 1.0F), (double)((float)k + 0.5F));
                    entityBicycle.rotationYaw = (float)(((MathHelper.floor_double((double)(par3EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) - 1) * 90);

                    if (!world.getCollidingBoundingBoxes(entityBicycle, entityBicycle.boundingBox.expand(-0.1D, -0.1D, -0.1D)).isEmpty())
                    {
                        return par1ItemStack;
                    }

                    if (!world.isRemote)
                    {
                        world.spawnEntityInWorld(entityBicycle);
                    }

                    if (!par3EntityPlayer.capabilities.isCreativeMode)
                    {
                        --par1ItemStack.stackSize;
                    }
                }

                return par1ItemStack;
            }
        }
    }

 

 

Any help is very much appreciated. I want my bicycle to work exactly like the horse but I want it to be an item. I have been at it for quite some time trying to understand how it works but currently am at a loss.

Posted

I changed isMovementBlocked to

 
	protected boolean isMovementBlocked() {
	return this.riddenByEntity != null;

}		

and got rid of a bunch of the Chested and Eating Hay stuff and also eliminated any references to saddle so this is my Entity File as of right now but still I can mount it but it will not move. One thing that did change is that when I turn the bicycle turns with the player where before only the player turned. where should I put the print line you suggested.

 

Updated EntityBicycle class

 

 

public class EntityBicycle extends EntityAnimal {
private static final IEntitySelector BicycleBreedingSelector = new IEntitySelector() {

	/**
	 * Return whether the specified entity is applicable to this filter.
	 */
	public boolean isEntityApplicable(Entity par1Entity) {
		return par1Entity instanceof EntityBicycle
				&& ((EntityBicycle) par1Entity).func_110205_ce();
	}
};
private static final IAttribute BicycleJumpStrength = (new RangedAttribute(
		"Bicycle.jumpStrength", 0.7D, 0.0D, 2.0D)).setDescription(
		"Jump Strength").setShouldWatch(true);

private static final String[] field_110273_bx = new String[] { "", "meo",
		"goo", "dio" };
private static final int[] armorValues = new int[] { 0, 5, 7, 11 };
private static final String[] BicycleTextures = new String[] {
		"textures/entity/Bicycle/Bicycle_white.png",
		"textures/entity/Bicycle/Bicycle_creamy.png",
		"textures/entity/Bicycle/Bicycle_chestnut.png",
		"textures/entity/Bicycle/Bicycle_brown.png",
		"textures/entity/Bicycle/Bicycle_black.png",
		"textures/entity/Bicycle/Bicycle_gray.png",
		"textures/entity/Bicycle/Bicycle_darkbrown.png" };
private static final String[] field_110269_bA = new String[] { "hwh",
		"hcr", "hch", "hbr", "hbl", "hgr", "hdb" };
private static final String[] BicycleMarkingTextures = new String[] { null,
		"textures/entity/Bicycle/Bicycle_markings_white.png",
		"textures/entity/Bicycle/Bicycle_markings_whitefield.png",
		"textures/entity/Bicycle/Bicycle_markings_whitedots.png",
		"textures/entity/Bicycle/Bicycle_markings_blackdots.png" };
private static final String[] field_110292_bC = new String[] { "", "wo_",
		"wmo", "wdo", "bdo" };
private int eatingHaystackCounter;
private int openMouthCounter;
private int jumpRearingCounter;
public int field_110278_bp;
public int field_110279_bq;
protected boolean BicycleJumping;
private AnimalChest BicycleChest;
private boolean hasReproduced;
/**
 * "The higher this value, the more likely the Bicycle is to be tamed next time a player rides it."
 */
protected int temper;
protected float jumpPower;
private boolean field_110294_bI;
private float headLean;
private float prevHeadLean;
private float rearingAmount;
private float prevRearingAmount;
private float mouthOpenness;
private float prevMouthOpenness;
private int field_110285_bP;
private String field_110286_bQ;
private String[] field_110280_bR = new String[3];
private static final String __OBFID = "CL_00001641";

public EntityBicycle(World par1World) {
	super(par1World);
	this.setSize(1.4F, 1.6F);

}

public EntityBicycle(World par1World, double par2, double par4, double par6) {
	this(par1World);
	this.setPosition(par2, par4 + (double) this.yOffset, par6);
	this.motionX = 0.0D;
	this.motionY = 0.0D;
	this.motionZ = 0.0D;
	this.prevPosX = par2;
	this.prevPosY = par4;
	this.prevPosZ = par6;
}

protected void entityInit() {
	super.entityInit();
	this.dataWatcher.addObject(16, Integer.valueOf(0));
	this.dataWatcher.addObject(19, Byte.valueOf((byte) 0));
	this.dataWatcher.addObject(20, Integer.valueOf(0));
	this.dataWatcher.addObject(21, String.valueOf(""));
	this.dataWatcher.addObject(22, Integer.valueOf(0));
}

public void setBicycleType(int par1) {
	this.dataWatcher.updateObject(19, Byte.valueOf((byte) par1));
	this.func_110230_cF();
}

/**
 * returns the Bicycle type
 */
public int getBicycleType() {
	return this.dataWatcher.getWatchableObjectByte(19);
}

public void setBicycleVariant(int par1) {
	this.dataWatcher.updateObject(20, Integer.valueOf(par1));
	this.func_110230_cF();
}

public int getBicycleVariant() {
	return this.dataWatcher.getWatchableObjectInt(20);
}

/**
 * Gets the name of this command sender (usually username, but possibly
 * "Rcon")
 */
public String getCommandSenderName() {
	if (this.hasCustomNameTag()) {
		return this.getCustomNameTag();
	} else {
		int i = this.getBicycleType();

		switch (i) {
		case 0:
		default:
			return StatCollector.translateToLocal("entity.Bicycle.name");
		case 1:
			return StatCollector.translateToLocal("entity.donkey.name");
		case 2:
			return StatCollector.translateToLocal("entity.mule.name");
		case 3:
			return StatCollector
					.translateToLocal("entity.zombieBicycle.name");
		case 4:
			return StatCollector
					.translateToLocal("entity.skeletonBicycle.name");
		}
	}
}

private boolean getBicycleWatchableBoolean(int par1) {
	return (this.dataWatcher.getWatchableObjectInt(16) & par1) != 0;
}

private void setBicycleWatchableBoolean(int par1, boolean par2) {
	int j = this.dataWatcher.getWatchableObjectInt(16);

	if (par2) {
		this.dataWatcher.updateObject(16, Integer.valueOf(j | par1));
	} else {
		this.dataWatcher.updateObject(16, Integer.valueOf(j & ~par1));
	}
}

public boolean isAdultBicycle() {
	return !this.isChild();
}

public boolean isTame() {
	return this.getBicycleWatchableBoolean(2);
}

public boolean func_110253_bW() {
	return this.isAdultBicycle();
}

public String getOwnerName() {
	return this.dataWatcher.getWatchableObjectString(21);
}

public void setOwnerName(String par1Str) {
	this.dataWatcher.updateObject(21, par1Str);
}

public float getBicycleSize() {
	int i = this.getGrowingAge();
	return i >= 0 ? 1.0F : 0.5F + (float) (-24000 - i) / -24000.0F * 0.5F;
}

/**
 * "Sets the scale for an ageable entity according to the boolean parameter, which says if it's a child."
 */
public void setScaleForAge(boolean par1) {
	if (par1) {
		this.setScale(this.getBicycleSize());
	} else {
		this.setScale(1.0F);
	}
}

public boolean isBicycleJumping() {
	return this.BicycleJumping;
}

public void setBicycleTamed(boolean par1) {
	this.setBicycleWatchableBoolean(2, par1);
}

public void setBicycleJumping(boolean par1) {
	this.BicycleJumping = par1;
}

public boolean allowLeashing() {
	return !this.func_110256_cu() && super.allowLeashing();
}


public int func_110241_cb() {
	return this.dataWatcher.getWatchableObjectInt(22);
}


public boolean func_110205_ce() {
	return this.getBicycleWatchableBoolean(16);
}

public boolean getHasReproduced() {
	return this.hasReproduced;
}

public void func_110242_l(boolean par1) {
	this.setBicycleWatchableBoolean(16, par1);
}

/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) {
	Entity entity = par1DamageSource.getEntity();
	return this.riddenByEntity != null
			&& this.riddenByEntity.equals(entity) ? false : super
			.attackEntityFrom(par1DamageSource, par2);
}

/**
 * Returns the current armor value as determined by a call to
 * InventoryPlayer.getTotalArmorValue
 */
public int getTotalArmorValue() {
	return armorValues[this.func_110241_cb()];
}

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

public boolean prepareChunkForSpawn() {
	int i = MathHelper.floor_double(this.posX);
	int j = MathHelper.floor_double(this.posZ);
	this.worldObj.getBiomeGenForCoords(i, j);
	return true;
}

/**
 * Called when the mob is falling. Calculates and applies fall damage.
 */
protected void fall(float par1) {
	if (par1 > 1.0F) {
		this.playSound("mob.Bicycle.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);
		}
	}
}



/**
 * Checks if the entity's current position is a valid location to spawn this
 * entity.
 */
public boolean getCanSpawnHere() {
	this.prepareChunkForSpawn();
	return super.getCanSpawnHere();
}

protected EntityBicycle getClosestBicycle(Entity par1Entity, double par2) {
	double d1 = Double.MAX_VALUE;
	Entity entity1 = null;
	List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(
			par1Entity, par1Entity.boundingBox.addCoord(par2, par2, par2),
			BicycleBreedingSelector);
	Iterator iterator = list.iterator();

	while (iterator.hasNext()) {
		Entity entity2 = (Entity) iterator.next();
		double d2 = entity2.getDistanceSq(par1Entity.posX, par1Entity.posY,
				par1Entity.posZ);

		if (d2 < d1) {
			entity1 = entity2;
			d1 = d2;
		}
	}

	return (EntityBicycle) entity1;
}

public double getBicycleJumpStrength() {
	return this.getEntityAttribute(BicycleJumpStrength).getAttributeValue();
}

/**
 * Returns the sound this mob makes on death.
 */
protected String getDeathSound() {
	this.openBicycleMouth();
	int i = this.getBicycleType();
	return i == 3 ? "mob.Bicycle.zombie.death"
			: (i == 4 ? "mob.Bicycle.skeleton.death"
					: (i != 1 && i != 2 ? "mob.Bicycle.death"
							: "mob.Bicycle.donkey.death"));
}

protected Item getDropItem() {
	boolean flag = this.rand.nextInt(4) == 0;
	int i = this.getBicycleType();
	return i == 4 ? Items.bone : (i == 3 ? (flag ? Item.getItemById(0)
			: Items.rotten_flesh) : Items.leather);
}

/**
 * Returns the sound this mob makes when it is hurt.
 */
protected String getHurtSound() {
	this.openBicycleMouth();

	if (this.rand.nextInt(3) == 0) {
		this.makeBicycleRear();
	}

	int i = this.getBicycleType();
	return i == 3 ? "mob.Bicycle.zombie.hit"
			: (i == 4 ? "mob.Bicycle.skeleton.hit"
					: (i != 1 && i != 2 ? "mob.Bicycle.hit"
							: "mob.Bicycle.donkey.hit"));
}


/**
 * Returns the sound this mob makes while it's alive.
 */
protected String getLivingSound() {
	this.openBicycleMouth();

	if (this.rand.nextInt(10) == 0 && !this.isMovementBlocked()) {
		this.makeBicycleRear();
	}

	int i = this.getBicycleType();
	return i == 3 ? "mob.Bicycle.zombie.idle"
			: (i == 4 ? "mob.Bicycle.skeleton.idle"
					: (i != 1 && i != 2 ? "mob.Bicycle.idle"
							: "mob.Bicycle.donkey.idle"));
}

protected String getAngrySoundName() {
	this.openBicycleMouth();
	this.makeBicycleRear();
	int i = this.getBicycleType();
	return i != 3 && i != 4 ? (i != 1 && i != 2 ? "mob.Bicycle.angry"
			: "mob.Bicycle.donkey.angry") : null;
}

protected void func_145780_a(int p_145780_1_, int p_145780_2_,
		int p_145780_3_, Block p_145780_4_) {
	Block.SoundType soundtype = p_145780_4_.stepSound;

	if (this.worldObj.getBlock(p_145780_1_, p_145780_2_ + 1, p_145780_3_) == Blocks.snow_layer) {
		soundtype = Blocks.snow_layer.stepSound;
	}

	if (!p_145780_4_.getMaterial().isLiquid()) {
		int l = this.getBicycleType();

		if (this.riddenByEntity != null && l != 1 && l != 2) {
			++this.field_110285_bP;

			if (this.field_110285_bP > 5 && this.field_110285_bP % 3 == 0) {
				this.playSound("mob.Bicycle.gallop",
						soundtype.getVolume() * 0.15F, soundtype.getPitch());

				if (l == 0 && this.rand.nextInt(10) == 0) {
					this.playSound("mob.Bicycle.breathe",
							soundtype.getVolume() * 0.6F,
							soundtype.getPitch());
				}
			} else if (this.field_110285_bP <= 5) {
				this.playSound("mob.Bicycle.wood",
						soundtype.getVolume() * 0.15F, soundtype.getPitch());
			}
		} else if (soundtype == Block.soundTypeWood) {
			this.playSound("mob.Bicycle.wood",
					soundtype.getVolume() * 0.15F, soundtype.getPitch());
		} else {
			this.playSound("mob.Bicycle.soft",
					soundtype.getVolume() * 0.15F, soundtype.getPitch());
		}
	}
}

protected void applyEntityAttributes() {
	super.applyEntityAttributes();
	this.getAttributeMap().registerAttribute(BicycleJumpStrength);
	this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.setBaseValue(53.0D);
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
			.setBaseValue(0.22499999403953552D);
}

/**
 * Will return how many at most can spawn in a chunk at once.
 */
public int getMaxSpawnedInChunk() {
	return 6;
}

public int getMaxTemper() {
	return 100;
}

/**
 * Returns the volume for the sounds this mob makes.
 */
protected float getSoundVolume() {
	return 0.8F;
}

/**
 * Get number of ticks, at least during which the living entity will be
 * silent.
 */
public int getTalkInterval() {
	return 400;
}

@SideOnly(Side.CLIENT)
public boolean func_110239_cn() {
	return this.getBicycleType() == 0 || this.func_110241_cb() > 0;
}

private void func_110230_cF() {
	this.field_110286_bQ = null;
}

@SideOnly(Side.CLIENT)
private void setBicycleTexturePaths() {
	this.field_110286_bQ = "Bicycle/";
	this.field_110280_bR[0] = null;
	this.field_110280_bR[1] = null;
	this.field_110280_bR[2] = null;
	int i = this.getBicycleType();
	int j = this.getBicycleVariant();
	int k;

	if (i == 0) {
		k = j & 255;
		int l = (j & 65280) >> 8;
		this.field_110280_bR[0] = BicycleTextures[k];
		this.field_110286_bQ = this.field_110286_bQ + field_110269_bA[k];
		this.field_110280_bR[1] = BicycleMarkingTextures[l];
		this.field_110286_bQ = this.field_110286_bQ + field_110292_bC[l];
	} else {
		this.field_110280_bR[0] = "";
		this.field_110286_bQ = this.field_110286_bQ + "_" + i + "_";
	}

	k = this.func_110241_cb();

	this.field_110286_bQ = this.field_110286_bQ + field_110273_bx[k];
}

@SideOnly(Side.CLIENT)
public String getBicycleTexture() {
	if (this.field_110286_bQ == null) {
		this.setBicycleTexturePaths();
	}

	return this.field_110286_bQ;
}

@SideOnly(Side.CLIENT)
public String[] getVariantTexturePaths() {
	if (this.field_110286_bQ == null) {
		this.setBicycleTexturePaths();
	}

	return this.field_110280_bR;
}

/**
 * Called when a player interacts with a mob.*/
public boolean interact(EntityPlayer par1EntityPlayer) {
	ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();

	if (itemstack != null && itemstack.getItem() == Items.spawn_egg) {
		return super.interact(par1EntityPlayer);
	} else if (!this.isTame() && this.func_110256_cu()) {
		return false;
	}

	else if (this.func_110253_bW() && this.riddenByEntity != null) {
		return super.interact(par1EntityPlayer);
	} else {
		if (itemstack != null) {
			boolean flag = false;

		}

	}

	if (this.func_110253_bW() && this.riddenByEntity == null) {
		if (itemstack != null
				&& itemstack.interactWithEntity(par1EntityPlayer, this)) {
			return true;
		} else {
			this.func_110237_h(par1EntityPlayer);
			return true;
		}
	} else {
		return super.interact(par1EntityPlayer);
	}
}

private void func_110237_h(EntityPlayer par1EntityPlayer) {
	par1EntityPlayer.rotationYaw = this.rotationYaw;
	par1EntityPlayer.rotationPitch = this.rotationPitch;
	this.setEatingHaystack(false);
	this.setRearing(false);

	if (!this.worldObj.isRemote) {
		par1EntityPlayer.mountEntity(this);
	}
}

public boolean func_110259_cr() {
	return this.getBicycleType() == 0;
}

public boolean func_110229_cs() {
	int i = this.getBicycleType();
	return i == 2 || i == 1;
}

/**
 * Dead and sleeping entities cannot move
 */
protected boolean isMovementBlocked() {
	return this.riddenByEntity != null;

}

public boolean func_110256_cu() {
	int i = this.getBicycleType();
	return i == 3 || i == 4;
}

public boolean func_110222_cv() {
	return this.func_110256_cu() || this.getBicycleType() == 2;
}

/**
 * Checks if the parameter is an item which this animal can be fed to breed
 * it (wheat, carrots or seeds depending on the animal type)
 */
public boolean isBreedingItem(ItemStack par1ItemStack) {
	return false;
}

private void func_110210_cH() {
	this.field_110278_bp = 1;
}

/**
 * Called frequently so the entity can update its state every tick as
 * required. For example, zombies and skeletons use this to react to
 * sunlight and start to burn.
 */
public void onLivingUpdate() {
	if (this.rand.nextInt(200) == 0) {
		this.func_110210_cH();
	}

	super.onLivingUpdate();

	if (!this.worldObj.isRemote) {
		if (this.rand.nextInt(900) == 0 && this.deathTime == 0) {
			this.heal(1.0F);
		}

	}
}

/**
 * Called to update the entity's position/logic.
 */
public void onUpdate() {
	super.onUpdate();

	if (this.worldObj.isRemote && this.dataWatcher.hasChanges()) {
		this.dataWatcher.func_111144_e();
		this.func_110230_cF();
	}

	if (this.openMouthCounter > 0 && ++this.openMouthCounter > 30) {
		this.openMouthCounter = 0;
		this.setBicycleWatchableBoolean(128, false);
	}

	if (!this.worldObj.isRemote && this.jumpRearingCounter > 0
			&& ++this.jumpRearingCounter > 20) {
		this.jumpRearingCounter = 0;
		this.setRearing(false);
	}

	if (this.field_110278_bp > 0 && ++this.field_110278_bp >  {
		this.field_110278_bp = 0;
	}

	if (this.field_110279_bq > 0) {
		++this.field_110279_bq;

		if (this.field_110279_bq > 300) {
			this.field_110279_bq = 0;
		}
	}

	this.prevHeadLean = this.headLean;



	this.prevRearingAmount = this.rearingAmount;



	this.prevMouthOpenness = this.mouthOpenness;

	if (this.getBicycleWatchableBoolean(128)) {
		this.mouthOpenness += (1.0F - this.mouthOpenness) * 0.7F + 0.05F;

		if (this.mouthOpenness > 1.0F) {
			this.mouthOpenness = 1.0F;
		}
	} else {
		this.mouthOpenness += (0.0F - this.mouthOpenness) * 0.7F - 0.05F;

		if (this.mouthOpenness < 0.0F) {
			this.mouthOpenness = 0.0F;
		}
	}
}

private void openBicycleMouth() {
	if (!this.worldObj.isRemote) {
		this.openMouthCounter = 1;
		this.setBicycleWatchableBoolean(128, true);
	}
}

private boolean func_110200_cJ() {
	return this.riddenByEntity == null && this.ridingEntity == null
			&& this.isTame() && this.isAdultBicycle()
			&& !this.func_110222_cv()
			&& this.getHealth() >= this.getMaxHealth();
}

public void setEating(boolean par1) {
	this.setBicycleWatchableBoolean(32, par1);
}

public void setEatingHaystack(boolean par1) {
	this.setEating(par1);
}

public void setRearing(boolean par1) {
	if (par1) {
		this.setEatingHaystack(false);
	}

	this.setBicycleWatchableBoolean(64, par1);
}

private void makeBicycleRear() {
	if (!this.worldObj.isRemote) {
		this.jumpRearingCounter = 1;
		this.setRearing(true);
	}
}

public void makeBicycleRearWithSound() {
	this.makeBicycleRear();
	String s = this.getAngrySoundName();

	if (s != null) {
		this.playSound(s, this.getSoundVolume(), this.getSoundPitch());
	}
}

private void dropItemsInChest(Entity par1Entity, AnimalChest par2AnimalChest) {
	if (par2AnimalChest != null && !this.worldObj.isRemote) {
		for (int i = 0; i < par2AnimalChest.getSizeInventory(); ++i) {
			ItemStack itemstack = par2AnimalChest.getStackInSlot(i);

			if (itemstack != null) {
				this.entityDropItem(itemstack, 0.0F);
			}
		}
	}
}

public boolean setTamedBy(EntityPlayer par1EntityPlayer) {
	this.setOwnerName(par1EntityPlayer.getCommandSenderName());
	this.setBicycleTamed(true);
	return true;
}

/**
 * Moves the entity based on the specified heading. Args: strafe, forward
 */
public void moveEntityWithHeading(float par1, float par2) {
	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;
		par1 = ((EntityLivingBase) this.riddenByEntity).moveStrafing * 0.5F;
		par2 = ((EntityLivingBase) this.riddenByEntity).moveForward;

		if (par2 <= 0.0F) {
			par2 *= 0.25F;
			this.field_110285_bP = 0;
		}

		if (this.onGround && this.jumpPower == 0.0F
				&& !this.field_110294_bI) {
			par1 = 0.0F;
			par2 = 0.0F;
		}

		if (this.jumpPower > 0.0F && !this.isBicycleJumping()
				&& this.onGround) {
			this.motionY = this.getBicycleJumpStrength()
					* (double) this.jumpPower;

			if (this.isPotionActive(Potion.jump)) {
				this.motionY += (double) ((float) (this
						.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
			}

			this.setBicycleJumping(true);
			this.isAirBorne = true;

			if (par2 > 0.0F) {
				float f2 = MathHelper.sin(this.rotationYaw
						* (float) Math.PI / 180.0F);
				float f3 = MathHelper.cos(this.rotationYaw
						* (float) Math.PI / 180.0F);
				this.motionX += (double) (-0.4F * f2 * this.jumpPower);
				this.motionZ += (double) (0.4F * f3 * this.jumpPower);
				this.playSound("mob.Bicycle.jump", 0.4F, 1.0F);
			}

			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());
			super.moveEntityWithHeading(par1, par2);
		}

		if (this.onGround) {
			this.jumpPower = 0.0F;
			this.setBicycleJumping(false);
		}

		this.prevLimbSwingAmount = this.limbSwingAmount;
		double d1 = this.posX - this.prevPosX;
		double d0 = this.posZ - this.prevPosZ;
		float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;

		if (f4 > 1.0F) {
			f4 = 1.0F;
		}

		this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
		this.limbSwing += this.limbSwingAmount;
	} else {
		this.stepHeight = 0.5F;
		this.jumpMovementFactor = 0.02F;
		super.moveEntityWithHeading(par1, par2);
	}
}

/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
	super.writeEntityToNBT(par1NBTTagCompound);

	par1NBTTagCompound.setBoolean("HasReproduced", this.getHasReproduced());
	par1NBTTagCompound.setBoolean("Bred", this.func_110205_ce());
	par1NBTTagCompound.setInteger("Type", this.getBicycleType());
	par1NBTTagCompound.setInteger("Variant", this.getBicycleVariant());
	par1NBTTagCompound.setBoolean("Tame", this.isTame());
	par1NBTTagCompound.setString("OwnerName", this.getOwnerName());

}

/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
	super.readEntityFromNBT(par1NBTTagCompound);
	this.setEatingHaystack(par1NBTTagCompound.getBoolean("EatingHaystack"));
	this.func_110242_l(par1NBTTagCompound.getBoolean("Bred"));
	this.setBicycleType(par1NBTTagCompound.getInteger("Type"));
	this.setBicycleVariant(par1NBTTagCompound.getInteger("Variant"));
	this.setBicycleTamed(par1NBTTagCompound.getBoolean("Tame"));

	if (par1NBTTagCompound.hasKey("OwnerName", ) {
		this.setOwnerName(par1NBTTagCompound.getString("OwnerName"));
	}

	IAttributeInstance iattributeinstance = this.getAttributeMap()
			.getAttributeInstanceByName("Speed");

	if (iattributeinstance != null) {
		this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
				.setBaseValue(iattributeinstance.getBaseValue() * 0.25D);
	}

	ItemStack itemstack;


}

/**
 * Returns true if the mob is currently able to mate with the specified mob.
 */
public boolean canMateWith(EntityAnimal par1EntityAnimal) {
	if (par1EntityAnimal == this) {
		return false;
	} else if (par1EntityAnimal.getClass() != this.getClass()) {
		return false;
	} else {
		EntityBicycle entityBicycle = (EntityBicycle) par1EntityAnimal;

		if (this.func_110200_cJ() && entityBicycle.func_110200_cJ()) {
			int i = this.getBicycleType();
			int j = entityBicycle.getBicycleType();
			return i == j || i == 0 && j == 1 || i == 1 && j == 0;
		} else {
			return false;
		}
	}
}

public EntityAgeable createChild(EntityAgeable par1EntityAgeable) {
	EntityBicycle entityBicycle = (EntityBicycle) par1EntityAgeable;
	EntityBicycle entityBicycle1 = new EntityBicycle(this.worldObj);
	int i = this.getBicycleType();
	int j = entityBicycle.getBicycleType();
	int k = 0;

	if (i == j) {
		k = i;
	} else if (i == 0 && j == 1 || i == 1 && j == 0) {
		k = 2;
	}

	if (k == 0) {
		int i1 = this.rand.nextInt(9);
		int l;

		if (i1 < 4) {
			l = this.getBicycleVariant() & 255;
		} else if (i1 <  {
			l = entityBicycle.getBicycleVariant() & 255;
		} else {
			l = this.rand.nextInt(7);
		}

		int j1 = this.rand.nextInt(5);

		if (j1 < 2) {
			l |= this.getBicycleVariant() & 65280;
		} else if (j1 < 4) {
			l |= entityBicycle.getBicycleVariant() & 65280;
		} else {
			l |= this.rand.nextInt(5) << 8 & 65280;
		}

		entityBicycle1.setBicycleVariant(l);
	}

	entityBicycle1.setBicycleType(k);
	double d1 = this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.getBaseValue()
			+ par1EntityAgeable.getEntityAttribute(
					SharedMonsterAttributes.maxHealth).getBaseValue()
			+ (double) this.func_110267_cL();
	entityBicycle1.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.setBaseValue(d1 / 3.0D);
	double d2 = this.getEntityAttribute(BicycleJumpStrength).getBaseValue()
			+ par1EntityAgeable.getEntityAttribute(BicycleJumpStrength)
					.getBaseValue() + this.func_110245_cM();
	entityBicycle1.getEntityAttribute(BicycleJumpStrength).setBaseValue(
			d2 / 3.0D);
	double d0 = this.getEntityAttribute(
			SharedMonsterAttributes.movementSpeed).getBaseValue()
			+ par1EntityAgeable.getEntityAttribute(
					SharedMonsterAttributes.movementSpeed).getBaseValue()
			+ this.func_110203_cN();
	entityBicycle1
			.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
			.setBaseValue(d0 / 3.0D);
	return entityBicycle1;
}

public IEntityLivingData onSpawnWithEgg(
		IEntityLivingData par1EntityLivingData) {
	Object p_110161_1_1 = super.onSpawnWithEgg(par1EntityLivingData);
	boolean flag = false;
	int i = 0;
	int l;

	if (p_110161_1_1 instanceof EntityBicycle.GroupData) {
		l = ((EntityBicycle.GroupData) p_110161_1_1).field_111107_a;
		i = ((EntityBicycle.GroupData) p_110161_1_1).field_111106_b & 255
				| this.rand.nextInt(5) << 8;
	} else {
		if (this.rand.nextInt(10) == 0) {
			l = 1;
		} else {
			int j = this.rand.nextInt(7);
			int k = this.rand.nextInt(5);
			l = 0;
			i = j | k << 8;
		}

		p_110161_1_1 = new EntityBicycle.GroupData(l, i);
	}

	this.setBicycleType(l);
	this.setBicycleVariant(i);

	if (this.rand.nextInt(5) == 0) {
		this.setGrowingAge(-24000);
	}

	if (l != 4 && l != 3) {
		this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
				.setBaseValue((double) this.func_110267_cL());

		if (l == 0) {
			this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
					.setBaseValue(this.func_110203_cN());
		} else {
			this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
					.setBaseValue(0.17499999701976776D);
		}
	} else {
		this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
				.setBaseValue(15.0D);
		this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
				.setBaseValue(0.20000000298023224D);
	}

	if (l != 2 && l != 1) {
		this.getEntityAttribute(BicycleJumpStrength).setBaseValue(
				this.func_110245_cM());
	} else {
		this.getEntityAttribute(BicycleJumpStrength).setBaseValue(0.5D);
	}

	this.setHealth(this.getMaxHealth());
	return (IEntityLivingData) p_110161_1_1;
}

@SideOnly(Side.CLIENT)
public float getGrassEatingAmount(float par1) {
	return this.prevHeadLean + (this.headLean - this.prevHeadLean) * par1;
}

@SideOnly(Side.CLIENT)
public float getRearingAmount(float par1) {
	return this.prevRearingAmount
			+ (this.rearingAmount - this.prevRearingAmount) * par1;
}

@SideOnly(Side.CLIENT)
public float func_110201_q(float par1) {
	return this.prevMouthOpenness
			+ (this.mouthOpenness - this.prevMouthOpenness) * par1;
}

/**
 * Returns true if the newer Entity AI code should be run
 */
protected boolean isAIEnabled() {
	return true;
}

public void setJumpPower(int par1) {

		if (par1 < 0) {
			par1 = 0;
		} else {
			this.field_110294_bI = true;
			this.makeBicycleRear();
		}

		if (par1 >= 90) {
			this.jumpPower = 1.0F;
		} else {
			this.jumpPower = 0.4F + 0.4F * (float) par1 / 90.0F;
		}
	}


/**
 * "Spawns particles for the Bicycle entity. par1 tells whether to spawn hearts. If it is false, it spawns smoke."
 */
@SideOnly(Side.CLIENT)
protected void spawnBicycleParticles(boolean par1) {
	String s = par1 ? "heart" : "smoke";

	for (int i = 0; i < 7; ++i) {
		double d0 = this.rand.nextGaussian() * 0.02D;
		double d1 = this.rand.nextGaussian() * 0.02D;
		double d2 = this.rand.nextGaussian() * 0.02D;
		this.worldObj
				.spawnParticle(
						s,
						this.posX
								+ (double) (this.rand.nextFloat()
										* this.width * 2.0F)
								- (double) this.width,
						this.posY
								+ 0.5D
								+ (double) (this.rand.nextFloat() * this.height),
						this.posZ
								+ (double) (this.rand.nextFloat()
										* this.width * 2.0F)
								- (double) this.width, d0, d1, d2);
	}
}

@SideOnly(Side.CLIENT)
public void handleHealthUpdate(byte par1) {
	if (par1 == 7) {
		this.spawnBicycleParticles(true);
	} else if (par1 == 6) {
		this.spawnBicycleParticles(false);
	} else {
		super.handleHealthUpdate(par1);
	}
}

public void updateRiderPosition() {
	super.updateRiderPosition();

	if (this.prevRearingAmount > 0.0F) {
		float f = MathHelper.sin(this.renderYawOffset * (float) Math.PI
				/ 180.0F);
		float f1 = MathHelper.cos(this.renderYawOffset * (float) Math.PI
				/ 180.0F);
		float f2 = 0.7F * this.prevRearingAmount;
		float f3 = 0.15F * this.prevRearingAmount;
		this.riddenByEntity.setPosition(
				this.posX + (double) (f2 * f),
				this.posY + this.getMountedYOffset()
						+ this.riddenByEntity.getYOffset() + (double) f3,
				this.posZ - (double) (f2 * f1));

		if (this.riddenByEntity instanceof EntityLivingBase) {
			((EntityLivingBase) this.riddenByEntity).renderYawOffset = this.renderYawOffset;
		}
	}
}

private float func_110267_cL() {
	return 15.0F + (float) this.rand.nextInt(
			+ (float) this.rand.nextInt(9);
}

private double func_110245_cM() {
	return 0.4000000059604645D + this.rand.nextDouble() * 0.2D
			+ this.rand.nextDouble() * 0.2D + this.rand.nextDouble() * 0.2D;
}

private double func_110203_cN() {
	return (0.44999998807907104D + this.rand.nextDouble() * 0.3D
			+ this.rand.nextDouble() * 0.3D + this.rand.nextDouble() * 0.3D) * 0.25D;
}

/**
 * returns true if this entity is by a ladder, false otherwise
 */
public boolean isOnLadder() {
	return false;
}

public static class GroupData implements IEntityLivingData {
	public int field_111107_a;
	public int field_111106_b;
	private static final String __OBFID = "CL_00001643";

	public GroupData(int par1, int par2) {
		this.field_111107_a = par1;
		this.field_111106_b = par2;
	}
}
}

 

 

Posted

You print it just before the return statement. Also, I think you need to change != to ==. this.riddenByEntity != null would return true when you tried to ride it.

 

edit: nevermind, I think that method pertains to the horse AI movement being blocked. It is good that you got rid of the need for a saddle in moveEntityWithHeading though.

Posted

If I put the print statement in as you suggested, It seems to print every tick that Movement is blocked and I am not sure why. But it shows up when I place the vehicle on the ground and continues to print even once I mount it. It does not print when I hold the item though.

 

The current isMovementBlocked() Method

 

 

protected boolean isMovementBlocked() {
	System.out.println("MovementBlocked");
	return this.riddenByEntity != null;

}
[/code[

Posted

I got rid of a bunch of the useless horse stuff such as head lean and open mouth This is the shortened cleaned up version of my entity file. Still cannot move forward on the Bike but it does rotate with the player when you mount it.

 

EntityBicycle class

 

 

public class EntityBicycle extends EntityAnimal {
private static final IEntitySelector BicycleBreedingSelector = new IEntitySelector() {

	/**
	 * Return whether the specified entity is applicable to this filter.
	 */
	public boolean isEntityApplicable(Entity par1Entity) {
		return par1Entity instanceof EntityBicycle
				&& ((EntityBicycle) par1Entity).func_110205_ce();
	}
};
private static final IAttribute BicycleJumpStrength = (new RangedAttribute(
		"Bicycle.jumpStrength", 0.7D, 0.0D, 2.0D)).setDescription(
		"Jump Strength").setShouldWatch(true);

private int jumpRearingCounter;
public int field_110278_bp;
public int field_110279_bq;
protected boolean BicycleJumping;

/**
 * "The higher this value, the more likely the Bicycle is to be tamed next time a player rides it."
 */

protected float jumpPower;
private boolean field_110294_bI;
private float rearingAmount;
private float prevRearingAmount;

private int field_110285_bP;
private String field_110286_bQ;
private String[] field_110280_bR = new String[3];
private static final String __OBFID = "CL_00001641";

public EntityBicycle(World par1World) {
	super(par1World);
	this.setSize(1.4F, 1.6F);

}

public EntityBicycle(World par1World, double par2, double par4, double par6) {
	this(par1World);
	this.setPosition(par2, par4 + (double) this.yOffset, par6);
	this.motionX = 0.0D;
	this.motionY = 0.0D;
	this.motionZ = 0.0D;
	this.prevPosX = par2;
	this.prevPosY = par4;
	this.prevPosZ = par6;
}

protected void entityInit() {
	super.entityInit();
	this.dataWatcher.addObject(16, Integer.valueOf(0));
	this.dataWatcher.addObject(19, Byte.valueOf((byte) 0));
	this.dataWatcher.addObject(20, Integer.valueOf(0));
	this.dataWatcher.addObject(21, String.valueOf(""));
	this.dataWatcher.addObject(22, Integer.valueOf(0));
}

public void setBicycleType(int par1) {
	this.dataWatcher.updateObject(19, Byte.valueOf((byte) par1));
	this.func_110230_cF();
}

/**
 * returns the Bicycle type
 */
public int getBicycleType() {
	return this.dataWatcher.getWatchableObjectByte(19);
}

/**
 * Gets the name of this command sender (usually username, but possibly
 * "Rcon")
 */
public String getCommandSenderName() {
	if (this.hasCustomNameTag()) {
		return this.getCustomNameTag();
	} else {
		int i = this.getBicycleType();

		switch (i) {
		case 0:
		default:
			return StatCollector.translateToLocal("entity.Bicycle.name");
		case 1:
			return StatCollector.translateToLocal("entity.donkey.name");
		case 2:
			return StatCollector.translateToLocal("entity.mule.name");
		case 3:
			return StatCollector
					.translateToLocal("entity.zombieBicycle.name");
		case 4:
			return StatCollector
					.translateToLocal("entity.skeletonBicycle.name");
		}
	}
}

private boolean getBicycleWatchableBoolean(int par1) {
	return (this.dataWatcher.getWatchableObjectInt(16) & par1) != 0;
}

private void setBicycleWatchableBoolean(int par1, boolean par2) {
	int j = this.dataWatcher.getWatchableObjectInt(16);

	if (par2) {
		this.dataWatcher.updateObject(16, Integer.valueOf(j | par1));
	} else {
		this.dataWatcher.updateObject(16, Integer.valueOf(j & ~par1));
	}
}

public boolean isAdultBicycle() {
	return !this.isChild();
}

public boolean isTame() {
	return this.getBicycleWatchableBoolean(2);
}

public boolean func_110253_bW() {
	return this.isAdultBicycle();
}

public String getOwnerName() {
	return this.dataWatcher.getWatchableObjectString(21);
}

public void setOwnerName(String par1Str) {
	this.dataWatcher.updateObject(21, par1Str);
}

public float getBicycleSize() {
	int i = this.getGrowingAge();
	return i >= 0 ? 1.0F : 0.5F + (float) (-24000 - i) / -24000.0F * 0.5F;
}

public boolean isBicycleJumping() {
	return this.BicycleJumping;
}

public void setBicycleTamed(boolean par1) {
	this.setBicycleWatchableBoolean(2, par1);
}

public void setBicycleJumping(boolean par1) {
	this.BicycleJumping = par1;
}

public boolean allowLeashing() {
	return !this.func_110256_cu() && super.allowLeashing();
}

public int func_110241_cb() {
	return this.dataWatcher.getWatchableObjectInt(22);
}

public boolean func_110205_ce() {
	return this.getBicycleWatchableBoolean(16);
}

public void func_110242_l(boolean par1) {
	this.setBicycleWatchableBoolean(16, par1);
}

/**
 * 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.Bicycle.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);
		}
	}
}

public double getBicycleJumpStrength() {
	return this.getEntityAttribute(BicycleJumpStrength).getAttributeValue();
}

protected Item getDropItem() {
	boolean flag = this.rand.nextInt(4) == 0;
	int i = this.getBicycleType();
	return i == 4 ? Items.bone : (i == 3 ? (flag ? Item.getItemById(0)
			: Items.rotten_flesh) : Items.leather);
}

protected void applyEntityAttributes() {
	super.applyEntityAttributes();
	this.getAttributeMap().registerAttribute(BicycleJumpStrength);
	this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.setBaseValue(53.0D);
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
			.setBaseValue(0.22499999403953552D);
}

@SideOnly(Side.CLIENT)
public boolean func_110239_cn() {
	return this.getBicycleType() == 0 || this.func_110241_cb() > 0;
}

private void func_110230_cF() {
	this.field_110286_bQ = null;
}

/**
 * Called when a player interacts with a mob.
 */
public boolean interact(EntityPlayer par1EntityPlayer) {
	ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();

	if (itemstack != null && itemstack.getItem() == Items.spawn_egg) {
		return super.interact(par1EntityPlayer);
	} else if (!this.isTame() && this.func_110256_cu()) {
		return false;
	}

	else if (this.func_110253_bW() && this.riddenByEntity != null) {
		return super.interact(par1EntityPlayer);
	} else {
		if (itemstack != null) {
			boolean flag = false;

		}

	}

	if (this.func_110253_bW() && this.riddenByEntity == null) {
		if (itemstack != null
				&& itemstack.interactWithEntity(par1EntityPlayer, this)) {
			return true;
		} else {
			this.func_110237_h(par1EntityPlayer);
			return true;
		}
	} else {
		return super.interact(par1EntityPlayer);
	}
}

private void func_110237_h(EntityPlayer par1EntityPlayer) {
	par1EntityPlayer.rotationYaw = this.rotationYaw;
	par1EntityPlayer.rotationPitch = this.rotationPitch;
	this.setRearing(false);

	if (!this.worldObj.isRemote) {
		par1EntityPlayer.mountEntity(this);
	}
}

public boolean func_110259_cr() {
	return this.getBicycleType() == 0;
}

public boolean func_110229_cs() {
	int i = this.getBicycleType();
	return i == 2 || i == 1;
}

/**
 * Dead and sleeping entities cannot move
 */
protected boolean isMovementBlocked() {
	System.out.println("MovementBlocked");
	return this.riddenByEntity != null;

}

public boolean func_110256_cu() {
	int i = this.getBicycleType();
	return i == 3 || i == 4;
}

public boolean func_110222_cv() {
	return this.func_110256_cu() || this.getBicycleType() == 2;
}

private void func_110210_cH() {
	this.field_110278_bp = 1;
}

/**
 * Called frequently so the entity can update its state every tick as
 * required. For example, zombies and skeletons use this to react to
 * sunlight and start to burn.
 */
public void onLivingUpdate() {
	if (this.rand.nextInt(200) == 0) {
		this.func_110210_cH();
	}

	super.onLivingUpdate();

	if (!this.worldObj.isRemote) {
		if (this.rand.nextInt(900) == 0 && this.deathTime == 0) {
			this.heal(1.0F);
		}

	}
}

/**
 * Called to update the entity's position/logic.
 */
public void onUpdate() {
	super.onUpdate();

	if (this.worldObj.isRemote && this.dataWatcher.hasChanges()) {
		this.dataWatcher.func_111144_e();
		this.func_110230_cF();
	}

	if (!this.worldObj.isRemote && this.jumpRearingCounter > 0
			&& ++this.jumpRearingCounter > 20) {
		this.jumpRearingCounter = 0;
		this.setRearing(false);
	}

	if (this.field_110278_bp > 0 && ++this.field_110278_bp >  {
		this.field_110278_bp = 0;
	}

	if (this.field_110279_bq > 0) {
		++this.field_110279_bq;

		if (this.field_110279_bq > 300) {
			this.field_110279_bq = 0;
		}
	}

	this.prevRearingAmount = this.rearingAmount;

}

private boolean func_110200_cJ() {
	return this.riddenByEntity == null && this.ridingEntity == null
			&& this.isTame() && this.isAdultBicycle()
			&& !this.func_110222_cv()
			&& this.getHealth() >= this.getMaxHealth();
}

public void setEating(boolean par1) {
	this.setBicycleWatchableBoolean(32, par1);
}

public void setEatingHaystack(boolean par1) {
	this.setEating(par1);
}

public void setRearing(boolean par1) {
	if (par1) {
		this.setEatingHaystack(false);
	}

	this.setBicycleWatchableBoolean(64, par1);
}

private void makeBicycleRear() {
	if (!this.worldObj.isRemote) {
		this.jumpRearingCounter = 1;
		this.setRearing(true);
	}
}

public void makeBicycleRearWithSound() {
	this.makeBicycleRear();
}

public boolean setTamedBy(EntityPlayer par1EntityPlayer) {
	this.setOwnerName(par1EntityPlayer.getCommandSenderName());
	this.setBicycleTamed(true);
	return true;
}

/**
 * Moves the entity based on the specified heading. Args: strafe, forward
 */
public void moveEntityWithHeading(float par1, float par2) {
	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;
		par1 = ((EntityLivingBase) this.riddenByEntity).moveStrafing * 0.5F;
		par2 = ((EntityLivingBase) this.riddenByEntity).moveForward;

		if (par2 <= 0.0F) {
			par2 *= 0.25F;
			this.field_110285_bP = 0;
		}

		if (this.onGround && this.jumpPower == 0.0F
				&& !this.field_110294_bI) {
			par1 = 0.0F;
			par2 = 0.0F;
		}

		if (this.jumpPower > 0.0F && !this.isBicycleJumping()
				&& this.onGround) {
			this.motionY = this.getBicycleJumpStrength()
					* (double) this.jumpPower;

			if (this.isPotionActive(Potion.jump)) {
				this.motionY += (double) ((float) (this
						.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
			}

			this.setBicycleJumping(true);
			this.isAirBorne = true;

			if (par2 > 0.0F) {
				float f2 = MathHelper.sin(this.rotationYaw
						* (float) Math.PI / 180.0F);
				float f3 = MathHelper.cos(this.rotationYaw
						* (float) Math.PI / 180.0F);
				this.motionX += (double) (-0.4F * f2 * this.jumpPower);
				this.motionZ += (double) (0.4F * f3 * this.jumpPower);
				this.playSound("mob.Bicycle.jump", 0.4F, 1.0F);
			}

			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());
			super.moveEntityWithHeading(par1, par2);
		}

		if (this.onGround) {
			this.jumpPower = 0.0F;
			this.setBicycleJumping(false);
		}

		this.prevLimbSwingAmount = this.limbSwingAmount;
		double d1 = this.posX - this.prevPosX;
		double d0 = this.posZ - this.prevPosZ;
		float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;

		if (f4 > 1.0F) {
			f4 = 1.0F;
		}

		this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
		this.limbSwing += this.limbSwingAmount;
	} else {
		this.stepHeight = 0.5F;
		this.jumpMovementFactor = 0.02F;
		super.moveEntityWithHeading(par1, par2);
	}
}

/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
	super.writeEntityToNBT(par1NBTTagCompound);

	par1NBTTagCompound.setBoolean("Bred", this.func_110205_ce());
	par1NBTTagCompound.setInteger("Type", this.getBicycleType());

	par1NBTTagCompound.setBoolean("Tame", this.isTame());
	par1NBTTagCompound.setString("OwnerName", this.getOwnerName());

}

/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
	super.readEntityFromNBT(par1NBTTagCompound);
	this.func_110242_l(par1NBTTagCompound.getBoolean("Bred"));
	this.setBicycleType(par1NBTTagCompound.getInteger("Type"));

	this.setBicycleTamed(par1NBTTagCompound.getBoolean("Tame"));

	if (par1NBTTagCompound.hasKey("OwnerName", ) {
		this.setOwnerName(par1NBTTagCompound.getString("OwnerName"));
	}

	IAttributeInstance iattributeinstance = this.getAttributeMap()
			.getAttributeInstanceByName("Speed");

	if (iattributeinstance != null) {
		this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
				.setBaseValue(iattributeinstance.getBaseValue() * 0.25D);
	}

	ItemStack itemstack;

}

public EntityAgeable createChild(EntityAgeable par1EntityAgeable) {
	EntityBicycle entityBicycle = (EntityBicycle) par1EntityAgeable;
	EntityBicycle entityBicycle1 = new EntityBicycle(this.worldObj);
	int i = this.getBicycleType();
	int j = entityBicycle.getBicycleType();
	int k = 0;

	if (i == j) {
		k = i;
	} else if (i == 0 && j == 1 || i == 1 && j == 0) {
		k = 2;
	}

	if (k == 0) {
		int i1 = this.rand.nextInt(9);
		int l;

		int j1 = this.rand.nextInt(5);

	}

	entityBicycle1.setBicycleType(k);
	double d1 = this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.getBaseValue()
			+ par1EntityAgeable.getEntityAttribute(
					SharedMonsterAttributes.maxHealth).getBaseValue()
			+ (double) this.func_110267_cL();
	entityBicycle1.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.setBaseValue(d1 / 3.0D);
	double d2 = this.getEntityAttribute(BicycleJumpStrength).getBaseValue()
			+ par1EntityAgeable.getEntityAttribute(BicycleJumpStrength)
					.getBaseValue() + this.func_110245_cM();
	entityBicycle1.getEntityAttribute(BicycleJumpStrength).setBaseValue(
			d2 / 3.0D);
	double d0 = this.getEntityAttribute(
			SharedMonsterAttributes.movementSpeed).getBaseValue()
			+ par1EntityAgeable.getEntityAttribute(
					SharedMonsterAttributes.movementSpeed).getBaseValue()
			+ this.func_110203_cN();
	entityBicycle1
			.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
			.setBaseValue(d0 / 3.0D);
	return entityBicycle1;
}

/**
 * Returns true if the newer Entity AI code should be run
 */
protected boolean isAIEnabled() {
	return true;
}

public void setJumpPower(int par1) {

	if (par1 < 0) {
		par1 = 0;
	} else {
		this.field_110294_bI = true;
		this.makeBicycleRear();
	}

	if (par1 >= 90) {
		this.jumpPower = 1.0F;
	} else {
		this.jumpPower = 0.4F + 0.4F * (float) par1 / 90.0F;
	}
}

/**
 * "Spawns particles for the Bicycle entity. par1 tells whether to spawn hearts. If it is false, it spawns smoke."
 */
@SideOnly(Side.CLIENT)
protected void spawnBicycleParticles(boolean par1) {
	String string = par1 ? "heart" : "smoke";

	for (int i = 0; i < 7; ++i) {
		double d0 = this.rand.nextGaussian() * 0.02D;
		double d1 = this.rand.nextGaussian() * 0.02D;
		double d2 = this.rand.nextGaussian() * 0.02D;
		this.worldObj
				.spawnParticle(
						string,
						this.posX
								+ (double) (this.rand.nextFloat()
										* this.width * 2.0F)
								- (double) this.width,
						this.posY
								+ 0.5D
								+ (double) (this.rand.nextFloat() * this.height),
						this.posZ
								+ (double) (this.rand.nextFloat()
										* this.width * 2.0F)
								- (double) this.width, d0, d1, d2);
	}
}

@SideOnly(Side.CLIENT)
public void handleHealthUpdate(byte par1) {
	if (par1 == 7) {
		this.spawnBicycleParticles(true);
	} else if (par1 == 6) {
		this.spawnBicycleParticles(false);
	} else {
		super.handleHealthUpdate(par1);
	}
}

public void updateRiderPosition() {
	super.updateRiderPosition();

	if (this.prevRearingAmount > 0.0F) {
		float f = MathHelper.sin(this.renderYawOffset * (float) Math.PI
				/ 180.0F);
		float f1 = MathHelper.cos(this.renderYawOffset * (float) Math.PI
				/ 180.0F);
		float f2 = 0.7F * this.prevRearingAmount;
		float f3 = 0.15F * this.prevRearingAmount;
		this.riddenByEntity.setPosition(
				this.posX + (double) (f2 * f),
				this.posY + this.getMountedYOffset()
						+ this.riddenByEntity.getYOffset() + (double) f3,
				this.posZ - (double) (f2 * f1));

		if (this.riddenByEntity instanceof EntityLivingBase) {
			((EntityLivingBase) this.riddenByEntity).renderYawOffset = this.renderYawOffset;
		}
	}
}

private float func_110267_cL() {
	return 15.0F + (float) this.rand.nextInt(
			+ (float) this.rand.nextInt(9);
}

private double func_110245_cM() {
	return 0.4000000059604645D + this.rand.nextDouble() * 0.2D
			+ this.rand.nextDouble() * 0.2D + this.rand.nextDouble() * 0.2D;
}

private double func_110203_cN() {
	return (0.44999998807907104D + this.rand.nextDouble() * 0.3D
			+ this.rand.nextDouble() * 0.3D + this.rand.nextDouble() * 0.3D) * 0.25D;
}

/**
 * returns true if this entity is by a ladder, false otherwise
 */
public boolean isOnLadder() {
	return false;
}

public static class GroupData implements IEntityLivingData {
	public int field_111107_a;
	public int field_111106_b;
	private static final String __OBFID = "CL_00001643";

	public GroupData(int par1, int par2) {
		this.field_111107_a = par1;
		this.field_111106_b = par2;
	}
}
}

Posted

Yeah, it's not an issue with isMovementBlocked, I think. As far as I can tell that has nothing to do with the player controling the horse, but with the AI controlling the horse. Since you don't want the bicycle to control itself ever (I assume) you should just have it control true.

Posted

I Added The following Print Statement - System.out.println("Moving"); - into the moveEntityWithHeading method As seen below, and now whenever I mount the Bike the word "Moving" gets printed to the Console but the bike still will not move in any direction and you cannot jump with it (but it does rotate with the player when you move the mouse).

 

I thought the problem might have been the method below so I got rid of a few things in it but this didnt have any appreciable effect. I also got rid of some of the undefined weird functions and strings in the class that I have no idea what they do but they didnt seem to help me and didnt seem to make the bike move or do weird things when I got rid of them. Ive included the updated bike class at the bottom.

 

Suspected Problem Method

 

 


public EntityBicycle(World par1World, double par2, double par4, double par6) {
	this(par1World);
	this.setPosition(par2, par4 + (double) this.yOffset, par6);
	this.motionX = 0.0D;
	this.motionY = 0.0D;
	this.motionZ = 0.0D;
	this.prevPosX = par2;
	this.prevPosY = par4;
	this.prevPosZ = par6;
}

 

So I changed it to the following but this change had no detectable effect on the bike. If I delete it completely then I cannot place Bicycles In the world.

 

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

}

 

 

 

The moveEntityWithHeading Method That has the print statement I mentioned Up top

 

 

 

public void moveEntityWithHeading(float par1, float par2) {
	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;
		par1 = ((EntityLivingBase) this.riddenByEntity).moveStrafing * 0.5F;
		par2 = ((EntityLivingBase) this.riddenByEntity).moveForward;
		System.out.println("Moving");       

		if (par2 <= 0.0F) {
			par2 *= 0.25F;

		}

		if (this.onGround && this.jumpPower == 0.0F
				&& !this.field_110294_bI) {
			par1 = 0.0F;
			par2 = 0.0F;
		}

		if (this.jumpPower > 0.0F && !this.isBicycleJumping()
				&& this.onGround) {
			this.motionY = this.getBicycleJumpStrength()
					* (double) this.jumpPower;

			if (this.isPotionActive(Potion.jump)) {
				this.motionY += (double) ((float) (this
						.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
			}

			this.setBicycleJumping(true);
			this.isAirBorne = true;

			if (par2 > 0.0F) {
				float f2 = MathHelper.sin(this.rotationYaw
						* (float) Math.PI / 180.0F);
				float f3 = MathHelper.cos(this.rotationYaw
						* (float) Math.PI / 180.0F);
				this.motionX += (double) (-0.4F * f2 * this.jumpPower);
				this.motionZ += (double) (0.4F * f3 * this.jumpPower);
				this.playSound("mob.Bicycle.jump", 0.4F, 1.0F);
			}

			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());
			super.moveEntityWithHeading(par1, par2);
		}

		if (this.onGround) {
			this.jumpPower = 0.0F;
			this.setBicycleJumping(false);
		}

		this.prevLimbSwingAmount = this.limbSwingAmount;
		double d1 = this.posX - this.prevPosX;
		double d0 = this.posZ - this.prevPosZ;
		float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;

		if (f4 > 1.0F) {
			f4 = 1.0F;
		}

		this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
		this.limbSwing += this.limbSwingAmount;
	} else {
		this.stepHeight = 0.5F;
		this.jumpMovementFactor = 0.02F;
		super.moveEntityWithHeading(par1, par2);
	}
}

 

 

 

Updated EntityBicycle class

 

 

 

public class EntityBicycle extends EntityAnimal {

private static final IAttribute BicycleJumpStrength = (new RangedAttribute(
		"Bicycle.jumpStrength", 0.7D, 0.0D, 2.0D)).setDescription(
		"Jump Strength").setShouldWatch(true);

private int jumpRearingCounter;
protected boolean BicycleJumping;

/**
 * "The higher this value, the more likely the Bicycle is to be tamed next time a player rides it."
 */

protected float jumpPower;
private boolean field_110294_bI;
private float rearingAmount;
private float prevRearingAmount;

// private int field_110285_bP;

public EntityBicycle(World par1World) {
	super(par1World);
	this.setSize(1.4F, 1.6F);

}

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

}

protected void entityInit() {
	super.entityInit();
	this.dataWatcher.addObject(16, Integer.valueOf(0));
	this.dataWatcher.addObject(19, Byte.valueOf((byte) 0));
	this.dataWatcher.addObject(20, Integer.valueOf(0));
	this.dataWatcher.addObject(21, String.valueOf(""));
	this.dataWatcher.addObject(22, Integer.valueOf(0));
}

public void setBicycleType(int par1) {
	this.dataWatcher.updateObject(19, Byte.valueOf((byte) par1));

}

/**
 * returns the Bicycle type
 */
public int getBicycleType() {
	return this.dataWatcher.getWatchableObjectByte(19);
}

/**
 * Gets the name of this command sender (usually username, but possibly
 * "Rcon")
 */
public String getCommandSenderName() {
	if (this.hasCustomNameTag()) {
		return this.getCustomNameTag();
	} else {
		int i = this.getBicycleType();

		switch (i) {
		case 0:
		default:
			return StatCollector.translateToLocal("entity.Bicycle.name");
		case 1:
			return StatCollector.translateToLocal("entity.donkey.name");
		case 2:
			return StatCollector.translateToLocal("entity.mule.name");
		case 3:
			return StatCollector
					.translateToLocal("entity.zombieBicycle.name");
		case 4:
			return StatCollector
					.translateToLocal("entity.skeletonBicycle.name");
		}
	}
}

private boolean getBicycleWatchableBoolean(int par1) {
	return (this.dataWatcher.getWatchableObjectInt(16) & par1) != 0;
}

private void setBicycleWatchableBoolean(int par1, boolean par2) {
	int j = this.dataWatcher.getWatchableObjectInt(16);

	if (par2) {
		this.dataWatcher.updateObject(16, Integer.valueOf(j | par1));
	} else {
		this.dataWatcher.updateObject(16, Integer.valueOf(j & ~par1));
	}
}

public boolean isAdultBicycle() {
	return !this.isChild();
}

public boolean isTame() {
	return this.getBicycleWatchableBoolean(2);
}

public boolean func_110253_bW() {
	return this.isAdultBicycle();
}

public String getOwnerName() {
	return this.dataWatcher.getWatchableObjectString(21);
}

public void setOwnerName(String par1Str) {
	this.dataWatcher.updateObject(21, par1Str);
}

public float getBicycleSize() {
	int i = this.getGrowingAge();
	return i >= 0 ? 1.0F : 0.5F + (float) (-24000 - i) / -24000.0F * 0.5F;
}

public boolean isBicycleJumping() {
	return this.BicycleJumping;
}

public void setBicycleTamed(boolean par1) {
	this.setBicycleWatchableBoolean(2, par1);
}

public void setBicycleJumping(boolean par1) {
	this.BicycleJumping = par1;
}

public boolean allowLeashing() {
	return !this.func_110256_cu() && super.allowLeashing();
}

public int func_110241_cb() {
	return this.dataWatcher.getWatchableObjectInt(22);
}

public boolean func_110205_ce() {
	return this.getBicycleWatchableBoolean(16);
}

public void func_110242_l(boolean par1) {
	this.setBicycleWatchableBoolean(16, par1);
}

/**
 * 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.Bicycle.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);
		}
	}
}

public double getBicycleJumpStrength() {
	return this.getEntityAttribute(BicycleJumpStrength).getAttributeValue();
}

protected void applyEntityAttributes() {
	super.applyEntityAttributes();
	this.getAttributeMap().registerAttribute(BicycleJumpStrength);
	this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.setBaseValue(53.0D);
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
			.setBaseValue(0.22499999403953552D);
}

@SideOnly(Side.CLIENT)
public boolean func_110239_cn() {
	return this.getBicycleType() == 0 || this.func_110241_cb() > 0;
}

/**
 * Called when a player interacts with a mob.
 */
public boolean interact(EntityPlayer par1EntityPlayer) {
	ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();

	if (itemstack != null && itemstack.getItem() == Items.spawn_egg) {
		return super.interact(par1EntityPlayer);
	} else if (!this.isTame() && this.func_110256_cu()) {
		return false;
	}

	else if (this.func_110253_bW() && this.riddenByEntity != null) {
		return super.interact(par1EntityPlayer);
	} else {
		if (itemstack != null) {
			boolean flag = false;

		}

	}

	if (this.func_110253_bW() && this.riddenByEntity == null) {
		if (itemstack != null
				&& itemstack.interactWithEntity(par1EntityPlayer, this)) {
			return true;
		} else {
			this.func_110237_h(par1EntityPlayer);
			return true;
		}
	} else {
		return super.interact(par1EntityPlayer);
	}
}

private void func_110237_h(EntityPlayer par1EntityPlayer) {
	par1EntityPlayer.rotationYaw = this.rotationYaw;
	par1EntityPlayer.rotationPitch = this.rotationPitch;
	this.setRearing(false);

	if (!this.worldObj.isRemote) {
		par1EntityPlayer.mountEntity(this);
	}
}

public boolean func_110259_cr() {
	return this.getBicycleType() == 0;
}

public boolean func_110229_cs() {
	int i = this.getBicycleType();
	return i == 2 || i == 1;
}

public boolean func_110256_cu() {
	int i = this.getBicycleType();
	return i == 3 || i == 4;
}

public boolean func_110222_cv() {
	return this.func_110256_cu() || this.getBicycleType() == 2;
}

/**
 * Called frequently so the entity can update its state every tick as
 * required. For example, zombies and skeletons use this to react to
 * sunlight and start to burn.
 */
public void onLivingUpdate() {
	if (this.rand.nextInt(200) == 0) {

	}

	super.onLivingUpdate();

	if (!this.worldObj.isRemote) {
		if (this.rand.nextInt(900) == 0 && this.deathTime == 0) {
			this.heal(1.0F);
		}

	}
}

/**
 * Called to update the entity's position/logic.
 */
public void onUpdate() {
	super.onUpdate();

	if (this.worldObj.isRemote && this.dataWatcher.hasChanges()) {
		this.dataWatcher.func_111144_e();

	}

	if (!this.worldObj.isRemote && this.jumpRearingCounter > 0
			&& ++this.jumpRearingCounter > 20) {
		this.jumpRearingCounter = 0;
		this.setRearing(false);
	}

	this.prevRearingAmount = this.rearingAmount;

}

private boolean func_110200_cJ() {
	return this.riddenByEntity == null && this.ridingEntity == null
			&& this.isTame() && this.isAdultBicycle()
			&& !this.func_110222_cv()
			&& this.getHealth() >= this.getMaxHealth();
}

public void setRearing(boolean par1) {
	this.setBicycleWatchableBoolean(64, par1);
}

private void makeBicycleRear() {
	if (!this.worldObj.isRemote) {
		this.jumpRearingCounter = 1;
		this.setRearing(true);
	}
}

public void makeBicycleRearWithSound() {
	this.makeBicycleRear();
}

public boolean setTamedBy(EntityPlayer par1EntityPlayer) {
	this.setOwnerName(par1EntityPlayer.getCommandSenderName());
	this.setBicycleTamed(true);
	return true;
}

/**
 * Moves the entity based on the specified heading. Args: strafe, forward
 */
public void moveEntityWithHeading(float par1, float par2) {
	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;
		par1 = ((EntityLivingBase) this.riddenByEntity).moveStrafing * 0.5F;
		par2 = ((EntityLivingBase) this.riddenByEntity).moveForward;
		System.out.println("Moving");

		if (par2 <= 0.0F) {
			par2 *= 0.25F;

		}

		if (this.onGround && this.jumpPower == 0.0F
				&& !this.field_110294_bI) {
			par1 = 0.0F;
			par2 = 0.0F;
		}

		if (this.jumpPower > 0.0F && !this.isBicycleJumping()
				&& this.onGround) {
			this.motionY = this.getBicycleJumpStrength()
					* (double) this.jumpPower;

			if (this.isPotionActive(Potion.jump)) {
				this.motionY += (double) ((float) (this
						.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
			}

			this.setBicycleJumping(true);
			this.isAirBorne = true;

			if (par2 > 0.0F) {
				float f2 = MathHelper.sin(this.rotationYaw
						* (float) Math.PI / 180.0F);
				float f3 = MathHelper.cos(this.rotationYaw
						* (float) Math.PI / 180.0F);
				this.motionX += (double) (-0.4F * f2 * this.jumpPower);
				this.motionZ += (double) (0.4F * f3 * this.jumpPower);
				this.playSound("mob.Bicycle.jump", 0.4F, 1.0F);
			}

			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());
			super.moveEntityWithHeading(par1, par2);
		}

		if (this.onGround) {
			this.jumpPower = 0.0F;
			this.setBicycleJumping(false);
		}

		this.prevLimbSwingAmount = this.limbSwingAmount;
		double d1 = this.posX - this.prevPosX;
		double d0 = this.posZ - this.prevPosZ;
		float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;

		if (f4 > 1.0F) {
			f4 = 1.0F;
		}

		this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
		this.limbSwing += this.limbSwingAmount;
	} else {
		this.stepHeight = 0.5F;
		this.jumpMovementFactor = 0.02F;
		super.moveEntityWithHeading(par1, par2);
	}
}

/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
	super.writeEntityToNBT(par1NBTTagCompound);

	par1NBTTagCompound.setBoolean("Bred", this.func_110205_ce());
	par1NBTTagCompound.setInteger("Type", this.getBicycleType());

	par1NBTTagCompound.setBoolean("Tame", this.isTame());
	par1NBTTagCompound.setString("OwnerName", this.getOwnerName());

}

/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
	super.readEntityFromNBT(par1NBTTagCompound);
	this.func_110242_l(par1NBTTagCompound.getBoolean("Bred"));
	this.setBicycleType(par1NBTTagCompound.getInteger("Type"));

	this.setBicycleTamed(par1NBTTagCompound.getBoolean("Tame"));

	if (par1NBTTagCompound.hasKey("OwnerName", ) {
		this.setOwnerName(par1NBTTagCompound.getString("OwnerName"));
	}

	IAttributeInstance iattributeinstance = this.getAttributeMap()
			.getAttributeInstanceByName("Speed");

	if (iattributeinstance != null) {
		this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
				.setBaseValue(iattributeinstance.getBaseValue() * 0.25D);
	}

	ItemStack itemstack;

}

public EntityAgeable createChild(EntityAgeable par1EntityAgeable) {
	EntityBicycle entityBicycle = (EntityBicycle) par1EntityAgeable;
	EntityBicycle entityBicycle1 = new EntityBicycle(this.worldObj);
	int i = this.getBicycleType();
	int j = entityBicycle.getBicycleType();
	int k = 0;

	if (i == j) {
		k = i;
	} else if (i == 0 && j == 1 || i == 1 && j == 0) {
		k = 2;
	}

	if (k == 0) {
		int i1 = this.rand.nextInt(9);
		int l;

		int j1 = this.rand.nextInt(5);

	}

	entityBicycle1.setBicycleType(k);
	double d1 = this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.getBaseValue()
			+ par1EntityAgeable.getEntityAttribute(
					SharedMonsterAttributes.maxHealth).getBaseValue()
			+ (double) this.func_110267_cL();
	entityBicycle1.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.setBaseValue(d1 / 3.0D);
	double d2 = this.getEntityAttribute(BicycleJumpStrength).getBaseValue()
			+ par1EntityAgeable.getEntityAttribute(BicycleJumpStrength)
					.getBaseValue() + this.func_110245_cM();
	entityBicycle1.getEntityAttribute(BicycleJumpStrength).setBaseValue(
			d2 / 3.0D);
	double d0 = this.getEntityAttribute(
			SharedMonsterAttributes.movementSpeed).getBaseValue()
			+ par1EntityAgeable.getEntityAttribute(
					SharedMonsterAttributes.movementSpeed).getBaseValue()
			+ this.func_110203_cN();
	entityBicycle1
			.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
			.setBaseValue(d0 / 3.0D);
	return entityBicycle1;
}

/**
 * Returns true if the newer Entity AI code should be run
 */
protected boolean isAIEnabled() {
	return true;
}

public void setJumpPower(int par1) {

	if (par1 < 0) {
		par1 = 0;
	} else {
		this.field_110294_bI = true;
		this.makeBicycleRear();
	}

	if (par1 >= 90) {
		this.jumpPower = 1.0F;
	} else {
		this.jumpPower = 0.4F + 0.4F * (float) par1 / 90.0F;
	}
}

/**
 * "Spawns particles for the Bicycle entity. par1 tells whether to spawn hearts. If it is false, it spawns smoke."
 */
@SideOnly(Side.CLIENT)
protected void spawnBicycleParticles(boolean par1) {
	String string = par1 ? "heart" : "smoke";

	for (int i = 0; i < 7; ++i) {
		double d0 = this.rand.nextGaussian() * 0.02D;
		double d1 = this.rand.nextGaussian() * 0.02D;
		double d2 = this.rand.nextGaussian() * 0.02D;
		this.worldObj
				.spawnParticle(
						string,
						this.posX
								+ (double) (this.rand.nextFloat()
										* this.width * 2.0F)
								- (double) this.width,
						this.posY
								+ 0.5D
								+ (double) (this.rand.nextFloat() * this.height),
						this.posZ
								+ (double) (this.rand.nextFloat()
										* this.width * 2.0F)
								- (double) this.width, d0, d1, d2);
	}
}

@SideOnly(Side.CLIENT)
public void handleHealthUpdate(byte par1) {
	if (par1 == 7) {
		this.spawnBicycleParticles(true);
	} else if (par1 == 6) {
		this.spawnBicycleParticles(false);
	} else {
		super.handleHealthUpdate(par1);
	}
}

public void updateRiderPosition() {
	super.updateRiderPosition();

	if (this.prevRearingAmount > 0.0F) {
		float f = MathHelper.sin(this.renderYawOffset * (float) Math.PI
				/ 180.0F);
		float f1 = MathHelper.cos(this.renderYawOffset * (float) Math.PI
				/ 180.0F);
		float f2 = 0.7F * this.prevRearingAmount;
		float f3 = 0.15F * this.prevRearingAmount;
		this.riddenByEntity.setPosition(
				this.posX + (double) (f2 * f),
				this.posY + this.getMountedYOffset()
						+ this.riddenByEntity.getYOffset() + (double) f3,
				this.posZ - (double) (f2 * f1));

		if (this.riddenByEntity instanceof EntityLivingBase) {
			((EntityLivingBase) this.riddenByEntity).renderYawOffset = this.renderYawOffset;
		}
	}
}

private float func_110267_cL() {
	return 15.0F + (float) this.rand.nextInt(
			+ (float) this.rand.nextInt(9);
}

private double func_110245_cM() {
	return 0.4000000059604645D + this.rand.nextDouble() * 0.2D
			+ this.rand.nextDouble() * 0.2D + this.rand.nextDouble() * 0.2D;
}

private double func_110203_cN() {
	return (0.44999998807907104D + this.rand.nextDouble() * 0.3D
			+ this.rand.nextDouble() * 0.3D + this.rand.nextDouble() * 0.3D) * 0.25D;
}

/**
 * returns true if this entity is by a ladder, false otherwise
 */
public boolean isOnLadder() {
	return false;
}

public static class GroupData implements IEntityLivingData {
	public int field_111107_a;
	public int field_111106_b;
	private static final String __OBFID = "CL_00001643";

	public GroupData(int par1, int par2) {
		this.field_111107_a = par1;
		this.field_111106_b = par2;
	}
}
}

 

 

Posted

You don't want to delete the constructor :P

 

Try printing moveStrafing and moveForward, I suspect those values are zero. Better yet, use the debugger which should show you how the values are returning whatever.

Posted

Haha Ya I know I dont want to delete the constructor but in the constructor I set my motion to 0 before and I suspected that was causing an issue. Im not sure I was correct though. Ill try your suggestion and see if I can solve this

Posted

[some Success] I figured out how to get the bike to move, it moves up slopes too which is awesome. But I still cannot find why it wont Jump. I cleaned up the class a lot and got rid of a lot more Horse stuff (this is how I noticed where moveForeward and moveStrafing were zero and I fixed it) Currently I have a bunch of print statements and in the console it prints jumpPower: 0.0 if (this.onGround) and nothing else. So for some reason I dont think it is recognizing my user input maybe? But this is a guess I am not really sure where to go at this point. I am comparing minecrafts horse class to mine and looking at the Jump functions to see if I accidentally deleted something. If anyone has an Idea of how to get the Jump working that would be amazing.

 

EntityBicycle class (the working movement code || but non working jump code)

 

 


public class EntityBicycle extends EntityAnimal {

private static final IAttribute BicycleJumpStrength = (new RangedAttribute(
		"Bicycle.jumpStrength", 0.7D, 0.0D, 2.0D)).setDescription(
				"Jump Strength").setShouldWatch(true);

protected boolean BicycleJumping;
protected float jumpPower;


public EntityBicycle(World par1World) {
	super(par1World);
	this.setSize(1.4F, 1.6F);

}

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

}

/**
 * Gets the name of this command sender (usually username, but possibly
 * "Rcon")
 */
public String getCommandSenderName() {
	if (this.hasCustomNameTag()) {
		return this.getCustomNameTag();
	} else {
		return StatCollector.translateToLocal("entity.bicycle.name");
	}
}


public boolean isBicycleJumping() {
	return this.BicycleJumping;
}

public void setBicycleJumping(boolean par1) {
	this.BicycleJumping = par1;
}


/**
 * 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.Bicycle.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.
 */
public boolean interact(EntityPlayer par1EntityPlayer) {
	ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();

	if (itemstack != null && itemstack.getItem() == Items.spawn_egg) {
		return super.interact(par1EntityPlayer);
	}

	if (this.riddenByEntity == null) {
		if (itemstack != null
				&& itemstack.interactWithEntity(par1EntityPlayer, this)) {
			return true;
		} else {
			this.onPlayerMounted(par1EntityPlayer);
			return true;
		}
	} else {
		return super.interact(par1EntityPlayer);
	}
}

//called when player mounts this entity
private void onPlayerMounted(EntityPlayer par1EntityPlayer) {
	par1EntityPlayer.rotationYaw = this.rotationYaw;
	par1EntityPlayer.rotationPitch = this.rotationPitch;

	if (!this.worldObj.isRemote) {
		par1EntityPlayer.mountEntity(this);
	}
}

/**
 * Called frequently so the entity can update its state every tick as
 * required. For example, zombies and skeletons use this to react to
 * sunlight and start to burn.
 */
public void onLivingUpdate() {
	super.onLivingUpdate();
}

/**
 * Called to update the entity's position/logic.
 */
public void onUpdate() {
	super.onUpdate();
}

private double getBicycleJumpPower(){
	return 50.0f;	//probably too high, but can adjust later

}

/**
 * Moves the entity based on the specified heading. Args: strafe, forward
 */
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 = ((EntityLivingBase)this.riddenByEntity).moveStrafing * 0.5F; // In the case of the bike this should be 0 as bikes shouldnt slide side to side.
		moveForward = ((EntityLivingBase) this.riddenByEntity).moveForward;

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

		}

		if (this.jumpPower > 0.0F && !this.isBicycleJumping() && this.onGround) {

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

			this.setBicycleJumping(true);
			this.isAirBorne = true;
			System.out.println("jumpPower: "+jumpPower+" if (this.jumpPower > 0.0F && !this.isBicycleJumping() && this.onGround)");

			if (moveForward > 0.0F) {
				float f2 = MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F);
				float f3 = MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F);
				this.motionX += (double) (-0.4F * f2 * this.jumpPower);
				this.motionZ += (double) (0.4F * f3 * this.jumpPower);
				this.playSound("mob.Bicycle.jump", 0.4F, 1.0F);
				System.out.println("jumpPower: "+jumpPower+" if (moveForward > 0.0F)");
			}

			this.jumpPower = 0.0F;
			System.out.println("jumpPower: "+jumpPower+" if (this.jumpPower > 0.0F && !this.isBicycleJumping() && this.onGround)");
		}

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

		if (!this.worldObj.isRemote) {
			this.setAIMoveSpeed((float) this.getEntityAttribute(
					SharedMonsterAttributes.movementSpeed)
					.getAttributeValue());
			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);
	}
}


public EntityAgeable createChild(EntityAgeable par1EntityAgeable) {
	return new EntityBicycle(this.worldObj);	//should this EVER be called? CANT BREED???
}

/**
 * Returns true if the newer Entity AI code should be run
 */
protected boolean isAIEnabled() {
	return true;
}

public void setJumpPower(int par1) {

	if (par1 < 0) {
		par1 = 0;
		System.out.println("jumpPower: "+jumpPower+" if (par1 < 0)");
	}

	if (par1 >= 90) {
		this.jumpPower = 1.0F;
		System.out.println("jumpPower: "+jumpPower+" if (par1 >= 90)");
	} else {
		this.jumpPower = 0.4F + 0.4F * (float) par1 / 90.0F;
		System.out.println("jumpPower: "+jumpPower+"  else {this.jumpPower = 0.4F + 0.4F * (float) par1 / 90.0F;");
	}
}


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

/**
 * returns true if this entity is by a ladder, false otherwise
 */
public boolean isOnLadder() {
	return false;
}

public static class GroupData implements IEntityLivingData {
	public int field_111107_a;
	public int field_111106_b;


	public GroupData(int par1, int par2) {
		this.field_111107_a = par1;
		this.field_111106_b = par2;
	}
}
}

 

 

  • 2 weeks later...
Posted

After alot of messing around I still havent figured out why the jump code doesnt work. for some reason the jump power is always 0 and I am not sure why. Any help will be appreciated. (the code is posted above)

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.