{"id":13510910,"url":"https://github.com/NucleoidMC/fantasy","last_synced_at":"2025-03-30T19:30:34.967Z","repository":{"id":44410664,"uuid":"314531618","full_name":"NucleoidMC/fantasy","owner":"NucleoidMC","description":"Library to support creating dimensions at runtime","archived":false,"fork":false,"pushed_at":"2025-03-10T20:59:50.000Z","size":340,"stargazers_count":109,"open_issues_count":11,"forks_count":31,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-10T21:35:12.511Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NucleoidMC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-20T11:16:17.000Z","updated_at":"2025-03-10T20:59:31.000Z","dependencies_parsed_at":"2024-01-16T12:46:18.103Z","dependency_job_id":"3bec5382-3dc3-4f7a-b113-3069a12e5595","html_url":"https://github.com/NucleoidMC/fantasy","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NucleoidMC%2Ffantasy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NucleoidMC%2Ffantasy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NucleoidMC%2Ffantasy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NucleoidMC%2Ffantasy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NucleoidMC","download_url":"https://codeload.github.com/NucleoidMC/fantasy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246368596,"owners_count":20766052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-08-01T03:00:21.851Z","updated_at":"2025-03-30T19:30:34.676Z","avatar_url":"https://github.com/NucleoidMC.png","language":"Java","funding_links":[],"categories":["API \u0026 Libraries"],"sub_categories":[],"readme":"# Fantasy\nFantasy is a library that allows for dimensions to be created and destroyed at runtime on the server.\nIt supports both temporary dimensions which do not get saved, as well as persistent dimensions which can be safely used across server restarts.\n\n## Using\n\n### Adding to Gradle\nTo add Fantasy to your Gradle project, add the Nucleoid Maven repository and Fantasy dependency.\n`FANTASY_VERSION` should be replaced with the latest version from [Maven](https://maven.nucleoid.xyz/xyz/nucleoid/fantasy).\n```gradle\nrepositories {\n  maven { url = 'https://maven.nucleoid.xyz/' }\n}\n\ndependencies {\n  // ...\n  modImplementation 'xyz.nucleoid:fantasy:FANTASY_VERSION'\n}\n```\n\n### Creating Runtime Dimensions\nAll access to Fantasy's APIs goes through the `Fantasy` object, which can be acquired given a `MinecraftServer` instance.\n\n```java\nFantasy fantasy = Fantasy.get(server);\n// ...\n```\n\nAll dimensions created with Fantasy must be set up through a `RuntimeWorldConfig`.\nThis specifies how the dimension should be created, involving a dimension type, seed, chunk generator, and so on.\n\nFor example, we could create a config like such:\n```java\nRuntimeWorldConfig worldConfig = new RuntimeWorldConfig()\n        .setDimensionType(DimensionTypes.OVERWORLD)\n        .setDifficulty(Difficulty.HARD)\n        .setGameRule(GameRules.DO_DAYLIGHT_CYCLE, false)\n        .setGenerator(server.getOverworld().getChunkManager().getChunkGenerator())\n        .setSeed(1234L);\n```\n\nValues such as difficulty, game rules, and weather can all be configured per-world. \n\n#### Creating a temporary dimension\nOnce we have a runtime world config, creating a temporary dimension is simple:\n```java\nRuntimeWorldHandle worldHandle = fantasy.openTemporaryWorld(worldConfig);\n\n// set a block in our created temporary world!\nServerWorld world = worldHandle.asWorld();\nworld.setBlockState(BlockPos.ORIGIN, Blocks.STONE.getDefaultState());\n\n// we don't need the world anymore, delete it!\nworldHandle.delete();\n```\nExplicit deletion is not strictly required for temporary worlds: they will be automatically cleaned up when the server exits.\nHowever, it is generally a good idea to delete old worlds if they're not in use anymore.\n\n#### Creating a persistent dimension \nPersistent dimensions work along very similar lines to temporary dimensions:\n\n```java\nRuntimeWorldHandle worldHandle = fantasy.getOrOpenPersistentWorld(new Identifier(\"foo\", \"bar\"), config);\n\n// set a block in our created persistent world!\nServerWorld world = worldHandle.asWorld();\nworld.setBlockState(BlockPos.ORIGIN, Blocks.STONE.getDefaultState());\n```\n\nThe main difference involves the addition of an `Identifier` parameter which much be specified to name your dimension uniquely.\n\nAnother **very important note** with persistent dimensions is that `getOrOpenPersistentWorld` must be called to re-initialize\nthe dimension after a game restart! Fantasy will not restore the dimension by itself- it only makes sure that the world data\nsticks around. This means, if you have a custom persistent dimension, you need to keep track of it and all its needed\ndata such that it can be reconstructed by calling `getOrOpenPersistentWorld` again with the same identifier.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNucleoidMC%2Ffantasy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNucleoidMC%2Ffantasy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNucleoidMC%2Ffantasy/lists"}