Skip to content

Commit

Permalink
feat: support cactus
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamalam360 committed Dec 30, 2023
1 parent 662a153 commit 89cd61d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
java-version: 17

- name: Build
run: ./gradlew clean forge:build fabric:build quilt:build
run: ./gradlew clean neoforge:build forge:build fabric:build quilt:build

- name: Capture Fabric Build Artifacts
uses: actions/upload-artifact@v2
Expand All @@ -53,3 +53,9 @@ jobs:
with:
name: Forge Artifacts
path: forge/build/libs/

- name: Capture NeoForge Build Artifacts
uses: actions/upload-artifact@v2
with:
name: NeoForge Artifacts
path: neoforge/build/libs/
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Update to support NeoForge. 1.20.4 will come soon.
Mod now works with cacti.
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,14 @@ allprojects {

tasks.publish {
dependsOn(":githubRelease")
dependsOn("common:publishAllPublicationsToMavenRepository")
dependsOn("fabric:publishUnified")
dependsOn("fabric:publishAllPublicationsToMavenRepository")
dependsOn("quilt:publishUnified")
dependsOn("quilt:publishAllPublicationsToMavenRepository")
dependsOn("forge:publishUnified")
dependsOn("forge:publishAllPublicationsToMavenRepository")
dependsOn("neoforge:publishUnified")
dependsOn("neoforge:publishAllPublicationsToMavenRepository")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,28 @@ private static InteractionResult onBlockUse(Player player, Level world, Interact
RightClickHarvestPlatform.postAfterHarvestEvent(new HarvestContext(player, originalBlock));
return InteractionResult.SUCCESS;
}
} else if (state.getBlock() instanceof SugarCaneBlock) {
if (hitResult.getDirection() == Direction.UP && stack.getItem() == Items.SUGAR_CANE) {
} else if (state.getBlock() instanceof SugarCaneBlock || state.getBlock() instanceof CactusBlock) {
if (hitResult.getDirection() == Direction.UP && ((stack.getItem() == Items.SUGAR_CANE && state
.getBlock() instanceof SugarCaneBlock) || (stack.getItem() == Items.CACTUS && state
.getBlock() instanceof CactusBlock))) {
return InteractionResult.PASS;
}

int count = 1;

Block lookingFor = state.getBlock() instanceof SugarCaneBlock ? Blocks.SUGAR_CANE : Blocks.CACTUS;
BlockPos bottom = hitResult.getBlockPos().below();
while (world.getBlockState(bottom).is(Blocks.SUGAR_CANE)) {
count++;
System.out.println("below is " + world.getBlockState(bottom).getBlock());
System.out.println("looking for " + lookingFor);
while (world.getBlockState(bottom).is(lookingFor)) {
bottom = bottom.below();
System.out.println("below is " + world.getBlockState(bottom).getBlock());
}

if (count == 1 && !world.getBlockState(hitResult.getBlockPos().above()).is(Blocks.SUGAR_CANE)) {
System.out.println("exited loop");
System.out.println("bottom is " + bottom);
System.out.println("below hitResult is " + hitResult.getBlockPos().below());

if (bottom.equals(hitResult.getBlockPos().below())) {
System.out.println("early return");
return InteractionResult.PASS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"replace": false,
"values": [
"minecraft:cocoa",
"minecraft:sugar_cane",
"minecraft:nether_wart"
]
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.parallel=true
version=4.0.2
version=4.1.0+1.20.2
minecraft_version=1.20.2
branch=1.20.2-multiloader
branch=main
group=io.github.jamalam360
mod_name=Right Click Harvest
mod_id=rightclickharvest
Expand Down

0 comments on commit 89cd61d

Please sign in to comment.