From ad35088c2b3d99547e1ec7af668b773a50d37481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ales=CC=8C=20Fabia=CC=81nek?= Date: Sun, 9 Jul 2023 10:19:36 +0200 Subject: [PATCH 1/4] Fixed conditions --- .../entity/CopperGolemEntity.java | 6 +++++- .../entity/TuffGolemEntity.java | 6 +++++- .../friendsandfoes/entity/WildfireEntity.java | 19 ++++++++----------- .../mixin/IllusionerEntityMixin.java | 16 ++++++++++------ 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java index 900373e07..59a7424d5 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java @@ -282,7 +282,11 @@ public boolean damage( DamageSource source, float amount ) { - if (source.getAttacker() instanceof LightningEntity || source == DamageSource.SWEET_BERRY_BUSH) { + if ( + source.getAttacker() == null + || source.getAttacker() instanceof LightningEntity + || source == DamageSource.SWEET_BERRY_BUSH + ) { return false; } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java index 6accec0cb..3f69c87d4 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java @@ -696,7 +696,11 @@ public boolean damage( DamageSource source, float amount ) { - if (source.getAttacker() instanceof LightningEntity || source == DamageSource.SWEET_BERRY_BUSH) { + if ( + source.getAttacker() == null + || source.getAttacker() instanceof LightningEntity + || source == DamageSource.SWEET_BERRY_BUSH + ) { return false; } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireEntity.java index b853f884c..b2aa28fc2 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireEntity.java @@ -6,10 +6,7 @@ import com.faboslav.friendsandfoes.tag.FriendsAndFoesTags; import com.mojang.serialization.Dynamic; import net.minecraft.block.BlockState; -import net.minecraft.entity.EntityData; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.SpawnReason; +import net.minecraft.entity.*; import net.minecraft.entity.ai.brain.Brain; import net.minecraft.entity.ai.pathing.PathNodeType; import net.minecraft.entity.attribute.DefaultAttributeContainer; @@ -260,12 +257,12 @@ public boolean damage( DamageSource source, float amount ) { + Entity attacker = source.getAttacker(); + if ( source == DamageSource.IN_FIRE - || ( - source.getAttacker() != null - && source.getAttacker().getType().isIn(FriendsAndFoesTags.WILDFIRE_ALLIES) - ) + || attacker == null + || attacker.getType().isIn(FriendsAndFoesTags.WILDFIRE_ALLIES) ) { return false; } @@ -275,7 +272,7 @@ public boolean damage( float shieldBreakDamageThreshold = (float) this.getAttributeValue(EntityAttributes.GENERIC_MAX_HEALTH) * 0.25F; if (this.damageAmountCounter >= shieldBreakDamageThreshold) { - source.getAttacker().damage(DamageSource.mob(this), GENERIC_ATTACK_DAMAGE); + attacker.damage(DamageSource.mob(this), GENERIC_ATTACK_DAMAGE); this.breakShield(); this.playShieldBreakSound(); this.damageAmountCounter = 0; @@ -288,8 +285,8 @@ public boolean damage( boolean damageResult = super.damage(source, amount); - if (damageResult && source.getAttacker() instanceof LivingEntity) { - WildfireBrain.onAttacked(this, (LivingEntity) source.getAttacker()); + if (damageResult && attacker instanceof LivingEntity) { + WildfireBrain.onAttacked(this, (LivingEntity) attacker); } return damageResult; diff --git a/common/src/main/java/com/faboslav/friendsandfoes/mixin/IllusionerEntityMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/mixin/IllusionerEntityMixin.java index 2013ded61..c39d3e980 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/mixin/IllusionerEntityMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/mixin/IllusionerEntityMixin.java @@ -3,6 +3,7 @@ import com.faboslav.friendsandfoes.FriendsAndFoes; import com.faboslav.friendsandfoes.entity.IllusionerEntityAccess; import com.faboslav.friendsandfoes.util.RandomGenerator; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; @@ -226,11 +227,14 @@ public boolean damage( return super.damage(source, amount); } + Entity attacker = source.getAttacker(); + if ( - source.getAttacker() instanceof IllusionerEntity + attacker == null + || attacker instanceof IllusionerEntity || ( this.isIllusion() - && !(source.getAttacker() instanceof LivingEntity) + && attacker instanceof LivingEntity == false ) ) { return false; @@ -239,9 +243,9 @@ public boolean damage( if ( this.getWorld().isClient() || ( - source.getAttacker() instanceof PlayerEntity + attacker instanceof PlayerEntity && !this.isIllusion() - && ((PlayerEntity) source.getAttacker()).getAbilities().creativeMode + && ((PlayerEntity) attacker).getAbilities().creativeMode ) ) { return super.damage(source, amount); @@ -254,8 +258,8 @@ public boolean damage( if ( ( - source.getAttacker() instanceof PlayerEntity - || source.getAttacker() instanceof IronGolemEntity + attacker instanceof PlayerEntity + || attacker instanceof IronGolemEntity ) && this.getTicksUntilCanCreateIllusions() == 0) { this.createIllusions(); From 6cdd4d46b28c4e69da8a9aa6e5936a3daa6cefe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ales=CC=8C=20Fabia=CC=81nek?= Date: Wed, 12 Jul 2023 09:55:10 +0200 Subject: [PATCH 2/4] Tweaked tuff golem sleep conditions --- .../friendsandfoes/entity/TuffGolemEntity.java | 4 ++-- .../task/tuffgolem/TuffGolemGoToHomePositionTask.java | 10 +++++----- .../ai/brain/task/tuffgolem/TuffGolemSleepTask.java | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java index 3f69c87d4..a61ac94cb 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java @@ -580,8 +580,8 @@ public boolean isAtHomePos() { return this.squaredDistanceTo(this.getHomePos()) < 0.1D; } - public boolean isCloseToHomePos() { - return this.squaredDistanceTo(this.getHomePos()) < 1.0D; + public boolean isCloseToHomePos(float distance) { + return this.squaredDistanceTo(this.getHomePos()) < distance; } public boolean isAtHomeYaw() { diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/tuffgolem/TuffGolemGoToHomePositionTask.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/tuffgolem/TuffGolemGoToHomePositionTask.java index 6a960606c..eda277d24 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/tuffgolem/TuffGolemGoToHomePositionTask.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/tuffgolem/TuffGolemGoToHomePositionTask.java @@ -13,7 +13,7 @@ public final class TuffGolemGoToHomePositionTask extends Task { - private final static int GO_TO_SLEEP_POSITION_DURATION = 1200; + private final static int GO_TO_SLEEP_POSITION_DURATION = 2400; public TuffGolemGoToHomePositionTask() { super(ImmutableMap.of( @@ -69,8 +69,8 @@ protected void keepRunning( } if ( - tuffGolem.isCloseToHomePos() == false - || (int) tuffGolem.getY() != (int) tuffGolem.getHomePos().getY() + tuffGolem.isCloseToHomePos(2.0F) == false + || Math.abs((int) tuffGolem.getY() - (int) tuffGolem.getHomePos().getY()) > 1 ) { return; } @@ -78,7 +78,7 @@ protected void keepRunning( tuffGolem.setVelocity( new Vec3d( (tuffGolem.getHomePos().getX() - tuffGolem.getX()), - 0, + (tuffGolem.getHomePos().getY() - tuffGolem.getY()), (tuffGolem.getHomePos().getZ() - tuffGolem.getZ()) ) ); @@ -91,7 +91,7 @@ protected void finishRunning( TuffGolemEntity tuffGolem, long time ) { - if (tuffGolem.isCloseToHomePos()) { + if (tuffGolem.isCloseToHomePos(1.5F)) { tuffGolem.setPosition(tuffGolem.getHomePos()); } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/tuffgolem/TuffGolemSleepTask.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/tuffgolem/TuffGolemSleepTask.java index 5e785ea23..6ac7e5c99 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/tuffgolem/TuffGolemSleepTask.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/tuffgolem/TuffGolemSleepTask.java @@ -11,8 +11,8 @@ public final class TuffGolemSleepTask extends Task { - private final static int MIN_TICKS_TO_SLEEP = 1200; - private final static int MAX_TICKS_TO_SLEEP = 3600; + private final static int MIN_TICKS_TO_SLEEP = 2400; + private final static int MAX_TICKS_TO_SLEEP = 4800; public TuffGolemSleepTask() { super(ImmutableMap.of( From 35cc34589e902fb11f963c82dd93fc8ae7ee7e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ales=CC=8C=20Fabia=CC=81nek?= Date: Wed, 12 Jul 2023 09:56:40 +0200 Subject: [PATCH 3/4] Bumped versions --- .github/versions.json | 6 +++--- gradle.properties | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/versions.json b/.github/versions.json index 641ea6727..28d1e6e74 100644 --- a/.github/versions.json +++ b/.github/versions.json @@ -1,7 +1,7 @@ { - "1.19.2": "1.8.4", - "1.19.1": "1.8.4", - "1.19": "1.8.4", + "1.19.2": "1.8.5", + "1.19.1": "1.8.5", + "1.19": "1.8.5", "1.18.2": "1.4.7", "1.18.1": "1.2.5", "1.18": "1.2.5" diff --git a/gradle.properties b/gradle.properties index 5f50db009..6c23c5fc1 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=1.8.4 +mod_version=1.8.5 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 e83abed439bcb8d827e7bd938cc35dad543a8c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ales=CC=8C=20Fabia=CC=81nek?= Date: Wed, 12 Jul 2023 10:02:17 +0200 Subject: [PATCH 4/4] Corrected code --- .../faboslav/friendsandfoes/entity/CopperGolemEntity.java | 6 ++++-- .../com/faboslav/friendsandfoes/entity/TuffGolemEntity.java | 6 ++++-- .../com/faboslav/friendsandfoes/entity/WildfireEntity.java | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java index 59a7424d5..9b3227111 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java @@ -282,9 +282,11 @@ public boolean damage( DamageSource source, float amount ) { + Entity attacker = source.getAttacker(); + if ( - source.getAttacker() == null - || source.getAttacker() instanceof LightningEntity + attacker == null + || attacker instanceof LightningEntity || source == DamageSource.SWEET_BERRY_BUSH ) { return false; diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java index a61ac94cb..7b5c150e0 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java @@ -696,9 +696,11 @@ public boolean damage( DamageSource source, float amount ) { + Entity attacker = source.getAttacker(); + if ( - source.getAttacker() == null - || source.getAttacker() instanceof LightningEntity + attacker == null + || attacker instanceof LightningEntity || source == DamageSource.SWEET_BERRY_BUSH ) { return false; diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireEntity.java index b2aa28fc2..116341ba9 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/WildfireEntity.java @@ -267,7 +267,7 @@ public boolean damage( return false; } - if (this.hasActiveShields() && source.getAttacker() != null) { + if (this.hasActiveShields()) { this.damageAmountCounter += amount; float shieldBreakDamageThreshold = (float) this.getAttributeValue(EntityAttributes.GENERIC_MAX_HEALTH) * 0.25F;