1

Urget help needed

JimboPanda123's Avatar JimboPanda1235/30/15 11:09 am
1 emeralds 345 1
5/30/2015 6:17 pm
FiskFille's Avatar FiskFille
Hi,
I am working on a sword using eclispe and i wanted it to shoot a fireball when right clicked. Here is my code

public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (!world.isRemote) {
Vec3 v3 = player.getLook(1);
EntityFireball fireball = new EntityFireball(world, player.posX, player.posY + player.eyeHeight, player.posZ, v3.xCoord, v3.yCoord, v3.zCoord);
fireball.shootingEntity = player;
world.playSoundAtEntity(player, "mob.ghast.fireball", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
world.spawnEntityInWorld(fireball);


The problem is that EntityFireball fireball = new EntityFireball the "new EntityFireball" comes with an error saying "cannot instantiate the type EntityFireball"
and my minecraft crashes when i run it.

Please can some on help!!!

Thanks
Posted by JimboPanda123's Avatar
JimboPanda123
Level 41 : Master Enderdragon
21

Create an account or sign in to comment.

1

1
05/30/2015 6:17 pm
Level 96 : Overlord Fish
FiskFille
FiskFille's Avatar
EntityFireball is an abstract class, and therefor cannot be instantiated. Abstract classes are generally used to be extended by other classes.
In this case, the what you really want is EntitySmallFireball or EntityLargeFireball. They both extend EntityFireball and can be instantiated.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome