Skip to content

Commit

Permalink
feat(function): use #c:hoes
Browse files Browse the repository at this point in the history
feat(test): another test
chore(meta): add CHANGELOG_TEMPLATE
chore(meta): add Jomlom to contributors
chore(meta): bump version
  • Loading branch information
Jamalam360 committed May 10, 2022
1 parent 47ef75a commit 7dc0527
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 7 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions CHANGELOG_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Changelog

### Features

### Fixes

Closed Issues: None

[Full Changelog](https://github.com/JamCoreModding/RightClickHarvestFabric/compare/...)
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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()
);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"Jamalam"
],
"contributors": [
"Fourmisain"
"Fourmisain",
"Jomlom"
],
"contact": {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/rightclickharvest-fabric",
Expand Down

0 comments on commit 7dc0527

Please sign in to comment.