Jump to content

Recommended Posts

Posted (edited)

I am trying to create a custom bow, but the only texture that I can get to show up is the standby. Once I start pulling back, the pink textureless box shows up.

 

These are my json and bow class:

 

 

fizzyo_bow.json

Spoiler


{
    "parent": "item/generated",
    "textures": {
        "layer0": "fizzyo:items/fizzyo_bow_standby"
    },
    "display": {
        "thirdperson_righthand": {
            "rotation": [ -80, 260, -40 ],
            "translation": [ -1, -2, 2.5 ],
            "scale": [ 0.9, 0.9, 0.9 ]
        },
        "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 ]
        }
    },
    "overrides": [
        {
            "predicate": {
                "pulling": 1
            },
            "model": "fizzyo:items/fizzyo_bow_pulling_0"
        },
        {
            "predicate": {
                "pulling": 1,
                "pull": 0.65
            },
            "model": "fizzyo:items/fizzyo_bow_pulling_1"
        },
        {
            "predicate": {
                "pulling": 1,
                "pull": 0.9
            },
            "model": "fizzyo:items/fizzyo_bow_pulling_2"
        }
    ]
}

 

 

 

FizzyoBow.java

 

Spoiler

package com.microsoft.fizzyo.common.item;

import javax.annotation.Nullable;

import com.microsoft.fizzyo.FizzyoMod;
import com.microsoft.fizzyo.client.FizzyoClientTickHandler;
import com.microsoft.fizzyo.client.FizzyoInputController;
import com.microsoft.fizzyo.common.FizzyoItems;

import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
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.EnumAction;
import net.minecraft.item.IItemPropertyGetter;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArrow;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
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;

public class FizzyoBow extends ItemBow {

	public FizzyoBow(String itemName) {
		setItemName(this, itemName);
		setCreativeTab(FizzyoMod.CREATIVE_TAB);
		
		
		
	
		this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter() {
			@SideOnly(Side.CLIENT)
			public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
				return entityIn == null ? 0.0F
						: (entityIn.getActiveItemStack().getItem() != FizzyoItems.BOW ? 0.0F
								: (float) (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F);
			}
		});
		this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter() {
			@SideOnly(Side.CLIENT)
			public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
				return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F
						: 0.0F;
			}
		});
	}

	public static void setItemName(Item item, String itemName) {
		item.setRegistryName(FizzyoMod.MODID, itemName);
		item.setUnlocalizedName(item.getRegistryName().toString());
	}

//	/**
//	 * Get the location of the blockstates file used for this item's models
//	 *
//	 * @return The location
//	 */
//	public String getModelLocation() {
//		String registry = getRegistryName().toString();
//
//		System.out.println("Registry: " + registry);
//
//		
//		
//		return registry;
//	}

