本文整理匯總了Java中net.minecraftforge.event.entity.player.EntityItemPickupEvent.getResult方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityItemPickupEvent.getResult方法的具體用法?Java EntityItemPickupEvent.getResult怎麽用?Java EntityItemPickupEvent.getResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.entity.player.EntityItemPickupEvent
的用法示例。
在下文中一共展示了EntityItemPickupEvent.getResult方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCollideWithPlayer
import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //導入方法依賴的package包/類
public void onCollideWithPlayer(EntityPlayer p_70100_1_)
{
if (!this.worldObj.isRemote)
{
if (this.delayBeforeCanPickup > 0)
{
return;
}
EntityItemPickupEvent event = new EntityItemPickupEvent(p_70100_1_, this);
if (MinecraftForge.EVENT_BUS.post(event))
{
return;
}
ItemStack itemstack = this.getEntityItem();
int i = itemstack.stackSize;
if (this.delayBeforeCanPickup <= 0 && (this.field_145802_g == null || lifespan - this.age <= 200 || this.field_145802_g.equals(p_70100_1_.getCommandSenderName())) && (event.getResult() == Result.ALLOW || i <= 0 || p_70100_1_.inventory.addItemStackToInventory(itemstack)))
{
if (itemstack.getItem() == Item.getItemFromBlock(Blocks.log))
{
p_70100_1_.triggerAchievement(AchievementList.mineWood);
}
if (itemstack.getItem() == Item.getItemFromBlock(Blocks.log2))
{
p_70100_1_.triggerAchievement(AchievementList.mineWood);
}
if (itemstack.getItem() == Items.leather)
{
p_70100_1_.triggerAchievement(AchievementList.killCow);
}
if (itemstack.getItem() == Items.diamond)
{
p_70100_1_.triggerAchievement(AchievementList.diamonds);
}
if (itemstack.getItem() == Items.blaze_rod)
{
p_70100_1_.triggerAchievement(AchievementList.blazeRod);
}
if (itemstack.getItem() == Items.diamond && this.func_145800_j() != null)
{
EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(this.func_145800_j());
if (entityplayer1 != null && entityplayer1 != p_70100_1_)
{
entityplayer1.triggerAchievement(AchievementList.field_150966_x);
}
}
FMLCommonHandler.instance().firePlayerItemPickupEvent(p_70100_1_, this);
this.worldObj.playSoundAtEntity(p_70100_1_, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
p_70100_1_.onItemPickup(this, i);
if (itemstack.stackSize <= 0)
{
this.setDead();
}
}
}
}
示例2: onCollideWithPlayer
import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //導入方法依賴的package包/類
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)
{
if (!this.worldObj.isRemote)
{
if (this.delayBeforeCanPickup > 0)
{
return;
}
EntityItemPickupEvent event = new EntityItemPickupEvent(par1EntityPlayer, this);
if (MinecraftForge.EVENT_BUS.post(event))
{
return;
}
ItemStack itemstack = this.getEntityItem();
int i = itemstack.stackSize;
if (this.delayBeforeCanPickup <= 0 && (event.getResult() == Result.ALLOW || i <= 0 || par1EntityPlayer.inventory.addItemStackToInventory(itemstack)))
{
if (itemstack.itemID == Block.wood.blockID)
{
par1EntityPlayer.triggerAchievement(AchievementList.mineWood);
}
if (itemstack.itemID == Item.leather.itemID)
{
par1EntityPlayer.triggerAchievement(AchievementList.killCow);
}
if (itemstack.itemID == Item.diamond.itemID)
{
par1EntityPlayer.triggerAchievement(AchievementList.diamonds);
}
if (itemstack.itemID == Item.blazeRod.itemID)
{
par1EntityPlayer.triggerAchievement(AchievementList.blazeRod);
}
GameRegistry.onPickupNotification(par1EntityPlayer, this);
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
par1EntityPlayer.onItemPickup(this, i);
if (itemstack.stackSize <= 0)
{
this.setDead();
}
}
}
}