Posted June 2, 20196 yr Hello, I've been trying all different approaches to try to get playSound to work in multiplayer. It does play in singleplayer. Anyone know what I am doing wrong? Spoiler Spoiler package com.papavinny.swordfight; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.util.SoundCategory; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; @EventBusSubscriber public class Dodge{ private static int dodgeLength = 0; private static int invulnerablityPeriod = 10; private static boolean wasHolding = false; private static EntityPlayer entity; @SubscribeEvent public static void Dodges(ClientTickEvent event) { entity = Minecraft.getMinecraft().player; // <---- could be the problem? if(Minecraft.getMinecraft().inGameHasFocus && GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSprint)) { if( //Dodge back. GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindBack) && !GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindForward) && !GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindRight) && !GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindLeft) && dodgeLength==0 && !wasHolding ) { Stamina.staminaDeplete(3); dodgeLength = 30; playWoosh(); } if( //TODO: Dodge right. !GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindBack) && !GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindForward) && GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindRight) && !GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindLeft) && dodgeLength==0 && !wasHolding ) { Stamina.staminaDeplete(3); } if( //TODO: Dodge left. !GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindBack) && !GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindForward) && !GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindRight) && GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindLeft) && dodgeLength==0 && !wasHolding ) { Stamina.staminaDeplete(3); } } if(Minecraft.getMinecraft().inGameHasFocus && GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSprint)) { wasHolding = true; }else wasHolding = false; if(dodgeLength > 0) { dodgeLength--; } } public static void playWoosh() { entity.world.playSound(entity,entity.getPosition().getX(), entity.getPosition().getY(), entity.getPosition().getZ(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.MASTER, 10.0f, 1.0f); } } The playSound is in playWoosh, I'm thinking the value of the variable "entity" is causing the problem. Edited June 2, 20196 yr by PapaVinny
June 2, 20196 yr Author 2 minutes ago, diesieben07 said: What even? Why? LOL im dying. I'm new to modding, and somewhat to java. I did that because if I make EntityPlayer = (the player) a field, the game would crash unless the declaration was in the TickEvent I encased what's within the ClientTickEvent in if(event.phase ==Phase.START). When I type KeyBinding.(Anything) I don't get the option for isKeyDown. Guessing it has something to do with that # but even when I type that it's a syntax error, same with the Tickevent#Phase, never seen that before
June 2, 20196 yr Author gotya, is that why the sound is not playing on the server btw? cuz my class isn't instantiated or am I supposed to send playSound to the server ie packets. Think I'm "Reaching across logical sides" from what I read in the forge docs Edited June 2, 20196 yr by PapaVinny
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.