-
Playing a sound event when player is in range of an entity
Did this and it's still not working
-
Playing a sound event when player is in range of an entity
Sorry for the late response, but yeah it's being executed
-
Playing a sound event when player is in range of an entity
Never mind, this is what i'm currently using entity.world.playSound(null, entity.chunkCoordX, entity.chunkCoordY, entity.chunkCoordZ, ModSounds.BATTLE_MUSIC, SoundCategory.MUSIC, 100, 1); But it still does not work
-
Playing a sound event when player is in range of an entity
Again i'm really sorry if I sound like an idiot, but I don't know how to get the sound to play using "World.playsound()" Because I don't know how to get my method non static, I did not set it as static though.
-
Playing a sound event when player is in range of an entity
So in this case I should be using "World.playsound" ?
-
Playing a sound event when player is in range of an entity
But this code should work right? I'm playing a sound from an entity, vanilla Minecraft does the same thing. So I don't know why it does not work.
-
Playing a sound event when player is in range of an entity
The priority was just me messing around
-
Playing a sound event when player is in range of an entity
So after everything I've seen in this thread, this is what I came up with: @SubscribeEvent(priority = EventPriority.HIGHEST) public void playBattleSong(LivingSetAttackTargetEvent event) { EntityLivingBase entity = event.getEntityLiving().getAttackingEntity(); entity.playSound(ModSounds.BATTLE_MUSIC, 75, 1); } It still does not play the sound.
-
Playing a sound event when player is in range of an entity
I do understand it to an extent, but I don't know how I would use it here. And sorry if I sound ignorant or like an idiot, I'm still learning
-
Playing a sound event when player is in range of an entity
Isn't that what i'm doing here? I'm playing the sound to the target.
-
Playing a sound event when player is in range of an entity
Still not the issue
-
Playing a sound event when player is in range of an entity
Also, thanks for this idea! This event does exactly what I need it to do.
-
Playing a sound event when player is in range of an entity
So I updated my code: @SubscribeEvent public void livingSetAttacktargetEvent(LivingSetAttackTargetEvent event) { EntityLivingBase player = event.getTarget(); System.out.println("Set attack target"); if(event.getTarget() == player) { System.out.println("Battle Music Play"); player.playSound(ModSounds.BATTLE_MUSIC, 100, 1); } else { } } It's still a work in progress, but no matter what I do I can't seem to get the event to start my method. The System.out.println's don't even go off, I'm really stumped here. Edit: This is my common proxy, just in case you wanna see it: public class CommonProxy { public void preInit(FMLPreInitializationEvent e) { ModItems.init(); ModItems.register();; ModEntities.init(); } public void init(FMLInitializationEvent e) { MinecraftForge.EVENT_BUS.register(ModSounds.class); MinecraftForge.EVENT_BUS.register(EventHandler.class); } public void postInit(FMLPostInitializationEvent e) { } }
-
Playing a sound event when player is in range of an entity
Title says a lot. Also, the "System.out.println("PlayerTickEvent Working");" does not print every tick. Here's my code: @SubscribeEvent public void entitiesInRadius(PlayerTickEvent event) { EntityPlayer player = event.player; int monsterCount = player.world.getEntitiesWithinAABB(EntityMob.class, new AxisAlignedBB(player.posX - 16, player.posY - 8, player.posZ - 16, player.posX + 16, player.posY + 8, player.posZ + 16)).size(); boolean isplayerinrange = false; System.out.println("PlayerTickEvent Working"); if(monsterCount > 0) { System.out.println("isplayerinrange is true"); isplayerinrange = true; if(isplayerinrange = true) { System.out.println("Battle Music Initiated"); player.playSound(ModSounds.BATTLE_MUSIC, 1, 1); } } else { isplayerinrange = false; } }
-
Can't change player speed
Also would there be a more efficient way of checking if a player is holding an item, without having to check every tick? I feel like having too many "Check every tick" methods would cause lag.
IPS spam blocked by CleanTalk.