diff --git a/gradle.properties b/gradle.properties index e20dce0..87c0daf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ neo_version=26.1.2.75 mod_id=cakesticklib mod_name=CakeStickLib mod_license=Ora Et Labora License -mod_version=1.11.1-hotfix1 +mod_version=1.11.1-hotfix2 mod_group_id=com.devdyna.cakestick mod_authors=DevDyna mod_description=A standalone port of Synergy API to unify most of the code diff --git a/src/main/java/com/devdyna/cakesticklib/setup/common/events/VanillaHarvestable.java b/src/main/java/com/devdyna/cakesticklib/setup/common/events/VanillaHarvestable.java index 7da28a6..e465dcd 100644 --- a/src/main/java/com/devdyna/cakesticklib/setup/common/events/VanillaHarvestable.java +++ b/src/main/java/com/devdyna/cakesticklib/setup/common/events/VanillaHarvestable.java @@ -3,8 +3,11 @@ import java.util.*; import com.devdyna.cakesticklib.api.factories.plants.*; +import com.devdyna.cakesticklib.setup.registry.LibTags; import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.item.BoneMealItem; import net.minecraft.world.item.ItemStack; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; @@ -16,16 +19,27 @@ public static void harvestVanillaCrops(PlayerInteractEvent.RightClickBlock event var level = event.getLevel(); var player = event.getEntity(); var hand = event.getHand(); + var item = event.getItemStack(); if (!Harvestable.getConfig()) return; - List check = VanillaPlants.checkReplant(level, pos,player,hand); + if (player.isSpectator()) + return; + + if (level.getBlockState(pos).is(LibTags.Blocks.HARVESTABLE_BLACKLIST)) + return; + + //prevent bonemeal usage conflict + if (!(item.getItem() instanceof BoneMealItem) && hand.equals(InteractionHand.MAIN_HAND)) { + List check = VanillaPlants.checkReplant(level, pos, player, hand); - if (check != null && hand.equals(InteractionHand.MAIN_HAND)) - check.forEach(i -> player.addItem(i)); - + if (check != null) { + check.forEach(i -> player.addItem(i)); + event.setCanceled(true); + event.setCancellationResult(InteractionResult.SUCCESS); + } + } - } } \ No newline at end of file diff --git a/src/main/java/com/devdyna/cakesticklib/setup/registry/LibTags.java b/src/main/java/com/devdyna/cakesticklib/setup/registry/LibTags.java index df78933..f90bdb0 100644 --- a/src/main/java/com/devdyna/cakesticklib/setup/registry/LibTags.java +++ b/src/main/java/com/devdyna/cakesticklib/setup/registry/LibTags.java @@ -1,5 +1,7 @@ package com.devdyna.cakesticklib.setup.registry; +import static com.devdyna.cakesticklib.CakeStickLib.MODULE_ID; + import com.devdyna.cakesticklib.CakeStickLib; import com.devdyna.cakesticklib.api.RegistryUtils; @@ -19,6 +21,9 @@ public class Blocks { public static void register(IEventBus bus) { } + public static final TagKey HARVESTABLE_BLACKLIST = RegistryUtils + .tagBlock(MODULE_ID, "harvestable/blacklist"); + //storage_blocks public static final TagKey STEEL_BLOCK = RegistryUtils .tagBlock("c", "storage_blocks/steel");