I created a custom bow that uses my modded arrows. It worked with checking for the custom arrows, and even subtracting them from the stack, but on firing the bow, it just shoots a normal MC arrow, and it picks a normal arrow up from the ground.
I figured the only way for it to shoot a new type of arrow was to create new ItemArrow and EntityArrow classes, which I have done. However, now the bow doesn't fire ANY arrow when I shoot it. I'm baffled by why this is the case now. Does anyone know anything about custom bows and arrows?
Here are the pastebins for all three classes used. I'd love to figure out why this isn't working.
Am I not supposed to have this as abstract? EntityArrow is abstract, which means I should have the class extending abstract, too, right?
Also, this should cover the custom entity already, right?
No, your arrow should not be abstract. An abstract class is used when one wants to define default behaviour (methods and/or fields) for its subclasses. EntityArrow is abstract for that purpose. So, make your arrow entity non-abstract and return its instance in "createArrow".
You need to register the arrow entity class by using EntityRegistry#registerModEntity(net.minecraft.util.ResourceLocation, java.lang.Class<? extends net.minecraft.entity.Entity>, java.lang.String, int, java.lang.Object, int, int, boolean) during Preinitialization.If after that the entity is not being rendered properly, also register a rendering handler using RenderingRegistry#registerEntityRenderingHandler (during Preinit., too).
Okay, I fixed the issue. Instead of making a new class that extends EntityArrow, I made a new class that extends EntityTippedArrow, and used that to change what I needed.
I created a custom bow that uses my modded arrows. It worked with checking for the custom arrows, and even subtracting them from the stack, but on firing the bow, it just shoots a normal MC arrow, and it picks a normal arrow up from the ground.
I figured the only way for it to shoot a new type of arrow was to create new ItemArrow and EntityArrow classes, which I have done. However, now the bow doesn't fire ANY arrow when I shoot it. I'm baffled by why this is the case now. Does anyone know anything about custom bows and arrows?
Here are the pastebins for all three classes used. I'd love to figure out why this isn't working.
Bow: https://pastebin.com/UX1KQZtY
Arrow: https://pastebin.com/8SBffjUu
Entity: https://pastebin.com/MKa1476m
You call:
BronzeArrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer);
But your method returns null:
public BronzeArrow createArrow(World worldIn, ItemStack itemstack, EntityPlayer entityplayer) {
return null;
}
The original code is:
If I have no EntityTippedArrow for my custom arrow, what should I be using for the return value instead? I figured null was fine.
Your custom arrow entity, I presume. But your BronzeArrow is abstract, why is that? Do you have a subclass of it?
Am I not supposed to have this as abstract? EntityArrow is abstract, which means I should have the class extending abstract, too, right?
Also, this should cover the custom entity already, right?
No, your arrow should not be abstract. An abstract class is used when one wants to define default behaviour (methods and/or fields) for its subclasses. EntityArrow is abstract for that purpose. So, make your arrow entity non-abstract and return its instance in "createArrow".
Eclipse is telling me
"The type BronzeArrow must be an abstract class to define abstract methods"
when I remove abstract.
Everytime I try to fire the bow in-game, it says there's an error at this line in ShortbowNormal:
Then you must override abstract methods of the EntityArrow - there is only one, I believe, it's named "getArrowStack".
I added a return method to ArrowBronze
and changed BronzeArrow to be non-abstract. The problem is now this though:
Caused by: java.lang.IllegalArgumentException: Don't know how to add class orescape.mod.entity.BronzeArrow!
It's happening at this line in ShortbowNormal:
I apologize for any inconvenience. I'm still new to all this.
You need to register the arrow entity class by using EntityRegistry#registerModEntity(net.minecraft.util.ResourceLocation, java.lang.Class<? extends net.minecraft.entity.Entity>, java.lang.String, int, java.lang.Object, int, int, boolean) during Preinitialization. If after that the entity is not being rendered properly, also register a rendering handler using RenderingRegistry#registerEntityRenderingHandler (during Preinit., too).
Okay, I fixed the issue. Instead of making a new class that extends EntityArrow, I made a new class that extends EntityTippedArrow, and used that to change what I needed.