Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I am having trouble spawning lightning bolts. There is thunder, but I cant seem to see the lightning bolt.

Any solutions?

 

I am new btw.

  • Author

package mod;

 

import net.minecraft.client.Minecraft;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.effect.EntityLightningBolt;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.item.ItemSword;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.BlockPos;

import net.minecraft.util.ChatComponentText;

import net.minecraft.util.EnumFacing;

import net.minecraft.util.MathHelper;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.util.MovingObjectPosition.MovingObjectType;

import net.minecraft.util.Vec3;

import net.minecraft.world.World;

 

 

 

public class ZeusLightningBolt extends Item {

 

 

 

 

 

public ZeusLightningBolt(ToolMaterial material) {

super();

 

 

}

 

 

public ItemStack onItemRightClick(ItemStack Itemstack, World world, EntityPlayer Entityplayer)

{

 

if(Entityplayer.capabilities.isCreativeMode || Entityplayer.inventory.consumeInventoryItem(Items.redstone)) 

world.playSoundAtEntity(Entityplayer, "ambient.weather.thunder", 20.0F, 40.0F / (itemRand.nextFloat() * 20.0F + 40.0F));

 

 

world.playSoundAtEntity(Entityplayer, "random.explode", 20.0F, 40.0F / (itemRand.nextFloat() * 20.0F + 40.0F));

 

double x = 0;

double y = 0;

double z = 0;

world.spawnEntityInWorld(new EntityLightningBolt(world, x, y, z));

return Itemstack;

 

}

}

it keeps telling me to set posX as a variable. I cant seem to get around that.

Learn Java and how minecraft works. Please.

The lightning has to be somewhere so the coordinates are necessary.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

1. use code tags

2. so. you are triing to spawn a lightning at the position 0,0,0 .. what are you expecting

 

Also, minecraft 1.8 uses

World#addWeatherEffect

not

World#spawnEntityInWorld

to spawn a lightning bolt.

CommandSummon

gives an example of how to summon lightnings.

Author of Tao Land Mod.

width=200 height=69http://taoland.herbix.me/images/1/14/TaoLandLogo.png[/img]

Also, author of RenderTo

----

I'm not an English native speaker. I just try my best.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.