Skip to content

Commit fff2532

Browse files
committed
feat: add pacifist enchantment
- stops animals from attacking other animals
1 parent 63574a4 commit fff2532

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/main/java/com/github/alexthe668/domesticationinnovation/mixin/MobMixin.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import net.minecraft.world.entity.Mob;
1111
import net.minecraft.world.entity.ai.control.MoveControl;
1212
import net.minecraft.world.entity.ai.navigation.PathNavigation;
13+
import net.minecraft.world.entity.animal.Animal;
1314
import net.minecraft.world.entity.animal.axolotl.Axolotl;
1415
import net.minecraft.world.entity.item.ItemEntity;
1516
import net.minecraft.world.entity.player.Player;
@@ -21,6 +22,8 @@
2122
import org.spongepowered.asm.mixin.injection.Inject;
2223
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2324

25+
import javax.annotation.Nullable;
26+
2427
@Mixin(Mob.class)
2528
public abstract class MobMixin extends LivingEntity {
2629

@@ -98,4 +101,11 @@ private void di_playAmbientSound(CallbackInfo ci) {
98101
ci.cancel();
99102
}
100103
}
104+
105+
@Inject(method = "setTarget", at = @At(value = "HEAD"), cancellable = true)
106+
private void di_setTarget(@Nullable LivingEntity livingEntity, CallbackInfo ci) {
107+
if (TameableUtils.hasEnchant(this, DIEnchantmentRegistry.PACIFIST) && livingEntity instanceof Animal) {
108+
ci.cancel();
109+
}
110+
}
101111
}

src/main/java/com/github/alexthe668/domesticationinnovation/server/enchantment/DIEnchantmentRegistry.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public class DIEnchantmentRegistry {
4949
public static final PetEnchantment BLAZING_PROTECTION = new PetEnchantmentLootOnly("blazing_protection", Enchantment.Rarity.VERY_RARE, 3, 8);
5050
public static final PetEnchantment HEALING_AURA = new PetEnchantment("healing_aura", Enchantment.Rarity.RARE, 2, 12);
5151

52-
public static final PetEnchantment REJUVENATION = new PetEnchantment("rejuvenation", Enchantment.Rarity.UNCOMMON, 1, 6);
52+
public static final PetEnchantment REJUVENATION = new PetEnchantment("rejuvenation", Enchantment.Rarity.COMMON, 1, 1);
53+
public static final PetEnchantment PACIFIST = new PetEnchantment("pacifist", Enchantment.Rarity.UNCOMMON, 1, 4);
5354
public static final PetEnchantment UNDEAD_CURSE = new PetEnchantmentCurse("undead_curse", Enchantment.Rarity.VERY_RARE);
5455
public static final PetEnchantment INFAMY_CURSE = new PetEnchantmentCurse("infamy_curse", Enchantment.Rarity.VERY_RARE);
5556
public static final PetEnchantment BLIGHT_CURSE = new PetEnchantmentCurse("blight_curse", Enchantment.Rarity.VERY_RARE);

src/main/resources/assets/domesticationinnovation/lang/en_us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
"enchantment.domesticationinnovation.healing_aura.desc": "Pet will ocassionally heal owner and other pets around it, level determines strength of healing effect.",
115115
"enchantment.domesticationinnovation.rejuvenation": "Rejuvenation",
116116
"enchantment.domesticationinnovation.rejuvenation.desc": "When injured, pet may absorb experience orbs to heal itself.",
117+
"enchantment.domesticationinnovation.pacifist": "Pacifist",
118+
"enchantment.domesticationinnovation.pacifist.desc": "Pet will not attack other animals.",
117119
"domesticationinnovation.sound.subtitle.collar_tag": "equipped Collar Tag",
118120
"domesticationinnovation.sound.subtitle.magnet_loop": "Magnet buzzes",
119121
"domesticationinnovation.sound.subtitle.chain_lightning": "Lightning zaps",

0 commit comments

Comments
 (0)