Skip to content

Commit

Permalink
Allow mixed logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakambda committed Sep 21, 2020
1 parent f24c975 commit b9df372
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 59 deletions.
45 changes: 41 additions & 4 deletions .github/workflows/gradle_build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Build
name: CI

on: [push]
on: [ push ]

env:
APP_JAVA_VERSION: 8

jobs:
build:
Expand All @@ -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:
Expand All @@ -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 }}
44 changes: 0 additions & 44 deletions .github/workflows/gradle_deploy.yml

This file was deleted.

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions changes.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* Check world type before scheduling leaf breaking (#23)
* Do not take into account "minimumLeavesAroundRequired" when using shift down mode
* Add option to cut trees with mixed log blocks
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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<Block> getBlacklistedLeaves(){
Expand Down Expand Up @@ -86,4 +90,8 @@ public boolean isLeavesBreaking(){
public BreakMode getBreakMode(){
return breakMode.get();
}

public boolean isAllowMixedLogs(){
return this.allowMixedLogs.get();
}
}
13 changes: 9 additions & 4 deletions src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -65,7 +64,7 @@ private static Collection<BlockPos> 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());
}
}
Expand All @@ -75,8 +74,14 @@ private static Collection<BlockPos> 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){
Expand Down
5 changes: 3 additions & 2 deletions update.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}

0 comments on commit b9df372

Please sign in to comment.