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 basically have an item, that when right clicked summonses a lightning bolt entity. I have been trying a variety of methods but none seem to work. The latest method I used was this:

 

http://pastebin.com/bP4iY1j7 (Used a link as spoilers wouldn't work)

 

What am I doing wrong? Is it the method, a parameter, or am I just messing up?

 

  • Author

Lighting bolts are handled differently from normal entities. Use addWeatherEffect instead of spawnEntity.

 

Ah thanks for your help! :)

  • Author

Sorry to be a bother, but I am still having issues. The problem is, I cannot summon lightning unless it is raining (I checked the code). Is there a way to override this?

float f = 1.0f;

        float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
        float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;

        double d = (double)f;

        double d1 = player.prevPosX + (player.posX - player.prevPosX) * d;
        double d2 = (player.prevPosY + (player.posY - player.prevPosY) * d + 1.6200000000000001d) - (double)player.yOffset;
        double d3 = player.prevPosZ + (player.posZ - player.prevPosZ) * d;

        Vec3 vec1 = Vec3.createVectorHelper(d1, d2, d3);

        float f11 = MathHelper.cos(-f2 * 0.01745329f - 3.141593f);
        float f12 = MathHelper.sin(-f2 * 0.01745329f - 3.141593f);
        float f13 = -MathHelper.cos(-f1 * 0.01745329f);
        float f14 = MathHelper.sin(-f1 * 0.01745329f);

        float f15 = f12 * f13;
        float f16 = f14;
        float f17 = f11 * f13;

        double d11 = 5000d;

        Vec3 vec2 = vec1.addVector((double)f15 * d11, (double)f16 * d11, (double)f17 * d11);

        MovingObjectPosition position = world.func_147447_a(vec1, vec2, false, true, true);

        if(position != null && position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {

            int x = position.blockX;
            int y = position.blockY;
            int z = position.blockZ;

            EntityLightningBolt lightning = new EntityLightningBolt(world, x, y, z);

            world.spawnEntityInWorld(lightning);

        }

 

This is the code I use in my mod and it works just fine

 

world is a World and player is an EntityPlayer

  • 5 years later...
On 7/17/2014 at 9:05 PM, kenoba10 said:

 


float f = 1.0f;

        float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
        float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;

        double d = (double)f;

        double d1 = player.prevPosX + (player.posX - player.prevPosX) * d;
        double d2 = (player.prevPosY + (player.posY - player.prevPosY) * d + 1.6200000000000001d) - (double)player.yOffset;
        double d3 = player.prevPosZ + (player.posZ - player.prevPosZ) * d;

        Vec3 vec1 = Vec3.createVectorHelper(d1, d2, d3);

        float f11 = MathHelper.cos(-f2 * 0.01745329f - 3.141593f);
        float f12 = MathHelper.sin(-f2 * 0.01745329f - 3.141593f);
        float f13 = -MathHelper.cos(-f1 * 0.01745329f);
        float f14 = MathHelper.sin(-f1 * 0.01745329f);

        float f15 = f12 * f13;
        float f16 = f14;
        float f17 = f11 * f13;

        double d11 = 5000d;

        Vec3 vec2 = vec1.addVector((double)f15 * d11, (double)f16 * d11, (double)f17 * d11);

        MovingObjectPosition position = world.func_147447_a(vec1, vec2, false, true, true);

        if(position != null && position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {

            int x = position.blockX;
            int y = position.blockY;
            int z = position.blockZ;

            EntityLightningBolt lightning = new EntityLightningBolt(world, x, y, z);

            world.spawnEntityInWorld(lightning);

        }
 

 

 

I know this is old but I couldn't find any new threads but I was wondering if anyone knows why mine crashes my game it is a java.lang.ExceptionInInitializerError

 

 

19 minutes ago, jgp22805 said:

I know this is old but I couldn't find any new threads but I was wondering if anyone knows why mine crashes my game it is a java.lang.ExceptionInInitializerError

Make a new thread dont necro.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

On 7/17/2014 at 9:05 PM, kenoba10 said:

 


 
 

 

 

thanks for the reply I will do that

 
 

 

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.