diff --git a/src/main/java/chronosacaria/mcdw/api/interfaces/IMcdwEnchantedArrow.java b/src/main/java/chronosacaria/mcdw/api/interfaces/IMcdwEnchantedArrow.java index 986b9d47..f361bab3 100644 --- a/src/main/java/chronosacaria/mcdw/api/interfaces/IMcdwEnchantedArrow.java +++ b/src/main/java/chronosacaria/mcdw/api/interfaces/IMcdwEnchantedArrow.java @@ -20,6 +20,9 @@ public interface IMcdwEnchantedArrow { int mcdw$getEnigmaResonatorLevel(); void mcdw$setEnigmaResonatorLevel(int enigmaResonatorLevel); + int mcdw$getFreezingLevel(); + void mcdw$setFreezingLevel(int freezingLevel); + int mcdw$getFuseShotLevel(); void mcdw$setFuseShotLevel(int fuseShotLevel); diff --git a/src/main/java/chronosacaria/mcdw/api/util/CleanlinessHelper.java b/src/main/java/chronosacaria/mcdw/api/util/CleanlinessHelper.java index f4ba8d9b..7088075d 100644 --- a/src/main/java/chronosacaria/mcdw/api/util/CleanlinessHelper.java +++ b/src/main/java/chronosacaria/mcdw/api/util/CleanlinessHelper.java @@ -1,10 +1,13 @@ package chronosacaria.mcdw.api.util; +import chronosacaria.mcdw.api.interfaces.IMcdwEnchantedArrow; import chronosacaria.mcdw.api.interfaces.IOffhandAttack; import chronosacaria.mcdw.bases.McdwLongbow; import chronosacaria.mcdw.bases.McdwShortbow; import chronosacaria.mcdw.configs.CompatibilityFlags; +import chronosacaria.mcdw.registries.EnchantsRegistry; import net.minecraft.client.resource.language.I18n; +import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.item.Item; @@ -99,4 +102,87 @@ public static void playCenteredSound (LivingEntity center, SoundEvent soundEvent } } + + public static void addPPEEnchantments(ItemStack itemStack, IMcdwEnchantedArrow ppe) { + int chainReactionLevel = EnchantmentHelper.getLevel(EnchantsRegistry.CHAIN_REACTION, itemStack); + if (chainReactionLevel > 0) { + ppe.mcdw$setChainReactionLevel(chainReactionLevel); + } + int chargeLevel = EnchantmentHelper.getLevel(EnchantsRegistry.CHARGE, itemStack); + if (chargeLevel > 0) { + ppe.mcdw$setChargeLevel(chargeLevel); + } + int cobwebShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.COBWEB_SHOT, itemStack); + if (cobwebShotLevel > 0) { + ppe.mcdw$setCobwebShotLevel(cobwebShotLevel); + } + int dynamoLevel = EnchantmentHelper.getLevel(EnchantsRegistry.DYNAMO, itemStack); + if (dynamoLevel > 0) { + ppe.mcdw$setDynamoLevel(dynamoLevel); + } + int enigmaResonatorLevel = EnchantmentHelper.getLevel(EnchantsRegistry.ENIGMA_RESONATOR, itemStack); + if (enigmaResonatorLevel > 0) { + ppe.mcdw$setEnigmaResonatorLevel(enigmaResonatorLevel); + } + int fuseShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.FUSE_SHOT, itemStack); + if (fuseShotLevel > 0) { + ppe.mcdw$setFuseShotLevel(fuseShotLevel); + } + int freezingLevel = EnchantmentHelper.getLevel(EnchantsRegistry.FREEZING, itemStack); + if (freezingLevel > 0) { + ppe.mcdw$setFreezingLevel(freezingLevel); + } + int gravityLevel = EnchantmentHelper.getLevel(EnchantsRegistry.GRAVITY, itemStack); + if (gravityLevel > 0) { + ppe.mcdw$setGravityLevel(gravityLevel); + } + int growingLevel = EnchantmentHelper.getLevel(EnchantsRegistry.GROWING, itemStack); + if (growingLevel > 0) { + ppe.mcdw$setGrowingLevel(growingLevel); + } + int levitationShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.LEVITATION_SHOT, itemStack); + if (levitationShotLevel > 0) { + ppe.mcdw$setLevitationShotLevel(levitationShotLevel); + } + int phantomsMarkLevel = EnchantmentHelper.getLevel(EnchantsRegistry.PHANTOMS_MARK, itemStack); + if (phantomsMarkLevel > 0) { + ppe.mcdw$setPhantomsMarkLevel(phantomsMarkLevel); + } + int poisonCloudLevel = EnchantmentHelper.getLevel(EnchantsRegistry.POISON_CLOUD, itemStack); + if (poisonCloudLevel > 0) { + ppe.mcdw$setPoisonCloudLevel(poisonCloudLevel); + } + int radianceLevel = EnchantmentHelper.getLevel(EnchantsRegistry.RADIANCE, itemStack); + if (radianceLevel > 0) { + ppe.mcdw$setRadianceLevel(radianceLevel); + } + int replenishLevel = EnchantmentHelper.getLevel(EnchantsRegistry.REPLENISH, itemStack); + if (replenishLevel > 0) { + ppe.mcdw$setReplenishLevel(replenishLevel); + } + int ricochetLevel = EnchantmentHelper.getLevel(EnchantsRegistry.RICOCHET, itemStack); + if (ricochetLevel > 0) { + ppe.mcdw$setRicochetLevel(ricochetLevel); + } + int shadowShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.SHADOW_SHOT, itemStack); + if (shadowShotLevel > 0) { + ppe.mcdw$setShadowShotLevel(shadowShotLevel); + } + int tempoTheftLevel = EnchantmentHelper.getLevel(EnchantsRegistry.TEMPO_THEFT, itemStack); + if (tempoTheftLevel > 0) { + ppe.mcdw$setTempoTheftLevel(tempoTheftLevel); + } + int thunderingLevel = EnchantmentHelper.getLevel(EnchantsRegistry.THUNDERING, itemStack); + if (thunderingLevel > 0) { + ppe.mcdw$setThunderingLevel(thunderingLevel); + } + int voidShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.VOID_SHOT, itemStack); + if (voidShotLevel > 0) { + ppe.mcdw$setVoidShotLevel(voidShotLevel); + } + int wildRageLevel = EnchantmentHelper.getLevel(EnchantsRegistry.WILD_RAGE, itemStack); + if (wildRageLevel > 0){ + ppe.mcdw$setWildRageLevel(wildRageLevel); + } + } } diff --git a/src/main/java/chronosacaria/mcdw/effects/EnchantmentEffects.java b/src/main/java/chronosacaria/mcdw/effects/EnchantmentEffects.java index 123ad78b..f99d97ff 100644 --- a/src/main/java/chronosacaria/mcdw/effects/EnchantmentEffects.java +++ b/src/main/java/chronosacaria/mcdw/effects/EnchantmentEffects.java @@ -708,6 +708,16 @@ public static void applyFuseShot(LivingEntity shooter, LivingEntity target, Pers } } + public static void applyFreezingShot(LivingEntity target, PersistentProjectileEntity ppe) { + int freezingLevel = ((IMcdwEnchantedArrow) ppe).mcdw$getFreezingLevel(); + if (freezingLevel > 0) { + + if (CleanlinessHelper.percentToOccur(CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(EnchantmentsID.FREEZING).mcdw$getProcChance() + (10 * freezingLevel))) { + AbilityHelper.causeFreezing(target, 100); + } + } + } + public static void applyGravityShot(LivingEntity shooter, LivingEntity target, PersistentProjectileEntity ppe) { int gravityLevel = ((IMcdwEnchantedArrow) ppe).mcdw$getGravityLevel(); if (gravityLevel > 0) { diff --git a/src/main/java/chronosacaria/mcdw/mixin/mcdw/BowItemMixin.java b/src/main/java/chronosacaria/mcdw/mixin/mcdw/BowItemMixin.java index b7d5dcf9..1c561795 100644 --- a/src/main/java/chronosacaria/mcdw/mixin/mcdw/BowItemMixin.java +++ b/src/main/java/chronosacaria/mcdw/mixin/mcdw/BowItemMixin.java @@ -2,6 +2,7 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IMcdwEnchantedArrow; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.api.util.ProjectileEffectHelper; import chronosacaria.mcdw.api.util.RangedAttackHelper; import chronosacaria.mcdw.bases.McdwBow; @@ -85,79 +86,7 @@ public void setLivingEntity(LivingEntity livingEntity){ if (overcharge > 0) { ((IMcdwEnchantedArrow)ppe).mcdw$setOvercharge(overcharge); } - - int chainReactionLevel = EnchantmentHelper.getLevel(EnchantsRegistry.CHAIN_REACTION, stack); - if (chainReactionLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setChainReactionLevel(chainReactionLevel); - } - int chargeLevel = EnchantmentHelper.getLevel(EnchantsRegistry.CHARGE, stack); - if (chargeLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setChargeLevel(chargeLevel); - } - int cobwebShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.COBWEB_SHOT, stack); - if (cobwebShotLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setCobwebShotLevel(cobwebShotLevel); - } - int dynamoLevel = EnchantmentHelper.getLevel(EnchantsRegistry.DYNAMO, stack); - if (dynamoLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setDynamoLevel(dynamoLevel); - } - int enigmaResonatorLevel = EnchantmentHelper.getLevel(EnchantsRegistry.ENIGMA_RESONATOR, stack); - if (enigmaResonatorLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setEnigmaResonatorLevel(enigmaResonatorLevel); - } - int fuseShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.FUSE_SHOT, stack); - if (fuseShotLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setFuseShotLevel(fuseShotLevel); - } - int gravityLevel = EnchantmentHelper.getLevel(EnchantsRegistry.GRAVITY, stack); - if (gravityLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setGravityLevel(gravityLevel); - } - int growingLevel = EnchantmentHelper.getLevel(EnchantsRegistry.GROWING, stack); - if (growingLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setGrowingLevel(growingLevel); - } - int levitationShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.LEVITATION_SHOT, stack); - if (levitationShotLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setLevitationShotLevel(levitationShotLevel); - } - int phantomsMarkLevel = EnchantmentHelper.getLevel(EnchantsRegistry.PHANTOMS_MARK, stack); - if (phantomsMarkLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setPhantomsMarkLevel(phantomsMarkLevel); - } - int poisonCloudLevel = EnchantmentHelper.getLevel(EnchantsRegistry.POISON_CLOUD, stack); - if (poisonCloudLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setPoisonCloudLevel(poisonCloudLevel); - } - int radianceLevel = EnchantmentHelper.getLevel(EnchantsRegistry.RADIANCE, stack); - if (radianceLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setRadianceLevel(radianceLevel); - } - int replenishLevel = EnchantmentHelper.getLevel(EnchantsRegistry.REPLENISH, stack); - if (replenishLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setReplenishLevel(replenishLevel); - } - int ricochetLevel = EnchantmentHelper.getLevel(EnchantsRegistry.RICOCHET, stack); - if (ricochetLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setRicochetLevel(ricochetLevel); - } - int tempoTheftLevel = EnchantmentHelper.getLevel(EnchantsRegistry.TEMPO_THEFT, stack); - if (tempoTheftLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setTempoTheftLevel(tempoTheftLevel); - } - //int thunderingLevel = EnchantmentHelper.getLevel(EnchantsRegistry.THUNDERING, stack); - //if (thunderingLevel > 0) { - // ((IMcdwEnchantedArrow)ppe).mcdw$setThunderingLevel(thunderingLevel); - //} - int voidShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.VOID_SHOT, stack); - if (voidShotLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setVoidShotLevel(voidShotLevel); - } - int wildRageLevel = EnchantmentHelper.getLevel(EnchantsRegistry.WILD_RAGE, stack); - if (wildRageLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setWildRageLevel(wildRageLevel); - } + CleanlinessHelper.addPPEEnchantments(stack, (IMcdwEnchantedArrow) ppe); } @Inject(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/BowItem;getMaxUseTime(Lnet/minecraft/item/ItemStack;)I")) diff --git a/src/main/java/chronosacaria/mcdw/mixin/mcdw/CrossbowItemMixin.java b/src/main/java/chronosacaria/mcdw/mixin/mcdw/CrossbowItemMixin.java index ae4e6798..0fefc958 100644 --- a/src/main/java/chronosacaria/mcdw/mixin/mcdw/CrossbowItemMixin.java +++ b/src/main/java/chronosacaria/mcdw/mixin/mcdw/CrossbowItemMixin.java @@ -2,6 +2,7 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IMcdwEnchantedArrow; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.api.util.ProjectileEffectHelper; import chronosacaria.mcdw.api.util.RangedAttackHelper; import chronosacaria.mcdw.bases.McdwCrossbow; @@ -46,86 +47,11 @@ public class CrossbowItemMixin { CallbackInfoReturnable cir, ArrowItem arrowItem, PersistentProjectileEntity ppe){ if (CrossbowItem.isCharged(crossbow)) { - - int chainReactionLevel = EnchantmentHelper.getLevel(EnchantsRegistry.CHAIN_REACTION, crossbow); - if (chainReactionLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setChainReactionLevel(chainReactionLevel); - } - int chargeLevel = EnchantmentHelper.getLevel(EnchantsRegistry.CHARGE, crossbow); - if (chargeLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setChargeLevel(chargeLevel); - } - int cobwebShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.COBWEB_SHOT, crossbow); - if (cobwebShotLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setCobwebShotLevel(cobwebShotLevel); - } - int dynamoLevel = EnchantmentHelper.getLevel(EnchantsRegistry.DYNAMO, crossbow); - if (dynamoLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setDynamoLevel(dynamoLevel); - } - int enigmaResonatorLevel = EnchantmentHelper.getLevel(EnchantsRegistry.ENIGMA_RESONATOR, crossbow); - if (enigmaResonatorLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setEnigmaResonatorLevel(enigmaResonatorLevel); - } - int fuseShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.FUSE_SHOT, crossbow); - if (fuseShotLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setFuseShotLevel(fuseShotLevel); - } - int gravityLevel = EnchantmentHelper.getLevel(EnchantsRegistry.GRAVITY, crossbow); - if (gravityLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setGravityLevel(gravityLevel); - } - int growingLevel = EnchantmentHelper.getLevel(EnchantsRegistry.GROWING, crossbow); - if (growingLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setGrowingLevel(growingLevel); - } - int levitationShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.LEVITATION_SHOT, crossbow); - if (levitationShotLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setLevitationShotLevel(levitationShotLevel); - } + CleanlinessHelper.addPPEEnchantments(crossbow, (IMcdwEnchantedArrow) ppe); // For Drag in Water for Nautilus Crossbow ((IMcdwEnchantedArrow)ppe).mcdw$setNautilusBoolean(crossbow.isOf(ItemsRegistry.CROSSBOW_ITEMS.get(CrossbowsID.CROSSBOW_NAUTICAL_CROSSBOW))); - int phantomsMarkLevel = EnchantmentHelper.getLevel(EnchantsRegistry.PHANTOMS_MARK, crossbow); - if (phantomsMarkLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setPhantomsMarkLevel(phantomsMarkLevel); - } - int poisonCloudLevel = EnchantmentHelper.getLevel(EnchantsRegistry.POISON_CLOUD, crossbow); - if (poisonCloudLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setPoisonCloudLevel(poisonCloudLevel); - } - int radianceLevel = EnchantmentHelper.getLevel(EnchantsRegistry.RADIANCE, crossbow); - if (radianceLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setRadianceLevel(radianceLevel); - } - int replenishLevel = EnchantmentHelper.getLevel(EnchantsRegistry.REPLENISH, crossbow); - if (replenishLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setReplenishLevel(replenishLevel); - } - int ricochetLevel = EnchantmentHelper.getLevel(EnchantsRegistry.RICOCHET, crossbow); - if (ricochetLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setRicochetLevel(ricochetLevel); - } ((IMcdwEnchantedArrow)ppe).mcdw$setShadowBarbBoolean(crossbow.isOf(ItemsRegistry.CROSSBOW_ITEMS.get(CrossbowsID.CROSSBOW_VEILED_CROSSBOW))); - int shadowShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.SHADOW_SHOT, crossbow); - if (shadowShotLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setShadowShotLevel(shadowShotLevel); - } - int tempoTheftLevel = EnchantmentHelper.getLevel(EnchantsRegistry.TEMPO_THEFT, crossbow); - if (tempoTheftLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setTempoTheftLevel(tempoTheftLevel); - } - int thunderingLevel = EnchantmentHelper.getLevel(EnchantsRegistry.THUNDERING, crossbow); - if (thunderingLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setThunderingLevel(thunderingLevel); - } - int voidShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.VOID_SHOT, crossbow); - if (voidShotLevel > 0) { - ((IMcdwEnchantedArrow)ppe).mcdw$setVoidShotLevel(voidShotLevel); - } - int wildRageLevel = EnchantmentHelper.getLevel(EnchantsRegistry.WILD_RAGE, crossbow); - if (wildRageLevel > 0){ - ((IMcdwEnchantedArrow)ppe).mcdw$setWildRageLevel(wildRageLevel); - } + if (Mcdw.CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(EnchantmentsID.BONUS_SHOT).mcdw$getIsEnabled()) { int bonusShotLevel = EnchantmentHelper.getLevel(EnchantsRegistry.BONUS_SHOT, crossbow); @@ -139,7 +65,8 @@ public class CrossbowItemMixin { } } } - + + @Inject(method = "onStoppedUsing", at = @At(value = "HEAD")) private void mcdw$livingEntityGetter(ItemStack stack, World world, LivingEntity user, int remainingUseTicks, CallbackInfo ci) { this.mcdw$setLivingEntity(user); diff --git a/src/main/java/chronosacaria/mcdw/mixin/mcdw/LivingEntityMixin.java b/src/main/java/chronosacaria/mcdw/mixin/mcdw/LivingEntityMixin.java index 574582c4..57796552 100644 --- a/src/main/java/chronosacaria/mcdw/mixin/mcdw/LivingEntityMixin.java +++ b/src/main/java/chronosacaria/mcdw/mixin/mcdw/LivingEntityMixin.java @@ -28,6 +28,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.item.PotionItem; import net.minecraft.potion.PotionUtil; import net.minecraft.potion.Potions; import net.minecraft.server.network.ServerPlayerEntity; @@ -47,6 +48,7 @@ @SuppressWarnings("ConstantValue") @Mixin(LivingEntity.class) public abstract class LivingEntityMixin extends Entity { + @Unique public final EntityType mcdw$summoned_bee = SummonedEntityRegistry.SUMMONED_BEE_ENTITY; @@ -162,10 +164,18 @@ public LivingEntityMixin(EntityType type, World world) { ItemStack poisonTippedArrow = PotionUtil.setPotion(new ItemStack(Items.TIPPED_ARROW, 8), Potions.POISON); if (Mcdw.CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(EnchantmentsID.DIPPING_POISON).mcdw$getIsEnabled()) { - if (user.getOffHandStack() != null && (EnchantmentHelper.getLevel(EnchantsRegistry.DIPPING_POISON, user.getOffHandStack()) > 0)) { + if (!(user.getMainHandStack().getItem() instanceof PotionItem)) + return; + + if (user.getOffHandStack() != null + && (EnchantmentHelper.getLevel(EnchantsRegistry.DIPPING_POISON, user.getOffHandStack()) > 0) + ) { int level = EnchantmentHelper.getLevel(EnchantsRegistry.DIPPING_POISON, user.getOffHandStack()); if (level > 0) { List potionEffects = PotionUtil.getPotionEffects(user.getMainHandStack()); + if (!(potionEffects.get(0).getEffectType() == StatusEffects.INSTANT_HEALTH)) { + return; + } if (potionEffects.get(0).getEffectType() == StatusEffects.INSTANT_HEALTH) { CleanlinessHelper.mcdw$dropItem(user, poisonTippedArrow); } diff --git a/src/main/java/chronosacaria/mcdw/mixin/mcdw/LivingEntityPlayerEntityMixin.java b/src/main/java/chronosacaria/mcdw/mixin/mcdw/LivingEntityPlayerEntityMixin.java index 0da98efe..3a8e8f38 100644 --- a/src/main/java/chronosacaria/mcdw/mixin/mcdw/LivingEntityPlayerEntityMixin.java +++ b/src/main/java/chronosacaria/mcdw/mixin/mcdw/LivingEntityPlayerEntityMixin.java @@ -10,6 +10,8 @@ import net.minecraft.entity.damage.DamageTypes; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.PersistentProjectileEntity; +import net.minecraft.item.BowItem; +import net.minecraft.item.CrossbowItem; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -87,7 +89,10 @@ public class LivingEntityPlayerEntityMixin { if (amount > 0) { - if (source.getSource() instanceof LivingEntity) { + if (source.getSource() instanceof LivingEntity sourceEntity + && !(sourceEntity.getMainHandStack().getItem() instanceof BowItem + || sourceEntity.getMainHandStack().getItem() instanceof CrossbowItem) + ) { if (Mcdw.CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(EnchantmentsID.FREEZING).mcdw$getIsEnabled()) EnchantmentEffects.applyFreezing(attackingEntity, victim, isOffHandAttack); @@ -129,7 +134,10 @@ public class LivingEntityPlayerEntityMixin { if (amount > 0) { - if (source.getSource() instanceof LivingEntity) { + if (source.getSource() instanceof LivingEntity sourceEntity + && !(sourceEntity.getMainHandStack().getItem() instanceof BowItem + || sourceEntity.getMainHandStack().getItem() instanceof CrossbowItem) + ) { if (Mcdw.CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(EnchantmentsID.ECHO).mcdw$getIsEnabled()) EnchantmentEffects.echoDamage(attackingEntity, victim, amount, isOffHandAttack); } @@ -143,7 +151,10 @@ public class LivingEntityPlayerEntityMixin { LivingEntity victim = (LivingEntity) (Object) this; - if (source.getSource() instanceof LivingEntity) { + if (source.getSource() instanceof LivingEntity sourceEntity + && !(sourceEntity.getMainHandStack().getItem() instanceof BowItem + || sourceEntity.getMainHandStack().getItem() instanceof CrossbowItem) + ) { if (Mcdw.CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(EnchantmentsID.EXPLODING).mcdw$getIsEnabled()) EnchantmentEffects.explodingDamage(attackingEntity, victim, isOffHandAttack); if (Mcdw.CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(EnchantmentsID.RAMPAGING).mcdw$getIsEnabled()) diff --git a/src/main/java/chronosacaria/mcdw/mixin/mcdw/PersistentProjectileEntityMixin.java b/src/main/java/chronosacaria/mcdw/mixin/mcdw/PersistentProjectileEntityMixin.java index bb2504fe..32c1e257 100644 --- a/src/main/java/chronosacaria/mcdw/mixin/mcdw/PersistentProjectileEntityMixin.java +++ b/src/main/java/chronosacaria/mcdw/mixin/mcdw/PersistentProjectileEntityMixin.java @@ -38,6 +38,8 @@ public abstract class PersistentProjectileEntityMixin implements IMcdwEnchantedA @Unique private int fuseShotLevel = 0; @Unique + private int freezingLevel = 0; + @Unique private int gravityLevel = 0; @Unique private int growingLevel = 0; @@ -134,6 +136,16 @@ public abstract class PersistentProjectileEntityMixin implements IMcdwEnchantedA this.fuseShotLevel = fuseShotLevel; } + @Override + public int mcdw$getFreezingLevel() { + return freezingLevel; + } + + @Override + public void mcdw$setFreezingLevel(int freezingLevel) { + this.freezingLevel = freezingLevel; + } + @Override public int mcdw$getGravityLevel() { return gravityLevel; @@ -279,6 +291,7 @@ public abstract class PersistentProjectileEntityMixin implements IMcdwEnchantedA tag.putInt("cobwebShotLevel", cobwebShotLevel); tag.putInt("enigmaResonatorLevel", enigmaResonatorLevel); tag.putInt("fuseShotLevel", fuseShotLevel); + tag.putInt("freezingLevel", freezingLevel); tag.putInt("gravityLevel", gravityLevel); tag.putInt("growingLevel", growingLevel); tag.putInt("levitationShotLevel", levitationShotLevel); @@ -303,6 +316,7 @@ public abstract class PersistentProjectileEntityMixin implements IMcdwEnchantedA this.cobwebShotLevel = tag.getInt("cobwebShotLevel"); this.enigmaResonatorLevel = tag.getInt("enigmaResonatorLevel"); this.fuseShotLevel = tag.getInt("fuseShotLevel"); + this.freezingLevel = tag.getInt("freezingLevel"); this.gravityLevel = tag.getInt("gravityLevel"); this.growingLevel = tag.getInt("growingLevel"); this.levitationShotLevel = tag.getInt("levitationLevel"); @@ -336,6 +350,8 @@ public abstract class PersistentProjectileEntityMixin implements IMcdwEnchantedA EnchantmentEffects.applyCobwebShotEntity(target, persProjEntity); if (Mcdw.CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(EnchantmentsID.FUSE_SHOT).mcdw$getIsEnabled()) EnchantmentEffects.applyFuseShot(shooter, target, persProjEntity); + if (Mcdw.CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(EnchantmentsID.FREEZING).mcdw$getIsEnabled()) + EnchantmentEffects.applyFreezingShot(target, persProjEntity); if (Mcdw.CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(EnchantmentsID.GRAVITY).mcdw$getIsEnabled()) EnchantmentEffects.applyGravityShot(shooter, target, persProjEntity); if (Mcdw.CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(EnchantmentsID.LEVITATION_SHOT).mcdw$getIsEnabled()) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2b66f061..ebbfa7f6 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -34,7 +34,7 @@ "depends": { "fabricloader": ">=0.14.21", "fabric": "*", - "minecraft": ">=1.20.0", + "minecraft": ">=1.20.0 <=1.20.1", "cloth-config2": ">=11.0.0.1" } }