//	@SideOnly(Side.CLIENT)
//	public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
//		System.out.println("IS THIS EVER CALLED");
//
//		if (player.isHandActive()) {
//			int useTime = stack.getMaxItemUseDuration() - useRemaining;
//
//			System.out.println(useTime);
//
//			if (useTime >= 18) {
//				return new ModelResourceLocation(getModelLocation(), "fizzyo_bow_pulling_2");
//			} else if (useTime > 13) {
//				return new ModelResourceLocation(getModelLocation(), "fizzyo_bow_pulling_1");
//			} else if (useTime > 0) {
//				return new ModelResourceLocation(getModelLocation(), "fizzyo_bow_pulling_0");
//			}
//		}
//
//		return null;
//	}

	public static float getVelocity(int charge) {

		FizzyoInputController controller = FizzyoClientTickHandler.Instance.fizzyo;

		float pressure = controller.getBlowStrength();

		float f = (float) charge / 20.0F;

		System.out.println(f);
		System.out.println("pressure = " + pressure);

		f = f * pressure;

		System.out.println(f);

		return f;
	}

	private ItemStack findAmmo(EntityPlayer player) {
		if (this.isArrow(player.getHeldItem(EnumHand.OFF_HAND))) {
			return player.getHeldItem(EnumHand.OFF_HAND);
		} else if (this.isArrow(player.getHeldItem(EnumHand.MAIN_HAND))) {
			return player.getHeldItem(EnumHand.MAIN_HAND);
		} else {
			for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
				ItemStack itemstack = player.inventory.getStackInSlot(i);

				if (this.isArrow(itemstack)) {
					return itemstack;
				}
			}

			return ItemStack.field_190927_a;
		}
	}

	// protected boolean isArrow(ItemStack stack) {
	// return stack.getItem() instanceof ItemArrow;
	// }

	/**
	 * Called when the player stops using an Item (stops holding the right mouse
	 * button).
	 */
	public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) {
		if (entityLiving instanceof EntityPlayer) {
			EntityPlayer entityplayer = (EntityPlayer) entityLiving;
			boolean flag = entityplayer.capabilities.isCreativeMode
					|| EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0;
			ItemStack itemstack = this.findAmmo(entityplayer);

			int i = this.getMaxItemUseDuration(stack) - timeLeft;
			i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, worldIn, (EntityPlayer) entityLiving, i,
					itemstack != null || flag);
			if (i < 0)
				return;

			if (!itemstack.func_190926_b() || flag) {
				if (itemstack.func_190926_b()) {
					itemstack = new ItemStack(Items.ARROW);
				}

				float f = getVelocity(i);

				if ((double) f >= 0.1D) {
					boolean flag1 = entityplayer.capabilities.isCreativeMode
							|| (itemstack.getItem() instanceof ItemArrow
									? ((ItemArrow) itemstack.getItem()).isInfinite(itemstack, stack, entityplayer)
									: false);

					if (!worldIn.isRemote) {
						ItemArrow itemarrow = (ItemArrow) ((ItemArrow) (itemstack.getItem() instanceof ItemArrow
								? itemstack.getItem()
								: Items.ARROW));
						EntityArrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer);
						entityarrow.setAim(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F,
								f * 3.0F, 1.0F);

						if (f == 1.0F) {
							entityarrow.setIsCritical(true);
						}

						int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);

						if (j > 0) {
							entityarrow.setDamage(entityarrow.getDamage() + (double) j * 0.5D + 0.5D);
						}

						int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);

						if (k > 0) {
							entityarrow.setKnockbackStrength(k);
						}

						if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) {
							entityarrow.setFire(100);
						}

						stack.damageItem(1, entityplayer);

						if (flag1 || entityplayer.capabilities.isCreativeMode
								&& (itemstack.getItem() == Items.SPECTRAL_ARROW
										|| itemstack.getItem() == Items.TIPPED_ARROW)) {
							entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
						}

						worldIn.spawnEntityInWorld(entityarrow);
					}

					worldIn.playSound((EntityPlayer) null, entityplayer.posX, entityplayer.posY, entityplayer.posZ,
							SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F,
							1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);

					if (!flag1 && !entityplayer.capabilities.isCreativeMode) {
						itemstack.func_190918_g(1);

						if (itemstack.func_190926_b()) {
							entityplayer.inventory.deleteStack(itemstack);
						}
					}

					entityplayer.addStat(StatList.getObjectUseStats(this));
				}
			}
		}
	}

	// /**
	// * How long it takes to use or consume an item
	// */
	// public int getMaxItemUseDuration(ItemStack stack) {
	// return 72000;
	// }
	//
	// /**
	// * returns the action that specifies what animation to play when the items is
	// * being used
	// */
	// public EnumAction getItemUseAction(ItemStack stack) {
	// return EnumAction.BOW;
	// }
	//
	// /**
	// * Called when the equipped item is right clicked.
	// */
	// public ActionResult<ItemStack> onItemRightClick(World itemStackIn,
	// EntityPlayer worldIn, EnumHand playerIn) {
	// ItemStack itemstack = worldIn.getHeldItem(playerIn);
	// boolean flag = !this.findAmmo(worldIn).func_190926_b();
	//
	// ActionResult<ItemStack> ret =
	// net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemstack,
	// itemStackIn,
	// worldIn, playerIn, flag);
	// if (ret != null)
	// return ret;
	//
	// if (!worldIn.capabilities.isCreativeMode && !flag) {
	// return flag ? new ActionResult(EnumActionResult.PASS, itemstack)
	// : new ActionResult(EnumActionResult.FAIL, itemstack);
	// } else {
	// worldIn.setActiveHand(playerIn);
	// return new ActionResult(EnumActionResult.SUCCESS, itemstack);
	// }
	// }
	//
	// /**
	// * Return the enchantability factor of the item, most of the time is based on
	// * material.
	// */
	// public int getItemEnchantability() {
	// return 1;
	// }

}

 

 

 

