-
Posts
129 -
Joined
-
Last visited
-
Days Won
1
Everything posted by JaredBGreat
-
Well, I'd slept late and just rolled out of bed, so I was pretty grouchy myself. Anyway, it may be that my own code is generating too many objects. I started writing some memory management of my own in hopes it would be easier to profile by inserting debug code into that. Then I realized I could add code to just count the objects, and got things like this: [16:11:25] [Server thread/INFO] [STDOUT]: [jaredbgreat.climaticbiome.generation.BetterBiomeProvider:cleanupCache:98]: There are... [16:11:25] [Server thread/INFO] [STDOUT]: [jaredbgreat.climaticbiome.generation.BetterBiomeProvider:cleanupCache:99]: 180511 Basin nodes [16:11:25] [Server thread/INFO] [STDOUT]: [jaredbgreat.climaticbiome.generation.BetterBiomeProvider:cleanupCache:100]: 9284 BiomeBasins [16:11:25] [Server thread/INFO] [STDOUT]: [jaredbgreat.climaticbiome.generation.BetterBiomeProvider:cleanupCache:101]: 37139 ChunkTiles [16:11:25] [Server thread/INFO] [STDOUT]: [jaredbgreat.climaticbiome.generation.BetterBiomeProvider:cleanupCache:102]: 3341 Regions [16:11:25] [Server thread/INFO] [STDOUT]: [jaredbgreat.climaticbiome.generation.BetterBiomeProvider:cleanupCache:103]: 10031 Spatial noise generators The numbers do go up and down a bit, so apparently its not a leak, they do get garbage collected. But apparently I'm creating far more of these than I ever imagined (especially noise generators, which I thought I had only one in, and basin nodes -- well, especially everything I guess). So, I need to figure out (1) where these are all coming from and (2) and good way to manage them. Thanks. Sorry for getting snarky earlier.
-
Thanks. I don't think that exactly is the problem, as it doesn't become slow unless it runs out of memory completely and starts having lag spikes, and extra files are generally empty. I'll take a look. Thanks for accusing me of doing things I did not do, asking for favors I did not ask for, and telling me things I already know, and assuming I don't know how to (or won't) do something I've done many, many times. I was simply asking if anyone had any good information on the sub-systems involved, not for anyone to debug anything. Anyway, I think I'll pass on your suggestion to create a huge core mod that adds debugging code to a large portion of the game. EDIT: Nevermind -- I don't want to start a fight. I was just hoping people who'd done similar things might have some general advice on pitfalls they may have encountered or know about, insights that might be useful. I'm removing the link to the biome provider so no one will think I'm asking for someone to actually debug it -- for the curious its not hard to find.
-
Really looking more for general advice, info, or insight on this one... I have a WIP biome placement mod (more of a biome zones mod than a biomes mod per se). Basically it places biomes based on a quasi-realistic climate model, using a system I developed outside Minecraft in a tool I made for experimenting with procedural content generation (especially maps). I've inserted my system into Minecraft as a custom world type. The worlds it makes seems great at this point, but there is a serious problem I need to fix before I go further with things like configurability and updating: I find the game using far more memory than I think it should, and exploring so that new terrain is generated causes the memory usage to increase without really going back down much (something I take as a sign memory is leaking). Note that I don't use any genlayers at all, having completely replaced the vanilla system and simply returning biome arrays where needed. Other than my own system (which I'm looking into, but I don't think has an internal problem), does anyone have any idea what might cause this? Also, I see it producing save files for distant parts of the world, far from where a player have been (things like "r.16.-20.mca" when I've never been more than a couple thousand blocks from spawn), and suspect that may be a system of the same underlaying problem, probably based on not interfacing my biome provider correctly with the vanilla chunk provider and world in general. I don't have a specific ease to nail down bug on this one, or specific code I can point to on this one, and don't really expect a specific answer, but if anyone has and potentially useful information or advice on doing things like this I'd be thankful to see it.
-
Sorry to wast everyone's time. It turns out it was an old Forge bug, and installing a newer version of Forge fixed the problem completely. (BTW, is there an easy way to unstall Forge installation to avoid picking an old version by accident -- I have a ton of Forge versions right now.) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ OK, I have something really strange going on. I've created an alternate pine tree (an actual pine instead of spruce) for warmer climates. When I run the mod from eclipse everything seems fine, the trees generate and are fully visible and tangible, just like ordinary blocks / like the should be. But, when I build the mod with gradle and use the re-obfuscated mod they become invisible blocks, much the kind you find when playing a laggy server. Here is my generation code: package jaredbgreat.climaticbiome.generation.feature; import jaredbgreat.climaticbiome.blocks.ModBlocks; import java.util.Random; import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockOldLeaf; import net.minecraft.block.BlockOldLog; import net.minecraft.block.BlockPlanks; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenAbstractTree; import net.minecraftforge.common.IPlantable; import static net.minecraft.util.EnumFacing.*; public class GenPine extends WorldGenAbstractTree { private static final IBlockState TRUNK = ModBlocks.pineLog.getDefaultState(); private static final IBlockState LEAF = ModBlocks.pineNeedle.getDefaultState() .withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false)); public GenPine() { super(false); } @Override public boolean generate(World world, Random rand, BlockPos pos) { //if(world.isRemote) return false; int j1 = 5 + rand.nextInt(5); // trunk height int j2 = 2 + rand.nextInt(1 + (j1 / 2)); // first leaf height if((pos.getY() < 1) || ((pos.getY() + j1 + 3) > 255)) { return false; } else { int x = pos.getX(); int z = pos.getZ(); IBlockState under = world.getBlockState(pos.down()); if(!under.getBlock().canSustainPlant(under, world, pos.down(), UP, (IPlantable) Blocks.SAPLING)) { return false; } BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); for(int j3 = pos.getY(); j3 < (pos.getY() + j1 +1); j3++) { if(!isReplaceable(world, mutable.setPos(x, j3, z))) { return false; } } int w = 1; int bonus = rand.nextInt(2); int j1b = pos.getY() + j1 + 1; for(int j4 = pos.getY() + j2; j4 < j1b; j4++) { w = 1 + ((j4 + bonus) % 2); for(int i2 = x - w; i2 <= (x + w); i2++) for(int k2 = z - w; k2 <= (z + w); k2++) { BlockPos place = new BlockPos(i2, j4, k2); IBlockState state = world.getBlockState(place); if (state.getBlock().canBeReplacedByLeaves(state, world, place)) { setBlockAndNotifyAdequately(world, place, LEAF); } } } w = 1 + ((j1b + bonus) % 2); for(int j4 = j1b; w > -1; j4++, w--) { for(int i2 = x - w; i2 <= (x + w); i2++) for(int k2 = z - w; k2 <= (z + w); k2++) { BlockPos place = new BlockPos(i2, j4, k2); IBlockState state = world.getBlockState(place); if (state.getBlock().canBeReplacedByLeaves(state, world, place)) { this.setBlockAndNotifyAdequately(world, place, LEAF); } } } for(int j4 = pos.getY(); j4 < j1b; j4++) { BlockPos place = new BlockPos(x, j4, z); IBlockState state = world.getBlockState(place); setBlockAndNotifyAdequately(world, place, TRUNK); } } return true; } } Any one have an idea what's going on here? EDIT: I've tried testing for server versus client side, and tried replacing setBlockAndNotifyAdequately with world.setBlockState (which works for Doomlike Dungeons, but still the same problem. EDIT 2: Oh, one other detail -- even though they act like invisible blocks at first, re-logging does not make them appear but instead disappear -- after leaving the world and restarting it the invisible blocks at gone, there is just air instead.
-
Well, this is how I did it in order to print them out: /** * This will list all mobs, using there unlocalized names, writing * the data to the file lists/mobs.txt. */ public static void listMobs() { Set<ResourceLocation> mobrl = EntityList.getEntityNameList(); ArrayList<String> mobs = new ArrayList<String>(); for(ResourceLocation mob : mobrl) { mobs.add(mob.toString()); } Collections.sort(mobs); BufferedWriter outstream = null; File moblist = new File(listsDir.toString() + File.separator + "entities.txt"); if(moblist.exists()) moblist.delete(); try { outstream = new BufferedWriter(new FileWriter(moblist.toString())); for(String mob : mobs){ outstream.write(mob.toString()); outstream.newLine(); } if(outstream != null) outstream.close(); } catch (IOException e) { e.printStackTrace(); } } /** * This will list all items, using their complete unlocalized names * with mod id's, and write them the file lists/items.txt. This * is useful for writing theme files. */ public static void listItems() { BufferedWriter outstream = null; File itemlist = new File(listsDir.toString() + File.separator + "items.txt"); if(itemlist.exists()) itemlist.delete(); try { outstream = new BufferedWriter(new FileWriter(itemlist.toString())); for(Object item : Item.REGISTRY){ String name = Item.REGISTRY.getNameForObject((Item) item).toString(); if(true) { outstream.write(name); outstream.newLine(); } } if(outstream != null) outstream.close(); } catch (IOException e) { System.err.println("[DLDUNGEONS] Error: Could not write file items.txt"); e.printStackTrace(); } } /** * This will list all blocks using their correct, unlocalized names, complete with * mod id's, and write them to the file lists/blocks.txt. This is useful for editing * theme files. */ public static void listBlocks() { BufferedWriter outstream = null; File itemlist = new File(listsDir.toString() + File.separator + "blocks.txt"); if(itemlist.exists()) itemlist.delete(); try { outstream = new BufferedWriter(new FileWriter(itemlist.toString())); for(Object block : Block.REGISTRY){ String name = Block.REGISTRY.getNameForObject((Block)block).toString(); if(true) {; outstream.write(name); outstream.newLine(); } } if(outstream != null) outstream.close(); } catch (IOException e) { System.err.println("[DLDUNGEONS] Error: Could not write file blocks.txt"); e.printStackTrace(); } } I hope it helps.
-
Replace blocks while the world generates
JaredBGreat replied to Insane96MCP's topic in Modder Support
Well, first check the if the block at that location is farmland at that BlockPos than set the BlockState at that BlockPos to your block if it is -- these methods are in the World object. You will need to hook into the world generator, probably using the event system to tell when a chunk is generating, and get the World and the coords for the chunk. To be thorough you'd need to search the chunks blocks, though finding the top block is probably good enough and more efficient (checking every block in a chunk is a lot of work for your CPU and I can't imagine it not being a performance issue). I don't know if there is an event for the generator placing a single block -- really, no idea. Some structure such as villages do have such events. I don't know all the details, by a long shot -- I've not done that much with the event system, but have used it to detect villages being generated. Another option is the mod the vanilla structures (I only know of one) to use this, which would be more efficient but have compatibility issues. I've never tried to modify villages and can't. The specifics are up to you to figure out and decide on. This all the help I can give -- and one of the Forge gurus might very well jump in to tell all sorts of things I'm wrong about! (If there are typos, sorry, I'm still half asleep this morning.) -
The main mod I've kept going the last few years is basically a server plug-in also (its all world gen), and never had any trouble. My advice would be to use the acceptableRemoteVersions tag to not require any version on the client -- I wouldn't even bother with ServerSideOnly, just in case someone want to use it in single player (whether it makes much sense or not). Assuming you don't use anything that needs client side functioning, that should be good.
-
[1.10.2][solved] Items not rendering properly
JaredBGreat replied to JaredBGreat's topic in Modder Support
Everything is rendering now, thanks. Now I can get back to the actual logic and organization of it all. -
[1.10.2][solved] Items not rendering properly
JaredBGreat replied to JaredBGreat's topic in Modder Support
Well, I haven't tried the registry events yet, but did put lightball back in creative tab for testing. It turn out it shows up fine as an item or item-entity when ModelMesher is used, but not when ModelLoader is used (maybe this will change if using the registry events). Rather, the problem has been that it is not being applied to projectile entity when fired; I have half a mind just to make a whole new model for it (I was trying to base it on the snowball model and rendering). I also wonder if they need to be an item -- the player isn't supposed to have them. I will try re-writing to use the new event system when I have more time (not this afternoon, maybe tomorrow). Thanks. EDIT: I tried just moving it to pre-init (since I don't have to learn the new systm for that), and had no problem with the correct way (the other crashed when called from preinit). -
[1.10.2][solved] Items not rendering properly
JaredBGreat replied to JaredBGreat's topic in Modder Support
Well... There is no server-specific behavior at this point -- if I need some I'll make a ServerProxy class -- I seriously doubt this mod will ever need sided initialization for anything but client-side code related to rendering. I tried ModelLoader.setCustomModelResourceLocation first; I commented it out and tried the other method because it didn't work. I then switched to ItemModelMesher based on some tutorials, which gave me the same result as the ModelLoader based system. I might consider a more currently proper way of registering entities once I have the things that are broken figured out -- right now that part works fine, though. I suppose I could look at these registry events and see if that makes any difference. -
I can't get items to render correctly for items or item blocks. Projectiles are white cubes, item blocks are the black and purple checker boards. (Blocks and mobs render just fine, even if the registration for mobs is deprecated.) Here's what I'm doing: ClientProxy.java: package jaredbgreat.rpgdungeons.proxies; import jaredbgreat.rpgdungeons.Info; import jaredbgreat.rpgdungeons.entity.mobs.EntityFallenAngel; import jaredbgreat.rpgdungeons.entity.mobs.EntityRevenant; import jaredbgreat.rpgdungeons.entity.mobs.EntityVampire; import jaredbgreat.rpgdungeons.entity.model.ModelFallenAngel; import jaredbgreat.rpgdungeons.entity.render.RenderFallenAngel; import jaredbgreat.rpgdungeons.entity.render.RenderVampire; import jaredbgreat.rpgdungeons.items.ModItems; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.entity.RenderZombie; import net.minecraftforge.fml.client.registry.RenderingRegistry; public class ClientProxy extends CommonProxy { @Override public void regsterRendering() { RenderingRegistry.registerEntityRenderingHandler(EntityRevenant.class, new RenderZombie(Minecraft.getMinecraft().getRenderManager())); RenderingRegistry.registerEntityRenderingHandler(EntityVampire.class, new RenderVampire(Minecraft.getMinecraft().getRenderManager(), new ModelBiped(), 0.5f)); RenderingRegistry.registerEntityRenderingHandler(EntityFallenAngel.class, new RenderFallenAngel(Minecraft.getMinecraft().getRenderManager(), new ModelFallenAngel(0), 0.5f)); } @Override public void registerItemRenders() { // FIXME: This whole setup does not work from pre-init -- must be from init. // Might as will be with the registerRendering. // ModelLoader.setCustomModelResourceLocation(ModItems.lightball, 0, // new ModelResourceLocation(ModItems.lightball.getRegistryName(), "projectile")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher() .register(ModItems.lightball, 0, new ModelResourceLocation(Info.ID + ":" + ModItems.lightball.getUnlocalizedName().substring(5), "inventory")); } } lightball.java: package jaredbgreat.rpgdungeons.items; import jaredbgreat.rpgdungeons.Info; import jaredbgreat.rpgdungeons.entity.projectiles.EntityLightBall; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.world.World; public class ItemLightBall extends Item { public ItemLightBall() { //setCreativeTab(CreativeTabs.MISC); // No creative tab -- these are not for the player setUnlocalizedName("lightball"); setRegistryName("lightball"); //setRegistryName(Info.ID + ":lightball"); } @Override public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) { if(!player.capabilities.isCreativeMode) { stack.stackSize--; } if(!world.isRemote) { EntityLightBall fired = new EntityLightBall(world, player); world.spawnEntityInWorld(fired); fired.setHeadingFromThrower(player, player.rotationPitch, player.rotationYawHead, 0.0f, (float)1.2, (float)0.0); } return new ActionResult(EnumActionResult.SUCCESS, stack); } } lightball.json: { "parent": "item/generated", "textures": { "layer0": "rpgdungeonsjbg:projectiles/lightball" } } My one attempt at getting a block item to render: { "parent": "block/cube_all", "textures": { "all": "rpgdungeonsjbg:blocks/Doomed/aqconc07" } } I've looked at many tutorials and some other modders code, and the vanilla JSONs. The full project is here: https://github.com/BlackJar72/RPGDungeons Can anyone tell me what I'm doing wrong?
-
[1.10.2] "Player moved wrongly" preventing teleportation
JaredBGreat replied to IceMetalPunk's topic in Modder Support
I've tried the basically same thing, taken straight from the command, in multiple game versions, and the results I get a very, very weird. I implemented my TP in an abstract base class, and had four classes that inherited it (for short vs. long range, and one-way vs. two-way teleporters). All inherited directly, no changes. It works perfectly 100% of the time for both one-way teleporters but not the two-way (always the error if in survival, even with cheats on, works if used in creative). So, this way can work, sometimes, but why it sometimes doesn't is a mystery that needs some explaining (and probably a fix) -- will anyone else answer this? -
Sorry to have bothered everyone. After struggling with it all night I seem to have figured it out. This works: /** * Returns an array of biomes for the location input. */ public Biome[] getBiomesForGeneration(Biome[] biomes, int x, int z, int width, int height) { ChunkTile[] chunks = finder.makeChunk((x / 4), (z / 4) + 1); System.err.println(((x / 4)) + ", " + ((z / 4) + 1)); biomes = new Biome[chunks.length]; for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) { biomes[(j * 10) + i] = Biome.getBiome(chunks[(((j / 4) + 3) * 10) + (i / 4) + 3] .getBiome(), Biomes.DEFAULT); } return biomes; } /** * checks given Chunk's Biomes against List of allowed ones */ public boolean areBiomesViable(int x, int z, int radius, List<Biome> allowed) { //return allowed.contains(test2) || allowed.contains(test); return true; } /** * Gets a list of biomes for the specified blocks. */ public Biome[] getBiomes(@Nullable Biome[] in, int x, int z, int width, int depth, boolean cacheFlag) { if (in == null || in.length < width * depth) { in = new Biome[width * depth]; } System.err.println(((x / 16)) + ", " + ((z / 16))); Biome biome = Biome.getBiome(finder.makeChunk((x / 16), (z / 16))[33].getBiome()); Arrays.fill(in, 0, width * depth, biome); return in; } I needed to keep the getBiomeForGeneration 4 times bigger, and it needed to be displaced by 3 (not two!) to have it consider most of the bordering chunks and all the the chunk in question. I then needed to displace the output for getBiome by 3 (not twelve?!) to compensate. This gets everything to the right scale and lines up the biomes with the correct terrain pretty well for the most part. (Now I just have to stop structures for appearing in all the wrong biomes.)
-
I've started working on a Climatic Biome Placement mod. I've worked out how I want to determine general biome categories, and have written my own BiomeProvider prototype. I don't want to modify the ChunkProvider since I want the actual terrain to look vanilla, I just want to change the biome placement. So far it is placing biomes, but the scale seems to be way off. I found and re-written two methods that are called by the ChunkProvider, getBiomesForGeneration (returning an array containing 10x10 biomes) and getBiomes (returning and array of 16x16 biomes). I'm pretty sure that getBiomes gives the biome array for blocks in a chunk, and that getBiomesForGeneration returns biomes for chunks on a lower resolution scale to be averages in smoothing terrain generation between biomes. However, I'm having trouble working out the actual scale that getBiomesForGeneration uses, and it seems to involves some displacement relative to getBiomes (I'm assuming the x and z parameters are chunk coordinates for both). However, I'm having trouble getting the terrain generation to line up with the biome placement. In addition, I've found that my biomes are much smaller than they should be, based on testing the same system in a visualization tool I created. I'm working on cracking what the ChunkProvider actually expects from its calls to getBiomeForGeneration. However, before I drive myself insane reinventing the wheel I'd like to know if any here who has figured this out would like to share, So if anyone has any useful information or insight into this I'd love to here it. Thanks. (P.S.: The mods code is at https://github.com/BlackJar72/ClimaticBiomePlacement if anyone would like to look, though I don't think any specific part is directly relevant to this fairly general question.) EDIT: I have figured out that getBiomes needs its coords divided by 16 (apparently they're block coordinates, not chunk coordinates). I think getBiomesForGeneration uses scale of four blocks, and maybe a displacement of (blocks? or units of four, making 8 blocks). This still gives a lot of weird anomolies, like wall, repeats of patterns, etc. I know getBiomesForGeneration gives its data to a method that helps to produce height maps -- I just need to figure out what data its (scale, format) supposed to be sending so I can make my biome data fit, and still haven't get that (so still open to hints or suggestion from anyone who make have figured it out).
-
(Solved) [1.10.2] Natural modded word-gen not occuring
JaredBGreat replied to JaredBGreat's topic in Modder Support
Well, I used the simple profiler I built in (since F3 info isn't that good for infrequence, time consuming events). It seems that GenerationHandler is working fine, but there was something wrong with the config. I don't understand it, but it wasn't reading the config, but after I simply deleted it and let a new one be generated everything worked -- no change in the config reading code. It wasn't generating dungeons because it was too close to spawn and hadn't read in the config changes I'd made to let them appear at a distance of 0. Text editors read it fine, and Minecraft reads the new one fine. So now it works, I just don't know what the problem was. -
(Solved) [1.10.2] Natural modded word-gen not occuring
JaredBGreat replied to JaredBGreat's topic in Modder Support
So, does anyone know what's going on -- or should this be reported as a bug? Its the same code that worked for 1.10, and 1.9.4. I have tried moving the registration out of the constructor to the code block that creates it (since something don't like be registered on creation), but that made no difference. At this point, I'm thinking this actually is a Forge bug rather than an error of mine. -
I recently tried to update Doomlike Dungeons to 1.10.2; the update to 1.10 was so easy, it literally required no code changes to make it work. Unfortunately this doesn't seem to be the case with 1.10.2. The code produces no errors, but my IWorldGenerator class (GenerationHandler) never seems to be triggered or to trigger world-gen. Everything works correctly when I spawn a dungeon in with a cheat code, they never appear with natural world-gen -- the game runs normally but no dungeons ever generation (without cheats). I'm not sure if something has to be registered differently, or if there is some extra-registration, or what -- or if this is simply a bug in the new Forge version. I've tried moving the registration of the IWorldGenerator out the constructor, but this made no difference. From DoomlikeDungoens.java: @EventHandler public void init(FMLInitializationEvent event) { if(ConfigHandler.naturalSpawn) dungeonPlacer = new GenerationHandler(); } My IWorldGenerator: Does anyone know what's happened to break this? -- or is this actually Forge bug?
-
[1.7.10] How to create an addon for a mod?
JaredBGreat replied to winnetrie's topic in Modder Support
wouldn't that make my mod depending on BOP? If so, i don't want that. My mod is a mod on his own, but whenever BOP is installed too you have the extra stuff That is true. If your mod really is an add-on it should have the other as a dependency, but if its not that's a problem. I know there is a way to make a mod a "soft" dependency, that doesn't require the other but loads after it because Lycanite did that with my mod -- but I don't know how (its something I've been wanting to learn myself). But if its not technically an add-on, if its its own mod, it really shouldn't have a hard dependency. -
[1.7.10] How to create an addon for a mod?
JaredBGreat replied to winnetrie's topic in Modder Support
Ah! Now I know what's happening, though should have thought of it before. Its about the order the mods load. Your mod was being loaded before BoP, so the BoP resources weren't there yet. By moving it to post init it insured that all other mods had been at least loaded (and should have gone through pre-init and init as well). By putting it in pre-init it meant that some mods might not even have been loaded. You should try defining and registering blocks in init -- technically pre-init is for things like reading in config files and setting options. Init is for initializing your main content, like including blocks, and post init is there to allow for inter-mod compatibility, by allowing things to be done after other mods have initialized. Register in init should work, since BoP resources should be loaded by then, but if not you can always go back to post-init. But doing this in pre-init was not the correct place and probably cause the problem. EDIT: The reason post-init might not be the best place is that it could cause problem if another mod wants to use your block -- for example, I have Doomlike Dungeons read in themes in post-init so blocks from other mods can be used -- if you're block didn't exist yet then my mod might crash if someone had added it to a theme. -
[1.9] Use the vainilla spawner in custom structure
JaredBGreat replied to perromercenary00's topic in Modder Support
The vanilla mobs are basically just the capitalized English names without spaces (though a few could through you off): Bat Blaze CaveSpider Chicken Cow Creeper EnderDragon Enderman Endermite EntityHorse Ghast Giant Guardian LavaSlime MushroomCow Ozelot Pig PigZombie Rabbit Sheep Shulker Silverfish Skeleton Slime SnowMan Spider Squid Villager VillagerGolem Witch WitherBoss Wolf Zombie Doomlike Dungeons and Just Another Spawner can both output names for you. If you'd like do this yourself, you can get the list from the class "net.minecraft.entity.EntityList" EDIT: Its case sensitive, try "Zombie" instead of "zombie" and it should work. -
[1.9] Use the vainilla spawner in custom structure
JaredBGreat replied to perromercenary00's topic in Modder Support
To add a mob you need to create the spawner TileEntity and put the name of the mob in it: I use this method: public static void placeSpawner(World world, int x, int y, int z, String mob) { BlockPos pos = new BlockPos(x, y, z); if(isProtectedBlock(world, x, y, z)) return; placeBlock(world, x, y, z, spawner); TileEntityMobSpawner theSpawner = (TileEntityMobSpawner)world.getTileEntity(pos); MobSpawnerBaseLogic logic = theSpawner.getSpawnerBaseLogic(); logic.setEntityName(mob); } I'm not sure about adding gear -- I've never tried -- so I don't know if the vanilla strings used in command blocks work, though I'm sure there are other methods that catch the spawn event and edit the mob. The name is just the official minecraft name (though mod id is usually needed for modded mobs, if the modder named them correctly, but no mod id for vanilla mob). Note, if the name is wrong the game will run fine but the spawner will be empty and spawn nothing. -
Can I get help with structures generation?
JaredBGreat replied to karurosu's topic in Modder Support
Well, I don't really know how villages are generated (though I can detect them as a forge event). I find the easiest way to generate a structure is to just place the blocks in the world after determining the location, like this: world.setBlockState(new BlockPos(x, y, z), block.getStateFromMeta(a)); Note that that uses the old meta-data (its also 1.9, but I don't think its changed from 1.8 -- in 1.7 there were no block states though and meta data was used directly). That line needs a BlockState -- I get if from metadata read from a config file -- there are more modern ways I've not used that could be used if you aren't using a system similar to that. The thing to do is to use create a generation handler that implements IWorldGenerator and register if with forge during the init phase like so: GameRegistry.registerWorldGenerator(generationHadler, 100); ...or in its constructor (bad for blocks / items, but seems to cause no problem with world generators) like this: GameRegistry.registerWorldGenerator(this, 100); Then, in the generation handler test by whatever means you like to determine if a structure will be there. If so, call a structure building method, which should probably be in its own class. Then, place the blocks like above. As far as which to place there are many ways you could do it. You could use a 3d array that holds them, you could write functions that determine where they are. There are a lot things you can do. For Doomlike Dungeons I read from a bunch of 2d arrays that give heights, blocks, etc., which is procedurally generated to resemble and early '90's 2 1/2 d shooter or rpg map. The ruins mod among others reads in schematic, and I suspect puts them in 3d arrays (not sure, its not my mod). There are many ways you could determine what blocks to place. One things to watch out for, though, is to remember block coordinates and chunk coordinates are not the same -- so keep track of when you need to multiply or divide by 16 to convert from one to the other. I'm not sure I make a good tutorial author, but that should be the basics of it. EDIT: My mod is open source if you want to look at the code. I think code is available for Greymerk's Roguelike Dungeons and Gotolink's updates of the old New Dungeons mod -- and probably others if you look. -
1.7.10 Making my custom dimension a void world
JaredBGreat replied to Elrol_Arrowsend's topic in Modder Support
If you really want a void world, with no world gen at all, you might need to create your own chunk provider that simply returns an array of all 0's (yep, 65536 repetition of 0) to make everything an air block. This isn't too hard -- making a new chunk provider that produces actual terrain in a new way would be, but filling with all one block, not so much. I did this once before with bedrock (planned to house dungeons), but its been away and I don't have that code -- but if you really want nothing, having a chunk provider that is based on all air will work, You should look at the chunk providers / terrain gen stuff in the vanilla code -- not world gen, the step before world gen, terrain gen, specifically chunk providers for clues. The chunk does start as an array of byte[65536] which is why you have to use id and only ids from 0-255 (contrary to popular misconception, this limit applies only terrain generation, not to world gen in general). Not sure what else I can add -- I hope I understood your intentions and that this helps. (BTW, what do you want with a void dimension anyway?)