first commit-ish, forked and updated for 1.21.11
Some checks failed
Compile / gradle (ubuntu-latest) (push) Has been cancelled

This commit is contained in:
Justus Wolff
2026-03-02 15:40:11 +01:00
parent ff9220654b
commit 53b4f6a04a
491 changed files with 98649 additions and 86 deletions

View File

@@ -17,6 +17,7 @@ repositories {
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT")
compileOnly("com.mojang:authlib:3.2.38")
compileOnly("com.googlecode.json-simple:json-simple:1.1.1")
}

View File

@@ -21,15 +21,15 @@ public interface BotManager {
List<String> fetchNames();
Terminator createBot(Location loc, String name, String skin, String signature);
Terminator createBot(Location loc, String name, String skin);
void createBots(CommandSender sender, String name, String skinName, int n, Location location);
void createBots(CommandSender sender, String name, String skinName, int n, NeuralNetwork network, Location location);
Set<Terminator> createBots(Location loc, String name, String[] skin, List<NeuralNetwork> networks);
Set<Terminator> createBots(Location loc, String name, String skin, List<NeuralNetwork> networks);
Set<Terminator> createBots(Location loc, String name, String[] skin, int n, NeuralNetwork network);
Set<Terminator> createBots(Location loc, String name, String skin, int n, NeuralNetwork network);
void remove(Terminator bot);

View File

@@ -1068,6 +1068,7 @@ public class LegacyAgent extends Agent {
}
private void blockBreakEffect(Terminator bot, LivingEntity player, Block block, LegacyLevel.LevelWrapper wrapper) {
if (bot == null) {return;}
if (LegacyMats.NO_CRACK.contains(block.getType())) return;
@@ -1314,7 +1315,7 @@ public class LegacyAgent extends Agent {
bot.look(BlockFace.DOWN);
bot.punch();
Boat boat = (Boat) world.spawnEntity(place, EntityType.BOAT);
Boat boat = (Boat) world.spawnEntity(place, EntityType.OAK_BOAT);
scheduler.runTaskLater(plugin, () -> {
if (!boat.isDead()) {
@@ -1565,6 +1566,8 @@ public class LegacyAgent extends Agent {
}
private boolean validateCloserEntity(LivingEntity entity, Location loc, LivingEntity result) {
if (entity == null)
return false;
double regionDistEntity = getWeightedRegionDist(entity.getLocation());
if (regionDistEntity == Double.MAX_VALUE)
return false;

View File

@@ -132,7 +132,7 @@ public class LegacyMats {
public static final Set<Material> OBSTACLES = new HashSet<>(concatTypes(Lists.newArrayList(
Material.IRON_BARS,
Material.CHAIN,
Material.IRON_CHAIN,
Material.END_ROD,
Material.LIGHTNING_ROD,
Material.COBWEB,
@@ -282,7 +282,7 @@ public class LegacyMats {
public static boolean canPlaceWater(Block block, Optional<Double> entityYPos) {
if (isSolid(block.getType())) {
if (block.getType() == Material.CHAIN && ((Chain)block.getBlockData()).getAxis() == Axis.Y
if (block.getType() == Material.IRON_CHAIN && ((Chain)block.getBlockData()).getAxis() == Axis.Y
&& !((Chain)block.getBlockData()).isWaterlogged())
return false;
if ((block.getType().data == Leaves.class || block.getType() == Material.MANGROVE_ROOTS
@@ -387,7 +387,7 @@ public class LegacyMats {
case CACTUS:
case DRAGON_EGG:
case TURTLE_EGG:
case CHAIN:
case IRON_CHAIN:
case IRON_BARS:
case LANTERN:
case SOUL_LANTERN:

View File

@@ -7,7 +7,6 @@ import net.nuggetmc.tplus.api.agent.legacyagent.EnumTargetGoal;
import net.nuggetmc.tplus.api.agent.legacyagent.LegacyAgent;
import net.nuggetmc.tplus.api.utils.ChatUtils;
import net.nuggetmc.tplus.api.utils.MathUtils;
import net.nuggetmc.tplus.api.utils.MojangAPI;
import net.nuggetmc.tplus.api.utils.PlayerUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -102,14 +101,12 @@ public class IntelligenceAgent {
print("Starting generation " + ChatColor.RED + generation + ChatColor.RESET + "...");
sleep(2000);
//sleep(2000);
String skinName = botSkin == null ? this.botName : botSkin;
print("Fetching skin data for " + ChatColor.GREEN + skinName + ChatColor.RESET + "...");
String[] skinData = MojangAPI.getSkin(skinName);
String botName = this.botName.endsWith("%") ? this.botName : this.botName + "%";
print("Creating " + (populationSize == 1 ? "new bot" : ChatColor.RED + NumberFormat.getInstance(Locale.US).format(populationSize) + ChatColor.RESET + " new bots")
@@ -124,7 +121,7 @@ public class IntelligenceAgent {
Set<Terminator> bots;
if (loadedProfiles == null) {
bots = manager.createBots(loc, botName, skinData, populationSize, NeuralNetwork.RANDOM);
bots = manager.createBots(loc, botName, skinName, populationSize, NeuralNetwork.RANDOM);
} else {
List<NeuralNetwork> networks = new ArrayList<>();
loadedProfiles.forEach(profile -> networks.add(NeuralNetwork.createNetworkFromProfile(profile)));
@@ -136,7 +133,7 @@ public class IntelligenceAgent {
return;
}
bots = manager.createBots(loc, botName, skinData, networks);
bots = manager.createBots(loc, botName, skinName, networks);
}
bots.forEach(bot -> {
@@ -151,16 +148,16 @@ public class IntelligenceAgent {
});
while (bots.size() != populationSize) {
sleep(1000);
sleep(100);
}
sleep(2000);
//sleep(2000);
print("The bots will now attack each other.");
agent.setTargetType(EnumTargetGoal.NEAREST_BOT);
while (aliveCount() > 1) {
sleep(1000);
sleep(100);
}
print("Generation " + ChatColor.RED + generation + ChatColor.RESET + " has ended.");
@@ -188,7 +185,7 @@ public class IntelligenceAgent {
i++;
}
sleep(3000);
//sleep(3000);
Map<BotNode, Map<BotDataType, List<Double>>> lists = new HashMap<>();
@@ -236,9 +233,12 @@ public class IntelligenceAgent {
genProfiles.put(generation + 1, profiles);
sleep(2000);
//sleep(2000);
clearBots();
while (bots.size() != 0) {
sleep(100);
}
agent.setTargetType(EnumTargetGoal.NONE);
}
@@ -326,8 +326,11 @@ public class IntelligenceAgent {
if (!bots.isEmpty()) {
print("Removing all cached bots...");
bots.values().forEach(Terminator::removeBot);
bots.clear();
scheduler.runTask(plugin, () -> {
bots.values().forEach(Terminator::removeBot);
bots.clear();
});
}
/*print("Removing all current bots...");