-
Posts
28 -
Joined
-
Last visited
Everything posted by Plgue
-
Playing a sound event when player is in range of an entity
Plgue replied to Plgue's topic in Modder Support
Did this and it's still not working -
Playing a sound event when player is in range of an entity
Plgue replied to Plgue's topic in Modder Support
Sorry for the late response, but yeah it's being executed -
Playing a sound event when player is in range of an entity
Plgue replied to Plgue's topic in Modder Support
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
Plgue replied to Plgue's topic in Modder Support
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
Plgue replied to Plgue's topic in Modder Support
So in this case I should be using "World.playsound" ? -
Playing a sound event when player is in range of an entity
Plgue replied to Plgue's topic in Modder Support
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
Plgue replied to Plgue's topic in Modder Support
The priority was just me messing around -
Playing a sound event when player is in range of an entity
Plgue replied to Plgue's topic in Modder Support
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
Plgue replied to Plgue's topic in Modder Support
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
Plgue replied to Plgue's topic in Modder Support
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
Plgue replied to Plgue's topic in Modder Support
Still not the issue -
Playing a sound event when player is in range of an entity
Plgue replied to Plgue's topic in Modder Support
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
Plgue replied to Plgue's topic in Modder Support
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) { } } -
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; } }
-
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.
-
Yeah, the other events in the same class are getting called, and it's not a stupid question, as that could have been the problem.
-
By no means am I trying to disrespect, but that's really not the problem, I've tried on player right click event, without checking what item they were holding, and it still did not work
-
Still not working
-
I'll try, I will update on progress also I posted my outdated code, this is my newer code @SubscribeEvent public void onPlayerTick(PlayerTickEvent event) { EntityPlayer p = event.player; if(p.getHeldItem(EnumHand.MAIN_HAND).equals(new ItemStack(ModItems.DransFeather))); { p.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(5.0); //p.capabilities.setPlayerWalkSpeed(2); } }
-
This is what I have @SubscribeEvent public void onPlayerTick(PlayerTickEvent event) { EntityPlayer p = event.player; if(p.getHeldItem(EnumHand.MAIN_HAND).equals(ModItems.DransFeather)); { //p.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(5.0); p.capabilities.setPlayerWalkSpeed(2); } } The other methods in my events class work, just not this one, I've also tried this without the if statement. Edit: The "p.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(5.0);" is the other thing I tried
-
I'm struggling on changing player speed, I've used attributes and capabilities, but neither work.