jabelar Posted October 19, 2015 Share Posted October 19, 2015 Okay basically I just want to make a configuration where either only my custom mobs spawn naturally or every mob spawns naturally. I always think that the entity join event will do the trick, but then realize that it seems to be fired not just for spawns but also whenever chunk loads -- right? So if a player spawns a mob with a spawn egg then if that chunk has to load later it would disappear. Right? Sorry but I always get confused on what "join" means exactly. The entity constructing event doesn't help because it isn't cancelable, although I suppose you could do something like set it dead right away? Anyway, I think the best way is to actually use the removeSpawn method in the EntityRegistry, right? That isn't too hard, so I'll probably do that. However, while looking at EntityRegistry I see a method called setCustomSpawn() which seems to allow you to fully override the spawning functionality. Has anyone used that before? It seems like it could be pretty powerful if you could fully take over the spawning decisions... Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/ Link to comment Share on other sites More sharing options...
jabelar Posted October 20, 2015 Author Share Posted October 20, 2015 The custom spawning in EntityRegistry is just for when the Entity is being spawned on the client. I am not sure there is an easy way to override the world spawning. You could disallow it entirely using LivingSpawnEvent.CheckSpawn and then do it yourself. It depends on your actual needs. Oh yeah I forgot about CheckSpawn event. That should work. (My need is to have a config boolean that can prevent all vanilla mobs from naturally spawning while letting my mobs spawn naturally.) Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/ Link to comment Share on other sites More sharing options...
jabelar Posted October 20, 2015 Author Share Posted October 20, 2015 Actually, CheckSpawn is still giving me some trouble -- it seems to be firing and setting result to DENY but when I make new world it is still full of chickens, pigs, etc. I noticed CheckSpawn is not fired when the "preparing spawn area" messages are happening, but only later when there is a tick. If you look at the call hierarchy it seems that CheckSpawn isn't fired during world gen. My code for the event handler: @SubscribeEvent(priority=EventPriority.HIGHEST, receiveCanceled=true) public void onCheckSpawn(CheckSpawn event) { if (event.entityLiving instanceof EntityDinosaur) { if (MyMod.spawnDinosNaturally) { event.setResult(Result.ALLOW); } else { event.setResult(Result.DENY); } } else { if (MyMod.spawnNonDinoMobsNaturally) { MyMod.instance.getLogger().debug("Allowing spawn for non-dino"); event.setResult(Result.ALLOW); } else { MyMod.instance.getLogger().debug("Denying spawn for non-dino"); event.setResult(Result.DENY); } } } And it is definitely getting called in game (although not during "preparing spawn area" as I mentioned). I know this because the logger sptis out continuos stream of "Denying spawn for non-dino". So what should I do to prevent generation in the first place? I'm thinking using the removeSpawn from EntityRegistry is cleanest way... Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
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.