Posted June 28, 20205 yr 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!"); } }
June 28, 20205 yr 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 June 28, 20205 yr 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.