{"id":18623671,"url":"https://github.com/Ueaj-Kerman/Fields-API","last_synced_at":"2025-11-03T18:30:28.364Z","repository":{"id":111231701,"uuid":"358118087","full_name":"Devan-Kerman/Fields-API","owner":"Devan-Kerman","description":"Value fields for Minecraft Worlds (eg. Heat, Gas)","archived":false,"fork":false,"pushed_at":"2021-04-22T23:08:46.000Z","size":110,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-27T05:25:04.470Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Devan-Kerman.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":"2021-04-15T03:43:07.000Z","updated_at":"2021-04-22T23:08:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"f904a2a7-cf2a-4a23-8ee7-04937241dcce","html_url":"https://github.com/Devan-Kerman/Fields-API","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devan-Kerman%2FFields-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devan-Kerman%2FFields-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devan-Kerman%2FFields-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devan-Kerman%2FFields-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Devan-Kerman","download_url":"https://codeload.github.com/Devan-Kerman/Fields-API/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239418575,"owners_count":19635208,"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":[],"created_at":"2024-11-07T04:25:36.131Z","updated_at":"2025-11-03T18:30:28.333Z","avatar_url":"https://github.com/Devan-Kerman.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fields-API\nValue fields for Minecraft Worlds (eg. Heat, Gas)\n\n```groovy\nrepositories {\n    maven {\n        url 'https://storage.googleapis.com/devan-maven/'\n    }\n}\n\ndependencies {\n    ...\n    modImplementation 'net.devtech:fields-api-fabric:2.0.0'\n    // there is a forge version as well now, fields-api-forge\n}\n```\n\n```java\nValueField.Int pollution = ValueField.create(INT_GRADIENT, new Identifier(\"mymod\", \"pollution\")); // store in a static final field somewhere\nint pollution = pollution.getInt(world, pos); // get pollution at point\npollution.setInt(world, pos, 0); // delete pollution\n\n// idk do something\nItemStack stack = new ItemStack(MyItems.SLUDGE, pollution);\n```\n\n\n## ValueFields\nValueField is just an accessor basically, it's an interface to translate global calls (eg. world + pos) to local ones (eg. chunksection). Feel free to make your own for other primitives\n\n## DataHandlers\nDataHandler is the format in which the data is stored in memory, and can tick `TickingDataHandler`. Overriding the `shouldSync` method and returning true allows \n\n```java\npackage net.devtech.heat;\n\nimport java.util.Arrays;\nimport java.util.Collections;\n\nimport net.devtech.fields.v0.api.DataFormatInitializer;\nimport net.devtech.fields.v0.api.data.GradientPackedDataHandler;\nimport net.devtech.fields.v0.api.data.TickingDataHandler;\nimport net.devtech.fields.v0.api.value.ValueField;\n\nimport net.minecraft.server.world.ServerWorld;\nimport net.minecraft.util.Identifier;\nimport net.minecraft.util.math.Direction;\nimport net.minecraft.world.Heightmap;\nimport net.minecraft.world.chunk.ChunkSection;\nimport net.minecraft.world.chunk.WorldChunk;\n\nimport net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;\n\n// this is kinda broken cus it doesn't actually spread heat to nearby subchunks, so heat will just say within the same subchunk\n// a proper implementation is an excersize left up to the reader :wink:\npublic class HeatDataHandler extends GradientPackedDataHandler implements TickingDataHandler {\n\tpublic static final Direction[] DIRECTIONS = Direction.values();\n\tstatic {\n\t\tServerTickEvents.START_SERVER_TICK.register(server -\u003e Collections.shuffle(Arrays.asList(DIRECTIONS)));\n\t}\n\n\tpublic HeatDataHandler(DataFormatInitializer.Entry\u003cInteger, ValueField.Int\u003e entry, ChunkSection section, Identifier id) {\n\t\tsuper(entry, section, id);\n\t}\n\n\t@Override\n\tpublic void onTick(ServerWorld world, WorldChunk chunk) {\n\t\tif(this.max == 0) return;\n\t\tint disequalibrium = 100 / Math.max(Math.abs(this.min), this.max);\n\t\tif (world.getTime() % disequalibrium == 0) {\n\t\t\tfor (int x = 0; x \u003c 16; x++) {\n\t\t\t\tfor (int z = 0; z \u003c 16; z++) {\n\t\t\t\t\tint surface = chunk.getHeightmap(Heightmap.Type.WORLD_SURFACE).get(x, z);\n\t\t\t\t\tfor (int y = 0; y \u003c 16; y++) {\n\t\t\t\t\t\tint i = this.getInt(x, y, z);\n\t\t\t\t\t\tif(y \u003e= surface) { // if exposed to sky\n\t\t\t\t\t\t\tif(i \u003c 0) {\n\t\t\t\t\t\t\t\t// radiate excess heat into space\n\t\t\t\t\t\t\t\tthis.setInt(x, y, z, i--);\n\t\t\t\t\t\t\t} else if(i \u003e 0) {\n\t\t\t\t\t\t\t\t// get heated up by the sun\n\t\t\t\t\t\t\t\tthis.setInt(x, y, z, i++);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// spread heat\n\t\t\t\t\t\tfor (Direction direction : DIRECTIONS) {\n\t\t\t\t\t\t\tint a = this.getInt(x + direction.getOffsetX(), y + direction.getOffsetY(), z + direction.getOffsetZ());\n\t\t\t\t\t\t\tif (i - a \u003e 2) {\n\t\t\t\t\t\t\t\tint avg = (i + a) / 2;\n\t\t\t\t\t\t\t\ti = avg;\n\t\t\t\t\t\t\t\ta = ((i - a \u0026 1) == 0 ? 0 : 1) + avg;\n\t\t\t\t\t\t\t\tif (this.setInt(x + direction.getOffsetX(), y + direction.getOffsetY(), z + direction.getOffsetZ(), a)) {\n\t\t\t\t\t\t\t\t\tthis.setInt(x, y, z, i);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUeaj-Kerman%2FFields-API","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FUeaj-Kerman%2FFields-API","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUeaj-Kerman%2FFields-API/lists"}