Help with Mincraft modding

View previous topic View next topic Go down

Help with Mincraft modding

Post  BLaZE252 on Mon Jan 09, 2012 12:49 am

I am trying to make a mod for Minecraft (I am new to modding using java) although I am following a tutorial on Youtube the tutorial does not explain what I want to do, I am using the eclipse program and I have made a "wand" and as of now it shoots arrows but I want it to shoot the fire balls that a mob shoots, so I have just copied and pasted the code and I only have one error along with the fire ball image not appearing when I right click.

The warning message is: The method causeFireballDamage(EntityFireball, Entity) in the type DamageSource is not applicable for the arguments (ItemPurpleStoneWand.EntityFireball, EntityLiving)

Here is the code:
The error is underlined below.(or just press Ctrl+F and search causeFireballDamage) Please Help!!

package net.minecraft.src;

import java.util.List;

public class ItemPurpleStoneWand extends Item
{
public ItemPurpleStoneWand(int x)
{
super(x);
maxStackSize = 1;
setMaxDamage(400);
}
public class EntityFireball extends Entity
{

private int xTile;
private int yTile;
private int zTile;
private int inTile;
private boolean inGround;
public EntityLiving shootingEntity;
private int ticksAlive;
private int ticksInAir;
public double accelerationX;
public double accelerationY;
public double accelerationZ;

public EntityFireball(World world)
{
super(world);
xTile = -1;
yTile = -1;
zTile = -1;
inTile = 0;
inGround = false;
ticksInAir = 0;
setSize(1.0F, 1.0F);
}

protected void entityInit()
{
}

public boolean isInRangeToRenderDist(double d)
{
double d1 = boundingBox.getAverageEdgeLength() * 4D;
d1 *= 64D;
return d < d1 * d1;
}

public EntityFireball(World world, double d, double d1, double d2,
double d3, double d4, double d5)
{
super(world);
xTile = -1;
yTile = -1;
zTile = -1;
inTile = 0;
inGround = false;
ticksInAir = 0;
setSize(1.0F, 1.0F);
setLocationAndAngles(d, d1, d2, rotationYaw, rotationPitch);
setPosition(d, d1, d2);
double d6 = MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5);
accelerationX = (d3 / d6) * 0.10000000000000001D;
accelerationY = (d4 / d6) * 0.10000000000000001D;
accelerationZ = (d5 / d6) * 0.10000000000000001D;
}

public EntityFireball(World world, EntityLiving entityliving, double d, double d1, double d2)
{
super(world);
xTile = -1;
yTile = -1;
zTile = -1;
inTile = 0;
inGround = false;
ticksInAir = 0;
shootingEntity = 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);
accelerationX = (d / d3) * 0.10000000000000001D;
accelerationY = (d1 / d3) * 0.10000000000000001D;
accelerationZ = (d2 / d3) * 0.10000000000000001D;
}

public void onUpdate()
{
super.onUpdate();
setFire(1);
if(!worldObj.multiplayerWorld && (shootingEntity == null || shootingEntity.isDead))
{
setEntityDead();
}
if(inGround)
{
int i = worldObj.getBlockId(xTile, yTile, zTile);
if(i != inTile)
{
inGround = false;
motionX *= rand.nextFloat() * 0.2F;
motionY *= rand.nextFloat() * 0.2F;
motionZ *= rand.nextFloat() * 0.2F;
ticksAlive = 0;
ticksInAir = 0;
} else
{
ticksAlive++;
if(ticksAlive == 1200)
{
setEntityDead();
}
return;
}
} else
{
ticksInAir++;
}
Vec3D vec3d = Vec3D.createVector(posX, posY, posZ);
Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
vec3d = Vec3D.createVector(posX, posY, posZ);
vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
if(movingobjectposition != null)
{
vec3d1 = Vec3D.createVector(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double d = 0.0D;
for(int j = 0; j < list.size(); j++)
{
Entity entity1 = (Entity)list.get(j);
if(!entity1.canBeCollidedWith() || entity1.isEntityEqual(shootingEntity) && ticksInAir < 25)
{
continue;
}
float f2 = 0.3F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2);
MovingObjectPosition movingobjectposition1 = axisalignedbb.func_1169_a(vec3d, vec3d1);
if(movingobjectposition1 == null)
{
continue;
}
double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
if(d1 < d || d == 0.0D)
{
entity = entity1;
d = d1;
}
}

if(entity != null)
{
movingobjectposition = new MovingObjectPosition(entity);
}
if(movingobjectposition != null)
{
func_40071_a(movingobjectposition);
}
posX += motionX;
posY += motionY;
posZ += motionZ;
float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
for(rotationPitch = (float)((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) { }
for(; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) { }
for(; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) { }
for(; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) { }
rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
float f1 = 0.95F;
if(isInWater())
{
for(int k = 0; k < 4; k++)
{
float f3 = 0.25F;
worldObj.spawnParticle("bubble", posX - motionX * (double)f3, posY - motionY * (double)f3, posZ - motionZ * (double)f3, motionX, motionY, motionZ);
}

f1 = 0.8F;
}
motionX += accelerationX;
motionY += accelerationY;
motionZ += accelerationZ;
motionX *= f1;
motionY *= f1;
motionZ *= f1;
worldObj.spawnParticle("smoke", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D);
setPosition(posX, posY, posZ);
}

protected void func_40071_a(MovingObjectPosition movingobjectposition)
{
if(!worldObj.multiplayerWorld)
{
if(movingobjectposition.entityHit != null)
{
if(!movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeFireballDamage(this, shootingEntity), 4));
}
worldObj.newExplosion(null, posX, posY, posZ, 1.0F, true);
setEntityDead();
}
}

public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
nbttagcompound.setShort("xTile", (short)xTile);
nbttagcompound.setShort("yTile", (short)yTile);
nbttagcompound.setShort("zTile", (short)zTile);
nbttagcompound.setByte("inTile", (byte)inTile);
nbttagcompound.setByte("inGround", (byte)(inGround ? 1 : 0));
}

public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
xTile = nbttagcompound.getShort("xTile");
yTile = nbttagcompound.getShort("yTile");
zTile = nbttagcompound.getShort("zTile");
inTile = nbttagcompound.getByte("inTile") & 0xff;
inGround = nbttagcompound.getByte("inGround") == 1;
}

public boolean canBeCollidedWith()
{
return true;
}

public float getCollisionBorderSize()
{
return 1.0F;
}

public boolean attackEntityFrom(DamageSource damagesource, int i)
{
setBeenAttacked();
if(damagesource.getEntity() != null)
{
Vec3D vec3d = damagesource.getEntity().getLookVec();
if(vec3d != null)
{
motionX = vec3d.xCoord;
motionY = vec3d.yCoord;
motionZ = vec3d.zCoord;
accelerationX = motionX * 0.10000000000000001D;
accelerationY = motionY * 0.10000000000000001D;
accelerationZ = motionZ * 0.10000000000000001D;
}
if(damagesource.getEntity() instanceof EntityLiving)
{
shootingEntity = (EntityLiving)damagesource.getEntity();
}
return true;
} else
{
return false;
}
}

public float getShadowSize()
{
return 0.0F;
}

public float getEntityBrightness(float f)
{
return 1.0F;
}

public int getEntityBrightnessForRender(float f)
{
return 0xf000f0;
}
}

BLaZE252

Posts : 1
Join date : 2012-01-09

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum