Jump to content

Issues with my projectile


Recommended Posts

Hey everybody, I have an entity based off of ArrowEntity that doesn't seem to be spawning. When I trigger onPlayerStoppedUsing it doesnt do anything. It does print the debug message "player stopped using staff" but nothing else

I'm 99% sure the issue is with the way I register it because mostly everything was working before I messed with that. I was trying to create my own EntityType as before I was using a constructor that didn't take EntityType as an argument to spawn my entity.

Here is how I'm spawning my entity:

public class ExplosionStaff extends BowItem {

    public ExplosionStaff() {
        super(new Item.Properties().group(ItemGroup.COMBAT));

    public void onPlayerStoppedUsing(ItemStack stack, World worldIn, LivingEntity playerIn, int timeLeft) {
        ExplosionSpellEntity spell = new ExplosionSpellEntity(RegistryHandler.SPELL_ENTITY.get(), worldIn);
        int i = this.getUseDuration(stack) - timeLeft;
        float f = super.getArrowVelocity(i);
        spell.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, f * 4.0F, 0.2F);
        System.out.println("Debug: player stopped using staff");


How I'm registering the entity: 

public class RegistryHandler {

    public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, Megumin.MOD_ID);
    public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = new DeferredRegister<>(ForgeRegistries.ENTITIES, Megumin.MOD_ID);

    public static void init() {

    // Items
    public static final RegistryObject<Item> STAFF = ITEMS.register("explosion_staff", ExplosionStaff::new);
    public static final RegistryObject<EntityType<ExplosionSpellEntity>> SPELL_ENTITY = ENTITY_TYPES.register("spell",
            () -> EntityType.Builder.<ExplosionSpellEntity>create(ExplosionSpellEntity::new, EntityClassification.MISC)
                    .size(1f, 2f).build(new ResourceLocation(Megumin.MOD_ID, "spell").toString()));


The actual entity:

public class ExplosionSpellEntity extends ArrowEntity {

    public ExplosionSpellEntity(EntityType<? extends ArrowEntity> type, World worldIn) {
        super(type, worldIn);

    public ExplosionSpellEntity(World worldIn, double x, double y, double z) {
        super(worldIn, x, y, z);

    public ExplosionSpellEntity(World worldIn, LivingEntity shooter) {
        super(worldIn, shooter);

    public void onHit(RayTraceResult raytraceResultIn) {
        System.out.println("Debug: spell entity hit");
        this.world.createExplosion(this, this.getPosX(), this.getPosY(), this.getPosZ(), 20, false, Explosion.Mode.DESTROY);

    public void tick() {
        Vec3d vec3d = this.getMotion();
        double d3 = vec3d.x;
        double d4 = vec3d.y;
        double d0 = vec3d.z;
        double d5 = this.getPosX() + d3;
        double d1 = this.getPosY() + d4;
        double d2 = this.getPosZ() + d0;
        this.world.addParticle(ParticleTypes.HEART, d5 - d3 * 0.25D, d1 - d4 * 0.25D, d2 - d0 * 0.25D, d3, d4, d0);

        System.out.println("DEBUG: arrow tick!");



Link to comment
Share on other sites

4 hours ago, poopoodice said:

Is it not spawning or not being rendered?

I'm guessing it's not spawning? Because the arrow is supposed to create an explosion but it's not happening.



UPDATE: I've tried using /summon to spawn my entity and my game crashes. Here's what happens:


Edited by thomask
new findings
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.

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.


  • Create New...

Important Information

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