From b9df372fd8290dbcae4266b51764e217ad080b81 Mon Sep 17 00:00:00 2001 From: Thomas Couchoud Date: Mon, 21 Sep 2020 20:08:07 +0200 Subject: [PATCH] Allow mixed logs --- .github/workflows/gradle_build.yml | 45 +++++++++++++++++-- .github/workflows/gradle_deploy.yml | 44 ------------------ CHANGELOG.md | 3 ++ changes.md | 3 +- gradle.properties | 6 +-- .../fallingtree/config/TreeConfiguration.java | 8 ++++ .../fallingtree/tree/TreeHandler.java | 13 ++++-- update.json | 5 ++- 8 files changed, 68 insertions(+), 59 deletions(-) delete mode 100644 .github/workflows/gradle_deploy.yml diff --git a/.github/workflows/gradle_build.yml b/.github/workflows/gradle_build.yml index b76b1b07..7c677b5a 100644 --- a/.github/workflows/gradle_build.yml +++ b/.github/workflows/gradle_build.yml @@ -1,6 +1,9 @@ -name: Build +name: CI -on: [push] +on: [ push ] + +env: + APP_JAVA_VERSION: 8 jobs: build: @@ -11,7 +14,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v1 with: - java-version: 8 + java-version: ${{ env.APP_JAVA_VERSION }} - uses: actions/cache@v1 name: Restore gradle cache with: @@ -26,10 +29,44 @@ jobs: with: path: ~/.gradle/wrapper key: ${{ runner.os }}-gradle-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} - - name: Set wrapper permissions + - name: Set gradle permissions run: chmod +x gradlew - name: Check project run: ./gradlew check env: GITHUB_USER: RakSrinaNa GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-curseforge: + runs-on: ubuntu-latest + needs: build + if: "startsWith(github.ref, 'refs/tags/')" + steps: + - name: Checkout source + uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: ${{ env.APP_JAVA_VERSION }} + - uses: actions/cache@v1 + name: Restore gradle cache + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: | + ${{ runner.OS }}-gradle-${{ env.cache-name }}- + ${{ runner.OS }}-gradle- + ${{ runner.OS }}- + - uses: actions/cache@v1 + name: Cache gradle wrapper + with: + path: ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} + - name: Set gradle permissions + run: chmod +x gradlew + - name: Push on CurseForge + run: ./gradlew curseforge + env: + GITHUB_USER: RakSrinaNa + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} diff --git a/.github/workflows/gradle_deploy.yml b/.github/workflows/gradle_deploy.yml deleted file mode 100644 index e7407c67..00000000 --- a/.github/workflows/gradle_deploy.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Curse deploy - -on: - push: - tags: - - '*' - -jobs: - curse: - runs-on: ubuntu-latest - steps: - - name: Checkout source - uses: actions/checkout@v2 - - name: Set up JDK - uses: actions/setup-java@v1 - with: - java-version: 8 - - uses: actions/cache@v1 - name: Restore gradle cache - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - restore-keys: | - ${{ runner.OS }}-gradle-${{ env.cache-name }}- - ${{ runner.OS }}-gradle- - ${{ runner.OS }}- - - uses: actions/cache@v1 - name: Cache gradle wrapper - with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} - - name: Set wrapper permissions - run: chmod +x gradlew - - name: Check project - run: ./gradlew check - env: - GITHUB_USER: RakSrinaNa - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Push on CurseForge - run: ./gradlew curseforge - env: - GITHUB_USER: RakSrinaNa - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} diff --git a/CHANGELOG.md b/CHANGELOG.md index d5296dcc..b5319c9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [1.15.2-2.4.0] - 2020-09-21 +* Add option to cut trees with mixed log blocks + ## [1.15.2-2.3.1] - 2020-09-09 * Check world type before scheduling leaf breaking (#23) * Do not take into account "minimumLeavesAroundRequired" when using shift down mode diff --git a/changes.md b/changes.md index dc29ba11..e2e00c70 100644 --- a/changes.md +++ b/changes.md @@ -1,2 +1 @@ -* Check world type before scheduling leaf breaking (#23) -* Do not take into account "minimumLeavesAroundRequired" when using shift down mode \ No newline at end of file +* Add option to cut trees with mixed log blocks \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index f603a830..89410f64 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,13 +7,13 @@ archivesBaseName=FallingTree mod_id=falling_tree repoName=FallingTree name=Falling Tree -version=2.3.1 +version=2.4.0 vcsUrl=https://github.com/RakSrinaNa/FallingTree.git changelogUrl=https://github.com/RakSrinaNa/FallingTree/blob/1.15.2/CHANGELOG.md mc_version=1.15.2 -forge_version=1.15.2-31.2.36 +forge_version=1.15.2-31.2.41 mcp_channel=snapshot -mcp_mappings=20200903-1.15.1 +mcp_mappings=20200921-1.15.1 curseforge_project_id=349559 curseforge_release_type=release doDeobfJar=false diff --git a/src/main/java/fr/raksrinana/fallingtree/config/TreeConfiguration.java b/src/main/java/fr/raksrinana/fallingtree/config/TreeConfiguration.java index 7717ec0b..22380830 100644 --- a/src/main/java/fr/raksrinana/fallingtree/config/TreeConfiguration.java +++ b/src/main/java/fr/raksrinana/fallingtree/config/TreeConfiguration.java @@ -18,6 +18,7 @@ public class TreeConfiguration{ private final ForgeConfigSpec.IntValue minimumLeavesAroundRequired; private final ForgeConfigSpec.BooleanValue leavesBreaking; private final ForgeConfigSpec.IntValue leavesBreakingForceRadius; + private final ForgeConfigSpec.BooleanValue allowMixedLogs; public TreeConfiguration(ForgeConfigSpec.Builder builder){ breakMode = builder.comment("How to break the tree.", @@ -49,6 +50,9 @@ public TreeConfiguration(ForgeConfigSpec.Builder builder){ minimumLeavesAroundRequired = builder.comment("The minimum amount of leaves that needs to be around the top most log in order for the mod to consider it a tree.", "INFO: Only in INSTANTANEOUS mode.") .defineInRange("minimum_leaves_around_required", 0, 0, 5); + allowMixedLogs = builder.comment("When set to true this allow to have any kind of log in a tree trunk.", + "Otherwise (false) the trunk will be considered as being only one kind of log.") + .define("allow_mixed_logs", false); } public Collection getBlacklistedLeaves(){ @@ -86,4 +90,8 @@ public boolean isLeavesBreaking(){ public BreakMode getBreakMode(){ return breakMode.get(); } + + public boolean isAllowMixedLogs(){ + return this.allowMixedLogs.get(); + } } diff --git a/src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java b/src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java index f116589d..1e9624ea 100644 --- a/src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java +++ b/src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java @@ -12,7 +12,6 @@ import net.minecraft.world.IWorld; import net.minecraft.world.World; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.*; import java.util.stream.Collectors; import static fr.raksrinana.fallingtree.utils.FallingTreeUtils.isLeafBlock; @@ -65,7 +64,7 @@ private static Collection neighborLogs(@Nonnull IWorld world, @Nonnull for(int z = -1; z <= 1; z++){ for(int y = -1; y <= 1; y++){ checkPos.setPos(blockPos.getX() + x, blockPos.getY() + y, blockPos.getZ() + z); - if(!analyzedPos.contains(checkPos) && isSameLog(world, checkPos, logBlock)){ + if(!analyzedPos.contains(checkPos) && isSameTree(world, checkPos, logBlock)){ neighborLogs.add(checkPos.toImmutable()); } } @@ -75,8 +74,14 @@ private static Collection neighborLogs(@Nonnull IWorld world, @Nonnull return neighborLogs; } - private static boolean isSameLog(@Nonnull IWorld world, @Nonnull BlockPos blockPos, @Nullable Block logBlock){ - return world.getBlockState(blockPos).getBlock().equals(logBlock); + private static boolean isSameTree(@Nonnull IWorld world, BlockPos checkBlockPos, Block parentLogBlock){ + Block checkBlock = world.getBlockState(checkBlockPos).getBlock(); + if(Config.COMMON.getTreesConfiguration().isAllowMixedLogs()){ + return isTreeBlock(checkBlock); + } + else{ + return checkBlock.equals(parentLogBlock); + } } public static boolean destroyInstant(@Nonnull Tree tree, @Nonnull PlayerEntity player, @Nonnull ItemStack tool){ diff --git a/update.json b/update.json index 223f26b0..91e63fc2 100644 --- a/update.json +++ b/update.json @@ -2,6 +2,7 @@ "homepage": "https://github.com/RakSrinaNa/FallingTree", "changelog": "https://github.com/RakSrinaNa/FallingTree/blob/1.15.2/CHANGELOG.md", "1.15.2": { + "2.4.0": "https://github.com/RakSrinaNa/FallingTree/blob/1.15.2/CHANGELOG.md", "2.3.1": "https://github.com/RakSrinaNa/FallingTree/blob/1.15.2/CHANGELOG.md", "2.3.0": "https://github.com/RakSrinaNa/FallingTree/blob/1.15.2/CHANGELOG.md", "2.2.1": "https://github.com/RakSrinaNa/FallingTree/blob/1.15.2/CHANGELOG.md", @@ -16,7 +17,7 @@ "2.0.2": "https://github.com/RakSrinaNa/FallingTree/blob/1.15.2/CHANGELOG.md" }, "promos": { - "1.15.2-latest": "2.3.1", - "1.15.2-recommended": "2.3.1" + "1.15.2-latest": "2.4.0", + "1.15.2-recommended": "2.4.0" } } \ No newline at end of file