aguinmox Posted December 6, 2015 Share Posted December 6, 2015 Hello Guys I was doing some stuff with my custom bow however Since this is a modelled one i use the animation at render of this bow. so the cycle like this - REST, START, HALF, FULL.. Now the problem is instead of being in the REST while not in use, i end up in the HALF i dont even know whats wrong with my code.. So please guys help me especially i want to finish this tonight.. Render Bow package mhfc.net.client.render.weapon.bow; import org.lwjgl.opengl.GL11; import mhfc.net.client.model.weapon.bow.ModelBHunters; import mhfc.net.common.util.lib.MHFCReference; import mhfc.net.common.weapon.range.bow.BHunters; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; public class RenderBHunters implements IItemRenderer { private ModelBHunters weapon; public RenderBHunters() { weapon = new ModelBHunters(); } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { int usingItem = 72000 - ((BHunters) item.getItem()).usingItem; switch (type) { case EQUIPPED : // render in third person float scale = 1.2f; GL11.glPushMatrix(); if (((Entity) data[1] instanceof EntityPlayer)&& (((EntityPlayer) data[1]).getCurrentEquippedItem() != null)) { if (usingItem < 5) { Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(MHFCReference.weapon_bow_hunters_tex_start)); } if ((usingItem >= 5) && (usingItem < 25)) { Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(MHFCReference.weapon_bow_hunters_tex_half)); } if (usingItem >= 25) { Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(MHFCReference.weapon_bow_hunters_tex_full)); } } else { Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(MHFCReference.weapon_bow_hunters_tex_rest)); } GL11.glRotatef(00F, 1.0f, 0.0f, 0.0f); GL11.glRotatef(-90F, 0.0f, 1.0f, 0.0f); GL11.glRotatef(-180F, 0.0f, 0.0f, 1.0f); GL11.glTranslatef(-0.1F, -0.2F, -0.4F); GL11.glScalef(scale, scale, scale); weapon.renderA(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F,0.0625F); GL11.glPopMatrix(); break; case EQUIPPED_FIRST_PERSON : // rince and repeat the rendering. adjust axis' and translation // as needed GL11.glPushMatrix(); if (((Entity) data[1] instanceof EntityPlayer)&& (((EntityPlayer) data[1]).getCurrentEquippedItem() != null)) { if (usingItem < 5) { Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(MHFCReference.weapon_bow_hunters_tex_start)); } if ((usingItem >= 5) && (usingItem < 25)) { Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(MHFCReference.weapon_bow_hunters_tex_half)); } if (usingItem >= 25) { Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(MHFCReference.weapon_bow_hunters_tex_full)); } } else { Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(MHFCReference.weapon_bow_hunters_tex_rest)); } scale = 1.5f; GL11.glScalef(scale, scale, scale); GL11.glRotatef(0F, 1.0f, 0.0f, 0.0f); GL11.glRotatef(-5F, 0.0f, 1.0f, 0.0f); GL11.glRotatef(-150F, 0.0f, 0.0f, 1.0f); //In to face or out, Up/Down , Left or Right <-- positive/negative GL11.glTranslatef(-1.1F, -0.6F, 0.5F); weapon.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); break; case ENTITY : GL11.glPushMatrix(); scale = 2.4F; GL11.glScalef(scale, scale, scale); Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(MHFCReference.weapon_bow_hunters_tex_rest)); GL11.glRotatef(90F, 1.0f, 0.0f, 0.0f); GL11.glRotatef(0F, 0.0f, 1.0f, 0.0f); GL11.glRotatef(45F, 0.0f, 0.0f, 1.0f); GL11.glTranslatef(0F, -0.6F, -0.1F); weapon.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); break; case INVENTORY : GL11.glPushMatrix(); scale = 1.0F; GL11.glScalef(scale, scale, scale); Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(MHFCReference.weapon_bow_hunters_tex_rest)); GL11.glRotatef(200F, 1.0f, 0.0f, 0.0f); GL11.glRotatef(-80F, 0.0f, 1.0f, 0.0f); GL11.glTranslatef(0.1F, -0.0F, -0.1F); // this is a method made by me in my model class to render only // the modelparts, without an entity argument, because in your // inventory, //the entity is always null. weapon.renderRest(0.0625F); GL11.glPopMatrix(); break; default : break; } } @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { return true; } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { switch (type) { case INVENTORY : return true; default : break; } return false; } } package mhfc.net.common.weapon.range.bow; import java.util.List; import java.util.Random; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mhfc.net.MHFCMain; import mhfc.net.common.helper.MHFCWeaponClassingHelper; import mhfc.net.common.system.ColorSystem; import mhfc.net.common.util.Cooldown; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; public class BowClass extends Item { public static final String[] ItemNameArray = new String[] { "bow","bow1", "bow2", "bow3" }; protected boolean poisontype, firetype, enableCooldownDisplay; protected String des1, des2, des3; // <--- Shorten the handles protected int attackdelay, rarity, meta, getcooldown; public int usingItem = 72000; @SideOnly(Side.CLIENT) public IIcon[] IconArray; public BowClass() { super(); getWeaponDescription(MHFCWeaponClassingHelper.bowname); this.maxStackSize = 1; this.setMaxDamage(1000); this.setCreativeTab(MHFCMain.mhfctabs); } public void elementalType(boolean poison, boolean fire) { poisontype = poison; firetype = fire; } @Deprecated // will rework soon public void getWeaponDescription(String title) { des1 = title; } public void getWeaponDescriptionWithMeta(String second, int rarerty, int metaData) { des2 = second; rarity = rarerty; meta = metaData; } public void getWeaponDescription(String second, int rareity) { des2 = second; rarity = rareity; } @Override @SuppressWarnings("unchecked") public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, @SuppressWarnings("rawtypes") List par3List, boolean par4) { par3List.add(ColorSystem.gold + des1); par3List.add(ColorSystem.dark_green + des2); par3List.add(ColorSystem.yellow + "Rarity: " + rarity); if (enableCooldownDisplay) Cooldown.displayAttackDelay(par1ItemStack, par3List, getcooldown); } @Override public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { if (stack == usingItem) { if ((usingItem != null) && (usingItem.getItem() instanceof BowClass)) { if (useRemaining > 21) { return IconArray[3]; } else if (useRemaining > 14) { return IconArray[2]; } else if (useRemaining > 7) { return IconArray[1]; } } } return IconArray[0]; } @Override public IIcon getIconFromDamage(int par1) { return this.IconArray[0]; } /** * Return the enchantability factor of the item, most of the time is based * on material. */ @Override public int getItemEnchantability() { return -1; } @SideOnly(Side.CLIENT) public IIcon getItemIconForUseDuration(int par1) { return this.IconArray[par1]; } /** * returns the action that specifies what animation to play when the items * is being used */ @Override public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } /** * How long it takes to use or consume an item */ @Override public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } @Override public boolean getShareTag() { return true; } @Override public ItemStack onEaten(ItemStack par1ItemStack, World par2World,EntityPlayer par3EntityPlayer) { return par1ItemStack; } /** * Called whenever this item is equipped and the right mouse button is * pressed. Args: itemStack, world, entityPlayer */ @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,EntityPlayer player) { player.setItemInUse(par1ItemStack,this.getMaxItemUseDuration(par1ItemStack)); return par1ItemStack; } @Override public void onPlayerStoppedUsing(ItemStack stack, World par2World,EntityPlayer player, int par4) { super.onPlayerStoppedUsing(stack, par2World, player, par4); int maxItemUse = getMaxItemUseDuration(stack) - par4; boolean flag = (player.capabilities.isCreativeMode); if (player.inventory.hasItem(Items.arrow) || flag) { float f = maxItemUse / 20.0F; f = ((f * f) + (f * 2.0F)) / 3.0F; if (f < 0.5d) { return; } EntityArrow entityarrow = new EntityArrow(par2World,player, f * 2.0F); boolean crit = new Random().nextInt(10) == 0 ? true : false; entityarrow.setIsCritical(crit); if (f >= 1.0F && f <1.5F) { entityarrow.setIsCritical(true); } if (f > 1.0F) { f = 1.0F; } entityarrow.setDamage(entityarrow.getDamage()+ (flag ? 2D : 1D)); entityarrow.setKnockbackStrength(1); if (flag) { entityarrow.canBePickedUp = 2; } else { player.inventory.consumeInventoryItem(Items.arrow); } if (!par2World.isRemote) { par2World.spawnEntityInWorld(entityarrow); } stack.damageItem(1, player); par2World.playSoundAtEntity(player, "random.bow", 1.0F,(1.0F / ((itemRand.nextFloat() * 0.4F) + 1.2F))+ (f * 0.5F)); } } @Override public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { player.setItemInUse(stack, count); usingItem = count; } @Override public void registerIcons(IIconRegister par1IconRegister) { this.IconArray = new IIcon[itemNameArray.length]; for (int i = 0; i < this.IconArray.length; ++i) { String prefix = "mhfc:"; this.IconArray[i] = par1IconRegister.registerIcon(prefix+ ItemNameArray[i]); } this.itemIcon = this.IconArray[0]; } @Override public boolean requiresMultipleRenderPasses() { return false; } } P,S im done already registering my classes and so. Quote Link to comment Share on other sites More sharing options...
aguinmox Posted December 6, 2015 Author Share Posted December 6, 2015 Bump any help Quote Link to comment Share on other sites More sharing options...
aguinmox Posted December 6, 2015 Author Share Posted December 6, 2015 Bump help Quote Link to comment Share on other sites More sharing options...
larsgerrits Posted December 6, 2015 Share Posted December 6, 2015 Serously? Bumping twice in 3 hours? Have some patience please. To your problem: public int usingItem = 72000; . You can't store it in the Item class like that, you have to store it in the the ItemStack's NBT. Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/ Link to comment Share on other sites More sharing options...
coolAlias Posted December 6, 2015 Share Posted December 6, 2015 Also Item has a method specifically designed to help you return a different IIcon / model based on the current use duration: @Override @SideOnly(Side.CLIENT) public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { int ticksInUse = stack.getMaxItemUseDuration() - useRemaining; // return different IIcon based on how long item has been in use - see vanilla ItemBow for example } Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
aguinmox Posted December 6, 2015 Author Share Posted December 6, 2015 Hey @coolAlias, is that possible to implement in the RenderBow.class i have? Quote Link to comment Share on other sites More sharing options...
coolAlias Posted December 6, 2015 Share Posted December 6, 2015 Hey @coolAlias, is that possible to implement in the RenderBow.class i have? No and yes - no because that is an Item method that goes in your bow class, yes because you call that method from your render class to get the icon you want to render. Look at the vanilla ItemBow class and bow rendering - highlight ItemBow#getIcon and open the call hierarchy for it to find the bow rendering code. Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
aguinmox Posted December 6, 2015 Author Share Posted December 6, 2015 But which of the two is the most convenient if I just add an NBT or i should go for IIcon? Quote Link to comment Share on other sites More sharing options...
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.