Could you please help me, there is an error in my code for the Gun, and I copied and code right from your Tut.
mod_VksWeaponsPack.java
package net.minecraft.src;
public class mod_VksWeaponsPack extends BaseMod
{
public static Item L115A3AWM = new ItemL115A3AWM(550).setMaxStackSize(1).setItemName("L115A3AWM")
.setCreativeTab(CreativeTabs.tabTools);
public static Item L115A3AWMAmmo = new Item(551).setItemName("L115A3AWMAmmo")
.setCreativeTab(CreativeTabs.tabTools);
public void load()
{
ModLoader.addName(L115A3AWM, "L115A3 AWM Sniper Rifle");
L115A3AWM.iconIndex = ModLoader.addOverride("/gui/items.png", "/vksweaponspack/L115A3AWM.png");
ModLoader.addName(L115A3AWMAmmo, "L115A3 AWM Ammunition");
L115A3AWMAmmo.iconIndex = ModLoader.addOverride("/gui/items.png", "/vksweaponspack/L115A3AWMAmmo.png");
}
public String getVersion()
{
return "1.4.4";
}
}
ItemL115A3AWM.java
package net.minecraft.src;
public class ItemL115A3AWM extends Item
{
public ItemL115A3AWM(int par1)
{
super(par1);
this.maxStackSize = 1;
}
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
boolean var5 = par3EntityPlayer.capabilities.depleteBuckets;
if (!par3EntityPlayer.capabilities.depleteBuckets)
{
if (var5 || par3EntityPlayer.inventory.hasItem(mod_VksWeaponsPack.L115A3AWMAmmo.shiftedIndex))
{
if (!var5)
{
par3EntityPlayer.inventory.consumeInventoryItem(mod_VksWeaponsPack.L115A3AWMAmmo.shiftedIndex);
if (!par2World.isRemote)
{
par2World.spawnEntityInWorld(new EntityL115A3AWMAmmo(par2World, par3EntityPlayer));
}
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
}
}
}
return par1ItemStack;
}
}
EntityL115A3AWMAmmo.java
package net.minecraft.src;
public class EntityL115A3AWMAmmo extends EntityThrowable
{
public EntityL115A3AWMAmmo(World par1World)
{
super(par1World);
}
public EntityL115A3AWMAmmo(World par1World, EntityLiving par2EntityLiving)
{
super(par1World, par2EntityLiving);
}
public EntityL115A3AWMAmmo(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
if (par1MovingObjectPosition.entityHit != null)
{
/**The damage is this variable
* \/ **/
byte var2 = 5;
if (par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.thrower), var2))
{
;
}
}
for (int var3 = 0; var3 < 8; ++var3)
{
this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
}
if (!this.worldObj.isRemote)
{
this.setEntityDead();
}
}
} {
}
i had the same problem remove all depletebucket references, replace like so:
boolean var5 = par3EntityPlayer.capabilities.isCreativeMode;
Also move the bracket at the end of the if (!var5) block right below this line or the gun will not work on creative:
par3EntityPlayer.inventory.consumeInventoryItem( mod_VksWeaponsPack.L115A3AWMAmmo.shiftedIndex );
The Gun File should now look like this:
package net.minecraft.src;
public class ItemL115A3AWM extends Item
{
public ItemL115A3AWM(int par1)
{
super(par1);
this.maxStackSize = 1;
}
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
boolean var5 = par3EntityPlayer.capabilities.isCreativeMode;
if (var5 || par3EntityPlayer.inventory.hasItem(mod_VksWeaponsPack.L115A3AWMAmmo.shiftedIndex))
{
if (!var5)
{
par3EntityPlayer.inventory.consumeInventoryItem(mod_VksWeaponsPack.L115A3AWMAmmo.shiftedIndex);
}
if (!par2World.isRemote)
{
par2World.spawnEntityInWorld(new EntityL115A3AWMAmmo(par2World, par3EntityPlayer));
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
}
}
return par1ItemStack;
}
}
Thanks for your help, I have another problem that I did not see before, in my EntityL115A3AWMAmmo.java there are 2 errors in the code.
Errors are the following lines:
(this, this.thrower)
&
this.setEntityDead();
EntityL115A3AWMAmmo.java
package net.minecraft.src;
public class EntityL115A3AWMAmmo extends EntityThrowable
{
public EntityL115A3AWMAmmo(World par1World)
{
super(par1World);
}
public EntityL115A3AWMAmmo(World par1World, EntityLiving par2EntityLiving)
{
super(par1World, par2EntityLiving);
}
public EntityL115A3AWMAmmo(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
if (par1MovingObjectPosition.entityHit != null)
{
/**The damage is this variable
* \/ **/
byte var2 = 5;
if (par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.thrower), var2))
{
;
}
}
for (int var3 = 0; var3 < 8; ++var3)
{
this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
}
if (!this.worldObj.isRemote)
{
this.setEntityDead();
}
}
}
Mmm,i see where the problem is.Your (this,this.thrower) doesn't work or exist anymore in MCP.Instead of that code you want to change the "this.thrower" into :
this.func_85052_h()
And for the second code instead of "this.setEntityDead" you want to change it into just:
this.setDead();
Hope that helps!Lemme know if you still have errors!
Mmm,i see where the problem is.Your (this,this.thrower) doesn't work or exist anymore in MCP.Instead of that code you want to change the "this.thrower" into :
this.func_85052_h()
And for the second code instead of "this.setEntityDead" you want to change it into just:
this.setDead();
Hope that helps!Lemme know if you still have errors!
I changed it to the following:
if (par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.func_85052_h(), var2))
{
;
}
and it changes the error line to under the 'causeThrownDamage'
if (par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.func_85052_h(), var2))
{
;
}
and it changes the error line to under the 'causeThrownDamage'
Ahh,a simple mistake that you have here.
if (par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.func_85052_h(), var2))
Your code here isn't finished yet.The cause of your error is that the causeThrownDamage statement hasn't been finished,so where is the error you might ask?:
(this, this.func_85052_h(),var2))
This code/statement isn't finished,because your missing a parenthesis in front of _h().It should be like this!:
i had the same problem remove all depletebucket references, replace like so:
boolean var5 = par3EntityPlayer.capabilities.isCreativeMode;
Also move the bracket at the end of the if (!var5) block right below this line or the gun will not work on creative:
par3EntityPlayer.inventory.consumeInventoryItem( mod_VksWeaponsPack.L115A3AWMAmmo.shiftedIndex );
The Gun File should now look like this:
Errors are the following lines:
&
EntityL115A3AWMAmmo.java
Mmm,i see where the problem is.Your (this,this.thrower) doesn't work or exist anymore in MCP.Instead of that code you want to change the "this.thrower" into :
And for the second code instead of "this.setEntityDead" you want to change it into just:
Hope that helps!Lemme know if you still have errors!
-
I changed it to the following:
and it changes the error line to under the 'causeThrownDamage'
here
http://www.minecraftforum.net/topic/960286-techguys-modding-tutorials/
he makes a lot of good tuts
Ahh,a simple mistake that you have here.
Your code here isn't finished yet.The cause of your error is that the causeThrownDamage statement hasn't been finished,so where is the error you might ask?:
This code/statement isn't finished,because your missing a parenthesis in front of _h().It should be like this!:
Hope that helps!
-
I got it to work but I need your help.
I want it so that the gun fires bullets and uses the ammo items then once the ammo item is all used up the gun will not fire, also custom fire sound.
can you help with that?
Hmm...Well i can't say i promise,but i'll try my best.So give me some time
-
Thanks