Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

How to make an item throw fireballs

fml

  • Please log in to reply
24 replies to this topic

#1

LieAngels

Posted 01 July 2013 - 07:35 AM

how would i make an item be able to throw an unlimited amount of fireballs and not break..

im pretty sure it has "entity throwable' in it..
Posted Image

Register or log in to remove.

#2

ElectricSnap
  • Location: When you look out i stay between two trees!
  • Minecraft: ElectricSnap

Posted 01 July 2013 - 08:21 AM

Copy the class from the snowball and change it to fireball and create your animation

~ ElectricSnap
Push the green arrow if that helps!
\,,/(-_-)\,,/

#3

LieAngels

Posted 01 July 2013 - 10:27 AM

View PostElectricSnap, on 01 July 2013 - 08:21 AM, said:

Copy the class from the snowball and change it to fireball and create your animation

~ ElectricSnap
Ive tried messing around with it..I couldnt get it working..
would you happen to know the exact code on how to do it?
and if you have a yt account, ill like all your vids + sub in return..
Posted Image

#4

Flyverse
    Flyverse

    Stone Miner

  • Curse Premium
  • Curse Premium
  • 92 posts

Posted 01 July 2013 - 10:48 AM

@LieAngels

Just instantiate the fireball entity in your wished "event-method", and let it spawn with the spawnEntityInWOrld method from a world object ;).


#5

Jimmy04creeper
  • Location: london uk

Posted 01 July 2013 - 12:07 PM

i cant remeber if this works as its from 1.5.1 but try it
Spoiler: Shooting fireballs from item


#6

LieAngels

Posted 02 July 2013 - 01:06 AM

View PostJimmy04creeper, on 01 July 2013 - 12:07 PM, said:

i cant remeber if this works as its from 1.5.1 but try it
Spoiler: Shooting fireballs from item
yes! thankyou... it worked.. i just had to play around with where it spawned and things like that.. now i know youve helped alot.. but how would i make it work with enderpearls? any ideas?
Posted Image

#7

Flyverse
    Flyverse

    Stone Miner

  • Curse Premium
  • Curse Premium
  • 92 posts

Posted 02 July 2013 - 08:15 AM

@LieAngels
Changing the EntityLargeFireball to EntityEnderPearl (+ Changing the variables wich were only in the fireball, if you used them)?

#8

SKYSOLDIERnumbersSS

Posted 02 July 2013 - 11:28 AM

how to change it into snowball? I got an error in the underlined words:
Spoiler:


#9

LieAngels

Posted 02 July 2013 - 11:47 AM

View PostFlyverse, on 02 July 2013 - 08:15 AM, said:

@LieAngels
Changing the EntityLargeFireball to EntityEnderPearl (+ Changing the variables wich were only in the fireball, if you used them)?
i made it so it uses enderpearls.. but the enderpearls just drop 1 block ahead of me.. and they dont tp you.. any ideas?
Posted Image

#10

SKYSOLDIERnumbersSS

Posted 02 July 2013 - 11:54 AM

can you try this??
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
if (!world.isRemote)
{
Vec3 look = entityplayer.getLookVec();
EntityEnderPearl fireball2 = new EntityEnderPearl(world, 1, 1, 1);
fireball2.setPosition(
				 entityplayer.posX + look.xCoord * 5,
				 entityplayer.posY + look.yCoord * 5,
				 entityplayer.posZ + look.zCoord * 5);
fireball2.posX = look.xCoord * 0.1;
fireball2.posY = look.yCoord * 0.1;
fireball2.posZ = look.zCoord * 0.1;
world.spawnEntityInWorld(fireball2);
}
return itemstack;
}


#11

LieAngels

Posted 02 July 2013 - 12:15 PM

nope :L
doesnt even seem to throw the enderpearl..
do you want to discuss this on skype for Instant Messages?
Posted Image

#12

SKYSOLDIERnumbersSS

Posted 02 July 2013 - 12:18 PM

Quote

nope :L
doesnt even seem to throw the enderpearl..
do you want to discuss this on skype for Instant Messages?



i have skype... but i have it only in my loptop... im am using pc right now

#13

LieAngels

Posted 02 July 2013 - 12:21 PM

View PostSKYSOLDIERnumbersSS, on 02 July 2013 - 12:18 PM, said:

i have skype... but i have it only in my loptop... im am using pc right now
ohh ok.. so do you have any idea on how you could get this to work?
its stumped me...
Posted Image

#14

SKYSOLDIERnumbersSS

Posted 02 July 2013 - 12:26 PM

maybe... maybe not

do you have facebook??

#15

LieAngels

