diff --git a/src/main/java/dev/seano/sgp/mixin/FoxEntityMixin.java b/src/main/java/dev/seano/sgp/mixin/FoxEntityMixin.java new file mode 100644 index 0000000..8741a76 --- /dev/null +++ b/src/main/java/dev/seano/sgp/mixin/FoxEntityMixin.java @@ -0,0 +1,24 @@ +package dev.seano.sgp.mixin; + +import dev.seano.sgp.entity.ai.TargetGuineaPigGoal; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.passive.AnimalEntity; +import net.minecraft.entity.passive.FoxEntity; +import net.minecraft.world.World; +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.CallbackInfo; + +@Mixin(FoxEntity.class) +public abstract class FoxEntityMixin extends AnimalEntity { + + protected FoxEntityMixin(EntityType entityType, World world) { + super(entityType, world); + } + + @Inject(method = "initGoals", at = @At(value = "TAIL")) + private void initGoals(CallbackInfo ci) { + this.targetSelector.add(3, new TargetGuineaPigGoal(this)); + } +} diff --git a/src/main/kotlin/dev/seano/sgp/entity/GuineaPigEntity.kt b/src/main/kotlin/dev/seano/sgp/entity/GuineaPigEntity.kt index 2dde1d1..d095cc1 100644 --- a/src/main/kotlin/dev/seano/sgp/entity/GuineaPigEntity.kt +++ b/src/main/kotlin/dev/seano/sgp/entity/GuineaPigEntity.kt @@ -13,7 +13,6 @@ import net.minecraft.entity.data.DataTracker import net.minecraft.entity.data.TrackedData import net.minecraft.entity.data.TrackedDataHandlerRegistry import net.minecraft.entity.mob.CreeperEntity -import net.minecraft.entity.mob.MobEntity import net.minecraft.entity.passive.* import net.minecraft.entity.player.PlayerEntity import net.minecraft.item.ItemStack @@ -42,8 +41,7 @@ class GuineaPigEntity(entityType: EntityType?, world: World? fun createAttributes(): DefaultAttributeContainer.Builder { - return MobEntity.createMobAttributes() - .add(EntityAttributes.GENERIC_MAX_HEALTH, MAX_HEALTH) + return createMobAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, MAX_HEALTH) .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.2) } } @@ -64,6 +62,7 @@ class GuineaPigEntity(entityType: EntityType?, world: World? goalSelector.add(6, FleeEntityGoal(this, CreeperEntity::class.java, 6f, 1.0, 1.25)) goalSelector.add(6, FleeEntityGoal(this, OcelotEntity::class.java, 6f, 1.0, 1.25)) goalSelector.add(6, FleeEntityGoal(this, CatEntity::class.java, 6f, 1.0, 1.25)) + goalSelector.add(6, FleeEntityGoal(this, FoxEntity::class.java, 6f, 1.0, 1.25)) goalSelector.add(7, FollowOwnerGoal(this, 1.1, 10.0f, 4.0f)) goalSelector.add(8, WanderAroundFarGoal(this, 1.0)) goalSelector.add(9, LookAtEntityGoal(this, PlayerEntity::class.java, 6.0f)) @@ -253,7 +252,7 @@ class GuineaPigEntity(entityType: EntityType?, world: World? } else if (!other.isTamed) { false } else { - if (other.isInSittingPose) false else this.isInLove && other.isInLove() + if (other.isInSittingPose) false else this.isInLove && other.isInLove } } } diff --git a/src/main/resources/sgp.mixins.json b/src/main/resources/sgp.mixins.json index 9a81c4f..a3e073d 100644 --- a/src/main/resources/sgp.mixins.json +++ b/src/main/resources/sgp.mixins.json @@ -4,6 +4,7 @@ "compatibilityLevel": "JAVA_21", "mixins": [ "CatEntityMixin", + "FoxEntityMixin", "OcelotEntityMixin" ], "injectors": {