Skip to content

Commit

Permalink
improv: Added and tweaked some Moa mechanics (The-Aether-Team#1289)
Browse files Browse the repository at this point in the history
  • Loading branch information
bconlon1 authored May 4, 2023
1 parent 05c8473 commit 784d40f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/aetherteam/aether/api/AetherMoaTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public class AetherMoaTypes {
public static final DeferredRegister<MoaType> MOA_TYPES = DeferredRegister.create(MOA_TYPE_REGISTRY_KEY, Aether.MODID);
public static final Supplier<IForgeRegistry<MoaType>> MOA_TYPE_REGISTRY = MOA_TYPES.makeRegistry(RegistryBuilder::new);

public static final RegistryObject<MoaType> BLUE = MOA_TYPES.register("blue", () -> new MoaType(new MoaType.Properties().egg(AetherItems.BLUE_MOA_EGG).maxJumps(3).speed(0.15F).spawnChance(100).texture("textures/entity/mobs/moa/blue_moa.png")));
public static final RegistryObject<MoaType> WHITE = MOA_TYPES.register("white", () -> new MoaType(new MoaType.Properties().egg(AetherItems.WHITE_MOA_EGG).maxJumps(4).speed(0.15F).spawnChance(50).texture("textures/entity/mobs/moa/white_moa.png")));
public static final RegistryObject<MoaType> BLACK = MOA_TYPES.register("black", () -> new MoaType(new MoaType.Properties().egg(AetherItems.BLACK_MOA_EGG).maxJumps(8).speed(0.15F).spawnChance(25).texture("textures/entity/mobs/moa/black_moa.png").saddleTexture("textures/entity/mobs/moa/black_moa_saddle.png")));
public static final RegistryObject<MoaType> BLUE = MOA_TYPES.register("blue", () -> new MoaType(new MoaType.Properties().egg(AetherItems.BLUE_MOA_EGG).maxJumps(3).speed(0.155F).spawnChance(100).texture("textures/entity/mobs/moa/blue_moa.png")));
public static final RegistryObject<MoaType> WHITE = MOA_TYPES.register("white", () -> new MoaType(new MoaType.Properties().egg(AetherItems.WHITE_MOA_EGG).maxJumps(4).speed(0.155F).spawnChance(50).texture("textures/entity/mobs/moa/white_moa.png")));
public static final RegistryObject<MoaType> BLACK = MOA_TYPES.register("black", () -> new MoaType(new MoaType.Properties().egg(AetherItems.BLACK_MOA_EGG).maxJumps(8).speed(0.155F).spawnChance(25).texture("textures/entity/mobs/moa/black_moa.png").saddleTexture("textures/entity/mobs/moa/black_moa_saddle.png")));

public static MoaType get(String id) {
return MOA_TYPE_REGISTRY.get().getValue(new ResourceLocation(id));
Expand Down
38 changes: 33 additions & 5 deletions src/main/java/com/aetherteam/aether/entity/passive/Moa.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import javax.annotation.Nullable;

import com.aetherteam.aether.client.AetherSoundEvents;
import com.aetherteam.aether.effect.AetherEffects;
import com.aetherteam.aether.entity.WingedBird;
import com.aetherteam.aether.entity.ai.goal.FallingRandomStrollGoal;
import com.aetherteam.aether.entity.ai.goal.MoaFollowGoal;
import com.aetherteam.aether.entity.ai.navigator.FallPathNavigation;

import com.aetherteam.aether.entity.monster.AechorPlant;
import com.aetherteam.aether.entity.monster.Swet;
import com.aetherteam.aether.item.miscellaneous.MoaEggItem;
import com.aetherteam.aether.item.AetherItems;
import com.aetherteam.aether.AetherTags;
Expand All @@ -31,11 +34,13 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.*;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.ai.navigation.PathNavigation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -78,9 +83,12 @@ protected void registerGoals() {
this.goalSelector.addGoal(0, new FloatGoal(this));
this.goalSelector.addGoal(1, new PanicGoal(this, 0.65));
this.goalSelector.addGoal(2, new MoaFollowGoal(this, 1.0));
this.goalSelector.addGoal(3, new FallingRandomStrollGoal(this, 0.35));
this.goalSelector.addGoal(4, new LookAtPlayerGoal(this, Player.class, 6.0F));
this.goalSelector.addGoal(3, new MeleeAttackGoal(this, 1.0D, true));
this.goalSelector.addGoal(4, new FallingRandomStrollGoal(this, 0.35));
this.goalSelector.addGoal(5, new LookAtPlayerGoal(this, Player.class, 6.0F));
this.goalSelector.addGoal(6, new RandomLookAroundGoal(this));
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Swet.class, false, (livingEntity) -> this.getFollowing() == null && this.isPlayerGrown()));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, AechorPlant.class, false, (livingEntity) -> this.getFollowing() == null && this.isPlayerGrown()));
}

@Nonnull
Expand All @@ -93,7 +101,9 @@ protected PathNavigation createNavigation(@Nonnull Level level) {
public static AttributeSupplier.Builder createMobAttributes() {
return Mob.createMobAttributes()
.add(Attributes.MAX_HEALTH, 35.0)
.add(Attributes.MOVEMENT_SPEED, 1.0);
.add(Attributes.MOVEMENT_SPEED, 1.0)
.add(Attributes.FOLLOW_RANGE, 16.0)
.add(Attributes.ATTACK_DAMAGE, 5.0);
}

@Override
Expand Down Expand Up @@ -146,7 +156,8 @@ public void tick() {
super.tick();
AttributeInstance gravity = this.getAttribute(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get());
if (gravity != null) {
double fallSpeed = Math.max(gravity.getValue() * -1.25, -0.1);
double max = this.isVehicle() ? -0.5 : -0.1;
double fallSpeed = Math.max(gravity.getValue() * -1.25, max);
if (this.getDeltaMovement().y < fallSpeed && !this.playerTriedToCrouch()) {
this.setDeltaMovement(this.getDeltaMovement().x, fallSpeed, this.getDeltaMovement().z);
this.hasImpulse = true;
Expand Down Expand Up @@ -291,6 +302,14 @@ public void spawnExplosionParticle() {
}
}

@Override
protected void removePassenger(Entity passenger) {
super.removePassenger(passenger);
if (passenger instanceof Player player && (this.getFollowing() == null || this.getFollowing().toString().equals(player.getUUID().toString()))) {
this.setFollowing(player.getUUID());
}
}

@Nullable
public MoaType getMoaType() {
return AetherMoaTypes.get(this.entityData.get(DATA_MOA_TYPE_ID));
Expand Down Expand Up @@ -461,6 +480,11 @@ public boolean isFood(@Nonnull ItemStack stack) {
return false;
}

@Override
public boolean canBeAffected(MobEffectInstance effect) {
return (effect.getEffect() != AetherEffects.INEBRIATION.get() || !this.isPlayerGrown()) && super.canBeAffected(effect);
}

@Override
public float getSpeed() {
MoaType moaType = this.getMoaType();
Expand Down Expand Up @@ -490,7 +514,11 @@ public float getSteeringSpeed() {

@Override
public float getFlyingSpeed() {
return this.getSteeringSpeed() * 0.45F;
if (this.isVehicle()) {
return this.getSteeringSpeed() * 0.45F;
} else {
return this.getSteeringSpeed() * 0.025F;
}
}

@Override
Expand Down

0 comments on commit 784d40f

Please sign in to comment.