本文整理匯總了Java中net.minecraft.entity.Entity.playSound方法的典型用法代碼示例。如果您正苦於以下問題:Java Entity.playSound方法的具體用法?Java Entity.playSound怎麽用?Java Entity.playSound使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.Entity
的用法示例。
在下文中一共展示了Entity.playSound方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onUserHurt
import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
* Whenever an entity that has this enchantment on one of its associated items is damaged this method will be
* called.
*/
public void onUserHurt(EntityLivingBase user, Entity attacker, int level)
{
Random random = user.getRNG();
ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantment.thorns, user);
if (func_92094_a(level, random))
{
if (attacker != null)
{
attacker.attackEntityFrom(DamageSource.causeThornsDamage(user), (float)func_92095_b(level, random));
attacker.playSound("damage.thorns", 0.5F, 1.0F);
}
if (itemstack != null)
{
itemstack.damageItem(3, user);
}
}
else if (itemstack != null)
{
itemstack.damageItem(1, user);
}
}
示例2: onDealDamage
import net.minecraft.entity.Entity; //導入方法依賴的package包/類
@Override
public void onDealDamage(ItemStack stack, EntityLivingBase attacker, Entity target, DamageSource source, float amount) {
super.onDealDamage(stack, attacker, target, source, amount);
if (target instanceof EntityLivingBase && !(target instanceof EntityBuilding)
&& getData(stack).getName().equals("sandmanball")) {
EntityBall ball = (EntityBall) source.getImmediateSource();
double reduce=Math.max(0.5, (25-((EntityLivingBase) target).getEntityAttribute(SharedMonsterAttributes.ARMOR).getAttributeValue())/25D);
if (!ball.canBePickedUp && ball.throwPos.squareDistanceTo(target.getPositionVector()) > 1100) {
TF2Util.stun((EntityLivingBase) target,
(int) (160 * reduce), true);
target.playSound(TF2Sounds.WEAPON_STUN_MAX, 4f, 1f);
} else if (!ball.canBePickedUp && ball.throwPos.squareDistanceTo(target.getPositionVector()) > 12) {
TF2Util.stun((EntityLivingBase) target,
(int) (ball.throwPos.distanceTo(target.getPositionVector()) * 8 * reduce), false);
target.playSound(TF2Sounds.WEAPON_STUN, 1.6f, 1f);
}
}
}
示例3: getCollisionBox
import net.minecraft.entity.Entity; //導入方法依賴的package包/類
@Override
public AxisAlignedBB getCollisionBox(Entity entityIn) {
if (!this.world.isRemote && !this.isExit() && this.getTPprogress() <= 0 && entityIn != null
&& entityIn instanceof EntityLivingBase && !(entityIn instanceof EntityBuilding)
&& ((this.getOwner() != null && ((WeaponsCapability.get(this.getOwner()).teleporterEntity && !(entityIn instanceof EntityPlayer)) ||
(WeaponsCapability.get(this.getOwner()).teleporterPlayer && entityIn instanceof EntityPlayer && entityIn.getTeam() == null)))
|| TF2Util.isOnSameTeam(EntityTeleporter.this, entityIn))
&& entityIn.getEntityBoundingBox()
.intersects(this.getEntityBoundingBox().grow(0, 0.5, 0).offset(0, 0.5D, 0)))
if (ticksToTeleport <= 0)
if (ticksToTeleport < 0)
ticksToTeleport = 10;
else {
TeleporterData exit = this.getTeleportExit();
if (exit != null) {
if (exit.dimension != this.dimension) {
if(entityIn instanceof EntityPlayerMP && net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, exit.dimension)) {
this.world.getMinecraftServer().getPlayerList().transferPlayerToDimension((EntityPlayerMP) entityIn,
exit.dimension, new TeleporterDim((WorldServer) this.world,exit));
}
else {
World destworld = this.world.getMinecraftServer().getWorld(exit.dimension);
Entity newent = EntityList.newEntity(entityIn.getClass(), destworld);
if(newent != null) {
NBTTagCompound data = entityIn.writeToNBT(new NBTTagCompound());
data.removeTag("Dimension");
newent.readFromNBT(data);
entityIn.setDead();
newent.forceSpawn = true;
entityIn.moveToBlockPosAndAngles(exit, entityIn.rotationYaw, entityIn.rotationPitch);
destworld.spawnEntity(newent);
entityIn = newent;
}
}
}
entityIn.setPositionAndUpdate(exit.getX() + 0.5, exit.getY() + 0.23, exit.getZ() + 0.5);
this.setTeleports(this.getTeleports() + 1);
this.setTPprogress(this.getLevel() == 1 ? 200 : (this.getLevel() == 2 ? 100 : 60));
this.playSound(TF2Sounds.MOB_TELEPORTER_SEND, 1.5f, 1f);
entityIn.playSound(TF2Sounds.MOB_TELEPORTER_RECEIVE, 0.75f, 1f);
if(this.getOwner() instanceof EntityPlayerMP){
((EntityPlayer) this.getOwner()).addStat(TF2Achievements.TELEPORTED);
/*if(((EntityPlayerMP) this.getOwner()).getStatFile().readStat(TF2Achievements.TELEPORTED)>=100)
((EntityPlayer) this.getOwner()).addStat(TF2Achievements.TELEPORTS);*/
}
}
}
return super.getCollisionBox(entityIn);
}