diff --git a/build.gradle b/build.gradle
index a9d44b47..add4aaae 100644
--- a/build.gradle
+++ b/build.gradle
@@ -30,6 +30,13 @@ repositories {
maven {
url 'https://jitpack.io'
}
+ maven {
+ name = 'Modrinth'
+ url = 'https://api.modrinth.com/maven'
+ content {
+ includeGroup 'maven.modrinth'
+ }
+ }
repositories {
flatDir{
dirs 'localdeps'
@@ -59,15 +66,18 @@ dependencies {
// Clumps
modImplementation "curse.maven:clumps-256717:3900783"
+ // Projectile Damage
+ modImplementation "maven.modrinth:projectile-damage-attribute:${project.projectile_damage_version}-fabric"
+
// Cloth Config
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
// Mixin Extras
- implementation("com.github.LlamaLad7:MixinExtras:0.2.0-beta.2")
- annotationProcessor("com.github.LlamaLad7:MixinExtras:0.2.0-beta.2")
- include "com.github.LlamaLad7:MixinExtras:0.2.0-beta.2"
+ implementation("com.github.LlamaLad7:MixinExtras:${project.mixin_extras_version}")
+ annotationProcessor("com.github.LlamaLad7:MixinExtras:${project.mixin_extras_version}")
+ include "com.github.LlamaLad7:MixinExtras:${project.mixin_extras_version}"
}
diff --git a/gradle.properties b/gradle.properties
index 6e7240ad..75002400 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -5,15 +5,17 @@ org.gradle.jvmargs=-Xmx1G
# check these on https://fabricmc.net/develop/
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
- loader_version=0.14.14
+ loader_version=0.14.19
# Mod Properties
- mod_version=5.0.8-1.19
+ mod_version=5.0.9-1.19
maven_group=chronosacaria
archives_base_name=mcdw
# Dependencies
# check this on https://fabricmc.net/develop/
- fabric_version=0.73.2+1.19.2
+ fabric_version=0.76.0+1.19.2
reach_entity_attributes_version=2.3.0
- cloth_config_version=7.0.72
\ No newline at end of file
+ cloth_config_version=7.0.72
+ mixin_extras_version=0.2.0-beta.6
+ projectile_damage_version=3.1.0+1.19
\ No newline at end of file
diff --git a/src/main/java/chronosacaria/mcdw/Mcdw.java b/src/main/java/chronosacaria/mcdw/Mcdw.java
index e0fd1962..b1720ce0 100644
--- a/src/main/java/chronosacaria/mcdw/Mcdw.java
+++ b/src/main/java/chronosacaria/mcdw/Mcdw.java
@@ -67,6 +67,7 @@ public void onInitialize() {
McdwEnchantGiverConfig.appendEnchants();
SummonedEntityRegistry.register();
StatusEffectsRegistry.init();
+ EnchantmentRestrictionsRegistry.init();
CompatRegistry.init();
}
}
\ No newline at end of file
diff --git a/src/main/java/chronosacaria/mcdw/api/util/EnchantmentRestriction.java b/src/main/java/chronosacaria/mcdw/api/util/EnchantmentRestriction.java
new file mode 100644
index 00000000..f896dddc
--- /dev/null
+++ b/src/main/java/chronosacaria/mcdw/api/util/EnchantmentRestriction.java
@@ -0,0 +1,73 @@
+package chronosacaria.mcdw.api.util;
+
+import com.google.common.collect.ArrayListMultimap;
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.item.ItemStack;
+
+import java.util.ArrayList;
+
+/**
+ * This code is used with the permission of Daedelus.
+ * The original code is from SpellEngine and can be found here.
+ */
+
+public final class EnchantmentRestriction {
+ public interface Condition {
+ boolean isAcceptableItem(ItemStack itemStack);
+ }
+
+ public interface TypeCondition {
+ boolean isAcceptableItem(Enchantment enchantment, ItemStack itemStack);
+ }
+ private static ArrayListMultimap permissions = ArrayListMultimap.create();
+ private static ArrayList permissibleTargets = new ArrayList<>();
+ private static ArrayListMultimap prohibitions = ArrayListMultimap.create();
+ private static ArrayList prohibitedTargets = new ArrayList<>();
+
+
+ public static void permit(Enchantment enchantment, Condition condition) {
+ permissions.put(enchantment, condition);
+ }
+
+ public static void permitTarget(TypeCondition typeCondition) {
+ permissibleTargets.add(typeCondition);
+ }
+
+ public static void prohibit(Enchantment enchantment, Condition condition) {
+ prohibitions.put(enchantment, condition);
+ }
+
+ public static void prohibitTarget(TypeCondition typeCondition) {
+ prohibitedTargets.add(typeCondition);
+ }
+
+ public static boolean isPermitted(Enchantment enchantment, ItemStack itemStack) {
+ var conditions = permissions.get(enchantment);
+ for(var condition: conditions) {
+ if (condition.isAcceptableItem(itemStack)) {
+ return true;
+ }
+ }
+ for(var condition: permissibleTargets) {
+ if (condition.isAcceptableItem(enchantment, itemStack)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean isProhibited(Enchantment enchantment, ItemStack itemStack) {
+ var conditions = prohibitions.get(enchantment);
+ for(var condition: conditions) {
+ if (condition.isAcceptableItem(itemStack)) {
+ return true;
+ }
+ }
+ for(var condition: prohibitedTargets) {
+ if (condition.isAcceptableItem(enchantment, itemStack)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/chronosacaria/mcdw/bases/McdwSword.java b/src/main/java/chronosacaria/mcdw/bases/McdwSword.java
index f85b03bf..0732cedc 100644
--- a/src/main/java/chronosacaria/mcdw/bases/McdwSword.java
+++ b/src/main/java/chronosacaria/mcdw/bases/McdwSword.java
@@ -5,19 +5,30 @@
import chronosacaria.mcdw.api.util.RarityHelper;
import chronosacaria.mcdw.enums.SwordsID;
import chronosacaria.mcdw.registries.ItemsRegistry;
+import com.google.common.collect.BiMap;
+import net.fabricmc.fabric.mixin.content.registry.AxeItemAccessor;
+import net.minecraft.advancement.criterion.Criteria;
+import net.minecraft.block.*;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.client.resource.language.I18n;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.item.SwordItem;
-import net.minecraft.item.ToolMaterial;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.item.*;
+import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.sound.SoundCategory;
+import net.minecraft.sound.SoundEvents;
+import net.minecraft.tag.BlockTags;
import net.minecraft.text.Text;
+import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
+import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
+import net.minecraft.world.event.GameEvent;
import java.util.List;
import java.util.Locale;
+import java.util.Optional;
+@SuppressWarnings("rawtypes")
public class McdwSword extends SwordItem {
String[] repairIngredient;
@@ -32,7 +43,65 @@ public boolean canRepair(ItemStack stack, ItemStack ingredient) {
return CleanlinessHelper.canRepairCheck(repairIngredient, ingredient);
}
- @Override
+ @Override
+ public ActionResult useOnBlock(ItemUsageContext context) {
+ World world = context.getWorld();
+ BlockPos blockPos = context.getBlockPos();
+ PlayerEntity playerEntity = context.getPlayer();
+ BlockState blockState = world.getBlockState(blockPos);
+ Optional strippedState = this.getStrippedState(blockState);
+ Optional decreasedOxidationState = Oxidizable.getDecreasedOxidationState(blockState);
+ Optional blockStateOptional = Optional.ofNullable((Block)((BiMap)HoneycombItem.WAXED_TO_UNWAXED_BLOCKS.get()).get(blockState.getBlock())).map((block) -> block.getStateWithProperties(blockState));
+ ItemStack itemStack = context.getStack();
+ Optional empty = Optional.empty();
+ if (context.getStack().isOf(SwordsID.SWORD_MECHANIZED_SAWBLADE.getItem())) {
+ if (strippedState.isPresent()) {
+ world.playSound(playerEntity, blockPos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ empty = strippedState;
+ } else if (decreasedOxidationState.isPresent()) {
+ world.playSound(playerEntity, blockPos, SoundEvents.ITEM_AXE_SCRAPE, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ world.syncWorldEvent(playerEntity, 3005, blockPos, 0);
+ empty = decreasedOxidationState;
+ } else if (blockStateOptional.isPresent()) {
+ world.playSound(playerEntity, blockPos, SoundEvents.ITEM_AXE_WAX_OFF, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ world.syncWorldEvent(playerEntity, 3004, blockPos, 0);
+ empty = blockStateOptional;
+ }
+
+ if (empty.isPresent()) {
+ if (playerEntity instanceof ServerPlayerEntity) {
+ Criteria.ITEM_USED_ON_BLOCK.trigger((ServerPlayerEntity)playerEntity, blockPos, itemStack);
+ }
+
+ world.setBlockState(blockPos, empty.get(), 11);
+ world.emitGameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Emitter.of(playerEntity, empty.get()));
+ if (playerEntity != null) {
+ itemStack.damage(1, playerEntity, (p) -> p.sendToolBreakStatus(context.getHand()));
+ }
+
+ return ActionResult.success(world.isClient);
+ } else {
+ return ActionResult.PASS;
+ }
+ }
+ return ActionResult.PASS;
+ }
+
+ @Override
+ public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
+ if (stack.isOf(SwordsID.SWORD_MECHANIZED_SAWBLADE.getItem())) {
+ if (state.isIn(BlockTags.AXE_MINEABLE))
+ return 8.0F;
+ }
+ return super.getMiningSpeedMultiplier(stack, state);
+ }
+
+ @SuppressWarnings("UnstableApiUsage")
+ private Optional getStrippedState(BlockState state) {
+ return Optional.ofNullable(AxeItemAccessor.getStrippedBlocks().get(state.getBlock())).map((block) -> block.getDefaultState().with(PillarBlock.AXIS, state.get(PillarBlock.AXIS)));
+ }
+
+ @Override
public void appendTooltip(ItemStack stack, World world, List tooltip, TooltipContext tooltipContext){
super.appendTooltip(stack, world, tooltip, tooltipContext);
int i = 1;
@@ -50,5 +119,4 @@ public void appendTooltip(ItemStack stack, World world, List tooltip, Tool
tooltip.add(Text.translatable("tooltip_info_item.mcdw.diamond_sword_3").formatted(Formatting.ITALIC));
}
}
-
}
diff --git a/src/main/java/chronosacaria/mcdw/configs/McdwEnchantmentsConfig.java b/src/main/java/chronosacaria/mcdw/configs/McdwEnchantmentsConfig.java
index 86e09465..907f0836 100644
--- a/src/main/java/chronosacaria/mcdw/configs/McdwEnchantmentsConfig.java
+++ b/src/main/java/chronosacaria/mcdw/configs/McdwEnchantmentsConfig.java
@@ -20,6 +20,7 @@ public McdwEnchantmentsConfig(){
for (EnchantmentsID enchantmentsID : EnchantmentsID.values())
ENABLE_VILLAGER_TRADING.put(enchantmentsID, true);
+ ENABLE_VILLAGER_TRADING.replace(EnchantmentsID.BURST_BOWSTRING, false);
ENABLE_VILLAGER_TRADING.replace(EnchantmentsID.DYNAMO, false);
ENABLE_VILLAGER_TRADING.replace(EnchantmentsID.SHARED_PAIN, false);
diff --git a/src/main/java/chronosacaria/mcdw/configs/McdwNewStatsConfig.java b/src/main/java/chronosacaria/mcdw/configs/McdwNewStatsConfig.java
index 7aa9fbc7..bfbf1516 100644
--- a/src/main/java/chronosacaria/mcdw/configs/McdwNewStatsConfig.java
+++ b/src/main/java/chronosacaria/mcdw/configs/McdwNewStatsConfig.java
@@ -51,11 +51,11 @@ protected IMeleeWeaponID.MeleeStats advancedMeleeWeaponStats(IMeleeWeaponID iMel
return meleeWeaponStats(materialToString(iMeleeWeaponID.getMaterial()), iMeleeWeaponID.getDamage(), iMeleeWeaponID.getAttackSpeed(), iMeleeWeaponID.getRepairIngredient(), iMeleeWeaponID);
}
- protected IRangedWeaponID.RangedStats rangedWeaponStats(String material, int drawSpeed, float range, String[] repairIngredient, IRangedWeaponID iRangedWeaponID) {
- return iRangedWeaponID.getWeaponItemStats(this).rangedStats(material, drawSpeed, range, repairIngredient);
+ protected IRangedWeaponID.RangedStats rangedWeaponStats(String material, double projectileDamage, int drawSpeed, float range, String[] repairIngredient, IRangedWeaponID iRangedWeaponID) {
+ return iRangedWeaponID.getWeaponItemStats(this).rangedStats(material, projectileDamage, drawSpeed, range, repairIngredient);
}
protected IRangedWeaponID.RangedStats advancedRangedWeaponStats(IRangedWeaponID iRangedWeaponID) {
- return rangedWeaponStats(materialToString(iRangedWeaponID.getMaterial()), iRangedWeaponID.getDrawSpeed(), iRangedWeaponID.getRange(), iRangedWeaponID.getRepairIngredient(), iRangedWeaponID);
+ return rangedWeaponStats(materialToString(iRangedWeaponID.getMaterial()), iRangedWeaponID.getProjectileDamage(), iRangedWeaponID.getDrawSpeed(), iRangedWeaponID.getRange(), iRangedWeaponID.getRepairIngredient(), iRangedWeaponID);
}
protected IShieldID.ShieldStats shieldStats(String material, String[] repairIngredient, IShieldID iShieldID) {
diff --git a/src/main/java/chronosacaria/mcdw/enchants/enchantments/AccelerateEnchantment.java b/src/main/java/chronosacaria/mcdw/enchants/enchantments/AccelerateEnchantment.java
index 5e0d091d..11ac246e 100644
--- a/src/main/java/chronosacaria/mcdw/enchants/enchantments/AccelerateEnchantment.java
+++ b/src/main/java/chronosacaria/mcdw/enchants/enchantments/AccelerateEnchantment.java
@@ -12,7 +12,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.registry.Registry;
-public class AccelerateEnchantment extends RangedEnchantment {
+public class AccelerateEnchantment extends RangedEnchantment{
public AccelerateEnchantment(Rarity rarity, EnchantmentTarget enchantmentTarget, EquipmentSlot[] equipmentSlots) {
super(rarity, enchantmentTarget, equipmentSlots);
if (Mcdw.CONFIG.mcdwEnchantmentsConfig.ENABLE_ENCHANTMENTS.get(EnchantmentsID.ACCELERATE)) {
@@ -56,5 +56,4 @@ public int getMinPower(int level) {
public int getMaxPower(int level) {
return this.getMinPower(level) + 5;
}
-
}
\ No newline at end of file
diff --git a/src/main/java/chronosacaria/mcdw/enchants/enchantments/AmbushEnchantment.java b/src/main/java/chronosacaria/mcdw/enchants/enchantments/AmbushEnchantment.java
index 6dc05e85..59cfeaa8 100644
--- a/src/main/java/chronosacaria/mcdw/enchants/enchantments/AmbushEnchantment.java
+++ b/src/main/java/chronosacaria/mcdw/enchants/enchantments/AmbushEnchantment.java
@@ -31,8 +31,9 @@ public int getMaxLevel(){
@Override
protected boolean canAccept (Enchantment other){
- return Mcdw.CONFIG.mcdwEnchantmentSettingsConfig.ENABLE_ENCHANTMENT_SETTINGS.get(SettingsID.ENABLE_OP_ENCHANTMENT_MIXING) ||
- !(other instanceof AOEEnchantment || other instanceof DamageBoostEnchantment);
+ return Mcdw.CONFIG.mcdwEnchantmentSettingsConfig.ENABLE_ENCHANTMENT_SETTINGS.get(SettingsID.ENABLE_OP_ENCHANTMENT_MIXING)
+ || !(other instanceof AOEEnchantment || other instanceof DamageBoostEnchantment)
+ || other.isAcceptableItem(DaggersID.DAGGER_SWIFT_STRIKER.getItem().getDefaultStack());
}
@Override
@@ -52,7 +53,8 @@ public boolean isAcceptableItem(ItemStack stack) {
return stack.getItem() instanceof SwordItem
|| stack.getItem() instanceof AxeItem
|| stack.getItem() instanceof McdwCustomWeaponBase
- || stack.isOf(DaggersID.DAGGER_SWIFT_STRIKER.getItem()); }
+ || stack.isOf(DaggersID.DAGGER_SWIFT_STRIKER.getItem());
+ }
@Override
public int getMinPower(int level) {
diff --git a/src/main/java/chronosacaria/mcdw/enchants/enchantments/EchoEnchantment.java b/src/main/java/chronosacaria/mcdw/enchants/enchantments/EchoEnchantment.java
index 3bbb54f1..4874ab2b 100644
--- a/src/main/java/chronosacaria/mcdw/enchants/enchantments/EchoEnchantment.java
+++ b/src/main/java/chronosacaria/mcdw/enchants/enchantments/EchoEnchantment.java
@@ -32,7 +32,8 @@ public int getMaxLevel() {
@Override
protected boolean canAccept (Enchantment other) {
return Mcdw.CONFIG.mcdwEnchantmentSettingsConfig.ENABLE_ENCHANTMENT_SETTINGS.get(SettingsID.ENABLE_OP_ENCHANTMENT_MIXING)
- || !(other instanceof AOEEnchantment || other instanceof DamageBoostEnchantment);
+ || !(other instanceof AOEEnchantment || other instanceof DamageBoostEnchantment)
+ || other.isAcceptableItem(DaggersID.DAGGER_SWIFT_STRIKER.getItem().getDefaultStack());
}
@Override
@@ -52,7 +53,8 @@ public boolean isAcceptableItem(ItemStack stack) {
return stack.getItem() instanceof SwordItem
|| stack.getItem() instanceof AxeItem
|| stack.getItem() instanceof McdwCustomWeaponBase
- || stack.isOf(DaggersID.DAGGER_SWIFT_STRIKER.getItem()); }
+ || stack.isOf(DaggersID.DAGGER_SWIFT_STRIKER.getItem());
+ }
@Override
public int getMinPower(int level) {
diff --git a/src/main/java/chronosacaria/mcdw/enchants/enchantments/GuardingStrikeEnchantment.java b/src/main/java/chronosacaria/mcdw/enchants/enchantments/GuardingStrikeEnchantment.java
index 28ebb9ad..56d92867 100644
--- a/src/main/java/chronosacaria/mcdw/enchants/enchantments/GuardingStrikeEnchantment.java
+++ b/src/main/java/chronosacaria/mcdw/enchants/enchantments/GuardingStrikeEnchantment.java
@@ -5,6 +5,8 @@
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentTarget;
import net.minecraft.entity.EquipmentSlot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.RangedWeaponItem;
import net.minecraft.util.registry.Registry;
public class GuardingStrikeEnchantment extends Enchantment {
@@ -33,6 +35,11 @@ public boolean isAvailableForEnchantedBookOffer() {
&& Mcdw.CONFIG.mcdwEnchantmentsConfig.ENABLE_VILLAGER_TRADING.get(EnchantmentsID.GUARDING_STRIKE);
}
+ @Override
+ public boolean isAcceptableItem(ItemStack stack) {
+ return !(stack.getItem() instanceof RangedWeaponItem);
+ }
+
@Override
public int getMinPower(int level) {
return 1 + level * 10;
diff --git a/src/main/java/chronosacaria/mcdw/enums/AxesID.java b/src/main/java/chronosacaria/mcdw/enums/AxesID.java
index c010fd07..76a656f5 100644
--- a/src/main/java/chronosacaria/mcdw/enums/AxesID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/AxesID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum AxesID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum AxesID implements IMeleeWeaponID {
AXE_ANCHOR(ToolMaterials.IRON,8, -3.4f, "minecraft:iron_ingot"),
AXE_AXE(ToolMaterials.IRON,6, -3.1f, "minecraft:iron_ingot"),
AXE_ENCRUSTED_ANCHOR(ToolMaterials.DIAMOND,8, -3.4f, "minecraft:diamond"),
diff --git a/src/main/java/chronosacaria/mcdw/enums/BowsID.java b/src/main/java/chronosacaria/mcdw/enums/BowsID.java
index bbf1adce..4c37c3a2 100644
--- a/src/main/java/chronosacaria/mcdw/enums/BowsID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/BowsID.java
@@ -4,53 +4,61 @@
import chronosacaria.mcdw.bases.McdwBow;
import chronosacaria.mcdw.configs.McdwNewStatsConfig;
import chronosacaria.mcdw.registries.ItemsRegistry;
+import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.item.ToolMaterial;
import net.minecraft.item.ToolMaterials;
+import net.projectile_damage.api.IProjectileWeapon;
import java.util.EnumMap;
import java.util.HashMap;
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum BowsID implements IMcdwWeaponID, IRangedWeaponID {
- BOW_ANCIENT_BOW(ToolMaterials.NETHERITE,14, 18f, "minecraft:netherite_scrap"),
- BOW_BONEBOW(ToolMaterials.STONE,16, 12f, "minecraft:bone"),
- BOW_BUBBLE_BOW(ToolMaterials.IRON,15, 12f, "minecraft:iron_ingot"),
- BOW_BUBBLE_BURSTER(ToolMaterials.DIAMOND,15, 13f, "minecraft:diamond"),
- BOW_BURST_GALE_BOW(ToolMaterials.DIAMOND,12, 16f, "minecraft:diamond"),
- BOW_CALL_OF_THE_VOID(ToolMaterials.NETHERITE,15, 16f, "minecraft:netherite_scrap"),
- BOW_ECHO_OF_THE_VALLEY(ToolMaterials.DIAMOND,11, 16f, "minecraft:diamond"),
- BOW_ELITE_POWER_BOW(ToolMaterials.IRON,20, 15f, "minecraft:iron_ingot"),
- BOW_GREEN_MENACE(ToolMaterials.DIAMOND,17, 13f, "minecraft:diamond"),
- BOW_HAUNTED_BOW(ToolMaterials.NETHERITE,18, 16f, "minecraft:netherite_scrap"),
- BOW_HUNTERS_PROMISE(ToolMaterials.IRON,15, 10f, "minecraft:iron_ingot"),
- BOW_HUNTING_BOW(ToolMaterials.IRON,16, 11f, "minecraft:iron_ingot"),
- BOW_LOST_SOULS(ToolMaterials.NETHERITE,12, 17f, "minecraft:netherite_scrap"),
- BOW_MASTERS_BOW(ToolMaterials.IRON,17, 10f, "minecraft:iron_ingot"),
- BOW_NOCTURNAL_BOW(ToolMaterials.DIAMOND,17, 14f, "minecraft:diamond"),
- BOW_PHANTOM_BOW(ToolMaterials.DIAMOND,20, 14f, "minecraft:diamond"),
- BOW_PINK_SCOUNDREL(ToolMaterials.DIAMOND,17, 13f, "minecraft:diamond"),
- BOW_POWER_BOW(ToolMaterials.IRON,20, 14f, "minecraft:iron_ingot"),
- BOW_SABREWING(ToolMaterials.DIAMOND,10, 13f, "minecraft:diamond"),
- BOW_SHIVERING_BOW(ToolMaterials.DIAMOND,14, 10f, "minecraft:diamond"),
- BOW_SNOW_BOW(ToolMaterials.IRON,16, 11f, "minecraft:iron_ingot"),
- BOW_SOUL_BOW(ToolMaterials.IRON,14, 10f, "minecraft:iron_ingot"),
- BOW_TRICKBOW(ToolMaterials.DIAMOND,12, 10f, "minecraft:diamond"),
- BOW_TWIN_BOW(ToolMaterials.DIAMOND,12, 10f, "minecraft:diamond"),
- BOW_TWISTING_VINE_BOW(ToolMaterials.IRON,15, 10f, "minecraft:iron_ingot"),
- BOW_VOID_BOW(ToolMaterials.DIAMOND,15, 15f, "minecraft:diamond"),
- BOW_WEB_BOW(ToolMaterials.DIAMOND,15, 12f, "minecraft:diamond"),
- BOW_WEEPING_VINE_BOW(ToolMaterials.IRON,15, 10f, "minecraft:iron_ingot"),
- BOW_WIND_BOW(ToolMaterials.DIAMOND,11, 15f, "minecraft:diamond"),
- BOW_WINTERS_TOUCH(ToolMaterials.DIAMOND,15, 13f, "minecraft:diamond");
+public enum BowsID implements IRangedWeaponID {
+ BOW_ANCIENT_BOW( ToolMaterials.NETHERITE, 7, 14, 18f, "minecraft:netherite_scrap"),
+ BOW_BONEBOW( ToolMaterials.STONE, 5, 16, 12f, "minecraft:bone"),
+ BOW_BUBBLE_BOW( ToolMaterials.IRON, 5, 15, 12f, "minecraft:iron_ingot"),
+ BOW_BUBBLE_BURSTER( ToolMaterials.DIAMOND, 5, 15, 13f, "minecraft:diamond"),
+ BOW_BURST_GALE_BOW( ToolMaterials.DIAMOND, 6, 12, 16f, "minecraft:diamond"),
+ BOW_CALL_OF_THE_VOID( ToolMaterials.NETHERITE, 6, 15, 16f, "minecraft:netherite_scrap"),
+ BOW_ECHO_OF_THE_VALLEY(ToolMaterials.DIAMOND, 6, 11, 16f, "minecraft:diamond"),
+ BOW_ELITE_POWER_BOW( ToolMaterials.IRON, 6, 20, 15f, "minecraft:iron_ingot"),
+ BOW_GREEN_MENACE( ToolMaterials.DIAMOND, 5, 17, 13f, "minecraft:diamond"),
+ BOW_HAUNTED_BOW( ToolMaterials.NETHERITE, 6, 18, 16f, "minecraft:netherite_scrap"),
+ BOW_HUNTERS_PROMISE( ToolMaterials.IRON, 6, 15, 16f, "minecraft:iron_ingot"),
+ BOW_HUNTING_BOW( ToolMaterials.IRON, 6, 16, 15f, "minecraft:iron_ingot"),
+ BOW_LOST_SOULS( ToolMaterials.NETHERITE, 6, 12, 17f, "minecraft:netherite_scrap"),
+ BOW_MASTERS_BOW( ToolMaterials.IRON, 6, 17, 16f, "minecraft:iron_ingot"),
+ BOW_NOCTURNAL_BOW( ToolMaterials.DIAMOND, 6, 17, 14f, "minecraft:diamond"),
+ BOW_PHANTOM_BOW( ToolMaterials.DIAMOND, 6, 20, 14f, "minecraft:diamond"),
+ BOW_PINK_SCOUNDREL( ToolMaterials.DIAMOND, 5, 17, 13f, "minecraft:diamond"),
+ BOW_POWER_BOW( ToolMaterials.IRON, 6, 20, 14f, "minecraft:iron_ingot"),
+ BOW_SABREWING( ToolMaterials.DIAMOND, 5, 10, 13f, "minecraft:diamond"),
+ BOW_SHIVERING_BOW( ToolMaterials.DIAMOND, 6, 14, 15f, "minecraft:diamond"),
+ BOW_SNOW_BOW( ToolMaterials.IRON, 5, 16, 13f, "minecraft:iron_ingot"),
+ BOW_SOUL_BOW( ToolMaterials.IRON, 6, 14, 15f, "minecraft:iron_ingot"),
+ BOW_TRICKBOW( ToolMaterials.DIAMOND, 5, 12, 12f, "minecraft:diamond"),
+ BOW_TWIN_BOW( ToolMaterials.DIAMOND, 5, 12, 12f, "minecraft:diamond"),
+ BOW_TWISTING_VINE_BOW( ToolMaterials.IRON, 5, 15, 13f, "minecraft:iron_ingot"),
+ BOW_VOID_BOW( ToolMaterials.DIAMOND, 6, 15, 16f, "minecraft:diamond"),
+ BOW_WEB_BOW( ToolMaterials.DIAMOND, 5, 15, 12f, "minecraft:diamond"),
+ BOW_WEEPING_VINE_BOW( ToolMaterials.IRON, 5, 15, 13f, "minecraft:iron_ingot"),
+ BOW_WIND_BOW( ToolMaterials.DIAMOND, 6, 11, 15f, "minecraft:diamond"),
+ BOW_WINTERS_TOUCH( ToolMaterials.DIAMOND, 6, 15, 14f, "minecraft:diamond");
public final ToolMaterial material;
+ public final double projectileDamage;
public final int drawSpeed;
public final float range;
private final String[] repairIngredient;
- BowsID(ToolMaterial material, int drawSpeed, float range, String... repairIngredient) {
+ BowsID(ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) {
this.material = material;
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ this.projectileDamage = projectileDamage;
+ } else {
+ this.projectileDamage = 0;
+ }
this.drawSpeed = drawSpeed;
this.range = range;
this.repairIngredient = repairIngredient;
@@ -107,6 +115,15 @@ public ToolMaterial getMaterial() {
return material;
}
+ @Override
+ public double getProjectileDamage() {
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ return projectileDamage;
+ } else {
+ return 0;
+ }
+ }
+
@Override
public int getDrawSpeed() {
return drawSpeed;
@@ -122,11 +139,17 @@ public String[] getRepairIngredient() {
return repairIngredient;
}
+ @SuppressWarnings("ConstantConditions")
@Override
public McdwBow makeWeapon() {
McdwBow mcdwBow = new McdwBow(ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material),
this.getWeaponItemStats().drawSpeed, this.getWeaponItemStats().range, this.getWeaponItemStats().repairIngredient);
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ ((IProjectileWeapon) mcdwBow).setProjectileDamage(this.getWeaponItemStats().projectileDamage);
+ ((IProjectileWeapon) mcdwBow).setCustomLaunchVelocity((this.getWeaponItemStats().range / 15.0f) * 3.0);
+ }
+
getItemsEnum().put(this, mcdwBow);
return mcdwBow;
}
diff --git a/src/main/java/chronosacaria/mcdw/enums/CrossbowsID.java b/src/main/java/chronosacaria/mcdw/enums/CrossbowsID.java
index 703e4bab..e83b1803 100644
--- a/src/main/java/chronosacaria/mcdw/enums/CrossbowsID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/CrossbowsID.java
@@ -4,52 +4,60 @@
import chronosacaria.mcdw.bases.McdwCrossbow;
import chronosacaria.mcdw.configs.McdwNewStatsConfig;
import chronosacaria.mcdw.registries.ItemsRegistry;
+import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.item.ToolMaterial;
import net.minecraft.item.ToolMaterials;
+import net.projectile_damage.api.IProjectileWeapon;
import java.util.EnumMap;
import java.util.HashMap;
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum CrossbowsID implements IMcdwWeaponID, IRangedWeaponID {
- CROSSBOW_AUTO_CROSSBOW(ToolMaterials.IRON, 28, 8.0f, "minecraft:iron_ingot"),
- CROSSBOW_AZURE_SEEKER(ToolMaterials.IRON, 28, 8.4f, "minecraft:iron_ingot"),
- CROSSBOW_BABY_CROSSBOW(ToolMaterials.IRON, 23, 7.2f, "minecraft:iron_ingot"),
- CROSSBOW_BURST_CROSSBOW(ToolMaterials.IRON, 28, 8.0f, "minecraft:iron_ingot"),
- CROSSBOW_BUTTERFLY_CROSSBOW(ToolMaterials.IRON, 28, 8.9f, "minecraft:iron_ingot"),
- CROSSBOW_COG_CROSSBOW(ToolMaterials.IRON, 28, 8.4f, "minecraft:iron_ingot"),
- CROSSBOW_CORRUPTED_CROSSBOW(ToolMaterials.NETHERITE, 22, 14.0f, "minecraft:netherite_scrap"),
- CROSSBOW_DOOM_CROSSBOW(ToolMaterials.NETHERITE, 26, 8.0f, "minecraft:netherite_scrap"),
- CROSSBOW_DUAL_CROSSBOW(ToolMaterials.IRON, 24, 7.0f, "minecraft:iron_ingot"),
- CROSSBOW_EXPLODING_CROSSBOW(ToolMaterials.IRON, 28, 8.0f, "minecraft:iron_ingot"),
- CROSSBOW_FERAL_SOUL_CROSSBOW(ToolMaterials.IRON, 28, 9.2f, "minecraft:iron_ingot"),
- CROSSBOW_FIREBOLT_THROWER(ToolMaterials.IRON, 28, 7.9f, "minecraft:iron_ingot"),
- CROSSBOW_HARPOON_CROSSBOW(ToolMaterials.IRON, 28, 11.0f, "minecraft:iron_ingot"),
- CROSSBOW_HARP_CROSSBOW(ToolMaterials.IRON, 28, 8.6f, "minecraft:iron_ingot"),
- CROSSBOW_HEAVY_CROSSBOW(ToolMaterials.IRON, 28, 8.0f, "minecraft:iron_ingot"),
- CROSSBOW_IMPLODING_CROSSBOW(ToolMaterials.IRON, 28, 8.0f, "minecraft:iron_ingot"),
- CROSSBOW_LIGHTNING_HARP_CROSSBOW(ToolMaterials.DIAMOND, 28, 14.2f, "minecraft:diamond"),
- CROSSBOW_NAUTICAL_CROSSBOW(ToolMaterials.DIAMOND, 24, 14.0f, "minecraft:diamond"),
- CROSSBOW_PRIDE_OF_THE_PIGLINS(ToolMaterials.NETHERITE, 20, 13.0f, "minecraft:netherite_scrap"),
- CROSSBOW_RAPID_CROSSBOW(ToolMaterials.IRON, 20, 8.2f, "minecraft:iron_ingot"),
- CROSSBOW_SCATTER_CROSSBOW(ToolMaterials.IRON, 28, 8.0f, "minecraft:iron_ingot"),
- CROSSBOW_SHADOW_CROSSBOW(ToolMaterials.DIAMOND, 25, 12.0f, "minecraft:diamond"),
- CROSSBOW_SLAYER_CROSSBOW(ToolMaterials.DIAMOND, 26, 8.8f, "minecraft:diamond"),
- CROSSBOW_SOUL_CROSSBOW(ToolMaterials.IRON, 28, 8.0f, "minecraft:iron_ingot"),
- CROSSBOW_SOUL_HUNTER_CROSSBOW(ToolMaterials.DIAMOND, 28, 11.0f, "minecraft:diamond"),
- CROSSBOW_SPELLBOUND_CROSSBOW(ToolMaterials.IRON, 28, 8.9f, "minecraft:iron_ingot"),
- CROSSBOW_THE_SLICER(ToolMaterials.IRON, 28, 10.2f, "minecraft:iron_ingot"),
- CROSSBOW_VEILED_CROSSBOW(ToolMaterials.DIAMOND, 22, 14.5f, "minecraft:diamond"),
- CROSSBOW_VOIDCALLER_CROSSBOW(ToolMaterials.DIAMOND, 26, 12.5f, "minecraft:diamond");
+public enum CrossbowsID implements IRangedWeaponID {
+ CROSSBOW_AUTO_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"),
+ CROSSBOW_AZURE_SEEKER( ToolMaterials.IRON, 10, 28, 8.4f, "minecraft:iron_ingot"),
+ CROSSBOW_BABY_CROSSBOW( ToolMaterials.IRON, 8, 23, 7.2f, "minecraft:iron_ingot"),
+ CROSSBOW_BURST_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"),
+ CROSSBOW_BUTTERFLY_CROSSBOW( ToolMaterials.IRON, 10, 28, 8.9f, "minecraft:iron_ingot"),
+ CROSSBOW_COG_CROSSBOW( ToolMaterials.IRON, 10, 28, 8.4f, "minecraft:iron_ingot"),
+ CROSSBOW_CORRUPTED_CROSSBOW( ToolMaterials.NETHERITE, 16, 22, 14.0f, "minecraft:netherite_scrap"),
+ CROSSBOW_DOOM_CROSSBOW( ToolMaterials.NETHERITE, 9, 26, 8.0f, "minecraft:netherite_scrap"),
+ CROSSBOW_DUAL_CROSSBOW( ToolMaterials.IRON, 8, 24, 7.0f, "minecraft:iron_ingot"),
+ CROSSBOW_EXPLODING_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"),
+ CROSSBOW_FERAL_SOUL_CROSSBOW( ToolMaterials.IRON, 10, 28, 9.2f, "minecraft:iron_ingot"),
+ CROSSBOW_FIREBOLT_THROWER( ToolMaterials.IRON, 9, 28, 7.9f, "minecraft:iron_ingot"),
+ CROSSBOW_HARPOON_CROSSBOW( ToolMaterials.IRON, 12, 28, 11.0f, "minecraft:iron_ingot"),
+ CROSSBOW_HARP_CROSSBOW( ToolMaterials.IRON, 10, 28, 8.6f, "minecraft:iron_ingot"),
+ CROSSBOW_HEAVY_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"),
+ CROSSBOW_IMPLODING_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"),
+ CROSSBOW_LIGHTNING_HARP_CROSSBOW(ToolMaterials.DIAMOND, 16, 28, 14.2f, "minecraft:diamond"),
+ CROSSBOW_NAUTICAL_CROSSBOW( ToolMaterials.DIAMOND, 16, 24, 14.0f, "minecraft:diamond"),
+ CROSSBOW_PRIDE_OF_THE_PIGLINS( ToolMaterials.NETHERITE, 15, 20, 13.0f, "minecraft:netherite_scrap"),
+ CROSSBOW_RAPID_CROSSBOW( ToolMaterials.IRON, 9, 20, 8.2f, "minecraft:iron_ingot"),
+ CROSSBOW_SCATTER_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"),
+ CROSSBOW_SHADOW_CROSSBOW( ToolMaterials.DIAMOND, 14, 25, 12.0f, "minecraft:diamond"),
+ CROSSBOW_SLAYER_CROSSBOW( ToolMaterials.DIAMOND, 10, 26, 8.8f, "minecraft:diamond"),
+ CROSSBOW_SOUL_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"),
+ CROSSBOW_SOUL_HUNTER_CROSSBOW( ToolMaterials.DIAMOND, 12, 28, 11.0f, "minecraft:diamond"),
+ CROSSBOW_SPELLBOUND_CROSSBOW( ToolMaterials.IRON, 10, 28, 8.9f, "minecraft:iron_ingot"),
+ CROSSBOW_THE_SLICER( ToolMaterials.IRON, 12, 28, 10.2f, "minecraft:iron_ingot"),
+ CROSSBOW_VEILED_CROSSBOW( ToolMaterials.DIAMOND, 16, 22, 14.5f, "minecraft:diamond"),
+ CROSSBOW_VOIDCALLER_CROSSBOW( ToolMaterials.DIAMOND, 14, 26, 12.5f, "minecraft:diamond");
public final ToolMaterial material;
+ public final double projectileDamage;
public final int drawSpeed;
public final float range;
private final String[] repairIngredient;
- CrossbowsID(ToolMaterial material, int drawSpeed, float range, String... repairIngredient) {
+ CrossbowsID(ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) {
this.material = material;
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ this.projectileDamage = projectileDamage;
+ } else {
+ this.projectileDamage = 0;
+ }
this.drawSpeed = drawSpeed;
this.range = range;
this.repairIngredient = repairIngredient;
@@ -106,6 +114,15 @@ public ToolMaterial getMaterial() {
return material;
}
+ @Override
+ public double getProjectileDamage() {
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ return projectileDamage;
+ } else {
+ return 0;
+ }
+ }
+
@Override
public int getDrawSpeed() {
return drawSpeed;
@@ -121,11 +138,16 @@ public String[] getRepairIngredient() {
return repairIngredient;
}
+ @SuppressWarnings("ConstantConditions")
@Override
public McdwCrossbow makeWeapon() {
McdwCrossbow mcdwCrossbow = new McdwCrossbow(ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material),
this.getWeaponItemStats().drawSpeed, this.getWeaponItemStats().range, this.getWeaponItemStats().repairIngredient);
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ ((IProjectileWeapon) mcdwCrossbow).setProjectileDamage(this.getWeaponItemStats().projectileDamage);
+ ((IProjectileWeapon) mcdwCrossbow).setCustomLaunchVelocity((this.getWeaponItemStats().range / 8.0f) * 3.15);
+ }
getItemsEnum().put(this, mcdwCrossbow);
return mcdwCrossbow;
}
diff --git a/src/main/java/chronosacaria/mcdw/enums/DaggersID.java b/src/main/java/chronosacaria/mcdw/enums/DaggersID.java
index c8857b1d..84434691 100644
--- a/src/main/java/chronosacaria/mcdw/enums/DaggersID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/DaggersID.java
@@ -11,7 +11,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum DaggersID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum DaggersID implements IMeleeWeaponID {
DAGGER_BACKSTABBER(ToolMaterials.DIAMOND,1, -1.7f, "minecraft:diamond"),
DAGGER_CHILL_GALE_KNIFE(ToolMaterials.DIAMOND,2, -2.2f, "minecraft:diamond"),
DAGGER_DAGGER(ToolMaterials.IRON,1, -1.5f, "minecraft:iron_ingot"),
diff --git a/src/main/java/chronosacaria/mcdw/enums/DoubleAxesID.java b/src/main/java/chronosacaria/mcdw/enums/DoubleAxesID.java
index 0fd1667e..df037e87 100644
--- a/src/main/java/chronosacaria/mcdw/enums/DoubleAxesID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/DoubleAxesID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum DoubleAxesID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum DoubleAxesID implements IMeleeWeaponID {
AXE_CURSED(ToolMaterials.IRON,7, -2.9f, "minecraft:iron_ingot"),
AXE_DOUBLE(ToolMaterials.IRON,6, -2.9f, "minecraft:iron_ingot"),
AXE_WHIRLWIND(ToolMaterials.IRON,6, -2.9f, "minecraft:iron_ingot");
diff --git a/src/main/java/chronosacaria/mcdw/enums/GauntletsID.java b/src/main/java/chronosacaria/mcdw/enums/GauntletsID.java
index 72f38dfd..1ee58df4 100644
--- a/src/main/java/chronosacaria/mcdw/enums/GauntletsID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/GauntletsID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum GauntletsID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum GauntletsID implements IMeleeWeaponID {
GAUNTLET_GAUNTLET(ToolMaterials.IRON,0, -1.5f, "minecraft:iron_ingot"),
GAUNTLET_MAULERS(ToolMaterials.DIAMOND,1, -1.5f, "minecraft:diamond"),
GAUNTLET_SOUL_FISTS(ToolMaterials.NETHERITE,0, -1.5f, "minecraft:netherite_scrap");
diff --git a/src/main/java/chronosacaria/mcdw/enums/GlaivesID.java b/src/main/java/chronosacaria/mcdw/enums/GlaivesID.java
index 6e8d0dc1..2595556e 100644
--- a/src/main/java/chronosacaria/mcdw/enums/GlaivesID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/GlaivesID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum GlaivesID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum GlaivesID implements IMeleeWeaponID {
SPEAR_CACKLING_BROOM(ToolMaterials.IRON,5, -3f, "minecraft:iron_ingot"),
SPEAR_GLAIVE(ToolMaterials.IRON,5, -3f, "minecraft:iron_ingot"),
SPEAR_GRAVE_BANE(ToolMaterials.IRON,6, -3f, "minecraft:iron_ingot"),
diff --git a/src/main/java/chronosacaria/mcdw/enums/HammersID.java b/src/main/java/chronosacaria/mcdw/enums/HammersID.java
index 97ac0379..1b079ff0 100644
--- a/src/main/java/chronosacaria/mcdw/enums/HammersID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/HammersID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum HammersID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum HammersID implements IMeleeWeaponID {
HAMMER_BONECLUB(ToolMaterials.IRON,7, -3.2f, "minecraft:bone_block"),
HAMMER_BONE_CUDGEL(ToolMaterials.NETHERITE,7, -3.2f, "minecraft:netherite_scrap"),
HAMMER_FLAIL(ToolMaterials.IRON,5, -2.8f, "minecraft:iron_ingot"),
diff --git a/src/main/java/chronosacaria/mcdw/enums/IRangedWeaponID.java b/src/main/java/chronosacaria/mcdw/enums/IRangedWeaponID.java
index 5c6ae932..881e4aba 100644
--- a/src/main/java/chronosacaria/mcdw/enums/IRangedWeaponID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/IRangedWeaponID.java
@@ -1,6 +1,7 @@
package chronosacaria.mcdw.enums;
import chronosacaria.mcdw.configs.McdwNewStatsConfig;
+import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.item.ToolMaterial;
import java.util.HashMap;
@@ -18,18 +19,25 @@ static IRangedWeaponID[] values() {
IRangedWeaponID.RangedStats getWeaponItemStats(McdwNewStatsConfig mcdwNewStatsConfig);
ToolMaterial getMaterial();
+ double getProjectileDamage();
int getDrawSpeed();
float getRange();
String[] getRepairIngredient();
class RangedStats {
public String material;
+ public double projectileDamage;
public int drawSpeed;
public float range;
String[] repairIngredient;
- public RangedStats rangedStats(String material, int drawSpeed, float range, String[] repairIngredient) {
+ public RangedStats rangedStats(String material, double projectileDamage, int drawSpeed, float range, String[] repairIngredient) {
this.material = material;
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ this.projectileDamage = projectileDamage;
+ } else {
+ this.projectileDamage = 0;
+ }
this.drawSpeed = drawSpeed;
this.range = range;
this.repairIngredient = repairIngredient;
diff --git a/src/main/java/chronosacaria/mcdw/enums/LongbowsID.java b/src/main/java/chronosacaria/mcdw/enums/LongbowsID.java
index 024c4242..9fe3ccc7 100644
--- a/src/main/java/chronosacaria/mcdw/enums/LongbowsID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/LongbowsID.java
@@ -4,26 +4,34 @@
import chronosacaria.mcdw.bases.McdwLongbow;
import chronosacaria.mcdw.configs.McdwNewStatsConfig;
import chronosacaria.mcdw.registries.ItemsRegistry;
+import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.item.ToolMaterial;
import net.minecraft.item.ToolMaterials;
+import net.projectile_damage.api.IProjectileWeapon;
import java.util.EnumMap;
import java.util.HashMap;
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum LongbowsID implements IMcdwWeaponID, IRangedWeaponID {
- BOW_GUARDIAN_BOW(ToolMaterials.DIAMOND, 30, 19f, "minecraft:diamond"),
- BOW_LONGBOW(ToolMaterials.IRON, 25, 17f, "minecraft:planks"),
- BOW_RED_SNAKE(ToolMaterials.DIAMOND, 30, 18f, "minecraft:diamond");
+public enum LongbowsID implements IRangedWeaponID {
+ BOW_GUARDIAN_BOW(ToolMaterials.DIAMOND, 8, 30, 19f, "minecraft:diamond"),
+ BOW_LONGBOW( ToolMaterials.IRON, 7, 25, 17f, "minecraft:planks"),
+ BOW_RED_SNAKE( ToolMaterials.DIAMOND, 7, 30, 18f, "minecraft:diamond");
public final ToolMaterial material;
+ public final double projectileDamage;
public final int drawSpeed;
public final float range;
private final String[] repairIngredient;
- LongbowsID(ToolMaterial material, int drawSpeed, float range, String... repairIngredient) {
+ LongbowsID(ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) {
this.material = material;
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ this.projectileDamage = projectileDamage;
+ } else {
+ this.projectileDamage = 0;
+ }
this.drawSpeed = drawSpeed;
this.range = range;
this.repairIngredient = repairIngredient;
@@ -80,6 +88,15 @@ public ToolMaterial getMaterial() {
return material;
}
+ @Override
+ public double getProjectileDamage() {
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ return projectileDamage;
+ } else {
+ return 0;
+ }
+ }
+
@Override
public int getDrawSpeed() {
return drawSpeed;
@@ -95,11 +112,16 @@ public String[] getRepairIngredient() {
return repairIngredient;
}
+ @SuppressWarnings("ConstantConditions")
@Override
public McdwLongbow makeWeapon() {
McdwLongbow mcdwLongbow = new McdwLongbow(ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material),
this.getWeaponItemStats().drawSpeed, this.getWeaponItemStats().range, this.getWeaponItemStats().repairIngredient);
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ ((IProjectileWeapon) mcdwLongbow).setProjectileDamage(this.getWeaponItemStats().projectileDamage);
+ ((IProjectileWeapon) mcdwLongbow).setCustomLaunchVelocity((this.getWeaponItemStats().range / 15.0f) * 3.0);
+ }
getItemsEnum().put(this, mcdwLongbow);
return mcdwLongbow;
}
diff --git a/src/main/java/chronosacaria/mcdw/enums/PicksID.java b/src/main/java/chronosacaria/mcdw/enums/PicksID.java
index e7497b2b..c2fa91af 100644
--- a/src/main/java/chronosacaria/mcdw/enums/PicksID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/PicksID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum PicksID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum PicksID implements IMeleeWeaponID {
PICK_DIAMOND_PICKAXE_VAR(ToolMaterials.DIAMOND,1, -2.8f, "minecraft:diamond"),
PICK_HAILING_PINNACLE(ToolMaterials.DIAMOND,1, -2.8f, "minecraft:diamond"),
PICK_HOWLING_PICK(ToolMaterials.IRON,1, -2.8f, "minecraft:iron_ingot"),
diff --git a/src/main/java/chronosacaria/mcdw/enums/ScythesID.java b/src/main/java/chronosacaria/mcdw/enums/ScythesID.java
index 1e145289..c2c8cf18 100644
--- a/src/main/java/chronosacaria/mcdw/enums/ScythesID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/ScythesID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum ScythesID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum ScythesID implements IMeleeWeaponID {
SICKLE_FROST_SCYTHE(ToolMaterials.DIAMOND,4, -2.9f, "minecraft:diamond"),
SICKLE_JAILORS_SCYTHE(ToolMaterials.IRON,4, -2.9f, "minecraft:iron_ingot"),
SICKLE_SKULL_SCYTHE(ToolMaterials.DIAMOND,4, -2.9f, "minecraft:diamond"),
diff --git a/src/main/java/chronosacaria/mcdw/enums/ShieldsID.java b/src/main/java/chronosacaria/mcdw/enums/ShieldsID.java
index a37a1aaf..6dba8ad0 100644
--- a/src/main/java/chronosacaria/mcdw/enums/ShieldsID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/ShieldsID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum ShieldsID implements IMcdwWeaponID, IShieldID {
+public enum ShieldsID implements IShieldID {
SHIELD_ROYAL_GUARD(ToolMaterials.DIAMOND, "minecraft:iron_ingot", "minecraft:gold_ingot"),
SHIELD_TOWER_GUARD(ToolMaterials.DIAMOND, "minecraft:iron_ingot", "minecraft:gold_ingot", "minecraft:copper_ingot"),
SHIELD_VANGUARD(ToolMaterials.DIAMOND, "minecraft:planks", "minecraft:iron_ingot");
diff --git a/src/main/java/chronosacaria/mcdw/enums/ShortbowsID.java b/src/main/java/chronosacaria/mcdw/enums/ShortbowsID.java
index deb6eab3..83122f06 100644
--- a/src/main/java/chronosacaria/mcdw/enums/ShortbowsID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/ShortbowsID.java
@@ -4,27 +4,35 @@
import chronosacaria.mcdw.bases.McdwShortbow;
import chronosacaria.mcdw.configs.McdwNewStatsConfig;
import chronosacaria.mcdw.registries.ItemsRegistry;
+import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.item.ToolMaterial;
import net.minecraft.item.ToolMaterials;
+import net.projectile_damage.api.IProjectileWeapon;
import java.util.EnumMap;
import java.util.HashMap;
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum ShortbowsID implements IMcdwWeaponID, IRangedWeaponID {
- BOW_LOVE_SPELL_BOW(ToolMaterials.IRON, 9, 8f, "minecraft:iron_ingot"),
- BOW_MECHANICAL_SHORTBOW(ToolMaterials.IRON, 9, 9f, "minecraft:iron_ingot"),
- BOW_PURPLE_STORM(ToolMaterials.IRON, 9, 8f, "minecraft:iron_ingot"),
- BOW_SHORTBOW(ToolMaterials.IRON, 9, 8f, "minecraft:planks");
+public enum ShortbowsID implements IRangedWeaponID {
+ BOW_LOVE_SPELL_BOW( ToolMaterials.IRON, 3, 9, 8f, "minecraft:iron_ingot"),
+ BOW_MECHANICAL_SHORTBOW(ToolMaterials.IRON, 4, 9, 9f, "minecraft:iron_ingot"),
+ BOW_PURPLE_STORM( ToolMaterials.IRON, 3, 9, 8f, "minecraft:iron_ingot"),
+ BOW_SHORTBOW( ToolMaterials.IRON, 3, 9, 8f, "minecraft:planks");
public final ToolMaterial material;
+ public final double projectileDamage;
public final int drawSpeed;
public final float range;
private final String[] repairIngredient;
- ShortbowsID(ToolMaterial material, int drawSpeed, float range, String... repairIngredient) {
+ ShortbowsID(ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) {
this.material = material;
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ this.projectileDamage = projectileDamage;
+ } else {
+ this.projectileDamage = 0;
+ }
this.drawSpeed = drawSpeed;
this.range = range;
this.repairIngredient = repairIngredient;
@@ -81,6 +89,15 @@ public ToolMaterial getMaterial() {
return material;
}
+ @Override
+ public double getProjectileDamage() {
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ return projectileDamage;
+ } else {
+ return 0;
+ }
+ }
+
@Override
public int getDrawSpeed() {
return drawSpeed;
@@ -96,11 +113,16 @@ public String[] getRepairIngredient() {
return repairIngredient;
}
+ @SuppressWarnings("ConstantConditions")
@Override
public McdwShortbow makeWeapon() {
McdwShortbow mcdwShortbow = new McdwShortbow(ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material),
this.getWeaponItemStats().drawSpeed, this.getWeaponItemStats().range, this.getWeaponItemStats().repairIngredient);
+ if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
+ ((IProjectileWeapon) mcdwShortbow).setProjectileDamage(this.getWeaponItemStats().projectileDamage);
+ ((IProjectileWeapon) mcdwShortbow).setCustomLaunchVelocity((this.getWeaponItemStats().range / 15.0f) * 3.0);
+ }
getItemsEnum().put(this, mcdwShortbow);
return mcdwShortbow;
}
diff --git a/src/main/java/chronosacaria/mcdw/enums/SicklesID.java b/src/main/java/chronosacaria/mcdw/enums/SicklesID.java
index 146445c6..d1ae6d6d 100644
--- a/src/main/java/chronosacaria/mcdw/enums/SicklesID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/SicklesID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum SicklesID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum SicklesID implements IMeleeWeaponID {
SICKLE_LAST_LAUGH_GOLD(ToolMaterials.IRON,2, -2.1f, "minecraft:iron_ingot"),
SICKLE_LAST_LAUGH_SILVER(ToolMaterials.IRON,2, -2.1f, "minecraft:iron_ingot"),
SICKLE_NIGHTMARES_BITE(ToolMaterials.IRON,2, -2.1f, "minecraft:iron_ingot"),
diff --git a/src/main/java/chronosacaria/mcdw/enums/SoulDaggersID.java b/src/main/java/chronosacaria/mcdw/enums/SoulDaggersID.java
index 30d25bc2..22f0027b 100644
--- a/src/main/java/chronosacaria/mcdw/enums/SoulDaggersID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/SoulDaggersID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum SoulDaggersID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum SoulDaggersID implements IMeleeWeaponID {
DAGGER_ETERNAL_KNIFE(ToolMaterials.NETHERITE,4, -2.8f, "minecraft:netherite_scrap"),
DAGGER_SOUL_KNIFE(ToolMaterials.IRON,4, -2.8f, "minecraft:iron_ingot"),
SWORD_TRUTHSEEKER(ToolMaterials.NETHERITE,3, -2.8f, "minecraft:netherite_scrap");
diff --git a/src/main/java/chronosacaria/mcdw/enums/SpearsID.java b/src/main/java/chronosacaria/mcdw/enums/SpearsID.java
index 8b12725f..62d39a5e 100644
--- a/src/main/java/chronosacaria/mcdw/enums/SpearsID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/SpearsID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum SpearsID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum SpearsID implements IMeleeWeaponID {
SPEAR_SPEAR(ToolMaterials.IRON,4, -2.5f, "minecraft:iron_ingot"),
SPEAR_WHISPERING_SPEAR(ToolMaterials.IRON,5, -2.5f, "minecraft:iron_ingot"),
SPEAR_FORTUNE(ToolMaterials.IRON,5, -2.5f, "minecraft:iron_ingot");
diff --git a/src/main/java/chronosacaria/mcdw/enums/StavesID.java b/src/main/java/chronosacaria/mcdw/enums/StavesID.java
index 4bdd76f8..502097db 100644
--- a/src/main/java/chronosacaria/mcdw/enums/StavesID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/StavesID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum StavesID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum StavesID implements IMeleeWeaponID {
STAFF_BATTLESTAFF(ToolMaterials.WOOD,2, -2.6f, "minecraft:planks"),
STAFF_BATTLESTAFF_OF_TERROR(ToolMaterials.IRON,5, -2.6f, "minecraft:iron_ingot"),
STAFF_GROWING_STAFF(ToolMaterials.IRON,5, -2.6f, "minecraft:iron_ingot");
diff --git a/src/main/java/chronosacaria/mcdw/enums/SwordsID.java b/src/main/java/chronosacaria/mcdw/enums/SwordsID.java
index 062a9c83..e2602daa 100644
--- a/src/main/java/chronosacaria/mcdw/enums/SwordsID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/SwordsID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum SwordsID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum SwordsID implements IMeleeWeaponID {
SWORD_BEESTINGER(ToolMaterials.IRON, 0, -1.1f, "minecraft:iron_ingot"),
SWORD_BROADSWORD(ToolMaterials.IRON, 5, -3.0f, "minecraft:iron_ingot"),
SWORD_BROKEN_SAWBLADE(ToolMaterials.IRON,3, -2.4f, "minecraft:iron_ingot"),
diff --git a/src/main/java/chronosacaria/mcdw/enums/WhipsID.java b/src/main/java/chronosacaria/mcdw/enums/WhipsID.java
index 1d5527f6..e0af18b2 100644
--- a/src/main/java/chronosacaria/mcdw/enums/WhipsID.java
+++ b/src/main/java/chronosacaria/mcdw/enums/WhipsID.java
@@ -12,7 +12,7 @@
import static chronosacaria.mcdw.Mcdw.CONFIG;
-public enum WhipsID implements IMcdwWeaponID, IMeleeWeaponID {
+public enum WhipsID implements IMeleeWeaponID {
WHIP_VINE_WHIP(ToolMaterials.IRON, 5, -3.1f, "minecraft:vine"),
WHIP_WHIP(ToolMaterials.IRON, 3, -3.1f, "minecraft:string");
diff --git a/src/main/java/chronosacaria/mcdw/mixin/DamageEnchantmentMixin.java b/src/main/java/chronosacaria/mcdw/mixin/DamageEnchantmentMixin.java
deleted file mode 100644
index 6cc79b3e..00000000
--- a/src/main/java/chronosacaria/mcdw/mixin/DamageEnchantmentMixin.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package chronosacaria.mcdw.mixin;
-
-import chronosacaria.mcdw.bases.McdwSpear;
-import net.minecraft.enchantment.DamageEnchantment;
-import net.minecraft.item.ItemStack;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-
-@Mixin(DamageEnchantment.class)
-public class DamageEnchantmentMixin {
- @Inject(method = "isAcceptableItem", at = @At("HEAD"), cancellable = true)
- public void mcdw$enableDamageEnchantmentsForSpears(ItemStack stack, CallbackInfoReturnable cir){
- if (stack.getItem() instanceof McdwSpear){
- cir.setReturnValue(true);
- }
- }
-}
diff --git a/src/main/java/chronosacaria/mcdw/mixin/EnchantmentHelperMixin.java b/src/main/java/chronosacaria/mcdw/mixin/EnchantmentHelperMixin.java
index 81f2ed22..d45f8631 100644
--- a/src/main/java/chronosacaria/mcdw/mixin/EnchantmentHelperMixin.java
+++ b/src/main/java/chronosacaria/mcdw/mixin/EnchantmentHelperMixin.java
@@ -4,32 +4,52 @@
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.EnchantmentLevelEntry;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NbtCompound;
-import net.minecraft.nbt.NbtElement;
-import net.minecraft.util.Identifier;
+import net.minecraft.item.Items;
import net.minecraft.util.registry.Registry;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import java.util.ArrayList;
import java.util.List;
@Mixin(EnchantmentHelper.class)
public class EnchantmentHelperMixin {
- @Inject(method = "getPossibleEntries", at = @At(value = "RETURN"), cancellable = true)
- private static void mcdw$permitInnateEnchantmentsToBeEnchantedButNotWithConflicts(int power, ItemStack stack, boolean treasureAllowed,
- CallbackInfoReturnable> cir) {
- List list = cir.getReturnValue();
- for (NbtElement enchantmentNbt : stack.getEnchantments()) {
- NbtCompound nbtCompound = (NbtCompound) enchantmentNbt;
- Identifier identifier = EnchantmentHelper.getIdFromNbt(nbtCompound);
- Enchantment enchantmentOnStack = Registry.ENCHANTMENT.get(identifier);
- // If can find enchants, remove incompatible options from the list of randomly enchant-able enchantments
- if (enchantmentOnStack != null)
- list.removeIf(enchantmentLevelEntry -> !enchantmentLevelEntry.enchantment.canCombine(enchantmentOnStack));
+ // This mixin is to fix Vanilla Enchantment table not checking `isAcceptableItem` function
+ @Inject(method = "getPossibleEntries", at = @At("RETURN"))
+ private static void getPossibleEntries_RETURN_SpellEngine(int power, ItemStack stack, boolean treasureAllowed, CallbackInfoReturnable> cir) {
+ var currentEntries = cir.getReturnValue();
+
+ // 1. REMOVING ENCHANT ENTRIES ADDED INCORRECTLY
+
+ var toRemove = new ArrayList();
+ for (var entry: currentEntries) {
+ if (!entry.enchantment.isAcceptableItem(stack)) {
+ toRemove.add(entry);
+ }
+ }
+ currentEntries.removeAll(toRemove);
+
+ // 2. ADDING ENCHANT ENTRIES LEFT OUT INITIALLY
+
+ // This logic is mostly copied from EnchantmentHelper.getPossibleEntries
+ boolean isBook = stack.isOf(Items.BOOK);
+ for (Enchantment enchantment : Registry.ENCHANTMENT) {
+ // Don't check entries already added
+ boolean alreadyAdded = currentEntries.stream().anyMatch(entry -> entry.enchantment.equals(enchantment));
+ if (alreadyAdded) { continue; }
+
+ if (enchantment.isTreasure()
+ && !treasureAllowed
+ || !enchantment.isAvailableForRandomSelection()
+ || !enchantment.isAcceptableItem(stack) // Custom logic, replacing `!enchantment.type.isAcceptableItem(item)`
+ && !isBook) continue;
+ for (int i = enchantment.getMaxLevel(); i > enchantment.getMinLevel() - 1; --i) {
+ if (power < enchantment.getMinPower(i) || power > enchantment.getMaxPower(i)) continue;
+ currentEntries.add(new EnchantmentLevelEntry(enchantment, i));
+ }
}
- cir.setReturnValue(list);
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/chronosacaria/mcdw/mixin/EnchantmentMixin.java b/src/main/java/chronosacaria/mcdw/mixin/EnchantmentMixin.java
index 8d38a218..e3ce2379 100644
--- a/src/main/java/chronosacaria/mcdw/mixin/EnchantmentMixin.java
+++ b/src/main/java/chronosacaria/mcdw/mixin/EnchantmentMixin.java
@@ -1,47 +1,30 @@
package chronosacaria.mcdw.mixin;
-import chronosacaria.mcdw.bases.McdwAxe;
-import chronosacaria.mcdw.bases.McdwCustomWeaponBase;
-import chronosacaria.mcdw.bases.McdwDoubleAxe;
-import chronosacaria.mcdw.enums.DaggersID;
-import chronosacaria.mcdw.registries.EnchantsRegistry;
+import chronosacaria.mcdw.api.util.EnchantmentRestriction;
import net.minecraft.enchantment.Enchantment;
-import net.minecraft.enchantment.EnchantmentTarget;
-import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemStack;
-import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import java.util.Arrays;
@Mixin(Enchantment.class)
-public abstract class EnchantmentMixin {
+public class EnchantmentMixin {
- @Shadow @Final public EnchantmentTarget type;
+ @Inject(method = "isAcceptableItem", at = @At("HEAD"), cancellable = true)
+ public void mcdw$isAcceptableItem(ItemStack stack, CallbackInfoReturnable cir) {
+ var enchantment = (Enchantment)((Object)this);
- @Inject(method = "isAcceptableItem", at = @At("RETURN"), cancellable = true)
-
- private void mcdw$isAcceptablePlz(ItemStack stack, CallbackInfoReturnable cir){
- if ((stack.getItem() instanceof McdwAxe || stack.getItem() instanceof McdwDoubleAxe)
- && mcdw$isEnchantment(Enchantments.FIRE_ASPECT)) {
- cir.setReturnValue(true);
- }
- if (stack.getItem() instanceof McdwCustomWeaponBase
- && this.type.equals(EnchantmentTarget.WEAPON)){
- cir.setReturnValue(true);
+ if (EnchantmentRestriction.isProhibited(enchantment, stack)) {
+ cir.setReturnValue(false);
+ cir.cancel();
}
- if (stack.isOf(DaggersID.DAGGER_SWIFT_STRIKER.getItem())
- && mcdw$isEnchantment(EnchantsRegistry.ECHO, EnchantsRegistry.AMBUSH)){
+
+ if (EnchantmentRestriction.isPermitted(enchantment, stack)) {
cir.setReturnValue(true);
+ cir.cancel();
}
}
-
- private boolean mcdw$isEnchantment(Enchantment ...enchantments){
- return Arrays.stream(enchantments).toList().contains((Enchantment) (Object) this);
- }
}
diff --git a/src/main/java/chronosacaria/mcdw/registries/EnchantmentRestrictionsRegistry.java b/src/main/java/chronosacaria/mcdw/registries/EnchantmentRestrictionsRegistry.java
new file mode 100644
index 00000000..feade93b
--- /dev/null
+++ b/src/main/java/chronosacaria/mcdw/registries/EnchantmentRestrictionsRegistry.java
@@ -0,0 +1,15 @@
+package chronosacaria.mcdw.registries;
+
+import chronosacaria.mcdw.api.util.EnchantmentRestriction;
+import chronosacaria.mcdw.bases.McdwAxe;
+import chronosacaria.mcdw.bases.McdwDoubleAxe;
+import chronosacaria.mcdw.bases.McdwSpear;
+import net.minecraft.enchantment.DamageEnchantment;
+import net.minecraft.enchantment.Enchantments;
+
+public class EnchantmentRestrictionsRegistry {
+ public static void init() {
+ EnchantmentRestriction.permit(Enchantments.FIRE_ASPECT, itemStack -> itemStack.getItem() instanceof McdwAxe || itemStack.getItem() instanceof McdwDoubleAxe);
+ EnchantmentRestriction.permitTarget((enchantment, itemStack) -> enchantment instanceof DamageEnchantment && itemStack.getItem() instanceof McdwSpear);
+ }
+}
diff --git a/src/main/resources/data/fabric/tags/items/axes.json b/src/main/resources/data/fabric/tags/items/axes.json
index 313c4ab6..b30863a9 100644
--- a/src/main/resources/data/fabric/tags/items/axes.json
+++ b/src/main/resources/data/fabric/tags/items/axes.json
@@ -32,6 +32,10 @@
{
"id":"mcdw:axe_encrusted_anchor",
"required": false
+ },
+ {
+ "id":"mcdw:sword_mechanized_sawblade",
+ "required": false
}
]
}
\ No newline at end of file
diff --git a/src/main/resources/mcdw.mixins.json b/src/main/resources/mcdw.mixins.json
index 8a1989c0..d472e05d 100644
--- a/src/main/resources/mcdw.mixins.json
+++ b/src/main/resources/mcdw.mixins.json
@@ -7,7 +7,6 @@
"BowItemMixin",
"CreeperEntityAccessor",
"CrossbowItemMixin",
- "DamageEnchantmentMixin",
"EnchantmentHelperMixin",
"EnchantmentMixin",
"ExperienceOrbEntityMixin",