If anyone has any ideas I would appreciate it!

Edited by camcraft1234
Posted
58 minutes ago, camcraft1234 said:

this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { return entityIn == null ? 0.0F : (entityIn.getActiveItemStack().getItem() != FizzyoItems.BOW ? 0.0F : (float) (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F); } }); this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F; } });

probably to do with this code google the problem and there should be some reasonable solutions. the code has to do with making the bow have different textures while pulling which I assume you don't want. You can probably just get rid of it. 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
20 minutes ago, Cadiboo said:

probably to do with this code google the problem and there should be some reasonable solutions. the code has to do with making the bow have different textures while pulling which I assume you don't want. You can probably just get rid of it. 

Thank you for replying but I've tried commenting it out, and the problem was the same. I do want the different textures to show up while pulling the arrow back in the same way as the vanilla bow

Posted
5 minutes ago, camcraft1234 said:

Thank you for replying but I've tried commenting it out, and the problem was the same. I do want the different textures to show up while pulling the arrow back in the same way as the vanilla bow

Post your logs please

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

In your Itemclass you create Property Overrides without giving them textures in your model file. Look at the Vannila Bow

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Posted
15 minutes ago, _Cruelar_ said:

In your Itemclass you create Property Overrides without giving them textures in your model file. Look at the Vannila Bow

I'm not sure I understand what you mean. I thought that in my model file 

 

2 hours ago, camcraft1234 said:

"model": "fizzyo:items/fizzyo_bow_pulling_0"

was referring to my texture fizzyo_bow_pulling_0.png

Posted
4 minutes ago, camcraft1234 said:

was referring to my texture fizzyo_bow_pulling_0.png

Nope, it refers to the file fizzo:models/items/fizzyo_bow_pulling_0.json.

Every override needs an own model file

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Posted (edited)
3 minutes ago, _Cruelar_ said:

Every override needs an own model file

Ive also got models for fizzyo_bow_pulling_0 1 and 2

 

Spoiler

{
    "parent": "item/generated",
    "textures": {
        "layer0": "fizzyo:items/fizzyo_bow_pulling_0"
    },
    "display": {
        "thirdperson_righthand": {
            "rotation": [ 0, 0, 0 ],
            "translation": [ 0.00, 0.00, 0.00 ],
            "scale": [ 1.00, 1.00, 1.00 ]
        },
            "thirdperson_lefthand": {
            "rotation": [ 0, 0, 0 ],
            "translation": [ 0.00, 0.00, 0.00 ],
            "scale": [ 1.00, 1.00, 1.00 ]
        },
            "firstperson_righthand": {
            "rotation": [ 284, 0, 332 ],
            "translation": [ 0.00, 1.00, -1.50 ],
            "scale": [ 1.00, 1.00, 1.00 ]
        },
            "firstperson_lefthand": {
            "rotation": [ 0, 0, 0 ],
            "translation": [ 0.00, 0.00, 0.00 ],
            "scale": [ 1.00, 1.00, 1.00 ]
    }
}
}

 

 

Edited by camcraft1234
Posted
1 minute ago, camcraft1234 said:

{ "parent": "item/generated", "textures": { "layer0": "fizzyo:items/fizzyo_bow_pulling_0" }}

should be enough.

But is your path in your models directory  items or item? Cause this

12 minutes ago, camcraft1234 said:

"model": "fizzyo:items/fizzyo_bow_pulling_0"

refers to items

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Posted

I am an idiot....

 

Since I thought it was referring to the texture rather than the json, i put 

2 hours ago, camcraft1234 said:

"model": "fizzyo:items/fizzyo_bow_pulling_0"

and it needed to be item rather than items because the models are in models/item

 

 

Thank you for pointing that out! Dumb mistake on my part

Posted
9 hours ago, _Cruelar_ said:

No Problem happens to me also sometimes

All will be solved in 1.13 when their dropping all the extraneous “s”s 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.