From aed2b9336908f95876c9fec83787e468da904aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Fabi=C3=A1nek?= Date: Thu, 1 Feb 2024 11:18:13 +0100 Subject: [PATCH 1/2] Fixed Glare follow logic when tamed --- CHANGELOG.md | 4 ++++ .../com/faboslav/friendsandfoes/entity/GlareEntity.java | 1 + .../faboslav/friendsandfoes/entity/ai/brain/GlareBrain.java | 6 ++++-- .../entity/ai/brain/sensor/GlareSpecificSensor.java | 2 +- .../entity/ai/brain/task/glare/GlareLocateDarkSpotTask.java | 1 + .../ai/brain/task/glare/GlareLocateGlowBerriesTask.java | 1 + gradle.properties | 2 +- 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7add72ef5..28a732e19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.9 + +- Fixed Glare follow logic when tamed + ## 2.0.8 - Reworked Glare AI to use brain/tasks instead of goals diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java index 3ced334db..2243302c8 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java @@ -214,6 +214,7 @@ public void travel(Vec3d movementInput) { this.setVelocity(this.getVelocity().multiply(0.91f)); } } + this.updateLimbs(this, false); } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/GlareBrain.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/GlareBrain.java index 629f5cb04..be25a7691 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/GlareBrain.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/GlareBrain.java @@ -116,6 +116,7 @@ private static void addAvoidActivities(Brain brain) { ), ImmutableSet.of( Pair.of(MemoryModuleType.AVOID_TARGET, MemoryModuleState.VALUE_PRESENT), + Pair.of(FriendsAndFoesMemoryModuleTypes.GLARE_IS_TAMED.get(), MemoryModuleState.VALUE_ABSENT), Pair.of(FriendsAndFoesMemoryModuleTypes.GLARE_IS_IDLE.get(), MemoryModuleState.VALUE_ABSENT) ) ); @@ -173,8 +174,8 @@ public static void updateActivities(GlareEntity glare) { public static void updateMemories(GlareEntity glare) { if ( ( - glare.isBaby() - || (glare.isBaby() == false && glare.isTamed() == false) + (glare.isBaby() == false && glare.isTamed() == false) + || GlareLocateDarkSpotTask.canLocateDarkSpot(glare) == false ) && glare.getBrain().isMemoryInState(FriendsAndFoesMemoryModuleTypes.GLARE_DARK_SPOT_LOCATING_COOLDOWN.get(), MemoryModuleState.VALUE_ABSENT) ) { @@ -184,6 +185,7 @@ public static void updateMemories(GlareEntity glare) { if ( glare.isSitting() || glare.isLeashed() + || glare.hasVehicle() ) { glare.getBrain().remember(FriendsAndFoesMemoryModuleTypes.GLARE_IS_IDLE.get(), true); } else { diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/sensor/GlareSpecificSensor.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/sensor/GlareSpecificSensor.java index ce5465966..7ade032dd 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/sensor/GlareSpecificSensor.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/sensor/GlareSpecificSensor.java @@ -50,7 +50,7 @@ protected void sense(ServerWorld world, GlareEntity glare) { LivingTargetCache livingTargetCache = brain.getOptionalMemory(MemoryModuleType.VISIBLE_MOBS).orElse(LivingTargetCache.empty()); LivingEntity firstHostileEntity = livingTargetCache.findFirst(livingEntity -> livingEntity instanceof HostileEntity).orElse(null); - if (firstHostileEntity == null) { + if (firstHostileEntity == null || glare.isTamed()) { return; } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/glare/GlareLocateDarkSpotTask.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/glare/GlareLocateDarkSpotTask.java index 5e0aab7be..ec83c62f6 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/glare/GlareLocateDarkSpotTask.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/glare/GlareLocateDarkSpotTask.java @@ -99,6 +99,7 @@ public static boolean canLocateDarkSpot(GlareEntity glare) { if ( glare.isLeashed() || glare.isSitting() + || glare.hasVehicle() || glare.isTamed() == false || glare.isBaby() || ( diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/glare/GlareLocateGlowBerriesTask.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/glare/GlareLocateGlowBerriesTask.java index 7b1e7bc82..ef04a6b13 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/glare/GlareLocateGlowBerriesTask.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/glare/GlareLocateGlowBerriesTask.java @@ -35,6 +35,7 @@ protected boolean shouldRun(ServerWorld world, GlareEntity glare) { return FriendsAndFoes.getConfig().enableGlareGriefing != false && !glare.isLeashed() && !glare.isSitting() + && !glare.hasVehicle() && glare.getEquippedStack(EquipmentSlot.MAINHAND).isEmpty() != false; } diff --git a/gradle.properties b/gradle.properties index 7648ba4b9..2523f83b9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.configureondemand=false # Mod mod_name=Friends&Foes mod_id=friendsandfoes -mod_version=2.0.8 +mod_version=2.0.9 mod_author=Faboslav mod_description=Adds outvoted and forgotten mobs from the mob votes in a believable vanilla plus style. maven_group=com.faboslav.friendsandfoes From 36042838409b64d974d38cd5f2855651a6b19b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Fabi=C3=A1nek?= Date: Thu, 1 Feb 2024 11:19:25 +0100 Subject: [PATCH 2/2] format --- .../java/com/faboslav/friendsandfoes/entity/GlareEntity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java index 9f1c06356..0f584f1dd 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/GlareEntity.java @@ -210,7 +210,7 @@ public void travel(Vec3d movementInput) { this.setVelocity(this.getVelocity().multiply(0.9100000262260437)); } } - + this.updateLimbs(false); }