Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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));
    }

    @Override
    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);
        worldIn.addEntity(spell);
        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.register(FMLJavaModLoadingContext.get().getModEventBus());
        ENTITY_TYPES.register((FMLJavaModLoadingContext.get().getModEventBus()));
    }

    // 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);
    }

    @Override
    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);
        this.remove();
    }

    @Override
    public void tick() {
        super.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!");
    }


}

 

  • Author
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:

https://pastebin.com/suzV9HSu

Edited by thomask
new findings

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.