use of net.minecraft.server.v1_15_R1.Packet in project Citizens2 by CitizensDev.
the class PlayerAnimationImpl method playDefaultAnimation.
protected static void playDefaultAnimation(EntityPlayer player, int radius, int code) {
PacketPlayOutAnimation packet = new PacketPlayOutAnimation(player, code);
sendPacketNearby(packet, player, radius);
}
use of net.minecraft.server.v1_15_R1.Packet in project Citizens2 by CitizensDev.
the class EntityHumanNPC method updatePackets.
private void updatePackets(boolean navigating) {
updateCounter++;
boolean itemChanged = false;
for (EnumItemSlot slot : EnumItemSlot.values()) {
ItemStack equipment = getEquipment(slot);
ItemStack cache = equipmentCache.get(slot);
if (!(cache == null && equipment == null) && (cache == null ^ equipment == null || !ItemStack.equals(cache, equipment))) {
itemChanged = true;
}
equipmentCache.put(slot, equipment);
}
if (updateCounter++ <= npc.data().<Integer>get(NPC.Metadata.PACKET_UPDATE_DELAY, Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
return;
updateCounter = 0;
Location current = getBukkitEntity().getLocation(packetLocationCache);
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
int i = 0;
for (EnumItemSlot slot : EnumItemSlot.values()) {
packets[i++] = new PacketPlayOutEntityEquipment(getId(), slot, getEquipment(slot));
}
NMSImpl.sendPacketsNearby(getBukkitEntity(), current, packets);
}
use of net.minecraft.server.v1_15_R1.Packet in project Citizens2 by CitizensDev.
the class EntityHumanNPC method updatePackets.
private void updatePackets(boolean navigating) {
updateCounter++;
boolean itemChanged = false;
for (int slot = 0; slot < this.inventory.armor.length; slot++) {
ItemStack equipment = getEquipment(slot);
ItemStack cache = equipmentCache.get(slot);
if (!(cache == null && equipment == null) && (cache == null ^ equipment == null || !ItemStack.equals(cache, equipment))) {
itemChanged = true;
}
equipmentCache.put(slot, equipment);
}
if (updateCounter++ <= npc.data().<Integer>get(NPC.Metadata.PACKET_UPDATE_DELAY, Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
return;
updateCounter = 0;
Location current = getBukkitEntity().getLocation(packetLocationCache);
Packet<?>[] packets = new Packet[this.inventory.armor.length];
for (int i = 0; i < this.inventory.armor.length; i++) {
packets[i] = new PacketPlayOutEntityEquipment(getId(), i, getEquipment(i));
}
NMSImpl.sendPacketsNearby(getBukkitEntity(), current, packets);
}
use of net.minecraft.server.v1_15_R1.Packet in project SimplePets by brainsynder-Dev.
the class EntityControllerPet method reloadLocation.
@Override
public void reloadLocation() {
if (displayEntity.getPassenger() != null) {
net.minecraft.server.v1_15_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
Location loc;
if (this.displayRider != null) {
if (this.displayRider.getType().equals(EntityType.SHULKER)) {
loc = getBukkitEntity().getLocation().clone().subtract(0, 0.735, 0);
} else {
loc = getBukkitEntity().getLocation().clone();
}
} else {
loc = getBukkitEntity().getLocation().clone();
}
displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
if (entity instanceof Player) {
Player player = (Player) entity;
PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
});
return;
}
net.minecraft.server.v1_15_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
Location loc;
if (this.displayRider != null) {
if (this.displayRider.getType().equals(EntityType.SHULKER)) {
loc = getBukkitEntity().getLocation().clone().add(0, 0.75, 0);
} else {
loc = getBukkitEntity().getLocation().clone();
}
} else {
loc = getBukkitEntity().getLocation().clone();
}
displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
if (entity instanceof Player) {
Player player = (Player) entity;
PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
});
}
use of net.minecraft.server.v1_15_R1.Packet in project jop by jop-devel.
the class Ppp method doSend.
void doSend() {
if (reconnectRequest) {
// System.out.print("3");
// start over
modemHangUp();
modemInit();
}
if (disconnectRequest) {
// stop the connection
modemHangUp();
}
if (state == CONNECTED) {
// send waiting ip packets
if (scnt == 0) {
// transmit buffer is free
// use IP timeout
globTimer = Timer.getTimeoutMs(IP_SEND);
//
// get a ready to send packet with source from this driver.
//
Packet p = PacketPool.getTxPacket(single);
if (p != null) {
// send one packet
sendIp(p);
}
} else {
// check sendTimer;
if (Timer.timeout(globTimer)) {
// System.out.print("4");
// start over
modemHangUp();
modemInit();
}
}
} else {
// do the negotiation stuff
dropIp();
if (Timer.timeout(globTimer)) {
/*
Dbg.intVal(state);
if (lcpAck) Dbg.wr('t'); else Dbg.wr('f');
*/
if (scnt == 0) {
// once every three seconds send a REQ
if (state == MODEM_OK) {
makeLCP();
state = LCP_SENT;
} else if (state == LCP_OK && lcpAck) {
makePAP();
state = PAP_SENT;
// } else if (state == PAP_OK && ipcpAck) { // wait for remote ipcp and ACK first on Linux
} else if (state >= PAP_OK && state < CONNECTED) {
// ONE
makeIPCP();
state = IPCP_SENT;
// incremenet counter to start over when no respond
++rejCnt;
}
// use negotiation timeout
globTimer = Timer.getTimeoutMs(NEG_SEND);
}
}
}
}
Aggregations