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

The following are Jave code examples for showing how to use displayVillagerTradeGui() 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: DecompiledMinecraft   File: EntityVillager.java   View Source Code Vote up 6 votes
/**
 * 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 player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();
    boolean flag = itemstack != null && itemstack.getItem() == Items.spawn_egg;

    if (!flag && this.isEntityAlive() && !this.isTrading() && !this.isChild())
    {
        if (!this.worldObj.isRemote && (this.buyingList == null || this.buyingList.size() > 0))
        {
            this.setCustomer(player);
            player.displayVillagerTradeGui(this);
        }

        player.triggerAchievement(StatList.timesTalkedToVillagerStat);
        return true;
    }
    else
    {
        return super.interact(player);
    }
}
 
Example 2
Project: DecompiledMinecraft   File: EntityVillager.java   View Source Code Vote up 6 votes
/**
 * 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 player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();
    boolean flag = itemstack != null && itemstack.getItem() == Items.spawn_egg;

    if (!flag && this.isEntityAlive() && !this.isTrading() && !this.isChild())
    {
        if (!this.worldObj.isRemote && (this.buyingList == null || this.buyingList.size() > 0))
        {
            this.setCustomer(player);
            player.displayVillagerTradeGui(this);
        }

        player.triggerAchievement(StatList.timesTalkedToVillagerStat);
        return true;
    }
    else
    {
        return super.interact(player);
    }
}
 
Example 3
Project: BaseClient   File: EntityVillager.java   View Source Code Vote up 6 votes
/**
 * 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 player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();
    boolean flag = itemstack != null && itemstack.getItem() == Items.spawn_egg;

    if (!flag && this.isEntityAlive() && !this.isTrading() && !this.isChild())
    {
        if (!this.worldObj.isRemote && (this.buyingList == null || this.buyingList.size() > 0))
        {
            this.setCustomer(player);
            player.displayVillagerTradeGui(this);
        }

        player.triggerAchievement(StatList.timesTalkedToVillagerStat);
        return true;
    }
    else
    {
        return super.interact(player);
    }
}
 
Example 4
Project: BaseClient   File: EntityVillager.java   View Source Code Vote up 6 votes
/**
 * 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 player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();
    boolean flag = itemstack != null && itemstack.getItem() == Items.spawn_egg;

    if (!flag && this.isEntityAlive() && !this.isTrading() && !this.isChild())
    {
        if (!this.worldObj.isRemote && (this.buyingList == null || this.buyingList.size() > 0))
        {
            this.setCustomer(player);
            player.displayVillagerTradeGui(this);
        }

        player.triggerAchievement(StatList.timesTalkedToVillagerStat);
        return true;
    }
    else
    {
        return super.interact(player);
    }
}
 
Example 5
Project: Mods   File: EntitySaxtonHale.java   View Source Code Vote up 6 votes
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
	if (!(player.getHeldItemMainhand() != null
			&& player.getHeldItemMainhand().getItem() instanceof ItemMonsterPlacerPlus)
			&& this.getAttackTarget() == null && this.isEntityAlive() && !this.isTrading() && !this.isChild()
			&& !player.isSneaking()) {
		if (this.world.isRemote && player.getTeam() == null && !player.isCreative())
			ClientProxy.displayScreenJoinTeam();
		else if (!this.world.isRemote && (player.getTeam() != null || player.isCreative())
				&& (this.tradeOffers == null || !this.tradeOffers.isEmpty())) {
			this.setCustomer(player);
			player.displayVillagerTradeGui(this);
		}

		player.addStat(StatList.TALKED_TO_VILLAGER);
		return true;
	} else
		return super.processInteract(player, hand);
}
 
Example 6
Project: CustomWorldGen   File: EntityVillager.java   View Source Code Vote up 6 votes
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack)
{
    boolean flag = stack != null && stack.getItem() == Items.SPAWN_EGG;

    if (!flag && this.isEntityAlive() && !this.isTrading() && !this.isChild() && !player.isSneaking())
    {
        if (!this.worldObj.isRemote && (this.buyingList == null || !this.buyingList.isEmpty()))
        {
            this.setCustomer(player);
            player.displayVillagerTradeGui(this);
        }

        player.addStat(StatList.TALKED_TO_VILLAGER);
        return true;
    }
    else
    {
        return super.processInteract(player, hand, stack);
    }
}
 
Example 7
Project: Backmemed   File: EntityVillager.java   View Source Code Vote up 5 votes
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);
    boolean flag = itemstack.getItem() == Items.NAME_TAG;

    if (flag)
    {
        itemstack.interactWithEntity(player, this, hand);
        return true;
    }
    else if (!this.func_190669_a(itemstack, this.getClass()) && this.isEntityAlive() && !this.isTrading() && !this.isChild())
    {
        if (this.buyingList == null)
        {
            this.populateBuyingList();
        }

        if (hand == EnumHand.MAIN_HAND)
        {
            player.addStat(StatList.TALKED_TO_VILLAGER);
        }

        if (!this.world.isRemote && !this.buyingList.isEmpty())
        {
            this.setCustomer(player);
            player.displayVillagerTradeGui(this);
        }
        else if (this.buyingList.isEmpty())
        {
            return super.processInteract(player, hand);
        }

        return true;
    }
    else
    {
        return super.processInteract(player, hand);
    }
}