Be more aggressive with bed packets in older minecraft versions

This commit is contained in:
fullwall 2022-12-22 23:35:19 +08:00
parent 4c958b5e7c
commit 8f21f87867
5 changed files with 35 additions and 10 deletions

View File

@ -1201,9 +1201,14 @@ public class NMSImpl implements NMSBridge {
public void sleep(Player entity, boolean sleep) {
EntityPlayer player = (EntityPlayer) getHandle(entity);
if (sleep) {
PacketPlayOutBed packet = new PacketPlayOutBed(player,
Location loc = player.getBukkitEntity().getLocation();
PacketPlayOutBed bed = new PacketPlayOutBed(player,
new BlockPosition((int) player.locX, (int) player.locY, (int) player.locZ));
sendPacketNearby(entity, entity.getLocation(), packet, 64);
for (Player nearby : CitizensAPI.getLocationLookup().getNearbyPlayers(entity.getLocation(), 64)) {
nearby.sendBlockChange(loc, Material.BED.getId(), (byte) 11);
sendPacket(nearby, bed);
nearby.sendBlockChange(loc, 0, (byte) 0);
}
} else {
PacketPlayOutAnimation packet = new PacketPlayOutAnimation(player, 2);
sendPacketNearby(entity, entity.getLocation(), packet, 64);

View File

@ -1268,9 +1268,14 @@ public class NMSImpl implements NMSBridge {
public void sleep(Player entity, boolean sleep) {
EntityPlayer player = (EntityPlayer) getHandle(entity);
if (sleep) {
PacketPlayOutBed packet = new PacketPlayOutBed(player,
Location loc = player.getBukkitEntity().getLocation();
PacketPlayOutBed bed = new PacketPlayOutBed(player,
new BlockPosition((int) player.locX, (int) player.locY, (int) player.locZ));
sendPacketNearby(entity, entity.getLocation(), packet, 64);
for (Player nearby : CitizensAPI.getLocationLookup().getNearbyPlayers(entity.getLocation(), 64)) {
nearby.sendBlockChange(loc, Material.BED.getId(), (byte) 11);
sendPacket(nearby, bed);
nearby.sendBlockChange(loc, 0, (byte) 0);
}
} else {
PacketPlayOutAnimation packet = new PacketPlayOutAnimation(player, 2);
sendPacketNearby(entity, entity.getLocation(), packet, 64);

View File

@ -1278,9 +1278,14 @@ public class NMSImpl implements NMSBridge {
public void sleep(Player entity, boolean sleep) {
EntityPlayer player = (EntityPlayer) getHandle(entity);
if (sleep) {
PacketPlayOutBed packet = new PacketPlayOutBed(player,
Location loc = player.getBukkitEntity().getLocation();
PacketPlayOutBed bed = new PacketPlayOutBed(player,
new BlockPosition((int) player.locX, (int) player.locY, (int) player.locZ));
sendPacketNearby(entity, entity.getLocation(), packet, 64);
for (Player nearby : CitizensAPI.getLocationLookup().getNearbyPlayers(entity.getLocation(), 64)) {
nearby.sendBlockChange(loc, Material.BED.getId(), (byte) 11);
sendPacket(nearby, bed);
nearby.sendBlockChange(loc, 0, (byte) 0);
}
} else {
PacketPlayOutAnimation packet = new PacketPlayOutAnimation(player, 2);
sendPacketNearby(entity, entity.getLocation(), packet, 64);

View File

@ -1318,9 +1318,14 @@ public class NMSImpl implements NMSBridge {
public void sleep(Player entity, boolean sleep) {
EntityPlayer player = (EntityPlayer) getHandle(entity);
if (sleep) {
PacketPlayOutBed packet = new PacketPlayOutBed(player,
Location loc = player.getBukkitEntity().getLocation();
PacketPlayOutBed bed = new PacketPlayOutBed(player,
new BlockPosition((int) player.locX, (int) player.locY, (int) player.locZ));
sendPacketNearby(entity, entity.getLocation(), packet, 64);
for (Player nearby : CitizensAPI.getLocationLookup().getNearbyPlayers(entity.getLocation(), 64)) {
nearby.sendBlockChange(loc, Material.BLACK_BED, (byte) 11);
sendPacket(nearby, bed);
nearby.sendBlockChange(loc, Material.AIR, (byte) 0);
}
} else {
PacketPlayOutAnimation packet = new PacketPlayOutAnimation(player, 2);
sendPacketNearby(entity, entity.getLocation(), packet, 64);

View File

@ -1138,9 +1138,14 @@ public class NMSImpl implements NMSBridge {
public void sleep(Player entity, boolean sleep) {
EntityPlayer player = (EntityPlayer) getHandle(entity);
if (sleep) {
PacketPlayOutBed packet = new PacketPlayOutBed(player,
Location loc = player.getBukkitEntity().getLocation();
PacketPlayOutBed bed = new PacketPlayOutBed(player,
new BlockPosition((int) player.locX, (int) player.locY, (int) player.locZ));
sendPacketNearby(entity, entity.getLocation(), packet, 64);
for (Player nearby : CitizensAPI.getLocationLookup().getNearbyPlayers(entity.getLocation(), 64)) {
nearby.sendBlockChange(loc, Material.BED.getId(), (byte) 11);
sendPacket(nearby, bed);
nearby.sendBlockChange(loc, 0, (byte) 0);
}
} else {
PacketPlayOutAnimation packet = new PacketPlayOutAnimation(player, 2);
sendPacketNearby(entity, entity.getLocation(), packet, 64);