Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f8448fee1 | ||
|
|
8b6e15457c | ||
|
|
b99e822db3 | ||
|
|
02f8d33a81 |
@@ -10,7 +10,6 @@ import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketSetCreat
|
|||||||
import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketSetSlot
|
import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketSetSlot
|
||||||
import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketWindowItems
|
import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketWindowItems
|
||||||
import com.willfp.eco.internal.spigot.proxy.common.packet.display.frame.clearFrames
|
import com.willfp.eco.internal.spigot.proxy.common.packet.display.frame.clearFrames
|
||||||
import com.willfp.eco.internal.spigot.proxy.v1_17_R1.display.PacketChat
|
|
||||||
import net.minecraft.network.protocol.Packet
|
import net.minecraft.network.protocol.Packet
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer
|
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
@@ -42,7 +41,7 @@ class PacketHandler : PacketHandlerProxy {
|
|||||||
PacketSetCreativeSlot,
|
PacketSetCreativeSlot,
|
||||||
PacketSetSlot,
|
PacketSetSlot,
|
||||||
PacketWindowItems(plugin),
|
PacketWindowItems(plugin),
|
||||||
PacketChat
|
// PacketChat
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketSetCreat
|
|||||||
import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketSetSlot
|
import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketSetSlot
|
||||||
import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketWindowItems
|
import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketWindowItems
|
||||||
import com.willfp.eco.internal.spigot.proxy.common.packet.display.frame.clearFrames
|
import com.willfp.eco.internal.spigot.proxy.common.packet.display.frame.clearFrames
|
||||||
import com.willfp.eco.internal.spigot.proxy.v1_18_R1.display.PacketChat
|
|
||||||
import net.minecraft.network.protocol.Packet
|
import net.minecraft.network.protocol.Packet
|
||||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer
|
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
@@ -42,7 +41,7 @@ class PacketHandler: PacketHandlerProxy {
|
|||||||
PacketSetCreativeSlot,
|
PacketSetCreativeSlot,
|
||||||
PacketSetSlot,
|
PacketSetSlot,
|
||||||
PacketWindowItems(plugin),
|
PacketWindowItems(plugin),
|
||||||
PacketChat
|
// PacketChat
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketSetCreat
|
|||||||
import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketSetSlot
|
import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketSetSlot
|
||||||
import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketWindowItems
|
import com.willfp.eco.internal.spigot.proxy.common.packet.display.PacketWindowItems
|
||||||
import com.willfp.eco.internal.spigot.proxy.common.packet.display.frame.clearFrames
|
import com.willfp.eco.internal.spigot.proxy.common.packet.display.frame.clearFrames
|
||||||
import com.willfp.eco.internal.spigot.proxy.v1_18_R2.display.PacketChat
|
|
||||||
import net.minecraft.network.protocol.Packet
|
import net.minecraft.network.protocol.Packet
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer
|
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
@@ -42,7 +41,7 @@ class PacketHandler: PacketHandlerProxy {
|
|||||||
PacketSetCreativeSlot,
|
PacketSetCreativeSlot,
|
||||||
PacketSetSlot,
|
PacketSetSlot,
|
||||||
PacketWindowItems(plugin),
|
PacketWindowItems(plugin),
|
||||||
PacketChat
|
// PacketChat
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.willfp.eco.internal.spigot.proxy.v1_19_R1
|
|||||||
|
|
||||||
import com.willfp.eco.core.entities.ai.EntityController
|
import com.willfp.eco.core.entities.ai.EntityController
|
||||||
import com.willfp.eco.internal.spigot.proxy.EntityControllerFactoryProxy
|
import com.willfp.eco.internal.spigot.proxy.EntityControllerFactoryProxy
|
||||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EcoEntityController
|
import com.willfp.eco.internal.spigot.proxy.v1_19_R1.entity.EcoEntityController
|
||||||
import org.bukkit.entity.Mob
|
import org.bukkit.entity.Mob
|
||||||
|
|
||||||
class EntityControllerFactory : EntityControllerFactoryProxy {
|
class EntityControllerFactory : EntityControllerFactoryProxy {
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package com.willfp.eco.internal.spigot.proxy.v1_19_R1.entity
|
||||||
|
|
||||||
|
import com.willfp.eco.core.entities.ai.CustomGoal
|
||||||
|
import com.willfp.eco.core.entities.ai.EntityController
|
||||||
|
import com.willfp.eco.core.entities.ai.EntityGoal
|
||||||
|
import com.willfp.eco.core.entities.ai.TargetGoal
|
||||||
|
import com.willfp.eco.internal.spigot.proxy.common.ai.CustomGoalFactory
|
||||||
|
import com.willfp.eco.internal.spigot.proxy.common.ai.getGoalFactory
|
||||||
|
import com.willfp.eco.internal.spigot.proxy.common.toPathfinderMob
|
||||||
|
import net.minecraft.world.entity.PathfinderMob
|
||||||
|
import net.minecraft.world.entity.ai.goal.Goal
|
||||||
|
import org.bukkit.entity.Mob
|
||||||
|
|
||||||
|
class EcoEntityController<T : Mob>(
|
||||||
|
private val handle: T
|
||||||
|
) : EntityController<T> {
|
||||||
|
override fun addEntityGoal(priority: Int, goal: EntityGoal<in T>): EntityController<T> {
|
||||||
|
val nms = getNms() ?: return this
|
||||||
|
|
||||||
|
nms.goalSelector.addGoal(
|
||||||
|
priority,
|
||||||
|
goal.getGoalFactory()?.create(goal, nms) ?: return this
|
||||||
|
)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun removeEntityGoal(goal: EntityGoal<in T>): EntityController<T> {
|
||||||
|
val nms = getNms() ?: return this
|
||||||
|
|
||||||
|
val predicate: (Goal) -> Boolean = if (goal is CustomGoal<*>) {
|
||||||
|
{ CustomGoalFactory.isGoalOfType(it, goal) }
|
||||||
|
} else {
|
||||||
|
{ goal.getGoalFactory()?.isGoalOfType(it) == true }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (wrapped in nms.goalSelector.availableGoals.toSet()) {
|
||||||
|
if (predicate(wrapped.goal)) {
|
||||||
|
nms.goalSelector.removeGoal(wrapped.goal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun clearEntityGoals(): EntityController<T> {
|
||||||
|
val nms = getNms() ?: return this
|
||||||
|
nms.goalSelector.availableGoals.clear()
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addTargetGoal(priority: Int, goal: TargetGoal<in T>): EntityController<T> {
|
||||||
|
val nms = getNms() ?: return this
|
||||||
|
|
||||||
|
nms.targetSelector.addGoal(
|
||||||
|
priority, goal.getGoalFactory()?.create(goal, nms) ?: return this
|
||||||
|
)
|
||||||
|
|
||||||
|
nms.targetSelector
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun removeTargetGoal(goal: TargetGoal<in T>): EntityController<T> {
|
||||||
|
val nms = getNms() ?: return this
|
||||||
|
|
||||||
|
val predicate: (Goal) -> Boolean = if (goal is CustomGoal<*>) {
|
||||||
|
{ CustomGoalFactory.isGoalOfType(it, goal) }
|
||||||
|
} else {
|
||||||
|
{ goal.getGoalFactory()?.isGoalOfType(it) == true }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (wrapped in nms.targetSelector.availableGoals.toSet()) {
|
||||||
|
if (predicate(wrapped.goal)) {
|
||||||
|
nms.targetSelector.removeGoal(wrapped.goal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun clearTargetGoals(): EntityController<T> {
|
||||||
|
val nms = getNms() ?: return this
|
||||||
|
nms.targetSelector.availableGoals.clear()
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getNms(): PathfinderMob? {
|
||||||
|
return handle.toPathfinderMob()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getEntity(): T {
|
||||||
|
return handle
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ package com.willfp.eco.internal.spigot.proxy.v1_19_R2
|
|||||||
|
|
||||||
import com.willfp.eco.core.entities.ai.EntityController
|
import com.willfp.eco.core.entities.ai.EntityController
|
||||||
import com.willfp.eco.internal.spigot.proxy.EntityControllerFactoryProxy
|
import com.willfp.eco.internal.spigot.proxy.EntityControllerFactoryProxy
|
||||||
import com.willfp.eco.internal.spigot.proxy.common.ai.EcoEntityController
|
import com.willfp.eco.internal.spigot.proxy.v1_19_R2.entity.EcoEntityController
|
||||||
import org.bukkit.entity.Mob
|
import org.bukkit.entity.Mob
|
||||||
|
|
||||||
class EntityControllerFactory : EntityControllerFactoryProxy {
|
class EntityControllerFactory : EntityControllerFactoryProxy {
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package com.willfp.eco.internal.spigot.proxy.v1_19_R2.entity
|
||||||
|
|
||||||
|
import com.willfp.eco.core.entities.ai.CustomGoal
|
||||||
|
import com.willfp.eco.core.entities.ai.EntityController
|
||||||
|
import com.willfp.eco.core.entities.ai.EntityGoal
|
||||||
|
import com.willfp.eco.core.entities.ai.TargetGoal
|
||||||
|
import com.willfp.eco.internal.spigot.proxy.common.ai.CustomGoalFactory
|
||||||
|
import com.willfp.eco.internal.spigot.proxy.common.ai.getGoalFactory
|
||||||
|
import com.willfp.eco.internal.spigot.proxy.common.toPathfinderMob
|
||||||
|
import net.minecraft.world.entity.PathfinderMob
|
||||||
|
import net.minecraft.world.entity.ai.goal.Goal
|
||||||
|
import org.bukkit.entity.Mob
|
||||||
|
|
||||||
|
class EcoEntityController<T : Mob>(
|
||||||
|
private val handle: T
|
||||||
|
) : EntityController<T> {
|
||||||
|
override fun addEntityGoal(priority: Int, goal: EntityGoal<in T>): EntityController<T> {
|
||||||
|
val nms = getNms() ?: return this
|
||||||
|
|
||||||
|
nms.goalSelector.addGoal(
|
||||||
|
priority,
|
||||||
|
goal.getGoalFactory()?.create(goal, nms) ?: return this
|
||||||
|
)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun removeEntityGoal(goal: EntityGoal<in T>): EntityController<T> {
|
||||||
|
val nms = getNms() ?: return this
|
||||||
|
|
||||||
|
val predicate: (Goal) -> Boolean = if (goal is CustomGoal<*>) {
|
||||||
|
{ CustomGoalFactory.isGoalOfType(it, goal) }
|
||||||
|
} else {
|
||||||
|
{ goal.getGoalFactory()?.isGoalOfType(it) == true }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (wrapped in nms.goalSelector.availableGoals.toSet()) {
|
||||||
|
if (predicate(wrapped.goal)) {
|
||||||
|
nms.goalSelector.removeGoal(wrapped.goal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun clearEntityGoals(): EntityController<T> {
|
||||||
|
val nms = getNms() ?: return this
|
||||||
|
nms.goalSelector.availableGoals.clear()
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addTargetGoal(priority: Int, goal: TargetGoal<in T>): EntityController<T> {
|
||||||
|
val nms = getNms() ?: return this
|
||||||
|
|
||||||
|
nms.targetSelector.addGoal(
|
||||||
|
priority, goal.getGoalFactory()?.create(goal, nms) ?: return this
|
||||||
|
)
|
||||||
|
|
||||||
|
nms.targetSelector
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun removeTargetGoal(goal: TargetGoal<in T>): EntityController<T> {
|
||||||
|
val nms = getNms() ?: return this
|
||||||
|
|
||||||
|
val predicate: (Goal) -> Boolean = if (goal is CustomGoal<*>) {
|
||||||
|
{ CustomGoalFactory.isGoalOfType(it, goal) }
|
||||||
|
} else {
|
||||||
|
{ goal.getGoalFactory()?.isGoalOfType(it) == true }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (wrapped in nms.targetSelector.availableGoals.toSet()) {
|
||||||
|
if (predicate(wrapped.goal)) {
|
||||||
|
nms.targetSelector.removeGoal(wrapped.goal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun clearTargetGoals(): EntityController<T> {
|
||||||
|
val nms = getNms() ?: return this
|
||||||
|
nms.targetSelector.availableGoals.clear()
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getNms(): PathfinderMob? {
|
||||||
|
return handle.toPathfinderMob()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getEntity(): T {
|
||||||
|
return handle
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
version = 6.51.1
|
version = 6.51.3
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
Reference in New Issue
Block a user