mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 20:25:19 +01:00
Trial manually calling aiStep for players with /npc ai turned on
This commit is contained in:
parent
903ba91b4c
commit
8be9da5f04
@ -728,12 +728,7 @@ public class NMS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Runnable playerTicker(Player entity) {
|
public static Runnable playerTicker(Player entity) {
|
||||||
Runnable tick = BRIDGE.playerTicker(entity);
|
return BRIDGE.playerTicker(entity instanceof NPCHolder ? ((NPCHolder) entity).getNPC() : null, entity);
|
||||||
return () -> {
|
|
||||||
if (entity.isValid()) {
|
|
||||||
tick.run();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerEntityClass(Class<?> clazz) {
|
public static void registerEntityClass(Class<?> clazz) {
|
||||||
|
@ -161,7 +161,7 @@ public interface NMSBridge {
|
|||||||
|
|
||||||
public void playAnimation(PlayerAnimation animation, Player player, Iterable<Player> to);
|
public void playAnimation(PlayerAnimation animation, Player player, Iterable<Player> to);
|
||||||
|
|
||||||
public Runnable playerTicker(Player entity);
|
public Runnable playerTicker(NPC npc, Player entity);
|
||||||
|
|
||||||
public void registerEntityClass(Class<?> clazz);
|
public void registerEntityClass(Class<?> clazz);
|
||||||
|
|
||||||
|
@ -965,8 +965,10 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable playerTicker(Player next) {
|
public Runnable playerTicker(NPC npc, Player next) {
|
||||||
return () -> {
|
return () -> {
|
||||||
|
if (!next.isValid())
|
||||||
|
return;
|
||||||
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
||||||
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
||||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||||
|
@ -1018,8 +1018,10 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable playerTicker(Player next) {
|
public Runnable playerTicker(NPC npc, Player next) {
|
||||||
return () -> {
|
return () -> {
|
||||||
|
if (!next.isValid())
|
||||||
|
return;
|
||||||
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
||||||
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
||||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||||
|
@ -1025,8 +1025,10 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable playerTicker(Player next) {
|
public Runnable playerTicker(NPC npc, Player next) {
|
||||||
return () -> {
|
return () -> {
|
||||||
|
if (!next.isValid())
|
||||||
|
return;
|
||||||
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
||||||
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
||||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||||
|
@ -1061,8 +1061,10 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable playerTicker(Player next) {
|
public Runnable playerTicker(NPC npc, Player next) {
|
||||||
return () -> {
|
return () -> {
|
||||||
|
if (!next.isValid())
|
||||||
|
return;
|
||||||
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
||||||
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
||||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||||
|
@ -1130,8 +1130,16 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable playerTicker(Player entity) {
|
public Runnable playerTicker(NPC npc, Player entity) {
|
||||||
return ((EntityPlayer) getHandle(entity))::playerTick;
|
EntityPlayer player = (EntityPlayer) getHandle(entity);
|
||||||
|
return () -> {
|
||||||
|
if (!entity.isValid())
|
||||||
|
return;
|
||||||
|
if (npc != null && npc.useMinecraftAI()) {
|
||||||
|
player.movementTick();
|
||||||
|
}
|
||||||
|
player.playerTick();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1147,8 +1147,16 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable playerTicker(Player entity) {
|
public Runnable playerTicker(NPC npc, Player entity) {
|
||||||
return ((EntityPlayer) getHandle(entity))::playerTick;
|
EntityPlayer player = (EntityPlayer) getHandle(entity);
|
||||||
|
return () -> {
|
||||||
|
if (!entity.isValid())
|
||||||
|
return;
|
||||||
|
if (npc != null && npc.useMinecraftAI()) {
|
||||||
|
player.movementTick();
|
||||||
|
}
|
||||||
|
player.playerTick();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1171,8 +1171,16 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable playerTicker(Player entity) {
|
public Runnable playerTicker(NPC npc, Player entity) {
|
||||||
return ((EntityPlayer) getHandle(entity))::playerTick;
|
EntityPlayer player = (EntityPlayer) getHandle(entity);
|
||||||
|
return () -> {
|
||||||
|
if (!entity.isValid())
|
||||||
|
return;
|
||||||
|
if (npc != null && npc.useMinecraftAI()) {
|
||||||
|
player.movementTick();
|
||||||
|
}
|
||||||
|
player.playerTick();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1177,8 +1177,16 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable playerTicker(Player entity) {
|
public Runnable playerTicker(NPC npc, Player entity) {
|
||||||
return ((ServerPlayer) getHandle(entity))::doTick;
|
ServerPlayer player = (ServerPlayer) getHandle(entity);
|
||||||
|
return () -> {
|
||||||
|
if (!entity.isValid())
|
||||||
|
return;
|
||||||
|
if (npc != null && npc.useMinecraftAI()) {
|
||||||
|
player.aiStep();
|
||||||
|
}
|
||||||
|
player.doTick();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1186,8 +1186,16 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable playerTicker(Player entity) {
|
public Runnable playerTicker(NPC npc, Player entity) {
|
||||||
return ((ServerPlayer) getHandle(entity))::doTick;
|
ServerPlayer player = (ServerPlayer) getHandle(entity);
|
||||||
|
return () -> {
|
||||||
|
if (!entity.isValid())
|
||||||
|
return;
|
||||||
|
if (npc != null && npc.useMinecraftAI()) {
|
||||||
|
player.aiStep();
|
||||||
|
}
|
||||||
|
player.doTick();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1313,8 +1313,16 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable playerTicker(Player entity) {
|
public Runnable playerTicker(NPC npc, Player entity) {
|
||||||
return ((ServerPlayer) getHandle(entity))::doTick;
|
ServerPlayer player = (ServerPlayer) getHandle(entity);
|
||||||
|
return () -> {
|
||||||
|
if (!entity.isValid())
|
||||||
|
return;
|
||||||
|
if (npc != null && npc.useMinecraftAI()) {
|
||||||
|
player.aiStep();
|
||||||
|
}
|
||||||
|
player.doTick();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1285,8 +1285,16 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable playerTicker(Player entity) {
|
public Runnable playerTicker(NPC npc, Player entity) {
|
||||||
return ((ServerPlayer) getHandle(entity))::doTick;
|
ServerPlayer player = (ServerPlayer) getHandle(entity);
|
||||||
|
return () -> {
|
||||||
|
if (!entity.isValid())
|
||||||
|
return;
|
||||||
|
if (npc != null && npc.useMinecraftAI()) {
|
||||||
|
player.aiStep();
|
||||||
|
}
|
||||||
|
player.doTick();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -901,12 +901,17 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable playerTicker(Player next) {
|
public Runnable playerTicker(NPC npc, Player next) {
|
||||||
return () -> {
|
return () -> {
|
||||||
|
if (!next.isValid())
|
||||||
|
return;
|
||||||
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
||||||
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
||||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||||
entity.l();
|
entity.l();
|
||||||
|
if (npc != null && npc.useMinecraftAI()) {
|
||||||
|
entity.m();
|
||||||
|
}
|
||||||
if (!removeFromPlayerList)
|
if (!removeFromPlayerList)
|
||||||
return;
|
return;
|
||||||
if (!entity.dead) {
|
if (!entity.dead) {
|
||||||
|
Loading…
Reference in New Issue
Block a user