Sentient Bow now properly renders when pulling.

This commit is contained in:
WayofTime 2016-03-20 10:06:53 -04:00
parent 2652dea81d
commit fc70319fa2
5 changed files with 124 additions and 56 deletions

View file

@ -1,6 +1,5 @@
package WayofTime.bloodmagic.item.soul; package WayofTime.bloodmagic.item.soul;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; 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.Enchantments;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents; import net.minecraft.init.SoundEvents;
import net.minecraft.item.IItemPropertyGetter;
import net.minecraft.item.ItemArrow; import net.minecraft.item.ItemArrow;
import net.minecraft.item.ItemBow; import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList; import net.minecraft.stats.StatList;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.registry.ModItems;
public class ItemSentientBow extends ItemBow public class ItemSentientBow extends ItemBow
{ {
@ -28,6 +30,29 @@ public class ItemSentientBow extends ItemBow
setUnlocalizedName(Constants.Mod.MODID + ".sentientBow"); setUnlocalizedName(Constants.Mod.MODID + ".sentientBow");
setRegistryName(Constants.BloodMagicItem.SENTIENT_BOW.getRegName()); setRegistryName(Constants.BloodMagicItem.SENTIENT_BOW.getRegName());
setCreativeTab(BloodMagic.tabBloodMagic); 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 @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) protected ItemStack getFiredArrow(EntityPlayer player)
{ {
if (this.func_185058_h_(player.getHeldItem(EnumHand.OFF_HAND))) if (this.func_185058_h_(player.getHeldItem(EnumHand.OFF_HAND)))

View file

@ -1,18 +1,50 @@
{ {
"parent": "builtin/generated", "parent": "item/generated",
"textures": { "textures": {
"layer0": "bloodmagic:items/SentientBow" "layer0": "bloodmagic:items/SentientBow"
}, },
"display": { "display": {
"thirdperson": { "thirdperson_righthand": {
"rotation": [ 5, 80, -45 ], "rotation": [ -80, 260, -40 ],
"translation": [ 0.75, 0, 0.25 ], "translation": [ -1, -2, 2.5 ],
"scale": [ 1, 1, 1 ] "scale": [ 0.9, 0.9, 0.9 ]
}, },
"firstperson": { "thirdperson_lefthand": {
"rotation": [ 0, -135, 25 ], "rotation": [ -80, -280, 40 ],
"translation": [ 0, 4, 2 ], "translation": [ -1, -2, 2.5 ],
"scale": [ 1.7, 1.7, 1.7 ] "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 ]
} }
} },
} "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"
}
]
}

View file

@ -3,16 +3,26 @@
"textures": { "textures": {
"layer0": "bloodmagic:items/SentientBow_pulling_0" "layer0": "bloodmagic:items/SentientBow_pulling_0"
}, },
"display": { "display": {
"thirdperson": { "thirdperson_righthand": {
"rotation": [ 5, 80, -45 ], "rotation": [ -80, 260, -40 ],
"translation": [ 0.75, 0, 0.25 ], "translation": [ -1, -2, 2.5 ],
"scale": [ 1, 1, 1 ] "scale": [ 0.9, 0.9, 0.9 ]
}, },
"firstperson": { "thirdperson_lefthand": {
"rotation": [ 0, -135, 25 ], "rotation": [ -80, -280, 40 ],
"translation": [ 0, 4, 2 ], "translation": [ -1, -2, 2.5 ],
"scale": [ 1.7, 1.7, 1.7 ] "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 ]
} }
} }
} }

View file

@ -4,15 +4,25 @@
"layer0": "bloodmagic:items/SentientBow_pulling_1" "layer0": "bloodmagic:items/SentientBow_pulling_1"
}, },
"display": { "display": {
"thirdperson": { "thirdperson_righthand": {
"rotation": [ 5, 80, -45 ], "rotation": [ -80, 260, -40 ],
"translation": [ 0.75, 0, 0.25 ], "translation": [ -1, -2, 2.5 ],
"scale": [ 1, 1, 1 ] "scale": [ 0.9, 0.9, 0.9 ]
}, },
"firstperson": { "thirdperson_lefthand": {
"rotation": [ 0, -135, 25 ], "rotation": [ -80, -280, 40 ],
"translation": [ 0, 4, 2 ], "translation": [ -1, -2, 2.5 ],
"scale": [ 1.7, 1.7, 1.7 ] "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 ]
} }
} }
} }

View file

@ -4,15 +4,25 @@
"layer0": "bloodmagic:items/SentientBow_pulling_2" "layer0": "bloodmagic:items/SentientBow_pulling_2"
}, },
"display": { "display": {
"thirdperson": { "thirdperson_righthand": {
"rotation": [ 5, 80, -45 ], "rotation": [ -80, 260, -40 ],
"translation": [ 0.75, 0, 0.25 ], "translation": [ -1, -2, 2.5 ],
"scale": [ 1, 1, 1 ] "scale": [ 0.9, 0.9, 0.9 ]
}, },
"firstperson": { "thirdperson_lefthand": {
"rotation": [ 0, -135, 25 ], "rotation": [ -80, -280, 40 ],
"translation": [ 0, 4, 2 ], "translation": [ -1, -2, 2.5 ],
"scale": [ 1.7, 1.7, 1.7 ] "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 ]
} }
} }
} }