mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 02:25:57 +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) {
|
||||
Runnable tick = BRIDGE.playerTicker(entity);
|
||||
return () -> {
|
||||
if (entity.isValid()) {
|
||||
tick.run();
|
||||
}
|
||||
};
|
||||
return BRIDGE.playerTicker(entity instanceof NPCHolder ? ((NPCHolder) entity).getNPC() : null, entity);
|
||||
}
|
||||
|
||||
public static void registerEntityClass(Class<?> clazz) {
|
||||
|
@ -161,7 +161,7 @@ public interface NMSBridge {
|
||||
|
||||
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);
|
||||
|
||||
|
@ -965,8 +965,10 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable playerTicker(Player next) {
|
||||
public Runnable playerTicker(NPC npc, Player next) {
|
||||
return () -> {
|
||||
if (!next.isValid())
|
||||
return;
|
||||
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
||||
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
|
@ -1018,8 +1018,10 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable playerTicker(Player next) {
|
||||
public Runnable playerTicker(NPC npc, Player next) {
|
||||
return () -> {
|
||||
if (!next.isValid())
|
||||
return;
|
||||
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
||||
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
|
@ -1025,8 +1025,10 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable playerTicker(Player next) {
|
||||
public Runnable playerTicker(NPC npc, Player next) {
|
||||
return () -> {
|
||||
if (!next.isValid())
|
||||
return;
|
||||
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
||||
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
|
@ -1061,8 +1061,10 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable playerTicker(Player next) {
|
||||
public Runnable playerTicker(NPC npc, Player next) {
|
||||
return () -> {
|
||||
if (!next.isValid())
|
||||
return;
|
||||
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
||||
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
|
@ -1130,8 +1130,16 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable playerTicker(Player entity) {
|
||||
return ((EntityPlayer) getHandle(entity))::playerTick;
|
||||
public Runnable playerTicker(NPC npc, Player entity) {
|
||||
EntityPlayer player = (EntityPlayer) getHandle(entity);
|
||||
return () -> {
|
||||
if (!entity.isValid())
|
||||
return;
|
||||
if (npc != null && npc.useMinecraftAI()) {
|
||||
player.movementTick();
|
||||
}
|
||||
player.playerTick();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1147,8 +1147,16 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable playerTicker(Player entity) {
|
||||
return ((EntityPlayer) getHandle(entity))::playerTick;
|
||||
public Runnable playerTicker(NPC npc, Player entity) {
|
||||
EntityPlayer player = (EntityPlayer) getHandle(entity);
|
||||
return () -> {
|
||||
if (!entity.isValid())
|
||||
return;
|
||||
if (npc != null && npc.useMinecraftAI()) {
|
||||
player.movementTick();
|
||||
}
|
||||
player.playerTick();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1171,8 +1171,16 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable playerTicker(Player entity) {
|
||||
return ((EntityPlayer) getHandle(entity))::playerTick;
|
||||
public Runnable playerTicker(NPC npc, Player entity) {
|
||||
EntityPlayer player = (EntityPlayer) getHandle(entity);
|
||||
return () -> {
|
||||
if (!entity.isValid())
|
||||
return;
|
||||
if (npc != null && npc.useMinecraftAI()) {
|
||||
player.movementTick();
|
||||
}
|
||||
player.playerTick();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1177,8 +1177,16 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable playerTicker(Player entity) {
|
||||
return ((ServerPlayer) getHandle(entity))::doTick;
|
||||
public Runnable playerTicker(NPC npc, Player entity) {
|
||||
ServerPlayer player = (ServerPlayer) getHandle(entity);
|
||||
return () -> {
|
||||
if (!entity.isValid())
|
||||
return;
|
||||
if (npc != null && npc.useMinecraftAI()) {
|
||||
player.aiStep();
|
||||
}
|
||||
player.doTick();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1186,8 +1186,16 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable playerTicker(Player entity) {
|
||||
return ((ServerPlayer) getHandle(entity))::doTick;
|
||||
public Runnable playerTicker(NPC npc, Player entity) {
|
||||
ServerPlayer player = (ServerPlayer) getHandle(entity);
|
||||
return () -> {
|
||||
if (!entity.isValid())
|
||||
return;
|
||||
if (npc != null && npc.useMinecraftAI()) {
|
||||
player.aiStep();
|
||||
}
|
||||
player.doTick();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1313,8 +1313,16 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable playerTicker(Player entity) {
|
||||
return ((ServerPlayer) getHandle(entity))::doTick;
|
||||
public Runnable playerTicker(NPC npc, Player entity) {
|
||||
ServerPlayer player = (ServerPlayer) getHandle(entity);
|
||||
return () -> {
|
||||
if (!entity.isValid())
|
||||
return;
|
||||
if (npc != null && npc.useMinecraftAI()) {
|
||||
player.aiStep();
|
||||
}
|
||||
player.doTick();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1285,8 +1285,16 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable playerTicker(Player entity) {
|
||||
return ((ServerPlayer) getHandle(entity))::doTick;
|
||||
public Runnable playerTicker(NPC npc, Player entity) {
|
||||
ServerPlayer player = (ServerPlayer) getHandle(entity);
|
||||
return () -> {
|
||||
if (!entity.isValid())
|
||||
return;
|
||||
if (npc != null && npc.useMinecraftAI()) {
|
||||
player.aiStep();
|
||||
}
|
||||
player.doTick();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -901,12 +901,17 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable playerTicker(Player next) {
|
||||
public Runnable playerTicker(NPC npc, Player next) {
|
||||
return () -> {
|
||||
if (!next.isValid())
|
||||
return;
|
||||
EntityPlayer entity = (EntityPlayer) getHandle(next);
|
||||
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
|
||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
entity.l();
|
||||
if (npc != null && npc.useMinecraftAI()) {
|
||||
entity.m();
|
||||
}
|
||||
if (!removeFromPlayerList)
|
||||
return;
|
||||
if (!entity.dead) {
|
||||
|
Loading…
Reference in New Issue
Block a user