#Mimic Mob Spawning

1 messages · Page 1 of 1 (latest)

short echo
#

Is there a function available which let's one mimic the spawn ability of a zombie, skeleton or blaze for example. Essentially copying their spawn behaviour?

strong marlinBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

short echo
#

Possibly with EntityJS?

sacred raven
#

@hasty elk

hasty elk
#

yea

hasty elk
# short echo Possibly with EntityJS?

in startup js let Monster = Java.loadClass("net.minecraft.world.entity.monster.Monster") let EntityType = Java.loadClass("net.minecraft.world.entity.EntityType") EntityJSEvents.spawnPlacement(event => { event.replace('minecraft:wither_skeleton', "on_ground", "motion_blocking_no_leaves", (entityType, levelAccessor, spawntype, blockpos, randomsource) => Monster.checkMonsterSpawnRules(EntityType.ZOMBIE, levelAccessor, spawntype, blockpos, randomsource) ); });

#

then you'll need to actually add their spawns like so in server scripts js EntityJSEvents.biomeSpawns(event => { event.addSpawn("minecraft:wither_skeleton", ["#minecraft:overworld"], 10, 1, 3) })

sacred raven
hasty elk
#

i dont mind it

sacred raven
#

Alright

#

for all entityJS related stuff, I will ping you

hasty elk
#

theres also a wiki page to look through as well

#

dont forget 😉

short echo
#

So after the mob spawn behaviour has been mimiced, can you still modify their spawn chance?

short echo
#

What do these 3 do: spawntype, blockpos, randomsource

hasty elk
hasty elk
short echo
#

I'm assuming randomsource handles spawn weight?

hasty elk
#

i think it handles the attempt when seeing a potential spawnable block

short echo
hasty elk
#

should be the full list

short echo
# hasty elk https://lexxie.dev/forge/1.20.1/net/minecraft/world/entity/EntityType.html

I've tried this now:
startup_scripts

let $Monster = Java.loadClass("net.minecraft.world.entity.monster.Monster")
let $EntityType = Java.loadClass("net.minecraft.world.entity.EntityType")

    EntityJSEvents.spawnPlacement(event => {
        event.replace('specialmobs:brutezombie', "on_ground", "motion_blocking_no_leaves", (entityType, levelAccessor, spawntype, blockpos, randomsource) =>
            $Monster.checkMonsterSpawnRules($EntityType.ZOMBIE, levelAccessor, spawntype, blockpos, randomsource)
        );
    });
#

and

EntityJSEvents.biomeSpawns(event => {
    event.addSpawn('specialmobs:brutezombie', ["#minecraft:overworld"], 10, 1, 3)
})
#

I don't know if this the numbers make the mob too rare to spawn, but I haven't seen the mob spawn yet

hasty elk
#

hmm

#

i know they need a mob type to be able to spawn with the biome spawns event

#

in some event like entity interacted console.log(entity.mobType) and see what it says

short echo
# hasty elk hmm

It's been some time but I stumbled back here and was wondering if I can do the checkSpawn to check if the spawns have worked

hasty elk
#

if mimics dont have a spawntype then it wont fire the checkspawn event

#

.spawned event will check regardless

short echo
# hasty elk .spawned event will check regardless

My current setup looks like this. Tell me if you have any recommandations/ if I am doing something wrong.

startup

const $Monster = Java.loadClass("net.minecraft.world.entity.monster.Monster");
const $EntityType = Java.loadClass("net.minecraft.world.entity.EntityType");

global.specialMobs = {
    'ZOMBIE': ['brutezombie', 'firezombie', 'fishingzombie', 'frozenzombie', 'giantzombie', 'hungryzombie', 'huskzombie', 'madscientistzombie', 'plaguezombie']
};

Object.entries(global.specialMobs).forEach(([mobType, variants]) => {
    EntityJSEvents.spawnPlacement(event => {
        variants.forEach(variant => {
            event.replace(`specialmobs:${variant}`, "on_ground", "motion_blocking_no_leaves", (entityType, levelAccessor, spawntype, blockpos, randomsource) => 
                Monster.checkMonsterSpawnRules($EntityType.ZOMBIE, levelAccessor, spawntype, blockpos, randomsource)
            );
        });
    });
});

server

Object.values(global.specialMobs).forEach(variants => {
    variants.forEach(variant => {
        EntityEvents.checkSpawn(`specialmobs:${variant}`, event => {
            console.log(`specialmobs:${variant}` + ' spawned!')
            event.server.tell(`specialmobs:${variant}` + ' spawned!')
        });
        EntityJSEvents.biomeSpawns(event => {
            event.addSpawn(`specialmobs:${variant}`, ["#minecraft:overworld"], 1000, 1, 3)
            console.log(`specialmobs:${variant}` + ' BiomeSpawned!')
        });
    });
});
#

maybe my numbers are too low

#

none of the mobs listed in global.specialMobs are spawning

short echo
hasty elk
short echo
hasty elk
#

those are spawn rules, not mobType

short echo
#

For doing console.log(target.mobType) in ItemEvents.entityInteracted
net.minecraft.world.entity.MobType@67797f7b [net.minecraft.world.entity.MobType]

hasty elk
#

do .toString()

#

afterwards

short echo
hasty elk
#

it looks correct to me

short echo
hasty elk
#

breh

#

uh

short echo
hasty elk
#

oh you know what

#

maybe it's MobCategory

#

that we need

#

cause they seem to add their own spawning logic

#

although i still wanna see what it says when you do this js let UtilsJS = Java.loadClass("dev.latvian.mods.kubejs.util.UtilsJS") ItemEvents.entityInteracted(event => { let /**@type {Internal.LivingEntity} */ target = event.target console.log(UtilsJS.getMobTypeId(target.mobType)) console.log(target.getSpawnType()) console.log(target.entityType.category.toString()) })

#

no promises thisll work but you can also try modifying their mobtype with the modify event js EntityJSEvents.modifyEntity(event => { Object.values(global.specialMobs).forEach(variants => { variants.forEach(variant => { event.modify(`specialmobs:${variant}`, modifyBuilder => { modifyBuilder.mobType("undead") }) }) }) })

short echo
hasty elk
#

so nothing out of the ordinary

#

yeah not sure tbh, maybe try incontrol spawning mechanics

short echo
#

The reason I am trying to naturally spawn them is because they, the author, chose a very bad way of making the mobs spawn: They replace vanilla mobs which also messes up their given attributes when spawned.

They left a config option in which one can disable the "Mob Replacer"-feature which is what I did, which led me down this KJS path

hasty elk
#

yikes

short echo
# hasty elk yikes

This mod adds a lot of mobs... so I wanted to ask you if you know an event in which I can list all of the mods' mobs using RegEx?

#

nevermind I found your comment:
#1330600997088919743 message

pallid orioleBOT
#

[➤](#1330600997088919743 message)
you mean this? js Utils.getRegistryIds("entity_type").forEach(type => { })