From 969efcc035aa1f16e6332c4f1ed8b72867d2413b Mon Sep 17 00:00:00 2001 From: Crim Date: Sun, 13 Oct 2024 15:10:57 +0800 Subject: [PATCH 1/4] Komodo Fix --- .../data/alexsmobs/tags/items/komodo_dragon_tameables.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/resources/data/alexsmobs/tags/items/komodo_dragon_tameables.json b/src/main/resources/data/alexsmobs/tags/items/komodo_dragon_tameables.json index 5e8aecc98..d73d41ac6 100644 --- a/src/main/resources/data/alexsmobs/tags/items/komodo_dragon_tameables.json +++ b/src/main/resources/data/alexsmobs/tags/items/komodo_dragon_tameables.json @@ -1,4 +1,6 @@ { "replace": false, - "values": [] + "values": [ + "minecraft:rotten_flesh" + ] } \ No newline at end of file From 88ecd9982f2473902bc0b7937f628d23936fdcbf Mon Sep 17 00:00:00 2001 From: Crim Date: Mon, 11 Nov 2024 04:46:09 +0800 Subject: [PATCH 2/4] unique behaviors to vanilla mobs fix --- build.gradle | 7 ++- .../alexsmobs/entity/EntityCentipedeHead.java | 2 +- .../alexsmobs/entity/EntityGorilla.java | 3 +- .../alexsmobs/entity/EntityRattlesnake.java | 60 +++++++++++-------- .../alexsmobs/event/ServerEvents.java | 32 ---------- .../alexthe666/alexsmobs/mixins/CatMixin.java | 40 +++++++++++++ .../alexsmobs/mixins/CreeperMixin.java | 39 ++++++++++++ .../alexsmobs/mixins/DolphinMixin.java | 35 +++++++++++ .../alexthe666/alexsmobs/mixins/FoxMixin.java | 34 +++++++++++ .../alexsmobs/mixins/OcelotMixin.java | 34 +++++++++++ .../alexsmobs/mixins/PolarBearMixin.java | 37 ++++++++++++ .../alexsmobs/mixins/RabbitMixin.java | 36 +++++++++++ .../alexsmobs/mixins/SpiderMixin.java | 36 +++++++++++ .../alexsmobs/mixins/WolfMixin.java | 36 +++++++++++ src/main/resources/alexsmobs.mixins.json | 23 +++++++ 15 files changed, 392 insertions(+), 62 deletions(-) create mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/CatMixin.java create mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/CreeperMixin.java create mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/DolphinMixin.java create mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/FoxMixin.java create mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/OcelotMixin.java create mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/PolarBearMixin.java create mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/RabbitMixin.java create mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/SpiderMixin.java create mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/WolfMixin.java create mode 100644 src/main/resources/alexsmobs.mixins.json diff --git a/build.gradle b/build.gradle index 3e7b71083..1a9d56e00 100644 --- a/build.gradle +++ b/build.gradle @@ -99,6 +99,7 @@ minecraft { } } } +apply plugin: 'org.spongepowered.mixin' // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } @@ -114,8 +115,10 @@ dependencies { mixin { - add sourceSets.main, "citadel.refmap.json" - config 'citadel.mixins.json' + + add sourceSets.main, "alexsmobs.refmap.json" + + config "alexsmobs.mixins.json" } // Example for how to get properties into the manifest for reading by the runtime.. diff --git a/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityCentipedeHead.java b/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityCentipedeHead.java index 312a7e3ad..6c4db7cc1 100644 --- a/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityCentipedeHead.java +++ b/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityCentipedeHead.java @@ -170,7 +170,7 @@ public void pushEntities() { @Nullable public SpawnGroupData finalizeSpawn(ServerLevelAccessor worldIn, DifficultyInstance difficultyIn, MobSpawnType reason, @Nullable SpawnGroupData spawnDataIn, @Nullable CompoundTag dataTag) { - this.setSegmentCount(random.nextInt(4) + 5); + this.setSegmentCount(random.nextInt(4) + 100); return super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); } diff --git a/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityGorilla.java b/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityGorilla.java index 48f3c998c..113963118 100644 --- a/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityGorilla.java +++ b/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityGorilla.java @@ -147,8 +147,7 @@ protected void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(0, new FloatGoal(this)); this.goalSelector.addGoal(1, new SitWhenOrderedToGoal(this)); - this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 1.2D, true)); - this.goalSelector.addGoal(2, new GorillaAIFollowCaravan(this, 0.8D)); + this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 1.2D, false)); this.goalSelector.addGoal(3, new GorillaAIChargeLooker(this, 1.6D)); this.goalSelector.addGoal(4, new TameableAITempt(this, 1.1D, Ingredient.of(AMTagRegistry.GORILLA_TAMEABLES), false)); this.goalSelector.addGoal(4, new AnimalAIRideParent(this, 1.25D)); diff --git a/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityRattlesnake.java b/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityRattlesnake.java index 681cce10f..a62724a23 100644 --- a/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityRattlesnake.java +++ b/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityRattlesnake.java @@ -34,6 +34,7 @@ import net.minecraft.world.phys.Vec3; import javax.annotation.Nullable; +import java.util.Iterator; import java.util.List; import java.util.function.Predicate; @@ -62,7 +63,7 @@ protected EntityRattlesnake(EntityType type, Level worldIn) { protected void registerGoals() { this.goalSelector.addGoal(0, new FloatGoal(this)); - this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.2D, true)); + this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.2D, false)); this.goalSelector.addGoal(2, new WarnPredatorsGoal()); this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D)); this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1D)); @@ -242,45 +243,54 @@ public static boolean canRattlesnakeSpawn(EntityType animal, L class WarnPredatorsGoal extends Goal { int executionChance = 20; - Entity target = null; + LivingEntity target = null; + + private static final Predicate WARNABLE_PREDICATE = (mob) -> { + return mob instanceof Player && !((Player) mob).isCreative() && !mob.isSpectator() || mob instanceof EntityRoadrunner || mob instanceof EntityRattlesnake; + }; + + public WarnPredatorsGoal() { + } - @Override public boolean canUse() { - if(EntityRattlesnake.this.getRandom().nextInt(executionChance) == 0){ - final double dist = 5D; - List list = EntityRattlesnake.this.level().getEntitiesOfClass(LivingEntity.class, EntityRattlesnake.this.getBoundingBox().inflate(dist, dist, dist), WARNABLE_PREDICATE); - double d0 = Double.MAX_VALUE; - Entity possibleTarget = null; - for(Entity entity : list) { - double d1 = EntityRattlesnake.this.distanceToSqr(entity); - if (!(d1 > d0)) { - d0 = d1; - possibleTarget = entity; - } + List list = EntityRattlesnake.this.level().getEntitiesOfClass(LivingEntity.class, EntityRattlesnake.this.getBoundingBox().inflate(5.0, 5.0, 5.0), WARNABLE_PREDICATE); + double d0 = Double.MAX_VALUE; + Entity possibleTarget = null; + Iterator var7 = list.iterator(); + + while(var7.hasNext()) { + + Entity entity = var7.next(); + double d1 = EntityRattlesnake.this.distanceToSqr(entity); + if (!(d1 > d0) && entity != EntityRattlesnake.this) { + d0 = d1; + possibleTarget = entity; } - target = possibleTarget; - return !list.isEmpty(); + } - return false; + + this.target = (LivingEntity) possibleTarget; + return !list.isEmpty(); + } - @Override - public boolean canContinueToUse(){ - return target != null && EntityRattlesnake.this.distanceTo(target) < 5D && EntityRattlesnake.this.getTarget() == null; + public boolean canContinueToUse() { + return this.target != null && (double)EntityRattlesnake.this.distanceTo(this.target) < 5.0 && EntityRattlesnake.this.getTarget() == null; } - @Override public void stop() { - target = null; + this.target = null; EntityRattlesnake.this.setRattling(false); } - @Override - public void tick(){ + public void tick() { + System.out.println("its working"); EntityRattlesnake.this.setRattling(true); EntityRattlesnake.this.setCurled(true); EntityRattlesnake.this.curlTime = 0; - EntityRattlesnake.this.getLookControl().setLookAt(target, 30, 30); + if (target != null){ + EntityRattlesnake.this.getLookControl().setLookAt(this.target, 30.0F, 30.0F); + } } } diff --git a/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java b/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java index a3043870a..ee39dcc96 100644 --- a/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java +++ b/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java @@ -506,38 +506,6 @@ public void onEntityFinalizeSpawn(MobSpawnEvent.FinalizeSpawn event) { } } } - try { - if (AMConfig.spidersAttackFlies && entity instanceof final Spider spider) { - spider.targetSelector.addGoal(4, - new NearestAttackableTargetGoal<>(spider, EntityFly.class, 1, true, false, null)); - } - else if (AMConfig.wolvesAttackMoose && entity instanceof final Wolf wolf) { - wolf.targetSelector.addGoal(6, new NonTameRandomTargetGoal<>(wolf, EntityMoose.class, false, null)); - } - else if (AMConfig.polarBearsAttackSeals && entity instanceof final PolarBear bear) { - bear.targetSelector.addGoal(6, - new NearestAttackableTargetGoal<>(bear, EntitySeal.class, 15, true, true, null)); - } - else if (entity instanceof final Creeper creeper) { - creeper.targetSelector.addGoal(3, new AvoidEntityGoal<>(creeper, EntitySnowLeopard.class, 6.0F, 1.0D, 1.2D)); - creeper.targetSelector.addGoal(3, new AvoidEntityGoal<>(creeper, EntityTiger.class, 6.0F, 1.0D, 1.2D)); - } - else if (AMConfig.catsAndFoxesAttackJerboas - && (entity instanceof Fox || entity instanceof Cat || entity instanceof Ocelot)) { - Mob mb = (Mob) entity; - mb.targetSelector.addGoal(6, - new NearestAttackableTargetGoal<>(mb, EntityJerboa.class, 45, true, true, null)); - } - else if (AMConfig.bunfungusTransformation && entity instanceof final Rabbit rabbit) { - rabbit.goalSelector.addGoal(3, new TemptGoal(rabbit, 1.0D, Ingredient.of(AMItemRegistry.MUNGAL_SPORES.get()), false)); - } - else if (AMConfig.dolphinsAttackFlyingFish && entity instanceof final Dolphin dolphin) { - dolphin.targetSelector.addGoal(2, - new NearestAttackableTargetGoal<>(dolphin, EntityFlyingFish.class, 70, true, true, null)); - } - } catch (Exception e) { - AlexsMobs.LOGGER.warn("Tried to add unique behaviors to vanilla mobs and encountered an error"); - } } @SubscribeEvent diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/CatMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/CatMixin.java new file mode 100644 index 000000000..06721a514 --- /dev/null +++ b/src/main/java/com/github/alexthe666/alexsmobs/mixins/CatMixin.java @@ -0,0 +1,40 @@ +package com.github.alexthe666.alexsmobs.mixins; + + +import com.github.alexthe666.alexsmobs.config.AMConfig; +import com.github.alexthe666.alexsmobs.entity.EntityJerboa; +import com.github.alexthe666.alexsmobs.entity.EntitySnowLeopard; +import com.github.alexthe666.alexsmobs.entity.EntityTiger; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.ai.goal.AvoidEntityGoal; +import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; +import net.minecraft.world.entity.animal.Cat; +import net.minecraft.world.entity.animal.Fox; +import net.minecraft.world.entity.animal.Ocelot; +import net.minecraft.world.entity.monster.Creeper; +import net.minecraft.world.entity.monster.Monster; +import net.minecraft.world.level.Level; +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(Cat.class) +public abstract class CatMixin extends TamableAnimal { + + + protected CatMixin(EntityType p_21803_, Level p_21804_) { + super(p_21803_, p_21804_); + } + + @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) + protected void registerGoals(CallbackInfo ci) { + if (AMConfig.catsAndFoxesAttackJerboas) { + this.targetSelector.addGoal(6, new NearestAttackableTargetGoal<>(this, EntityJerboa.class, 45, true, true, null)); + } + } + +} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/CreeperMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/CreeperMixin.java new file mode 100644 index 000000000..27f8e585d --- /dev/null +++ b/src/main/java/com/github/alexthe666/alexsmobs/mixins/CreeperMixin.java @@ -0,0 +1,39 @@ +package com.github.alexthe666.alexsmobs.mixins; + + +import com.github.alexthe666.alexsmobs.entity.*; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.goal.AvoidEntityGoal; +import net.minecraft.world.entity.monster.Creeper; +import net.minecraft.world.entity.monster.Monster; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + + +@Mixin(Creeper.class) +public abstract class CreeperMixin extends Monster { + + + protected CreeperMixin(EntityType p_33002_, Level p_33003_) { + super(p_33002_, p_33003_); + } + + @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) + protected void registerGoals(CallbackInfo ci) { + this.targetSelector.addGoal(3, new AvoidEntityGoal<>(this, EntitySnowLeopard.class, 6.0F, 1.0D, 1.2D)); + this.targetSelector.addGoal(3, new AvoidEntityGoal<>(this, EntityTiger.class, 6.0F, 1.0D, 1.2D)); + } + +} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/DolphinMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/DolphinMixin.java new file mode 100644 index 000000000..2e3a904a8 --- /dev/null +++ b/src/main/java/com/github/alexthe666/alexsmobs/mixins/DolphinMixin.java @@ -0,0 +1,35 @@ +package com.github.alexthe666.alexsmobs.mixins; + + +import com.github.alexthe666.alexsmobs.config.AMConfig; +import com.github.alexthe666.alexsmobs.entity.EntityFlyingFish; +import com.github.alexthe666.alexsmobs.entity.EntityJerboa; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; +import net.minecraft.world.entity.animal.Cat; +import net.minecraft.world.entity.animal.Dolphin; +import net.minecraft.world.entity.animal.WaterAnimal; +import net.minecraft.world.level.Level; +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(Dolphin.class) +public abstract class DolphinMixin extends WaterAnimal { + + + protected DolphinMixin(EntityType p_30341_, Level p_30342_) { + super(p_30341_, p_30342_); + } + + @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) + protected void registerGoals(CallbackInfo ci) { + if (AMConfig.dolphinsAttackFlyingFish) { + this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, EntityFlyingFish.class, 70, true, true, null)); + } + } + +} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/FoxMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/FoxMixin.java new file mode 100644 index 000000000..d38102655 --- /dev/null +++ b/src/main/java/com/github/alexthe666/alexsmobs/mixins/FoxMixin.java @@ -0,0 +1,34 @@ +package com.github.alexthe666.alexsmobs.mixins; + + +import com.github.alexthe666.alexsmobs.config.AMConfig; +import com.github.alexthe666.alexsmobs.entity.EntityJerboa; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.animal.Cat; +import net.minecraft.world.entity.animal.Fox; +import net.minecraft.world.level.Level; +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(Fox.class) +public abstract class FoxMixin extends Animal { + + + protected FoxMixin(EntityType p_21803_, Level p_21804_) { + super(p_21803_, p_21804_); + } + + @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) + protected void registerGoals(CallbackInfo ci) { + if (AMConfig.catsAndFoxesAttackJerboas) { + this.targetSelector.addGoal(6, new NearestAttackableTargetGoal<>(this, EntityJerboa.class, 45, true, true, null)); + } + } + +} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/OcelotMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/OcelotMixin.java new file mode 100644 index 000000000..622e68a0d --- /dev/null +++ b/src/main/java/com/github/alexthe666/alexsmobs/mixins/OcelotMixin.java @@ -0,0 +1,34 @@ +package com.github.alexthe666.alexsmobs.mixins; + + +import com.github.alexthe666.alexsmobs.config.AMConfig; +import com.github.alexthe666.alexsmobs.entity.EntityJerboa; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.animal.Fox; +import net.minecraft.world.entity.animal.Ocelot; +import net.minecraft.world.level.Level; +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(Ocelot.class) +public abstract class OcelotMixin extends Animal { + + + protected OcelotMixin(EntityType p_21803_, Level p_21804_) { + super(p_21803_, p_21804_); + } + + @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) + protected void registerGoals(CallbackInfo ci) { + if (AMConfig.catsAndFoxesAttackJerboas) { + this.targetSelector.addGoal(6, new NearestAttackableTargetGoal<>(this, EntityJerboa.class, 45, true, true, null)); + } + } + +} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/PolarBearMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/PolarBearMixin.java new file mode 100644 index 000000000..abc6b9825 --- /dev/null +++ b/src/main/java/com/github/alexthe666/alexsmobs/mixins/PolarBearMixin.java @@ -0,0 +1,37 @@ +package com.github.alexthe666.alexsmobs.mixins; + + +import com.github.alexthe666.alexsmobs.config.AMConfig; +import com.github.alexthe666.alexsmobs.entity.EntitySeal; +import com.github.alexthe666.alexsmobs.entity.EntitySnowLeopard; +import com.github.alexthe666.alexsmobs.entity.EntityTiger; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ai.goal.AvoidEntityGoal; +import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.animal.PolarBear; +import net.minecraft.world.entity.monster.Creeper; +import net.minecraft.world.entity.monster.Monster; +import net.minecraft.world.level.Level; +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(PolarBear.class) +public abstract class PolarBearMixin extends Animal { + + + protected PolarBearMixin(EntityType p_27557_, Level p_27558_) { + super(p_27557_, p_27558_); + } + + @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) + protected void registerGoals(CallbackInfo ci) { + if (AMConfig.polarBearsAttackSeals) { + this.targetSelector.addGoal(6, new NearestAttackableTargetGoal<>(this, EntitySeal.class, 15, true, true, null)); + } + } + +} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/RabbitMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/RabbitMixin.java new file mode 100644 index 000000000..331b685e1 --- /dev/null +++ b/src/main/java/com/github/alexthe666/alexsmobs/mixins/RabbitMixin.java @@ -0,0 +1,36 @@ +package com.github.alexthe666.alexsmobs.mixins; + + +import com.github.alexthe666.alexsmobs.config.AMConfig; +import com.github.alexthe666.alexsmobs.entity.EntityJerboa; +import com.github.alexthe666.alexsmobs.item.AMItemRegistry; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.ai.goal.TemptGoal; +import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.animal.Rabbit; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.Level; +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(Rabbit.class) +public abstract class RabbitMixin extends Animal { + + + protected RabbitMixin(EntityType p_21803_, Level p_21804_) { + super(p_21803_, p_21804_); + } + + @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) + protected void registerGoals(CallbackInfo ci) { + if (AMConfig.bunfungusTransformation) { + this.goalSelector.addGoal(3, new TemptGoal(this, 1.0D, Ingredient.of(AMItemRegistry.MUNGAL_SPORES.get()), false)); + } + } + +} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/SpiderMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/SpiderMixin.java new file mode 100644 index 000000000..c20c153f4 --- /dev/null +++ b/src/main/java/com/github/alexthe666/alexsmobs/mixins/SpiderMixin.java @@ -0,0 +1,36 @@ +package com.github.alexthe666.alexsmobs.mixins; + + +import com.github.alexthe666.alexsmobs.config.AMConfig; +import com.github.alexthe666.alexsmobs.entity.EntityFly; +import com.github.alexthe666.alexsmobs.entity.EntitySnowLeopard; +import com.github.alexthe666.alexsmobs.entity.EntityTiger; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ai.goal.AvoidEntityGoal; +import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; +import net.minecraft.world.entity.monster.Creeper; +import net.minecraft.world.entity.monster.Monster; +import net.minecraft.world.entity.monster.Spider; +import net.minecraft.world.level.Level; +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(Spider.class) +public abstract class SpiderMixin extends Monster { + + + protected SpiderMixin(EntityType p_33002_, Level p_33003_) { + super(p_33002_, p_33003_); + } + + @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) + protected void registerGoals(CallbackInfo ci) { + if (AMConfig.spidersAttackFlies) { + this.targetSelector.addGoal(4, new NearestAttackableTargetGoal<>(this, EntityFly.class, 1, true, false, null)); + } + } + +} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/WolfMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/WolfMixin.java new file mode 100644 index 000000000..34862ede0 --- /dev/null +++ b/src/main/java/com/github/alexthe666/alexsmobs/mixins/WolfMixin.java @@ -0,0 +1,36 @@ +package com.github.alexthe666.alexsmobs.mixins; + + +import com.github.alexthe666.alexsmobs.config.AMConfig; +import com.github.alexthe666.alexsmobs.entity.EntityFly; +import com.github.alexthe666.alexsmobs.entity.EntityMoose; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; +import net.minecraft.world.entity.ai.goal.target.NonTameRandomTargetGoal; +import net.minecraft.world.entity.animal.Wolf; +import net.minecraft.world.entity.monster.Monster; +import net.minecraft.world.entity.monster.Spider; +import net.minecraft.world.level.Level; +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(Wolf.class) +public abstract class WolfMixin extends TamableAnimal { + + + protected WolfMixin(EntityType p_21803_, Level p_21804_) { + super(p_21803_, p_21804_); + } + + @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) + protected void registerGoals(CallbackInfo ci) { + if (AMConfig.wolvesAttackMoose) { + this.targetSelector.addGoal(6, new NonTameRandomTargetGoal<>(this, EntityMoose.class, false, null)); + } + } + +} diff --git a/src/main/resources/alexsmobs.mixins.json b/src/main/resources/alexsmobs.mixins.json new file mode 100644 index 000000000..bf618c437 --- /dev/null +++ b/src/main/resources/alexsmobs.mixins.json @@ -0,0 +1,23 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.github.alexthe666.alexsmobs.mixins", + "compatibilityLevel": "JAVA_8", + "refmap": "alexsmobs.refmap.json", + "mixins": [ + "CatMixin", + "CreeperMixin", + "DolphinMixin", + "FoxMixin", + "OcelotMixin", + "PolarBearMixin", + "RabbitMixin", + "SpiderMixin", + "WolfMixin" + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} From ab6caed28a985fd483a718c7edd3f0a5bffdf82e Mon Sep 17 00:00:00 2001 From: Crim Date: Mon, 11 Nov 2024 05:09:54 +0800 Subject: [PATCH 3/4] Revert "unique behaviors to vanilla mobs fix" This reverts commit 88ecd9982f2473902bc0b7937f628d23936fdcbf. --- build.gradle | 7 +-- .../alexsmobs/entity/EntityCentipedeHead.java | 2 +- .../alexsmobs/entity/EntityGorilla.java | 3 +- .../alexsmobs/entity/EntityRattlesnake.java | 60 ++++++++----------- .../alexsmobs/event/ServerEvents.java | 32 ++++++++++ .../alexthe666/alexsmobs/mixins/CatMixin.java | 40 ------------- .../alexsmobs/mixins/CreeperMixin.java | 39 ------------ .../alexsmobs/mixins/DolphinMixin.java | 35 ----------- .../alexthe666/alexsmobs/mixins/FoxMixin.java | 34 ----------- .../alexsmobs/mixins/OcelotMixin.java | 34 ----------- .../alexsmobs/mixins/PolarBearMixin.java | 37 ------------ .../alexsmobs/mixins/RabbitMixin.java | 36 ----------- .../alexsmobs/mixins/SpiderMixin.java | 36 ----------- .../alexsmobs/mixins/WolfMixin.java | 36 ----------- src/main/resources/alexsmobs.mixins.json | 23 ------- 15 files changed, 62 insertions(+), 392 deletions(-) delete mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/CatMixin.java delete mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/CreeperMixin.java delete mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/DolphinMixin.java delete mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/FoxMixin.java delete mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/OcelotMixin.java delete mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/PolarBearMixin.java delete mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/RabbitMixin.java delete mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/SpiderMixin.java delete mode 100644 src/main/java/com/github/alexthe666/alexsmobs/mixins/WolfMixin.java delete mode 100644 src/main/resources/alexsmobs.mixins.json diff --git a/build.gradle b/build.gradle index 1a9d56e00..3e7b71083 100644 --- a/build.gradle +++ b/build.gradle @@ -99,7 +99,6 @@ minecraft { } } } -apply plugin: 'org.spongepowered.mixin' // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } @@ -115,10 +114,8 @@ dependencies { mixin { - - add sourceSets.main, "alexsmobs.refmap.json" - - config "alexsmobs.mixins.json" + add sourceSets.main, "citadel.refmap.json" + config 'citadel.mixins.json' } // Example for how to get properties into the manifest for reading by the runtime.. diff --git a/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityCentipedeHead.java b/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityCentipedeHead.java index 6c4db7cc1..312a7e3ad 100644 --- a/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityCentipedeHead.java +++ b/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityCentipedeHead.java @@ -170,7 +170,7 @@ public void pushEntities() { @Nullable public SpawnGroupData finalizeSpawn(ServerLevelAccessor worldIn, DifficultyInstance difficultyIn, MobSpawnType reason, @Nullable SpawnGroupData spawnDataIn, @Nullable CompoundTag dataTag) { - this.setSegmentCount(random.nextInt(4) + 100); + this.setSegmentCount(random.nextInt(4) + 5); return super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); } diff --git a/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityGorilla.java b/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityGorilla.java index 113963118..48f3c998c 100644 --- a/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityGorilla.java +++ b/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityGorilla.java @@ -147,7 +147,8 @@ protected void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(0, new FloatGoal(this)); this.goalSelector.addGoal(1, new SitWhenOrderedToGoal(this)); - this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 1.2D, false)); + this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 1.2D, true)); + this.goalSelector.addGoal(2, new GorillaAIFollowCaravan(this, 0.8D)); this.goalSelector.addGoal(3, new GorillaAIChargeLooker(this, 1.6D)); this.goalSelector.addGoal(4, new TameableAITempt(this, 1.1D, Ingredient.of(AMTagRegistry.GORILLA_TAMEABLES), false)); this.goalSelector.addGoal(4, new AnimalAIRideParent(this, 1.25D)); diff --git a/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityRattlesnake.java b/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityRattlesnake.java index a62724a23..681cce10f 100644 --- a/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityRattlesnake.java +++ b/src/main/java/com/github/alexthe666/alexsmobs/entity/EntityRattlesnake.java @@ -34,7 +34,6 @@ import net.minecraft.world.phys.Vec3; import javax.annotation.Nullable; -import java.util.Iterator; import java.util.List; import java.util.function.Predicate; @@ -63,7 +62,7 @@ protected EntityRattlesnake(EntityType type, Level worldIn) { protected void registerGoals() { this.goalSelector.addGoal(0, new FloatGoal(this)); - this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.2D, false)); + this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.2D, true)); this.goalSelector.addGoal(2, new WarnPredatorsGoal()); this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D)); this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1D)); @@ -243,54 +242,45 @@ public static boolean canRattlesnakeSpawn(EntityType animal, L class WarnPredatorsGoal extends Goal { int executionChance = 20; - LivingEntity target = null; - - private static final Predicate WARNABLE_PREDICATE = (mob) -> { - return mob instanceof Player && !((Player) mob).isCreative() && !mob.isSpectator() || mob instanceof EntityRoadrunner || mob instanceof EntityRattlesnake; - }; - - public WarnPredatorsGoal() { - } + Entity target = null; + @Override public boolean canUse() { - List list = EntityRattlesnake.this.level().getEntitiesOfClass(LivingEntity.class, EntityRattlesnake.this.getBoundingBox().inflate(5.0, 5.0, 5.0), WARNABLE_PREDICATE); - double d0 = Double.MAX_VALUE; - Entity possibleTarget = null; - Iterator var7 = list.iterator(); - - while(var7.hasNext()) { - - Entity entity = var7.next(); - double d1 = EntityRattlesnake.this.distanceToSqr(entity); - if (!(d1 > d0) && entity != EntityRattlesnake.this) { - d0 = d1; - possibleTarget = entity; + if(EntityRattlesnake.this.getRandom().nextInt(executionChance) == 0){ + final double dist = 5D; + List list = EntityRattlesnake.this.level().getEntitiesOfClass(LivingEntity.class, EntityRattlesnake.this.getBoundingBox().inflate(dist, dist, dist), WARNABLE_PREDICATE); + double d0 = Double.MAX_VALUE; + Entity possibleTarget = null; + for(Entity entity : list) { + double d1 = EntityRattlesnake.this.distanceToSqr(entity); + if (!(d1 > d0)) { + d0 = d1; + possibleTarget = entity; + } } - + target = possibleTarget; + return !list.isEmpty(); } - - this.target = (LivingEntity) possibleTarget; - return !list.isEmpty(); - + return false; } - public boolean canContinueToUse() { - return this.target != null && (double)EntityRattlesnake.this.distanceTo(this.target) < 5.0 && EntityRattlesnake.this.getTarget() == null; + @Override + public boolean canContinueToUse(){ + return target != null && EntityRattlesnake.this.distanceTo(target) < 5D && EntityRattlesnake.this.getTarget() == null; } + @Override public void stop() { - this.target = null; + target = null; EntityRattlesnake.this.setRattling(false); } - public void tick() { - System.out.println("its working"); + @Override + public void tick(){ EntityRattlesnake.this.setRattling(true); EntityRattlesnake.this.setCurled(true); EntityRattlesnake.this.curlTime = 0; - if (target != null){ - EntityRattlesnake.this.getLookControl().setLookAt(this.target, 30.0F, 30.0F); - } + EntityRattlesnake.this.getLookControl().setLookAt(target, 30, 30); } } diff --git a/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java b/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java index ee39dcc96..a3043870a 100644 --- a/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java +++ b/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java @@ -506,6 +506,38 @@ public void onEntityFinalizeSpawn(MobSpawnEvent.FinalizeSpawn event) { } } } + try { + if (AMConfig.spidersAttackFlies && entity instanceof final Spider spider) { + spider.targetSelector.addGoal(4, + new NearestAttackableTargetGoal<>(spider, EntityFly.class, 1, true, false, null)); + } + else if (AMConfig.wolvesAttackMoose && entity instanceof final Wolf wolf) { + wolf.targetSelector.addGoal(6, new NonTameRandomTargetGoal<>(wolf, EntityMoose.class, false, null)); + } + else if (AMConfig.polarBearsAttackSeals && entity instanceof final PolarBear bear) { + bear.targetSelector.addGoal(6, + new NearestAttackableTargetGoal<>(bear, EntitySeal.class, 15, true, true, null)); + } + else if (entity instanceof final Creeper creeper) { + creeper.targetSelector.addGoal(3, new AvoidEntityGoal<>(creeper, EntitySnowLeopard.class, 6.0F, 1.0D, 1.2D)); + creeper.targetSelector.addGoal(3, new AvoidEntityGoal<>(creeper, EntityTiger.class, 6.0F, 1.0D, 1.2D)); + } + else if (AMConfig.catsAndFoxesAttackJerboas + && (entity instanceof Fox || entity instanceof Cat || entity instanceof Ocelot)) { + Mob mb = (Mob) entity; + mb.targetSelector.addGoal(6, + new NearestAttackableTargetGoal<>(mb, EntityJerboa.class, 45, true, true, null)); + } + else if (AMConfig.bunfungusTransformation && entity instanceof final Rabbit rabbit) { + rabbit.goalSelector.addGoal(3, new TemptGoal(rabbit, 1.0D, Ingredient.of(AMItemRegistry.MUNGAL_SPORES.get()), false)); + } + else if (AMConfig.dolphinsAttackFlyingFish && entity instanceof final Dolphin dolphin) { + dolphin.targetSelector.addGoal(2, + new NearestAttackableTargetGoal<>(dolphin, EntityFlyingFish.class, 70, true, true, null)); + } + } catch (Exception e) { + AlexsMobs.LOGGER.warn("Tried to add unique behaviors to vanilla mobs and encountered an error"); + } } @SubscribeEvent diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/CatMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/CatMixin.java deleted file mode 100644 index 06721a514..000000000 --- a/src/main/java/com/github/alexthe666/alexsmobs/mixins/CatMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.github.alexthe666.alexsmobs.mixins; - - -import com.github.alexthe666.alexsmobs.config.AMConfig; -import com.github.alexthe666.alexsmobs.entity.EntityJerboa; -import com.github.alexthe666.alexsmobs.entity.EntitySnowLeopard; -import com.github.alexthe666.alexsmobs.entity.EntityTiger; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.TamableAnimal; -import net.minecraft.world.entity.ai.goal.AvoidEntityGoal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.animal.Cat; -import net.minecraft.world.entity.animal.Fox; -import net.minecraft.world.entity.animal.Ocelot; -import net.minecraft.world.entity.monster.Creeper; -import net.minecraft.world.entity.monster.Monster; -import net.minecraft.world.level.Level; -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(Cat.class) -public abstract class CatMixin extends TamableAnimal { - - - protected CatMixin(EntityType p_21803_, Level p_21804_) { - super(p_21803_, p_21804_); - } - - @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) - protected void registerGoals(CallbackInfo ci) { - if (AMConfig.catsAndFoxesAttackJerboas) { - this.targetSelector.addGoal(6, new NearestAttackableTargetGoal<>(this, EntityJerboa.class, 45, true, true, null)); - } - } - -} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/CreeperMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/CreeperMixin.java deleted file mode 100644 index 27f8e585d..000000000 --- a/src/main/java/com/github/alexthe666/alexsmobs/mixins/CreeperMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.github.alexthe666.alexsmobs.mixins; - - -import com.github.alexthe666.alexsmobs.entity.*; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.Component; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.ai.goal.AvoidEntityGoal; -import net.minecraft.world.entity.monster.Creeper; -import net.minecraft.world.entity.monster.Monster; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.EntityHitResult; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - - -@Mixin(Creeper.class) -public abstract class CreeperMixin extends Monster { - - - protected CreeperMixin(EntityType p_33002_, Level p_33003_) { - super(p_33002_, p_33003_); - } - - @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) - protected void registerGoals(CallbackInfo ci) { - this.targetSelector.addGoal(3, new AvoidEntityGoal<>(this, EntitySnowLeopard.class, 6.0F, 1.0D, 1.2D)); - this.targetSelector.addGoal(3, new AvoidEntityGoal<>(this, EntityTiger.class, 6.0F, 1.0D, 1.2D)); - } - -} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/DolphinMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/DolphinMixin.java deleted file mode 100644 index 2e3a904a8..000000000 --- a/src/main/java/com/github/alexthe666/alexsmobs/mixins/DolphinMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.github.alexthe666.alexsmobs.mixins; - - -import com.github.alexthe666.alexsmobs.config.AMConfig; -import com.github.alexthe666.alexsmobs.entity.EntityFlyingFish; -import com.github.alexthe666.alexsmobs.entity.EntityJerboa; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.TamableAnimal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.animal.Cat; -import net.minecraft.world.entity.animal.Dolphin; -import net.minecraft.world.entity.animal.WaterAnimal; -import net.minecraft.world.level.Level; -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(Dolphin.class) -public abstract class DolphinMixin extends WaterAnimal { - - - protected DolphinMixin(EntityType p_30341_, Level p_30342_) { - super(p_30341_, p_30342_); - } - - @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) - protected void registerGoals(CallbackInfo ci) { - if (AMConfig.dolphinsAttackFlyingFish) { - this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, EntityFlyingFish.class, 70, true, true, null)); - } - } - -} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/FoxMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/FoxMixin.java deleted file mode 100644 index d38102655..000000000 --- a/src/main/java/com/github/alexthe666/alexsmobs/mixins/FoxMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.github.alexthe666.alexsmobs.mixins; - - -import com.github.alexthe666.alexsmobs.config.AMConfig; -import com.github.alexthe666.alexsmobs.entity.EntityJerboa; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.TamableAnimal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.animal.Animal; -import net.minecraft.world.entity.animal.Cat; -import net.minecraft.world.entity.animal.Fox; -import net.minecraft.world.level.Level; -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(Fox.class) -public abstract class FoxMixin extends Animal { - - - protected FoxMixin(EntityType p_21803_, Level p_21804_) { - super(p_21803_, p_21804_); - } - - @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) - protected void registerGoals(CallbackInfo ci) { - if (AMConfig.catsAndFoxesAttackJerboas) { - this.targetSelector.addGoal(6, new NearestAttackableTargetGoal<>(this, EntityJerboa.class, 45, true, true, null)); - } - } - -} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/OcelotMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/OcelotMixin.java deleted file mode 100644 index 622e68a0d..000000000 --- a/src/main/java/com/github/alexthe666/alexsmobs/mixins/OcelotMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.github.alexthe666.alexsmobs.mixins; - - -import com.github.alexthe666.alexsmobs.config.AMConfig; -import com.github.alexthe666.alexsmobs.entity.EntityJerboa; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.TamableAnimal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.animal.Animal; -import net.minecraft.world.entity.animal.Fox; -import net.minecraft.world.entity.animal.Ocelot; -import net.minecraft.world.level.Level; -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(Ocelot.class) -public abstract class OcelotMixin extends Animal { - - - protected OcelotMixin(EntityType p_21803_, Level p_21804_) { - super(p_21803_, p_21804_); - } - - @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) - protected void registerGoals(CallbackInfo ci) { - if (AMConfig.catsAndFoxesAttackJerboas) { - this.targetSelector.addGoal(6, new NearestAttackableTargetGoal<>(this, EntityJerboa.class, 45, true, true, null)); - } - } - -} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/PolarBearMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/PolarBearMixin.java deleted file mode 100644 index abc6b9825..000000000 --- a/src/main/java/com/github/alexthe666/alexsmobs/mixins/PolarBearMixin.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.github.alexthe666.alexsmobs.mixins; - - -import com.github.alexthe666.alexsmobs.config.AMConfig; -import com.github.alexthe666.alexsmobs.entity.EntitySeal; -import com.github.alexthe666.alexsmobs.entity.EntitySnowLeopard; -import com.github.alexthe666.alexsmobs.entity.EntityTiger; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.ai.goal.AvoidEntityGoal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.animal.Animal; -import net.minecraft.world.entity.animal.PolarBear; -import net.minecraft.world.entity.monster.Creeper; -import net.minecraft.world.entity.monster.Monster; -import net.minecraft.world.level.Level; -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(PolarBear.class) -public abstract class PolarBearMixin extends Animal { - - - protected PolarBearMixin(EntityType p_27557_, Level p_27558_) { - super(p_27557_, p_27558_); - } - - @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) - protected void registerGoals(CallbackInfo ci) { - if (AMConfig.polarBearsAttackSeals) { - this.targetSelector.addGoal(6, new NearestAttackableTargetGoal<>(this, EntitySeal.class, 15, true, true, null)); - } - } - -} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/RabbitMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/RabbitMixin.java deleted file mode 100644 index 331b685e1..000000000 --- a/src/main/java/com/github/alexthe666/alexsmobs/mixins/RabbitMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.github.alexthe666.alexsmobs.mixins; - - -import com.github.alexthe666.alexsmobs.config.AMConfig; -import com.github.alexthe666.alexsmobs.entity.EntityJerboa; -import com.github.alexthe666.alexsmobs.item.AMItemRegistry; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.TamableAnimal; -import net.minecraft.world.entity.ai.goal.TemptGoal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.animal.Animal; -import net.minecraft.world.entity.animal.Rabbit; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.level.Level; -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(Rabbit.class) -public abstract class RabbitMixin extends Animal { - - - protected RabbitMixin(EntityType p_21803_, Level p_21804_) { - super(p_21803_, p_21804_); - } - - @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) - protected void registerGoals(CallbackInfo ci) { - if (AMConfig.bunfungusTransformation) { - this.goalSelector.addGoal(3, new TemptGoal(this, 1.0D, Ingredient.of(AMItemRegistry.MUNGAL_SPORES.get()), false)); - } - } - -} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/SpiderMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/SpiderMixin.java deleted file mode 100644 index c20c153f4..000000000 --- a/src/main/java/com/github/alexthe666/alexsmobs/mixins/SpiderMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.github.alexthe666.alexsmobs.mixins; - - -import com.github.alexthe666.alexsmobs.config.AMConfig; -import com.github.alexthe666.alexsmobs.entity.EntityFly; -import com.github.alexthe666.alexsmobs.entity.EntitySnowLeopard; -import com.github.alexthe666.alexsmobs.entity.EntityTiger; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.ai.goal.AvoidEntityGoal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.monster.Creeper; -import net.minecraft.world.entity.monster.Monster; -import net.minecraft.world.entity.monster.Spider; -import net.minecraft.world.level.Level; -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(Spider.class) -public abstract class SpiderMixin extends Monster { - - - protected SpiderMixin(EntityType p_33002_, Level p_33003_) { - super(p_33002_, p_33003_); - } - - @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) - protected void registerGoals(CallbackInfo ci) { - if (AMConfig.spidersAttackFlies) { - this.targetSelector.addGoal(4, new NearestAttackableTargetGoal<>(this, EntityFly.class, 1, true, false, null)); - } - } - -} diff --git a/src/main/java/com/github/alexthe666/alexsmobs/mixins/WolfMixin.java b/src/main/java/com/github/alexthe666/alexsmobs/mixins/WolfMixin.java deleted file mode 100644 index 34862ede0..000000000 --- a/src/main/java/com/github/alexthe666/alexsmobs/mixins/WolfMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.github.alexthe666.alexsmobs.mixins; - - -import com.github.alexthe666.alexsmobs.config.AMConfig; -import com.github.alexthe666.alexsmobs.entity.EntityFly; -import com.github.alexthe666.alexsmobs.entity.EntityMoose; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.TamableAnimal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.ai.goal.target.NonTameRandomTargetGoal; -import net.minecraft.world.entity.animal.Wolf; -import net.minecraft.world.entity.monster.Monster; -import net.minecraft.world.entity.monster.Spider; -import net.minecraft.world.level.Level; -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(Wolf.class) -public abstract class WolfMixin extends TamableAnimal { - - - protected WolfMixin(EntityType p_21803_, Level p_21804_) { - super(p_21803_, p_21804_); - } - - @Inject(method = "registerGoals", at = @At("TAIL"), remap = false) - protected void registerGoals(CallbackInfo ci) { - if (AMConfig.wolvesAttackMoose) { - this.targetSelector.addGoal(6, new NonTameRandomTargetGoal<>(this, EntityMoose.class, false, null)); - } - } - -} diff --git a/src/main/resources/alexsmobs.mixins.json b/src/main/resources/alexsmobs.mixins.json deleted file mode 100644 index bf618c437..000000000 --- a/src/main/resources/alexsmobs.mixins.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "com.github.alexthe666.alexsmobs.mixins", - "compatibilityLevel": "JAVA_8", - "refmap": "alexsmobs.refmap.json", - "mixins": [ - "CatMixin", - "CreeperMixin", - "DolphinMixin", - "FoxMixin", - "OcelotMixin", - "PolarBearMixin", - "RabbitMixin", - "SpiderMixin", - "WolfMixin" - ], - "client": [ - ], - "injectors": { - "defaultRequire": 1 - } -} From 88e74236daed558497c9bee0dfc1c7fc24999494 Mon Sep 17 00:00:00 2001 From: Crim Date: Mon, 11 Nov 2024 05:12:49 +0800 Subject: [PATCH 4/4] revert --- .../java/com/github/alexthe666/alexsmobs/event/ServerEvents.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java b/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java index a3043870a..6328e0a40 100644 --- a/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java +++ b/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java @@ -507,6 +507,7 @@ public void onEntityFinalizeSpawn(MobSpawnEvent.FinalizeSpawn event) { } } try { + if (AMConfig.spidersAttackFlies && entity instanceof final Spider spider) { spider.targetSelector.addGoal(4, new NearestAttackableTargetGoal<>(spider, EntityFly.class, 1, true, false, null));