1

Smoke Effect?

charlieepperly's Avatar charlieepperly12/31/13 1:27 am
1/1/2014 11:10 am
coolAlias's Avatar coolAlias
Hey im making a plugin that when you type /potion it gives you 4 different potions and I would like to know how to add a smoke effect that plays while the potions are still active.
Here is my code:

player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, getConfig().getInt("Time"), 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, getConfig().getInt("Time"), 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, getConfig().getInt("Time"), 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, getConfig().getInt("Time"), 1));
player.getLocation().getWorld().playEffect(player.getLocation(), Effect.SMOKE, 1);


Ask if you need more of the code, Thanks:)
Posted by charlieepperly's Avatar
charlieepperly
Level 1 : New Warrior
3

Create an account or sign in to comment.

10

1
01/01/2014 2:23 am
Level 38 : Artisan Programmer
deadrecon98
deadrecon98's Avatar
charlieepperlyHey im making a plugin that when you type /potion it gives you 4 different potions and I would like to know how to add a smoke effect that plays while the potions are still active.
Here is my code:

player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, getConfig().getInt("Time"), 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, getConfig().getInt("Time"), 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, getConfig().getInt("Time"), 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, getConfig().getInt("Time"), 1));
player.getLocation().getWorld().playEffect(player.getLocation(), Effect.SMOKE, 1);

Ask if you need more of the code, Thanks:)


You would need a ClientTickHandler to do that.
1
12/31/2013 7:46 pm
Level 71 : Legendary Modder
coolAlias
coolAlias's Avatar
That's pretty basic Java. You need to get those variables from somewhere, such as the method paramaters. If there is no World object in the method's parameters, you can get one from any entity using "entity.worldObj"; par2, par3 and par4 are the position at which to spawn the particles, i.e. x/y/z coordinates, and they are doubles so that you can spawn anywhere within a block. par5Random can be gotten from the World object, wherever you got that from, using worldObj.rand.
1
01/01/2014 12:34 am
Level 1 : New Warrior
charlieepperly
charlieepperly's Avatar
I'm sorry but i'm pretty new to Java so how would you make that happen?
1
01/01/2014 12:57 am
Level 71 : Legendary Modder
coolAlias
coolAlias's Avatar
Then I suggest you look up some Java tutorials. They will help you far more than you expect. The New Boston has an excellent and free course on programming / Java. If you follow all of those, you will be able to do so much more than you can now.

Anyway, in your code you have access to the player object, right? That player is a member of the class EntityPlayer, which is a sub-class of Entity, meaning it has a World object you can use. All entities also have position coordinates, called posX, posY, and posZ.

player.posX; // that's a double for the player's position
player.worldObj; // that's the World object
player.worldObj.rand; // there's your Random object

etc. I'm sure you can figure out the rest.
1
01/01/2014 1:20 am
Level 1 : New Warrior
charlieepperly
charlieepperly's Avatar
Thanks for the help, and that New Boston is a great website, normally all the java videos that I have watched don't tell me anything or the peoples voices are just plain boring, but that guy seems to know what he is talking about and his voice is very pleasant for me. Thanks! ohh and one more question once you learned Java did you have to learn something else for the Minecraft part?
1
01/01/2014 11:10 am
Level 71 : Legendary Modder
coolAlias
coolAlias's Avatar
Yes, Minecraft is its own beast ;p Knowing Java is the first step, though, and once you've got a good grasp of the basics it will be much easier to follow along with more advanced tutorials as well as figure stuff out on your own by looking at the vanilla classes (which is what all the advanced tutorials are based on!).

That's really the best advice: look in vanilla code for something that is similar to what you want to do, copy that, and then change it until it's doing what you want. Pretty much everything you could want to do has already been done in vanilla code, and if it hasn't, then you're lucky because you get to code it from scratch! Trust me, when you get better at Java, much of the time you'll prefer doing it from scratch to messing with Minecraft's code.
1
12/31/2013 4:08 am
Level 6 : Apprentice Artist
Gear-Beast
Gear-Beast's Avatar
par1World.spawnParticle("smoke", (double)((float)par2 + par5Random.nextFloat()), (double)((float)par3 + 1.1F), (double)((float)par4 + par5Random.nextFloat()), 0.0D, 0.0D, 0.0D);
would this help at all?
1
12/31/2013 2:16 pm
Level 1 : New Warrior
charlieepperly
charlieepperly's Avatar
Okay could you please help me with this piece of code the par1World, par2, both par5Random, par3, and par4 are all underlined in red saying they can not be resolved, thank you
1
12/31/2013 11:09 am
Level 71 : Legendary Modder
coolAlias
coolAlias's Avatar
As this guy shows, it's totally possible. You can spawn any particle in Minecraft using the above code and the particle name, which can be found on the wiki here.
1
12/31/2013 3:47 am
Level 31 : Artisan Geek
Z645
Z645's Avatar
Nvm.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome