Began refactoring NMS
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package com.willfp.eco.core.entities.ai.goals;
|
||||
package com.willfp.eco.core.entities.ai;
|
||||
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -7,8 +7,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Base interface for all custom goals.
|
||||
* <p>
|
||||
* Can be used both for entity goals and target goals.
|
||||
*
|
||||
* @param <T> The type of mob that this goal can be applied to.
|
||||
*/
|
||||
public interface CustomGoal extends EntityGoal, TargetGoal {
|
||||
public interface CustomGoal<T extends Mob> extends EntityGoal<T>, TargetGoal<T> {
|
||||
/**
|
||||
* Initialize the goal with a mob.
|
||||
* <p>
|
||||
@@ -16,7 +18,7 @@ public interface CustomGoal extends EntityGoal, TargetGoal {
|
||||
*
|
||||
* @param mob The mob.
|
||||
*/
|
||||
void initialize(@NotNull Mob mob);
|
||||
void initialize(@NotNull T mob);
|
||||
|
||||
/**
|
||||
* Get if the goal can be used.
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.willfp.eco.core.entities.ai;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.goals.TargetGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -22,7 +20,7 @@ public interface EntityController<T extends Mob> {
|
||||
* @return The entity controller.
|
||||
*/
|
||||
EntityController<T> addTargetGoal(int priority,
|
||||
@NotNull TargetGoal goal);
|
||||
@NotNull TargetGoal<? super T> goal);
|
||||
|
||||
/**
|
||||
* Remove all target goals from the entity.
|
||||
@@ -41,7 +39,7 @@ public interface EntityController<T extends Mob> {
|
||||
* @param goal The goal.
|
||||
* @return The entity controller.
|
||||
*/
|
||||
EntityController<T> removeTargetGoal(@NotNull TargetGoal goal);
|
||||
EntityController<T> removeTargetGoal(@NotNull TargetGoal<? super T> goal);
|
||||
|
||||
/**
|
||||
* Add an entity goal to the entity.
|
||||
@@ -53,7 +51,7 @@ public interface EntityController<T extends Mob> {
|
||||
* @return The entity controller.
|
||||
*/
|
||||
EntityController<T> addEntityGoal(int priority,
|
||||
@NotNull EntityGoal goal);
|
||||
@NotNull EntityGoal<? super T> goal);
|
||||
|
||||
/**
|
||||
* Remove an entity goal from the entity.
|
||||
@@ -63,7 +61,7 @@ public interface EntityController<T extends Mob> {
|
||||
* @param goal The goal.
|
||||
* @return The entity controller.
|
||||
*/
|
||||
EntityController<T> removeEntityGoal(@NotNull EntityGoal goal);
|
||||
EntityController<T> removeEntityGoal(@NotNull EntityGoal<? super T> goal);
|
||||
|
||||
/**
|
||||
* Remove all entity goals from the entity.
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.willfp.eco.core.entities.ai;
|
||||
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* A goal for entity AI.
|
||||
*
|
||||
* @param <T> The type of mob that the goal can be applied to.
|
||||
*/
|
||||
public interface EntityGoal<T extends Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.willfp.eco.core.entities.ai;
|
||||
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* A goal for entity target AI.
|
||||
*
|
||||
* @param <T> The type of mob that the goal can be applied to.
|
||||
*/
|
||||
public interface TargetGoal<T extends Mob> {
|
||||
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
@@ -21,6 +22,6 @@ public record EntityGoalAvoidEntity(
|
||||
double slowSpeed,
|
||||
double fastSpeed,
|
||||
@NotNull Predicate<LivingEntity> filter
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Break doors.
|
||||
@@ -9,6 +10,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
*/
|
||||
public record EntityGoalBreakDoor(
|
||||
int maxProgress
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Breathe air.
|
||||
*/
|
||||
public record EntityGoalBreatheAir(
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Eat block.
|
||||
*/
|
||||
public record EntityGoalEatBlock(
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Flee sun.
|
||||
*
|
||||
* @param speed The speed at which to flee.
|
||||
*/
|
||||
public record EntityGoalFleeSun(
|
||||
double speed
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Float in water.
|
||||
*/
|
||||
public record EntityGoalFloat(
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Follow boats.
|
||||
*/
|
||||
public record EntityGoalFollowBoats(
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Follow other mobs.
|
||||
@@ -13,6 +14,6 @@ public record EntityGoalFollowMobs(
|
||||
double speed,
|
||||
double minDistance,
|
||||
double maxDistance
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -15,6 +16,6 @@ public record EntityGoalInteract(
|
||||
@NotNull Class<? extends LivingEntity> targetClass,
|
||||
double range,
|
||||
double chance
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Leap at target.
|
||||
*
|
||||
* @param velocity The leap velocity.
|
||||
*/
|
||||
public record EntityGoalLeapAtTarget(
|
||||
double velocity
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Look at the player.
|
||||
@@ -11,6 +12,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
public record EntityGoalLookAtPlayer(
|
||||
double range,
|
||||
double chance
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Melee attack target.
|
||||
@@ -11,6 +12,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
public record EntityGoalMeleeAttack(
|
||||
double speed,
|
||||
boolean pauseWhenMobIdle
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Move back to village.
|
||||
@@ -11,6 +12,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
public record EntityGoalMoveBackToVillage(
|
||||
double speed,
|
||||
boolean canDespawn
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
@@ -17,6 +18,6 @@ public record EntityGoalMoveThroughVillage(
|
||||
boolean onlyAtNight,
|
||||
int distance,
|
||||
BooleanSupplier canPassThroughDoorsGetter
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Move towards restriction.
|
||||
@@ -9,6 +10,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
*/
|
||||
public record EntityGoalMoveTowardsRestriction(
|
||||
double speed
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Move towards target.
|
||||
@@ -11,6 +12,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
public record EntityGoalMoveTowardsTarget(
|
||||
double speed,
|
||||
double maxDistance
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Attack like an ocelot.
|
||||
*/
|
||||
public record EntityGoalOcelotAttack(
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Open doors.
|
||||
*
|
||||
* @param delayedClose If closing the door should be delayed.
|
||||
*/
|
||||
public record EntityGoalOpenDoors(
|
||||
boolean delayedClose
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Panic.
|
||||
*
|
||||
* @param speed The speed at which to panic.
|
||||
*/
|
||||
public record EntityGoalPanic(
|
||||
double speed
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Look around randomly.
|
||||
*/
|
||||
public record EntityGoalRandomLookAround(
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Move around randomly.
|
||||
@@ -13,6 +14,6 @@ public record EntityGoalRandomStroll(
|
||||
double speed,
|
||||
int interval,
|
||||
boolean canDespawn
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Swim around randomly.
|
||||
@@ -11,6 +12,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
public record EntityGoalRandomSwimming(
|
||||
double speed,
|
||||
int interval
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Ranged attack.
|
||||
@@ -17,6 +18,6 @@ public record EntityGoalRangedAttack(
|
||||
int minInterval,
|
||||
int maxInterval,
|
||||
double maxRange
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Monster;
|
||||
|
||||
/**
|
||||
* Ranged attack.
|
||||
@@ -15,6 +16,6 @@ public record EntityGoalRangedBowAttack(
|
||||
double speed,
|
||||
int attackInterval,
|
||||
double range
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Monster> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Monster;
|
||||
|
||||
/**
|
||||
* Ranged attack.
|
||||
@@ -13,6 +14,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
public record EntityGoalRangedCrossbowAttack(
|
||||
double speed,
|
||||
double range
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Monster> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Restrict sun.
|
||||
*/
|
||||
public record EntityGoalRestrictSun(
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Stroll through village.
|
||||
*
|
||||
* @param searchRange The search range.
|
||||
*/
|
||||
public record EntityGoalStrollThroughVillage(
|
||||
int searchRange
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -16,6 +17,6 @@ public record EntityGoalTempt(
|
||||
double speed,
|
||||
Collection<ItemStack> items,
|
||||
boolean canBeScared
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Try to find water.
|
||||
*/
|
||||
public record EntityGoalTryFindWater(
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -19,6 +20,6 @@ public record EntityGoalUseItem(
|
||||
@NotNull ItemStack item,
|
||||
@NotNull Sound sound,
|
||||
@NotNull Predicate<LivingEntity> condition
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Fly randomly while avoiding water.
|
||||
*
|
||||
* @param speed The speed.
|
||||
*/
|
||||
public record EntityGoalWaterAvoidingRandomFlying(
|
||||
double speed
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
package com.willfp.eco.core.entities.ai.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
|
||||
/**
|
||||
* Stroll randomly while avoiding water.
|
||||
@@ -11,6 +12,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
public record EntityGoalWaterAvoidingRandomStroll(
|
||||
double speed,
|
||||
double chance
|
||||
) implements EntityGoal {
|
||||
) implements EntityGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals;
|
||||
|
||||
/**
|
||||
* A goal for entity AI.
|
||||
*/
|
||||
public interface EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals;
|
||||
|
||||
/**
|
||||
* A goal for entity AI.
|
||||
*/
|
||||
public interface TargetGoal {
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Breathe air.
|
||||
*/
|
||||
public record EntityGoalBreatheAir(
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Eat block.
|
||||
*/
|
||||
public record EntityGoalEatBlock(
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Flee sun.
|
||||
*
|
||||
* @param speed The speed at which to flee.
|
||||
*/
|
||||
public record EntityGoalFleeSun(
|
||||
double speed
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Float in water.
|
||||
*/
|
||||
public record EntityGoalFloat(
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Follow boats.
|
||||
*/
|
||||
public record EntityGoalFollowBoats(
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Leap at target.
|
||||
*
|
||||
* @param velocity The leap velocity.
|
||||
*/
|
||||
public record EntityGoalLeapAtTarget(
|
||||
double velocity
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Attack like an ocelot.
|
||||
*/
|
||||
public record EntityGoalOcelotAttack(
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Open doors.
|
||||
*
|
||||
* @param delayedClose If closing the door should be delayed.
|
||||
*/
|
||||
public record EntityGoalOpenDoors(
|
||||
boolean delayedClose
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Panic.
|
||||
*
|
||||
* @param speed The speed at which to panic.
|
||||
*/
|
||||
public record EntityGoalPanic(
|
||||
double speed
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Look around randomly.
|
||||
*/
|
||||
public record EntityGoalRandomLookAround(
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Restrict sun.
|
||||
*/
|
||||
public record EntityGoalRestrictSun(
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Stroll through village.
|
||||
*
|
||||
* @param searchRange The search range.
|
||||
*/
|
||||
public record EntityGoalStrollThroughVillage(
|
||||
int searchRange
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Try to find water.
|
||||
*/
|
||||
public record EntityGoalTryFindWater(
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.entity;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
|
||||
/**
|
||||
* Fly randomly while avoiding water.
|
||||
*
|
||||
* @param speed The speed.
|
||||
*/
|
||||
public record EntityGoalWaterAvoidingRandomFlying(
|
||||
double speed
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.target;
|
||||
package com.willfp.eco.core.entities.ai.target;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.TargetGoal;
|
||||
import com.willfp.eco.core.entities.ai.TargetGoal;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -12,6 +13,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
@SuppressWarnings({"varargs", "unchecked"})
|
||||
public record TargetGoalHurtBy(
|
||||
@NotNull Class<? extends LivingEntity>... blacklist
|
||||
) implements TargetGoal {
|
||||
) implements TargetGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.willfp.eco.core.entities.ai.goals.target;
|
||||
package com.willfp.eco.core.entities.ai.target;
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.TargetGoal;
|
||||
import com.willfp.eco.core.entities.ai.TargetGoal;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -13,6 +14,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
public record TargetGoalNearestAttackable(
|
||||
@NotNull Class<? extends LivingEntity> targetClass,
|
||||
boolean checkVisibility
|
||||
) implements TargetGoal {
|
||||
) implements TargetGoal<Mob> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.CustomGoal
|
||||
import com.willfp.eco.core.entities.ai.CustomGoal
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
|
||||
object CustomGoalFactory : EntityGoalFactory<CustomGoal>, TargetGoalFactory<CustomGoal> {
|
||||
override fun create(apiGoal: CustomGoal, entity: PathfinderMob): Goal {
|
||||
object CustomGoalFactory : EntityGoalFactory<CustomGoal<*>>, TargetGoalFactory<CustomGoal<*>> {
|
||||
override fun create(apiGoal: CustomGoal<*>, entity: PathfinderMob): Goal {
|
||||
return NMSCustomGoal(apiGoal, entity)
|
||||
}
|
||||
}
|
||||
|
||||
private class NMSCustomGoal(
|
||||
private val customEntityGoal: CustomGoal,
|
||||
private class NMSCustomGoal<T : org.bukkit.entity.Mob>(
|
||||
private val customEntityGoal: CustomGoal<T>,
|
||||
entity: PathfinderMob
|
||||
) : Goal() {
|
||||
init {
|
||||
customEntityGoal.initialize(entity.bukkitMob)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
customEntityGoal.initialize(entity.bukkitMob as T)
|
||||
}
|
||||
|
||||
override fun canUse(): Boolean {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai
|
||||
|
||||
import com.willfp.eco.core.entities.ai.EntityController
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal
|
||||
import com.willfp.eco.core.entities.ai.goals.TargetGoal
|
||||
import com.willfp.eco.core.entities.ai.EntityGoal
|
||||
import com.willfp.eco.core.entities.ai.TargetGoal
|
||||
import com.willfp.eco.internal.spigot.proxy.common.commonsProvider
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import org.bukkit.entity.Mob
|
||||
@@ -10,7 +10,7 @@ import org.bukkit.entity.Mob
|
||||
class EcoEntityController<T : Mob>(
|
||||
private val handle: T
|
||||
) : EntityController<T> {
|
||||
override fun addEntityGoal(priority: Int, goal: EntityGoal): EntityController<T> {
|
||||
override fun addEntityGoal(priority: Int, goal: EntityGoal<in T>): EntityController<T> {
|
||||
val nms = getNms() ?: return this
|
||||
|
||||
nms.goalSelector.addGoal(
|
||||
@@ -21,7 +21,7 @@ class EcoEntityController<T : Mob>(
|
||||
return this
|
||||
}
|
||||
|
||||
override fun removeEntityGoal(goal: EntityGoal): EntityController<T> {
|
||||
override fun removeEntityGoal(goal: EntityGoal<in T>): EntityController<T> {
|
||||
val nms = getNms() ?: return this
|
||||
nms.goalSelector.removeGoal(
|
||||
goal.getGoalFactory()?.create(goal, nms) ?: return this
|
||||
@@ -36,7 +36,7 @@ class EcoEntityController<T : Mob>(
|
||||
return this
|
||||
}
|
||||
|
||||
override fun addTargetGoal(priority: Int, goal: TargetGoal): EntityController<T> {
|
||||
override fun addTargetGoal(priority: Int, goal: TargetGoal<in T>): EntityController<T> {
|
||||
val nms = getNms() ?: return this
|
||||
|
||||
nms.targetSelector.addGoal(
|
||||
@@ -48,7 +48,7 @@ class EcoEntityController<T : Mob>(
|
||||
return this
|
||||
}
|
||||
|
||||
override fun removeTargetGoal(goal: TargetGoal): EntityController<T> {
|
||||
override fun removeTargetGoal(goal: TargetGoal<in T>): EntityController<T> {
|
||||
val nms = getNms() ?: return this
|
||||
nms.targetSelector.removeGoal(
|
||||
goal.getGoalFactory()?.create(goal, nms) ?: return this
|
||||
|
||||
@@ -1,82 +1,76 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.CustomGoal
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalAvoidEntity
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalBreakDoor
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalBreatheAir
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalEatBlock
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalFleeSun
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalFloat
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalFollowBoats
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalFollowMobs
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalInteract
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalLeapAtTarget
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalLookAtPlayer
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalMeleeAttack
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalMoveBackToVillage
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalMoveThroughVillage
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalMoveTowardsRestriction
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalMoveTowardsTarget
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalOcelotAttack
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalOpenDoors
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalPanic
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRandomLookAround
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRandomStroll
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRandomSwimming
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRangedAttack
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRangedBowAttack
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRangedCrossbowAttack
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRestrictSun
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalStrollThroughVillage
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalTempt
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalTryFindWater
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalUseItem
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalWaterAvoidingRandomFlying
|
||||
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalWaterAvoidingRandomStroll
|
||||
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.EntityGoalBreatheAir
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalEatBlock
|
||||
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
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalFollowMobs
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalInteract
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalLeapAtTarget
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalLookAtPlayer
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalMeleeAttack
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveBackToVillage
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveThroughVillage
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveTowardsRestriction
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveTowardsTarget
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalOcelotAttack
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalOpenDoors
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalPanic
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRandomLookAround
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRandomStroll
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRandomSwimming
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRangedAttack
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRangedBowAttack
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRangedCrossbowAttack
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRestrictSun
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalStrollThroughVillage
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalTempt
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalTryFindWater
|
||||
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.BreatheAirGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.EatBlockGoalFactory
|
||||
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
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.FollowMobsGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.InteractGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.LeapAtTargetGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.LookAtPlayerGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.MeleeAttackGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.MoveBackToVillageGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.MoveThroughVillageGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.MoveTowardsRestrictionGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.MoveTowardsTargetGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.OcelotAttackGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.OpenDoorsGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.PanicGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RandomLookAroundGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RandomStrollGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RandomSwimmingGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RangedAttackGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RangedBowAttackGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RangedCrossbowAttackGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RestrictSunGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.StrollThroughVillageGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.TemptGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.TryFindWaterGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.entity.UseItemGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.commonsProvider
|
||||
import net.minecraft.sounds.SoundEvent
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.AvoidEntityGoal
|
||||
import net.minecraft.world.entity.ai.goal.BreakDoorGoal
|
||||
import net.minecraft.world.entity.ai.goal.BreathAirGoal
|
||||
import net.minecraft.world.entity.ai.goal.EatBlockGoal
|
||||
import net.minecraft.world.entity.ai.goal.FleeSunGoal
|
||||
import net.minecraft.world.entity.ai.goal.FloatGoal
|
||||
import net.minecraft.world.entity.ai.goal.FollowBoatGoal
|
||||
import net.minecraft.world.entity.ai.goal.FollowMobGoal
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.InteractGoal
|
||||
import net.minecraft.world.entity.ai.goal.LeapAtTargetGoal
|
||||
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal
|
||||
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal
|
||||
import net.minecraft.world.entity.ai.goal.MoveBackToVillageGoal
|
||||
import net.minecraft.world.entity.ai.goal.MoveThroughVillageGoal
|
||||
import net.minecraft.world.entity.ai.goal.MoveTowardsRestrictionGoal
|
||||
import net.minecraft.world.entity.ai.goal.MoveTowardsTargetGoal
|
||||
import net.minecraft.world.entity.ai.goal.OcelotAttackGoal
|
||||
import net.minecraft.world.entity.ai.goal.OpenDoorGoal
|
||||
import net.minecraft.world.entity.ai.goal.PanicGoal
|
||||
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal
|
||||
import net.minecraft.world.entity.ai.goal.RandomStrollGoal
|
||||
import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal
|
||||
import net.minecraft.world.entity.ai.goal.RangedAttackGoal
|
||||
import net.minecraft.world.entity.ai.goal.RangedBowAttackGoal
|
||||
import net.minecraft.world.entity.ai.goal.RangedCrossbowAttackGoal
|
||||
import net.minecraft.world.entity.ai.goal.RestrictSunGoal
|
||||
import net.minecraft.world.entity.ai.goal.StrollThroughVillageGoal
|
||||
import net.minecraft.world.entity.ai.goal.TemptGoal
|
||||
import net.minecraft.world.entity.ai.goal.TryFindWaterGoal
|
||||
import net.minecraft.world.entity.ai.goal.UseItemGoal
|
||||
import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomFlyingGoal
|
||||
import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal
|
||||
import net.minecraft.world.entity.monster.CrossbowAttackMob
|
||||
import net.minecraft.world.entity.monster.Monster
|
||||
import net.minecraft.world.entity.monster.RangedAttackMob
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
|
||||
fun <T : EntityGoal> T.getGoalFactory(): EntityGoalFactory<T>? {
|
||||
fun <T : EntityGoal<*>> T.getGoalFactory(): EntityGoalFactory<T>? {
|
||||
val versionSpecific = commonsProvider.getVersionSpecificGoalFactory(this)
|
||||
if (versionSpecific != null) {
|
||||
return versionSpecific
|
||||
@@ -116,321 +110,21 @@ fun <T : EntityGoal> T.getGoalFactory(): EntityGoalFactory<T>? {
|
||||
is EntityGoalUseItem -> UseItemGoalFactory
|
||||
is EntityGoalWaterAvoidingRandomFlying -> WaterAvoidingRandomFlyingGoalFactory
|
||||
is EntityGoalWaterAvoidingRandomStroll -> WaterAvoidingRandomStrollGoalFactory
|
||||
is CustomGoal -> CustomGoalFactory
|
||||
is CustomGoal<*> -> CustomGoalFactory
|
||||
else -> null
|
||||
} as EntityGoalFactory<T>?
|
||||
}
|
||||
|
||||
interface EntityGoalFactory<T : EntityGoal> {
|
||||
interface EntityGoalFactory<T : EntityGoal<*>> {
|
||||
fun create(apiGoal: T, entity: PathfinderMob): Goal?
|
||||
}
|
||||
|
||||
object AvoidEntityGoalFactory : EntityGoalFactory<EntityGoalAvoidEntity> {
|
||||
override fun create(apiGoal: EntityGoalAvoidEntity, entity: PathfinderMob): Goal {
|
||||
return AvoidEntityGoal(
|
||||
entity,
|
||||
apiGoal.avoidClass.toNMSClass(),
|
||||
apiGoal.fleeDistance.toFloat(),
|
||||
apiGoal.slowSpeed,
|
||||
apiGoal.fastSpeed
|
||||
) { apiGoal.filter.test(it.toBukkitEntity()) }
|
||||
}
|
||||
}
|
||||
|
||||
object BreakDoorGoalFactory : EntityGoalFactory<EntityGoalBreakDoor> {
|
||||
override fun create(apiGoal: EntityGoalBreakDoor, entity: PathfinderMob): Goal {
|
||||
return BreakDoorGoal(
|
||||
entity,
|
||||
apiGoal.maxProgress
|
||||
) { true }
|
||||
}
|
||||
}
|
||||
|
||||
object BreatheAirGoalFactory : EntityGoalFactory<EntityGoalBreatheAir> {
|
||||
override fun create(apiGoal: EntityGoalBreatheAir, entity: PathfinderMob): Goal {
|
||||
return BreathAirGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object EatBlockGoalFactory : EntityGoalFactory<EntityGoalEatBlock> {
|
||||
override fun create(apiGoal: EntityGoalEatBlock, entity: PathfinderMob): Goal {
|
||||
return EatBlockGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object FleeSunGoalFactory : EntityGoalFactory<EntityGoalFleeSun> {
|
||||
override fun create(apiGoal: EntityGoalFleeSun, entity: PathfinderMob): Goal {
|
||||
return FleeSunGoal(
|
||||
entity,
|
||||
apiGoal.speed
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object FloatGoalFactory : EntityGoalFactory<EntityGoalFloat> {
|
||||
override fun create(apiGoal: EntityGoalFloat, entity: PathfinderMob): Goal {
|
||||
return FloatGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object FollowBoatsGoalFactory : EntityGoalFactory<EntityGoalFollowBoats> {
|
||||
override fun create(apiGoal: EntityGoalFollowBoats, entity: PathfinderMob): Goal {
|
||||
return FollowBoatGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object FollowMobsGoalFactory : EntityGoalFactory<EntityGoalFollowMobs> {
|
||||
override fun create(apiGoal: EntityGoalFollowMobs, entity: PathfinderMob): Goal {
|
||||
return FollowMobGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.minDistance.toFloat(),
|
||||
apiGoal.maxDistance.toFloat(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object InteractGoalFactory : EntityGoalFactory<EntityGoalInteract> {
|
||||
override fun create(apiGoal: EntityGoalInteract, entity: PathfinderMob): Goal {
|
||||
return InteractGoal(
|
||||
entity,
|
||||
apiGoal.targetClass.toNMSClass(),
|
||||
apiGoal.range.toFloat(),
|
||||
apiGoal.chance.toFloat() / 100f,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object LeapAtTargetGoalFactory : EntityGoalFactory<EntityGoalLeapAtTarget> {
|
||||
override fun create(apiGoal: EntityGoalLeapAtTarget, entity: PathfinderMob): Goal {
|
||||
return LeapAtTargetGoal(
|
||||
entity,
|
||||
apiGoal.velocity.toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object LookAtPlayerGoalFactory : EntityGoalFactory<EntityGoalLookAtPlayer> {
|
||||
override fun create(apiGoal: EntityGoalLookAtPlayer, entity: PathfinderMob): Goal {
|
||||
return LookAtPlayerGoal(
|
||||
entity,
|
||||
Player::class.java,
|
||||
apiGoal.range.toFloat(),
|
||||
apiGoal.chance.toFloat() / 100f,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object MeleeAttackGoalFactory : EntityGoalFactory<EntityGoalMeleeAttack> {
|
||||
override fun create(apiGoal: EntityGoalMeleeAttack, entity: PathfinderMob): Goal {
|
||||
return MeleeAttackGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.pauseWhenMobIdle
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object MoveBackToVillageGoalFactory : EntityGoalFactory<EntityGoalMoveBackToVillage> {
|
||||
override fun create(apiGoal: EntityGoalMoveBackToVillage, entity: PathfinderMob): Goal {
|
||||
return MoveBackToVillageGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.canDespawn
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object MoveThroughVillageGoalFactory : EntityGoalFactory<EntityGoalMoveThroughVillage> {
|
||||
override fun create(apiGoal: EntityGoalMoveThroughVillage, entity: PathfinderMob): Goal {
|
||||
return MoveThroughVillageGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.onlyAtNight,
|
||||
apiGoal.distance,
|
||||
apiGoal.canPassThroughDoorsGetter
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object MoveTowardsRestrictionGoalFactory : EntityGoalFactory<EntityGoalMoveTowardsRestriction> {
|
||||
override fun create(apiGoal: EntityGoalMoveTowardsRestriction, entity: PathfinderMob): Goal {
|
||||
return MoveTowardsRestrictionGoal(
|
||||
entity,
|
||||
apiGoal.speed
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object MoveTowardsTargetGoalFactory : EntityGoalFactory<EntityGoalMoveTowardsTarget> {
|
||||
override fun create(apiGoal: EntityGoalMoveTowardsTarget, entity: PathfinderMob): Goal {
|
||||
return MoveTowardsTargetGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.maxDistance.toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object OcelotAttackGoalFactory : EntityGoalFactory<EntityGoalOcelotAttack> {
|
||||
override fun create(apiGoal: EntityGoalOcelotAttack, entity: PathfinderMob): Goal {
|
||||
return OcelotAttackGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object OpenDoorsGoalFactory : EntityGoalFactory<EntityGoalOpenDoors> {
|
||||
override fun create(apiGoal: EntityGoalOpenDoors, entity: PathfinderMob): Goal {
|
||||
return OpenDoorGoal(
|
||||
entity,
|
||||
apiGoal.delayedClose
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object PanicGoalFactory : EntityGoalFactory<EntityGoalPanic> {
|
||||
override fun create(apiGoal: EntityGoalPanic, entity: PathfinderMob): Goal {
|
||||
return PanicGoal(
|
||||
entity,
|
||||
apiGoal.speed
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object RandomLookAroundGoalFactory : EntityGoalFactory<EntityGoalRandomLookAround> {
|
||||
override fun create(apiGoal: EntityGoalRandomLookAround, entity: PathfinderMob): Goal {
|
||||
return RandomLookAroundGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object RandomStrollGoalFactory : EntityGoalFactory<EntityGoalRandomStroll> {
|
||||
override fun create(apiGoal: EntityGoalRandomStroll, entity: PathfinderMob): Goal {
|
||||
return RandomStrollGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.interval,
|
||||
apiGoal.canDespawn
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object RandomSwimmingGoalFactory : EntityGoalFactory<EntityGoalRandomSwimming> {
|
||||
override fun create(apiGoal: EntityGoalRandomSwimming, entity: PathfinderMob): Goal {
|
||||
return RandomSwimmingGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.interval
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object RangedAttackGoalFactory : EntityGoalFactory<EntityGoalRangedAttack> {
|
||||
override fun create(apiGoal: EntityGoalRangedAttack, entity: PathfinderMob): Goal? {
|
||||
return RangedAttackGoal(
|
||||
entity as? RangedAttackMob ?: return null,
|
||||
apiGoal.mobSpeed,
|
||||
apiGoal.minInterval,
|
||||
apiGoal.maxInterval,
|
||||
apiGoal.maxRange.toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object RangedBowAttackGoalFactory : EntityGoalFactory<EntityGoalRangedBowAttack> {
|
||||
override fun create(apiGoal: EntityGoalRangedBowAttack, entity: PathfinderMob): Goal? {
|
||||
(if (entity !is Monster) return null)
|
||||
if (entity !is RangedAttackMob) return null
|
||||
|
||||
return RangedBowAttackGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.attackInterval,
|
||||
apiGoal.range.toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object RangedCrossbowAttackGoalFactory : EntityGoalFactory<EntityGoalRangedCrossbowAttack> {
|
||||
override fun create(apiGoal: EntityGoalRangedCrossbowAttack, entity: PathfinderMob): Goal? {
|
||||
(if (entity !is Monster) return null)
|
||||
if (entity !is RangedAttackMob) return null
|
||||
if (entity !is CrossbowAttackMob) return null
|
||||
|
||||
return RangedCrossbowAttackGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.range.toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object RestrictSunGoalFactory : EntityGoalFactory<EntityGoalRestrictSun> {
|
||||
override fun create(apiGoal: EntityGoalRestrictSun, entity: PathfinderMob): Goal {
|
||||
return RestrictSunGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object StrollThroughVillageGoalFactory : EntityGoalFactory<EntityGoalStrollThroughVillage> {
|
||||
override fun create(apiGoal: EntityGoalStrollThroughVillage, entity: PathfinderMob): Goal {
|
||||
return StrollThroughVillageGoal(
|
||||
entity,
|
||||
apiGoal.searchRange
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object TemptGoalFactory : EntityGoalFactory<EntityGoalTempt> {
|
||||
override fun create(apiGoal: EntityGoalTempt, entity: PathfinderMob): Goal {
|
||||
return TemptGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
Ingredient.of(*apiGoal.items.map { commonsProvider.toNMSStack(it) }.toTypedArray()),
|
||||
apiGoal.canBeScared
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object TryFindWaterGoalFactory : EntityGoalFactory<EntityGoalTryFindWater> {
|
||||
override fun create(apiGoal: EntityGoalTryFindWater, entity: PathfinderMob): Goal {
|
||||
return TryFindWaterGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object UseItemGoalFactory : EntityGoalFactory<EntityGoalUseItem> {
|
||||
override fun create(apiGoal: EntityGoalUseItem, entity: PathfinderMob): Goal {
|
||||
return UseItemGoal(
|
||||
entity,
|
||||
commonsProvider.toNMSStack(apiGoal.item),
|
||||
SoundEvent(commonsProvider.toResourceLocation(apiGoal.sound.key)),
|
||||
) {
|
||||
apiGoal.condition.test(it.toBukkitEntity())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object WaterAvoidingRandomFlyingGoalFactory : EntityGoalFactory<EntityGoalWaterAvoidingRandomFlying> {
|
||||
override fun create(apiGoal: EntityGoalWaterAvoidingRandomFlying, entity: PathfinderMob): Goal {
|
||||
return WaterAvoidingRandomFlyingGoal(
|
||||
entity,
|
||||
apiGoal.speed
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object WaterAvoidingRandomStrollGoalFactory : EntityGoalFactory<EntityGoalWaterAvoidingRandomStroll> {
|
||||
override fun create(apiGoal: EntityGoalWaterAvoidingRandomStroll, entity: PathfinderMob): Goal {
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai
|
||||
|
||||
import com.willfp.eco.core.entities.ai.goals.CustomGoal
|
||||
import com.willfp.eco.core.entities.ai.goals.TargetGoal
|
||||
import com.willfp.eco.core.entities.ai.goals.target.TargetGoalHurtBy
|
||||
import com.willfp.eco.core.entities.ai.goals.target.TargetGoalNearestAttackable
|
||||
import com.willfp.eco.core.entities.ai.CustomGoal
|
||||
import com.willfp.eco.core.entities.ai.TargetGoal
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalHurtBy
|
||||
import com.willfp.eco.core.entities.ai.target.TargetGoalNearestAttackable
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal
|
||||
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal
|
||||
|
||||
fun <T : TargetGoal> T.getGoalFactory(): TargetGoalFactory<T>? {
|
||||
fun <T : TargetGoal<*>> T.getGoalFactory(): TargetGoalFactory<T>? {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return when (this) {
|
||||
is TargetGoalHurtBy -> HurtByGoalFactory
|
||||
is TargetGoalNearestAttackable -> NearestAttackableGoalFactory
|
||||
is CustomGoal -> CustomGoalFactory
|
||||
is CustomGoal<*> -> CustomGoalFactory
|
||||
else -> null
|
||||
} as TargetGoalFactory<T>?
|
||||
}
|
||||
|
||||
interface TargetGoalFactory<T : TargetGoal> {
|
||||
interface TargetGoalFactory<T : TargetGoal<*>> {
|
||||
fun create(apiGoal: T, entity: PathfinderMob): Goal?
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalAvoidEntity
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.toBukkitEntity
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.toNMSClass
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.AvoidEntityGoal
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
|
||||
object AvoidEntityGoalFactory : EntityGoalFactory<EntityGoalAvoidEntity> {
|
||||
override fun create(apiGoal: EntityGoalAvoidEntity, entity: PathfinderMob): Goal {
|
||||
return AvoidEntityGoal(
|
||||
entity,
|
||||
apiGoal.avoidClass.toNMSClass(),
|
||||
apiGoal.fleeDistance.toFloat(),
|
||||
apiGoal.slowSpeed,
|
||||
apiGoal.fastSpeed
|
||||
) { apiGoal.filter.test(it.toBukkitEntity()) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalBreakDoor
|
||||
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 {
|
||||
return BreakDoorGoal(
|
||||
entity,
|
||||
apiGoal.maxProgress
|
||||
) { true }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalBreatheAir
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.BreathAirGoal
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
|
||||
object BreatheAirGoalFactory : EntityGoalFactory<EntityGoalBreatheAir> {
|
||||
override fun create(apiGoal: EntityGoalBreatheAir, entity: PathfinderMob): Goal {
|
||||
return BreathAirGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalEatBlock
|
||||
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 EatBlockGoalFactory : EntityGoalFactory<EntityGoalEatBlock> {
|
||||
override fun create(apiGoal: EntityGoalEatBlock, entity: PathfinderMob): Goal {
|
||||
return EatBlockGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalFleeSun
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.FleeSunGoal
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
|
||||
object FleeSunGoalFactory : EntityGoalFactory<EntityGoalFleeSun> {
|
||||
override fun create(apiGoal: EntityGoalFleeSun, entity: PathfinderMob): Goal {
|
||||
return FleeSunGoal(
|
||||
entity,
|
||||
apiGoal.speed
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalFloat
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.FloatGoal
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
|
||||
object FloatGoalFactory : EntityGoalFactory<EntityGoalFloat> {
|
||||
override fun create(apiGoal: EntityGoalFloat, entity: PathfinderMob): Goal {
|
||||
return FloatGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalFollowBoats
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.FollowBoatGoal
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
|
||||
object FollowBoatsGoalFactory : EntityGoalFactory<EntityGoalFollowBoats> {
|
||||
override fun create(apiGoal: EntityGoalFollowBoats, entity: PathfinderMob): Goal {
|
||||
return FollowBoatGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalFollowMobs
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.FollowMobGoal
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
|
||||
object FollowMobsGoalFactory : EntityGoalFactory<EntityGoalFollowMobs> {
|
||||
override fun create(apiGoal: EntityGoalFollowMobs, entity: PathfinderMob): Goal {
|
||||
return FollowMobGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.minDistance.toFloat(),
|
||||
apiGoal.maxDistance.toFloat(),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalInteract
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.toNMSClass
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.InteractGoal
|
||||
|
||||
object InteractGoalFactory : EntityGoalFactory<EntityGoalInteract> {
|
||||
override fun create(apiGoal: EntityGoalInteract, entity: PathfinderMob): Goal {
|
||||
return InteractGoal(
|
||||
entity,
|
||||
apiGoal.targetClass.toNMSClass(),
|
||||
apiGoal.range.toFloat(),
|
||||
apiGoal.chance.toFloat() / 100f,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalLeapAtTarget
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.LeapAtTargetGoal
|
||||
|
||||
object LeapAtTargetGoalFactory : EntityGoalFactory<EntityGoalLeapAtTarget> {
|
||||
override fun create(apiGoal: EntityGoalLeapAtTarget, entity: PathfinderMob): Goal {
|
||||
return LeapAtTargetGoal(
|
||||
entity,
|
||||
apiGoal.velocity.toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalLookAtPlayer
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal
|
||||
import net.minecraft.world.entity.player.Player
|
||||
|
||||
object LookAtPlayerGoalFactory : EntityGoalFactory<EntityGoalLookAtPlayer> {
|
||||
override fun create(apiGoal: EntityGoalLookAtPlayer, entity: PathfinderMob): Goal {
|
||||
return LookAtPlayerGoal(
|
||||
entity,
|
||||
Player::class.java,
|
||||
apiGoal.range.toFloat(),
|
||||
apiGoal.chance.toFloat() / 100f,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalMeleeAttack
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal
|
||||
|
||||
object MeleeAttackGoalFactory : EntityGoalFactory<EntityGoalMeleeAttack> {
|
||||
override fun create(apiGoal: EntityGoalMeleeAttack, entity: PathfinderMob): Goal {
|
||||
return MeleeAttackGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.pauseWhenMobIdle
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveBackToVillage
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.MoveBackToVillageGoal
|
||||
|
||||
object MoveBackToVillageGoalFactory : EntityGoalFactory<EntityGoalMoveBackToVillage> {
|
||||
override fun create(apiGoal: EntityGoalMoveBackToVillage, entity: PathfinderMob): Goal {
|
||||
return MoveBackToVillageGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.canDespawn
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveThroughVillage
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.MoveThroughVillageGoal
|
||||
|
||||
object MoveThroughVillageGoalFactory : EntityGoalFactory<EntityGoalMoveThroughVillage> {
|
||||
override fun create(apiGoal: EntityGoalMoveThroughVillage, entity: PathfinderMob): Goal {
|
||||
return MoveThroughVillageGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.onlyAtNight,
|
||||
apiGoal.distance,
|
||||
apiGoal.canPassThroughDoorsGetter
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveTowardsRestriction
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.MoveTowardsRestrictionGoal
|
||||
|
||||
object MoveTowardsRestrictionGoalFactory : EntityGoalFactory<EntityGoalMoveTowardsRestriction> {
|
||||
override fun create(apiGoal: EntityGoalMoveTowardsRestriction, entity: PathfinderMob): Goal {
|
||||
return MoveTowardsRestrictionGoal(
|
||||
entity,
|
||||
apiGoal.speed
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveTowardsTarget
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.MoveTowardsTargetGoal
|
||||
|
||||
object MoveTowardsTargetGoalFactory : EntityGoalFactory<EntityGoalMoveTowardsTarget> {
|
||||
override fun create(apiGoal: EntityGoalMoveTowardsTarget, entity: PathfinderMob): Goal {
|
||||
return MoveTowardsTargetGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.maxDistance.toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalOcelotAttack
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.OcelotAttackGoal
|
||||
|
||||
object OcelotAttackGoalFactory : EntityGoalFactory<EntityGoalOcelotAttack> {
|
||||
override fun create(apiGoal: EntityGoalOcelotAttack, entity: PathfinderMob): Goal {
|
||||
return OcelotAttackGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalOpenDoors
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.OpenDoorGoal
|
||||
|
||||
object OpenDoorsGoalFactory : EntityGoalFactory<EntityGoalOpenDoors> {
|
||||
override fun create(apiGoal: EntityGoalOpenDoors, entity: PathfinderMob): Goal {
|
||||
return OpenDoorGoal(
|
||||
entity,
|
||||
apiGoal.delayedClose
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalPanic
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.PanicGoal
|
||||
|
||||
object PanicGoalFactory : EntityGoalFactory<EntityGoalPanic> {
|
||||
override fun create(apiGoal: EntityGoalPanic, entity: PathfinderMob): Goal {
|
||||
return PanicGoal(
|
||||
entity,
|
||||
apiGoal.speed
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRandomLookAround
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal
|
||||
|
||||
object RandomLookAroundGoalFactory : EntityGoalFactory<EntityGoalRandomLookAround> {
|
||||
override fun create(apiGoal: EntityGoalRandomLookAround, entity: PathfinderMob): Goal {
|
||||
return RandomLookAroundGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRandomStroll
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.RandomStrollGoal
|
||||
|
||||
object RandomStrollGoalFactory : EntityGoalFactory<EntityGoalRandomStroll> {
|
||||
override fun create(apiGoal: EntityGoalRandomStroll, entity: PathfinderMob): Goal {
|
||||
return RandomStrollGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.interval,
|
||||
apiGoal.canDespawn
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRandomSwimming
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal
|
||||
|
||||
object RandomSwimmingGoalFactory : EntityGoalFactory<EntityGoalRandomSwimming> {
|
||||
override fun create(apiGoal: EntityGoalRandomSwimming, entity: PathfinderMob): Goal {
|
||||
return RandomSwimmingGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.interval
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRangedAttack
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.RangedAttackGoal
|
||||
import net.minecraft.world.entity.monster.RangedAttackMob
|
||||
|
||||
object RangedAttackGoalFactory : EntityGoalFactory<EntityGoalRangedAttack> {
|
||||
override fun create(apiGoal: EntityGoalRangedAttack, entity: PathfinderMob): Goal? {
|
||||
return RangedAttackGoal(
|
||||
entity as? RangedAttackMob ?: return null,
|
||||
apiGoal.mobSpeed,
|
||||
apiGoal.minInterval,
|
||||
apiGoal.maxInterval,
|
||||
apiGoal.maxRange.toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRangedBowAttack
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.RangedBowAttackGoal
|
||||
import net.minecraft.world.entity.monster.Monster
|
||||
import net.minecraft.world.entity.monster.RangedAttackMob
|
||||
|
||||
object RangedBowAttackGoalFactory : EntityGoalFactory<EntityGoalRangedBowAttack> {
|
||||
override fun create(apiGoal: EntityGoalRangedBowAttack, entity: PathfinderMob): Goal? {
|
||||
(if (entity !is Monster) return null)
|
||||
if (entity !is RangedAttackMob) return null
|
||||
|
||||
return RangedBowAttackGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.attackInterval,
|
||||
apiGoal.range.toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRangedCrossbowAttack
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.RangedCrossbowAttackGoal
|
||||
import net.minecraft.world.entity.monster.CrossbowAttackMob
|
||||
import net.minecraft.world.entity.monster.Monster
|
||||
import net.minecraft.world.entity.monster.RangedAttackMob
|
||||
|
||||
object RangedCrossbowAttackGoalFactory : EntityGoalFactory<EntityGoalRangedCrossbowAttack> {
|
||||
override fun create(apiGoal: EntityGoalRangedCrossbowAttack, entity: PathfinderMob): Goal? {
|
||||
(if (entity !is Monster) return null)
|
||||
if (entity !is RangedAttackMob) return null
|
||||
if (entity !is CrossbowAttackMob) return null
|
||||
|
||||
return RangedCrossbowAttackGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
apiGoal.range.toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalRestrictSun
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.RestrictSunGoal
|
||||
|
||||
object RestrictSunGoalFactory : EntityGoalFactory<EntityGoalRestrictSun> {
|
||||
override fun create(apiGoal: EntityGoalRestrictSun, entity: PathfinderMob): Goal {
|
||||
return RestrictSunGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalStrollThroughVillage
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.StrollThroughVillageGoal
|
||||
|
||||
object StrollThroughVillageGoalFactory : EntityGoalFactory<EntityGoalStrollThroughVillage> {
|
||||
override fun create(apiGoal: EntityGoalStrollThroughVillage, entity: PathfinderMob): Goal {
|
||||
return StrollThroughVillageGoal(
|
||||
entity,
|
||||
apiGoal.searchRange
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalTempt
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.commonsProvider
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.TemptGoal
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
|
||||
object TemptGoalFactory : EntityGoalFactory<EntityGoalTempt> {
|
||||
override fun create(apiGoal: EntityGoalTempt, entity: PathfinderMob): Goal {
|
||||
return TemptGoal(
|
||||
entity,
|
||||
apiGoal.speed,
|
||||
Ingredient.of(*apiGoal.items.map { commonsProvider.toNMSStack(it) }.toTypedArray()),
|
||||
apiGoal.canBeScared
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalTryFindWater
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.TryFindWaterGoal
|
||||
|
||||
object TryFindWaterGoalFactory : EntityGoalFactory<EntityGoalTryFindWater> {
|
||||
override fun create(apiGoal: EntityGoalTryFindWater, entity: PathfinderMob): Goal {
|
||||
return TryFindWaterGoal(
|
||||
entity
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalUseItem
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.toBukkitEntity
|
||||
import com.willfp.eco.internal.spigot.proxy.common.commonsProvider
|
||||
import net.minecraft.sounds.SoundEvent
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.UseItemGoal
|
||||
|
||||
object UseItemGoalFactory : EntityGoalFactory<EntityGoalUseItem> {
|
||||
override fun create(apiGoal: EntityGoalUseItem, entity: PathfinderMob): Goal {
|
||||
return UseItemGoal(
|
||||
entity,
|
||||
commonsProvider.toNMSStack(apiGoal.item),
|
||||
SoundEvent(commonsProvider.toResourceLocation(apiGoal.sound.key)),
|
||||
) {
|
||||
apiGoal.condition.test(it.toBukkitEntity())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.ai.entity
|
||||
|
||||
import com.willfp.eco.core.entities.ai.entity.EntityGoalWaterAvoidingRandomFlying
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.goal.Goal
|
||||
import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomFlyingGoal
|
||||
|
||||
object WaterAvoidingRandomFlyingGoalFactory : EntityGoalFactory<EntityGoalWaterAvoidingRandomFlying> {
|
||||
override fun create(apiGoal: EntityGoalWaterAvoidingRandomFlying, entity: PathfinderMob): Goal {
|
||||
return WaterAvoidingRandomFlyingGoal(
|
||||
entity,
|
||||
apiGoal.speed
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user