Everything posted by Monstrous_Apple
-
[1.8.9] Bow Pull Back Help
Yeah I'm sorry I still have a lot to learn in java, could you give me a bit of extra help on this? Sorry again
-
[1.8.9] Bow Pull Back Help
Is any of these correct for the "model" part? private void registerItemModel(Item item, ModelResourceLocation modelResourceLocation) { ModelLoader.setCustomModelResourceLocation(MAItems.ObsidianBow, 0, modelResourceLocation = assets.ma.models/item/ObsidianBow_pulling_0.json); } or: private void registerItemModel(Item item, ModelResourceLocation modelResourceLocation) { ModelLoader.setCustomModelResourceLocation(MAItems.ObsidianBow, 0, Model == assets.ma.models/item/ObsidianBow_pulling_0.json); }
-
[1.8.9] Bow Pull Back Help
Oh right sorry I forgot about the model... memory sucks and all... sorry gimmie a sec
-
[1.8.9] Bow Pull Back Help
Okay so is this correct so far? Also what do I put for the model? Is it "ObsidianBow_pulling_0"? private void registerItemModel(Item item, ModelResourceLocation modelResourceLocation) { ModelLoader.setCustomModelResourceLocation(MAItems.ObsidianBow, 0, model); }
-
[1.8.9] Bow Pull Back Help
For the first part can you give me a bit more detail like a example or something? I'm not good at this sorry and for the second part is this what's needed?: private void registerItemModel(Item item, ModelResourceLocation modelResourceLocation) { } If it is what do I put inside it and if not then I'm clueless again, sorry.
-
[1.8.9] Bow Pull Back Help
Okay sorry and it didn't crash or anything even when shooting the bow, but I'll show you what the console said: Also when hovering over the errors in eclipse it says for the first error: "The method getModelLocation() is underfined for the type Item" and for the second "The method registerItemModel(Item, ResourceLocation) is undefined for the type ClientProxy"
-
[1.8.9] Bow Pull Back Help
Sorry my bad I changed it to MAObsidianBow now also I copied it in and am trying to understand it but I'm finding this part hard Edit: getModelLocation and registerItemModel are to two parts I'm getting an error on, it's asking me to "Add cast to method receiver" for the first error and for the second it's asking me to "Create method 'registerItemModel(Item, ModelResourceLocation)' "
-
[1.8.9] Bow Pull Back Help
Thanks for all the help, and i did what you said but I got an error here: String locationBow = MAItems.ObsidianBow.getModelLocation(); and here: registerItemModel(MAItems.ObsidianBow, new ModelResourceLocation(locationBow, "standby")); Also: ClientProxy: import com.MonstrousApple.mod.items.MAItems; import com.MonstrousApple.mod.render.MABlockRender; import com.MonstrousApple.mod.render.MAGemRender; import com.MonstrousApple.mod.render.MAItemRender; import com.MonstrousApple.mod.render.MAOreRender; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class ClientProxy extends CommonProxy { public void preInit(FMLPreInitializationEvent preEvent) { super.preInit(preEvent); ModelBakery.registerItemVariants(MAItems.ObsidianBow, new ModelResourceLocation(MAItems.ObsidianBow.getRegistryName(), "ObsidianBow")); ModelBakery.registerItemVariants(MAItems.ObsidianBow, new ModelResourceLocation(MAItems.ObsidianBow.getRegistryName(), "ObsidianBow_pulling_0")); ModelBakery.registerItemVariants(MAItems.ObsidianBow, new ModelResourceLocation(MAItems.ObsidianBow.getRegistryName(), "ObsidianBow_pulling_1")); ModelBakery.registerItemVariants(MAItems.ObsidianBow, new ModelResourceLocation(MAItems.ObsidianBow.getRegistryName(), "ObsidianBow_pulling_2")); } private void registerItemModels() { String locationBow = MAItems.ObsidianBow.getModelLocation(); for (int stage = 0; stage < 3; stage++) { // Add a variant for each stage's model ModelBakery.registerItemVariants(MAItems.ObsidianBow, new ModelResourceLocation(locationBow, "pulling_" + stage)); } registerItemModel(MAItems.ObsidianBow, new ModelResourceLocation(locationBow, "standby")); } public void init(FMLInitializationEvent event) { super.init(event); MABlockRender.registerBlockRender(); MAItemRender.registerItemRender(); MAOreRender.registerOreRender(); MAGemRender.registerGemRender(); } public void postInit(FMLPostInitializationEvent postEvent) { super.postInit(postEvent); } } Blockstates: (What would I change "testmod3" to? { "forge_marker": 1, "defaults": { "model": "testmod3:simple_model" }, "variants": { "standby": [ { "textures": { "layer0": "items/bow_standby" } } ], "pulling_0": [ { "textures": { "layer0": "items/bow_pulling_0" } } ], "pulling_1": [ { "textures": { "layer0": "items/bow_pulling_1" } } ], "pulling_2": [ { "textures": { "layer0": "items/bow_pulling_2" } } ] } } Bow Class: (MAObsidianBow.java) package com.MonstrousApple.mod.items.rangedweapons; import com.MonstrousApple.mod.MACreativeTabRangingWeapons; import com.MonstrousApple.mod.MAGlobal; import com.MonstrousApple.mod.items.MAItems; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.stats.StatList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class MAObsidianBow extends Item { public MAObsidianBow(String unlocalizedName) { this.setUnlocalizedName(unlocalizedName); this.setCreativeTab(MAGlobal.maCreativeTabRangingWeapons); //Maximum Amount In One Slot - Stack Size this.maxStackSize = 1; //Durability - How many uses this.setMaxDamage(2341); } /** * Get the location of the blockstates file used for this item's models * * @return The location */ public String getModelLocation() { return getRegistryName(); } @SideOnly(Side.CLIENT) @Override public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) { if (player.isUsingItem()) { int useTime = stack.getMaxItemUseDuration() - useRemaining; if (useTime >= 18) { return new ModelResourceLocation(getModelLocation(), "pulling_2"); } else if (useTime > 13) { return new ModelResourceLocation(getModelLocation(), "pulling_1"); } else if (useTime > 0) { return new ModelResourceLocation(getModelLocation(), "pulling_0"); } } return null; } //{ //final String[] bowPullIconNameArray = new String[] {"bow_pulling_0", "bow_pulling_1", "bow_pulling_2"}; //} /** * Called when the player stops using an Item (stops holding the right mouse button). */ public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft) { boolean flag = playerIn.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0; if (flag || playerIn.inventory.hasItem(MAItems.ObsidianArrow)) { int i = this.getMaxItemUseDuration(stack) - timeLeft; net.minecraftforge.event.entity.player.ArrowLooseEvent event = new net.minecraftforge.event.entity.player.ArrowLooseEvent(playerIn, stack, i); if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; i = event.charge; float f = (float)i / 20.0F; f = (f * f + f * 2.0F) / 3.0F; if ((double)f < 0.1D) { return; } if (f > 1.0F) { f = 1.0F; } EntityArrow entityarrow = new EntityArrow(worldIn, playerIn, f * 2.0F); if (f == 1.0F) { entityarrow.setIsCritical(true); } int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack); if (j > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double)j * 0.5D + 0.5D); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack); if (k > 0) { entityarrow.setKnockbackStrength(k); } if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0) { entityarrow.setFire(100); } stack.damageItem(1, playerIn); worldIn.playSoundAtEntity(playerIn, "random.bow", 1.0F, 1.0F); // /(itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (flag) { entityarrow.canBePickedUp = 2; } else { playerIn.inventory.consumeInventoryItem(MAItems.ObsidianArrow); } //playerIn.triggerAchievement(StatList.objectUseStats[item.getIdFromItem(this)]); if (!worldIn.isRemote) { worldIn.spawnEntityInWorld(entityarrow); } } } /** * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using * the Item before the action is complete. */ public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn) { return stack; } /** * 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 whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { net.minecraftforge.event.entity.player.ArrowNockEvent event = new net.minecraftforge.event.entity.player.ArrowNockEvent(playerIn, itemStackIn); if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return event.result; if (playerIn.capabilities.isCreativeMode || playerIn.inventory.hasItem(MAItems.ObsidianArrow)) { playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn)); } return itemStackIn; } /** * Return the enchantability factor of the item, most of the time is based on material. */ public int getItemEnchantability() { return 1; } }
-
[1.8.9] Bow Pull Back Help
Is it okay if you give me an example in code please? Or do you mean something like this? assets.ma.models/item/IronBow_pulling_0.json
-
[1.8.9] Bow Pull Back Help
Okay I tried doing the blockstates way but that don't work so how do I change it to a different path?
-
[1.8.9] Bow Pull Back Help
Oh so I need to just move my json files to block states instead?
-
[1.8.9] Bow Pull Back Help
How does it not?
-
[1.8.9] Bow Pull Back Help
Named; "IronBow.json" Named; "IronBow_pulling_0" Named; "IronBow_pulling_1" Named; "IronBow_pulling_2"
-
[1.8.9] Bow Pull Back Help
Is there anything wrong in here? Client Proxy: package com.MonstrousApple.mod.proxy; import com.MonstrousApple.mod.items.MAItems; import com.MonstrousApple.mod.render.MABlockRender; import com.MonstrousApple.mod.render.MAGemRender; import com.MonstrousApple.mod.render.MAItemRender; import com.MonstrousApple.mod.render.MAOreRender; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class ClientProxy extends CommonProxy { public void preInit(FMLPreInitializationEvent preEvent) { super.preInit(preEvent); ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation(MAItems.IronBow.getRegistryName(), "IronBow")); ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation(MAItems.IronBow.getRegistryName(), "IronBow_pulling_0")); ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation(MAItems.IronBow.getRegistryName(), "IronBow_pulling_1")); ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation(MAItems.IronBow.getRegistryName(), "IronBow_pulling_2")); //ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation(getModelLocation(), "IronBow_pulling_1")); //ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation(getModelLocation(), "IronBow_pulling_0")); //new ModelResourceLocation(MAItems.ObsidianBow.getRegistryName(), "IronBow_pulling_2") } public void init(FMLInitializationEvent event) { super.init(event); MABlockRender.registerBlockRender(); MAItemRender.registerItemRender(); MAOreRender.registerOreRender(); MAGemRender.registerGemRender(); } public void postInit(FMLPostInitializationEvent postEvent) { super.postInit(postEvent); } } Bow: package com.MonstrousApple.mod.items.rangedweapons; import com.MonstrousApple.mod.MACreativeTabRangingWeapons; import com.MonstrousApple.mod.MAGlobal; import com.MonstrousApple.mod.items.MAItems; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemBow; import net.minecraft.stats.StatList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class MAIronBow extends ItemBow { public MAIronBow(String unlocalizedName) { this.setUnlocalizedName(unlocalizedName); this.setCreativeTab(MAGlobal.maCreativeTabRangingWeapons); //Maximum Amount In One Slot - Stack Size this.maxStackSize = 1; //Durability - How many uses this.setMaxDamage(250); //this.setMaxDamage(3); } /** * Get the location of the blockstates file used for this item's models * * @return The location */ public String getModelLocation() { return getRegistryName(); } @SideOnly(Side.CLIENT) @Override public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) { if (player.isUsingItem()) { int useTime = stack.getMaxItemUseDuration() - useRemaining; if (useTime >= 18) { return new ModelResourceLocation(getModelLocation(), "IronBow_pulling_2"); } else if (useTime > 13) { return new ModelResourceLocation(getModelLocation(), "IronBow_pulling_1"); } else if (useTime > 0) { return new ModelResourceLocation(getModelLocation(), "IronBow_pulling_0"); } } return null; } { final String[] bowPullIconNameArray = new String[] {"IronBow_pulling_0", "IronBow_pulling_1", "IronBow_pulling_2"}; } /** * Called when the player stops using an Item (stops holding the right mouse button). */ public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft) { boolean flag = playerIn.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0; if (flag || playerIn.inventory.hasItem(MAItems.IronArrow)) { int i = this.getMaxItemUseDuration(stack) - timeLeft; net.minecraftforge.event.entity.player.ArrowLooseEvent event = new net.minecraftforge.event.entity.player.ArrowLooseEvent(playerIn, stack, i); if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; i = event.charge; float f = (float)i / 20.0F; f = (f * f + f * 2.0F) / 3.0F; if ((double)f < 0.1D) { return; } if (f > 1.0F) { f = 1.0F; } EntityArrow entityarrow = new EntityArrow(worldIn, playerIn, f * 2.0F); if (f == 1.0F) { entityarrow.setIsCritical(true); } int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack); if (j > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double)j * 0.5D + 0.5D); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack); if (k > 0) { entityarrow.setKnockbackStrength(k); } if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0) { entityarrow.setFire(100); } stack.damageItem(1, playerIn); worldIn.playSoundAtEntity(playerIn, "random.bow", 1.0F, 1.0F); // /(itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (flag) { entityarrow.canBePickedUp = 2; } else { playerIn.inventory.consumeInventoryItem(MAItems.IronArrow); } playerIn.triggerAchievement(StatList.objectUseStats[item.getIdFromItem(this)]); if (!worldIn.isRemote) { worldIn.spawnEntityInWorld(entityarrow); } } } /** * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using * the Item before the action is complete. */ public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn) { return stack; } /** * 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 whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { net.minecraftforge.event.entity.player.ArrowNockEvent event = new net.minecraftforge.event.entity.player.ArrowNockEvent(playerIn, itemStackIn); if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return event.result; if (playerIn.capabilities.isCreativeMode || playerIn.inventory.hasItem(MAItems.IronArrow)) { playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn)); } return itemStackIn; } /** * Return the enchantability factor of the item, most of the time is based on material. */ public int getItemEnchantability() { return 1; } }
-
[1.8.9] Bow Pull Back Help
Okay now when I pull it back it renders as if my bow was in standby phase and doesn't switch between the pulling stages and also when I actually hold my bow it has no texture..? Thanks for helping by the way and yeah I will be learning more of java real soon... sorry about that, but anyway do you know why this problem is happening? ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation(MAItems.IronBow.getRegistryName(), "IronBow")); ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation(MAItems.IronBow.getRegistryName(), "IronBow_pulling_0")); ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation(MAItems.IronBow.getRegistryName(), "IronBow_pulling_1")); ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation(MAItems.IronBow.getRegistryName(), "IronBow_pulling_2"));
-
[1.8.9] Bow Pull Back Help
Sorry I'm extremely tired at the moment, is it alright if you give me an example code? It's basically 2 for me, sorry.
-
[1.8.9] Bow Pull Back Help
I know that but I'm saying I don't know what to do with that code to make mine work...
-
[1.8.9] Bow Pull Back Help
Well this is the code from ModelResourceLocation and yeah I have still got no clue what to do... package net.minecraft.client.resources.model; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.StringUtils; @SideOnly(Side.CLIENT) public class ModelResourceLocation extends ResourceLocation { private final String variant; protected ModelResourceLocation(int p_i46078_1_, String... p_i46078_2_) { super(0, new String[] {p_i46078_2_[0], p_i46078_2_[1]}); this.variant = StringUtils.isEmpty(p_i46078_2_[2]) ? "normal" : p_i46078_2_[2].toLowerCase(); } public ModelResourceLocation(String p_i46079_1_) { this(0, parsePathString(p_i46079_1_)); } public ModelResourceLocation(ResourceLocation p_i46080_1_, String p_i46080_2_) { this(p_i46080_1_.toString(), p_i46080_2_); } public ModelResourceLocation(String p_i46081_1_, String p_i46081_2_) { this(0, parsePathString(p_i46081_1_ + '#' + (p_i46081_2_ == null ? "normal" : p_i46081_2_))); } protected static String[] parsePathString(String p_177517_0_) { String[] astring = new String[] {null, p_177517_0_, null}; int i = p_177517_0_.indexOf(35); String s = p_177517_0_; if (i >= 0) { astring[2] = p_177517_0_.substring(i + 1, p_177517_0_.length()); if (i > 1) { s = p_177517_0_.substring(0, i); } } System.arraycopy(ResourceLocation.splitObjectName(s), 0, astring, 0, 2); return astring; } public String getVariant() { return this.variant; } public boolean equals(Object p_equals_1_) { if (this == p_equals_1_) { return true; } else if (p_equals_1_ instanceof ModelResourceLocation && super.equals(p_equals_1_)) { ModelResourceLocation modelresourcelocation = (ModelResourceLocation)p_equals_1_; return this.variant.equals(modelresourcelocation.variant); } else { return false; } } public int hashCode() { return 31 * super.hashCode() + this.variant.hashCode(); } public String toString() { return super.toString() + '#' + this.variant; } }
-
[1.8.9] Bow Pull Back Help
Okay so I get an error on getModelLocation and it says to "Create method 'getModelLocation()'" which is then what I do, and now there's no errors however when I run Minecraft it crashes and I get this error:
-
[1.8.9] Bow Pull Back Help
Which is?
-
[1.8.9] Bow Pull Back Help
Not al all, but anyway what do I do then?
-
[1.8.9] Bow Pull Back Help
All I can see is that the getModelLocation is gone which is what made it have no errors, what am I missing here?
-
[1.8.9] Bow Pull Back Help
What in my main items class?Where I register them etc?
-
[1.8.9] Bow Pull Back Help
Okay look this has no errors however now when I use my bow it has no standby texture and still no pull back textures? ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation("IronBow_standby")); ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation("IronBow_pulling_0")); ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation("IronBow_pulling_1")); ModelBakery.registerItemVariants(MAItems.IronBow, new ModelResourceLocation("IronBow_pulling_2")); And yeah it's not hard for you, but that doesn't mean it won't be for others, if everything was easy and should be known for all java coders and minecraft modders, there wouldn't be a modder support section in the first place.
-
[1.8.9] Bow Pull Back Help
Instead of being rude you could actually give clear instructions, you said copy and paste it, not copy and paste it then remove, this and that... common.
IPS spam blocked by CleanTalk.