Advertisement
ProgramerGamer

Custom Bow

Jul 22nd, 2018
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.98 KB | None | 0 0
  1. package mod.mcreator;
  2.  
  3. import net.minecraftforge.fml.relauncher.SideOnly;
  4. import net.minecraftforge.fml.relauncher.Side;
  5.  
  6. import net.minecraft.world.World;
  7. import net.minecraft.util.ResourceLocation;
  8. import net.minecraft.util.EnumHand;
  9. import net.minecraft.item.ItemStack;
  10. import net.minecraft.item.ItemBow;
  11. import net.minecraft.item.Item;
  12. import net.minecraft.item.IItemPropertyGetter;
  13. import net.minecraft.entity.player.EntityPlayer;
  14. import net.minecraft.entity.EntityLivingBase;
  15.  
  16. import javax.annotation.Nullable;
  17.  
  18. public class mcreator_supremeBow extends supreme_tools.ModElement {
  19.  
  20.     public static Item block;
  21.     public static final int ENTITYID = 1;
  22.     static {
  23.         block = (new SupremeBow());
  24.     }
  25.  
  26.     public static class SupremeBow extends ItemBow {
  27.  
  28.         public SupremeBow() {
  29.             super();
  30.             setMaxDamage(0);
  31.             maxStackSize = 1;
  32.             setFull3D();
  33.             setUnlocalizedName("supremebow");
  34.             setRegistryName("supremebow");
  35.             setCreativeTab(mcreator_supremeTab.tab);
  36.             addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter() {
  37.  
  38.                 @SideOnly(Side.CLIENT)
  39.                 public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
  40.                     if (entityIn == null)
  41.                         return 0.0F;
  42.                     else
  43.                         return entityIn.getActiveItemStack().getItem() != mcreator_supremeBow.block
  44.  ? 0.0F
  45.  : (float) (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F;
  46.                 }
  47.             });
  48.             this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter() {
  49.  
  50.                 @SideOnly(Side.CLIENT)
  51.                 public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
  52.                     return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F;
  53.                 }
  54.             });
  55.         }/* ItemBlazeBow constructor end */
  56.  
  57.         private ItemStack findAmmo(EntityPlayer player) {
  58.             if (this.isArrow(player.getHeldItem(EnumHand.OFF_HAND))) {
  59.                 return player.getHeldItem(EnumHand.OFF_HAND);
  60.             } else if (this.isArrow(player.getHeldItem(EnumHand.MAIN_HAND))) {
  61.                 return player.getHeldItem(EnumHand.MAIN_HAND);
  62.             } else {
  63.                 for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
  64.                     ItemStack itemstack = player.inventory.getStackInSlot(i);
  65.                     if (this.isArrow(itemstack))
  66.                         return itemstack;
  67.                 }
  68.                 return ItemStack.EMPTY;
  69.             }
  70.         }/* findAmmo method end */
  71.  
  72.         public static float getArrowVelocity(int charge) {
  73.             float f = (float) charge / 20.0F;
  74.             f = (f * f + f * 2.0F) / 3.0F;
  75.             if (f > 1.0F) {
  76.                 f = 1.0F;
  77.             }
  78.             return f;
  79.         }
  80.     }
  81. }
  82.  
  83.  
  84.  
  85.  
  86. JSON
  87.  
  88.  
  89. {
  90.     "parent": "item/generated",
  91.     "textures": {
  92.         "layer0": "minecraft:/textures/items/supremebow"
  93.     },
  94.     "display": {
  95.         "thirdperson_righthand": {
  96.             "rotation": [ -80, 260, -40 ],
  97.             "translation": [ -1, -2, 2.5 ],
  98.             "scale": [ 0.9, 0.9, 0.9 ]
  99.         },
  100.         "thirdperson_lefthand": {
  101.             "rotation": [ -80, -280, 40 ],
  102.             "translation": [ -1, -2, 2.5 ],
  103.             "scale": [ 0.9, 0.9, 0.9 ]
  104.         },
  105.         "firstperson_righthand": {
  106.             "rotation": [ 0, -90, 25 ],
  107.             "translation": [ 1.13, 3.2, 1.13],
  108.             "scale": [ 0.68, 0.68, 0.68 ]
  109.         },
  110.         "firstperson_lefthand": {
  111.             "rotation": [ 0, 90, -25 ],
  112.             "translation": [ 1.13, 3.2, 1.13],
  113.             "scale": [ 0.68, 0.68, 0.68 ]
  114.         }
  115.     },
  116.     "overrides": [
  117.         {
  118.             "predicate": {
  119.                 "pulling": 1
  120.             },
  121.             "model": "minecraft:/textures/item/supremebowpulling0"
  122.         },
  123.         {
  124.             "predicate": {
  125.                 "pulling": 1,
  126.                 "pull": 0.65
  127.             },
  128.             "model": "minecraft:/textures/item/supremebowpulling1"
  129.         },
  130.         {
  131.             "predicate": {
  132.                 "pulling": 1,
  133.                 "pull": 0.9
  134.             },
  135.             "model": "minecraft:/textures/item/supremebowpulling2"
  136.         }
  137.     ]
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement