Draco18s Posted May 31, 2013 Posted May 31, 2013 How would I go about registering a mob to be spawned under certain conditions (typically at night, but for the mob I have in mind, I probably want them to spawn during the day)? Right now I have them showing up on chunk generation (because that I know where it occurs) but I'm not sure how to go about spawning mobs over time and maintaining a reasonable count (given that individually my mob is fairly tough, spawning one in a chunk that already has one--or in an adjacent chunk--might be a little unfair on the player). Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
thebest108 Posted June 3, 2013 Posted June 3, 2013 Forge Events is how I'd do it Quote "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
Mew Posted June 3, 2013 Posted June 3, 2013 Forge Events is how I'd do it Not needed. What you do, is that when you call the EntityRegistry.addSpawn(); method, you sawn as a EnumCreatureType.CREATURE (I think thats what it is, I know it's EnumCreatureType though) for spawning during the day, and EnumCreatureType.MONSTER (once again, same issue as before) for during the night. Then there is EnumCreatureType.WATER. If that isn't self explanatory then I don't know what is But yeah, the EntityRegistry.addSpawn(); is where you can register if it spawns or not and such. As for the spawning only one in a chunk, there is a method in the Entity class that sets that I think. And for the adjacent chunks.... Well, have fun with that Quote I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
Draco18s Posted June 3, 2013 Author Posted June 3, 2013 What you do, is that when you call the EntityRegistry.addSpawn(); method, you sawn as a EnumCreatureType.CREATURE (I think thats what it is, I know it's EnumCreatureType though) for spawning during the day, and EnumCreatureType.MONSTER (once again, same issue as before) for during the night. Then there is EnumCreatureType.WATER. If that isn't self explanatory then I don't know what is But yeah, the EntityRegistry.addSpawn(); is where you can register if it spawns or not and such. As for the spawning only one in a chunk, there is a method in the Entity class that sets that I think. Awesome, thanks! And yeah, there's a function in the entity class that says how many can spawn per chunk. Couldn't figure out how it was used (because I was lacking the EntityRegistry part) but I did at least alter the numbers to what I'd like. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Draco18s Posted June 3, 2013 Author Posted June 3, 2013 MORE ADVANCED TRICKIER QUESTION ASK: What if I want to limit these mob spawns to additional dimensions and only additional dimensions (i.e. not vanilla) and not during the night (i.e. I don't care about light level)? Conditions: 1) Arbitrary light level: daytime spawning should be valid--night may never actually occur, day may never actually occur, but mobs should still spawn. 2) Specific dimensions of unknown dimension ID: which dimensions are not known at mod registration time because the dimensions don't exist yet. 3) If the player leaves a valid dimension and enters a non-valid dimension, mob spawning should be disabled (and vice versa).1 4) Biome is irrelevant (some modifiers yes--such as mob A not spawning where it is cold, mob B not spawning where it is hot, etc.2--but not "oh mob B only spawns in Jungles" like ocelots). Example: Spawn the mob when "Jungles in Dimension with Non-Vanilla Property Y." Not "Jungles" nor "Dimension N." 1Through another mod's API I have a class that has two functions--onChunkPopulate and tick--that get called for each chunk in a valid dimension (the first one being chunk creation the second being chunk update) and access to a few events for when the player changes dimension via this mod's methods,3 though I am unsure if I can determine from the world object if it is a valid spawning dimension or not: I do not appear to have access to the custom WorldSavedData class that would hold those properties. At the moment I am using this class to manually spawn mobs by checking each chunk as it ticks for existing mobs and distance from the nearest player, although this is imperfect. 2Due to additional biome mods, like Biomes o' Plenty, I want my mob to spawn even in those biomes. I know there's a BiomeEvent...event and I could catch and store the additional IDs based on various parameters that I chose, but that's not the issue. It's figuring out when and where to register the spawning and then invalidate it! 3And there are other mods that permit dimensional travel that I do not (necessarily) have access to! IC2's teleporter, vanilla nether portal, end portal, twilight forest portal... Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Mew Posted June 4, 2013 Posted June 4, 2013 MORE ADVANCED TRICKIER QUESTION ASK: What if I want to limit these mob spawns to additional dimensions and only additional dimensions (i.e. not vanilla) and not during the night (i.e. I don't care about light level)? Conditions: 1) Arbitrary light level: daytime spawning should be valid--night may never actually occur, day may never actually occur, but mobs should still spawn. 2) Specific dimensions of unknown dimension ID: which dimensions are not known at mod registration time because the dimensions don't exist yet. 3) If the player leaves a valid dimension and enters a non-valid dimension, mob spawning should be disabled (and vice versa).1 4) Biome is irrelevant (some modifiers yes--such as mob A not spawning where it is cold, mob B not spawning where it is hot, etc.2--but not "oh mob B only spawns in Jungles" like ocelots). Example: Spawn the mob when "Jungles in Dimension with Non-Vanilla Property Y." Not "Jungles" nor "Dimension N." 1Through another mod's API I have a class that has two functions--onChunkPopulate and tick--that get called for each chunk in a valid dimension (the first one being chunk creation the second being chunk update) and access to a few events for when the player changes dimension via this mod's methods,3 though I am unsure if I can determine from the world object if it is a valid spawning dimension or not: I do not appear to have access to the custom WorldSavedData class that would hold those properties. At the moment I am using this class to manually spawn mobs by checking each chunk as it ticks for existing mobs and distance from the nearest player, although this is imperfect. 2Due to additional biome mods, like Biomes o' Plenty, I want my mob to spawn even in those biomes. I know there's a BiomeEvent...event and I could catch and store the additional IDs based on various parameters that I chose, but that's not the issue. It's figuring out when and where to register the spawning and then invalidate it! 3And there are other mods that permit dimensional travel that I do not (necessarily) have access to! IC2's teleporter, vanilla nether portal, end portal, twilight forest portal... Ahh.... I see some of your problems... I think. I am not quite getting some of these problems So If you could try explaining them in a bit more detailed way?? Then I might be able to read it the way you want it to be read. Quote I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
Draco18s Posted June 4, 2013 Author Posted June 4, 2013 Ahh.... I see some of your problems... I think. I am not quite getting some of these problems So If you could try explaining them in a bit more detailed way?? Then I might be able to read it the way you want it to be read. I'm working with the Mystcraft API. Part of that API is a world generator interface, it's effectively the same as a vanilla IWorldGenerator, but Mystcraft controls when it is used (and there are often multiple per dimension). Each one of these files is the implementation of a single effect. An effect can range from "add these blocks to the world" to "cause potion effects on mobs at random." I want to spawn custom mobs as part of one of these effects. Mystcraft does not currently do any kind of mob spawn control. So I am currently doing AABB checks over a wide area (easily 65x65x128) every 80 or so ticks, and counting how many mobs of a given type are found, and if below a certain threshold, spawn more. I would much rather hand control over to Minecraft's spawning system, but I have no way of knowing when to invalidate the spawning rules. I only know when the player is in the dimension them dimension is loaded. I do not have access to the load or unload events (at least, not in any more detail than the Forge events) nor do I have access to the list of effects a given dimension has (specifically: XCompWiz doesn't want symbols to be aware of each other: observable properties are fine ("what is the average terrain height?" "what is the sea level?") but not the specific symbols used to get there ("Flat terrain" "nether terrain" etc.). So a number of things can be inferred from looking at these aggregate properties, but outside of the IWorldGenerator class, I have no way of knowing if an active dimension has the property I desire (nor does the spawn registry limit dimensions! Imagine multiplayer where I could enable/disable the spawning based on the property I don't have access to: one player goes to the valid dimension and the player in the overworld sees my mobs spawn at night! This is not desirable!). So, I need to spawn my mobs... 1) Any time, day or night 2) Specific, but unknown, dimension ID or IDs 3) No biome restrictions Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Mew Posted June 4, 2013 Posted June 4, 2013 So, I need to spawn my mobs... 1) Any time, day or night Thats fairly easy. Just call the EntityRegistry.addSpawn(); twice, once with the mob as EnumCreatureType.CREATURE, and the other as EnumCreatureType.MONSTER. That will spawn it as a monster (night) and creature (day). 2) Specific, but unknown, dimension ID or IDs Couldn't this be achieved by checking if the player is in the dimension needed? (or do you need the dimension ID still?) If this is possible, then you could spawn it in a dimension specific biome. (I assume that the dimension biomes do not spawn in the overworld, and only in the dimension?) 3) No biome restrictions I believe that cannot be achieved with vanilla code... Quote I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
Draco18s Posted June 4, 2013 Author Posted June 4, 2013 2) Specific, but unknown, dimension ID or IDs Couldn't this be achieved by checking if the player is in the dimension needed? (or do you need the dimension ID still?) If this is possible, then you could spawn it in a dimension specific biome. (I assume that the dimension biomes do not spawn in the overworld, and only in the dimension?) The problem arises when trying to determine what dimension number that is. Followed by what object is doing the checking assuming I knew? The mob itself? And your assumption is wrong. Mystcraft says "what biomes would you like?" and gives you a list. All vanilla biomes are valid (and so are all mod biomes). I can, in fact, make a world that checkerboards between Sky and Hell. 3) No biome restrictions I believe that cannot be achieved with vanilla code... Other than calling addSpawn for all biomes...which means I need an event listener to listen for mod biomes... Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Mew Posted June 5, 2013 Posted June 5, 2013 Other than calling addSpawn for all biomes...which means I need an event listener to listen for mod biomes... I think that using the biomeList (the list of all the biomes that are available, including modded ones), you could check to see what ID's are used, and then (somehow as there is no method that I can find that returns the name of the biome) get the name of the biome. Then, using that getName() method or whatever you are using to get it, print out the ID of the biome, and the name of the corresponding ID. After obtaining that information, you could then read through and find the biomes you needed.... And if you are just wanting to spawn a mob in one biome only, its like this: EntityRegistry.addSpawn(EntityToSpawn.class, weightedProb, min, max, typeOfCreature, BiomeGenBase.nameOfBiome); or, for a modded biome: EntityRegistry.addSpawn(EntityToSpawn.class, weightedProb, min, max, typeOfCreature, WhereYourBiomeVariablesAreKept.nameOfBiome); Quote I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
Draco18s Posted June 5, 2013 Author Posted June 5, 2013 Other than calling addSpawn for all biomes...which means I need an event listener to listen for mod biomes... I think that using the biomeList (the list of all the biomes that are available, including modded ones), you could check to see what ID's are used, and then (somehow as there is no method that I can find that returns the name of the biome) get the name of the biome. Then, using that getName() method or whatever you are using to get it, print out the ID of the biome, and the name of the corresponding ID. After obtaining that information, you could then read through and find the biomes you needed.... Something like that. Less of an issue than restriction dimension. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Mew Posted June 5, 2013 Posted June 5, 2013 I am still not getting what you mean by restricting dimension. Do you mean restricting it so that the mob can only exist inside that dimension? Quote I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
Draco18s Posted June 5, 2013 Author Posted June 5, 2013 Do you mean restricting it so that the mob can only exist inside that dimension? Yes. The mob should be able to change dimensions if forced (via teleportation effects, such as nether portals) but should not spawn there. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Mew Posted June 5, 2013 Posted June 5, 2013 You could probably do a check like that inside the actual entity. Basically, you have a method that will set the entity to dead if it is not in a dimension. Then you use the good 'ole spawn method to spawn it in the biome you want. Then it can only exist in that dimension... Another way would be to look through gast code. They can only exist in the nether right? Or is it just the hell biome? Quote I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
Draco18s Posted June 5, 2013 Author Posted June 5, 2013 You could probably do a check like that inside the actual entity. Basically, you have a method that will set the entity to dead if it is not in a dimension. Then you use the good 'ole spawn method to spawn it in the biome you want. Then it can only exist in that dimension... Meaning I'd have to store a list of valid dimension IDs. Grumble grumble. Rather than being able to look at empirical world properties. Another way would be to look through gast code. They can only exist in the nether right? Or is it just the hell biome? Hell biome. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Mew Posted June 5, 2013 Posted June 5, 2013 Quote Another way would be to look through gast code. They can only exist in the nether right? Or is it just the hell biome? Hell biome. Damn..... Well then. This will be fun Quote I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
Draco18s Posted June 5, 2013 Author Posted June 5, 2013 Damn..... Well then. This will be fun I think you mean ‼Fun‼. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.