Skip to content

Commit

Permalink
attack/follow range is now adjustable through the config
Browse files Browse the repository at this point in the history
  • Loading branch information
tristankechlo committed Aug 11, 2024
1 parent 3910236 commit b4507d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- improved AI of baby enderdragon
- can not take damage from own attacks any more (immune to own area effect clouds that do damage)
- once tamed, no longer tries to shoot other players
- attack/follow range is now adjustable through the config

### Version 1.20.6 - 2.0.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ public final class BabyEnderDragonConfig extends EntityConfig {
public final DoubleValue health = new DoubleValue("health", 10.0D, MIN_HEALTH, MAX_HEALTH);
public final DoubleValue movementSpeed = new DoubleValue("movementSpeed", 0.3D, MIN_SPEED, MAX_SPEED);
public final DoubleValue flyingSpeed = new DoubleValue("flyingSpeed", 0.5D, MIN_SPEED, MAX_SPEED);
public final DoubleValue followRange = new DoubleValue("followRange", 64.0D, 0.0D, 2048.0D); // twice the default FOLLOW_RANGE
public final BooleanValue canSpawn = new BooleanValue("canSpawn", true);
public final IntegerValue maxSpawnedInChunk = new IntegerValue("maxSpawnedInChunk", 5, 1, 15);
public final IngredientValue temptationItems = new IngredientValue("temptationItems", Items.CHORUS_FRUIT);

private BabyEnderDragonConfig() {
super("baby_ender_dragon");
this.registerConfigValues(canAttack, health, movementSpeed, flyingSpeed, canSpawn, maxSpawnedInChunk, temptationItems);
this.registerConfigValues(canAttack, health, movementSpeed, flyingSpeed, followRange, canSpawn, maxSpawnedInChunk, temptationItems);
}

public static BabyEnderDragonConfig get() {
Expand Down Expand Up @@ -57,4 +58,8 @@ public static Ingredient temptationItems() {
return INSTANCE.temptationItems.get();
}

public static double followRange() {
return INSTANCE.followRange.get();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected void registerGoals() {
this.goalSelector.addGoal(1, new FloatGoal(this));
this.goalSelector.addGoal(2, new CustomSitWhenOrderedToSitGoal(this));
this.goalSelector.addGoal(3, new TemptGoal(this, 1.0D, BabyEnderDragonConfig.temptationItems(), false));
this.goalSelector.addGoal(4, new RangedAttackGoal(this, 1.1D, 120, 240, 25.0F));
this.goalSelector.addGoal(4, new RangedAttackGoal(this, 1.1D, 120, 240, (float) BabyEnderDragonConfig.followRange()));
this.goalSelector.addGoal(6, new FollowOwnerGoal(this, 1.3D, 10.0F, 3.0F));
this.goalSelector.addGoal(8, new WaterAvoidingRandomFlyingGoal(this, 1.2D));
this.goalSelector.addGoal(10, new LookAtPlayerGoal(this, Player.class, 8.0F));
Expand Down Expand Up @@ -179,7 +179,8 @@ public static AttributeSupplier.Builder createAttributes() {
return Mob.createMobAttributes()
.add(Attributes.MAX_HEALTH, BabyEnderDragonConfig.health())
.add(Attributes.MOVEMENT_SPEED, BabyEnderDragonConfig.movementSpeed())
.add(Attributes.FLYING_SPEED, BabyEnderDragonConfig.flyingSpeed());
.add(Attributes.FLYING_SPEED, BabyEnderDragonConfig.flyingSpeed())
.add(Attributes.FOLLOW_RANGE, BabyEnderDragonConfig.followRange());
}

public static boolean checkBabyEnderDragonSpawnRules(EntityType<BabyEnderDragonEntity> entityType, LevelAccessor level, MobSpawnType spawnReason, BlockPos pos, RandomSource random) {
Expand Down

0 comments on commit b4507d2

Please sign in to comment.