Skip to content

Commit

Permalink
make femboy.ai actually spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
Inf1nityy committed Aug 2, 2024
1 parent 9183291 commit 6b3acf5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/nexia/ffa/base/BaseFfaUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ private boolean checkWorld() {
List<ServerPlayer> players = getFfaWorld().players();
if(players.isEmpty()) return true;

return checkBot(players);
return checkBot();
}

public boolean checkBot(List<ServerPlayer> players) {
public boolean checkBot() {
return false;
}

Expand Down
39 changes: 27 additions & 12 deletions src/main/java/com/nexia/ffa/classic/utilities/FfaClassicUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.ffa.FfaGameMode;
import com.nexia.ffa.base.BaseFfaUtil;
import com.nexia.nexus.api.world.entity.player.Player;
import com.nexia.nexus.api.world.util.Location;
import net.kyori.adventure.text.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.timers.FunctionCallback;
import net.minecraft.world.level.timers.TimerQueue;

import java.util.List;

Expand All @@ -35,23 +41,32 @@ public PlayerDataManager getDataManager() {
}

@Override
public boolean checkBot(List<ServerPlayer> players) {
ServerPlayer bot = null;

for(ServerPlayer player : players) {
if(player.getScoreboardName().equals("femboy.ai")) {
bot = player;
break;
}
}
public boolean checkBot() {
Player bot = ServerTime.nexusServer.getPlayer("femboy.ai");

if(bot != null && players.size() == 1) {
if (bot != null && getNexusFfaWorld().getPlayers().size() == 1) {
bot.kill(); // despawns the bot
return true;
}

if(bot == null && !players.isEmpty()) {
ServerTime.nexusServer.runCommand("/function core:bot/bot", 4, false); // spawns the bot
if (bot == null && !getNexusFfaWorld().getPlayers().isEmpty()) {
// spawn the bot
ServerTime.nexusServer.runCommand("/player femboy.ai spawn", 4, false);

bot = ServerTime.nexusServer.getPlayer("femboy.ai");
bot.runCommand("ffa classic");

ServerTime.nexusServer.runCommand("/player femboy.ai move forward", 4, false);

TimerQueue<MinecraftServer> timerQueue = ServerTime.minecraftServer.getWorldData().overworldData().getScheduledEvents();
timerQueue.schedule("core:bot/look", 1, new FunctionCallback(new ResourceLocation("core:bot/look")));
timerQueue.schedule("core:bot/attack", 7, new FunctionCallback(new ResourceLocation("core:bot/look")));
timerQueue.schedule("core:bot/attack2", 10, new FunctionCallback(new ResourceLocation("core:bot/look")));
timerQueue.schedule("core:bot/strafe", 4, new FunctionCallback(new ResourceLocation("core:bot/look")));

bot.addTag("bot");
bot.teleport(new Location(0.5, 128, 0.5, getNexusFfaWorld()));
ServerTime.nexusServer.runCommand("/player femboy.ai move forward", 4, false);
return false;
}

Expand Down

0 comments on commit 6b3acf5

Please sign in to comment.