From fbd59a9c7ebcb167ec6170b70217bb4a410895f4 Mon Sep 17 00:00:00 2001 From: JohnBraham Date: Tue, 20 Oct 2026 13:49:55 +0100 Subject: [PATCH] Update terrain smoothing integration and source readability --- .editorconfig | 10 + CONTRIBUTING.md | 15 + README.md | 2 +- build.gradle | 13 +- docs/BUILDING.md | 39 +- gradle/content-dependencies.properties | 6 +- .../skysterrainsmoother/probe/CaveProbe.java | 433 +++++--- .../probe/ClientProbe.java | 117 ++- .../probe/ClientStatus.java | 8 +- .../probe/LateTerrainProbe.java | 295 ++++-- .../skysterrainsmoother/probe/ProbeProxy.java | 6 +- .../probe/RuntimeProbe.java | 986 +++++++++++++----- .../SkysTerrainSmoother.java | 84 +- .../api/TerrainMaterial.java | 77 +- .../api/TerrainSmoothingApi.java | 50 +- .../client/ClientProxy.java | 11 +- .../client/CommonProxy.java | 5 +- .../content/SandContent.java | 17 +- .../content/SandSlabBlock.java | 141 ++- .../content/SandSlabItem.java | 75 +- .../internal/BuiltInMaterials.java | 120 ++- .../internal/EmptyAccess.java | 40 +- .../internal/ExistingChunkIndex.java | 58 +- .../internal/Footprint.java | 66 +- .../internal/MaterialCatalogue.java | 243 ++++- .../internal/SmoothingEngine.java | 656 ++++++++---- .../internal/StructureProtection.java | 42 +- .../mc/skysterrainsmoother/CatalogueTest.java | 142 ++- .../ExistingChunkIndexTest.java | 42 +- .../mc/skysterrainsmoother/FootprintTest.java | 82 +- .../ProjectContractTest.java | 153 ++- .../PublicationContractTest.java | 33 +- style/eclipse-java-formatter.xml | 56 + 33 files changed, 3035 insertions(+), 1088 deletions(-) create mode 100644 .editorconfig create mode 100644 CONTRIBUTING.md create mode 100644 style/eclipse-java-formatter.xml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..192b055 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*.java] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +max_line_length = 120 +trim_trailing_whitespace = true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..13fa9f2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Contributing + +Keep the code easy to read and straightforward to review. + +- Use four spaces, UTF-8 and LF line endings. Aim for 120 columns; do not split a registry ID or other literal just to meet the limit. +- Put each statement on its own line and use braces for conditional and loop bodies, including early returns. +- Leave a blank line between logical steps. Keep related assignments together rather than separating every line. +- Name variables for their role. Use `inventorySlot`, `cellX` or `chunkX` when that context matters, rather than a single letter or a type abbreviation. Keep established names such as `world` and `state` when their meaning is already clear. +- Declare separate local values on separate lines. Explain packed masks and coordinate conventions where the names cannot tell the whole story. +- Write comments in plain English. Explain a decision, save-format constraint or surprising API behaviour instead of repeating what the next line says. +- Document public extension points, including when they can be called and what they preserve. Keep comments current when behaviour changes. + +For Eclipse, import [the Java formatter profile](style/eclipse-java-formatter.xml) under **Java > Code Style > Formatter** and select **Sky Java**. The formatter handles layout; braces and logical grouping still need a quick human review. + +Treat registry IDs, metadata palettes, configuration keys and saved NBT fields as compatibility contracts. A readability change should not alter them. Keep behavioural changes separate and run the relevant tests before submitting a pull request. See [the build guide](docs/BUILDING.md) for this branch's toolchain and checks. diff --git a/README.md b/README.md index 556cd76..3ece957 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ slabs for beaches and desert slopes. This beta is for Minecraft 1.10.2 and Forge 12.18.3.2511. Install Terrain Smoother 0.1.0.110021, Grass Slabs 1.1.0.110021 and Building Pieces -0.3.0.110021 together on the client and server. Mineralogy is optional. +0.3.6.110021 together on the client and server. Mineralogy is optional. ## Smoothing levels diff --git a/build.gradle b/build.gradle index 7641b77..110f799 100644 --- a/build.gradle +++ b/build.gradle @@ -62,15 +62,24 @@ tasks.withType(JavaCompile).configureEach { def grassSlabsDirectory = file(providers.gradleProperty('grassSlabsDirectory').getOrElse('../..' + '/SkysGrassSlabs110/SkysGrassSlabs')) def buildingPiecesDirectory = file(providers.gradleProperty('buildingPiecesDirectory').getOrElse('../..' + '/SkysBuildingPieces110/SkysBuildingPieces')) def grassSlabsDevelopmentJar = new File(grassSlabsDirectory, 'build/libs-dev/SkysGrassSlabs-1.1.0.110021-deobf.jar') -def buildingPiecesDevelopmentJar = new File(buildingPiecesDirectory, 'build/libs-dev/SkysBuildingPieces-0.3.0.110021-deobf.jar') def contentLock=new Properties() file('gradle/content-dependencies.properties').withInputStream { contentLock.load(it) } + +def localPiecesVersion = providers.gradleProperty('buildingPiecesCoreVersion') +if (localPiecesVersion.isPresent() && + (System.getenv('CI') != null || !providers.gradleProperty('buildingPiecesDirectory').isPresent())) { + throw new GradleException('A local core-version override needs an explicit core directory and is not allowed in CI.') +} +def piecesVersion = localPiecesVersion.getOrElse(contentLock.getProperty('pieces.version')) +def buildingPiecesDevelopmentJar = new File(buildingPiecesDirectory, + "build/libs-dev/SkysBuildingPieces-${piecesVersion}-deobf.jar") def verifyContentDependencies=tasks.register('verifyContentDependencies') { doLast { [grass:grassSlabsDirectory,pieces:buildingPiecesDirectory].each { name,directory -> Properties metadata=new Properties() new File(directory,'gradle.properties').withInputStream { metadata.load(it) } - if(metadata.mod_version!=contentLock.getProperty(name+'.version')) + String expectedVersion = name == 'pieces' ? piecesVersion : contentLock.getProperty(name + '.version') + if(metadata.mod_version!=expectedVersion) throw new GradleException('Content dependency version does not match its lock: '+name) if(System.getenv('CI')!=null) { Process git=new ProcessBuilder('git','-C',directory.path,'rev-parse','HEAD').start() diff --git a/docs/BUILDING.md b/docs/BUILDING.md index efbd47b..34fb9f3 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -1,23 +1,28 @@ # Building from source -Use Java 17 for Gradle and Temurin 8.0.502+7 for production. Set `STS_JAVA8_HOME` -to the Java 8 installation. The wrapper uses Gradle 9.6.1 and ForgeGradle -7.0.34 with stable 29-1.10.2 mappings. +Use the Gradle 9.6.1 wrapper with Java 17 and Temurin 8.0.502+7 for production. +Set `STS_JAVA8_HOME` to the Java 8 installation. This branch targets +Minecraft 1.10.2 with ForgeGradle 7.0.34. -Build the Grass Slabs and Building Pieces source commits recorded in +Build the exact Grass Slabs and Building Pieces source commits listed in `gradle/content-dependencies.properties` with their `jar` tasks first. -Then run `gradlew check build javadoc verifyReleaseArtifacts -writeReleaseChecksums verifyEclipseProductionClasspath` here. -The default layout uses sibling Grass Slabs and Building Pieces 1.10 -checkouts. Elsewhere, pass `-PgrassSlabsDirectory=` and -`-PbuildingPiecesDirectory=`. Development dependencies use their -deobfuscated jars; packaged games use the normal main jars. No dependency -classes or assets are bundled. +The default layout uses sibling checkouts. For another layout, pass +`-PgrassSlabsDirectory=` and +`-PbuildingPiecesDirectory=`. +Then run: -The build-only integration mod exercises real Forge startup, grass lifecycle, -every footprint, player-tracked chunk generation and a saved-world reload. -It is absent from production artifacts and ordinary Eclipse runs. Use -`genEclipseRuns eclipse` to regenerate those runs. CI builds the pinned content -mods first. Publication remains disabled until this mod has its own CurseForge -project. +```text +gradlew check build javadoc verifyReleaseArtifacts writeReleaseChecksums verifyEclipseProductionClasspath +``` + +Development dependencies use deobfuscated jars. Packaged games use the normal +main jars; dependency classes and assets are not bundled. CI builds the exact +pinned commits rather than moving branches. + +A local-only `buildingPiecesCoreVersion` override can test another core +candidate. It requires an explicit core directory and is rejected in CI. + +Use `genEclipseRuns eclipse` to prepare the Java 8 IDE setup. Ordinary launches +exclude unit tests and build-only runtime probes. Publication remains disabled +until this mod has its own CurseForge project. diff --git a/gradle/content-dependencies.properties b/gradle/content-dependencies.properties index 73c6780..35858e7 100644 --- a/gradle/content-dependencies.properties +++ b/gradle/content-dependencies.properties @@ -1,6 +1,6 @@ grass.repository=SkyBlade1978/SkysGrassSlabs -grass.commit=95c11e25bd8dad7398e05104277aa6cb522719bc +grass.commit=5ebc77d3e1195e4c537994ad3ffe0f234332321f grass.version=1.1.0.110021 pieces.repository=SkyBlade1978/SkysBuildingPieces -pieces.commit=f21616d4e4bfe09dcf25490a3568fd846a820792 -pieces.version=0.3.0.110021 +pieces.commit=f55f53d0c6f29e741635f47234fbabba893bdffd +pieces.version=0.3.6.110021 diff --git a/src/integrationTest/java/zone/moddev/mc/skysterrainsmoother/probe/CaveProbe.java b/src/integrationTest/java/zone/moddev/mc/skysterrainsmoother/probe/CaveProbe.java index f0ca517..9414771 100644 --- a/src/integrationTest/java/zone/moddev/mc/skysterrainsmoother/probe/CaveProbe.java +++ b/src/integrationTest/java/zone/moddev/mc/skysterrainsmoother/probe/CaveProbe.java @@ -21,167 +21,330 @@ /** Real cave-floor regressions, never included in production launches or jars. */ final class CaveProbe { - private static final int[] DX={0,1,0,-1},DZ={-1,0,1,0},CX={-1,1,1,-1},CZ={-1,-1,1,1}; - private CaveProbe() { } + private static final int[] DX = { 0, 1, 0, -1 }, DZ = { -1, 0, 1, 0 }, CX = { -1, 1, 1, -1 }, CZ = { -1, -1, 1, 1 }; + + private CaveProbe() { + } + static int run(WorldServer world) { - BlockPos floor=new BlockPos(3000,70,3000); - Chunk owner=world.getChunkFromBlockCoords(floor); - clear(world,floor,69,255); - fixture(world,floor,6); - world.setBlockState(floor.north().up(),Blocks.STONE.getDefaultState(),2); - SkysTerrainSmoother.engine.smooth(world,owner,1); - RuntimeProbe.require(!world.isAirBlock(floor.up()),"cave floor below a roof receives a matching slab"); - int checks=1; - TerrainMaterial stone=MaterialCatalogue.instance().source(Blocks.STONE.getDefaultState()); - for(int level=1;level<=3;level++)for(int cardinal=0;cardinal<16;cardinal++)for(int diagonal=0;diagonal<16;diagonal++) { - fixture(world,floor,6); - for(int d=0;d<4;d++) { - if((cardinal&(1<