Only if you want your arrow to be rendered differently to the vanilla arrow. If you don't specify a Render for an Entity class, it will inherit the Render of its parent class (if it has 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.
public static void registerRenders()
{
registerRender(RageArrow);
}
public static void registerRender(Entity item) {
}
}
Error bubble:
The method registerModEntity(Class<? extends Entity>, String, int, Object, int, int, boolean) in the type EntityRegistry is
not applicable for the arguments (Class<EntityRageArrow>, Entity, int, PlusMod, int, int, boolean)
Did I do something wrong?
Note: I shifted the RageArrow stuffs to a new class for me to create other entity stuffs in future in that class.
You need to pass a String for the entity's name, not an Entity.
You should increment the ID field (using the post-increment operator ++) with each entity you register so each one has a unique ID.
Why did you name the field Rage1? Names should reflect the purpose of the class, field, method, etc. Call it something like id or entityID.
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.
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.
<pre>class PrePostDemo {
public static void main(String[] args){
int i = 3;
i++;
// prints 4
System.out.println(i);
++i;
// prints 5
System.out.println(i);
// prints 6
System.out.println(++i);
// prints 6
System.out.println(i++);
// prints 7
System.out.println(i);
}
}
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.
Just use the post-increment operator. The class in the tutorial is a just an example program that uses the pre- and post-increment operators, you don't need the entire class in your code.
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.
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.
If you don't initialise a field, it will have its default value (null for reference types like String). Passing null to a method instead of an actual value will often throw an exception if the method wasn't expecting null. There's no need for the RageArrow field at all, just pass the name directly to EntityRegistry.registerModEntity.
Your registerRender method is doing nothing. To register an entity renderer, use 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.
so I have to create a Item class of the entity arrow to put the setCreativeTab into?
That's one option, yes.
Note the arrow Item doesn't actually do anything itself and isn't linked to the arrow Entity in any way, it's just a simple item that the bow consumes (if the player isn't in creative mode) when it spawns an arrow Entity.
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 have to extend for the arrow item? extends Item?
That will work, 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.
Quote from Choonster»
Your registerRender method is doing nothing. To register an entity renderer, use RenderingRegistry.registerEntityRenderingHandler.
What do I replace the "renderer" with and should I place it under public static void registerRenders()?
Quote from Choonster»
Do you mean bow? Just look at ItemBow and replace references to the vanilla arrow item/entity with references to your own
item/entity.
Do I use this chunk of code?
public ItemBow()
{
this.maxStackSize = 1;
this.setMaxDamage(384);
this.setCreativeTab(CreativeTabs.tabCombat);
}
/**
* Called when the player stops using an Item (stops holding the right mouse button).
*
* @param timeLeft The amount of ticks left before the using would have been complete
*/
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(Items.arrow))
{
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;
}
EntityArrow entityarrow = new EntityArrow(worldIn, playerIn, f * 2.0F);
if (f == 1.0F)
{
entityarrow.setIsCritical(true);
}
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
if (k > 0)
{
entityarrow.setDamage(entityarrow.getDamage() + (double)k * 0.5D + 0.5D);
}
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
if (l > 0)
{
entityarrow.setKnockbackStrength(l);
}
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(Items.arrow);
}
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(entityarrow);
}
}
}
If you don't initialise a field, it will have its default value (null for reference types like String). Passing null to a method instead of an actual value will often throw an exception if the method wasn't expecting null. There's no need for the RageArrow field at all, just pass the name directly to EntityRegistry.registerModEntity.
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.
If your bow's Item class extend ItemBow, you'll need to override both Item#onPlayerStoppedUsing and Item#onItemRightClick (the two methods that reference the vanilla arrow item/entity). As I said before, replace references to the vanilla arrow with references to your arrow.
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.
Do I need to registerRender the entity arrow?
Only if you want your arrow to be rendered differently to the vanilla arrow. If you don't specify a Render for an Entity class, it will inherit the Render of its parent class (if it has 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 I did the EntityRegistry statement and I seem to be receiving an error for it.
EntityRegistry class:
package com.spyeedy.itemsplus;
import com.spyeedy.itemsplus.classes.rage.EntityRageArrow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraftforge.fml.common.registry.EntityRegistry;
public class CustomEntities {
private static int Rage1;
public static Entity RageArrow;
public static void init() {
}
public static void register() {
EntityRegistry.registerModEntity(EntityRageArrow.class, RageArrow, Rage1, PlusMod.instance, 64, 20, false);
}
public static void registerRenders()
{
registerRender(RageArrow);
}
public static void registerRender(Entity item) {
}
}
Error bubble:
Did I do something wrong?
Note: I shifted the RageArrow stuffs to a new class for me to create other entity stuffs in future in that class.
You need to pass a String for the entity's name, not an Entity.
You should increment the ID field (using the post-increment operator ++) with each entity you register so each one has a unique ID.
Why did you name the field Rage1? Names should reflect the purpose of the class, field, method, etc. Call it something like id or entityID.
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 increment the ID field?
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html
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.
this was from the guide's next page
Is this the one you were saying?
That demonstrates how the pre- and post-increment operators work. Did you have trouble understanding it? Do you have some other issue?
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.
No I didn't have trouble understanding, but I'm not sure how I create the increment into my CustomEntities class, the heading stuff.
Example:
Just use the post-increment operator. The class in the tutorial is a just an example program that uses the pre- and post-increment operators, you don't need the entire class in your code.
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.
like this?
All you need is the ++ operator, not the local variable or the main method. Increment the ID field as you pass it to EntityRegistry.registerModEntity.
Assuming the field is called id:
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.
ah, thanks man. Sorry for troubling you with the field id parts.
2 questions:
Here's my code:
If you don't initialise a field, it will have its default value (null for reference types like String). Passing null to a method instead of an actual value will often throw an exception if the method wasn't expecting null. There's no need for the RageArrow field at all, just pass the name directly to EntityRegistry.registerModEntity.
Your registerRender method is doing nothing. To register an entity renderer, use RenderingRegistry.registerEntityRenderingHandler.
Do you mean bow? Just look at ItemBow and replace references to the vanilla arrow item/entity with references to your own item/entity.
Call Item#setCreativeTab in the constructor of your arrow's Item class or in the method where you instantiate your arrow Item.
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 have to create a Item class of the entity arrow to put the setCreativeTab into?
That's one option, yes.
Note the arrow Item doesn't actually do anything itself and isn't linked to the arrow Entity in any way, it's just a simple item that the bow consumes (if the player isn't in creative mode) when it spawns an arrow Entity.
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 have to extend for the arrow item? extends Item?
That will work, 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.
What do I replace the "renderer" with and should I place it under public static void registerRenders()?
Do I use this chunk of code?
Which RageArrow field were you referring to?
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.
If your bow's Item class extend ItemBow, you'll need to override both Item#onPlayerStoppedUsing and Item#onItemRightClick (the two methods that reference the vanilla arrow item/entity). As I said before, replace references to the vanilla arrow with references to your arrow.
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.