本文整理汇总了Java中net.minecraft.init.Items.fish方法的典型用法代码示例。如果您正苦于以下问题:Java Items.fish方法的具体用法?Java Items.fish怎么用?Java Items.fish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.init.Items
的用法示例。
在下文中一共展示了Items.fish方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: interact
import net.minecraft.init.Items; //导入方法依赖的package包/类
/**
* 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();
if (this.isTamed())
{
if (this.isOwner(player) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack))
{
this.aiSit.setSitting(!this.isSitting());
}
}
else if (this.aiTempt.isRunning() && itemstack != null && itemstack.getItem() == Items.fish && player.getDistanceSqToEntity(this) < 9.0D)
{
if (!player.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(3) == 0)
{
this.setTamed(true);
this.setTameSkin(1 + this.worldObj.rand.nextInt(3));
this.setOwnerId(player.getUniqueID().toString());
this.playTameEffect(true);
this.aiSit.setSitting(true);
this.worldObj.setEntityState(this, (byte)7);
}
else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte)6);
}
}
return true;
}
return super.interact(player);
}
示例2: isBreedingItem
import net.minecraft.init.Items; //导入方法依赖的package包/类
/**
* 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 stack)
{
return stack != null && stack.getItem() == Items.fish;
}