Jump to content

Particle Spawn when Holding item?


RYxINATORx314

Recommended Posts

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);

    }

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.