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

I want to thank those who help me in advance,

 

so i posted a few days ago except i worded my post oddly and none understood what i was trying to do, i apologize for that, this is what i was trying to say;

 

I want to make particles spawn when you are holding an item, how can i accomplish this?

  • Author

i tried messing around with

 

this.onUpdate();

 

 

 

and...

 

public void onUpdate(World world, double x, double y, double z, double velX, double velY, double velZ) {

 

world.spawnParticle("portal", x + 1, y, z + 1, 1.0D, 1.0D, 1.0D);

   

also...

 

 

public void randomDisplayTick(World world, int x, int y, int z, Random random);

 

    if (random.nextInt(10) == 0)

    {

    world.spawnParticle("portal", (double)((float)x + random.nextFloat()), (double)((float)y + 1.1F), (double)((float)z + random.nextFloat()), 0.0D, 0.0D, 0.0D);

    }

randomDisplayTick is for Blocks. And those are not the parameters that onUpdate takes. Learn how to override a method. You cannot just change the parameters and expect Minecraft to magically call your method with the correct values.

I agree.

 

Are you in eclipse? Because in eclipse it shows that green override symbol.

Here is the correct code.

public void onUpdate(ItemStack p_77663_1_, World world, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) {
	EntityPlayer player=(EntityPlayer) p_77663_3_;
	if(player.getCurrentEquippedItem().getItem().equals(this)){
		 world.spawnParticle("portal", player.posX + 1, player.posY, player.posZ, 1.0D, 1.0D, 1.0D);
	}
}

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

private Random rand = new Random();
    @Override
    public void onUpdate(ItemStack is, World world, Entity ent, int i, boolean bool)
    {
    	if(ent != null && ent instanceof EntityPlayer && bool)
    	{
    		EntityPlayer p = (EntityPlayer)ent;
    			world.spawnParticle("portal", p.posX, p.posY, p.posZ, rand.nextGaussian(), rand.nextGaussian(), rand.nextGaussian());
    	}
    }

This sends all particles to your head.

 

private Random rand = new Random();
    @Override
    public void onUpdate(ItemStack is, World world, Entity ent, int i, boolean bool)
    {
    	if(ent != null && ent instanceof EntityPlayer && bool)
    	{
    		EntityPlayer p = (EntityPlayer)ent;
    			world.spawnParticle("portal", p.posX, p.posY-rand.nextInt(2), p.posZ, rand.nextGaussian(), rand.nextGaussian(), rand.nextGaussian());
    	}
    }

This sends particles to random points on your body(height wise).

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

@starwarsmace:

 

a) Don't rely on it being a player, check with instanceof

b) the "is current item" check is already done for you, it's the boolean parameter.

 

a)Youre right.

b) oh yeah. That make sense.

 

Corrected code

 

public void onUpdate(ItemStack p_77663_1_, World world, Entity entity, int p_77663_4_, boolean flag) {
	if(flag){
		 world.spawnParticle("portal", entity.posX + 1, entity.posY, entity.posZ, 1.0D, 1.0D, 1.0D);
	}
}

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

The problem with doing 1.0D instead of a random double or Gaussian is that the particles will all spawn in one spot and fly into the players head instead spawning around the player and going into random spots.  In basic though, that is fine code to get started.

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

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.