Java Code Examples for net.minecraft.entity.player.EntityPlayer.startRiding()

The following are Jave code examples for showing how to use startRiding() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Melodium   File: SongHorse.java   View Source Code Vote up 6 votes
@Override
public boolean songTick(EntityPlayer player, ItemStack instrument, int interval, int ticks, int length) {
	if (interval == 0 && ticks == 1) {
		EnumHand hand = player.getActiveHand();
		World world = player.world;
		SoundType t = SoundType.getSoundTypeByName(SoundType.AMBIENT.getTag());
		if (!world.isRemote) {
			EntityHorse horse = new EntityGhostHorse(world);
			horse.setHorseSaddled(true);
			horse.setTamedBy(player);
			horse.setLocationAndAngles(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
			world.spawnEntity(horse);
			player.startRiding(horse);
			NBTTagCompound tag = ItemUtil.getOrCreateTag(instrument);
			tag.setInteger("id", horse.getEntityId());
		}
		player.setActiveHand(hand);
	}
	return true;
}
 
Example 2
Project: Backmemed   File: EntityBoat.java   View Source Code Vote up 6 votes
public boolean processInitialInteract(EntityPlayer player, EnumHand stack)
{
    if (player.isSneaking())
    {
        return false;
    }
    else
    {
        if (!this.world.isRemote && this.outOfControlTicks < 60.0F)
        {
            player.startRiding(this);
        }

        return true;
    }
}
 
Example 3
Project: Backmemed   File: EntityMinecartEmpty.java   View Source Code Vote up 6 votes
public boolean processInitialInteract(EntityPlayer player, EnumHand stack)
{
    if (player.isSneaking())
    {
        return false;
    }
    else if (this.isBeingRidden())
    {
        return true;
    }
    else
    {
        if (!this.world.isRemote)
        {
            player.startRiding(this);
        }

        return true;
    }
}
 
Example 4
Project: CustomWorldGen   File: EntityMinecartEmpty.java   View Source Code Vote up 6 votes
public boolean processInitialInteract(EntityPlayer player, @Nullable ItemStack stack, EnumHand hand)
{
    if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, player, stack, hand))) return true;

    if (player.isSneaking())
    {
        return false;
    }
    else if (this.isBeingRidden())
    {
        return true;
    }
    else
    {
        if (!this.worldObj.isRemote)
        {
            player.startRiding(this);
        }

        return true;
    }
}
 
Example 5
Project: CustomWorldGen   File: EntityPig.java   View Source Code Vote up 6 votes
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack)
{
    if (!super.processInteract(player, hand, stack))
    {
        if (this.getSaddled() && !this.worldObj.isRemote && !this.isBeingRidden())
        {
            player.startRiding(this);
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return true;
    }
}
 
Example 6
Project: Backmemed   File: AbstractHorse.java   View Source Code Vote up 5 votes
protected void mountTo(EntityPlayer player)
{
    player.rotationYaw = this.rotationYaw;
    player.rotationPitch = this.rotationPitch;
    this.setEatingHaystack(false);
    this.setRearing(false);

    if (!this.world.isRemote)
    {
        player.startRiding(this);
    }
}
 
Example 7
Project: Backmemed   File: EntityPig.java   View Source Code Vote up 5 votes
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    if (!super.processInteract(player, hand))
    {
        ItemStack itemstack = player.getHeldItem(hand);

        if (itemstack.getItem() == Items.NAME_TAG)
        {
            itemstack.interactWithEntity(player, this, hand);
            return true;
        }
        else if (this.getSaddled() && !this.isBeingRidden())
        {
            if (!this.world.isRemote)
            {
                player.startRiding(this);
            }

            return true;
        }
        else if (itemstack.getItem() == Items.SADDLE)
        {
            itemstack.interactWithEntity(player, this, hand);
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return true;
    }
}
 
Example 8
Project: CustomWorldGen   File: EntityBoat.java   View Source Code Vote up 5 votes
public boolean processInitialInteract(EntityPlayer player, @Nullable ItemStack stack, EnumHand hand)
{
    if (!this.worldObj.isRemote && !player.isSneaking() && this.outOfControlTicks < 60.0F)
    {
        player.startRiding(this);
    }

    return true;
}
 
Example 9
Project: CustomWorldGen   File: EntityHorse.java   View Source Code Vote up 5 votes
private void mountTo(EntityPlayer player)
{
    player.rotationYaw = this.rotationYaw;
    player.rotationPitch = this.rotationPitch;
    this.setEatingHaystack(false);
    this.setRearing(false);

    if (!this.worldObj.isRemote)
    {
        player.startRiding(this);
    }
}
 
Example 10
Project: SimpleTractor   File: EntityTractor.java   View Source Code Vote up 5 votes
@Override
protected boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack) {
    if(player != null && this.canBeRidden(player) && !this.isBeingRidden()) {
        player.startRiding(this);
        return true;
    }
    return false;
}