forum Forumsplay_arrow Minecraft fiber_manual_record Mods

1

Smoke Effect?

1 emerald10 replies591 views
created 12/31/2013 1:27 am by charlieepperly
last reply 01/01/2014 11:10 am
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 avatar
charlieepperly
Level 1 : New Warrior
3

10 replies

1
01/01/2014 2:23 am
Level 36 : Artisan Programmer
deadrecon98
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 68 : High Grandmaster Modder
coolAlias
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
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 68 : High Grandmaster Modder
coolAlias
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
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 68 : High Grandmaster Modder
coolAlias
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 5 : Apprentice Artist
Gear-Beast
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
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 68 : High Grandmaster Modder
coolAlias
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 30 : Artisan Geek
Z645
avatar
Nvm.

Planet Minecraft

Browse

Site

© 2010 - 2019
planetminecraft.com

Welcome