本文整理匯總了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;
}