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

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

Ghast's Fireball Weapon [SOLVED]

Post by CressAlbane »

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

Re: Ghast's Fireball Weapon

Post by bamdur123 »

Is it not compiling? or just undesired results
CressAlbane
Master Bounty Hunter
Master Bounty Hunter
Posts: 1519
Joined: Fri Dec 18, 2009 8:02 am
Projects :: CTF Arenas
Games I'm Playing :: Steam- cressalbane2
Location: ¿uoıʇɐɔoן ʎɯ sıɥʇ sı

Re: Ghast's Fireball Weapon

Post by CressAlbane »

Undesired results. Everything else about the weapon is set up properly.
User avatar
bamdur123
Sergeant Major
Sergeant Major
Posts: 243
Joined: Fri Oct 15, 2010 7:15 pm
Projects :: Tython-Siege of Darkness Zombie Hotel
Games I'm Playing :: SWBF 1+2
Location: Ohio, USA

Re: Ghast's Fireball Weapon

Post by bamdur123 »

not sure if i canhelp you without your source
CressAlbane
Master Bounty Hunter
Master Bounty Hunter
Posts: 1519
Joined: Fri Dec 18, 2009 8:02 am
Projects :: CTF Arenas
Games I'm Playing :: Steam- cressalbane2
Location: ¿uoıʇɐɔoן ʎɯ sıɥʇ sı

Re: Ghast's Fireball Weapon

Post by CressAlbane »

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

Re: Ghast's Fireball Weapon

Post by bamdur123 »

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;
    }
CressAlbane
Master Bounty Hunter
Master Bounty Hunter
Posts: 1519
Joined: Fri Dec 18, 2009 8:02 am
Projects :: CTF Arenas
Games I'm Playing :: Steam- cressalbane2
Location: ¿uoıʇɐɔoן ʎɯ sıɥʇ sı

Re: Ghast's Fireball Weapon

Post by CressAlbane »

Hidden/Spoiler:
[quote][quote="CressAlbane"]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]
world, entityplayer, 1, 2, 3[/code]
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![/quote]
[/quote]
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.
Post Reply