Posted January 18, 201510 yr comment_138421 I am attempting to make a item that when right clicked will shoot lightning bolts. However I have tried everything and cannot get lightning bolts to spawn. Does anyone have any idea of how I could do this? Here is the items class: package com.mineturnedmod.mineturned.items; import com.mineturnedmod.mineturned.EntityBolt; import com.mineturnedmod.mineturned.EntityRpg; import com.mineturnedmod.mineturned.Mineturnedmain; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntitySnowball; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class MjolnirClass extends Item { public MjolnirClass() { super(); setMaxStackSize(1).setFull3D(); } @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,EntityPlayer par3EntityPlayer) { if(par3EntityPlayer.capabilities.isCreativeMode||par3EntityPlayer.inventory.consumeInventoryItem(Mineturnedmain.RpgAmmo)) { par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) { par2World.spawnEntityInWorld(new EntityLightningBolt(par2World, maxDamage, maxDamage, maxDamage)); } } return par1ItemStack; } @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister reg){ this.itemIcon = reg.registerIcon("morecraftingmod:iron_sword_"); } } The problem is on the line spawn in world. The maxDamage is the default constructor that it tells me to put there but it doesn't spawn the lightning bolt.
January 18, 201510 yr comment_138423 Uhm, im pretty damn sure the maxDamage parameters are the x, y, z coords How else would minecraft know where to spawn it?
January 18, 201510 yr comment_138439 Why are you trying to spawn the entity at (maxDamage, maxDamage, maxDamage)? All three instance of "maxDamage" should be replaced with the x, y, and z coordinates respectively. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
January 18, 201510 yr comment_138471 Just like you put maxDamage, maxDamage, maxDamage, I suggest you learn Java, learn Java, learn Java. Maker of the Craft++ mod.
January 18, 201510 yr Author comment_138476 I want it to go horizontally to the block the player is facing.
January 19, 201510 yr Author comment_138516 Okay then How can I make it hit the block the player is facing vertically.
January 19, 201510 yr comment_138533 You mean where the player is looking at / the cross-hair is pointed to? Players may not always face vertically. You can try using MovingObjectPosition mop = Minecraft.getMinecraft().renderViewEntity.rayTrace(200, 1.0F); It may help, considering you know how to extract data from the variable 'mop'.
January 19, 201510 yr comment_138611 What, we can get the block the player is looking at at the server without packages? I am pretty sure that i used some really complicated algorithm to archive this using the players head rotation. DAMN! (Cause I didn't want to add packages just for this one function.) You put the x y z values by using EntityLightningBolt(par2World, z, y, x). (yeah, its definitely zyx, not xyz ) Here could be your advertisement!
January 19, 201510 yr comment_138626 Can't believe i really wrote packages... Here could be your advertisement!
January 19, 201510 yr Author comment_138656 it says z, y, x cannot be resolved as variables. and btw where do I put MovingObjectPosition mop = Minecraft.getMinecraft().renderViewEntity.rayTrace(200, 1.0F);?
January 19, 201510 yr Author comment_138658 Just out of curiosity how long would it take to learn the basic java stuff?
January 19, 201510 yr comment_138659 It doesn't matter, and it depends on willingness to learn and effort. Maker of the Craft++ mod.
January 19, 201510 yr Author comment_138660 I don't want to spend a lot of time learning java as I only would be using it for this and maybe moding other games.
January 20, 201510 yr comment_138664 Too bad, if you want to make a mod for Minecraft you will have to learn Java, because MINECRAFT IS BUILT IN JAVA. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
January 20, 201510 yr Author comment_138746 Any one have a link to a video tutorial for the basic Java stuff?
January 21, 201510 yr comment_138967 I suggest you just use onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) wich gives u the x,y,z coords off the block clicked. note this will not work for clicking on air water and lava
January 21, 201510 yr comment_138986 I wanted to do the same as you. Diesieben07 helped me and i figured out how to make them spawn. Basically i used getMovingObjectPositionFromPlayer(...) that i copied in the class of my item, rename into getDistanceFromPlayer(...) and modified a bit in order to be able to adjust the distance the player can right-click (as diesieben07 suggested) and not the rayTrace(...) which is only client side. Then i test if the world is remote and if not i spawn the lightning. You can have a look at the solution i used at the end of this topic : http://www.minecraftforge.net/forum/index.php/topic,27030.0.html Hope it helps PS : i also think that you should learn Java before trying to create your mod. It will be easier to understand how everything work
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.