Renaming goals, second pass
This commit is contained in:
@@ -2,9 +2,9 @@ package com.willfp.eco.core.entities.ai;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalAvoidEntity;
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalBreakDoor;
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalBreakDoors;
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalBreatheAir;
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalEatGround;
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalEatGrass;
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalFleeSun;
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalFloat;
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalFollowBoats;
|
||||
@@ -51,9 +51,9 @@ public final class EntityGoals {
|
||||
|
||||
static {
|
||||
register(EntityGoalAvoidEntity.DESERIALIZER);
|
||||
register(EntityGoalBreakDoor.DESERIALIZER);
|
||||
register(EntityGoalBreakDoors.DESERIALIZER);
|
||||
register(EntityGoalBreatheAir.DESERIALIZER);
|
||||
register(EntityGoalEatGround.DESERIALIZER);
|
||||
register(EntityGoalEatGrass.DESERIALIZER);
|
||||
register(EntityGoalFleeSun.DESERIALIZER);
|
||||
register(EntityGoalFloat.DESERIALIZER);
|
||||
register(EntityGoalFollowBoats.DESERIALIZER);
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.willfp.eco.core.entities.ai.target.TargetGoalNearestAttackable;
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalNearestAttackableWitch;
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalNearestHealableRaider;
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalNonTameRandom;
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalOwnerHurt;
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalOwnerTarget;
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalOwnerHurtBy;
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalResetUniversalAnger;
|
||||
import com.willfp.eco.core.serialization.KeyedDeserializer;
|
||||
@@ -33,7 +33,7 @@ public final class TargetGoals {
|
||||
register(TargetGoalNearestAttackableWitch.DESERIALIZER);
|
||||
register(TargetGoalNearestHealableRaider.DESERIALIZER);
|
||||
register(TargetGoalNonTameRandom.DESERIALIZER);
|
||||
register(TargetGoalOwnerHurt.DESERIALIZER);
|
||||
register(TargetGoalOwnerTarget.DESERIALIZER);
|
||||
register(TargetGoalOwnerHurtBy.DESERIALIZER);
|
||||
register(TargetGoalResetUniversalAnger.DESERIALIZER);
|
||||
}
|
||||
|
||||
@@ -13,21 +13,21 @@ import org.jetbrains.annotations.Nullable;
|
||||
*
|
||||
* @param maxProgress The time taken to break the door (any integer above 240).
|
||||
*/
|
||||
public record EntityGoalBreakDoor(
|
||||
public record EntityGoalBreakDoors(
|
||||
int maxProgress
|
||||
) implements EntityGoal<Mob> {
|
||||
/**
|
||||
* The deserializer for the goal.
|
||||
*/
|
||||
public static final KeyedDeserializer<EntityGoalBreakDoor> DESERIALIZER = new EntityGoalBreakDoor.Deserializer();
|
||||
public static final KeyedDeserializer<EntityGoalBreakDoors> DESERIALIZER = new EntityGoalBreakDoors.Deserializer();
|
||||
|
||||
/**
|
||||
* Deserialize configs into the goal.
|
||||
*/
|
||||
private static final class Deserializer implements KeyedDeserializer<EntityGoalBreakDoor> {
|
||||
private static final class Deserializer implements KeyedDeserializer<EntityGoalBreakDoors> {
|
||||
@Override
|
||||
@Nullable
|
||||
public EntityGoalBreakDoor deserialize(@NotNull final Config config) {
|
||||
public EntityGoalBreakDoors deserialize(@NotNull final Config config) {
|
||||
if (!(
|
||||
config.has("maxProgress")
|
||||
)) {
|
||||
@@ -35,7 +35,7 @@ public record EntityGoalBreakDoor(
|
||||
}
|
||||
|
||||
try {
|
||||
return new EntityGoalBreakDoor(
|
||||
return new EntityGoalBreakDoors(
|
||||
config.getInt("maxProgress")
|
||||
);
|
||||
} catch (Exception e) {
|
||||
@@ -51,7 +51,7 @@ public record EntityGoalBreakDoor(
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return NamespacedKey.minecraft("break_door");
|
||||
return NamespacedKey.minecraft("break_doors");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,26 +10,26 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Allows an entity to eat the ground.
|
||||
*/
|
||||
public record EntityGoalEatGround(
|
||||
public record EntityGoalEatGrass(
|
||||
) implements EntityGoal<Mob> {
|
||||
/**
|
||||
* The deserializer for the goal.
|
||||
*/
|
||||
public static final KeyedDeserializer<EntityGoalEatGround> DESERIALIZER = new EntityGoalEatGround.Deserializer();
|
||||
public static final KeyedDeserializer<EntityGoalEatGrass> DESERIALIZER = new EntityGoalEatGrass.Deserializer();
|
||||
|
||||
/**
|
||||
* Deserialize configs into the goal.
|
||||
*/
|
||||
private static final class Deserializer implements KeyedDeserializer<EntityGoalEatGround> {
|
||||
private static final class Deserializer implements KeyedDeserializer<EntityGoalEatGrass> {
|
||||
@Override
|
||||
public EntityGoalEatGround deserialize(@NotNull final Config config) {
|
||||
return new EntityGoalEatGround();
|
||||
public EntityGoalEatGrass deserialize(@NotNull final Config config) {
|
||||
return new EntityGoalEatGrass();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return NamespacedKey.minecraft("eat_ground");
|
||||
return NamespacedKey.minecraft("eat_grass");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,26 +10,26 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Allows an entity to react when the owner hits a target.
|
||||
*/
|
||||
public record TargetGoalOwnerHurt(
|
||||
public record TargetGoalOwnerTarget(
|
||||
) implements TargetGoal<Tameable> {
|
||||
/**
|
||||
* The deserializer for the goal.
|
||||
*/
|
||||
public static final KeyedDeserializer<TargetGoalOwnerHurt> DESERIALIZER = new TargetGoalOwnerHurt.Deserializer();
|
||||
public static final KeyedDeserializer<TargetGoalOwnerTarget> DESERIALIZER = new TargetGoalOwnerTarget.Deserializer();
|
||||
|
||||
/**
|
||||
* Deserialize configs into the goal.
|
||||
*/
|
||||
private static final class Deserializer implements KeyedDeserializer<TargetGoalOwnerHurt> {
|
||||
private static final class Deserializer implements KeyedDeserializer<TargetGoalOwnerTarget> {
|
||||
@Override
|
||||
public TargetGoalOwnerHurt deserialize(@NotNull final Config config) {
|
||||
return new TargetGoalOwnerHurt();
|
||||
public TargetGoalOwnerTarget deserialize(@NotNull final Config config) {
|
||||
return new TargetGoalOwnerTarget();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return NamespacedKey.minecraft("owner_hurt");
|
||||
return NamespacedKey.minecraft("owner_target");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package com.willfp.eco.internal.spigot.proxy.common.ai
|
||||
import com.willfp.eco.core.entities.ai.CustomGoal
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalAvoidEntity
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalBreakDoor
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalBreakDoors
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalBreatheAir
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalEatGround
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalEatGrass
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalFleeSun
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalFloat
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalFollowBoats
|
||||
@@ -35,9 +35,9 @@ import com.willfp.eco.core.entities.ai.entity.EntityGoalUseItem
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalWaterAvoidingRandomFlying
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalWaterAvoidingRandomStroll
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.AvoidEntityGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.BreakDoorGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.BreakDoorsGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.BreatheAirGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.EatGroundGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.EatGrassGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.FleeSunGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.FloatGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.FollowBoatsGoalFactory
|
||||
@@ -79,9 +79,9 @@ fun <T : EntityGoal<*>> T.getGoalFactory(): EntityGoalFactory<T>? {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return when (this) {
|
||||
is EntityGoalAvoidEntity -> AvoidEntityGoalFactory
|
||||
is EntityGoalBreakDoor -> BreakDoorGoalFactory
|
||||
is EntityGoalBreakDoors -> BreakDoorsGoalFactory
|
||||
is EntityGoalBreatheAir -> BreatheAirGoalFactory
|
||||
is EntityGoalEatGround -> EatGroundGoalFactory
|
||||
is EntityGoalEatGrass -> EatGrassGoalFactory
|
||||
is EntityGoalFleeSun -> FleeSunGoalFactory
|
||||
is EntityGoalFloat -> FloatGoalFactory
|
||||
is EntityGoalFollowBoats -> FollowBoatsGoalFactory
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.willfp.eco.core.entities.ai.target.TargetGoalNearestAttackable
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalNearestAttackableWitch
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalNearestHealableRaider
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalNonTameRandom
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalOwnerHurt
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalOwnerTarget
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalOwnerHurtBy
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.target.HurtByGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.target.NearestAttackableGoalFactory
|
||||
@@ -15,7 +15,7 @@ import com.willfp.eco.internal.spigot.proxy.common.ai.target.NearestAttackableWi
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.target.NearestHealableRaiderGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.target.NonTameRandomGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.target.OwnerHurtByGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.target.OwnerHurtGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.target.OwnerTargetGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.commonsProvider
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
@@ -34,7 +34,7 @@ fun <T : TargetGoal<*>> T.getGoalFactory(): TargetGoalFactory<T>? {
|
||||
is TargetGoalNearestHealableRaider -> NearestHealableRaiderGoalFactory
|
||||
is TargetGoalNonTameRandom -> NonTameRandomGoalFactory
|
||||
is TargetGoalOwnerHurtBy -> OwnerHurtByGoalFactory
|
||||
is TargetGoalOwnerHurt -> OwnerHurtGoalFactory
|
||||
is TargetGoalOwnerTarget -> OwnerTargetGoalFactory
|
||||
is CustomGoal<*> -> CustomGoalFactory
|
||||
else -> null
|
||||
} as TargetGoalFactory<T>?
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalBreakDoor
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalBreakDoors
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.BreakDoorGoal
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
|
||||
object BreakDoorGoalFactory : EntityGoalFactory<EntityGoalBreakDoor> {
|
||||
override fun create(apiGoal: EntityGoalBreakDoor, entity: PathfinderMob): Goal {
|
||||
object BreakDoorsGoalFactory : EntityGoalFactory<EntityGoalBreakDoors> {
|
||||
override fun create(apiGoal: EntityGoalBreakDoors, entity: PathfinderMob): Goal {
|
||||
return BreakDoorGoal(
|
||||
entity,
|
||||
apiGoal.maxProgress
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalEatGround
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalEatGrass
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.EatBlockGoal
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
|
||||
object EatGroundGoalFactory : EntityGoalFactory<EntityGoalEatGround> {
|
||||
override fun create(apiGoal: EntityGoalEatGround, entity: PathfinderMob): Goal {
|
||||
object EatGrassGoalFactory : EntityGoalFactory<EntityGoalEatGrass> {
|
||||
override fun create(apiGoal: EntityGoalEatGrass, entity: PathfinderMob): Goal {
|
||||
return EatBlockGoal(
|
||||
entity
|
||||
)
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.target
|
||||
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalOwnerHurt
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalOwnerTarget
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.TargetGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.TamableAnimal
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.target.OwnerHurtTargetGoal
|
||||
|
||||
object OwnerHurtGoalFactory : TargetGoalFactory<TargetGoalOwnerHurt> {
|
||||
override fun create(apiGoal: TargetGoalOwnerHurt, entity: PathfinderMob): Goal? {
|
||||
object OwnerTargetGoalFactory : TargetGoalFactory<TargetGoalOwnerTarget> {
|
||||
override fun create(apiGoal: TargetGoalOwnerTarget, entity: PathfinderMob): Goal? {
|
||||
return OwnerHurtTargetGoal(
|
||||
entity as? TamableAnimal ?: return null
|
||||
)
|
||||
Reference in New Issue
Block a user