mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-16 12:21:25 +01:00
Add per-player rotation API
This commit is contained in:
parent
f93266135b
commit
b8050199f1
@ -1,5 +1,7 @@
|
||||
package net.citizensnpcs;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import com.comphenix.protocol.PacketType.Play.Server;
|
||||
@ -7,43 +9,81 @@ import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.trait.SmoothRotationTrait;
|
||||
import net.citizensnpcs.trait.SmoothRotationTrait.LocalRotationSession;
|
||||
|
||||
public class ProtocolLibListener {
|
||||
private final Class<?> flagsClass;
|
||||
private final ProtocolManager manager;
|
||||
private final Citizens plugin;
|
||||
|
||||
public ProtocolLibListener(Citizens plugin) {
|
||||
this.plugin = plugin;
|
||||
this.manager = ProtocolLibrary.getProtocolManager();
|
||||
flagsClass = MinecraftReflection.getMinecraftClass("EnumPlayerTeleportFlags",
|
||||
"PacketPlayOutPosition$EnumPlayerTeleportFlags",
|
||||
"network.protocol.game.PacketPlayOutPosition$EnumPlayerTeleportFlags");
|
||||
manager.addPacketListener(
|
||||
new PacketAdapter(plugin, ListenerPriority.MONITOR, Server.ENTITY_HEAD_ROTATION, Server.ENTITY_LOOK) {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
Entity entity = manager.getEntityFromID(event.getPlayer().getWorld(),
|
||||
event.getPacket().getIntegers().getValues().get(0));
|
||||
packet.getIntegers().getValues().get(0));
|
||||
if (!(entity instanceof NPCHolder))
|
||||
return;
|
||||
|
||||
NPC npc = ((NPCHolder) entity).getNPC();
|
||||
SmoothRotationTrait trait = npc.getTraitNullable(SmoothRotationTrait.class);
|
||||
if (trait == null)
|
||||
return;
|
||||
|
||||
LocalRotationSession session = trait.getLocalSession(event.getPlayer());
|
||||
if (session == null || !session.isActive())
|
||||
return;
|
||||
|
||||
if (event.getPacketType() == Server.ENTITY_HEAD_ROTATION) {
|
||||
byte headYaw = event.getPacket().getBytes().read(0);
|
||||
packet.getBytes().write(0, degToByte(session.getHeadYaw()));
|
||||
} else if (event.getPacketType() == Server.ENTITY_LOOK) {
|
||||
byte yaw = event.getPacket().getBytes().read(0);
|
||||
byte pitch = event.getPacket().getBytes().read(1);
|
||||
packet.getBytes().write(0, degToByte(session.getBodyYaw()));
|
||||
packet.getBytes().write(1, degToByte(session.getPitch()));
|
||||
} else if (event.getPacketType() == Server.ENTITY_MOVE_LOOK
|
||||
|| event.getPacketType() == Server.REL_ENTITY_MOVE_LOOK) {
|
||||
byte yaw = event.getPacket().getBytes().read(0);
|
||||
byte pitch = event.getPacket().getBytes().read(1);
|
||||
packet.getBytes().write(0, degToByte(session.getBodyYaw()));
|
||||
packet.getBytes().write(1, degToByte(session.getPitch()));
|
||||
} else if (event.getPacketType() == Server.POSITION) {
|
||||
Set<PlayerTeleportFlag> rel = getFlagsModifier(packet).read(0);
|
||||
rel.remove(PlayerTeleportFlag.ZYAW);
|
||||
rel.remove(PlayerTeleportFlag.ZPITCH);
|
||||
getFlagsModifier(packet).write(0, rel);
|
||||
packet.getFloat().write(0, session.getBodyYaw());
|
||||
packet.getFloat().write(1, session.getPitch());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static byte degToByte(float in) {
|
||||
return (byte) (in * 256.0F / 360.0F);
|
||||
}
|
||||
|
||||
private StructureModifier<Set<PlayerTeleportFlag>> getFlagsModifier(PacketContainer handle) {
|
||||
return handle.getSets(EnumWrappers.getGenericConverter(flagsClass, PlayerTeleportFlag.class));
|
||||
}
|
||||
|
||||
public enum PlayerTeleportFlag {
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
ZPITCH,
|
||||
ZYAW,
|
||||
}
|
||||
}
|
||||
|
41
main/src/main/java/net/citizensnpcs/WorldPlayerCache.java
Normal file
41
main/src/main/java/net/citizensnpcs/WorldPlayerCache.java
Normal file
@ -0,0 +1,41 @@
|
||||
package net.citizensnpcs;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import ch.ethz.globis.phtree.PhTreeF;
|
||||
|
||||
public class WorldPlayerCache implements Runnable {
|
||||
private final Map<UUID, PhTreeF<Player>> worlds = Maps.newHashMap();
|
||||
|
||||
public PhTreeF<Player> getPlayersByWorld(World world) {
|
||||
return worlds.get(world.getUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
worlds.clear();
|
||||
for (World world : Bukkit.getServer().getWorlds()) {
|
||||
List<Player> players = world.getPlayers();
|
||||
if (players.isEmpty())
|
||||
continue;
|
||||
PhTreeF<Player> tree = PhTreeF.create(3);
|
||||
worlds.put(world.getUID(), tree);
|
||||
Location loc = new Location(null, 0, 0, 0);
|
||||
for (Player player : players) {
|
||||
if (player.hasMetadata("NPC"))
|
||||
continue;
|
||||
player.getLocation(loc);
|
||||
tree.put(new double[] { loc.getX(), loc.getY(), loc.getZ() }, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -133,6 +133,7 @@ import net.citizensnpcs.trait.SkinLayers;
|
||||
import net.citizensnpcs.trait.SkinLayers.Layer;
|
||||
import net.citizensnpcs.trait.SkinTrait;
|
||||
import net.citizensnpcs.trait.SlimeSize;
|
||||
import net.citizensnpcs.trait.SmoothRotationTrait;
|
||||
import net.citizensnpcs.trait.VillagerProfession;
|
||||
import net.citizensnpcs.trait.WitherTrait;
|
||||
import net.citizensnpcs.trait.WolfModifiers;
|
||||
@ -402,12 +403,12 @@ public class NPCCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "command|cmd (add [command] | remove [id] | permissions [permissions] | sequential | random | clearerror [type] (name|uuid) | errormsg [type] [msg] | (exp|item)cost [cost]) (-l[eft]/-r[ight]) (-p[layer] -o[p]), --cooldown --gcooldown [seconds] --delay [ticks] --permissions [perms] --n [max # of uses]",
|
||||
usage = "command|cmd (add [command] | remove [id] | permissions [permissions] | sequential | random | clearerror [type] (name|uuid) | errormsg [type] [msg] | persistsequence [true|false] | (exp|item)cost [cost]) (-s(hift)) (-l[eft]/-r[ight]) (-p[layer] -o[p]), --cooldown --gcooldown [seconds] --delay [ticks] --permissions [perms] --n [max # of uses]",
|
||||
desc = "Controls commands which will be run when clicking on an NPC",
|
||||
help = Messages.NPC_COMMAND_HELP,
|
||||
modifiers = { "command", "cmd" },
|
||||
min = 1,
|
||||
flags = "lrpo",
|
||||
flags = "lrpos",
|
||||
permission = "citizens.npc.command")
|
||||
public void command(CommandContext args, CommandSender sender, NPC npc, @Flag("permissions") String permissions,
|
||||
@Flag(value = "cooldown", defValue = "0") int cooldown,
|
||||
@ -415,8 +416,8 @@ public class NPCCommands {
|
||||
@Flag(value = "delay", defValue = "0") int delay,
|
||||
@Arg(
|
||||
value = 1,
|
||||
completions = { "add", "remove", "permissions", "sequential", "random", "hideerrors", "errormsg",
|
||||
"clearerror", "expcost", "itemcost" }) String action)
|
||||
completions = { "add", "remove", "permissions", "persistsequence", "sequential", "random",
|
||||
"hideerrors", "errormsg", "clearerror", "expcost", "itemcost" }) String action)
|
||||
throws CommandException {
|
||||
CommandTrait commands = npc.getOrAddTrait(CommandTrait.class);
|
||||
if (args.argsLength() == 1) {
|
||||
@ -429,6 +430,9 @@ public class NPCCommands {
|
||||
String command = args.getJoinedStrings(2);
|
||||
CommandTrait.Hand hand = args.hasFlag('l') && args.hasFlag('r') ? CommandTrait.Hand.BOTH
|
||||
: args.hasFlag('l') ? CommandTrait.Hand.LEFT : CommandTrait.Hand.RIGHT;
|
||||
if (args.hasFlag('s') && hand != CommandTrait.Hand.BOTH) {
|
||||
hand = hand == CommandTrait.Hand.LEFT ? CommandTrait.Hand.SHIFT_LEFT : CommandTrait.Hand.SHIFT_RIGHT;
|
||||
}
|
||||
List<String> perms = Lists.newArrayList();
|
||||
if (permissions != null) {
|
||||
perms.addAll(Arrays.asList(permissions.split(",")));
|
||||
@ -465,6 +469,14 @@ public class NPCCommands {
|
||||
Messaging.sendTr(sender,
|
||||
commands.getExecutionMode() == ExecutionMode.SEQUENTIAL ? Messages.COMMANDS_SEQUENTIAL_SET
|
||||
: Messages.COMMANDS_SEQUENTIAL_UNSET);
|
||||
} else if (action.equalsIgnoreCase("persistsequence")) {
|
||||
if (args.argsLength() == 2) {
|
||||
commands.setPersistSequence(!commands.persistSequence());
|
||||
} else {
|
||||
commands.setPersistSequence(Boolean.parseBoolean(args.getString(3)));
|
||||
}
|
||||
Messaging.sendTr(sender, commands.persistSequence() ? Messages.COMMANDS_PERSIST_SEQUENCE_SET
|
||||
: Messages.COMMANDS_PERSIST_SEQUENCE_UNSET);
|
||||
} else if (action.equalsIgnoreCase("remove")) {
|
||||
if (args.argsLength() == 2)
|
||||
throw new CommandUsageException();
|
||||
@ -1290,7 +1302,7 @@ public class NPCCommands {
|
||||
aliases = { "npc" },
|
||||
usage = "lookclose --range [range] -r[ealistic looking] --randomlook [true|false] --randomswitchtargets [true|false] --randompitchrange [min,max] --randomyawrange [min,max] --disablewhennavigating [true|false]",
|
||||
desc = "Toggle whether a NPC will look when a player is near",
|
||||
modifiers = { "lookclose", "look", "rotate" },
|
||||
modifiers = { "lookclose", "look" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
flags = "r",
|
||||
@ -2101,6 +2113,42 @@ public class NPCCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "rotate (--body [yaw]) (--head [yaw]) (--pitch [pitch]) (-s(mooth))",
|
||||
desc = "Rotate NPC",
|
||||
flags = "s",
|
||||
modifiers = { "rotate" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
permission = "citizens.npc.rotate")
|
||||
public void rotate(CommandContext args, CommandSender sender, NPC npc, @Flag("body") Float yaw,
|
||||
@Flag("head") Float head, @Flag("pitch") Float pitch) {
|
||||
if (args.hasFlag('s')) {
|
||||
if (pitch == null) {
|
||||
pitch = npc.getStoredLocation().getPitch();
|
||||
}
|
||||
if (yaw == null) {
|
||||
if (head != null) {
|
||||
yaw = head;
|
||||
} else {
|
||||
yaw = NMS.getHeadYaw(npc.getEntity());
|
||||
}
|
||||
}
|
||||
npc.getOrAddTrait(SmoothRotationTrait.class).rotateToHave(yaw, pitch);
|
||||
return;
|
||||
}
|
||||
if (yaw != null) {
|
||||
NMS.setBodyYaw(npc.getEntity(), yaw);
|
||||
}
|
||||
if (pitch != null) {
|
||||
NMS.setPitch(npc.getEntity(), pitch);
|
||||
}
|
||||
if (head != null) {
|
||||
NMS.setHeadYaw(npc.getEntity(), head);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "scoreboard --addtag [tags] --removetag [tags]",
|
||||
|
@ -75,6 +75,8 @@ public class CommandTrait extends Trait {
|
||||
private boolean hideErrorMessages;
|
||||
@Persist
|
||||
private final List<ItemStack> itemRequirements = Lists.newArrayList();
|
||||
@Persist
|
||||
private boolean persistSequence = false;
|
||||
@Persist(keyType = UUID.class, reify = true, value = "cooldowns")
|
||||
private final Map<UUID, PlayerNPCCommand> playerTracking = Maps.newHashMap();
|
||||
@Persist
|
||||
@ -171,10 +173,10 @@ public class CommandTrait extends Trait {
|
||||
List<NPCCommand> left = Lists.newArrayList();
|
||||
List<NPCCommand> right = Lists.newArrayList();
|
||||
for (NPCCommand command : commands.values()) {
|
||||
if (command.hand == Hand.LEFT || command.hand == Hand.BOTH) {
|
||||
if (command.hand == Hand.LEFT || command.hand == Hand.SHIFT_LEFT || command.hand == Hand.BOTH) {
|
||||
left.add(command);
|
||||
}
|
||||
if (command.hand == Hand.RIGHT || command.hand == Hand.BOTH) {
|
||||
if (command.hand == Hand.RIGHT || command.hand == Hand.SHIFT_RIGHT || command.hand == Hand.BOTH) {
|
||||
right.add(command);
|
||||
}
|
||||
}
|
||||
@ -222,7 +224,10 @@ public class CommandTrait extends Trait {
|
||||
return output;
|
||||
}
|
||||
|
||||
public void dispatch(final Player player, final Hand hand) {
|
||||
public void dispatch(final Player player, Hand handIn) {
|
||||
final Hand hand = player.isSneaking()
|
||||
? (handIn == CommandTrait.Hand.LEFT ? CommandTrait.Hand.SHIFT_LEFT : CommandTrait.Hand.SHIFT_RIGHT)
|
||||
: handIn;
|
||||
NPCCommandDispatchEvent event = new NPCCommandDispatchEvent(npc, player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
@ -233,8 +238,9 @@ public class CommandTrait extends Trait {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
List<NPCCommand> commandList = Lists.newArrayList(Iterables.filter(commands.values(),
|
||||
command -> command.hand == hand || command.hand == Hand.BOTH));
|
||||
List<NPCCommand> commandList = Lists.newArrayList(Iterables.filter(commands.values(), command -> {
|
||||
return command.hand == hand || command.hand == Hand.BOTH;
|
||||
}));
|
||||
if (executionMode == ExecutionMode.RANDOM) {
|
||||
if (commandList.size() > 0) {
|
||||
runCommand(player, commandList.get(Util.getFastRandom().nextInt(commandList.size())));
|
||||
@ -339,6 +345,10 @@ public class CommandTrait extends Trait {
|
||||
return hideErrorMessages;
|
||||
}
|
||||
|
||||
public boolean persistSequence() {
|
||||
return persistSequence;
|
||||
}
|
||||
|
||||
public void removeCommandById(int id) {
|
||||
commands.remove(id);
|
||||
}
|
||||
@ -349,7 +359,8 @@ public class CommandTrait extends Trait {
|
||||
for (Iterator<PlayerNPCCommand> itr = playerTracking.values().iterator(); itr.hasNext();) {
|
||||
PlayerNPCCommand playerCommand = itr.next();
|
||||
playerCommand.prune(globalCooldowns, commands);
|
||||
if (playerCommand.lastUsed.isEmpty() && playerCommand.nUsed.isEmpty() && playerCommand.lastUsedId == -1) {
|
||||
if (playerCommand.lastUsed.isEmpty() && playerCommand.nUsed.isEmpty()
|
||||
&& (!persistSequence || playerCommand.lastUsedId == -1)) {
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
@ -395,6 +406,10 @@ public class CommandTrait extends Trait {
|
||||
this.hideErrorMessages = hide;
|
||||
}
|
||||
|
||||
public void setPersistSequence(boolean persistSequence) {
|
||||
this.persistSequence = persistSequence;
|
||||
}
|
||||
|
||||
public void setTemporaryPermissions(List<String> permissions) {
|
||||
temporaryPermissions.clear();
|
||||
temporaryPermissions.addAll(permissions);
|
||||
@ -430,7 +445,9 @@ public class CommandTrait extends Trait {
|
||||
public static enum Hand {
|
||||
BOTH,
|
||||
LEFT,
|
||||
RIGHT;
|
||||
RIGHT,
|
||||
SHIFT_LEFT,
|
||||
SHIFT_RIGHT;
|
||||
}
|
||||
|
||||
@Menu(title = "Drag items for requirements", type = InventoryType.CHEST, dimensions = { 5, 9 })
|
||||
@ -728,12 +745,14 @@ public class CommandTrait extends Trait {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> diff = Sets.newHashSet(lastUsed.keySet());
|
||||
diff.removeAll(commandKeys);
|
||||
for (String key : diff) {
|
||||
lastUsed.remove(key);
|
||||
nUsed.remove(key);
|
||||
}
|
||||
|
||||
if (globalCooldowns != null) {
|
||||
diff = Sets.newHashSet(globalCooldowns.keySet());
|
||||
diff.removeAll(commandKeys);
|
||||
|
@ -16,10 +16,6 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.command.CommandConfigurable;
|
||||
import net.citizensnpcs.api.command.CommandContext;
|
||||
import net.citizensnpcs.api.command.CommandMessages;
|
||||
import net.citizensnpcs.api.command.exception.CommandException;
|
||||
import net.citizensnpcs.api.event.NPCLookCloseChangeTargetEvent;
|
||||
import net.citizensnpcs.api.persistence.Persist;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
@ -33,7 +29,7 @@ import net.citizensnpcs.util.Util;
|
||||
*
|
||||
*/
|
||||
@TraitName("lookclose")
|
||||
public class LookClose extends Trait implements Toggleable, CommandConfigurable {
|
||||
public class LookClose extends Trait implements Toggleable {
|
||||
@Persist("disablewhilenavigating")
|
||||
private boolean disableWhileNavigating = Setting.DISABLE_LOOKCLOSE_WHILE_NAVIGATING.asBoolean();
|
||||
@Persist("enabled")
|
||||
@ -74,16 +70,6 @@ public class LookClose extends Trait implements Toggleable, CommandConfigurable
|
||||
return canSee(lookingAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(CommandContext args) throws CommandException {
|
||||
try {
|
||||
range = args.getFlagDouble("range", args.getFlagDouble("r", range));
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new CommandException(CommandMessages.INVALID_NUMBER);
|
||||
}
|
||||
realisticLooking = args.hasFlag('r');
|
||||
}
|
||||
|
||||
public boolean disableWhileNavigating() {
|
||||
return disableWhileNavigating;
|
||||
}
|
||||
|
@ -292,6 +292,15 @@ public class ShopTrait extends Trait {
|
||||
if (meta.hasDisplayName()) {
|
||||
meta.setDisplayName(Placeholders.replace(meta.getDisplayName(), player));
|
||||
}
|
||||
if (!meta.hasLore()) {
|
||||
List<String> lore = Lists.newArrayList();
|
||||
if (cost.size() > 0) {
|
||||
result.forEach((a) -> lore.add(a.describe()));
|
||||
}
|
||||
if (result.size() > 0) {
|
||||
result.forEach((a) -> lore.add(a.describe()));
|
||||
}
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
meta.setLore(Lists.transform(meta.getLore(), line -> Placeholders.replace(line, player)));
|
||||
}
|
||||
|
@ -1,9 +1,16 @@
|
||||
package net.citizensnpcs.trait;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.citizensnpcs.api.persistence.Persist;
|
||||
import net.citizensnpcs.api.persistence.Persistable;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
@ -14,16 +21,30 @@ import net.citizensnpcs.util.Util;
|
||||
|
||||
@TraitName("smoothrotationtrait")
|
||||
public class SmoothRotationTrait extends Trait {
|
||||
@Persist
|
||||
private Float defaultPitch;
|
||||
@Persist(reify = true)
|
||||
private final RotationParams globalParameters = new RotationParams();
|
||||
private final SmoothRotationSession globalSession = new SmoothRotationSession(globalParameters);
|
||||
private final RotationSession globalSession = new RotationSession(globalParameters);
|
||||
private final List<LocalRotationSession> localSessions = Lists.newArrayList();
|
||||
|
||||
public SmoothRotationTrait() {
|
||||
super("smoothrotationtrait");
|
||||
}
|
||||
|
||||
public void clearLocalSessions() {
|
||||
localSessions.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The created session
|
||||
*/
|
||||
public RotationSession createLocalSession(RotationParams params) {
|
||||
if (params.filter == null)
|
||||
throw new IllegalStateException();
|
||||
RotationSession session = new RotationSession(params);
|
||||
localSessions.add(new LocalRotationSession(session));
|
||||
return session;
|
||||
}
|
||||
|
||||
private double getEyeY() {
|
||||
return NMS.getHeight(npc.getEntity());
|
||||
}
|
||||
@ -35,6 +56,15 @@ public class SmoothRotationTrait extends Trait {
|
||||
return globalParameters;
|
||||
}
|
||||
|
||||
public LocalRotationSession getLocalSession(Player player) {
|
||||
for (LocalRotationSession session : localSessions) {
|
||||
if (session.accepts(player)) {
|
||||
return session;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private double getX() {
|
||||
return npc.getStoredLocation().getX();
|
||||
}
|
||||
@ -78,55 +108,108 @@ public class SmoothRotationTrait extends Trait {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!npc.isSpawned() || npc.getNavigator().isNavigating()) {
|
||||
if (!npc.isSpawned())
|
||||
return;
|
||||
|
||||
for (Iterator<LocalRotationSession> itr = localSessions.iterator(); itr.hasNext();) {
|
||||
LocalRotationSession session = itr.next();
|
||||
session.run(npc.getEntity());
|
||||
if (!session.isActive()) {
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (npc.getNavigator().isNavigating()) {
|
||||
// npc.yHeadRot = rotateIfNecessary(npc.yHeadRot, npc.yBodyRot, 75);
|
||||
return;
|
||||
}
|
||||
if (!globalSession.hasTarget()) {
|
||||
return;
|
||||
}
|
||||
EntityRotation rot = new EntityRotation(npc.getEntity());
|
||||
globalSession.run(rot);
|
||||
if (!globalSession.hasTarget()) {
|
||||
rot.bodyYaw = rot.headYaw;
|
||||
}
|
||||
rot.apply(npc.getEntity());
|
||||
|
||||
globalSession.run(new EntityRotation(npc.getEntity()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets default pitch when not looking at anything
|
||||
*
|
||||
* @param pitch
|
||||
* The default pitch
|
||||
*/
|
||||
public void setDefaultPitch(float pitch) {
|
||||
defaultPitch = pitch;
|
||||
}
|
||||
|
||||
private static class EntityRotation {
|
||||
public float bodyYaw, headYaw, pitch;
|
||||
private static class EntityRotation extends RotationTriple {
|
||||
protected final Entity entity;
|
||||
|
||||
public EntityRotation(Entity entity) {
|
||||
this.bodyYaw = NMS.getYaw(entity);
|
||||
this.headYaw = NMS.getHeadYaw(entity);
|
||||
this.pitch = entity.getLocation().getPitch();
|
||||
super(NMS.getYaw(entity), NMS.getHeadYaw(entity), entity.getLocation().getPitch());
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public void apply(Entity entity) {
|
||||
@Override
|
||||
public void apply() {
|
||||
NMS.setBodyYaw(entity, bodyYaw);
|
||||
NMS.setHeadYaw(entity, headYaw);
|
||||
NMS.setPitch(entity, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
public static class LocalRotationSession {
|
||||
private final RotationSession session;
|
||||
private RotationTriple triple;
|
||||
|
||||
public LocalRotationSession(RotationSession session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
public boolean accepts(Player player) {
|
||||
return session.params.accepts(player);
|
||||
}
|
||||
|
||||
public float getBodyYaw() {
|
||||
return triple.bodyYaw;
|
||||
}
|
||||
|
||||
public float getHeadYaw() {
|
||||
return triple.headYaw;
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return triple.pitch;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return session.isActive();
|
||||
}
|
||||
|
||||
public void run(Entity entity) {
|
||||
if (triple == null) {
|
||||
triple = new PacketRotationTriple(entity);
|
||||
}
|
||||
session.run(triple);
|
||||
if (!session.isActive()) {
|
||||
triple = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class PacketRotationTriple extends EntityRotation {
|
||||
public PacketRotationTriple(Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Location loc = entity.getLocation();
|
||||
loc.setPitch(pitch);
|
||||
loc.setYaw(headYaw);
|
||||
NMS.sendRotationNearby(entity, bodyYaw, headYaw, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
public static class RotationParams implements Persistable, Cloneable {
|
||||
private Function<Player, Boolean> filter;
|
||||
private boolean headOnly = false;
|
||||
private boolean immediate = false;
|
||||
private float maxPitchPerTick = 10;
|
||||
private float maxYawPerTick = 40;
|
||||
private boolean persist = false;
|
||||
private float[] pitchRange = { -180, 180 };
|
||||
private float[] yawRange = { -180, 180 };
|
||||
|
||||
public boolean accepts(Player player) {
|
||||
return filter.apply(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RotationParams clone() {
|
||||
try {
|
||||
@ -136,6 +219,11 @@ public class SmoothRotationTrait extends Trait {
|
||||
}
|
||||
}
|
||||
|
||||
public RotationParams filter(Function<Player, Boolean> filter) {
|
||||
this.filter = filter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RotationParams headOnly(boolean headOnly) {
|
||||
this.headOnly = headOnly;
|
||||
return this;
|
||||
@ -180,6 +268,11 @@ public class SmoothRotationTrait extends Trait {
|
||||
return this;
|
||||
}
|
||||
|
||||
public RotationParams persist(boolean persist) {
|
||||
this.persist = persist;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RotationParams pitchRange(float[] val) {
|
||||
this.pitchRange = val;
|
||||
return this;
|
||||
@ -212,6 +305,7 @@ public class SmoothRotationTrait extends Trait {
|
||||
if (headOnly) {
|
||||
key.setBoolean("headOnly", headOnly);
|
||||
}
|
||||
|
||||
if (immediate) {
|
||||
key.setBoolean("immediate", immediate);
|
||||
}
|
||||
@ -247,12 +341,12 @@ public class SmoothRotationTrait extends Trait {
|
||||
}
|
||||
}
|
||||
|
||||
public class SmoothRotationSession {
|
||||
public class RotationSession {
|
||||
private final RotationParams params;
|
||||
private int t = -1;
|
||||
private double tx, ty, tz;
|
||||
|
||||
public SmoothRotationSession(RotationParams params) {
|
||||
public RotationSession(RotationParams params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@ -280,15 +374,17 @@ public class SmoothRotationTrait extends Trait {
|
||||
return tz;
|
||||
}
|
||||
|
||||
public boolean hasTarget() {
|
||||
return t >= 0;
|
||||
public boolean isActive() {
|
||||
return params.persist || t >= 0;
|
||||
}
|
||||
|
||||
public void run(EntityRotation rot) {
|
||||
if (!hasTarget())
|
||||
private void run(RotationTriple rot) {
|
||||
if (!isActive())
|
||||
return;
|
||||
|
||||
rot.headYaw = params.immediate ? getTargetYaw()
|
||||
: Util.clamp(params.rotateHeadYawTowards(t, rot.headYaw, getTargetYaw()));
|
||||
|
||||
if (!params.headOnly) {
|
||||
float d = Util.clamp(rot.headYaw - 35);
|
||||
if (d > rot.bodyYaw) {
|
||||
@ -301,11 +397,16 @@ public class SmoothRotationTrait extends Trait {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rot.pitch = params.immediate ? getTargetPitch() : params.rotatePitchTowards(t, rot.pitch, getTargetPitch());
|
||||
t++;
|
||||
|
||||
if (Math.abs(rot.pitch - getTargetPitch()) + Math.abs(rot.headYaw - getTargetYaw()) < 0.1) {
|
||||
t = -1;
|
||||
rot.bodyYaw = rot.headYaw;
|
||||
}
|
||||
|
||||
rot.apply();
|
||||
}
|
||||
|
||||
public void setTarget(Location target) {
|
||||
@ -316,6 +417,28 @@ public class SmoothRotationTrait extends Trait {
|
||||
}
|
||||
}
|
||||
|
||||
private static abstract class RotationTriple implements Cloneable {
|
||||
public float bodyYaw, headYaw, pitch;
|
||||
|
||||
public RotationTriple(float bodyYaw, float headYaw, float pitch) {
|
||||
this.bodyYaw = bodyYaw;
|
||||
this.headYaw = headYaw;
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public abstract void apply();
|
||||
|
||||
@Override
|
||||
public RotationTriple clone() {
|
||||
try {
|
||||
return (RotationTriple) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static float clamp(float orig, float min, float max) {
|
||||
return Math.max(min, Math.min(max, orig));
|
||||
}
|
||||
|
@ -69,6 +69,20 @@ public class ItemAction extends NPCShopAction {
|
||||
return required.size() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
String description = items.size() + " items";
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
ItemStack item = items.get(i);
|
||||
description += "\n" + item.getAmount() + " " + Util.prettyEnum(item.getType());
|
||||
if (i == 3) {
|
||||
description += "...";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction grant(Entity entity) {
|
||||
if (!(entity instanceof InventoryHolder))
|
||||
@ -175,15 +189,7 @@ public class ItemAction extends NPCShopAction {
|
||||
String description = null;
|
||||
if (previous != null) {
|
||||
ItemAction old = (ItemAction) previous;
|
||||
description = old.items.size() + " items";
|
||||
for (int i = 0; i < old.items.size(); i++) {
|
||||
ItemStack item = old.items.get(i);
|
||||
description += "\n" + item.getAmount() + " " + Util.prettyEnum(item.getType());
|
||||
if (i == 3) {
|
||||
description += "...";
|
||||
break;
|
||||
}
|
||||
}
|
||||
description = old.describe();
|
||||
}
|
||||
return Util.createItem(Material.CHEST, "Item", description);
|
||||
}
|
||||
|
@ -21,6 +21,12 @@ public class MoneyAction extends NPCShopAction {
|
||||
public MoneyAction() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
Economy economy = Bukkit.getServicesManager().getRegistration(Economy.class).getProvider();
|
||||
return money + " " + economy.currencyNamePlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction grant(Entity entity) {
|
||||
if (!(entity instanceof Player))
|
||||
@ -85,9 +91,8 @@ public class MoneyAction extends NPCShopAction {
|
||||
}
|
||||
String description = null;
|
||||
if (previous != null) {
|
||||
Economy economy = Bukkit.getServicesManager().getRegistration(Economy.class).getProvider();
|
||||
MoneyAction old = (MoneyAction) previous;
|
||||
description = old.money + " " + economy.currencyNamePlural();
|
||||
description = old.describe();
|
||||
}
|
||||
return Util.createItem(Material.GOLD_INGOT, "Money", description);
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ public abstract class NPCShopAction implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String describe();
|
||||
|
||||
public abstract Transaction grant(Entity entity);
|
||||
|
||||
public abstract Transaction take(Entity entity);
|
||||
|
@ -32,6 +32,19 @@ public class PermissionAction extends NPCShopAction {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
String description = permissions.size() + " permissions";
|
||||
for (int i = 0; i < permissions.size(); i++) {
|
||||
description += "\n" + permissions.get(i);
|
||||
if (i == 3) {
|
||||
description += "...";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction grant(Entity entity) {
|
||||
if (!(entity instanceof Player))
|
||||
@ -153,14 +166,7 @@ public class PermissionAction extends NPCShopAction {
|
||||
String description = null;
|
||||
if (previous != null) {
|
||||
PermissionAction old = (PermissionAction) previous;
|
||||
description = old.permissions.size() + " permissions";
|
||||
for (int i = 0; i < old.permissions.size(); i++) {
|
||||
description += "\n" + old.permissions.get(i);
|
||||
if (i == 3) {
|
||||
description += "...";
|
||||
break;
|
||||
}
|
||||
}
|
||||
description = old.describe();
|
||||
}
|
||||
return Util.createItem(Util.getFallbackMaterial("OAK_SIGN", "SIGN"), "Permission", description);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.citizensnpcs.nms.v1_8_R3.network;
|
||||
package net.citizensnpcs.util;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.citizensnpcs.nms.v1_19_R1.network;
|
||||
package net.citizensnpcs.util;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
@ -73,6 +73,8 @@ public class Messages {
|
||||
public static final String COMMAND_SAVE_HELP = "citizens.commands.citizens.save.help";
|
||||
public static final String COMMAND_TEMPORARY_PERMISSIONS_SET = "citizens.commands.npc.command.temporary-permissions-set";
|
||||
public static final String COMMAND_UNKNOWN_COMMAND_ID = "citizens.commands.npc.command.unknown-id";
|
||||
public static final String COMMANDS_PERSIST_SEQUENCE_SET = "citizens.commands.npc.command.persist-sequence-set";
|
||||
public static final String COMMANDS_PERSIST_SEQUENCE_UNSET = "citizens.commands.npc.command.persist-sequence-unset";
|
||||
public static final String COMMANDS_RANDOM_SET = "citizens.commands.npc.commands.random-set";
|
||||
public static final String COMMANDS_RANDOM_UNSET = "citizens.commands.npc.commands.random-unset";
|
||||
public static final String COMMANDS_SEQUENTIAL_SET = "citizens.commands.npc.commands.sequential-set";
|
||||
|
@ -495,8 +495,12 @@ public class NMS {
|
||||
BRIDGE.replaceTrackerEntry(player);
|
||||
}
|
||||
|
||||
public static void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location storedLocation) {
|
||||
BRIDGE.sendPositionUpdate(excluding, from, storedLocation);
|
||||
public static void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location location) {
|
||||
BRIDGE.sendPositionUpdate(excluding, from, location);
|
||||
}
|
||||
|
||||
public static void sendRotationNearby(Entity entity, float bodyYaw, float headYaw, float pitch) {
|
||||
BRIDGE.sendRotationNearby(entity, bodyYaw, headYaw, pitch);
|
||||
}
|
||||
|
||||
public static void sendTabListAdd(Player recipient, Player listPlayer) {
|
||||
@ -658,7 +662,6 @@ public class NMS {
|
||||
private static Object UNSAFE;
|
||||
private static MethodHandle UNSAFE_FIELD_OFFSET;
|
||||
private static MethodHandle UNSAFE_PUT_OBJECT;
|
||||
|
||||
private static MethodHandle UNSAFE_STATIC_FIELD_OFFSET;
|
||||
|
||||
static {
|
||||
|
@ -129,7 +129,9 @@ public interface NMSBridge {
|
||||
|
||||
public void replaceTrackerEntry(Player player);
|
||||
|
||||
public void sendPositionUpdate(Player excluding, Entity from, Location storedLocation);
|
||||
public void sendPositionUpdate(Player excluding, Entity from, Location location);
|
||||
|
||||
public void sendRotationNearby(Entity from, float bodyYaw, float headYaw, float pitch);
|
||||
|
||||
public void sendTabListAdd(Player recipient, Player listPlayer);
|
||||
|
||||
|
@ -52,6 +52,8 @@ citizens.commands.npc.chunkload.set=[[{0}]] will now force chunks to be loaded.
|
||||
citizens.commands.npc.chunkload.unset=[[{0}]] will no longer force chunks to be loaded.
|
||||
citizens.commands.npc.collidable.set=[[{0}]] will now collide with entities.
|
||||
citizens.commands.npc.collidable.unset=[[{0}]] will no longer collide with entities.
|
||||
citizens.commands.npc.command.persist-sequence-set=Command sequences will now be saved across server restarts.
|
||||
citizens.commands.npc.command.persist-sequence-unset=Command sequences will no longer be saved across server restarts.
|
||||
citizens.commands.npc.command.none-added=No commands have been added.
|
||||
citizens.commands.npc.command.cost-set=Set cost per click to [[{0}]].
|
||||
citizens.commands.npc.command.invalid-error-message=Invalid error message. Valid messages are [[{0}]].
|
||||
|
@ -25,7 +25,6 @@ import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.nms.v1_10_R1.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.nms.v1_10_R1.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.nms.v1_10_R1.network.EmptySocket;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerJump;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerMove;
|
||||
@ -36,6 +35,7 @@ import net.citizensnpcs.npc.skin.SkinPacketTracker;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.SkinTrait;
|
||||
import net.citizensnpcs.util.EmptySocket;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.AttributeInstance;
|
||||
|
@ -1,81 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_10_R1.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
import net.citizensnpcs.util.Util;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
|
||||
public EmptyChannel(Channel parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig config() {
|
||||
config.setAutoRead(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBeginRead() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(SocketAddress arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDisconnect() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWrite(ChannelOutboundBuffer arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCompatible(EventLoop arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress localAddress0() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return Util.requiresNettyChannelMetadata() ? new ChannelMetadata(true) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractUnsafe newUnsafe() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress remoteAddress0() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_10_R1.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class EmptySocket extends Socket {
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return new ByteArrayOutputStream(10);
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY = new byte[50];
|
||||
}
|
@ -144,7 +144,6 @@ import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.ThrownExpBottleController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.TippedArrowController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.network.EmptyChannel;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
@ -155,6 +154,7 @@ import net.citizensnpcs.trait.versioned.BossBarTrait;
|
||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -206,6 +206,8 @@ import net.minecraft.server.v1_10_R1.NetworkManager;
|
||||
import net.minecraft.server.v1_10_R1.Packet;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutAnimation;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutBed;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityHeadRotation;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutPlayerInfo;
|
||||
@ -948,6 +950,16 @@ public class NMSImpl implements NMSBridge {
|
||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
||||
Entity handle = getHandle(from);
|
||||
Packet<?>[] packets = new Packet[] {
|
||||
new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||
(byte) (pitch * 256.0F / 360.0F), isOnGround(from)),
|
||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
||||
sendPacketsNearby(null, from.getLocation(), packets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabListAdd(Player recipient, Player listPlayer) {
|
||||
Preconditions.checkNotNull(recipient);
|
||||
|
@ -25,7 +25,6 @@ import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.nms.v1_11_R1.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.nms.v1_11_R1.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.nms.v1_11_R1.network.EmptySocket;
|
||||
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_11_R1.util.PlayerControllerJump;
|
||||
import net.citizensnpcs.nms.v1_11_R1.util.PlayerControllerMove;
|
||||
@ -36,6 +35,7 @@ import net.citizensnpcs.npc.skin.SkinPacketTracker;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.SkinTrait;
|
||||
import net.citizensnpcs.util.EmptySocket;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_11_R1.AttributeInstance;
|
||||
|
@ -1,81 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_11_R1.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
import net.citizensnpcs.util.Util;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
|
||||
public EmptyChannel(Channel parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig config() {
|
||||
config.setAutoRead(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBeginRead() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(SocketAddress arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDisconnect() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWrite(ChannelOutboundBuffer arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCompatible(EventLoop arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress localAddress0() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return Util.requiresNettyChannelMetadata() ? new ChannelMetadata(true) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractUnsafe newUnsafe() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress remoteAddress0() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_11_R1.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class EmptySocket extends Socket {
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return new ByteArrayOutputStream(10);
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY = new byte[50];
|
||||
}
|
@ -158,7 +158,6 @@ import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.ThrownExpBottleController;
|
||||
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.TippedArrowController;
|
||||
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.nms.v1_11_R1.network.EmptyChannel;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
@ -170,6 +169,7 @@ import net.citizensnpcs.trait.versioned.LlamaTrait;
|
||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -224,6 +224,8 @@ import net.minecraft.server.v1_11_R1.NetworkManager;
|
||||
import net.minecraft.server.v1_11_R1.Packet;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutAnimation;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutBed;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityHeadRotation;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutPlayerInfo;
|
||||
@ -1004,6 +1006,16 @@ public class NMSImpl implements NMSBridge {
|
||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
||||
Entity handle = getHandle(from);
|
||||
Packet<?>[] packets = new Packet[] {
|
||||
new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||
(byte) (pitch * 256.0F / 360.0F), isOnGround(from)),
|
||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
||||
sendPacketsNearby(null, from.getLocation(), packets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabListAdd(Player recipient, Player listPlayer) {
|
||||
Preconditions.checkNotNull(recipient);
|
||||
|
@ -26,7 +26,6 @@ import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.nms.v1_12_R1.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.nms.v1_12_R1.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.nms.v1_12_R1.network.EmptySocket;
|
||||
import net.citizensnpcs.nms.v1_12_R1.util.EmptyAdvancementDataPlayer;
|
||||
import net.citizensnpcs.nms.v1_12_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerJump;
|
||||
@ -39,6 +38,7 @@ import net.citizensnpcs.npc.skin.SkinPacketTracker;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.SkinTrait;
|
||||
import net.citizensnpcs.util.EmptySocket;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_12_R1.AttributeInstance;
|
||||
|
@ -1,80 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_12_R1.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
|
||||
public EmptyChannel(Channel parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig config() {
|
||||
config.setAutoRead(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBeginRead() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(SocketAddress arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDisconnect() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWrite(ChannelOutboundBuffer arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCompatible(EventLoop arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress localAddress0() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return new ChannelMetadata(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractUnsafe newUnsafe() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress remoteAddress0() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_12_R1.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class EmptySocket extends Socket {
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return new ByteArrayOutputStream(10);
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY = new byte[50];
|
||||
}
|
@ -160,7 +160,6 @@ import net.citizensnpcs.nms.v1_12_R1.entity.nonliving.ThrownExpBottleController;
|
||||
import net.citizensnpcs.nms.v1_12_R1.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.nms.v1_12_R1.entity.nonliving.TippedArrowController;
|
||||
import net.citizensnpcs.nms.v1_12_R1.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.nms.v1_12_R1.network.EmptyChannel;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
@ -173,6 +172,7 @@ import net.citizensnpcs.trait.versioned.ParrotTrait;
|
||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -228,6 +228,8 @@ import net.minecraft.server.v1_12_R1.NetworkManager;
|
||||
import net.minecraft.server.v1_12_R1.Packet;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutAnimation;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutBed;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityHeadRotation;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo;
|
||||
@ -1014,6 +1016,16 @@ public class NMSImpl implements NMSBridge {
|
||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
||||
Entity handle = getHandle(from);
|
||||
Packet<?>[] packets = new Packet[] {
|
||||
new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||
(byte) (pitch * 256.0F / 360.0F), isOnGround(from)),
|
||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
||||
sendPacketsNearby(null, from.getLocation(), packets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabListAdd(Player recipient, Player listPlayer) {
|
||||
Preconditions.checkNotNull(recipient);
|
||||
|
@ -26,7 +26,6 @@ import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.nms.v1_13_R2.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.nms.v1_13_R2.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.nms.v1_13_R2.network.EmptySocket;
|
||||
import net.citizensnpcs.nms.v1_13_R2.util.EmptyAdvancementDataPlayer;
|
||||
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_13_R2.util.PlayerControllerJump;
|
||||
@ -39,6 +38,7 @@ import net.citizensnpcs.npc.skin.SkinPacketTracker;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.SkinTrait;
|
||||
import net.citizensnpcs.util.EmptySocket;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_13_R2.AttributeInstance;
|
||||
|
@ -1,80 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_13_R2.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
|
||||
public EmptyChannel(Channel parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig config() {
|
||||
config.setAutoRead(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBeginRead() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(SocketAddress arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDisconnect() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWrite(ChannelOutboundBuffer arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCompatible(EventLoop arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress localAddress0() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return new ChannelMetadata(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractUnsafe newUnsafe() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress remoteAddress0() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_13_R2.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class EmptySocket extends Socket {
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return new ByteArrayOutputStream(10);
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY = new byte[50];
|
||||
}
|
@ -171,7 +171,6 @@ import net.citizensnpcs.nms.v1_13_R2.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.nms.v1_13_R2.entity.nonliving.ThrownTridentController;
|
||||
import net.citizensnpcs.nms.v1_13_R2.entity.nonliving.TippedArrowController;
|
||||
import net.citizensnpcs.nms.v1_13_R2.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.nms.v1_13_R2.network.EmptyChannel;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
@ -187,6 +186,7 @@ import net.citizensnpcs.trait.versioned.PufferFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -246,6 +246,8 @@ import net.minecraft.server.v1_13_R2.NetworkManager;
|
||||
import net.minecraft.server.v1_13_R2.Packet;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutAnimation;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutBed;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutEntityHeadRotation;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutPlayerInfo;
|
||||
@ -1050,6 +1052,16 @@ public class NMSImpl implements NMSBridge {
|
||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
||||
Entity handle = getHandle(from);
|
||||
Packet<?>[] packets = new Packet[] {
|
||||
new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||
(byte) (pitch * 256.0F / 360.0F), isOnGround(from)),
|
||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
||||
sendPacketsNearby(null, from.getLocation(), packets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabListAdd(Player recipient, Player listPlayer) {
|
||||
Preconditions.checkNotNull(recipient);
|
||||
|
@ -25,7 +25,6 @@ import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.nms.v1_14_R1.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.nms.v1_14_R1.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.nms.v1_14_R1.network.EmptySocket;
|
||||
import net.citizensnpcs.nms.v1_14_R1.util.EmptyAdvancementDataPlayer;
|
||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_14_R1.util.PlayerControllerJump;
|
||||
@ -38,6 +37,7 @@ import net.citizensnpcs.npc.skin.SkinPacketTracker;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.SkinTrait;
|
||||
import net.citizensnpcs.util.EmptySocket;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_14_R1.AttributeInstance;
|
||||
|
@ -1,80 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_14_R1.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
|
||||
public EmptyChannel(Channel parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig config() {
|
||||
config.setAutoRead(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBeginRead() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(SocketAddress arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDisconnect() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWrite(ChannelOutboundBuffer arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCompatible(EventLoop arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress localAddress0() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return new ChannelMetadata(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractUnsafe newUnsafe() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress remoteAddress0() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_14_R1.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class EmptySocket extends Socket {
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return new ByteArrayOutputStream(10);
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY = new byte[50];
|
||||
}
|
@ -179,7 +179,6 @@ import net.citizensnpcs.nms.v1_14_R1.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.nms.v1_14_R1.entity.nonliving.ThrownTridentController;
|
||||
import net.citizensnpcs.nms.v1_14_R1.entity.nonliving.TippedArrowController;
|
||||
import net.citizensnpcs.nms.v1_14_R1.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.nms.v1_14_R1.network.EmptyChannel;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
@ -200,6 +199,7 @@ import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -264,6 +264,8 @@ import net.minecraft.server.v1_14_R1.MobEffects;
|
||||
import net.minecraft.server.v1_14_R1.NavigationAbstract;
|
||||
import net.minecraft.server.v1_14_R1.NetworkManager;
|
||||
import net.minecraft.server.v1_14_R1.Packet;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayOutEntityHeadRotation;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayOutPlayerInfo;
|
||||
@ -1107,6 +1109,16 @@ public class NMSImpl implements NMSBridge {
|
||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
||||
Entity handle = getHandle(from);
|
||||
Packet<?>[] packets = new Packet[] {
|
||||
new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||
(byte) (pitch * 256.0F / 360.0F), isOnGround(from)),
|
||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
||||
sendPacketsNearby(null, from.getLocation(), packets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabListAdd(Player recipient, Player listPlayer) {
|
||||
Preconditions.checkNotNull(recipient);
|
||||
|
@ -25,7 +25,6 @@ import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.nms.v1_15_R1.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.nms.v1_15_R1.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.nms.v1_15_R1.network.EmptySocket;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.EmptyAdvancementDataPlayer;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerJump;
|
||||
@ -38,6 +37,7 @@ import net.citizensnpcs.npc.skin.SkinPacketTracker;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.SkinTrait;
|
||||
import net.citizensnpcs.util.EmptySocket;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_15_R1.AttributeInstance;
|
||||
|
@ -1,80 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_15_R1.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
|
||||
public EmptyChannel(Channel parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig config() {
|
||||
config.setAutoRead(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBeginRead() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(SocketAddress arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDisconnect() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWrite(ChannelOutboundBuffer arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCompatible(EventLoop arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress localAddress0() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return new ChannelMetadata(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractUnsafe newUnsafe() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress remoteAddress0() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_15_R1.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class EmptySocket extends Socket {
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return new ByteArrayOutputStream(10);
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY = new byte[50];
|
||||
}
|
@ -180,7 +180,6 @@ import net.citizensnpcs.nms.v1_15_R1.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.nms.v1_15_R1.entity.nonliving.ThrownTridentController;
|
||||
import net.citizensnpcs.nms.v1_15_R1.entity.nonliving.TippedArrowController;
|
||||
import net.citizensnpcs.nms.v1_15_R1.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.nms.v1_15_R1.network.EmptyChannel;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
@ -202,6 +201,7 @@ import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -268,6 +268,8 @@ import net.minecraft.server.v1_15_R1.MobEffects;
|
||||
import net.minecraft.server.v1_15_R1.NavigationAbstract;
|
||||
import net.minecraft.server.v1_15_R1.NetworkManager;
|
||||
import net.minecraft.server.v1_15_R1.Packet;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityHeadRotation;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutPlayerInfo;
|
||||
@ -1119,6 +1121,16 @@ public class NMSImpl implements NMSBridge {
|
||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
||||
Entity handle = getHandle(from);
|
||||
Packet<?>[] packets = new Packet[] {
|
||||
new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||
(byte) (pitch * 256.0F / 360.0F), isOnGround(from)),
|
||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
||||
sendPacketsNearby(null, from.getLocation(), packets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabListAdd(Player recipient, Player listPlayer) {
|
||||
Preconditions.checkNotNull(recipient);
|
||||
|
@ -30,7 +30,6 @@ import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.nms.v1_16_R3.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.nms.v1_16_R3.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.nms.v1_16_R3.network.EmptySocket;
|
||||
import net.citizensnpcs.nms.v1_16_R3.util.EmptyAdvancementDataPlayer;
|
||||
import net.citizensnpcs.nms.v1_16_R3.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_16_R3.util.PlayerControllerJump;
|
||||
@ -43,6 +42,7 @@ import net.citizensnpcs.npc.skin.SkinPacketTracker;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.SkinTrait;
|
||||
import net.citizensnpcs.util.EmptySocket;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_16_R3.AttributeBase;
|
||||
|
@ -1,80 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_16_R3.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
|
||||
public EmptyChannel(Channel parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig config() {
|
||||
config.setAutoRead(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBeginRead() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(SocketAddress arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDisconnect() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWrite(ChannelOutboundBuffer arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCompatible(EventLoop arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress localAddress0() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return new ChannelMetadata(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractUnsafe newUnsafe() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress remoteAddress0() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_16_R3.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class EmptySocket extends Socket {
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return new ByteArrayOutputStream(10);
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY = new byte[50];
|
||||
}
|
@ -186,7 +186,6 @@ import net.citizensnpcs.nms.v1_16_R3.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.nms.v1_16_R3.entity.nonliving.ThrownTridentController;
|
||||
import net.citizensnpcs.nms.v1_16_R3.entity.nonliving.TippedArrowController;
|
||||
import net.citizensnpcs.nms.v1_16_R3.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.nms.v1_16_R3.network.EmptyChannel;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
@ -209,6 +208,7 @@ import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -277,6 +277,8 @@ import net.minecraft.server.v1_16_R3.MobEffects;
|
||||
import net.minecraft.server.v1_16_R3.NavigationAbstract;
|
||||
import net.minecraft.server.v1_16_R3.NetworkManager;
|
||||
import net.minecraft.server.v1_16_R3.Packet;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutEntityHeadRotation;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutPlayerInfo;
|
||||
@ -1149,6 +1151,16 @@ public class NMSImpl implements NMSBridge {
|
||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
||||
Entity handle = getHandle(from);
|
||||
Packet<?>[] packets = new Packet[] {
|
||||
new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||
(byte) (pitch * 256.0F / 360.0F), isOnGround(from)),
|
||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
||||
sendPacketsNearby(null, from.getLocation(), packets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabListAdd(Player recipient, Player listPlayer) {
|
||||
Preconditions.checkNotNull(recipient);
|
||||
|
@ -30,7 +30,6 @@ import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.nms.v1_17_R1.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.nms.v1_17_R1.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.nms.v1_17_R1.network.EmptySocket;
|
||||
import net.citizensnpcs.nms.v1_17_R1.util.EmptyAdvancementDataPlayer;
|
||||
import net.citizensnpcs.nms.v1_17_R1.util.EmptyServerStatsCounter;
|
||||
import net.citizensnpcs.nms.v1_17_R1.util.NMSImpl;
|
||||
@ -44,6 +43,7 @@ import net.citizensnpcs.npc.skin.SkinPacketTracker;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.SkinTrait;
|
||||
import net.citizensnpcs.util.EmptySocket;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -1,80 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_17_R1.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
|
||||
public EmptyChannel(Channel parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig config() {
|
||||
config.setAutoRead(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBeginRead() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(SocketAddress arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDisconnect() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWrite(ChannelOutboundBuffer arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCompatible(EventLoop arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress localAddress0() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return new ChannelMetadata(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractUnsafe newUnsafe() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress remoteAddress0() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_17_R1.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class EmptySocket extends Socket {
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return new ByteArrayOutputStream(10);
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY = new byte[50];
|
||||
}
|
@ -188,7 +188,6 @@ import net.citizensnpcs.nms.v1_17_R1.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.nms.v1_17_R1.entity.nonliving.ThrownTridentController;
|
||||
import net.citizensnpcs.nms.v1_17_R1.entity.nonliving.TippedArrowController;
|
||||
import net.citizensnpcs.nms.v1_17_R1.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.nms.v1_17_R1.network.EmptyChannel;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
@ -212,6 +211,7 @@ import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -225,8 +225,10 @@ import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@ -1140,6 +1142,16 @@ public class NMSImpl implements NMSBridge {
|
||||
sendPacketNearby(excluding, storedLocation, new ClientboundTeleportEntityPacket(getHandle(from)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
||||
Entity handle = getHandle(from);
|
||||
Packet<?>[] packets = new Packet[] {
|
||||
new ClientboundMoveEntityPacket.Rot(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||
(byte) (pitch * 256.0F / 360.0F), handle.isOnGround()),
|
||||
new ClientboundRotateHeadPacket(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
||||
sendPacketsNearby(null, from.getLocation(), packets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabListAdd(Player recipient, Player listPlayer) {
|
||||
Preconditions.checkNotNull(recipient);
|
||||
|
@ -31,7 +31,6 @@ import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.nms.v1_18_R2.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.nms.v1_18_R2.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.nms.v1_18_R2.network.EmptySocket;
|
||||
import net.citizensnpcs.nms.v1_18_R2.util.EmptyAdvancementDataPlayer;
|
||||
import net.citizensnpcs.nms.v1_18_R2.util.EmptyServerStatsCounter;
|
||||
import net.citizensnpcs.nms.v1_18_R2.util.NMSImpl;
|
||||
@ -45,6 +44,7 @@ import net.citizensnpcs.npc.skin.SkinPacketTracker;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.SkinTrait;
|
||||
import net.citizensnpcs.util.EmptySocket;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -1,80 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_18_R2.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
|
||||
public EmptyChannel(Channel parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig config() {
|
||||
config.setAutoRead(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBeginRead() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(SocketAddress arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDisconnect() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWrite(ChannelOutboundBuffer arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCompatible(EventLoop arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress localAddress0() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return new ChannelMetadata(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractUnsafe newUnsafe() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress remoteAddress0() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_18_R2.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class EmptySocket extends Socket {
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return new ByteArrayOutputStream(10);
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY = new byte[50];
|
||||
}
|
@ -190,7 +190,6 @@ import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.ThrownTridentController;
|
||||
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.TippedArrowController;
|
||||
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.nms.v1_18_R2.network.EmptyChannel;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
@ -214,6 +213,7 @@ import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -227,8 +227,10 @@ import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@ -1147,6 +1149,16 @@ public class NMSImpl implements NMSBridge {
|
||||
sendPacketNearby(excluding, storedLocation, new ClientboundTeleportEntityPacket(getHandle(from)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
||||
Entity handle = getHandle(from);
|
||||
Packet<?>[] packets = new Packet[] {
|
||||
new ClientboundMoveEntityPacket.Rot(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||
(byte) (pitch * 256.0F / 360.0F), handle.onGround),
|
||||
new ClientboundRotateHeadPacket(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
||||
sendPacketsNearby(null, from.getLocation(), packets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabListAdd(Player recipient, Player listPlayer) {
|
||||
Preconditions.checkNotNull(recipient);
|
||||
|
@ -32,7 +32,6 @@ import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.nms.v1_19_R1.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.nms.v1_19_R1.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.nms.v1_19_R1.network.EmptySocket;
|
||||
import net.citizensnpcs.nms.v1_19_R1.util.EmptyAdvancementDataPlayer;
|
||||
import net.citizensnpcs.nms.v1_19_R1.util.EmptyServerStatsCounter;
|
||||
import net.citizensnpcs.nms.v1_19_R1.util.NMSImpl;
|
||||
@ -46,6 +45,7 @@ import net.citizensnpcs.npc.skin.SkinPacketTracker;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.SkinTrait;
|
||||
import net.citizensnpcs.util.EmptySocket;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -1,80 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_19_R1.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
|
||||
public EmptyChannel(Channel parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig config() {
|
||||
config.setAutoRead(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBeginRead() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(SocketAddress arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDisconnect() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWrite(ChannelOutboundBuffer arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCompatible(EventLoop arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress localAddress0() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return new ChannelMetadata(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractUnsafe newUnsafe() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress remoteAddress0() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -195,7 +195,6 @@ import net.citizensnpcs.nms.v1_19_R1.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.nms.v1_19_R1.entity.nonliving.ThrownTridentController;
|
||||
import net.citizensnpcs.nms.v1_19_R1.entity.nonliving.TippedArrowController;
|
||||
import net.citizensnpcs.nms.v1_19_R1.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.nms.v1_19_R1.network.EmptyChannel;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
@ -222,6 +221,7 @@ import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -237,8 +237,10 @@ import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.contents.LiteralContents;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@ -1161,8 +1163,18 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location storedLocation) {
|
||||
sendPacketNearby(excluding, storedLocation, new ClientboundTeleportEntityPacket(getHandle(from)));
|
||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location location) {
|
||||
sendPacketNearby(excluding, location, new ClientboundTeleportEntityPacket(getHandle(from)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
||||
Entity handle = getHandle(from);
|
||||
Packet<?>[] packets = new Packet[] {
|
||||
new ClientboundMoveEntityPacket.Rot(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||
(byte) (pitch * 256.0F / 360.0F), handle.onGround),
|
||||
new ClientboundRotateHeadPacket(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
||||
sendPacketsNearby(null, from.getLocation(), packets);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,7 +53,6 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
|
||||
return;
|
||||
this.lastUpdatedPlayer = entityplayer;
|
||||
super.updatePlayer(entityplayer);
|
||||
|
||||
}
|
||||
|
||||
private static int getE(TrackedEntity entry) {
|
||||
|
@ -25,7 +25,6 @@ import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.nms.v1_8_R3.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.nms.v1_8_R3.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.nms.v1_8_R3.network.EmptySocket;
|
||||
import net.citizensnpcs.nms.v1_8_R3.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerJump;
|
||||
import net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerMove;
|
||||
@ -37,6 +36,7 @@ import net.citizensnpcs.npc.skin.SkinPacketTracker;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.SkinTrait;
|
||||
import net.citizensnpcs.util.EmptySocket;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_8_R3.AttributeInstance;
|
||||
|
@ -1,21 +0,0 @@
|
||||
package net.citizensnpcs.nms.v1_8_R3.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class EmptySocket extends Socket {
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return new ByteArrayOutputStream(10);
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY = new byte[50];
|
||||
}
|
@ -133,13 +133,13 @@ import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.SplashPotionController;
|
||||
import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.TNTPrimedController;
|
||||
import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.ThrownExpBottleController;
|
||||
import net.citizensnpcs.nms.v1_8_R3.entity.nonliving.WitherSkullController;
|
||||
import net.citizensnpcs.nms.v1_8_R3.network.EmptyChannel;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.SmoothRotationTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -183,6 +183,8 @@ import net.minecraft.server.v1_8_R3.NetworkManager;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutBed;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
|
||||
@ -889,6 +891,16 @@ public class NMSImpl implements NMSBridge {
|
||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
||||
Entity handle = getHandle(from);
|
||||
Packet<?>[] packets = new Packet[] {
|
||||
new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||
(byte) (pitch * 256.0F / 360.0F), isOnGround(from)),
|
||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
||||
sendPacketsNearby(null, from.getLocation(), packets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabListAdd(Player recipient, Player listPlayer) {
|
||||
Preconditions.checkNotNull(recipient);
|
||||
|
Loading…
Reference in New Issue
Block a user