I have this block, and when certain conditions are met and you right click it, the tool the mod adds gets enchanted. But, for added effect, I would like to know if there is a method to make lightening strike where the block is. Any ideas?
Rollback Post to RevisionRollBack
When life gives you a potato, wonder why the heck life just gave you a potato. Why not something else? Like money? Or a combustable lemon? No, you get a potato. Nothing else.
Lightning is an entity, and it can be placed just like an entity. Most of the time I hate to just give away the answers, so take a look at EntityEgg and try to figure out how it places a chicken in the world. You can ignore the line about growth since lightning doesn't age, but if you look at EntityLightningBolt you'll see that lightning can be placed almost exactly the same way. All you need is the world variable, and the xyz coordinates you want it to strike. Luckily, onBlockActivated provides you with all of those. It shouldn't be very difficult from here for you to call down lightning. Just be aware that lightning damages everything within a certain radius and not just that exact spot.
Lightning is an entity, and it can be placed just like an entity. Most of the time I hate to just give away the answers, so take a look at EntityEgg and try to figure out how it places a chicken in the world. You can ignore the line about growth since lightning doesn't age, but if you look at EntityLightningBolt you'll see that lightning can be placed almost exactly the same way. All you need is the world variable, and the xyz coordinates you want it to strike. Luckily, onBlockActivated provides you with all of those. It shouldn't be very difficult from here for you to call down lightning. Just be aware that lightning damages everything within a certain radius and not just that exact spot.
I tried, could you maybe tell me where I went wrong?
This is my block code (there's a lot of it, sorry)
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
try {
par5EntityPlayer.extinguish();
ItemStack var1 = par5EntityPlayer.inventory.getCurrentItem();
Item var2 = par5EntityPlayer.getCurrentEquippedItem().getItem();
int var3 = par5EntityPlayer.getHealth();
float var4 = par5EntityPlayer.getTotalArmorValue();
boolean var5 = par5EntityPlayer.isSneaking();
boolean var6 = par5EntityPlayer.isInWater();
boolean var7 = par5EntityPlayer.isBurning();
boolean var8 = par5EntityPlayer.isEntityAlive();
boolean var9 = var1.isItemDamaged();
boolean var10 = par5EntityPlayer.isAirBorne;
if (var1 != null) {
if (var2 == PowerMod.Key) {
this.mc.displayGuiScreen(new GuiPowerMod());
return true;
}
// Called when/if the player has at least 5 health, 5 armor
// (status), is sneaking, is in water, is not on fire (sic),
// (for fun) is alive, the item in question is not damaged, and
// makes sure they're not airborne.
if (!var1.isItemEnchanted() && var3 >= 10 && var4 >= 5
&& var5 == true && var6 == true && var7 == false
&& var8 == true && var9 == false && var10 == false) {
EntityLightningBolt var11 = new EntityLightningBolt(par1World, par2, par4, par6);
if (var2 == PowerMod.PowerSword) {
var1.addEnchantment(Enchantment.baneOfArthropods, 4);
var1.addEnchantment(Enchantment.fireAspect, 4);
var1.addEnchantment(Enchantment.sharpness, 4);
var1.addEnchantment(Enchantment.knockback, 4);
var1.addEnchantment(Enchantment.looting, 4);
IOHelper.print("You discovered the secret!");
var11.setLocationAndAngles(par2, par4, par6, 0.0F, 0.0F);
theWorld.spawnEntityInWorld(var11);
var1.damageItem(70, EntityLiving);
} else if (var2 == PowerMod.PowerHelmet) {
var1.addEnchantment(Enchantment.aquaAffinity, 3);
var1.damageItem(20, EntityLiving);
} else if (var2 == PowerMod.PowerBody) {
var1.addEnchantment(Enchantment.projectileProtection, 3);
var1.addEnchantment(Enchantment.aquaAffinity, 3);
var1.addEnchantment(Enchantment.blastProtection, 3);
var1.damageItem(25, EntityLiving);
} else if (var2 == PowerMod.PowerLegs) {
var1.addEnchantment(Enchantment.fireProtection, 4);
var1.damageItem(25, EntityLiving);
} else if (var2 == PowerMod.PowerBoots) {
var1.addEnchantment(Enchantment.featherFalling, 4);
var1.damageItem(30, EntityLiving);
} else if (var2 == PowerMod.PowerSpade) {
var1.addEnchantment(Enchantment.unbreaking, 4);
var1.damageItem(20, EntityLiving);
} else if (var2 == PowerMod.PowerAxe) {
var1.addEnchantment(Enchantment.efficiency, 3);
var1.damageItem(20, EntityLiving);
} else if (var2 == PowerMod.PowerPick) {
var1.addEnchantment(Enchantment.unbreaking, 3);
var1.damageItem(80, EntityLiving);
} else if (var2 == PowerMod.IronStick) {
IOHelper.print("Getting there...");
} else if (var2 == PowerMod.PowerFuel) {
IOHelper.print("Getting there...");
} else if (var2 == PowerMod.Paxel) {
var1.addEnchantment(Enchantment.baneOfArthropods, 4);
var1.addEnchantment(Enchantment.fireAspect, 4);
var1.addEnchantment(Enchantment.sharpness, 4);
var1.addEnchantment(Enchantment.knockback, 4);
var1.addEnchantment(Enchantment.looting, 4);
var1.addEnchantment(Enchantment.efficiency, 4);
var1.addEnchantment(Enchantment.silkTouch, 1);
var1.addEnchantment(Enchantment.unbreaking, 4);
var1.damageItem(80, EntityLiving);
} else {
return false;
}
}
}
} catch (NullPointerException e) {
IOHelper.print("Caught exception from BlockPowerBlock. This is normal.");
}
return false;
}
When life gives you a potato, wonder why the heck life just gave you a potato. Why not something else? Like money? Or a combustable lemon? No, you get a potato. Nothing else.
Error messages would be nice if you have any. Overall it looks pretty good. The two things that jump to mind are 1) Is it getting to the part of the if-statement where it should be adding the entity to the world? And 2) You use theWorld.spawnEntityInWorld, but at the top of your function I only see one World variable and it's called "par1World" instead of "theWorld".
I tried, could you maybe tell me where I went wrong?
This is my block code (there's a lot of it, sorry)
like is there a command eg "Lightning 56 -76 -783 " ???
Coding or mods
And there is something called Minecraft Wiki
YOU CRAZIES
how do you make the little thing @ the bottom of ur comment?
<html>
<img src="file:///C:/Users/Gwynnie/Desktop/Media/bannerfans_13392727.png">
</html>