Jump to content

sshipway

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by sshipway

  1. http://www.steveshipway.org/forum/viewtopic.php?f=44&p=17942 This is a simple mod that allows you to pre-generate chunks on a single-player world. This is useful when - You want to have chunks pre-generated for use in a multiplayer server - You want to run an add-in program, such as MCDungeon, to add structures to your world - You want to edit but with pre-generated terrain first You need to be in Creative mode, and the server thread will appear to hang while the generation takes place (which is why you can't do it in multiplayer). To use, install the mod, then set up the area to generate using /worldgen . You can use any of these options to specify a circle or a rectangle area. /worldgen radius /worldgen x y radius /worldgen x1 y1 x2 y2 E.G. /worldgen 0 0 1000 Finally use /worldgen go to start the generation. Progress logs will appear in the Minecraft log file and log window (if open). A 1,000 block radius circle will take about 20min to generate but this varies considerably depending on CPU speed, memory, other installed mods, and so on. I created this mod specifically to pre-gen large worlds for use with MCDungeon. Note that people using Bukkit have a (much better) alternative in WorldBorder and WorldGuard; there do exist script-based solutions for Forge but I could find no Mod-based ones. Feedback welcome.
  2. When you use /wand copy, instead of /bp copy, you click on the lower corners of the volume to be copied, and the height is automatically worked out by coming down until it hits a hard block. The lower Y coordinate is the minimum of the two clicked corners. So, if you click on [10,60,0] and [15,65,5] then the volume copied will be [10-15,60-H,0-5] where H is the highest block in the [10-15,0-5] column - which may well be 100 if there is something up that high. It works this way because you cannot click on an air block, and usually the top of your structure volume will have air in the corners. If you want to copy a specific volume, you can use /bp copy to specify the exact corners. The /wand copy command is intended to make things easier when copying an outside structure with nothing else above it. The problem might occur if you have an overhanging cliff, or a tree, or something floating in the air 69 blocks above you. Then you'll end up copying higher than you intended - though you could save with /bp save and subsequently edit the saved .bp file in a text editor and remove the offending block(s), before doing a /bp load to reload the blueprints.
  3. Thanks for this; I'd found IChunkProvider but not ChunkProvderServer. Obviously now I can call dropChunk() to get rid on the individual chunks (for some reason, dropChunk does not appear to exist in IChunkProvider). I assume that the instance of ChunkProviderServer to use this one -- ChunkProviderServer cps; cps = MinecraftServer.getServer().worldServers[0].theChunkProviderServer; cps.saveChunks(true,null); // make sure we have no pending updates cps.dropChunk(x,z); ... and indeed, the getLoadedChunkCount() from both the IChunkProvider and the ChunkProviderServer now never goes above approx 700, and the memory death is averted. Thanks for the help
  4. I have a (server-side) mod which is accessing a large number of chunks when it activates. Once accessed, these chunks do not need to remain in the cache as they are not likely to be accessed again for a long time. The problem is that the Java heap memory runs out. This is because the IChunkProvider.getLoadedChunkCount() shows me that I have many thousands of chunks still in the cache, exhausting the available memory. My question is, how can I kick these out of the cache? I've tried all of these: world.getChunkProvider().saveChunks(true,null); world.getSaveHandler().flush(); world.getChunkProvider().unloadQueuedChunks(); world.getWorldChunkManager().cleanupCache(); (new Chunk(world, x, y)).setChunkLoaded(false); However none of them seem to affect the cache size, which goes relentlessly upwards until a malloc error ends its life. What is the correct way to flag these cached chunks for unloading? TIA
  5. Version 2.5 is available from http://www.steveshipway.org/mc/builders-helper-2.5.zip This supports Ruins Templates and MCEdit Schematics, and can convert them to Blueprint format. There is also an 'undo' command to back out your changes, and you can select a structure by clicking on the corners of the base. It also supports a 'flatten' command to smooth out the land below a structure to avoid overhangs.
  6. Version 2.4 is available from http://www.steveshipway.org/mc/builders-helper-2.4.zip Changes: You can select the area to copy using right-click on the wand, rather than having to type in the coordinates. It also adds support for Ruins Templates (from the Ruins mod); these are automatically converted to Blueprint format and made available. Additional blueprints added Corrections to Float and Soft code Support for ChestGenHooks
  7. Version 2.3.2 is now available. This fixes some bugs, and adds the MSG and PICTURE directives. You can now create maps displaying the pictures from external image files!
  8. Aha! It seems that, in Minceraft 1.7, the data.markDirty() call is essential -- this is what causes the initial NBT file to be written. In Minecraft 1.8, it happens implicitly. I've added this call immediately after world.setItemData call, and now my code also works in 1.7.10. Thanks for the help -- I've posted here for the benefit of any future readers with a similar problem.
  9. While the method above works in 1.8, it seems that in 1.7 things are somewhat different. The code will create the object in-game, but the 'map' picture displays progressively, column by column. The worse part is that the map_#.dat NBT file is not written on save (though the idcounts ARE updated) and when the game is restarted, the 'map' is now a basic 0,0 blank map. Clearly, under 1.7, there is something else that needs to be done in order to add the map data to the world. Writing the map_#.dat NBT file myself only results in the previously mentioned "the world has been modified by something else" error, even if I try the trick of setting the file last modification time. The other problems, of ItemFrame being an entity and its Tile* attributes being different under 1.7 and 1.8 have been solved, and that's behaving, at least... V1.8 seem to me to be far easier to code for, and far more forgiving of missing or invalid data. They seem to have coded with the expectation of mods being created.
  10. Many thanks! The mystery was the correct usage of the MapData object. Although I had managed to avoid the error in the previous code by writing the NBT file and then setting the last modification time into the past, that solution was... suboptimal The function now all works, and I can generate framed-map 'pictures' in-game from external image files on the fly. public static short createMap(World world, String imgFilename , Logger logger ) { short mapNo; String mapFilename; NBTTagCompound map; MapData data; // build map object NBT map = imgToNBT(imgFilename,logger); if( map == null ) { return -1; } // unable to convert // get a new unique ID for the new map mapNo = (short) world.getUniqueDataId("map"); // save the data data = new MapData("map_"+mapNo); data.readFromNBT(map); world.setItemData("map_"+mapNo,data); return mapNo; }
  11. So, I'm trying to create a new filled_map item, preloaded with data (it is converted from an external image file). I have already created the code to convert my chosen image to an NBTCompoundTag corresponding to the Map Data. I can obtain a new, unique mapID, and write the NBT file to the correct data/map_#.dat location: mapNo = (short) world.getUniqueDataId("map"); String folderName = MinecraftServer.getServer().getFolderName(); ISaveFormat saveFormat = MinecraftServer.getServer().getActiveAnvilConverter(); SaveHandler saveHandler = (SaveHandler)saveFormat.getSaveLoader(folderName, false); String worldsavedir = saveHandler.getWorldDirectory().getPath(); mapFilename = worldsavedir + File.separator + "data" + File.separator + "map_" + mapNo + ".dat"; CompressedStreamTools.writeCompressed(map,new FileOutputStream(mapFilename)); This then allows me to make an object in the game, should I wish: mapItemStack = new ItemStack(Items.filled_map,1,mapNo); The new object appears in the game, has the correct contents, and seems happy. The problem is that, when I try to save the world, Minecraft complains that the world has been modified by something else -- the cause is the writing of the map_#.dat file, which must break some save-time integrity test. It is valid NBT (because exiting Minecraft and restarting allows things to work) but clearly, I should be using some internal function to write the new map out, not the CompressedStreamTools. I can create a MapData object like this: md = new MapData("map"); // what is the parameter for? md.readFromNBT(map); However, I cannot identify how to write this and obtain the unique DataId. There is a MapStorage class, and an ItemMap class, but I cannot work out how to link the MapData to these, obtain a unique ID, and force a save. I can possibly do this: im = Items.filled_map; im.updateMapData(world, entity, md); ... but it is unclear what the 'entity' refers to, and again there seems to be no way to specify the mapNumber. Conversely, the MapStorage class allows me to make a new mapNumber and apparently to save the maps, but I have no way to assign the MapData object to the new mapNumber. Any help and pointers on this would be appreciated. I feel like I'm so close, but blocked by a lack of documentation... Steve
  12. Many thanks for the tip. Your camera mod looks awesome, though it does not generate a filled_map but a custom photo object; if only this were available for 1.7.10 or 1.8 I'd install it immediately. Fortunately for me, my chosen niche is not yet completely filled, as I'm planning on doing in-game conversion from external jpgs to filled_map objects. I'll skip the 'camera' object part as you've already done that so well...
  13. To copy a structure in-game: [*]Hold the Wand, or be in Creative mode [*]Use the command: /bp copy myname x1 y1 z1 x2 y2 z2 Replace myname with the name you want to store the new blueprint under. The coordinates are for opposite corners of the box to copy; so "1 2 3 4 5 6" will copy from block 1,2,3 to block 4,5,6 (a 3x3x3 cube). It will not copy Air blocks. [*]You can now use /wand set myname to make the wand produce your newly copied blocks when you right-click at a location. [*]Use /bp savemyname to save your new blueprint to disk as confg/bp/myname.cfg . This will make it persist after game restarts. [*]Note that the 'origin' as defined by a /bp copy may not be precisely where you want it to be. In this case, you can edit the new blueprint file to wrap the new plan in another plan that simply does an offset and/or rotation. See the cottage.cfg example blueprint for a demonstration of this. To use the wand: [*]The wand is initially not set to do anything. You need to "enchant" it (I.E., associate it with an existing Blueprint). [*]Use /bp list to list the Public blueprints. [*]Use /wand set name to set the wand to produce a specific blueprint. This works with public or private blueprints. [*]Right-click (use) the wand on a block. You must be targetting a block; just clicking in the air does nothing. This will create the specified structure at this point. [*]You may need to wait a few seconds for the structure to appear, depending on the complexity of the structure, or the speed of your server. A chat message will tell you when the build is completed (or if it failed for any reason). Using Blueprints [*]A blueprint is a file containing one or more plans, which contain sequences of instructions to create a structure. The directory of blueprints is called the portfolio. [*]A particular plan may call one or more other plans multiple times; in fact, this is a recommended way to define structures. The sub-plans can be marked 'private', which means their names do not normally display when listing plans. [*]A plan may be marked as 'autocreate' with a probability and biome list. This is used by the autogenerator to randomly create this structure in the world as new chunks are defined. [*]Blueprints can be created by the /bp save command, usually after running /bp copy to copy something in-world. However, it is usually more efficient to write or edit them by hand. [*]The Blueprint language is structured similarly to the language Logo. It has basic testing and branching, and can use 'soft' blocks (which only place in Air) or 'meta' blocks (which have an element of randomness or dependence on biome). The language is detailed in the readme.cfg sample blueprint; there are also many other example blueprints provided to help you. [*]Plans in one blueprint may call plans from another; however this is not generally recommended as you cannot be certain which order they will be evaluated in. It is best to keep all related plans in a single blueprint file. Also, it is Best Practice (though not required) to prefix private plans with an underscore, and have all plans in a blueprint with a common prefix -- for example, "hut", "_hut_roof", "_hut_window". [*]Be careful with recursion. An infinitely-recurring plan will hang the server thread (this will be hopefully prevented in a future release) I hope this helps! Documentation is slowly being written. I'm hoping that other module writers may pick up on the blueprint language as being a convenient way to define structures, and it could become a common language for exchanging structural definitions.
  14. So, I am trying to create a new microsoft:filled_map item. It's pretty easy to make an empty one, or even one that will fill from the world map, but how do I set the contents dynamically? If the game were offline, I could increment the counter in the idcounts.dat NBT, then create a new maps/map_#.dat file for the new ID, and create the item with the appropriate id set. However, I'd like to do this online... Is there an API call that I can use to set the map data (creating the map_#.dat and incrementing the idcounts.dat) from a colors array? The intention for this is to be able to create a 'picture' (actually a filled map) in game from either an external file, or a view via a 'camera' object, that can be placed in an item frame for display. Thanks for any suggestions or help...
  15. Version 2.3.1 is now available, and implements the IFBIOME and IFBLOCK tests. This now supports 1.7.10 and 1.8, and fixes the issues with metablocks not always working as well as the issues with log rotation in 1.8.
  16. Next enhancements -- 1. an IFBIOME directive, to branch on certain biome matches (so you can have dcompletely different structures in different biomes form the same blueprint) 2. an IFBLOCK <x><y><z> <id> directive, to branch if the block at a certain relative position matches (so you can have a structure that continues until a condition is met, such as a tunnel ending on the other side of a hill, or a bridge pier ending at ground level. eg. PUBLIC PLAN village CALL meta_cottage 0 0 0 0 IFBIOME Desert CALL 10 0 10 0 desert_well CALL 10 0 10 0 other_well END PUBLIC PLAN tunnel_section IFBLOCK 10 0 0 minecraft:air NOOP CALL tunnel_section 10 0 0 0 CALL build_section 0 0 0 0 END
  17. Version 2.2 is now released, with source for both 1.7.10 and 1.8 This adds the MOB directive, allowing blueprints to include minecarts, armour stands, zombies and so on; the /bp copy command will copy mobs in the region as well. You can also specify blocks as MetaBlocks, such as OLD_STONE. This will resolve to a different block depending on biome and randomness to give a more realistic look (thanks to the coders of mcDungeon for this idea!) Pick up from http://www.steveshipway.org/mc/builders-helper-2.2.zip
  18. Version 2.1 (beta1) is now available. This allows chests to be defined using this sort of syntax: CHEST 1 2 3 2 stick,0,5;50 minecraft:silk,6;90 This gives you a 50% chance of 0-5 sticks, and a 90% chance of 6 pieces of string. You can also use NBT either inline or in external files to specifiy either an item or the entire chest. Similarly, you can define spawners to have multiple weights and source by name or from external files: SPAWNER 1 2 3 Skeleton;10 Zombie;10 externalfile.nbt;20 Some examples are shipped with the module.
  19. In Minecraft 1.8, things are a lot easier because you can use the generic blockstate to give you an Enum for direction, which can be used to rotate. As long as orientable userdefined blocks use the standard EnumDirection or EnumOrientation (which is highly likely) then it is possible to make a generic rotation function... of course, there will always be a few exceptions, which end up not rotating. For 1.7, I handled rotation in the same way as the code example you linked to -- with a special rotate function that takes the DV and returns a rotated on for the specified block type, using many If statements. Highly non-ideal, but all you can do, I think. I wish that Mojang has standardised on a sngle way to specify orientation back at the beginning Having an option in the module cfg file to customise <blockname>=<bitmask>,<dv>,<dv>,<dv>,<dv> or <blockname>=<statename>,<valuelist> to specify the n/s/e/w DV values might be the way to go for custom blocks with orientation.
  20. I like the ability to script out a chain of commands; this is very useful if it can be called by (eg) a command block as these only allow a single command, of course. If building an Adventure map where you want to trigger complex actions via a command block, this would allow far more possibilities (I think Mojang dropped the ball a bit by not allowing a command block to run multiple commands) For placing blocks, I think there is an easier way to do it than to script as a chain of commands. May I suggest you take a look at the mod I've been working on for a couple of months now, the Builder's Helper -- http://www.minecraftforge.net/forum/index.php/topic,26612.0.html -- this allows definition of structures using a 'blueprint' language, and can copy structures from the world as well as place them. It takes care of rotations, metadata, random selection, 'soft' blocks, block from other add-in modules, and (in the latest beta) randomising spawners and chest contents. The source code is included in the zip file if you want to see how I achieved the rotations.
  21. Version 2.0 is now in beta, for Minecraft 1.8 only This includes new directives to allow placing of Chests with randomised contents and Spawners with randomised and customised mobs; you can also specify metadata, chests, items, spawners and mob using NBT files instead of JSON. There are a few more provided blueprints, as well. The Blueprint Java package is now properly packaged up in a separate heirachy from the module so that it is portable and reuseable by other modules. A number of instances of bad coding have been rewritten, and the module used BlockPos and NBTTagCompound objects internally.
  22. Version 1.0, for both Minecraft 1.7.10 and 1.8, is now released (link in the first posting). This includes a large blueprint library, as well as the ability to auto-create blueprints in new chunks.
  23. Hi -- we appear to be approaching the same rough target from different direction. I'm writing a separate mod ( here ) that focusses on on-demand in-world generation of customisable user-defined structures, with a possibility of in the future making them auto-generate via the World Generator. Your mod is apparently handling the World Generation piece first, then looking at adding new structures to its repertoire. I'm really interested in seeing how you're achieving your outcome -- are you planning on releasing the current beta sourcecode as open source at all, either via a simple zip archive or via something like Github? If you're interested, you can grab a copy of my code in the latest package under my module's thread. I'd also be interested in collaboration on a common structure definition file format. -Steve
  24. I'll give this a go. Strangely, the other (non-container) blocks which can rotate (e.g., stone stairs) seem to work with a single placing; and the setBlock() directive takes DV as a parameter, so you'd think it would be used... also, I thought they defaulted to DV=2, not 3. - goes away and does a quick recompile and test - Well, you were right - that was the problem. For Container blocks, it seems that DV cannot be set at the time of placement, for some reason known only to Mojang. Many thanks for clearing this one up for me, have a +1.
  25. It might be possible to hook this into the world generation hooks, so that specified plans are randomly generated during world generation. A plan could be enabled for autogeneration using an Option flag, with a probability and valid biomes in which it may appear; then, you'd be able to customise the autogenerated structures easily. I'm not sure how simple this would be to do; it also changes the focus of the mod from being one used by a builder and then removed before playing, to being one intended to be permanently loaded. It would also be necessary to have a module cfg file (separate from the blueprint files) to enable or disable such things are the wand crafting recipie, autogeneration, and so on.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.