Ghast's Fireball Weapon [SOLVED]

Modding , share your ideas for a mod, link to your mod, this is a forum devoted to those who want to mod , offer mods or learn to mod Minecraft!

Moderator: Moderators

Master Bounty Hunter
User avatar
Posts: 1650
Joined: Fri Dec 18, 2009 8:02 am
Location: ¿uoıʇɐɔoן ʎɯ sıɥʇ sı
Projects :: CTF Arenas
Games I'm Playing :: Steam- cressalbane2

Ghast's Fireball Weapon [SOLVED]

Postby CressAlbane » Mon Jun 06, 2011 7:00 am

I'm trying to add a weapon that shoots Ghast Fireballs to the game. Here's the line I'm having trouble with:
world.entityJoinedWorld(new EntitySpell(world, entityplayer, d, d1, d2));
I know that these three arguments (d, d1, d2) determine where the fireball goes after it shoots, but how can I get the player's direction?
Everything else about the weapon is set up properly.

EDIT: solved, see last post
Last edited by CressAlbane on Tue Dec 13, 2011 8:03 pm, edited 1 time in total.

Sergeant Major
User avatar
Posts: 243
Joined: Fri Oct 15, 2010 7:15 pm
Location: Ohio, USA
Projects :: Tython-Siege of Darkness Zombie Hotel
Games I'm Playing :: SWBF 1+2

Re: Ghast's Fireball Weapon

Postby bamdur123 » Mon Jun 06, 2011 7:21 pm

Is it not compiling? or just undesired results

Master Bounty Hunter
User avatar
Posts: 1650
Joined: Fri Dec 18, 2009 8:02 am
Location: ¿uoıʇɐɔoן ʎɯ sıɥʇ sı
Projects :: CTF Arenas
Games I'm Playing :: Steam- cressalbane2

Re: Ghast's Fireball Weapon

Postby CressAlbane » Tue Jun 07, 2011 1:36 pm

Undesired results. Everything else about the weapon is set up properly.

Sergeant Major
User avatar
Posts: 243
Joined: Fri Oct 15, 2010 7:15 pm
Location: Ohio, USA
Projects :: Tython-Siege of Darkness Zombie Hotel
Games I'm Playing :: SWBF 1+2

Re: Ghast's Fireball Weapon

Postby bamdur123 » Wed Jun 08, 2011 8:44 pm

not sure if i canhelp you without your source

Master Bounty Hunter
User avatar
Posts: 1650
Joined: Fri Dec 18, 2009 8:02 am
Location: ¿uoıʇɐɔoן ʎɯ sıɥʇ sı
Projects :: CTF Arenas
Games I'm Playing :: Steam- cressalbane2

Re: Ghast's Fireball Weapon

Postby CressAlbane » Wed Jun 08, 2011 8:52 pm

Code: Select all
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode

package net.minecraft.src;

import java.util.Random;

// Referenced classes of package net.minecraft.src:
//            Item, World, EntityPlayer, InventoryPlayer,
//            EntityArrow, ItemStack

public class ItemFlamer extends Item
{

    public ItemFlamer(int i)
    {
        super(i);
        maxStackSize = 1;
    }

    public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
    {
                    world.playSoundAtEntity(entityplayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 0.8F));
            if(!world.multiplayerWorld)
            {
                world.entityJoinedWorld(new EntityFireball(world, entityplayer, d, d1, d2));
            }
                return itemstack;
    }
}

Here is the line I'm having trouble with:
Code: Select all
world.entityJoinedWorld(new EntityFireball(world, entityplayer, d, d1, d2));
           

I need to know what will go in the d, d1, and d2 arguments for the player's direction.
Hidden/Spoiler:
NOTE: This is not exactly what I have but the same basics; I added some other junk in the original ItemFlamer.java so just used an edited ItemBow.java(like I did to start with)
I have tried messing around with the class for EntityFireball and making one without the three d arguments, but that made a fireball that doesn't move.

Sergeant Major
User avatar
Posts: 243
Joined: Fri Oct 15, 2010 7:15 pm
Location: Ohio, USA
Projects :: Tython-Siege of Darkness Zombie Hotel
Games I'm Playing :: SWBF 1+2

Re: Ghast's Fireball Weapon

Postby bamdur123 » Thu Jun 09, 2011 5:13 am

i think they are variables that need to be defined, iw ould try that, if it doesnt work i suggest taking a look at the entityfireball.java

Code: Select all
 public EntityFireball(World world, EntityLiving entityliving, double d, double d1, double d2)
    {
        super(world);
        field_9402_e = -1;
        field_9401_f = -1;
        field_9400_g = -1;
        field_9399_h = 0;
        field_9398_i = false;
        field_9406_a = 0;
        field_9395_l = 0;
        field_9397_j = entityliving;
        setSize(1.0F, 1.0F);
        setLocationAndAngles(entityliving.posX, entityliving.posY, entityliving.posZ, entityliving.rotationYaw, entityliving.rotationPitch);
        setPosition(posX, posY, posZ);
        yOffset = 0.0F;
        motionX = motionY = motionZ = 0.0D;
        d += rand.nextGaussian() * 0.40000000000000002D;
        d1 += rand.nextGaussian() * 0.40000000000000002D;
        d2 += rand.nextGaussian() * 0.40000000000000002D;
        double d3 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2);
        field_9405_b = (d / d3) * 0.10000000000000001D;
        field_9404_c = (d1 / d3) * 0.10000000000000001D;
        field_9403_d = (d2 / d3) * 0.10000000000000001D;
    }

Master Bounty Hunter
User avatar
Posts: 1650
Joined: Fri Dec 18, 2009 8:02 am
Location: ¿uoıʇɐɔoן ʎɯ sıɥʇ sı
Projects :: CTF Arenas
Games I'm Playing :: Steam- cressalbane2

Re: Ghast's Fireball Weapon

Postby CressAlbane » Tue Dec 13, 2011 7:58 pm

Hidden/Spoiler:
CressAlbane wrote:I already know that these variables need to be defined. They are the direction of the EntityFireball when it is created. What I need to know ishow the EntityFireball obtains how the ghast is facing, or the variables that tell Miecraft where the player is facing.
For example,calling the EntityFireball with these arguments
Code: Select all
world, entityplayer, 1, 2, 3

created an EntityFireball that always flies in the upper-north direction when fired. I want the fireball to fly in the direction the player is facing.
EDIT: 666 posts!


BUMP: I finally figured out all of this. XD solved
The parameters to passed in with a situation like this come from the variables in the Entity class:
Code: Select all
 public float rotationYaw;
    public float rotationPitch;
    public float prevRotationYaw;
    public float prevRotationPitch;
   
also,
Code: Select all
posX, posY, posZ

However, in this particular case you could set up a different method that sets up the Fireball as a child of EntityThrowable. Or, a whole new entity. Or, even modifying the needed parameters and passing them up to the parent class Entity.

Return to Minecraft Modding

Who is online

Users browsing this forum: No registered users and 2 guests