Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Faboslav committed Jul 12, 2023
2 parents 24e98e7 + 94cc7fa commit 69ff295
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/versions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"1.20.1": "1.9.2",
"1.20": "1.9.2",
"1.20.1": "1.9.3",
"1.20": "1.9.3",
"1.19.4": "1.8.4",
"1.19.3": "1.8.4",
"1.19.2": "1.8.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,13 @@ public boolean damage(
DamageSource source,
float amount
) {
if (source.getAttacker() instanceof LightningEntity || source == this.getDamageSources().sweetBerryBush()) {
Entity attacker = source.getAttacker();

if (
attacker == null
|| attacker instanceof LightningEntity
|| source == this.getDamageSources().sweetBerryBush()
) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,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() {
Expand Down Expand Up @@ -695,7 +695,13 @@ public boolean damage(
DamageSource source,
float amount
) {
if (source.getAttacker() instanceof LightningEntity || source == this.getDamageSources().sweetBerryBush()) {
Entity attacker = source.getAttacker();

if (
attacker == null
|| attacker instanceof LightningEntity
|| source == this.getDamageSources().sweetBerryBush()
) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -262,22 +259,22 @@ public boolean damage(
DamageSource source,
float amount
) {
Entity attacker = source.getAttacker();

if (
source == this.getDamageSources().inFire()
|| (
source.getAttacker() != null
&& source.getAttacker().getType().isIn(FriendsAndFoesTags.WILDFIRE_ALLIES)
)
|| attacker == null
|| attacker.getType().isIn(FriendsAndFoesTags.WILDFIRE_ALLIES)
) {
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;

if (this.damageAmountCounter >= shieldBreakDamageThreshold) {
source.getAttacker().damage(this.getDamageSources().mobAttack(this), GENERIC_ATTACK_DAMAGE);
attacker.damage(this.getDamageSources().mobAttack(this), GENERIC_ATTACK_DAMAGE);
this.breakShield();
this.playShieldBreakSound();
this.damageAmountCounter = 0;
Expand All @@ -290,8 +287,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public final class TuffGolemGoToHomePositionTask extends MultiTickTask<TuffGolemEntity>
{
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(
Expand Down Expand Up @@ -69,16 +69,16 @@ 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;
}

tuffGolem.setVelocity(
new Vec3d(
(tuffGolem.getHomePos().getX() - tuffGolem.getX()),
0,
(tuffGolem.getHomePos().getY() - tuffGolem.getY()),
(tuffGolem.getHomePos().getZ() - tuffGolem.getZ())
)
);
Expand All @@ -91,7 +91,7 @@ protected void finishRunning(
TuffGolemEntity tuffGolem,
long time
) {
if (tuffGolem.isCloseToHomePos()) {
if (tuffGolem.isCloseToHomePos(1.5F)) {
tuffGolem.setPosition(tuffGolem.getHomePos());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

public final class TuffGolemSleepTask extends MultiTickTask<TuffGolemEntity>
{
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.configureondemand=false
# Mod
mod_name=Friends&Foes
mod_id=friendsandfoes
mod_version=1.9.2
mod_version=1.9.3
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
Expand Down

0 comments on commit 69ff295

Please sign in to comment.