event.create("cryony", "bow")
		.tooltip('§bFreezes targets')
		.unstackable()
		.maxDamage(448) // Durability
		.bow(bow => {
			bow.modifyBow(attributes => {
				attributes
					.fullChargeTick(2) // In ticks
					.baseDamage(1) //(the default is 2.0)

			})
				.onArrowHit(arrow => {
					arrow.postHurtEffect((/**@type {Internal.LivingEntity} */ livingEntity) => {
						livingEntity.potionEffects.add('slowness', 60, 2) //add effect to entity hit by arrows
						livingEntity.potionEffects.add('simplyswords:freeze', 12) //add effect to entity hit by arrows
					})
				})
		})

StartupEvents.registry('entity_type', event => {
    event.create('spiked_ice_ball', 'entityjs:projectile')
        /**
         * One-Off values set at the startup of the game.
         */
        .clientTrackingRange(64)
        .isAttackable(false)
        .mobCategory('misc')
        .item(item => {
            item.canThrow(true)
            item.maxStackSize(16);
        })
        .sized(1, 1)
        .renderOffset(0, 0, 0)
        .renderScale(1, 1, 1)
        .updateInterval(3)

        .shouldRenderAtSqrDistance(context => {
            const { entity, distanceToPlayer } = context;
            // Custom logic to determine if the arrow should render based on distance, for example, rendering only if distance is less than 100 blocks
            return distanceToPlayer < 100;
        })

        /**
         * All methods below return void meaning they don't require a set return value to function.
         * These mostly are similar to KubeJS' normal events where you may do things on certain events your entities call!
         */

        .textureLocation(entity => {
            return "kubejs:textures/entity/projectiles/spiked_ice_ball.png"
        })

        .move(context => {
            const { entity, moverType, position } = context;
            // Custom movement logic, for example, applying velocity to the arrow
            entity.setDeltaMovement(0, 0.1, 0);
        })
        .onHitBlock(context => {
            const { entity, result } = context;
            // Custom behavior when the arrow hits a block, for example, spawning particles
            entity.getLevel().addParticle('minecraft:item_snowball', entity.getX(), entity.getY(), entity.getZ(), 0, 0, 0);
            entity.remove('discarded')
        })
        .onHitEntity(context => {
            const { entity, result } = context;
            // Custom behavior when the arrow hits an entity, for example, applying potion effects
            if (result.entity.living) {
                let potion = result.entity.potionEffects
                const { entity, result } = context;
                // Custom behavior when the arrow hits a block, for example, spawning particles
                entity.getLevel().addParticle('minecraft:item_snowball', entity.getX(), entity.getY(), entity.getZ(), 0, 0, 0);
                potion.add('minecraft:slowness', 200, 1, false, false)
                entity.remove('discarded')
            }
        })
        .playerTouch(context => {
            const { player, entity } = context;
            // Custom behavior when a player touches the arrow, for example, setting the player on fire.
            if (entity.age > 5) {
                let potion = result.entity.potionEffects
                const { entity, result } = context;
                // Custom behavior when the arrow hits a block, for example, spawning particles
                entity.getLevel().addParticle('minecraft:item_snowball', entity.getX(), entity.getY(), entity.getZ(), 0, 0, 0);
                potion.add('minecraft:slowness', 200, 0, false, false)
                entity.remove('discarded')
            }
        })
        .tick(entity => {
            // Custom tick logic, for example, checking if the arrow is in lava and setting it on fire
            if (entity.getLevel().getBlockState(entity.blockPosition()).getBlock().id == "minecraft:lava") {
                entity.remove('discarded')
            }
        })

})