From 1d5b6fa1a07e008468fbf3de5ef2f89c87c0515f Mon Sep 17 00:00:00 2001 From: lothrazar Date: Mon, 1 Apr 2024 23:40:07 -0700 Subject: [PATCH] excavate enchant improvements --- src/main/java/com/lothrazar/cyclic/data/DataTags.java | 1 + .../lothrazar/cyclic/enchant/EnchantExcavation.java | 10 ++++++++++ .../data/cyclic/tags/blocks/ignored/excavate.json | 9 +++++++++ update.json | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/data/cyclic/tags/blocks/ignored/excavate.json diff --git a/src/main/java/com/lothrazar/cyclic/data/DataTags.java b/src/main/java/com/lothrazar/cyclic/data/DataTags.java index c9b23b586..b976a8ff1 100644 --- a/src/main/java/com/lothrazar/cyclic/data/DataTags.java +++ b/src/main/java/com/lothrazar/cyclic/data/DataTags.java @@ -21,6 +21,7 @@ public class DataTags { public static final INamedTag VINES = BlockTags.makeWrapperTag("forge:vines"); public static final INamedTag CACTUS = BlockTags.makeWrapperTag("forge:cactus"); public static final INamedTag CROP_BLOCKS = BlockTags.makeWrapperTag("forge:crop_blocks"); + public static final INamedTag EXCAVATE_IGNORED = BlockTags.makeWrapperTag("cyclic:ignored/excavate"); public static final INamedTag FISHING_RODS = ItemTags.makeWrapperTag("forge:fishing_rods"); public static final INamedTag BOOKS = ItemTags.makeWrapperTag("forge:books"); public static final INamedTag ANVIL_IMMUNE = ItemTags.makeWrapperTag("cyclic:anvil_immune"); diff --git a/src/main/java/com/lothrazar/cyclic/enchant/EnchantExcavation.java b/src/main/java/com/lothrazar/cyclic/enchant/EnchantExcavation.java index 63d38e126..6e473ab22 100644 --- a/src/main/java/com/lothrazar/cyclic/enchant/EnchantExcavation.java +++ b/src/main/java/com/lothrazar/cyclic/enchant/EnchantExcavation.java @@ -25,6 +25,7 @@ import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.base.EnchantBase; +import com.lothrazar.cyclic.data.DataTags; import com.lothrazar.cyclic.registry.EnchantRegistry; import com.lothrazar.cyclic.util.UtilItemStack; import java.util.Arrays; @@ -64,6 +65,7 @@ public EnchantExcavation(Rarity rarityIn, EnchantmentType typeIn, EquipmentSlotT public static BooleanValue CFG; public static final String ID = "excavate"; + public static boolean effectiveToolRequired = true; // non-config lets hardcode this actually @Override public boolean isEnabled() { @@ -105,6 +107,14 @@ public void onBreakEvent(BreakEvent event) { if (level <= 0) { return; } + if (effectiveToolRequired && !ForgeHooks.isToolEffective(world, pos, stackHarvestingWith)) { + ModCyclic.LOGGER.info("excavate trigger cancelled; tool not effective"); + return; + } + if (eventState.isIn(DataTags.EXCAVATE_IGNORED)) { + ModCyclic.LOGGER.info("excavate trigger cancelled; see blocktag " + DataTags.EXCAVATE_IGNORED.toString()); + return; + } if (ForgeHooks.canHarvestBlock(eventState, player, world, pos)) { int harvested = this.harvestSurrounding((World) world, player, pos, block, 1, level, player.swingingHand); if (harvested > 0) { diff --git a/src/main/resources/data/cyclic/tags/blocks/ignored/excavate.json b/src/main/resources/data/cyclic/tags/blocks/ignored/excavate.json new file mode 100644 index 000000000..cf52e968c --- /dev/null +++ b/src/main/resources/data/cyclic/tags/blocks/ignored/excavate.json @@ -0,0 +1,9 @@ +{ + "replace": false, + "values": [ + "#minecraft:shulker_boxes", + {"required":false, "id": "cyclic:crate"}, + {"required":false, "id": "minecraft:chest"}, + {"required":false, "id": "minecraft:command_block"} + ] +} \ No newline at end of file diff --git a/update.json b/update.json index af83baa95..2f4b754f1 100644 --- a/update.json +++ b/update.json @@ -79,6 +79,6 @@ ,"1.5.20":"#2102 wooden and golden hopper deposit logic fixed, now matches 1.18.2+ versions. #2085 Hopper reach area & pickup logic now uses vanilla-hopper area size. JEED compatibility added for some potion effects. Port Fishing Net and Mending Fishingrods compatibility from 1.12.2 #2067. Ender Apple now sends a message if nothing is found (void/flatworlds/etc). Growth enchant now skips IGrowable blocks that return false for 'canGrow();'. Many new config options added for: growth enchant, beheading enchant, battery, sprinkler, experience_pylon, fisher, scythes, and others in cyclic.toml" ,"1.5.21":"#1933 Sack of Holding chest placement override added, with new config to revert back to legacy behavior if desired (overrideChestSingle). #2168 fix bug where ender shelf sometimes would not save contents when mined after exiting reloading world when client data desyncs. Added a percentage config and ignorelist config for cyclic:disarm enchantment (disarmPercentPerLevel, disarmIngoredMobs), resolves it dropping your copied weapon from alexsmobs:mimicube #2249. Fix #1878 layered and/or logic for multiple wireless transmitters on the same node " ,"1.5.22":"Fix #2351 advanced crafting stick not opening. " - ,"1.5.23":"Backport #2182 candle model assets. New config under [cyclic.blocks] wireless_transfer_dimensional = true allowing transfer nodes to connect across dimensions if possible. " + ,"1.5.23":"Backport #2182 candle model assets. New config under [cyclic.blocks] wireless_transfer_dimensional = true allowing transfer nodes to connect across dimensions if possible #1913. Excavate enchant will no longer trigger if the tool is not 'mineable' effective for example axe on dirt. Excavate enchant will not trigger on anything matching the new block tag [cyclic:ignored/excavate] #2116 " } }