Refactored BotUtils.java

This commit is contained in:
batchprogrammer314
2021-07-12 18:24:10 -05:00
parent 94da2ac11b
commit a10c330504
4 changed files with 16 additions and 19 deletions

View File

@@ -4,9 +4,9 @@ import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Pair;
import net.minecraft.server.v1_16_R3.*;
import net.nuggetmc.ai.PlayerAI;
import net.nuggetmc.ai.utils.BotUtils;
import net.nuggetmc.ai.utils.MathUtils;
import net.nuggetmc.ai.utils.MojangAPI;
import net.nuggetmc.ai.utils.SteveUUID;
import org.bukkit.Material;
import org.bukkit.SoundCategory;
import org.bukkit.World;
@@ -50,7 +50,7 @@ public class Bot extends EntityPlayer {
MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer nmsWorld = ((CraftWorld) Objects.requireNonNull(loc.getWorld())).getHandle();
UUID uuid = SteveUUID.generate();
UUID uuid = BotUtils.randomSteveUUID();
CustomGameProfile profile = new CustomGameProfile(uuid, name, skin);
PlayerInteractManager interactManager = new PlayerInteractManager(nmsWorld);

View File

@@ -1,12 +1,24 @@
package net.nuggetmc.ai.bot;
package net.nuggetmc.ai.utils;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.Vector;
import java.util.UUID;
public class BotUtils {
public static UUID randomSteveUUID() {
UUID uuid = UUID.randomUUID();
if (uuid.hashCode() % 2 == 0) {
return uuid;
}
return randomSteveUUID();
}
public static boolean solidAt(Location loc) { // not perfect, still cuts corners of fences
Block block = loc.getBlock();
BoundingBox box = block.getBoundingBox();

View File

@@ -1,16 +0,0 @@
package net.nuggetmc.ai.utils;
import java.util.UUID;
public class SteveUUID {
public static UUID generate() {
UUID uuid = UUID.randomUUID();
if (uuid.hashCode() % 2 == 0) {
return uuid;
}
return generate();
}
}