#Mimic Mob Spawning
1 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Possibly with EntityJS?
@hasty elk
yea
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) })
you made the mod, I shall ping you (if its okay)
i dont mind it
So after the mob spawn behaviour has been mimiced, can you still modify their spawn chance?
What does the first part do, because the second part looks like it handles the spawn addition
What do these 3 do: spawntype, blockpos, randomsource
spawn chance is modified via the weight in the biome spawn event
those are pretty self explanatory
for spawntype reference the MobSpawnType class https://lexxie.dev/forge/1.20.1/net/minecraft/world/entity/MobSpawnType.html
I'm assuming randomsource handles spawn weight?
i think it handles the attempt when seeing a potential spawnable block
In this example you used the spawn rules of Zombie, but what about mobs like Creepers, Cave Spiders, Slimes, Drowned and Ghasts.
Where can I find the list of EntityType for example?
declaration: package: net.minecraft.world.entity, class: EntityType
should be the full list
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
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
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
if mimics dont have a spawntype then it wont fire the checkspawn event
.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
@hasty elk Could you tell me if I am doing something wrong here?
^
i've seen entities not spawn with forge spawning because they lack a mobType too, summon it manually and console.log(event.entity.mobType) in the checkSpawn event
okay
Wait, I thought you explained to me that this line
Monster.checkMonsterSpawnRules($EntityType.ZOMBIE, levelAccessor, spawntype, blockpos, randomsource)
is meant to grab ahold of the EntityType.ZOMBIE spawn rule and apply it to the entities put into:
event.replace(`specialmobs:${variant}`
those are spawn rules, not mobType
For doing console.log(target.mobType) in ItemEvents.entityInteracted
net.minecraft.world.entity.MobType@67797f7b [net.minecraft.world.entity.MobType]
Is my way of trying to get an existing mobs spawn rule not correct as done here, then applying it to the event.replace?
it looks correct to me
It did this: net.minecraft.world.entity.MobType@67797f7b without the outer part
this is there github for the version
https://github.com/FatherToast/SpecialMobs/tree/1.20.X
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") }) }) }) })
[INFO] overall/entities/target_test.js#4: undead
[INFO] overall/entities/target_test.js#5: SPAWN_EGG [net.minecraft.world.entity.MobSpawnType]
[INFO] overall/entities/target_test.js#6: MONSTER

so nothing out of the ordinary
yeah not sure tbh, maybe try incontrol spawning mechanics
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
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