本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.playSound方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.playSound方法的具体用法?Java EntityLivingBase.playSound怎么用?Java EntityLivingBase.playSound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.playSound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEquipped
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onEquipped(ItemStack stack, EntityLivingBase entity)
{
if (entity.getEntityWorld().isRemote) entity.playSound(SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.1F, 1.3f);
else
{
if (entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entity;
PlayerInformation info = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
if (info != null && info.getPlayerLevel() >= NBTHelper.loadStackNBT(stack).getInteger("Level"))
{
EventPlayerTick.updateStats(player, info);
}
else player.sendMessage(new TextComponentString(TextFormatting.RED + "WARNING: You are using a high-leveled item. It will be useless and will not provide any bonuses."));
}
}
}
示例2: attackEntityFrom
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (!this.func_175472_n() && !source.isMagicDamage() && source.getSourceOfDamage() instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)source.getSourceOfDamage();
if (!source.isExplosion())
{
entitylivingbase.attackEntityFrom(DamageSource.causeThornsDamage(this), 2.0F);
entitylivingbase.playSound("damage.thorns", 0.5F, 1.0F);
}
}
this.wander.makeUpdate();
return super.attackEntityFrom(source, amount);
}
示例3: setCloak
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void setCloak(boolean active, ItemStack stack, EntityLivingBase living, World world) {
// System.out.println("set active: "+active);
if (!active || !(living instanceof EntityPlayer) || searchForWatches(living).getSecond().isEmpty()) {
if (!active) {
living.setInvisible(false);
living.getCapability(TF2weapons.WEAPONS_CAP, null).invisTicks = 20;
}
// System.out.println("ok: "+active);
stack.getTagCompound().setBoolean("Active", active);
WeaponsCapability.get(living).setInvisible(active);
// setInvisiblity(living);
if (active) {
living.playSound(ItemFromData.getSound(stack, PropertyType.CLOAK_SOUND), 1.5f, 1);
stack.setItemDamage(Math.min(this.getMaxDamage(stack),
stack.getItemDamage()+this.getMaxDamage(stack)-(int)TF2Attribute.getModifier("Cloak Drain", stack, this.getMaxDamage(stack),living)));
}
else
living.playSound(ItemFromData.getSound(stack, PropertyType.DECLOAK_SOUND), 1.5f, 1);
if (!world.isRemote) {
// TF2weapons.sendTracking(new
// TF2Message.PropertyMessage("IsCloaked",
// (byte)(active?1:0),living),living);
}
}
}
示例4: onActiveItemUseTick
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void onActiveItemUseTick(LivingEntityUseItemEvent.Tick event) {
ItemStack stack = event.getItem();
if (stack.getItem() == TrumpetSkeletonItems.TRUMPET) {
if (event.getDuration() == stack.getMaxItemUseDuration() - 10) {
EntityLivingBase user = event.getEntityLiving();
World world = user.world;
user.playSound(TrumpetSkeletonSoundEvents.ITEM_TRUMPET_USE, 1.0F, 0.9F + world.rand.nextFloat() * 0.2F);
if (!world.isRemote) {
List<EntityLivingBase> spookedEntities = world.getEntitiesWithinAABB(EntityLivingBase.class, user.getEntityBoundingBox().grow(10.0D));
for (EntityLivingBase spookedEntity : spookedEntities) {
if (spookedEntity == user) continue;
double deltaX = user.posX - spookedEntity.posX;
double deltaZ = user.posZ - spookedEntity.posZ;
double distance = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
if (distance > 0.25D) {
spookedEntity.knockBack(user, 0.5F, deltaX / distance, deltaZ / distance);
}
spookedEntity.setRevengeTarget(user);
}
stack.damageItem(1, user);
}
} else if (event.getDuration() <= stack.getMaxItemUseDuration() - 15) {
event.setCanceled(true);
}
}
}
示例5: onItemUseFinish
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
* the Item before the action is complete.
*/
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
ItemStack itemstack = super.onItemUseFinish(stack, worldIn, entityLiving);
if (!worldIn.isRemote)
{
double d0 = entityLiving.posX;
double d1 = entityLiving.posY;
double d2 = entityLiving.posZ;
for (int i = 0; i < 16; ++i)
{
double d3 = entityLiving.posX + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
double d4 = MathHelper.clamp(entityLiving.posY + (double)(entityLiving.getRNG().nextInt(16) - 8), 0.0D, (double)(worldIn.getActualHeight() - 1));
double d5 = entityLiving.posZ + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
if (entityLiving.isRiding())
{
entityLiving.dismountRidingEntity();
}
if (entityLiving.attemptTeleport(d3, d4, d5))
{
worldIn.playSound((EntityPlayer)null, d0, d1, d2, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
entityLiving.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
break;
}
}
if (entityLiving instanceof EntityPlayer)
{
((EntityPlayer)entityLiving).getCooldownTracker().setCooldown(this, 20);
}
}
return itemstack;
}
示例6: doFireSound
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void doFireSound(ItemStack stack, EntityLivingBase living, World world, int critical) {
if (ItemFromData.getData(stack).hasProperty(PropertyType.FIRE_SOUND)) {
SoundEvent soundToPlay = SoundEvent.REGISTRY
.getObject(new ResourceLocation(ItemFromData.getData(stack).getString(PropertyType.FIRE_SOUND)
+ (critical == 2 ? ".crit" : "")));
living.playSound(soundToPlay, living instanceof EntityLiving && !(((EntityLiving) living).getAttackTarget() instanceof EntityPlayer) ? TF2ConfigVars.mercenaryVolume : TF2ConfigVars.gunVolume, 1f);
if (world.isRemote)
ClientProxy.removeReloadSound(living);
}
}
示例7: doFireSound
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void doFireSound(ItemStack stack, EntityLivingBase living, World world, int critical) {
if (ItemFromData.getData(stack).hasProperty(PropertyType.CHARGED_FIRE_SOUND)
&& living.getCapability(TF2weapons.WEAPONS_CAP, null).chargeTicks >= getChargeTime(stack, living)) {
SoundEvent soundToPlay = SoundEvent.REGISTRY
.getObject(new ResourceLocation(ItemFromData.getData(stack).getString(PropertyType.CHARGED_FIRE_SOUND)
+ (critical == 2 ? ".crit" : "")));
living.playSound(soundToPlay, 4f, 1f);
if (world.isRemote)
ClientProxy.removeReloadSound(living);
}
else {
super.doFireSound(stack, living, world, critical);
}
}
示例8: endUse
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public boolean endUse(ItemStack stack, EntityLivingBase living, World world, int action, int newState) {
if ((action & 1) == 1) {
if (world.isRemote)
// System.out.println("called"+ClientProxy.fireSounds.get(living));
if (ClientProxy.fireSounds.get(living) != null)
// System.out.println("called2"+ClientProxy.fireSounds.get(living).type);
ClientProxy.fireSounds.get(living).setDone();
// Minecraft.getMinecraft().getSoundHandler().stopSound(ClientProxy.fireSounds.get(living));
living.playSound(ItemFromData.getSound(stack, PropertyType.FIRE_STOP_SOUND), 1f, 1f);
}
return false;
}
示例9: altFireTick
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public boolean altFireTick(ItemStack stack, EntityLivingBase living, World world) {
if (!world.isRemote) {
ArrayList<EntityStickybomb> list = living.getCapability(TF2weapons.WEAPONS_CAP, null).activeBomb;
if (list == null || list.isEmpty())
return false;
boolean exploded = false;
TF2PlayerCapability cap=living.getCapability(TF2weapons.PLAYER_CAP, null);
if(cap != null){
cap.engineerKilled=false;
cap.dispenserKilled=false;
cap.sentryKilled=false;
cap.stickybombKilled=0;
}
for (int i = 0; i < list.size(); i++) {
EntityStickybomb bomb = list.get(i);
if (bomb.ticksExisted > bomb.getArmTime() && (bomb.getType()!=1 || living.getEntityBoundingBox().grow(1.5, 0.25, 1.5).offset(0, -1.25, 0).contains(bomb.getPositionVector()) || TF2Util.lookingAt(living, 30, bomb.posX, bomb.posY, bomb.posZ))) {
bomb.explode(bomb.posX, bomb.posY + bomb.height / 2, bomb.posZ, null, 1);
i--;
exploded = true;
}
}
if (exploded) {
living.playSound(ItemFromData.getSound(stack, PropertyType.DETONATE_SOUND), 1f, 1);
/*if(living instanceof EntityPlayer && cap.stickybombKilled>=3)
((EntityPlayer)living).addStat(TF2Achievements.PIPEBAGGER);
if(living instanceof EntityPlayer && cap.engineerKilled && cap.dispenserKilled && cap.sentryKilled)
((EntityPlayer)living).addStat(TF2Achievements.ARGYLE_SAP);*/
}
}
return false;
}
示例10: damageShield
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
void damageShield(EntityLivingBase attacked, EntityLivingBase attacker, float f)
{
ItemStack shield = null;
if(Prep1_11.isValid(attacked.getHeldItemOffhand()) && attacked.getHeldItemOffhand().getItem() == RegisterItems.wickerShield)
shield = attacked.getHeldItemOffhand();
else if(Prep1_11.isValid(attacked.getHeldItemMainhand()) && attacked.getHeldItemMainhand().getItem() == RegisterItems.wickerShield)
shield = attacked.getHeldItemMainhand();
//Copied from EntityPlayer#damageShield() START
if(Prep1_11.isEmpty(shield)) return;
shield.damageItem(1 + MathHelper.floor(f), attacker);
if (shield.getCount() <= 0)
{
EnumHand enumhand = attacked.getActiveHand();
if(attacked instanceof EntityPlayer) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem((EntityPlayer) attacked, attacked.getActiveItemStack(), enumhand);
if (enumhand == EnumHand.MAIN_HAND)
{
attacked.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
}
else
{
attacked.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY);
}
attacked.resetActiveHand();
attacked.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + attacked.world.rand.nextFloat() * 0.4F);
}
//Copied from EntityPlayer#damageShield() END
}
示例11: onItemUseFinish
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
* the Item before the action is complete.
*/
@Nullable
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
ItemStack itemstack = super.onItemUseFinish(stack, worldIn, entityLiving);
if (!worldIn.isRemote)
{
double d0 = entityLiving.posX;
double d1 = entityLiving.posY;
double d2 = entityLiving.posZ;
for (int i = 0; i < 16; ++i)
{
double d3 = entityLiving.posX + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
double d4 = MathHelper.clamp_double(entityLiving.posY + (double)(entityLiving.getRNG().nextInt(16) - 8), 0.0D, (double)(worldIn.getActualHeight() - 1));
double d5 = entityLiving.posZ + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
if (entityLiving.isRiding())
{
entityLiving.dismountRidingEntity();
}
if (entityLiving.attemptTeleport(d3, d4, d5))
{
worldIn.playSound((EntityPlayer)null, d0, d1, d2, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
entityLiving.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
break;
}
}
if (entityLiving instanceof EntityPlayer)
{
((EntityPlayer)entityLiving).getCooldownTracker().setCooldown(this, 20);
}
}
return itemstack;
}
示例12: onEquipped
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {
player.playSound(SoundEvents.ITEM_ARMOR_EQUIP_IRON, .75F, 1.9f);
}
示例13: onEquipped
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {
player.playSound(SoundEvents.ITEM_ARMOR_EQUIP_CHAIN, .75F, 1.9f);
}
示例14: teleportTo
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
private static boolean teleportTo(EntityLivingBase entity, double xx, double yy, double zz) {
EnderTeleportEvent event = new EnderTeleportEvent(entity, xx, yy, zz, 0);
if (MinecraftForge.EVENT_BUS.post(event))
return false;
double d3 = entity.posX;
double d4 = entity.posY;
double d5 = entity.posZ;
entity.posX = event.targetX;
entity.posY = event.targetY;
entity.posZ = event.targetZ;
boolean flag = false;
int i = MathHelper.floor_double(entity.posX);
int j = MathHelper.floor_double(entity.posY);
int k = MathHelper.floor_double(entity.posZ);
if (entity.worldObj.blockExists(i, j, k)) {
boolean flag1 = false;
while (!flag1 && j > 0) {
Block block = entity.worldObj.getBlock(i, j - 1, k);
if (block.getMaterial().blocksMovement())
flag1 = true;
else {
entity.posY--;
j--;
}
}
if (flag1) {
entity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ);
if (entity.worldObj.getCollidingBoundingBoxes(entity, entity.boundingBox).isEmpty() && !entity.worldObj.isAnyLiquid(entity.boundingBox))
flag = true;
}
}
if (!flag) {
entity.setPosition(d3, d4, d5);
return false;
} else {
short short1 = 128;
for (int l = 0; l < short1; l++) {
double d6 = l / (short1 - 1.0D);
float f = (entity.getRNG().nextFloat() - 0.5F) * 0.2F;
float f1 = (entity.getRNG().nextFloat() - 0.5F) * 0.2F;
float f2 = (entity.getRNG().nextFloat() - 0.5F) * 0.2F;
double d7 = d3 + (entity.posX - d3) * d6 + (entity.getRNG().nextDouble() - 0.5D) * entity.width * 2.0D;
double d8 = d4 + (entity.posY - d4) * d6 + entity.getRNG().nextDouble() * entity.height;
double d9 = d5 + (entity.posZ - d5) * d6 + (entity.getRNG().nextDouble() - 0.5D) * entity.width * 2.0D;
entity.worldObj.spawnParticle("portal", d7, d8, d9, f, f1, f2);
}
entity.worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F);
entity.playSound("mob.endermen.portal", 1.0F, 1.0F);
return true;
}
}
示例15: onDealDamage
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void onDealDamage(ItemStack stack, EntityLivingBase attacker, Entity target, DamageSource source, float amount) {
if (TF2Attribute.getModifier("Burn Hit", stack, 0, attacker) > 0)
TF2Util.igniteAndAchievement(target, attacker, (int) TF2Attribute.getModifier("Burn Time", stack,
TF2Attribute.getModifier("Burn Hit", stack, 0, attacker), attacker) + 1);
if (target instanceof EntityLivingBase && attacker.hasCapability(TF2weapons.WEAPONS_CAP, null)){
boolean enemy = TF2Util.isEnemy(attacker, (EntityLivingBase) target);
/*if (attacker instanceof EntityPlayerMP && !target.isEntityAlive() &&
if (attacker instanceof EntityPlayerMP && target instanceof EntitySniper && !target.isEntityAlive() &&
&& TF2weapons.isEnemy(attacker, (EntityLivingBase) target)){
*/
float metalhit = TF2Attribute.getModifier("Metal Hit", stack, 0, attacker);
if (metalhit != 0) {
int restore=(int) (amount*metalhit/TF2ConfigVars.damageMultiplier);
if(!enemy && restore > 30)
restore=30;
attacker.getCapability(TF2weapons.WEAPONS_CAP, null).setMetal((int) (attacker.getCapability(TF2weapons.WEAPONS_CAP, null).getMetal()+restore));
}
if (!target.isEntityAlive() && !(target instanceof EntityBuilding)
&& TF2Attribute.getModifier("Kill Count", stack, 0, attacker)!=0){
stack.getTagCompound().setInteger("Heads", stack.getTagCompound().getInteger("Heads")+1);
}
float healthHit=TF2Attribute.getModifier("Health Hit", stack, 0, attacker);
if (healthHit > 0)
attacker.heal(enemy ? healthHit : healthHit/2f);
float bleed=TF2Attribute.getModifier("Bleed", stack, 0, attacker);
if (bleed > 0) {
((EntityLivingBase) target).addPotionEffect(new PotionEffect(TF2weapons.bleeding,(int) (bleed*20f)+10,0));
}
int rage = (int) TF2Attribute.getModifier("Knockback Rage", stack, 0, attacker);
if (enemy && !WeaponsCapability.get(attacker).knockbackActive && rage > 0) {
WeaponsCapability.get(attacker).setKnockbackRage(Math.min(1, WeaponsCapability.get(attacker).getKnockbackRage()+amount*(0.025f+rage*0.017f)));
}
if (enemy && TF2Attribute.getModifier("Uber Hit", stack, 0, attacker) > 0)
if (attacker instanceof EntityPlayer)
for (ItemStack medigun : ((EntityPlayer) attacker).inventory.mainInventory)
if (medigun != null && medigun.getItem() instanceof ItemMedigun) {
medigun.getTagCompound().setFloat("ubercharge",
MathHelper.clamp(
medigun.getTagCompound().getFloat("ubercharge")
+ TF2Attribute.getModifier("Uber Hit", stack, 0, attacker) / 100,
0, 1));
if (stack.getTagCompound().getFloat("ubercharge") >= 1)
attacker.playSound(ItemFromData.getSound(stack, PropertyType.CHARGED_SOUND), 1.2f, 1);
break;
}
if (TF2Attribute.getModifier("Fire Rate Hit", stack, 1, attacker) != 1) {
//System.out.println(this.getFiringSpeed(stack, attacker) * (1-(1/TF2Attribute.getModifier("Fire Rate Hit", stack, 1, attacker))));
attacker.getCapability(TF2weapons.WEAPONS_CAP, null).fire1Cool-= this.getFiringSpeed(stack, attacker) * (1-(1/TF2Attribute.getModifier("Fire Rate Hit", stack, 1, attacker)));
if(attacker instanceof EntityPlayerMP)
TF2weapons.network.sendTo(new TF2Message.ActionMessage(27,attacker), (EntityPlayerMP) attacker);
}
}
}