本文整理汇总了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();
}
}
}
}