I made a texture for a custom arrow, so how do I create a custom arrow class to register it in game? Also, I would like my custom arrow shoot the custom arrow instead of the vanilla arrow, how can I do that?
First create the Item form of the arrows like you would any other item. Vanilla arrows don't even have their own class, they just use the base Item class.
Next create the Entity form of the arrows. You can probably extend EntityArrow and just override any methods you want to change the behaviour of. Make sure you register the Entity with EntityRegistry.registerModEntity, using the same tracking values as vanilla arrows do (look at the EntityArrow part of EntityTracker#trackEntity).
Finally make your bow check for and consume your arrow Item and spawn your arrow Entity instead of the vanilla ones.
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 in my item arrow class, I extend EntityArrow? So I'm importing net.minecraft.entity.projectile.EntityArrow? But which constructor should I be adding via the fixes from the error bubble?
Code's here:
package com.spyeedy.itemsplus.classes.rage;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
import net.minecraft.world.World;
public class ItemRageArrow extends EntityArrow {
public Item setUnlocalizedName(String string) {
return null;
}
}
So in my item arrow class, I extend EntityArrow? So I'm importing net.minecraft.entity.projectile.EntityArrow? But which constructor should I be adding via the fixes from the error bubble?
No, your ItemRageArrow class should extend Item (if you even need a custom class). Your EntityRageArrow class should extend EntityArrow, like I said in my post.
You should add all four constructors to EntityRageArrow, 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.
Make sure you register the Entity with EntityRegistry.registerModEntity, using the same tracking values as vanilla arrows do (look at the EntityArrow part of EntityTracker#trackEntity).
Finally make your bow check for and consume your arrow Item and spawn your arrow Entity instead of the vanilla ones.
Where am I supposed to register the Entity and how do I make my bow check for and consume my arrow Item and spawn my arrow Entity? My arrow code:
package com.spyeedy.itemsplus.weapons;
import com.spyeedy.itemsplus.PlusMod;
import com.spyeedy.itemsplus.Reference;
import com.spyeedy.itemsplus.classes.rage.EntityRageArrow;
import com.spyeedy.itemsplus.classes.rage.ItemRageArrow;
import com.spyeedy.itemsplus.classes.rage.ItemRageBow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class RageWeapons {
public static ToolMaterial Rage = EnumHelper.addToolMaterial("Rage", 3, -1, 15.0F, 4.0F, 30);
public static Item RageBow;
public static Item RageArrow;
public static void init() {
RageBow = new ItemRageBow("rage_bow", Rage).setUnlocalizedName("rage_bow").setCreativeTab(PlusMod.tabWeaponPlus);
RageArrow = new ItemRageArrow();
}
public static void register() {
GameRegistry.registerItem(RageBow, RageBow.getUnlocalizedName().substring(5));
}
public static void registerRenders()
{
ModelBakery.addVariantName(RageBow, new String[] {Reference.MOD_ID + ":rage_bow", Reference.MOD_ID + ":rage_bow_pulling_0", Reference.MOD_ID + ":rage_bow_pulling_1", Reference.MOD_ID + ":rage_bow_pulling_2"});
registerRender(RageBow);
}
private static void registerRender(Item item) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "Inventory"));
}
}
EntityRageBow class:
package com.spyeedy.itemsplus.classes.rage;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.world.World;
public class EntityRageArrow extends EntityArrow {
public EntityRageArrow(World worldIn) {
super(worldIn);
}
public EntityRageArrow(World worldIn, double x, double y, double z) { super(worldIn, x, y, z);
}
public EntityRageArrow(World worldIn, EntityLivingBase shooter, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) {
super(worldIn, shooter, p_i1755_3_, p_i1755_4_, p_i1755_5_);
}
public EntityRageArrow(World worldIn, EntityLivingBase shooter, float p_i1756_3_) {
super(worldIn, shooter, p_i1756_3_);
}
}
To make your bow use your arrow, look for the usages of Items.arrow and EntityArrow in ItemBow. Override the methods that use these to do the same thing with 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.
Where do I register the entity and how? Do I register it in my main class where all my other items/blocks are registered or that weapon class where my bow is registered?
I'd suggest having one class each for items, blocks and entities (using a naming scheme like ModItems or ItemsPlusItems) and handling all the registration (apart from rendering/models) in those classes. I explained how to register your entity in post #2.
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.
package com.spyeedy.itemsplus.classes.rage;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.world.World;
public class EntityRageArrow extends EntityArrow {
public EntityRageArrow(World worldIn) {
super(worldIn);
}
public EntityRageArrow(World worldIn, double x, double y, double z) { super(worldIn, x, y, z);
}
public EntityRageArrow(World worldIn, EntityLivingBase shooter, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) {
super(worldIn, shooter, p_i1755_3_, p_i1755_4_, p_i1755_5_);
}
public EntityRageArrow(World worldIn, EntityLivingBase shooter, float p_i1756_3_) {
super(worldIn, shooter, p_i1756_3_);
}
}
So the part now that I am having trouble is which values should I use to add into the EntityRegistry.registerModEntity? The values from Screenshot 1 or Screenshot 2?
Entities aren't singletons, don't create an instance during the loading process. EntityRegistry.registerModEntity takes the entity class's Class object, not an instance of the class.
There are no values in screenshot 1, that's just the method signature. The values you want are the trackingRange, updateFrequency and sendVelocityUpdates arguments from screenshot 2 (i.e. the last three values passed to addEntityToTracker).
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.
Entities aren't singletons, don't create an instance during the loading process. EntityRegistry.registerModEntity takes the entity class's Class object, not an instance of the class.
What's that supposed to mean and where should I place EntityRegistry.registerModEntity instead?
You can get the Class object of a class from the .class keyword, e.g. EntityRegistry.registerModEntity(MyEntity.class, "MyEntity", ...).
If RageWeapons.register is called from your @Mod class in the preInit phase, the EntityRegistry.registerModEntity call is in the correct place.
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.
id is the mod-unique ID of the entity. You can create an int field in your entity registration class to use as the ID and increment it each time you register an entity.
mod is the instance of your @Mod class. If you create a static field in this class with the @Mod.Instance annotation, FML with populate it with the instance it creates.
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.
id is the mod-unique ID of the entity. You can create an int field in your entity registration class to use as the ID and increment it each time you register an entity.
mod is the instance of your @Mod class. If you create a static field in this class with the @Mod.Instance annotation, FML with populate it with the instance it creates.
How do I create an int field and my entity registration class is my EntityRageArrow.class?
How do I create a static field for the Instance annotation?
Does it starts with public static final?
And which argument should I add to match the EntityRageArrow's constructs in my public static void init of my RageWeapons class? I attached a screenshot of the arguments they want me to match to.
The entity registration class is the class in which you register your entities; in this case, RageWeapons. The technique I mentioned only works if you're registering your entities from a single class or call a single method to register every entity.
Do you not understand what a field is and what static means? These are extremely basic Java concepts.
By int field, I mean a field with type int. The instance field should be static and have the class with the @Mod annotation as its type (since it will hold an instance of that class). Annotate it with @Mod.Instance(Reference.MOD_ID).
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.
That will work; but field, method, argument and variable names should be in camelCase (i.e. instance instead of Instance). Only class names should be in PascalCase.
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.
Which argument should I add to match the EntityRageArrow's constructs in my public static void init of my RageWeapons class? I attached a screenshot of the arguments they want me to match to.
Which argument should I add to match the EntityRageArrow's constructs in my public static void init of my RageWeapons class? I attached a screenshot of the arguments they want me to match to.
Entities aren't singletons, don't create an instance during the loading process. EntityRegistry.registerModEntity takes the entity class's Class object, not an instance of the class.
The ID is just an integer, it can be anything. Every entity type within your mod needs to have a unique ID. I suggested a technique for ensuring unique IDs in my previous post.
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 made a texture for a custom arrow, so how do I create a custom arrow class to register it in game? Also, I would like my custom arrow shoot the custom arrow instead of the vanilla arrow, how can I do that?
First create the Item form of the arrows like you would any other item. Vanilla arrows don't even have their own class, they just use the base Item class.
Next create the Entity form of the arrows. You can probably extend EntityArrow and just override any methods you want to change the behaviour of. Make sure you register the Entity with EntityRegistry.registerModEntity, using the same tracking values as vanilla arrows do (look at the EntityArrow part of EntityTracker#trackEntity).
Finally make your bow check for and consume your arrow Item and spawn your arrow Entity instead of the vanilla ones.
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 in my item arrow class, I extend EntityArrow? So I'm importing net.minecraft.entity.projectile.EntityArrow? But which constructor should I be adding via the fixes from the error bubble?
Code's here:
And the 4 constructors in the error bubble:
No, your ItemRageArrow class should extend Item (if you even need a custom class). Your EntityRageArrow class should extend EntityArrow, like I said in my post.
You should add all four constructors to EntityRageArrow, 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.
Where am I supposed to register the Entity and how do I make my bow check for and consume my arrow Item and spawn my arrow Entity?
My arrow code:
EntityRageBow class:
Register the entity in preInit.
To make your bow use your arrow, look for the usages of Items.arrow and EntityArrow in ItemBow. Override the methods that use these to do the same thing with 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.
Where do I register the entity and how? Do I register it in my main class where all my other items/blocks are registered or that weapon class where my bow is registered?
I'd suggest having one class each for items, blocks and entities (using a naming scheme like ModItems or ItemsPlusItems) and handling all the registration (apart from rendering/models) in those classes. I explained how to register your entity in post #2.
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 that and here's the code.
Weapon Registry class:
EntityArrow class:
So the part now that I am having trouble is which values should I use to add into the EntityRegistry.registerModEntity? The values from Screenshot 1 or Screenshot 2?
Screenshot 1:
Screenshot 2:
Entities aren't singletons, don't create an instance during the loading process. EntityRegistry.registerModEntity takes the entity class's Class object, not an instance of the class.
There are no values in screenshot 1, that's just the method signature. The values you want are the trackingRange, updateFrequency and sendVelocityUpdates arguments from screenshot 2 (i.e. the last three values passed to addEntityToTracker).
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's that supposed to mean and where should I place EntityRegistry.registerModEntity instead?
You can get the Class object of a class from the .class keyword, e.g. EntityRegistry.registerModEntity(MyEntity.class, "MyEntity", ...).
If RageWeapons.register is called from your @Mod class in the preInit phase, the EntityRegistry.registerModEntity call is in the correct place.
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.
Yup, RageWeapons.register is in the preInit phase.
So I changed the values as you said so what I should I fill in place of "id" & "mod"?
And do I need to registerRender my custom arrow?
id is the mod-unique ID of the entity. You can create an int field in your entity registration class to use as the ID and increment it each time you register an entity.
mod is the instance of your @Mod class. If you create a static field in this class with the @Mod.Instance annotation, FML with populate it with the instance it creates.
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 create an int field and my entity registration class is my EntityRageArrow.class?
How do I create a static field for the Instance annotation?
Does it starts with public static final?
And which argument should I add to match the EntityRageArrow's constructs in my public static void init of my RageWeapons class? I attached a screenshot of the arguments they want me to match to.
The entity registration class is the class in which you register your entities; in this case, RageWeapons. The technique I mentioned only works if you're registering your entities from a single class or call a single method to register every entity.
Do you not understand what a field is and what static means? These are extremely basic Java concepts.
By int field, I mean a field with type int. The instance field should be static and have the class with the @Mod annotation as its type (since it will hold an instance of that class). Annotate it with @Mod.Instance(Reference.MOD_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.
Is it supposed to be like this?
That will work; but field, method, argument and variable names should be in camelCase (i.e. instance instead of Instance). Only class names should be in PascalCase.
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.
Which argument should I add to match the EntityRageArrow's constructs in my public static void init of my RageWeapons class? I attached a screenshot of the arguments they want me to match to.
And how do I create an id for my EntityRageArrow?
---------
The ID is just an integer, it can be anything. Every entity type within your mod needs to have a unique ID. I suggested a technique for ensuring unique IDs in my previous post.
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.