RYxINATORx314 Posted November 27, 2014 Posted November 27, 2014 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? Quote
DanPerry1808 Posted November 27, 2014 Posted November 27, 2014 Is this 1.7.10 or 1.8 you're trying to do this in? Quote
RYxINATORx314 Posted November 27, 2014 Author Posted November 27, 2014 1.7.10 and i tried that already, i couldn't get it to work, could you show me some sort of example code? Quote
RYxINATORx314 Posted November 28, 2014 Author Posted November 28, 2014 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); } Quote
starwarsmace Posted November 28, 2014 Posted November 28, 2014 On 11/28/2014 at 2:47 AM, diesieben07 said: 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); } } Quote 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!
hotrods20 Posted November 28, 2014 Posted November 28, 2014 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). Quote http://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 Posted November 28, 2014 Posted November 28, 2014 On 11/28/2014 at 4:15 PM, diesieben07 said: @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); } } Quote 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!
hotrods20 Posted November 28, 2014 Posted November 28, 2014 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. Quote http://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.
Recommended Posts
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.