An instance of a class that extends Render and renders your arrow. If you want your arrow to render like the vanilla arrow with a different texture, just extend RenderArrow and override RenderArrow#getEntityTexture(EntityArrow) to return a ResourceLocation pointing to the texture.
So I need to create a new class that extends RenderArrow?
How do I replace entityarrow? my entityragearrow is located in the CustomEntities registry class
Instead of creating an instance of EntityArrow in onPlayerStoppedUsing, create an instance of EntityRageArrow. Entities aren't singletons like items and blocks, each entity in the world is its own instance of the appropriate class.
So I need to create a new class that extends RenderArrow?
If you want your arrow entity to be rendered differently to the vanilla one, yes.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
An instance of a class that extends Render and renders your arrow. If you want your arrow to render like the vanilla arrow with a different texture, just extend RenderArrow and overrideRenderArrow#getEntityTexture(EntityArrow) to return a ResourceLocation pointing to the texture.
Like this?
CustomEntities Registry:
package com.spyeedy.itemsplus;
import com.spyeedy.itemsplus.classes.rage.EntityRageArrow;
import com.spyeedy.itemsplus.classes.rage.RenderRageArrow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
public class CustomEntities {
private static int id;
public static EntityRageArrow instance;
public static String RageArrow;
public static void init() {
}
public static void register() {
EntityRegistry.registerModEntity(EntityRageArrow.class, RageArrow, id++, PlusMod.instance, 64, 20, false);
}
public static void registerRenders()
{
RenderingRegistry.registerEntityRenderingHandler(EntityRageArrow.class, RenderRageArrow.instance);
}
public static void registerRender(String string)
{
}
}
RenderRageArrow class:
package com.spyeedy.itemsplus.classes.rage;
import com.spyeedy.itemsplus.CustomEntities;
import com.spyeedy.itemsplus.weapons.RageWeapons;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderArrow;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.resources.model.ModelResourceLocation;
public class RenderRageArrow extends RenderArrow {
public static Render instance;
public RenderRageArrow(RenderManager p_i46193_1_) {
super(p_i46193_1_);
this.getEntityTexture(CustomEntities.instance);
}
}
I replaced the references to the vanilla item/entity in the 2 methods I copied into my ItemBow. I tried it in game and it seems the rage arrow is being consumed but not spawned. When I fire an arrow with the RageBow, it consumes the rage arrow item but spawns the vanilla arrow.
Here's the code:
package com.spyeedy.itemsplus.classes.rage;
import com.spyeedy.itemsplus.CustomEntities;
import com.spyeedy.itemsplus.Reference;
import com.spyeedy.itemsplus.weapons.RageWeapons;
import net.minecraft.client.resources.model.ModelResourceLocation;
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.Item;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.stats.StatList;
import net.minecraft.world.World;
public class ItemRageBow extends ItemBow {
public ItemRageBow(String unlocalizedName, ToolMaterial material) {
super();
this.setUnlocalizedName(unlocalizedName);
}
@Override
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
{
ModelResourceLocation modelresourcelocation = new ModelResourceLocation(Reference.MOD_ID + ":rage_bow", "inventory");
if(stack.getItem() == this && player.getItemInUse() != null)
{
if(useRemaining >= 18)
{
modelresourcelocation = new ModelResourceLocation(Reference.MOD_ID + ":rage_bow_pulling_2", "inventory");
}
else if(useRemaining > 13)
{
modelresourcelocation = new ModelResourceLocation(Reference.MOD_ID + ":rage_bow_pulling_1", "inventory");
}
else if(useRemaining > 0)
{
modelresourcelocation = new ModelResourceLocation(Reference.MOD_ID + ":rage_bow_pulling_0", "inventory");
}
}
return modelresourcelocation;
}
@Override
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft)
{
int j = this.getMaxItemUseDuration(stack) - timeLeft;
net.minecraftforge.event.entity.player.ArrowLooseEvent event = new net.minecraftforge.event.entity.player.ArrowLooseEvent(playerIn, stack, j);
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return;
j = event.charge;
boolean flag = playerIn.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;
if (flag || playerIn.inventory.hasItem(RageWeapons.RageArrow))
{
float f = (float)j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double)f < 0.1D)
{
return;
}
if (f > 1.0F)
{
f = 1.0F;
}
EntityRageArrow ragearrow = new EntityRageArrow(worldIn, playerIn, f * 2.0F);
if (f == 1.0F)
{
ragearrow.setIsCritical(true);
}
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
if (k > 0)
{
ragearrow.setDamage(ragearrow.getDamage() + (double)k * 0.5D + 0.5D);
}
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
if (l > 0)
{
ragearrow.setKnockbackStrength(l);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0)
{
ragearrow.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)
{
ragearrow.canBePickedUp = 2;
}
else
{
playerIn.inventory.consumeInventoryItem(RageWeapons.RageArrow);
}
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(ragearrow);
}
}
}
@Override
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(RageWeapons.RageArrow))
{
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
}
return itemStackIn;
}
}
You can't just make fields and expect them to have a value, you need to initialise them at some point. You never assign a value to RenderRageArrow.instance, so you're registering null as the renderer for your entity. This means that it's using the vanilla arrow's renderer for your arrow.
Don't call getEntityTexture in the constructor (and don't call it with null), it's doing absolutely nothing. I suggested you override this method, not call it.
Your bow code looks correct and is probably working fine, but your arrow is being rendered exactly the same as the vanilla one.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
You can't just make fields and expect them to have a value, you need to initialise them at some point. You never assign a value to RenderRageArrow.instance, so you're registering null as the renderer for your entity. This means that it's using the vanilla arrow's renderer for your arrow.
So how do I assign a value to RenderRageArrow.Instance
Quote from Choonster>>
Don't call getEntityTexture in the constructor (and don't call it with null), it's doing absolutely nothing. I suggested you override this method, not call it.
Like this?
package com.spyeedy.itemsplus.classes.rage;
import com.spyeedy.itemsplus.CustomEntities;
import com.spyeedy.itemsplus.weapons.RageWeapons;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderArrow;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.resources.model.ModelResourceLocation;
public class RenderRageArrow extends RenderArrow {
public static Render instance;
public RenderRageArrow(RenderManager p_i46193_1_) {
super(p_i46193_1_)
}
@Override
public getEntityTexture() {
return null;
}
}
So how do I assign a value to RenderRageArrow.Instance
The same way you assign a value to any other field or variable: using the assignment (=) operator. In this case, I wouldn't bother storing the instance, just create it and pass it directly to RenderingRegistry.registerEntityRenderingHandler.
That's not even valid syntax and there's no zero-argument overload of getEntityTexture. I told you exactly which overload to override in post 40.
Returning null from this method will probably break things, you need to return the ResourceLocation of your entity's texture.
At this point, I would highly recommend relearning the basics of Java. You can't make a mod if you don't know Java properly.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
what do I need to type for the ResourceLocation statement? And I'm a newbie alright
Look at what RenderArrow does: it creates a ResourceLocation with the texture's path and stores it in a static final field. It then returns this from getEntityTexture.
You should do the same, but make sure you add your mod ID as a prefix (e.g. yourmod:textures/entity/rageArrow.png for src/main/resources/assets/yourmod/textures/entity/rageArrow.png).
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
there's no zero-argument overload of getEntityTexture. I told you exactly which overload to override in post 40.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I mean that there's no overload of getEntityTexture that takes no arguments, there's only various overloads that take a single argument of type Enity or some subclass (e.g. EntityArrow in RenderArrow). Look at the RenderArrow class: it overrides the overload that takes an Entity argument and has another overload that takes an EntityArrow argument. This second method is the one you should override.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
protected ResourceLocation getEntityTexture(EntityArrow p_180550_1_)
{
return arrowTextures;
}
/**
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
*/
protected ResourceLocation getEntityTexture(Entity entity)
{
return this.getEntityTexture((EntityArrow)entity);
}
And that I was supposed to use the 2nd one? The one with this.getEntityTexture((EntityArrow)entity); as the return?
Those are the methods I'm talking about, yes. You need to override getEntityTexture(EntityArrow) to return your texture.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
The same way you assign a value to any other field or variable: using the assignment (=) operator. In this case, I wouldn't bother storing the instance, just create it and pass it directly to RenderingRegistry.registerEntityRenderingHandler.
At some point you need to learn basic Java concepts. I can't tell you how to do every little thing.
When you call a method, there's an expression for each argument. Expressions include field/variable access, method calls and object creation.
doSomething(new Foo()) creates a new instance of Foo and passes it as an argument to doSomething.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
So I need to create something similar to dosomething(new Foo()) ?
You need to create an instance of RenderRageArrow and pass it to RenderingRegistry.registerEntityRenderingHandler.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
How do I replace entityarrow? my entityragearrow is located in the CustomEntities registry class
So I need to create a new class that extends RenderArrow?
Instead of creating an instance of EntityArrow in onPlayerStoppedUsing, create an instance of EntityRageArrow. Entities aren't singletons like items and blocks, each entity in the world is its own instance of the appropriate class.
If you want your arrow entity to be rendered differently to the vanilla one, yes.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Rendered differently? How so?
Like this?
CustomEntities Registry:
RenderRageArrow class:
I replaced the references to the vanilla item/entity in the 2 methods I copied into my ItemBow. I tried it in game and it seems the rage arrow is being consumed but not spawned. When I fire an arrow with the RageBow, it consumes the rage arrow item but spawns the vanilla arrow.
Here's the code:
Where did I go wrong?
Different texture and/or model.
You can't just make fields and expect them to have a value, you need to initialise them at some point. You never assign a value to RenderRageArrow.instance, so you're registering null as the renderer for your entity. This means that it's using the vanilla arrow's renderer for your arrow.
Don't call getEntityTexture in the constructor (and don't call it with null), it's doing absolutely nothing. I suggested you override this method, not call it.
Your bow code looks correct and is probably working fine, but your arrow is being rendered exactly the same as the vanilla one.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
So how do I assign a value to RenderRageArrow.Instance
Like this?
The same way you assign a value to any other field or variable: using the assignment (=) operator. In this case, I wouldn't bother storing the instance, just create it and pass it directly to RenderingRegistry.registerEntityRenderingHandler.
That's not even valid syntax and there's no zero-argument overload of getEntityTexture. I told you exactly which overload to override in post 40.
Returning null from this method will probably break things, you need to return the ResourceLocation of your entity's texture.
At this point, I would highly recommend relearning the basics of Java. You can't make a mod if you don't know Java properly.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
what do I need to type for the ResourceLocation statement? And I'm a newbie alright
Look at what RenderArrow does: it creates a ResourceLocation with the texture's path and stores it in a static final field. It then returns this from getEntityTexture.
You should do the same, but make sure you add your mod ID as a prefix (e.g. yourmod:textures/entity/rageArrow.png for src/main/resources/assets/yourmod/textures/entity/rageArrow.png).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I did it but I am getting an error.
Code:
Error:
The method getEntityTexture() of type RenderRageArrow must override or implement a supertype method
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I don't get what you mean zero-argument overload
I mean that there's no overload of getEntityTexture that takes no arguments, there's only various overloads that take a single argument of type Enity or some subclass (e.g. EntityArrow in RenderArrow). Look at the RenderArrow class: it overrides the overload that takes an Entity argument and has another overload that takes an EntityArrow argument. This second method is the one you should override.
This tutorial explains method overriding. This tutorial explains method overloading.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
You mean this 2 arguments?
And that I was supposed to use the 2nd one? The one with this.getEntityTexture((EntityArrow)entity); as the return?
I took an attempt at follwing the second method.
Here's the code:
There was no errors, it's the correct method?
Those are the methods I'm talking about, yes. You need to override getEntityTexture(EntityArrow) to return your texture.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
How do I do that?
At some point you need to learn basic Java concepts. I can't tell you how to do every little thing.
When you call a method, there's an expression for each argument. Expressions include field/variable access, method calls and object creation.
doSomething(new Foo()) creates a new instance of Foo and passes it as an argument to doSomething.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
So I need to create something similar to dosomething(new Foo()) ?
You need to create an instance of RenderRageArrow and pass it to RenderingRegistry.registerEntityRenderingHandler.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.