Jump to content

[Solved] Custom Arrow Entity not spawning


AzureZhen

Recommended Posts

Still having issues with it rendering the vanilla arrow instead of my custom entity. Posting the new code for any help. 
AgrentBolt

public class ArgentBolt extends ArrowItem {

	public ArgentBolt(Properties properties) {
		super(properties);
	}

	@Override
	@OnlyIn(Dist.CLIENT)
	public void addInformation(ItemStack stack, World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
		tooltip.add(new StringTextComponent("\u00A7o" + "Powered by Argent. Used for Ballista."));
		super.addInformation(stack, worldIn, tooltip, flagIn);
	}

	@Override
	public boolean isInfinite(ItemStack stack, ItemStack bow, net.minecraft.entity.player.PlayerEntity player) {
		int enchant = net.minecraft.enchantment.EnchantmentHelper
				.getEnchantmentLevel(net.minecraft.enchantment.Enchantments.INFINITY, bow);
		return enchant <= 0 ? false : this instanceof ArgentBolt;
	}

	@Override
	public AbstractArrowEntity createArrow(World worldIn, ItemStack stack, LivingEntity shooter) {
		ArgentBoltEntity arrowentity = new ArgentBoltEntity(worldIn, shooter);
		return arrowentity;
	}
}

ArgentBoltEntity

public class ArgentBoltEntity extends ArrowEntity  {

	public ArgentBoltEntity(EntityType<? extends ArgentBoltEntity> shooter, World worldIn) {
		super(shooter, worldIn);
	}
	
	public ArgentBoltEntity(World worldIn, LivingEntity shooter) {
		super(worldIn, shooter);
	}
	
	public ArgentBoltEntity(World world) {
        super(ModEntityTypes.ARGENT_BOLT.get(), world);
    }

	@SuppressWarnings("unchecked")
	public ArgentBoltEntity(World worldIn, EntityType<?> type) {
		super((EntityType<? extends ArrowEntity>) type, worldIn);
	}

	@Override
	protected ItemStack getArrowStack() {
		return new ItemStack(DoomItems.ARGENT_BOLT.get());
	}

	@Override
	public IPacket<?> createSpawnPacket() {
		return NetworkHooks.getEntitySpawningPacket(this);
	}
}

ArgentBoltRender

public class ArgentBoltRender extends ArrowRenderer<ArgentBoltEntity> {

	private static final ResourceLocation ARGENT_BOLT_TEXTURE = new ResourceLocation(DoomMod.MODID,
			"textures/entity/projectiles/argent_bolt.png");

	public ArgentBoltRender(EntityRendererManager renderManagerIn) {
		super(renderManagerIn);
	}

	@Override
	public ResourceLocation getEntityTexture(ArgentBoltEntity entity) {
		return ARGENT_BOLT_TEXTURE;
	}
}

It works when I do /summon dooweapon:argent_bolt but when I use the ammo with say a bow, it is still rendering the vanilla arrow. Any thoughts?

Link to comment
Share on other sites

5 hours ago, diesieben07 said:
  • Do not use @DistOnly

What is the correct thing to use thing? I don't see any issues with it and it's what Vanilla is using.

 

 

5 hours ago, diesieben07 said:
  • All your constructors must call a super constructor and pass your EntityType. You have one of them that does not do that.

Yup, that fixed it. Changed my ArgentBoltEntity to extend AbstractArrowEntity and did  
 

public ArgentBoltEntity(EntityType<?> type, World world) {
		super((EntityType<? extends AbstractArrowEntity>) type, world);
		this.referenceItem = null;
	}

Did a few other changes I found from another post here and now it's using the correct Entity when firing!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.