Posted February 26, 20178 yr in my EntitySMGRounds(Custom arrow) I've been trying to add custom impact sounds, so far the custom sound plays when it hits an entity, but when I try to register the block coline SMGRound hits a block/the ground, the sound spams, and when shooting a mob, the game freezes. would anyone be able to help? http://pastebin.com/JsTz48hV EDIT: updated the pastebin, EntitySMGRounds class is at the bottom Edited February 27, 20178 yr by SparkyFox95
February 26, 20178 yr POST CRASH LOG EDIT: Nevermind Edited February 26, 20178 yr by Leomelonseeds Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.
February 26, 20178 yr Author 1 hour ago, diesieben07 said: Read the stacktrace, it points to a line. Read that line. Then understand what a NullPointerException is and the error is obvious. I already know what variable s missing....and I know I've to call super() in the onHit method, its trying to call the right method I'm looking for that's causing the problem, I tried to explain that at the bottom of the pastebin. Edited February 26, 20178 yr by SparkyFox95
February 27, 20178 yr Author http://pastebin.com/JsTz48hV I managed to get the custom sound to play upon hitting a mob and a block/the ground, but when the SMGRounds hit the ground/block the custom sound spams Edited February 27, 20178 yr by SparkyFox95
February 27, 20178 yr Author In my EntitySMGRounds do I have to have "this.playSound(ModSoundEvent.impact, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));" in a certain line? if I put it after the super(line 86), the sound spams, but if I have it after if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) the sound doesn't play at all (I've updated the pastebin with my entitysmgrounds class) EDIT: Fixed it! I had to protected void onHit(RayTraceResult raytraceResultIn) { super.onHit(raytraceResultIn); this.playSound(ModSoundEvent.impact, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); Entity entity = raytraceResultIn.entityHit; if (entity != null) { float f = MathHelper.sqrt(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); int i = MathHelper.ceil((double)f * this.damage); if (this.getIsCritical()) { i += this.rand.nextInt(i / 2 + 2); } } } I've updated the pastebin again incase anyone wants to use my SMGRounds for any reason Edited February 27, 20178 yr by SparkyFox95
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.