本文整理汇总了Java中net.minecraft.entity.projectile.EntitySnowball类的典型用法代码示例。如果您正苦于以下问题:Java EntitySnowball类的具体用法?Java EntitySnowball怎么用?Java EntitySnowball使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntitySnowball类属于net.minecraft.entity.projectile包,在下文中一共展示了EntitySnowball类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemRightClick
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的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 (!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 EntitySnowball(worldIn, playerIn));
}
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
return itemStackIn;
}
示例2: onItemRightClick
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
if (!worldIn.capabilities.isCreativeMode)
{
itemstack.func_190918_g(1);
}
itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!itemStackIn.isRemote)
{
EntitySnowball entitysnowball = new EntitySnowball(itemStackIn, worldIn);
entitysnowball.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, 0.0F, 1.5F, 1.0F);
itemStackIn.spawnEntityInWorld(entitysnowball);
}
worldIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
示例3: onItemRightClick
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的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_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
EntitySnowball entitysnowball = new EntitySnowball(worldIn, playerIn);
entitysnowball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
worldIn.spawnEntityInWorld(entitysnowball);
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
示例4: execute
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的package包/类
@Override
public void execute(EntityLivingBase target, @Nullable AbstractMorph morph)
{
if (!target.worldObj.isRemote)
{
EntitySnowball snowball = new EntitySnowball(target.worldObj, target);
Vec3d vec3d = target.getLook(1.0F);
double d1 = 4.0D;
double d2 = vec3d.xCoord * d1;
double d3 = vec3d.yCoord * d1;
double d4 = vec3d.zCoord * d1;
snowball.setPosition(target.posX, target.posY + target.height * 0.9F, target.posZ);
snowball.motionX = d2;
snowball.motionY = d3;
snowball.motionZ = d4;
target.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (target.getRNG().nextFloat() * 0.4F + 0.8F));
target.worldObj.spawnEntityInWorld(snowball);
}
}
示例5: snowballFight
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的package包/类
public boolean snowballFight(DamageSource damagesource) {
if (damagesource instanceof EntityDamageSourceIndirect) {
EntityDamageSourceIndirect snowdamage = (EntityDamageSourceIndirect) damagesource;
if (snowdamage.getSourceOfDamage() != null && snowdamage
.getSourceOfDamage() instanceof EntitySnowball) {
snowballin += 1;
if (attackTime < 10) {
attackTime = 10;
}
}
}
return snowballin <= 0;
}
示例6: tossSnowball
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的package包/类
private void tossSnowball(EntityLivingBase attackTarget) {
EntitySnowball entitysnowball = new EntitySnowball(worldObj, this);
double d = attackTarget.posX - this.posX;
double d1 = ( attackTarget.posY + (double) attackTarget.getEyeHeight() )
- 1.1000000238418579D - entitysnowball.posY;
double d2 = attackTarget.posZ - this.posZ;
float f = MathHelper.sqrt_double(d * d + d2 * d2) * 0.2F;
entitysnowball.setThrowableHeading(d, d1 + (double) f, d2, 1.6F, 12F);
worldObj.playSoundAtEntity(this, "random.bow", 1.0F,
1.0F / ( this.getRNG().nextFloat() * 0.4F + 0.8F ));
worldObj.spawnEntityInWorld(entitysnowball);
attackTime = 30;
armSwing(!didSwing);
faceEntity(attackTarget, 180F, 180F);
snowballin -= 1;
if (snowballin < 0) {
snowballin = 0;
}
}
示例7: onItemRightClick
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的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 (!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 EntitySnowball(par2World, par3EntityPlayer));
}
return par1ItemStack;
}
示例8: update
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的package包/类
@Override
public void update() {
super.update();
List<Entity> entityList = worldObj.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.getX() - .5, pos.getY() - .5, pos.getZ() - .5, pos.getX() + 1.5, pos.getY() + 1.5, pos.getZ() + 1.5));
for (Entity entity : entityList) {
if (entity instanceof EntitySnowball || entity instanceof EntityEgg) {
//Fun fact: Eggs and snowballs use the same particle code
for (int i = 0; i < 8; ++i) {
this.worldObj.spawnParticle(EnumParticleTypes.SNOWBALL, entity.posX, entity.posY, entity.posZ, 0.0D, 0.0D, 0.0D);
}
entity.setDead();
if (!worldObj.isRemote) {
onEntityCollidedWithBlock(entity);
}
} else if (entity instanceof EntityArrow) {
entity.setDead();
if (!worldObj.isRemote) {
onEntityCollidedWithBlock(entity);
}
}
}
}
示例9: onItemRightClick
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的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 (!par3EntityPlayer.capabilities.isCreativeMode)
// {
// --par1ItemStack.stackSize;
// }
par3EntityPlayer.swingItem();//Make the item swing on right click
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!par2World.isRemote)
{
par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer));
}
return par1ItemStack;
}
示例10: replaceSnowballWithArrow
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的package包/类
@SubscribeEvent
public void replaceSnowballWithArrow(EntityJoinWorldEvent event) {
Entity entity = event.entity;
World world = entity.worldObj;
if (!(entity instanceof EntitySnowball)) {
return;
}
if (!world.isRemote) {
EntityArrow arrow = new EntityArrow(world);
arrow.setLocationAndAngles(entity.posX, entity.posY, entity.posZ,
0, 0);
arrow.motionX = entity.motionX;
arrow.motionY = entity.motionY;
arrow.motionZ = entity.motionZ;
arrow.posX += arrow.motionX;
arrow.posY += arrow.motionY;
arrow.posZ += arrow.motionZ;
world.spawnEntityInWorld(arrow);
entity.setDead();
}
}
示例11: onItemRightClick
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的package包/类
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
{
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 EntitySnowball(p_77659_2_, p_77659_3_));
}
return p_77659_1_;
}
示例12: onItemRightClick
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的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 (!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 EntitySnowball(par2World, par3EntityPlayer));
}
return par1ItemStack;
}
示例13: onItemRightClick
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的package包/类
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
/*
* if(lastUse == 0) par2World.getWorldTime();
*/
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!par2World.isRemote/* && lastUse + 4 < par2World.getWorldTime() */)
{
par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer));
// lastUse = par2World.getWorldTime();
}
par1ItemStack.damageItem(1, par3EntityPlayer);
return par1ItemStack;
}
示例14: attackEntityWithRangedAttack
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的package包/类
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
double d1 = p_82196_1_.posX - this.posX;
double d2 = d0 - entitysnowball.posY;
double d3 = p_82196_1_.posZ - this.posZ;
float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F;
entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.worldObj.spawnEntityInWorld(entitysnowball);
}
示例15: attackEntityWithRangedAttack
import net.minecraft.entity.projectile.EntitySnowball; //导入依赖的package包/类
/**
* Attack the specified entity using a ranged attack.
*
* @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
*/
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
EntitySnowball entitysnowball = new EntitySnowball(this.world, this);
double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
double d1 = target.posX - this.posX;
double d2 = d0 - entitysnowball.posY;
double d3 = target.posZ - this.posZ;
float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
this.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.world.spawnEntityInWorld(entitysnowball);
}