I tried creating my own ItemStaff and used the code from the ItemLightningWand, and here's the errors that came up:
== ERRORS FOUND ==
src/minecraft/net/minecraft/src/ItemStaff.java:21: cannot find symbol
symbol : class Vec3D
location: class net.minecraft.src.ItemStaff
Vec3D vec3d = movingobjectposition.hitVec;
^
src/minecraft/net/minecraft/src/ItemStaff.java:31: cannot find symbol
symbol : method entityJoinedWorld(net.minecraft.src.EntityLightningBolt)
location: class net.minecraft.src.World
world.entityJoinedWorld(entitybolt);
^
Other than that, as long as you typed everything the same, you should have no problems. You don't want to know how long I spent yelling at my computer to get this information.
EDIT: Forgot to add code & /code tags
EDIT2: Removed code tags because colors refuse to work
My arrows are invisible. I dont know what is going on because I have double and tripled checked all the files but still nothing. When I shoot, it takes away one of the arrows and it acts like a real arrow, as in it causes damage to mobs and kills them, but you just cant see it. Any ideas?
If I leave the line:
EntityArrow var8 = new EntityArrow(par2World, par3EntityPlayer, var7 * 2.0F);
as is then my bow shoots an arrow, but if I change it to say:
EntityNewArrow var8 = new EntityNewArrow(par2World, par3EntityPlayer, var7 * 2.0F);
then my arrow disappears in game.
The damage for the bow is calculated inside of the actual arrow entity. I don't know of any easy way to change it because of the way damage is handled.
is it possible for the damage an arrow does automatically change dpending on the bow you're weilding, like some fancy code that tests for the player if holding a certain item variable equals this, i hope you know what i'm getting at, i'm new to this, and i just want to make a custom damage bow, but now i have another idea, have it consume arrows, but shoot out what appears to be an arrow, but a duplicate of the arow entity class and all that, but some of it's tweaked so it does the amount of damage you want it to do. that's two ways i can think of making custom damage bows, it'l just be hard as hell to do.
You would have to change damage type it uses because it currently uses the DamageType 'projectile' which is what makes it do damage based on it's velocity. I think.
so you would have to make a new Damage Type "NAME" for every bow in order to achieve that, unless you can assign ammunition to multiple bows with that new Damage Type, just the same texture as an arrow or an elemental one, but still have it consume arrows? Wow, I can't wait untill summer hits and school's over so I can take a college course on java so I can see how it works and know which files to look for that tell me all the code and variables, that will be nice, but until then I'm just making low end mods like; hostile mutant nether pig zombies that drop stuff, but no custom experience, or making crafting recipes for uncraftable items (probably the most basic), thing is I have to keep learning. ... I'l get there : )
Okay. So for the custom arrow, I tried addRenderer, but it gave me an error, saying that I can't use void with addRenderer. Help?
EDIT: Nevermind, I figured out my problem. It was in the wrong place.
Hey, I'm trying to make a mod. Obviously. I'm not going to give a lot of details, but I have a request.
Can you show how to make headwear? Such as a hat or mask? I tried looking in the armor class to see if it's similar to the helmet, but I can't figure it out. I'm new to Java. I know some basics and am still learning it (rapidly I might add), so maybe I'm making some kind of newb mistake.
Rollback Post to RevisionRollBack
I am nobody. Nobody is perfect, therefore, I am perfect.
It is giving me trouble... I am currently running on 1.3.2 and wherever it has anything to do with "vec" it gives me an error. Here is my code can somebody please help:
EntityFireArrow:
package net.minecraft.src;
import java.util.List;
import java.util.Random;
public class EntityFireArrow extends Entity
{
private int xTile;
private int yTile;
private int zTile;
private int inTile;
private int inData;
private boolean inGround;
public boolean doesArrowBelongToPlayer;
/** Seems to be some sort of timer for animating an arrow. */
public int arrowShake;
/** The owner of this arrow. */
public Entity shootingEntity;
private int ticksInGround;
private int ticksInAir;
private double damage;
private int field_46027_au;
/** Is this arrow a critical hit? (Controls particles and damage) */
public boolean arrowCritical;
if (isBurning())
{
movingobjectposition.entityHit.setFire(5);
}
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, j1))
{
if (movingobjectposition.entityHit instanceof EntityLiving)
{
((EntityLiving)movingobjectposition.entityHit).arrowHitTempCounter++;
if (par1NBTTagCompound.hasKey("damage"))
{
damage = par1NBTTagCompound.getDouble("damage");
}
}
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)
{
if (worldObj.isRemote)
{
return;
}
How do I fix this?
{
EntityPlayer entityplayer = (EntityPlayer)entity;
ItemStack itemstack1 = entityplayer.inventory.getCurrentItem();
if(entityplayer.isUsingItem() && itemstack1.itemID == mod_AdvancedBows.FireBow.shiftedIndex)
{
int k = itemstack.getMaxItemUseDuration() - entityplayer.func_35205_Y();
if(k >= 48)
{
iconIndex = mod_AdvancedBows.fireBow4;
}else
if(k > 26)
{
iconIndex = mod_AdvancedBows.fireBow3;
}else
if(k > 0)
{
iconIndex = mod_AdvancedBows.fireBow2;
}else
iconIndex = mod_AdvancedBows.fireBow1;
}
}
{
EntityPlayer entityplayer = (EntityPlayer)entity;
ItemStack itemstack1 = entityplayer.inventory.getCurrentItem();
if(entityplayer.isUsingItem() && itemstack1.itemID == mod_AdvancedBows.FireBow.itemID)
{
int k = itemstack.getMaxItemUseDuration() - entityplayer.getItemInUseCount();
if(k >= 48)
{
iconIndex = mod_AdvancedBows.fireBow4;
}else
if(k > 26)
{
iconIndex = mod_AdvancedBows.fireBow3;
}else
if(k > 0)
{
iconIndex = mod_AdvancedBows.fireBow2;
}else
iconIndex = mod_AdvancedBows.fireBow1;
}
}
Red is outdated
Blue is current
Other than that, as long as you typed everything the same, you should have no problems. You don't want to know how long I spent yelling at my computer to get this information.
EDIT: Forgot to add code & /code tags
EDIT2: Removed code tags because colors refuse to work
Have you found a fix?
is it possible for the damage an arrow does automatically change dpending on the bow you're weilding, like some fancy code that tests for the player if holding a certain item variable equals this, i hope you know what i'm getting at, i'm new to this, and i just want to make a custom damage bow, but now i have another idea, have it consume arrows, but shoot out what appears to be an arrow, but a duplicate of the arow entity class and all that, but some of it's tweaked so it does the amount of damage you want it to do. that's two ways i can think of making custom damage bows, it'l just be hard as hell to do.
EDIT: Nevermind, I figured out my problem. It was in the wrong place.
Can you show how to make headwear? Such as a hat or mask? I tried looking in the armor class to see if it's similar to the helmet, but I can't figure it out. I'm new to Java. I know some basics and am still learning it (rapidly I might add), so maybe I'm making some kind of newb mistake.
It is giving me trouble... I am currently running on 1.3.2 and wherever it has anything to do with "vec" it gives me an error. Here is my code can somebody please help:
package net.minecraft.src;
import java.util.List;
import java.util.Random;
public class EntityFireArrow extends Entity
{
private int xTile;
private int yTile;
private int zTile;
private int inTile;
private int inData;
private boolean inGround;
public boolean doesArrowBelongToPlayer;
/** Seems to be some sort of timer for animating an arrow. */
public int arrowShake;
/** The owner of this arrow. */
public Entity shootingEntity;
private int ticksInGround;
private int ticksInAir;
private double damage;
private int field_46027_au;
/** Is this arrow a critical hit? (Controls particles and damage) */
public boolean arrowCritical;
public EntityFireArrow(World par1World)
{
super(par1World);
xTile = -1;
yTile = -1;
zTile = -1;
inTile = 0;
inData = 0;
inGround = false;
doesArrowBelongToPlayer = false;
arrowShake = 0;
ticksInAir = 0;
damage = 2D;
arrowCritical = false;
setSize(0.5F, 0.5F);
}
public EntityFireArrow(World par1World, double par2, double par4, double par6)
{
super(par1World);
xTile = -1;
yTile = -1;
zTile = -1;
inTile = 0;
inData = 0;
inGround = false;
doesArrowBelongToPlayer = false;
arrowShake = 0;
ticksInAir = 0;
damage = 2D;
arrowCritical = false;
setSize(0.5F, 0.5F);
setPosition(par2, par4, par6);
yOffset = 0.0F;
}
public EntityFireArrow(World par1World, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving, float par4, float par5)
{
super(par1World);
xTile = -1;
yTile = -1;
zTile = -1;
inTile = 0;
inData = 0;
inGround = false;
doesArrowBelongToPlayer = false;
arrowShake = 0;
ticksInAir = 0;
damage = 2D;
arrowCritical = false;
shootingEntity = par2EntityLiving;
doesArrowBelongToPlayer = par2EntityLiving instanceof EntityPlayer;
posY = (par2EntityLiving.posY + (double)par2EntityLiving.getEyeHeight()) - 0.10000000149011612D;
double d = par3EntityLiving.posX - par2EntityLiving.posX;
double d1 = (par3EntityLiving.posY + (double)par3EntityLiving.getEyeHeight()) - 0.69999998807907104D - posY;
double d2 = par3EntityLiving.posZ - par2EntityLiving.posZ;
double d3 = MathHelper.sqrt_double(d * d + d2 * d2);
if (d3 < 9.9999999999999995E-008D)
{
return;
}
else
{
float f = (float)((Math.atan2(d2, d) * 180D) / Math.PI) - 90F;
float f1 = (float)(-((Math.atan2(d1, d3) * 180D) / Math.PI));
double d4 = d / d3;
double d5 = d2 / d3;
setLocationAndAngles(par2EntityLiving.posX + d4, posY, par2EntityLiving.posZ + d5, f, f1);
yOffset = 0.0F;
float f2 = (float)d3 * 0.2F;
setArrowHeading(d, d1 + (double)f2, d2, par4, par5);
return;
}
}
public EntityFireArrow(World par1World, EntityLiving par2EntityLiving, float par3)
{
super(par1World);
xTile = -1;
yTile = -1;
zTile = -1;
inTile = 0;
inData = 0;
inGround = false;
doesArrowBelongToPlayer = false;
arrowShake = 0;
ticksInAir = 0;
damage = 2D;
arrowCritical = false;
shootingEntity = par2EntityLiving;
doesArrowBelongToPlayer = par2EntityLiving instanceof EntityPlayer;
setSize(0.5F, 0.5F);
setLocationAndAngles(par2EntityLiving.posX, par2EntityLiving.posY + (double)par2EntityLiving.getEyeHeight(), par2EntityLiving.posZ, par2EntityLiving.rotationYaw, par2EntityLiving.rotationPitch);
posX -= MathHelper.cos((rotationYaw / 180F) * (float)Math.PI) * 0.16F;
posY -= 0.10000000149011612D;
posZ -= MathHelper.sin((rotationYaw / 180F) * (float)Math.PI) * 0.16F;
setPosition(posX, posY, posZ);
yOffset = 0.0F;
motionX = -MathHelper.sin((rotationYaw / 180F) * (float)Math.PI) * MathHelper.cos((rotationPitch / 180F) * (float)Math.PI);
motionZ = MathHelper.cos((rotationYaw / 180F) * (float)Math.PI) * MathHelper.cos((rotationPitch / 180F) * (float)Math.PI);
motionY = -MathHelper.sin((rotationPitch / 180F) * (float)Math.PI);
setArrowHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F);
}
protected void entityInit()
{
}
/**
* Uses the provided coordinates as a heading and determines the velocity from it with the set force and random
* variance. Args: x, y, z, force, forceVariation
*/
public void setArrowHeading(double par1, double par3, double par5, float par7, float par8)
{
float f = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
par1 /= f;
par3 /= f;
par5 /= f;
par1 += rand.nextGaussian() * 0.0074999998323619366D * (double)par8;
par3 += rand.nextGaussian() * 0.0074999998323619366D * (double)par8;
par5 += rand.nextGaussian() * 0.0074999998323619366D * (double)par8;
par1 *= par7;
par3 *= par7;
par5 *= par7;
motionX = par1;
motionY = par3;
motionZ = par5;
float f1 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
prevRotationYaw = rotationYaw = (float)((Math.atan2(par1, par5) * 180D) / Math.PI);
prevRotationPitch = rotationPitch = (float)((Math.atan2(par3, f1) * 180D) / Math.PI);
ticksInGround = 0;
}
/**
* Sets the velocity to the args. Args: x, y, z
*/
public void setVelocity(double par1, double par3, double par5)
{
motionX = par1;
motionY = par3;
motionZ = par5;
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
prevRotationYaw = rotationYaw = (float)((Math.atan2(par1, par5) * 180D) / Math.PI);
prevRotationPitch = rotationPitch = (float)((Math.atan2(par3, f) * 180D) / Math.PI);
prevRotationPitch = rotationPitch;
prevRotationYaw = rotationYaw;
setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
ticksInGround = 0;
}
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
prevRotationYaw = rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / Math.PI);
prevRotationPitch = rotationPitch = (float)((Math.atan2(motionY, f) * 180D) / Math.PI);
}
int i = worldObj.getBlockId(xTile, yTile, zTile);
if (i > 0)
{
Block.blocksList[i].setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile);
AxisAlignedBB axisalignedbb = Block.blocksList[i].getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3D.createVector(posX, posY, posZ)))
{
inGround = true;
}
}
if (arrowShake > 0)
{
arrowShake--;
}
if (inGround)
{
int j = worldObj.getBlockId(xTile, yTile, zTile);
int k = worldObj.getBlockMetadata(xTile, yTile, zTile);
if (j != inTile || k != inData)
{
inGround = false;
motionX *= rand.nextFloat() * 0.2F;
motionY *= rand.nextFloat() * 0.2F;
motionZ *= rand.nextFloat() * 0.2F;
ticksInGround = 0;
ticksInAir = 0;
return;
}
ticksInGround++;
if (ticksInGround == 1200)
{
setDead();
}
return;
}
ticksInAir++;
Vec3D vec3d = Vec3D.createVector(posX, posY, posZ);
Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks_do_do(vec3d, vec3d1, false, true);
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 l = 0; l < list.size(); l++)
{
Entity entity1 = (Entity)list.get(l);
if (!entity1.canBeCollidedWith() || entity1 == shootingEntity && ticksInAir < 5)
{
continue;
}
float f5 = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f5, f5, f5);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(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)
{
if (movingobjectposition.entityHit != null)
{
float f1 = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ);
int j1 = (int)Math.ceil((double)f1 * damage);
if (arrowCritical)
{
j1 += rand.nextInt(j1 / 2 + 2);
}
DamageSource damagesource = null;
if (shootingEntity == null)
{
damagesource = causeArrowDamage(this, this);
}
else
{
damagesource = causeArrowDamage(this, shootingEntity);
}
if (isBurning())
{
movingobjectposition.entityHit.setFire(5);
}
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, j1))
{
if (movingobjectposition.entityHit instanceof EntityLiving)
{
((EntityLiving)movingobjectposition.entityHit).arrowHitTempCounter++;
if (field_46027_au > 0)
{
float f7 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
if (f7 > 0.0F)
{
movingobjectposition.entityHit.addVelocity((motionX * (double)field_46027_au * 0.60000002384185791D) / (double)f7, 0.10000000000000001D, (motionZ * (double)field_46027_au * 0.60000002384185791D) / (double)f7);
}
}
}
worldObj.playSoundAtEntity(this, "random.bowhit", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F));
setDead();
}
else
{
motionX *= -0.10000000149011612D;
motionY *= -0.10000000149011612D;
motionZ *= -0.10000000149011612D;
rotationYaw += 180F;
prevRotationYaw += 180F;
ticksInAir = 0;
}
}
else
{
xTile = movingobjectposition.blockX;
yTile = movingobjectposition.blockY;
zTile = movingobjectposition.blockZ;
inTile = worldObj.getBlockId(xTile, yTile, zTile);
inData = worldObj.getBlockMetadata(xTile, yTile, zTile);
motionX = (float)(movingobjectposition.hitVec.xCoord - posX);
motionY = (float)(movingobjectposition.hitVec.yCoord - posY);
motionZ = (float)(movingobjectposition.hitVec.zCoord - posZ);
float f2 = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ);
posX -= (motionX / (double)f2) * 0.05000000074505806D;
posY -= (motionY / (double)f2) * 0.05000000074505806D;
posZ -= (motionZ / (double)f2) * 0.05000000074505806D;
worldObj.playSoundAtEntity(this, "random.bowhit", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F));
inGround = true;
arrowShake = 7;
arrowCritical = false;
}
}
if (arrowCritical)
{
for (int i1 = 0; i1 < 4; i1++)
{
worldObj.spawnParticle("crit", posX + (motionX * (double)i1) / 4D, posY + (motionY * (double)i1) / 4D, posZ + (motionZ * (double)i1) / 4D, -motionX, -motionY + 0.20000000000000001D, -motionZ);
}
}
posX += motionX;
posY += motionY;
posZ += motionZ;
float f3 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / Math.PI);
for (rotationPitch = (float)((Math.atan2(motionY, f3) * 180D) / Math.PI); 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 f4 = 0.99F;
float f6 = 0.05F;
if (isInWater())
{
for (int k1 = 0; k1 < 4; k1++)
{
float f8 = 0.25F;
worldObj.spawnParticle("bubble", posX - motionX * (double)f8, posY - motionY * (double)f8, posZ - motionZ * (double)f8, motionX, motionY, motionZ);
}
f4 = 0.8F;
}
motionX *= f4;
motionY *= f4;
motionZ *= f4;
motionY -= f6;
setPosition(posX, posY, posZ);
}
private DamageSource causeArrowDamage(
EntityFireArrow entityBedrockArrow,
Entity shootingEntity2) {
// TODO Auto-generated method stub
return null;
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
par1NBTTagCompound.setShort("xTile", (short)xTile);
par1NBTTagCompound.setShort("yTile", (short)yTile);
par1NBTTagCompound.setShort("zTile", (short)zTile);
par1NBTTagCompound.setByte("inTile", (byte)inTile);
par1NBTTagCompound.setByte("inData", (byte)inData);
par1NBTTagCompound.setByte("shake", (byte)arrowShake);
par1NBTTagCompound.setByte("inGround", (byte)(inGround ? 1 : 0));
par1NBTTagCompound.setBoolean("player", doesArrowBelongToPlayer);
par1NBTTagCompound.setDouble("damage", damage);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
xTile = par1NBTTagCompound.getShort("xTile");
yTile = par1NBTTagCompound.getShort("yTile");
zTile = par1NBTTagCompound.getShort("zTile");
inTile = par1NBTTagCompound.getByte("inTile") & 0xff;
inData = par1NBTTagCompound.getByte("inData") & 0xff;
arrowShake = par1NBTTagCompound.getByte("shake") & 0xff;
inGround = par1NBTTagCompound.getByte("inGround") == 1;
doesArrowBelongToPlayer = par1NBTTagCompound.getBoolean("player");
if (par1NBTTagCompound.hasKey("damage"))
{
damage = par1NBTTagCompound.getDouble("damage");
}
}
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)
{
if (worldObj.isRemote)
{
return;
}
if (inGround && doesArrowBelongToPlayer && arrowShake <= 0 && par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(mod_theKennyMod.Firearrow, 1)))
{
worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
par1EntityPlayer.onItemPickup(this, 1);
setDead();
}
}
public float getShadowSize()
{
return 0.0F;
}
public void setDamage(double par1)
{
damage = par1;
}
public double getDamage()
{
return damage;
}
public void func_46023_b(int par1)
{
field_46027_au = par1;
}
/**
* If returns false, the item will not inflict any damage against entities.
*/
public boolean canAttackWithItem()
{
return false;
}
}