Posted December 14, 201410 yr hi, I started to update one of my mods to 1.8 this weekend and I'm stuck on the bow textures. By doing research on how the minecraft bow work, I found this in net.minecraft.client.renderer.entity.RenderItem : public void renderItemModelForEntity(ItemStack stack, EntityLivingBase entityToRenderFor, ItemCameraTransforms.TransformType cameraTransformType) { IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack); if (entityToRenderFor instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)entityToRenderFor; Item item = stack.getItem(); ModelResourceLocation modelresourcelocation = null; if (item == Items.fishing_rod && entityplayer.fishEntity != null) { modelresourcelocation = new ModelResourceLocation("fishing_rod_cast", "inventory"); } else if (item == Items.bow && entityplayer.getItemInUse() != null) { int i = stack.getMaxItemUseDuration() - entityplayer.getItemInUseCount(); if (i >= 18) { modelresourcelocation = new ModelResourceLocation("bow_pulling_2", "inventory"); } else if (i > 13) { modelresourcelocation = new ModelResourceLocation("bow_pulling_1", "inventory"); } else if (i > 0) { modelresourcelocation = new ModelResourceLocation("bow_pulling_0", "inventory"); } } else { modelresourcelocation = item.getModel(stack, entityplayer, stack.getMaxItemUseDuration() - entityplayer.getItemInUseCount()); } if (modelresourcelocation != null) { ibakedmodel = this.itemModelMesher.getModelManager().getModel(modelresourcelocation); } } this.renderItemModelTransform(stack, ibakedmodel, cameraTransformType); } but apparently forge did not have hook or event to allow modder to use it. Is there any other way to do a custom bow or it would add an event or hook to forge ?
December 14, 201410 yr Author modelresourcelocation = item.getModel(stack, entityplayer, stack.getMaxItemUseDuration() - entityplayer.getItemInUseCount()); Indeed, it was just under my eyes and I didn't even see it x) thank you ! EDIT : It's working, if someone else has the same problem, here's how: package your.package; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBow; import net.minecraft.item.ItemStack; public class ItemCustomBow extends ItemBow { @Override public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) { ModelResourceLocation modelresourcelocation = new ModelResourceLocation(TestMod.MODID + ":custom_bow", "inventory"); if(stack.getItem() == this && player.getItemInUse() != null) { if(useRemaining >= 18) { modelresourcelocation = new ModelResourceLocation(TestMod.MODID + ":custom_bow_pull2", "inventory"); } else if(useRemaining > 13) { modelresourcelocation = new ModelResourceLocation(TestMod.MODID + ":custom_bow_pull1", "inventory"); } else if(useRemaining > 0) { modelresourcelocation = new ModelResourceLocation(TestMod.MODID + ":custom_bow_pull0", "inventory"); } } return modelresourcelocation; } } and the main class : package your.package; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemModelMesher; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @Mod(modid = TestMod.MODID, name = "Test Mod", version = "1.0.0", acceptedMinecraftVersions = "[1.8.0,)") public class TestMod { public static final String MODID = "testmod"; public static Item customBow; @EventHandler public void preLoad(FMLPreInitializationEvent event) { customBow = new ItemCustomBow().setUnlocalizedName("customBow"); GameRegistry.registerItem(customBow, "custom_bow"); } @EventHandler public void load(FMLInitializationEvent event) { if(event.getSide().isClient()) { ModelBakery.addVariantName(customBow, new String[] {MODID + ":custom_bow", MODID + ":custom_bow_pull0", MODID + ":custom_bow_pull1", MODID + ":custom_bow_pull2"}); registerItem(customBow, 0, MODID + ":custom_bow"); registerItem(customBow, 1, MODID + ":custom_bow_pull0"); registerItem(customBow, 2, MODID + ":custom_bow_pull1"); registerItem(customBow, 3, MODID + ":custom_bow_pull2"); } } @SideOnly(Side.CLIENT) public static void registerItem(Item item, int metadata, String itemName) { ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher(); mesher.register(item, metadata, new ModelResourceLocation(itemName, "inventory")); } }
December 31, 201410 yr i have a question over your question if you have more than one ItemCustomBow in the hot bar wen you pull one of the bows all the bows in hot bar get pulled to or just afect the one you have in hands?
December 31, 201410 yr i have a question over your question if you have more than one ItemCustomBow in the hot bar wen you pull one of the bows all the bows in hot bar get pulled to or just afect the one you have in hands?
January 1, 201510 yr yap i do it and works like i wan just the inhand item change the other remain still
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.