Jump to content

Recommended Posts

Posted (edited)

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 by SparkyFox95
Posted (edited)

POST CRASH LOG

 

EDIT: Nevermind

 

Edited 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.

Posted (edited)
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 by SparkyFox95
Posted (edited)

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 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.