Posted March 11, 201411 yr I make a Gun This is Gun package yorri.mods.mod_MicroUkr; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class ItemPistol extends Item { private byte damage; public ItemPistol(int i, byte dmg){ super(); maxStackSize = 1; this.damage = dmg; this.setMaxDamage(64); this.bFull3D=true; this.setCreativeTab(mod_MicroUkr.tabMicroUkr); } @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if(par3EntityPlayer.inventory.hasItem(mod_MicroUkr.pistolclip)) { par2World.playSoundAtEntity(par3EntityPlayer, "microukr:gunshot", 1, 1); par3EntityPlayer.inventory.consumeInventoryItem(mod_MicroUkr.pistolclip); par1ItemStack.damageItem(1, par3EntityPlayer); if(!par2World.isRemote) { System.out.println( "from pistol onItemRightClick" ); par2World.spawnEntityInWorld(new EntityBullet(par2World, par3EntityPlayer, (byte)5)); } } return par1ItemStack; } public int getMaxItemUseDuration(ItemStack par1ItemStack){ return 10; } } When I Right Click I create Bullet. This is EntityBullet package yorri.mods.mod_MicroUkr; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class EntityBullet extends EntityThrowable { public byte damageValue; public int xTile,yTile,zTile; public MovingObjectPosition objectMouseOver; public EntityBullet(World par1world, EntityPlayer par3EntityPlayer, byte damage) { super(par1world); damageValue = damage; System.out.println( "constructor1" ); } public EntityBullet(World par1world, EntityLiving par2EntityLiving, byte damage) { super(par1world, par2EntityLiving); damageValue = damage; } public EntityBullet(World par1world, double par2, double par4, double par6, byte damage) { super(par1world, par2, par4, par6); damageValue = damage; } @Override public void onImpact(MovingObjectPosition par1MovingObjectPosition) { System.out.println( "on impact" ); } @Override protected void entityInit() {} @Override public void readEntityFromNBT(NBTTagCompound var1) {} @Override public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {} } In the console I see "from pistol onItemRightClick" and "constructor1" but I not see "on impact"... /sorry for my english/
March 11, 201411 yr Check the minecraft snowball src i think the correct method is inthere I'm always happy to help others! Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL
March 11, 201411 yr Author Nothing... I can not understand why does not work? I see this and made something like this. But it not work...
March 11, 201411 yr Try removing the @Override? I'm always happy to help others! Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL
March 12, 201411 yr Author May be I am wrong registering in main class? pistol = new ItemPistol(getUniqueEntityId(),(byte)5).setUnlocalizedName("pistol").setTextureName(mod_MicroUkr.MODID + ":" + "pistol"); GameRegistry.registerItem(pistol, pistol.getUnlocalizedName().substring(5)); pistolclip = new ItemPistolClip(getUniqueEntityId()).setUnlocalizedName("pistolclip").setTextureName(mod_MicroUkr.MODID + ":" + "kula"); GameRegistry.registerItem(pistolclip, pistolclip.getUnlocalizedName().substring(5)); int i2=getUniqueEntityId(); EntityRegistry.registerGlobalEntityID(EntityBullet.class, "bullet", i2); EntityRegistry.registerModEntity(EntityBullet.class, "bullet", i2, this, 64, 1, true); RenderingRegistry.registerEntityRenderingHandler(EntityBullet.class, new RenderSnowball(mod_MicroUkr.pistolclip));
March 12, 201411 yr Author Sorry. I detect my error. In the EntityBullet class in constructor. Must be public EntityBullet(World par1world, EntityPlayer par3EntityPlayer) { super(par1world,[b]par3EntityPlayer[/b]); } I lost par3EntityPlayer. (I created other similar item and entity and saw this error. I guess that the error is in my code. Sorry again for the trouble )
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.