Posted 02 July 2013 - 12:28 PM

View PostSKYSOLDIERnumbersSS, on 02 July 2013 - 12:26 PM, said:

maybe... maybe not

do you have facebook??
yeah whats yours?
Posted Image

#16

LieAngels

Posted 02 July 2013 - 12:47 PM

View PostSKYSOLDIERnumbersSS, on 02 July 2013 - 12:26 PM, said:

maybe... maybe not

do you have facebook??

ooh ive made the enderpearl throw.. but.. it doesnt tp you.. now we just have to work on that.. :D
Posted Image

#17

Jimmy04creeper
  • Location: london uk

Posted 02 July 2013 - 03:09 PM

View PostLieAngels, on 02 July 2013 - 12:47 PM, said:



ooh ive made the enderpearl throw.. but.. it doesnt tp you.. now we just have to work on that.. :D
If you look in the ender pearl class and look for the method and see how it tp you, maybe it has a pram that says it has to b thrown by a player and not from an item to teleport you ? I'm just guessing as I'm not on my pc though ?

#18

LieAngels

Posted 02 July 2013 - 03:31 PM

@Jimmy04Creeper
uhm it has this..

protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
if (par1MovingObjectPosition.entityHit != null)
{

for (int i = 0; i < 32; ++i)
{
this.worldObj.spawnParticle("portal", this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian());
}

if (!this.worldObj.isRemote)
{
if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.getThrower();

if (!entityplayermp.playerNetServerHandler.connectionClosed && entityplayermp.worldObj == this.worldObj)
{
EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5);
if (!MinecraftForge.EVENT_BUS.post(event)){
this.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ);
this.getThrower().fallDistance = 0.0F;
this.getThrower().attackEntityFrom(DamageSource.fall, event.attackDamage);
}

}
}

but if i import this into my code.. i get a lot of un solvable errors..
Posted Image

#19

Jimmy04creeper
  • Location: london uk

Posted 02 July 2013 - 04:20 PM

View PostLieAngels, on 02 July 2013 - 03:31 PM, said:

@Jimmy04Creeper
uhm it has this..

protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
if (par1MovingObjectPosition.entityHit != null)
{

for (int i = 0; i < 32; ++i)
{
this.worldObj.spawnParticle("portal", this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian());
}

if (!this.worldObj.isRemote)
{
if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.getThrower();

if (!entityplayermp.playerNetServerHandler.connectionClosed && entityplayermp.worldObj == this.worldObj)
{
EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5);
if (!MinecraftForge.EVENT_BUS.post(event)){
this.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ);
this.getThrower().fallDistance = 0.0F;
this.getThrower().attackEntityFrom(DamageSource.fall, event.attackDamage);
}

}
}

but if i import this into my code.. i get a lot of un solvable errors..
can you post the file you trying to use to shot the ender pearl ?

in the item you useing to shot the ender pearl change the method to this below then test it ?
remember that for it to teleport you you have to shot EntityEnderPearl not Item.enderPearl ?
Spoiler: Shoots the ender pearl


#20

LieAngels

Posted 03 July 2013 - 12:05 AM

View PostJimmy04creeper, on 02 July 2013 - 04:20 PM, said:

can you post the file you trying to use to shot the ender pearl ?

in the item you useing to shot the ender pearl change the method to this below then test it ?
remember that for it to teleport you you have to shot EntityEnderPearl not Item.enderPearl ?
Spoiler: Shoots the ender pearl

yeah sure,

package ##.#;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityEnderPearl;
import net.minecraft.entity.item.EntityPainting;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityEgg;
import net.minecraft.entity.projectile.EntityLargeFireball;
import net.minecraft.entity.projectile.EntitySmallFireball;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.entity.projectile.EntityWitherSkull;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;

public class ############# extends Item
{
public #############(int par1)
{
super(par1);
this.setMaxDamage(100);
maxStackSize = 1;
setCreativeTab(####Mod.####);
}

/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
if (!world.isRemote)
{
Vec3 look = entityplayer.getLookVec();
EntityEnderPearl fireball2 = new EntityEnderPearl(world, 1, 2, 1);
fireball2.setPosition(
entityplayer.posX + look.xCoord * 0,
entityplayer.posY + look.yCoord * 1.5,
entityplayer.posZ + look.zCoord * 0);
fireball2.motionX = look.xCoord * 1.0;
fireball2.motionY = look.yCoord * 1.0;
fireball2.motionZ = look.zCoord * 1.0;
world.spawnEntityInWorld(fireball2);
itemstack.damageItem(1, entityplayer);

}
return itemstack;
}
}



Posted Image