Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi!

 

Question in title. And...

I can do this without using ASM?

Do you mean to do something whenever a mob drops experience?

 

You can use LivingDropsEvent or PlayerPickupXpEvent. I'm not exactly sure what you want to do, but these seem like a good place to start.

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

  • Author

Do you mean to do something whenever a mob drops experience?

 

You can use LivingDropsEvent or PlayerPickupXpEvent. I'm not exactly sure what you want to do, but these seem like a good place to start.

 

Nope, but thanks. I wanna remove experience orbs if it will drop, for example from creeper. But mobs drops orbs with this stupid metod:

    protected void onDeathUpdate()
    {
        ++this.deathTime;

        if (this.deathTime == 20)
        {
            int i;

            if (!this.worldObj.isRemote && (this.recentlyHit > 0 || this.isPlayer()) && !this.isChild() && this.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot"))
            {
                i = this.getExperiencePoints(this.attackingPlayer);

                // !
                while (i > 0)
                {
                    int j = EntityXPOrb.getXPSplit(i);
                    i -= j;
                    this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
                }
            }

            this.setDead();

            for (i = 0; i < 20; ++i)
            {
                double d0 = this.rand.nextGaussian() * 0.02D;
                double d1 = this.rand.nextGaussian() * 0.02D;
                double d2 = this.rand.nextGaussian() * 0.02D;
                this.worldObj.spawnParticle("explode", this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, d0, d1, d2);
            }
        }
    }

Since Experience Orbs are entities I'd assume they're still spawned, so you can mess around with things like LivingSpawnEvent.CheckSpawn or LivingSpawnEvent.SpecialSpawn.

 

Maybe even the EntityConstructingEvent.

 

Another option might be to subscribe to LivingDeathEvent, and then make it die in a way that you define, that might work.

 

The last resort I can think of right now is that if none of the above work, you can try using the spawn events to make every creeper spawned actually spawn an instance of your own creeper class that extends EntityCreeper or whatever its called, and then override that method there. This would probably be a bad idea though, as it can mess with compatibility with other mods.

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

  • Author

Since Experience Orbs are entities I'd assume they're still spawned, so you can mess around with things like LivingSpawnEvent.CheckSpawn or LivingSpawnEvent.SpecialSpawn.

 

Maybe even the EntityConstructingEvent.

 

Another option might be to subscribe to LivingDeathEvent, and then make it die in a way that you define, that might work.

 

If I understand correctly, these methods do not give 100% accurate.

 

The last resort I can think of right now is that if none of the above work, you can try using the spawn events to make every creeper spawned actually spawn an instance of your own creeper class that extends EntityCreeper or whatever its called, and then override that method there. This would probably be a bad idea though, as it can mess with compatibility with other mods.

This method may not be compatible with other mods. I create some constructor for change drops of mobs. It must works with all mobs.

 

Maybe I should read about ASM-lib and somehow insert custom xp-drop event in the method OnDathUpdate?

  • Author

You could create your own event and make a PR on the official github.

I'll try in the near future.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.