Jump to content

Recommended Posts

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?

 

Posted

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?

Posted

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...
Posted
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

 

 

Posted
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.

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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