use of net.minecraft.server.v1_13_R1.WorldServer in project Citizens2 by CitizensDev.
the class HumanController method createEntity.
@Override
protected Entity createEntity(final Location at, final NPC npc) {
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
String coloredName = npc.getFullName();
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) {
// clear version
long msb = uuid.getMostSignificantBits();
msb &= ~0x0000000000004000L;
msb |= 0x0000000000002000L;
uuid = new UUID(msb, uuid.getLeastSignificantBits());
}
String teamName = Util.getTeamName(uuid);
if (npc.requiresNameHologram()) {
name = teamName;
}
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
Util.generateTeamFor(npc, name, teamName);
}
final GameProfile profile = new GameProfile(uuid, name);
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile, new PlayerInteractManager(nmsWorld), npc);
Skin skin = handle.getSkinTracker().getSkin();
if (skin != null) {
skin.apply(handle);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override
public void run() {
if (getBukkitEntity() == null || !getBukkitEntity().isValid() || getBukkitEntity() != handle.getBukkitEntity())
return;
boolean removeFromPlayerList = npc.data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList);
}
}, 20);
handle.getBukkitEntity().setSleepingIgnored(true);
return handle.getBukkitEntity();
}
use of net.minecraft.server.v1_13_R1.WorldServer in project Citizens2 by CitizensDev.
the class NMSImpl method updateNavigationWorld.
@Override
public void updateNavigationWorld(org.bukkit.entity.Entity entity, World world) {
if (NAVIGATION_WORLD_FIELD == null)
return;
Entity en = NMSImpl.getHandle(entity);
if (en == null || !(en instanceof EntityInsentient))
return;
EntityInsentient handle = (EntityInsentient) en;
WorldServer worldHandle = ((CraftWorld) world).getHandle();
try {
NAVIGATION_WORLD_FIELD.set(handle.getNavigation(), worldHandle);
} catch (Exception e) {
Messaging.logTr(Messages.ERROR_UPDATING_NAVIGATION_WORLD, e.getMessage());
}
}
use of net.minecraft.server.v1_13_R1.WorldServer in project Citizens2 by CitizensDev.
the class HumanController method createEntity.
@Override
protected Entity createEntity(final Location at, final NPC npc) {
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
String coloredName = npc.getFullName();
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) {
// clear version
long msb = uuid.getMostSignificantBits();
msb &= ~0x0000000000004000L;
msb |= 0x0000000000002000L;
uuid = new UUID(msb, uuid.getLeastSignificantBits());
}
String teamName = Util.getTeamName(uuid);
if (npc.requiresNameHologram()) {
name = teamName;
}
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
Util.generateTeamFor(npc, name, teamName);
}
final GameProfile profile = new GameProfile(uuid, name);
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile, new PlayerInteractManager(nmsWorld), npc);
Skin skin = handle.getSkinTracker().getSkin();
if (skin != null) {
skin.apply(handle);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override
public void run() {
if (getBukkitEntity() == null || !getBukkitEntity().isValid() || getBukkitEntity() != handle.getBukkitEntity())
return;
boolean removeFromPlayerList = npc.data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList);
}
}, 20);
handle.getBukkitEntity().setSleepingIgnored(true);
return handle.getBukkitEntity();
}
use of net.minecraft.server.v1_13_R1.WorldServer in project Citizens2 by CitizensDev.
the class NMSImpl method getCollisionBox.
@Override
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
AxisAlignedBB aabb = world.getType(pos).c(world, pos);
if (aabb == null) {
aabb = world.getType(pos).d(world, pos);
}
return new BoundingBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
}
use of net.minecraft.server.v1_13_R1.WorldServer in project Citizens2 by CitizensDev.
the class HumanController method createEntity.
@Override
protected Entity createEntity(final Location at, final NPC npc) {
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
String coloredName = npc.getFullName();
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) {
// clear version
long msb = uuid.getMostSignificantBits();
msb &= ~0x0000000000004000L;
msb |= 0x0000000000002000L;
uuid = new UUID(msb, uuid.getLeastSignificantBits());
}
String teamName = Util.getTeamName(uuid);
if (npc.requiresNameHologram()) {
name = teamName;
}
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
Util.generateTeamFor(npc, name, teamName);
}
final GameProfile profile = new GameProfile(uuid, name);
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile, new PlayerInteractManager(nmsWorld), npc);
Skin skin = handle.getSkinTracker().getSkin();
if (skin != null) {
skin.apply(handle);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override
public void run() {
if (getBukkitEntity() == null || !getBukkitEntity().isValid() || getBukkitEntity() != handle.getBukkitEntity())
return;
boolean removeFromPlayerList = npc.data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList);
}
}, 20);
handle.getBukkitEntity().setSleepingIgnored(true);
return handle.getBukkitEntity();
}
Aggregations