本文整理匯總了Java中net.minecraft.entity.projectile.EntityPotion類的典型用法代碼示例。如果您正苦於以下問題:Java EntityPotion類的具體用法?Java EntityPotion怎麽用?Java EntityPotion使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EntityPotion類屬於net.minecraft.entity.projectile包,在下文中一共展示了EntityPotion類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onItemRightClick
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
if (isSplash(itemStackIn.getMetadata()))
{
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(new EntityPotion(worldIn, playerIn, itemStackIn));
}
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
return itemStackIn;
}
else
{
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
return itemStackIn;
}
}
示例2: onItemRightClick
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
ItemStack itemstack1 = worldIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_LINGERINGPOTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!itemStackIn.isRemote)
{
EntityPotion entitypotion = new EntityPotion(itemStackIn, worldIn, itemstack1);
entitypotion.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, -20.0F, 0.5F, 1.0F);
itemStackIn.spawnEntityInWorld(entitypotion);
}
worldIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
示例3: onItemRightClick
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
ItemStack itemstack1 = worldIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_SPLASH_POTION_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!itemStackIn.isRemote)
{
EntityPotion entitypotion = new EntityPotion(itemStackIn, worldIn, itemstack1);
entitypotion.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, -20.0F, 0.5F, 1.0F);
itemStackIn.spawnEntityInWorld(entitypotion);
}
worldIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
示例4: onItemRightClick
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_LINGERINGPOTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
EntityPotion entitypotion = new EntityPotion(worldIn, playerIn, itemStackIn);
entitypotion.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
worldIn.spawnEntityInWorld(entitypotion);
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
示例5: onItemRightClick
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SPLASH_POTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
EntityPotion entitypotion = new EntityPotion(worldIn, playerIn, itemStackIn);
entitypotion.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
worldIn.spawnEntityInWorld(entitypotion);
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
示例6: attackWithPotion
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
protected void attackWithPotion(EntityLivingBase target) {
double targetY = target.posY + (double) target.getEyeHeight() - 1.100000023841858D;
double targetX = target.posX + target.motionX - this.posX;
double d2 = targetY - this.posY;
double targetZ = target.posZ + target.motionZ - this.posZ;
float f = MathHelper.sqrt(targetX * targetX + targetZ * targetZ);
PotionType potiontype = PotionTypes.HARMING;
if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS)) {
potiontype = PotionTypes.SLOWNESS;
} else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON)) {
potiontype = PotionTypes.POISON;
} else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F) {
potiontype = PotionTypes.WEAKNESS;
}
EntityPotion entitypotion = new EntityPotion(this.world, this,
PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
entitypotion.rotationPitch -= -20.0F;
entitypotion.setThrowableHeading(targetX, d2 + (double) (f * 0.2F), targetZ, 0.75F, 8.0F);
this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F,
0.8F + this.rand.nextFloat() * 0.4F);
this.world.spawnEntity(entitypotion);
}
示例7: applyPotionOnBlocks
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
public static void applyPotionOnBlocks(EntityPotion entityPotion) {
int range = 5;
Map<BlockPos, TileEntity> teMap = entityPotion.world.getChunkFromBlockCoords(entityPotion.getPosition()).getTileEntityMap();
teMap.putAll(entityPotion.world.getChunkFromBlockCoords(new BlockPos(entityPotion.posX + range, entityPotion.posY, entityPotion.posZ)).getTileEntityMap());
teMap.putAll(entityPotion.world.getChunkFromBlockCoords(new BlockPos(entityPotion.posX - range, entityPotion.posY, entityPotion.posZ)).getTileEntityMap());
teMap.putAll(entityPotion.world.getChunkFromBlockCoords(new BlockPos(entityPotion.posX, entityPotion.posY, entityPotion.posZ + range)).getTileEntityMap());
teMap.putAll(entityPotion.world.getChunkFromBlockCoords(new BlockPos(entityPotion.posX, entityPotion.posY, entityPotion.posZ - range)).getTileEntityMap());
teMap.putAll(entityPotion.world.getChunkFromBlockCoords(new BlockPos(entityPotion.posX + range, entityPotion.posY, entityPotion.posZ + range)).getTileEntityMap());
teMap.putAll(entityPotion.world.getChunkFromBlockCoords(new BlockPos(entityPotion.posX + range, entityPotion.posY, entityPotion.posZ - range)).getTileEntityMap());
teMap.putAll(entityPotion.world.getChunkFromBlockCoords(new BlockPos(entityPotion.posX - range, entityPotion.posY, entityPotion.posZ + range)).getTileEntityMap());
teMap.putAll(entityPotion.world.getChunkFromBlockCoords(new BlockPos(entityPotion.posX - range, entityPotion.posY, entityPotion.posZ - range)).getTileEntityMap());
for (Map.Entry<BlockPos, TileEntity> teEntry : teMap.entrySet()) {
if (teEntry != null && teEntry.getValue() instanceof TileEntityGraveStone &&
(teEntry.getKey().getX() >= entityPotion.posX - range && teEntry.getKey().getX() <= entityPotion.posX + range &&
teEntry.getKey().getZ() >= entityPotion.posZ - range && teEntry.getKey().getZ() <= entityPotion.posZ + range &&
teEntry.getKey().getY() >= entityPotion.posY - range && teEntry.getKey().getY() <= entityPotion.posY + range)) {
((TileEntityGraveStone) teEntry.getValue()).setPurified(true);
}
}
}
示例8: doHeal
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
private void doHeal(EntityLivingBase guy) {
armSwing(!didSwing); // Swings arm and heals the specified person.
EntityPotion potion = new EntityPotion(worldObj, this,
handPotion().getItemDamage());
worldObj.spawnEntityInWorld(potion);
// potion.onImpact(new MovingObjectPosition(guy));
try {
final Method onImpact = ReflectionHelper.findMethod(
EntityPotion.class, potion, MCP_ONIMPACT,
MovingObjectPosition.class);
onImpact.invoke(potion, new MovingObjectPosition(guy));
} catch (Exception e) {
e.printStackTrace();
}
setPathToEntity((PathEntity) null);
healTime = 200;
setRarePotion(rand.nextInt(4) == 0);
}
示例9: onItemRightClick
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
{
if (isSplash(p_77659_1_.getItemDamage()))
{
if (!p_77659_3_.capabilities.isCreativeMode)
{
--p_77659_1_.stackSize;
}
p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!p_77659_2_.isRemote)
{
p_77659_2_.spawnEntityInWorld(new EntityPotion(p_77659_2_, p_77659_3_, p_77659_1_));
}
return p_77659_1_;
}
else
{
p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_));
return p_77659_1_;
}
}
示例10: onItemRightClick
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (isSplash(par1ItemStack.getItemDamage()))
{
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
}
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!par2World.isClient)
{
par2World.spawnEntityInWorld(new EntityPotion(par2World, par3EntityPlayer, par1ItemStack));
}
return par1ItemStack;
}
else
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
}
}
示例11: onItemRightClick
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
{
if (isSplash(p_77659_1_.getItemDamage()))
{
if (!p_77659_3_.capabilities.isCreativeMode)
{
--p_77659_1_.stackSize;
}
p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!p_77659_2_.isRemote)
{
p_77659_2_.spawnEntityInWorld(new EntityPotion(p_77659_2_, p_77659_3_, p_77659_1_));
}
return p_77659_1_;
}
else
{
p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_));
return p_77659_1_;
}
}
示例12: func_82196_d
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
public void func_82196_d(EntityLivingBase p_82196_1_, float p_82196_2_) {
if(!this.func_82198_m()) {
EntityPotion var3 = new EntityPotion(this.field_70170_p, this, 32732);
var3.field_70125_A -= -20.0F;
double var4 = p_82196_1_.field_70165_t + p_82196_1_.field_70159_w - this.field_70165_t;
double var6 = p_82196_1_.field_70163_u + (double)p_82196_1_.func_70047_e() - 1.100000023841858D - this.field_70163_u;
double var8 = p_82196_1_.field_70161_v + p_82196_1_.field_70179_y - this.field_70161_v;
float var10 = MathHelper.func_76133_a(var4 * var4 + var8 * var8);
if(var10 >= 8.0F && !p_82196_1_.func_70644_a(Potion.field_76421_d)) {
var3.func_82340_a(32698);
} else if(p_82196_1_.func_110143_aJ() >= 8.0F && !p_82196_1_.func_70644_a(Potion.field_76436_u)) {
var3.func_82340_a(32660);
} else if(var10 <= 3.0F && !p_82196_1_.func_70644_a(Potion.field_76437_t) && this.field_70146_Z.nextFloat() < 0.25F) {
var3.func_82340_a(32696);
}
var3.func_70186_c(var4, var6 + (double)(var10 * 0.2F), var8, 0.75F, 8.0F);
this.field_70170_p.func_72838_d(var3);
}
}
示例13: func_77659_a
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
public ItemStack func_77659_a(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) {
if(func_77831_g(p_77659_1_.func_77960_j())) {
if(!p_77659_3_.field_71075_bZ.field_75098_d) {
--p_77659_1_.field_77994_a;
}
p_77659_2_.func_72956_a(p_77659_3_, "random.bow", 0.5F, 0.4F / (field_77697_d.nextFloat() * 0.4F + 0.8F));
if(!p_77659_2_.field_72995_K) {
p_77659_2_.func_72838_d(new EntityPotion(p_77659_2_, p_77659_3_, p_77659_1_));
}
return p_77659_1_;
} else {
p_77659_3_.func_71008_a(p_77659_1_, this.func_77626_a(p_77659_1_));
return p_77659_1_;
}
}
示例14: func_76986_a
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
public void func_76986_a(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) {
Icon var10 = this.field_94151_a.func_77617_a(this.field_94150_f);
if(var10 != null) {
GL11.glPushMatrix();
GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_);
GL11.glEnable('\u803a');
GL11.glScalef(0.5F, 0.5F, 0.5F);
this.func_110777_b(p_76986_1_);
Tessellator var11 = Tessellator.field_78398_a;
if(var10 == ItemPotion.func_94589_d("bottle_splash")) {
int var12 = PotionHelper.func_77915_a(((EntityPotion)p_76986_1_).func_70196_i(), false);
float var13 = (float)(var12 >> 16 & 255) / 255.0F;
float var14 = (float)(var12 >> 8 & 255) / 255.0F;
float var15 = (float)(var12 & 255) / 255.0F;
GL11.glColor3f(var13, var14, var15);
GL11.glPushMatrix();
this.func_77026_a(var11, ItemPotion.func_94589_d("overlay"));
GL11.glPopMatrix();
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
this.func_77026_a(var11, var10);
GL11.glDisable('\u803a');
GL11.glPopMatrix();
}
}
示例15: onItemRightClick
import net.minecraft.entity.projectile.EntityPotion; //導入依賴的package包/類
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (isSplash(par1ItemStack.getItemDamage()))
{
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
}
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!par2World.isRemote)
{
par2World.spawnEntityInWorld(new EntityPotion(par2World, par3EntityPlayer, par1ItemStack));
}
return par1ItemStack;
}
else
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
}
}