From fc70319fa26f144894670ade60196b19ab5e20a3 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Sun, 20 Mar 2016 10:06:53 -0400 Subject: [PATCH] Sentient Bow now properly renders when pulling. --- .../bloodmagic/item/soul/ItemSentientBow.java | 46 +++++++++------- .../models/item/ItemSentientBow.json | 54 +++++++++++++++---- .../item/ItemSentientBow_pulling_0.json | 28 ++++++---- .../item/ItemSentientBow_pulling_1.json | 26 ++++++--- .../item/ItemSentientBow_pulling_2.json | 26 ++++++--- 5 files changed, 124 insertions(+), 56 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java index caecd57e..0f0e68f0 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java @@ -1,6 +1,5 @@ package WayofTime.bloodmagic.item.soul; -import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -8,17 +7,20 @@ import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Enchantments; import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; +import net.minecraft.item.IItemPropertyGetter; import net.minecraft.item.ItemArrow; import net.minecraft.item.ItemBow; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatList; import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.registry.ModItems; public class ItemSentientBow extends ItemBow { @@ -28,6 +30,29 @@ public class ItemSentientBow extends ItemBow setUnlocalizedName(Constants.Mod.MODID + ".sentientBow"); setRegistryName(Constants.BloodMagicItem.SENTIENT_BOW.getRegName()); setCreativeTab(BloodMagic.tabBloodMagic); + this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter() + { + @SideOnly(Side.CLIENT) + public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) + { + if (entityIn == null) + { + return 0.0F; + } else + { + ItemStack itemstack = entityIn.getActiveItemStack(); + return itemstack != null && itemstack.getItem() == ModItems.sentientBow ? (float) (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F; + } + } + }); + this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter() + { + @SideOnly(Side.CLIENT) + public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) + { + return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F; + } + }); } @Override @@ -116,25 +141,6 @@ public class ItemSentientBow extends ItemBow } } - @SideOnly(Side.CLIENT) - public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) - { - int i = stack.getMaxItemUseDuration() - player.getItemInUseCount(); - - if (i >= 18) - { - return new ModelResourceLocation("bloodmagic:ItemSentientBow_pulling_2", "inventory"); - } else if (i > 13) - { - return new ModelResourceLocation("bloodmagic:ItemSentientBow_pulling_1", "inventory"); - } else if (i > 0) - { - return new ModelResourceLocation("bloodmagic:ItemSentientBow_pulling_0", "inventory"); - } - - return null; - } - protected ItemStack getFiredArrow(EntityPlayer player) { if (this.func_185058_h_(player.getHeldItem(EnumHand.OFF_HAND))) diff --git a/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow.json b/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow.json index 7becea77..5fa6f964 100644 --- a/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow.json +++ b/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow.json @@ -1,18 +1,50 @@ { - "parent": "builtin/generated", + "parent": "item/generated", "textures": { "layer0": "bloodmagic:items/SentientBow" }, "display": { - "thirdperson": { - "rotation": [ 5, 80, -45 ], - "translation": [ 0.75, 0, 0.25 ], - "scale": [ 1, 1, 1 ] + "thirdperson_righthand": { + "rotation": [ -80, 260, -40 ], + "translation": [ -1, -2, 2.5 ], + "scale": [ 0.9, 0.9, 0.9 ] }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] + "thirdperson_lefthand": { + "rotation": [ -80, -280, 40 ], + "translation": [ -1, -2, 2.5 ], + "scale": [ 0.9, 0.9, 0.9 ] + }, + "firstperson_righthand": { + "rotation": [ 0, -90, 25 ], + "translation": [ 1.13, 3.2, 1.13], + "scale": [ 0.68, 0.68, 0.68 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, 90, -25 ], + "translation": [ 1.13, 3.2, 1.13], + "scale": [ 0.68, 0.68, 0.68 ] } - } -} \ No newline at end of file + }, + "overrides": [ + { + "predicate": { + "pulling": 1 + }, + "model": "bloodmagic:item/ItemSentientBow_pulling_0" + }, + { + "predicate": { + "pulling": 1, + "pull": 0.65 + }, + "model": "bloodmagic:item/ItemSentientBow_pulling_1" + }, + { + "predicate": { + "pulling": 1, + "pull": 0.9 + }, + "model": "bloodmagic:item/ItemSentientBow_pulling_2" + } + ] +} diff --git a/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow_pulling_0.json b/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow_pulling_0.json index 08eb3bb7..b6704fe2 100644 --- a/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow_pulling_0.json +++ b/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow_pulling_0.json @@ -3,16 +3,26 @@ "textures": { "layer0": "bloodmagic:items/SentientBow_pulling_0" }, - "display": { - "thirdperson": { - "rotation": [ 5, 80, -45 ], - "translation": [ 0.75, 0, 0.25 ], - "scale": [ 1, 1, 1 ] + "display": { + "thirdperson_righthand": { + "rotation": [ -80, 260, -40 ], + "translation": [ -1, -2, 2.5 ], + "scale": [ 0.9, 0.9, 0.9 ] }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] + "thirdperson_lefthand": { + "rotation": [ -80, -280, 40 ], + "translation": [ -1, -2, 2.5 ], + "scale": [ 0.9, 0.9, 0.9 ] + }, + "firstperson_righthand": { + "rotation": [ 0, -90, 25 ], + "translation": [ 1.13, 3.2, 1.13], + "scale": [ 0.68, 0.68, 0.68 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, 90, -25 ], + "translation": [ 1.13, 3.2, 1.13], + "scale": [ 0.68, 0.68, 0.68 ] } } } \ No newline at end of file diff --git a/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow_pulling_1.json b/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow_pulling_1.json index c1c5d61f..74d75dfd 100644 --- a/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow_pulling_1.json +++ b/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow_pulling_1.json @@ -4,15 +4,25 @@ "layer0": "bloodmagic:items/SentientBow_pulling_1" }, "display": { - "thirdperson": { - "rotation": [ 5, 80, -45 ], - "translation": [ 0.75, 0, 0.25 ], - "scale": [ 1, 1, 1 ] + "thirdperson_righthand": { + "rotation": [ -80, 260, -40 ], + "translation": [ -1, -2, 2.5 ], + "scale": [ 0.9, 0.9, 0.9 ] }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] + "thirdperson_lefthand": { + "rotation": [ -80, -280, 40 ], + "translation": [ -1, -2, 2.5 ], + "scale": [ 0.9, 0.9, 0.9 ] + }, + "firstperson_righthand": { + "rotation": [ 0, -90, 25 ], + "translation": [ 1.13, 3.2, 1.13], + "scale": [ 0.68, 0.68, 0.68 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, 90, -25 ], + "translation": [ 1.13, 3.2, 1.13], + "scale": [ 0.68, 0.68, 0.68 ] } } } diff --git a/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow_pulling_2.json b/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow_pulling_2.json index 42c22e8a..42dc030c 100644 --- a/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow_pulling_2.json +++ b/src/main/resources/assets/bloodmagic/models/item/ItemSentientBow_pulling_2.json @@ -4,15 +4,25 @@ "layer0": "bloodmagic:items/SentientBow_pulling_2" }, "display": { - "thirdperson": { - "rotation": [ 5, 80, -45 ], - "translation": [ 0.75, 0, 0.25 ], - "scale": [ 1, 1, 1 ] + "thirdperson_righthand": { + "rotation": [ -80, 260, -40 ], + "translation": [ -1, -2, 2.5 ], + "scale": [ 0.9, 0.9, 0.9 ] }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] + "thirdperson_lefthand": { + "rotation": [ -80, -280, 40 ], + "translation": [ -1, -2, 2.5 ], + "scale": [ 0.9, 0.9, 0.9 ] + }, + "firstperson_righthand": { + "rotation": [ 0, -90, 25 ], + "translation": [ 1.13, 3.2, 1.13], + "scale": [ 0.68, 0.68, 0.68 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, 90, -25 ], + "translation": [ 1.13, 3.2, 1.13], + "scale": [ 0.68, 0.68, 0.68 ] } } }