Update AI
This commit is contained in:
parent
6b81874bee
commit
4664a01de9
@ -5,6 +5,7 @@ import io.izzel.taboolib.TabooLib;
|
||||
import io.izzel.taboolib.TabooLibAPI;
|
||||
import io.izzel.taboolib.common.loader.Startup;
|
||||
import io.izzel.taboolib.common.loader.StartupLoader;
|
||||
import io.izzel.taboolib.module.ai.SimpleAiSelector;
|
||||
import io.izzel.taboolib.module.command.lite.CommandBuilder;
|
||||
import io.izzel.taboolib.module.db.local.Local;
|
||||
import io.izzel.taboolib.module.db.local.LocalPlayer;
|
||||
@ -12,6 +13,7 @@ import io.izzel.taboolib.module.hologram.Hologram;
|
||||
import io.izzel.taboolib.module.hologram.THologram;
|
||||
import io.izzel.taboolib.module.inject.TListener;
|
||||
import io.izzel.taboolib.module.light.TLight;
|
||||
import io.izzel.taboolib.module.lite.SimpleReflection;
|
||||
import io.izzel.taboolib.module.locale.logger.TLogger;
|
||||
import io.izzel.taboolib.module.nms.impl.Type;
|
||||
import io.izzel.taboolib.module.tellraw.TellrawJson;
|
||||
@ -22,6 +24,7 @@ import io.izzel.taboolib.util.lite.Signs;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -143,6 +146,30 @@ public class ListenerCommand implements Listener {
|
||||
player.sendMessage("§8[§fTabooLib§8] §7Lighting. §8(-)");
|
||||
}, 40);
|
||||
}
|
||||
},
|
||||
new Module() {
|
||||
@Override
|
||||
public String[] name() {
|
||||
return new String[] {"simpleAI", "ai"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Player player) {
|
||||
player.sendMessage("§8[§fTabooLib§8] §7SimpleAI.");
|
||||
Skeleton skeleton = player.getWorld().spawn(player.getLocation(), Skeleton.class, c -> {
|
||||
c.setCustomName("Fearless Skeleton");
|
||||
c.setCustomNameVisible(true);
|
||||
});
|
||||
TabooLib.getPlugin().runTask(() -> {
|
||||
SimpleAiSelector.getExecutor().getGoalAi(skeleton).forEach(ai -> {
|
||||
player.sendMessage("§8[§fTabooLib§8] §7AI (Origin): §8" + SimpleReflection.getFieldValueChecked(ai.getClass(), ai, "a", true));
|
||||
});
|
||||
SimpleAiSelector.getExecutor().removeGoalAi(skeleton, 3);
|
||||
SimpleAiSelector.getExecutor().getGoalAi(skeleton).forEach(ai -> {
|
||||
player.sendMessage("§8[§fTabooLib§8] §7AI (After): §8" + SimpleReflection.getFieldValueChecked(ai.getClass(), ai, "a", true));
|
||||
});
|
||||
}, 20);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
@ -46,13 +46,13 @@ public abstract class PathfinderExecutor {
|
||||
|
||||
public abstract void replaceTargetAi(LivingEntity entity, SimpleAi ai, int priority, String name);
|
||||
|
||||
public abstract void removeGoalAi(LivingEntity entity, SimpleAi ai, int priority);
|
||||
public abstract void removeGoalAi(LivingEntity entity, int priority);
|
||||
|
||||
public abstract void removeTargetAi(LivingEntity entity, SimpleAi ai, int priority);
|
||||
public abstract void removeTargetAi(LivingEntity entity, int priority);
|
||||
|
||||
public abstract void removeGoalAi(LivingEntity entity, SimpleAi ai, String name);
|
||||
public abstract void removeGoalAi(LivingEntity entity, String name);
|
||||
|
||||
public abstract void removeTargetAi(LivingEntity entity, SimpleAi ai, String name);
|
||||
public abstract void removeTargetAi(LivingEntity entity, String name);
|
||||
|
||||
public abstract void clearGoalAi(LivingEntity entity);
|
||||
|
||||
|
@ -33,7 +33,11 @@ public class InternalPathfinderExecutor extends PathfinderExecutor {
|
||||
try {
|
||||
SimpleReflection.saveField(PathfinderGoalSelector.class);
|
||||
SimpleReflection.saveField(ControllerJump.class);
|
||||
pathfinderGoalSelectorSet = SimpleReflection.getField(PathfinderGoalSelector.class, "b");
|
||||
if (v11400) {
|
||||
pathfinderGoalSelectorSet = SimpleReflection.getField(PathfinderGoalSelector.class, "d");
|
||||
} else {
|
||||
pathfinderGoalSelectorSet = SimpleReflection.getField(PathfinderGoalSelector.class, "b");
|
||||
}
|
||||
controllerJumpCurrent = SimpleReflection.getField(ControllerJump.class, "a");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -156,22 +160,22 @@ public class InternalPathfinderExecutor extends PathfinderExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGoalAi(LivingEntity entity, SimpleAi ai, int priority) {
|
||||
public void removeGoalAi(LivingEntity entity, int priority) {
|
||||
removeGoal(priority, ((EntityInsentient) getEntityInsentient(entity)).goalSelector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTargetAi(LivingEntity entity, SimpleAi ai, int priority) {
|
||||
public void removeTargetAi(LivingEntity entity, int priority) {
|
||||
removeGoal(priority, ((EntityInsentient) getEntityInsentient(entity)).targetSelector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGoalAi(LivingEntity entity, SimpleAi ai, String name) {
|
||||
public void removeGoalAi(LivingEntity entity, String name) {
|
||||
removeGoal(name, ((EntityInsentient) getEntityInsentient(entity)).goalSelector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTargetAi(LivingEntity entity, SimpleAi ai, String name) {
|
||||
public void removeTargetAi(LivingEntity entity, String name) {
|
||||
removeGoal(name, ((EntityInsentient) getEntityInsentient(entity)).targetSelector);
|
||||
}
|
||||
|
||||
@ -196,9 +200,9 @@ public class InternalPathfinderExecutor extends PathfinderExecutor {
|
||||
private Collection getGoal(Object targetSelector) {
|
||||
Collection c;
|
||||
if (v11400) {
|
||||
c = (Collection) SimpleReflection.getFieldValueChecked(PathfinderGoalSelector.class, targetSelector, "b", true);
|
||||
} else {
|
||||
c = (Collection) SimpleReflection.getFieldValueChecked(PathfinderGoalSelector.class, targetSelector, "d", true);
|
||||
} else {
|
||||
c = (Collection) SimpleReflection.getFieldValueChecked(PathfinderGoalSelector.class, targetSelector, "b", true);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user