BlueGhast90 Posted May 10, 2013 Posted May 10, 2013 I am trying to Make the bow animated and I have all three bow animated textures, but when I right click the bow, it disappers and it shoots an arrow then the bow comes back Here's my code package AeroMod.Tutorial; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import AeroMod.Tutorial.*; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.ArrowLooseEvent; import net.minecraftforge.event.entity.player.ArrowNockEvent; public class AzulBow extends Item { public static final String[] bowPullIconNameArray = new String[] {"blueeagle:angelbow_pull_0", "blueeagle:angelbow_pull_1", "blueeagle:angelbow_pull_2"}; @SideOnly(Side.CLIENT) private Icon[] iconArray; public AzulBow(int par1) { super(par1); this.maxStackSize = 1; this.setMaxDamage(384); this.setCreativeTab(CreativeTabs.tabCombat); } /** * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount */ public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) { int j = this.getMaxItemUseDuration(par1ItemStack) - par4; ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, j); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return; } j = event.charge; boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0; if (flag || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID)) { float f = (float)j / 20.0F; f = (f * f + f * 2.0F) / 3.0F; if ((double)f < 0.1D) { return; } if (f > 1.0F) { f = 1.0F; } EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F); if (f == 1.0F) { entityarrow.setIsCritical(true); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack); if (k > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double)k * 0.5D + 0.5D); } int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack); if (l > 0) { entityarrow.setKnockbackStrength(l); } if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0) { entityarrow.setFire(100); } par1ItemStack.damageItem(1, par3EntityPlayer); par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (flag) { entityarrow.canBePickedUp = 2; } else { par3EntityPlayer.inventory.consumeInventoryItem(Item.arrow.itemID); } if (!par2World.isRemote) { par2World.spawnEntityInWorld(entityarrow); } } } public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { return par1ItemStack; } /** * How long it takes to use or consume an item */ public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } /** * returns the action that specifies what animation to play when the items is being used */ public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; } /** * Return the enchantability factor of the item, most of the time is based on material. */ public int getItemEnchantability() { return 1; } @SideOnly(Side.CLIENT) private Icon[] azulbow = new Icon[4]; public void updateIcons(IconRegister par1IconRegister) { itemIcon = par1IconRegister.registerIcon("TutorialMod:" + this.getUnlocalizedName().substring(5) + "_0"); for (int N = 0; N < 4; N++) { this.azulbow[N] = par1IconRegister.registerIcon("TutorialMod:" + this.getUnlocalizedName().substring(5) + "_" + N); } } public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { if(player.getItemInUse() == null) return this.itemIcon; int time = stack.getMaxItemUseDuration() - useRemaining; if (time >= 18) { return azulbow[3]; } else if (time > 13) { return azulbow[2]; } else if (time > 0) { return azulbow[1]; } return azulbow[0]; } } Some help would be greatly appreciated Quote
Zetal Posted May 10, 2013 Posted May 10, 2013 I've never actually done any work with bows, but my first instinct would be to add System.out.println(time); underneath this line int time = stack.getMaxItemUseDuration() - useRemaining; then check the message that prints out in the Eclipse console. Quote Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
Zetal Posted May 10, 2013 Posted May 10, 2013 In the quotations? What do you mean? If you mean you get an error in the Eclipse console, that likely means that the variable 'stack' is null. Otherwise, please explain what you mean. Quote Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
BlueGhast90 Posted May 10, 2013 Author Posted May 10, 2013 sorry about that, i misplaced the code you gave me... In the console it gives me [ForgeModLoader]Forge Mod Loader has detected an older LWJGL version, new advanced texture animation features are disabled 2013-05-09 23:21:07 [iNFO] [ForgeModLoader] Not using advanced OpenGL 4.3 advanced capability for animations : OpenGL 4.3 is not available also when I right click, it shows numbers (assuming those are for timing) Quote
Zetal Posted May 10, 2013 Posted May 10, 2013 Well, yes, I was hoping for the Timing numbers. Could you tell me what those are? Quote Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
BlueGhast90 Posted May 10, 2013 Author Posted May 10, 2013 2013-05-09 23:23:18 [iNFO] [sTDOUT] 1 2013-05-09 23:23:18 [iNFO] [sTDOUT] 3 2013-05-09 23:23:18 [iNFO] [sTDOUT] 4 2013-05-09 23:23:18 [iNFO] [sTDOUT] 4 2013-05-09 23:23:18 [iNFO] [sTDOUT] 6 2013-05-09 23:23:18 [iNFO] [sTDOUT] 6 2013-05-09 23:23:18 [iNFO] [sTDOUT] 8 2013-05-09 23:23:19 [iNFO] [sTDOUT] 8 2013-05-09 23:23:19 [iNFO] [sTDOUT] 9 2013-05-09 23:23:19 [iNFO] [sTDOUT] 9 2013-05-09 23:23:19 [iNFO] [sTDOUT] 10 2013-05-09 23:23:19 [iNFO] [sTDOUT] 10 2013-05-09 23:23:19 [iNFO] [sTDOUT] 11 2013-05-09 23:23:19 [iNFO] [sTDOUT] 11 2013-05-09 23:23:19 [iNFO] [sTDOUT] 12 2013-05-09 23:23:19 [iNFO] [sTDOUT] 12 2013-05-09 23:23:19 [iNFO] [sTDOUT] 13 2013-05-09 23:23:19 [iNFO] [sTDOUT] 14 2013-05-09 23:23:19 [iNFO] [sTDOUT] 14 2013-05-09 23:23:19 [iNFO] [sTDOUT] 15 2013-05-09 23:23:19 [iNFO] [sTDOUT] 15 2013-05-09 23:23:19 [iNFO] [sTDOUT] 16 2013-05-09 23:23:19 [iNFO] [sTDOUT] 16 2013-05-09 23:23:19 [iNFO] [sTDOUT] 16 It also gives me this 2013-05-09 23:23:14 [WARNING] [Minecraft-Server] Can't keep up! Did the system time change, or is the server overloaded? Quote
Zetal Posted May 10, 2013 Posted May 10, 2013 Okay, thanks. Just wanted to verify that it wasn't something silly. Firstly, you should add super.updateIcons(par1IconRegister); inside the updateIcons method. See if that fixes it. Even if not, you should probably keep it. Next; At the bottom, where you set the default Icon? Swap that out with one of the textures that isn't appearing. It's possible that the icon you're trying to switch to isn't actually registered, and might not appear. If that's the case- you've found your problem. If not, start adding println messages in areas you think might be causing the problem- the more information you can gather, the more likely you'll be able to solve the issue. Quote Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
BlueGhast90 Posted May 10, 2013 Author Posted May 10, 2013 I get an error for the "updateIcons" and I dont get what you mean by default import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import AeroMod.Tutorial.*; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.ArrowLooseEvent; import net.minecraftforge.event.entity.player.ArrowNockEvent; public class AzulBow extends Item { public static final String[] bowPullIconNameArray = new String[] {"blueeagle:angelbow_pull_0", "blueeagle:angelbow_pull_1", "blueeagle:angelbow_pull_2"}; @SideOnly(Side.CLIENT) private Icon[] iconArray; public AzulBow(int par1) { super(par1); this.maxStackSize = 1; this.setMaxDamage(384); this.setCreativeTab(CreativeTabs.tabCombat); } /** * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount */ public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) { int j = this.getMaxItemUseDuration(par1ItemStack) - par4; ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, j); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return; } j = event.charge; boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0; if (flag || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID)) { float f = (float)j / 20.0F; f = (f * f + f * 2.0F) / 3.0F; if ((double)f < 0.1D) { return; } if (f > 1.0F) { f = 1.0F; } EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F); if (f == 1.0F) { entityarrow.setIsCritical(true); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack); if (k > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double)k * 0.5D + 0.5D); } int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack); if (l > 0) { entityarrow.setKnockbackStrength(l); } if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0) { entityarrow.setFire(100); } par1ItemStack.damageItem(1, par3EntityPlayer); par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (flag) { entityarrow.canBePickedUp = 2; } else { par3EntityPlayer.inventory.consumeInventoryItem(Item.arrow.itemID); } if (!par2World.isRemote) { par2World.spawnEntityInWorld(entityarrow); } } } public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { return par1ItemStack; } /** * How long it takes to use or consume an item */ public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } /** * returns the action that specifies what animation to play when the items is being used */ public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; } /** * Return the enchantability factor of the item, most of the time is based on material. */ public int getItemEnchantability() { return 1; } @SideOnly(Side.CLIENT) private Icon[] azulbow = new Icon[4]; public void updateIcons(IconRegister par1IconRegister) { super.updateIcons(par1IconRegister); itemIcon = par1IconRegister.registerIcon("TutorialMod:" + this.getUnlocalizedName().substring(5) + "_0"); for (int N = 0; N < 4; N++) { this.azulbow[N] = par1IconRegister.registerIcon("TutorialMod:" + this.getUnlocalizedName().substring(5) + "_" + N); } } public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { if(player.getItemInUse() == null) return this.itemIcon; int time = stack.getMaxItemUseDuration() - useRemaining; System.out.println(time); if (time >= 18) { return azulbow[3]; } else if (time > 13) { return azulbow[2]; } else if (time > 0) { return azulbow[1]; } return azulbow[0]; } } Sorry I am just beginning to Mod with Forge, so I'm not so good with the Terms (Method, Icon....) Quote
Zetal Posted May 10, 2013 Posted May 10, 2013 Well, "method" is a coding term... but, besides that, the 'Icon' is the image you're updating so that the bow appears to be animated. At least, that's what it seems like. All the way at the bottom, where you return different azulBow[#] icons, add return azulbow[3]; at the very top, so that only that returns. Change that 3 from 0-3 and run it every time you change it, and see what happens. if the bow ever stops rendering entirely, tell me. Now, you say that updateIcons has an error..? If it's a problem with a 'parent' class, you should move the @SideOnly(Side.CLIENT) down a line, beneath the azulBow[] variable. Quote Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
BlueGhast90 Posted May 10, 2013 Author Posted May 10, 2013 i moved @SideOnly(Side.CLIENT) down, but the error is still their When I hover over it, it gives me The Method updateIcons(IconRegister) is undefined for the type item Quote
Zetal Posted May 10, 2013 Posted May 10, 2013 That's...really weird, but I don't know what's causing that. It shouldn't matter TOO much, though... for now, comment it out and do the other stuff I told you. I need to get to sleep, though. If all of the icons are rendering correctly, then look into the ItemBow class, and look for any obvious discrepancies. Good luck. Quote Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
BlueGhast90 Posted May 10, 2013 Author Posted May 10, 2013 Sorry for the late night, but i went to ItemBow ans copy/pasted the super.updateIcons(par1IconRegister); from that and it worked somehow The main bow renders as usual, but the rest don't. I've tried changing the return image to both 2 & 3. but no luck Here's my code again if you can find anything else ** Left out imports to save space ** public class AzulBow extends Item { public static final String[] bowPullIconNameArray = new String[] {"azulbow_1", "azulbow_2", "azulbow_3"}; @SideOnly(Side.CLIENT) private Icon[] iconArray; public AzulBow(int par1) { super(par1); this.maxStackSize = 1; this.setMaxDamage(384); this.setCreativeTab(CreativeTabs.tabCombat); } /** * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount */ public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) { int j = this.getMaxItemUseDuration(par1ItemStack) - par4; ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, j); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return; } j = event.charge; boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0; if (flag || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID)) { float f = (float)j / 20.0F; f = (f * f + f * 2.0F) / 3.0F; if ((double)f < 0.1D) { return; } if (f > 1.0F) { f = 1.0F; } EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F); if (f == 1.0F) { entityarrow.setIsCritical(true); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack); if (k > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double)k * 0.5D + 0.5D); } int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack); if (l > 0) { entityarrow.setKnockbackStrength(l); } if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0) { entityarrow.setFire(100); } par1ItemStack.damageItem(1, par3EntityPlayer); par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (flag) { entityarrow.canBePickedUp = 2; } else { par3EntityPlayer.inventory.consumeInventoryItem(Item.arrow.itemID); } if (!par2World.isRemote) { par2World.spawnEntityInWorld(entityarrow); } } } public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { return par1ItemStack; } /** * How long it takes to use or consume an item */ public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } /** * returns the action that specifies what animation to play when the items is being used */ public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; } /** * Return the enchantability factor of the item, most of the time is based on material. */ public int getItemEnchantability() { return 1; } private Icon[] azulbow = new Icon[4]; @SideOnly(Side.CLIENT) public void updateIcons(IconRegister par1IconRegister) { super.registerIcons(par1IconRegister); itemIcon = par1IconRegister.registerIcon("TutorialMod:" + this.getUnlocalizedName().substring(5) + "_0"); for (int N = 0; N < 4; N++) { this.azulbow[N] = par1IconRegister.registerIcon("TutorialMod:" + this.getUnlocalizedName().substring(5) + "_" + N); } } public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining){ { if(player.getItemInUse() == null) return this.itemIcon; int time = stack.getMaxItemUseDuration() - useRemaining; if (time >= 18) { return azulbow[3]; } else if (time > 13) { return azulbow[2]; } else if (time > 0) { return azulbow[1]; } return azulbow[3]; } }} Thanks again, I really appreciated it Quote
Ives Posted May 10, 2013 Posted May 10, 2013 I would use @SideOnly(Side.CLIENT) private Icon[] azulnow = new Icon[4]; @Override public void registerIcons(IconRegister iconRegister){ this.itemIcon = iconRegister.registerIcon((this.getUnlocalizedName().substring(5)) + "_0"); for (int N = 0; N < 4; N++){ this.azulbow[N] = iconRegister.registerIcon((this.getUnlocalizedName().substring(5)) + "_" + N); } }{ The Override is important, otherwise the texturer asks for the wrong textures. Quote
Zetal Posted May 10, 2013 Posted May 10, 2013 @Ives The @Override annotation is purely for Eclipse to notify you if the method you're attempting to override doesn't exist. It adds no 'real' functionality. It's useful, but won't solve this problem. @BlueGhast90 It sounds like you aren't registering all of the icons, then. I would recommend adding a System.out.println message for this.getUnlocalizedName().substring(5)) + "_" + N This part to see what exactly you're attempting to register. I'm not completely familiar with what the substring(5) is doing, so that's kind of worrying me. Sorry! Quote Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
BlueGhast90 Posted May 11, 2013 Author Posted May 11, 2013 Wow, Thanks Ives I got almost all of them to render, the only one i cant get to render is the original bow texture I would also like to thank Zetal for all your hard work and support, I really appreciate it. I think I can fix it from here. I really appreciate the help Edit: I got it to work by making a copy of the original bow image and renaming it azulbow_0 to fix the broken animation in the icon section Quote
Recommended Posts
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.