diff --git a/src/main/java/io/savagedev/soulmatter/init/ModConfiguration.java b/src/main/java/io/savagedev/soulmatter/init/ModConfiguration.java index 6d180f8..fd6ae32 100644 --- a/src/main/java/io/savagedev/soulmatter/init/ModConfiguration.java +++ b/src/main/java/io/savagedev/soulmatter/init/ModConfiguration.java @@ -38,6 +38,7 @@ public class ModConfiguration } public static final ForgeConfigSpec.IntValue MAX_SOUL_TOOL_LEVEL; + public static final ForgeConfigSpec.BooleanValue SHOULD_DAMAGE_MAX_TOOL; static { final ForgeConfigSpec.Builder common = new ForgeConfigSpec.Builder(); @@ -48,6 +49,9 @@ public class ModConfiguration .comment("This number handles the Soul Matter Tool max tool level. When the tool reaches this number, it will have max abilities.") .translation("configGui.soulmatter.max_soul_tool_level") .defineInRange("maxSoulToolLevel", 3, 2, 8); + SHOULD_DAMAGE_MAX_TOOL = common.comment("Damage Soul Matter Tools that have reached max level") + .translation("configGui.soulmatter.should_damage_max_tool_level") + .define("shouldDamageMaxTool", false); common.pop(); diff --git a/src/main/java/io/savagedev/soulmatter/items/soul/tools/BaseSoulTool.java b/src/main/java/io/savagedev/soulmatter/items/soul/tools/BaseSoulTool.java index 77730b8..54ed389 100644 --- a/src/main/java/io/savagedev/soulmatter/items/soul/tools/BaseSoulTool.java +++ b/src/main/java/io/savagedev/soulmatter/items/soul/tools/BaseSoulTool.java @@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableSet; import io.savagedev.soulmatter.handlers.SoulToolLevelHandler; +import io.savagedev.soulmatter.init.ModConfiguration; import io.savagedev.soulmatter.init.ModItems; import io.savagedev.soulmatter.init.ModToolTier; import io.savagedev.soulmatter.util.LogHelper; @@ -90,9 +91,15 @@ public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity atta event.sendBreakAnimation(attacker.getActiveHand()); }); } else { - stack.damageItem(0, attacker, (event) -> { - event.sendBreakAnimation(attacker.getActiveHand()); - }); + if(ModConfiguration.SHOULD_DAMAGE_MAX_TOOL.get()) { + stack.damageItem(1, attacker, (event) -> { + event.sendBreakAnimation(attacker.getActiveHand()); + }); + } else { + stack.damageItem(0, attacker, (event) -> { + event.sendBreakAnimation(attacker.getActiveHand()); + }); + } } return true; @@ -112,9 +119,15 @@ public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state event.sendBreakAnimation(entityLiving.getActiveHand()); }); } else { - stack.damageItem(0, entityLiving, (event) -> { - event.sendBreakAnimation(entityLiving.getActiveHand()); - }); + if(ModConfiguration.SHOULD_DAMAGE_MAX_TOOL.get()) { + stack.damageItem(1, entityLiving, (event) -> { + event.sendBreakAnimation(entityLiving.getActiveHand()); + }); + } else { + stack.damageItem(0, entityLiving, (event) -> { + event.sendBreakAnimation(entityLiving.getActiveHand()); + }); + } } } else { if(!SoulToolLevelHandler.isMaxToolLevel(stack)) { @@ -122,9 +135,15 @@ public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state event.sendBreakAnimation(entityLiving.getActiveHand()); }); } else { - stack.damageItem(0, entityLiving, (event) -> { - event.sendBreakAnimation(entityLiving.getActiveHand()); - }); + if(ModConfiguration.SHOULD_DAMAGE_MAX_TOOL.get()) { + stack.damageItem(1, entityLiving, (event) -> { + event.sendBreakAnimation(entityLiving.getActiveHand()); + }); + } else { + stack.damageItem(0, entityLiving, (event) -> { + event.sendBreakAnimation(entityLiving.getActiveHand()); + }); + } } } } diff --git a/src/main/java/io/savagedev/soulmatter/items/soul/tools/ItemSoulMatterHoe.java b/src/main/java/io/savagedev/soulmatter/items/soul/tools/ItemSoulMatterHoe.java index 1d481f9..5b61c7f 100644 --- a/src/main/java/io/savagedev/soulmatter/items/soul/tools/ItemSoulMatterHoe.java +++ b/src/main/java/io/savagedev/soulmatter/items/soul/tools/ItemSoulMatterHoe.java @@ -27,6 +27,7 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; import io.savagedev.soulmatter.handlers.SoulToolLevelHandler; +import io.savagedev.soulmatter.init.ModConfiguration; import io.savagedev.soulmatter.init.ModItems; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -93,16 +94,22 @@ public ActionResultType onItemUse(ItemUseContext context) { if (!world.isRemote) { world.setBlockState(blockpos, blockstate, 11); if (playerentity != null) { - if(SoulToolLevelHandler.hasLevelTags(context.getItem()) && !SoulToolLevelHandler.isMaxToolLevel(context.getItem())) { + if(!SoulToolLevelHandler.isMaxToolLevel(context.getItem())) { SoulToolLevelHandler.addXp(context.getItem(), playerentity, MathHelper.nextInt(new Random(), 2, 8)); context.getItem().damageItem(1, playerentity, (hand) -> { hand.sendBreakAnimation(context.getHand()); }); } else { - context.getItem().damageItem(0, playerentity, (hand) -> { - hand.sendBreakAnimation(context.getHand()); - }); + if(ModConfiguration.SHOULD_DAMAGE_MAX_TOOL.get()) { + context.getItem().damageItem(1, context.getPlayer(), (event) -> { + event.sendBreakAnimation(context.getPlayer().getActiveHand()); + }); + } else { + context.getItem().damageItem(0, context.getPlayer(), (event) -> { + event.sendBreakAnimation(context.getPlayer().getActiveHand()); + }); + } } }