More intuituve EntityPlayer creation.
This commit is contained in:
@@ -37,6 +37,8 @@ public class Bot extends EntityPlayer {
|
|||||||
|
|
||||||
this.velocity = new Vector(0, 0, 0);
|
this.velocity = new Vector(0, 0, 0);
|
||||||
this.offset = MathUtils.circleOffset(3);
|
this.offset = MathUtils.circleOffset(3);
|
||||||
|
|
||||||
|
datawatcher.set(new DataWatcherObject<>(16, DataWatcherRegistry.a), (byte) 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bot createBot(Location loc, String name, String skin) {
|
public static Bot createBot(Location loc, String name, String skin) {
|
||||||
@@ -45,11 +47,9 @@ public class Bot extends EntityPlayer {
|
|||||||
|
|
||||||
UUID uuid = SteveUUID.generate();
|
UUID uuid = SteveUUID.generate();
|
||||||
|
|
||||||
CustomGameProfile profile = new CustomGameProfile(uuid, name);
|
CustomGameProfile profile = new CustomGameProfile(uuid, name, skin);
|
||||||
PlayerInteractManager interactManager = new PlayerInteractManager(nmsWorld);
|
PlayerInteractManager interactManager = new PlayerInteractManager(nmsWorld);
|
||||||
|
|
||||||
profile.setSkin(skin);
|
|
||||||
|
|
||||||
Bot bot = new Bot(nmsServer, nmsWorld, profile, interactManager);
|
Bot bot = new Bot(nmsServer, nmsWorld, profile, interactManager);
|
||||||
|
|
||||||
bot.playerConnection = new PlayerConnection(nmsServer, new NetworkManager(EnumProtocolDirection.CLIENTBOUND), bot);
|
bot.playerConnection = new PlayerConnection(nmsServer, new NetworkManager(EnumProtocolDirection.CLIENTBOUND), bot);
|
||||||
@@ -57,16 +57,14 @@ public class Bot extends EntityPlayer {
|
|||||||
bot.getBukkitEntity().setNoDamageTicks(0);
|
bot.getBukkitEntity().setNoDamageTicks(0);
|
||||||
nmsWorld.addEntity(bot);
|
nmsWorld.addEntity(bot);
|
||||||
|
|
||||||
bot.sendSpawnPackets();
|
bot.renderAll();
|
||||||
|
|
||||||
PlayerAI.getInstance().getManager().add(bot);
|
PlayerAI.getInstance().getManager().add(bot);
|
||||||
|
|
||||||
return bot;
|
return bot;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendSpawnPackets() {
|
private void renderAll() {
|
||||||
getDataWatcher().set(new DataWatcherObject<>(16, DataWatcherRegistry.a), (byte) 0xFF);
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
|
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||||
render(connection, false);
|
render(connection, false);
|
||||||
@@ -130,7 +128,7 @@ public class Bot extends EntityPlayer {
|
|||||||
groundTicks = 0;
|
groundTicks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player botPlayer = this.getBukkitEntity();
|
Player botPlayer = getBukkitEntity();
|
||||||
if (botPlayer.isDead()) return;
|
if (botPlayer.isDead()) return;
|
||||||
|
|
||||||
double health = botPlayer.getHealth();
|
double health = botPlayer.getHealth();
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class CustomGameProfile extends GameProfile {
|
public class CustomGameProfile extends GameProfile {
|
||||||
|
|
||||||
public CustomGameProfile(UUID uuid, String name) {
|
public CustomGameProfile(UUID uuid, String name, String skin) {
|
||||||
super(uuid, name);
|
super(uuid, name);
|
||||||
|
|
||||||
|
setSkin(skin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSkin(String skin) {
|
public void setSkin(String skin) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class CommandHandler {
|
|||||||
|
|
||||||
public CommandHandler(PlayerAI plugin) {
|
public CommandHandler(PlayerAI plugin) {
|
||||||
drink = (DrinkCommandService) Drink.get(plugin);
|
drink = (DrinkCommandService) Drink.get(plugin);
|
||||||
drink.register(new PlayerAICommand(this), "bot", "playerai", "pai", "ai", "npc");
|
drink.register(new PlayerAICommand(this), "bot", "playerai", "pai", "ai", "npc", "k");
|
||||||
drink.registerCommands();
|
drink.registerCommands();
|
||||||
|
|
||||||
help = new HashMap<>();
|
help = new HashMap<>();
|
||||||
|
|||||||
@@ -12,11 +12,8 @@ import net.nuggetmc.ai.commands.CommandInstance;
|
|||||||
import net.nuggetmc.ai.utils.ChatUtils;
|
import net.nuggetmc.ai.utils.ChatUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Particle;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|||||||
Reference in New Issue
Block a user