Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Use brush on suspicious blocks #16

Merged
merged 1 commit into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/) and this
### Added

- Now uses shears on vines
- Now uses brush on suspicious blocks

### Changed

Expand Down
13 changes: 11 additions & 2 deletions src/main/java/com/natoboram/switcheroo/BlockSwitch.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.block.BambooBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.BrushableBlock;
import net.minecraft.block.CaveVinesBodyBlock;
import net.minecraft.block.CaveVinesHeadBlock;
import net.minecraft.block.CobwebBlock;
Expand All @@ -26,6 +27,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.AxeItem;
import net.minecraft.item.BrushItem;
import net.minecraft.item.HoeItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -77,8 +79,15 @@ public ActionResult interact(final PlayerEntity player, final World world, final
final ArrayList<ItemStack> tools = new ArrayList<ItemStack>();
final PlayerInventory inventory = player.getInventory();

// Use hoe on crops
if (block instanceof CropBlock) {
if (block instanceof BrushableBlock) {

// Use brush on suspicious blocks
for (final ItemStack stack : inventory.main)
if (stack.getItem() instanceof BrushItem)
tools.add(stack);
} else if (block instanceof CropBlock) {

// Use hoe on crops
for (final ItemStack stack : inventory.main)
if (stack.getItem() instanceof HoeItem)
tools.add(stack);
Expand Down