diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..f8102a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,13 @@ +## Changelog + +### Features + +- Use the `c:hoes` tag as well as checking `instanceof HoeItem` for greater mod compatibility. + +### Fixes + +- Add a test for a potential future issue. + +Closed Issues: None + +[Full Changelog](https://github.com/JamCoreModding/RightClickHarvestFabric/compare/2.0.1...2.0.2) diff --git a/CHANGELOG_TEMPLATE.md b/CHANGELOG_TEMPLATE.md new file mode 100644 index 0000000..c3a3ab7 --- /dev/null +++ b/CHANGELOG_TEMPLATE.md @@ -0,0 +1,9 @@ +## Changelog + +### Features + +### Fixes + +Closed Issues: None + +[Full Changelog](https://github.com/JamCoreModding/RightClickHarvestFabric/compare/...) diff --git a/gradle.properties b/gradle.properties index 21c5d03..1935d99 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ org.gradle.jvmargs=-Xmx4G -mod_version=2.0.1 -release_name=V2.0.1 [1.16.x - 1.18.x] +mod_version=2.0.2 +release_name=V2.0.2 [1.16.x - 1.18.x] archive_base_name=rightclickharvest supported_versions=1.18.2,1.18.1,1.18,1.17.1,1.17,1.16.5,1.16.4,1.16.3,1.16.2,1.16.1,1.16 diff --git a/src/main/java/io/github/jamalam360/rightclickharvest/RightClickHarvestGameTest.java b/src/main/java/io/github/jamalam360/rightclickharvest/RightClickHarvestGameTest.java index 4768e84..8124d78 100644 --- a/src/main/java/io/github/jamalam360/rightclickharvest/RightClickHarvestGameTest.java +++ b/src/main/java/io/github/jamalam360/rightclickharvest/RightClickHarvestGameTest.java @@ -93,6 +93,29 @@ public void testRegularCropsWithHoe(TestContext context) { context.complete(); }); } + + @GameTest(structureName = EMPTY_STRUCTURE) + public void testRegularCropsWithNonEmptyHand(TestContext context) { + context.setBlockState(0, 2, 0, Blocks.FARMLAND); + context.setBlockState(0, 3, 0, Blocks.WHEAT.getDefaultState().with(CropBlock.AGE, CropBlock.MAX_AGE)); + + BlockPos blockPos = context.getAbsolutePos(new BlockPos(0, 3, 0)); + BlockState blockState = context.getWorld().getBlockState(blockPos); + + PlayerEntity player = context.createMockPlayer(); + player.setStackInHand(Hand.MAIN_HAND, Items.WOODEN_HOE.getDefaultStack()); + + blockState.onUse( + context.getWorld(), player, Hand.MAIN_HAND, new BlockHitResult(Vec3d.ofCenter(blockPos), Direction.NORTH, blockPos, true) + ); + + context.addInstantFinalTask(() -> { + context.dontExpectEntity(EntityType.ITEM); + context.expectBlockProperty(new BlockPos(0, 3, 0), CropBlock.AGE, CropBlock.MAX_AGE); + context.complete(); + }); + } + @GameTest(structureName = EMPTY_STRUCTURE) public void testCocoaBeans(TestContext context) { context.setBlockState(0, 2, 0, Blocks.JUNGLE_LOG); diff --git a/src/main/java/io/github/jamalam360/rightclickharvest/RightClickHarvestModInit.java b/src/main/java/io/github/jamalam360/rightclickharvest/RightClickHarvestModInit.java index eb8b415..3671e41 100644 --- a/src/main/java/io/github/jamalam360/rightclickharvest/RightClickHarvestModInit.java +++ b/src/main/java/io/github/jamalam360/rightclickharvest/RightClickHarvestModInit.java @@ -24,11 +24,12 @@ package io.github.jamalam360.rightclickharvest; +import io.github.jamalam360.rightclickharvest.config.Config; +import io.github.jamalam360.rightclickharvest.config.MidnightConfig; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.tag.convention.v1.ConventionalItemTags; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.HoeItem; -import io.github.jamalam360.rightclickharvest.config.Config; -import io.github.jamalam360.rightclickharvest.config.MidnightConfig; import org.apache.logging.log4j.LogManager; /** @@ -42,7 +43,12 @@ public void onInitialize() { } public static boolean canRightClickHarvest(PlayerEntity player) { - return (Config.requireHoe && player.getMainHandStack().getItem() instanceof HoeItem) - || (!Config.requireHoe && player.getMainHandStack().isEmpty()); + return ( + Config.requireHoe && + (player.getMainHandStack().isIn(ConventionalItemTags.HOES) || player.getMainHandStack().getItem() instanceof HoeItem) + ) + || ( + !Config.requireHoe && player.getMainHandStack().isEmpty() + ); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 9069495..37b7bb1 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -8,7 +8,8 @@ "Jamalam" ], "contributors": [ - "Fourmisain" + "Fourmisain", + "Jomlom" ], "contact": { "homepage": "https://www.curseforge.com/minecraft/mc-mods/rightclickharvest-fabric",