Fix VisibilitySettings not working

This commit is contained in:
filoghost 2021-07-05 23:58:20 +02:00
parent 08410feb48
commit f6c7fd5f0f
3 changed files with 25 additions and 5 deletions

View File

@ -38,7 +38,9 @@ class MetadataHelper {
MetadataHelper() {
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_14_R1)) {
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_17_R1)) {
itemSlotIndex = 8;
} else if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_14_R1)) {
itemSlotIndex = 7;
} else if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_10_R1)) {
itemSlotIndex = 6;
@ -48,7 +50,9 @@ class MetadataHelper {
itemSlotIndex = 10;
}
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_15_R1)) {
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_17_R1)) {
armorStandStatusIndex = 15;
} else if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_15_R1)) {
armorStandStatusIndex = 14;
} else {
armorStandStatusIndex = 11;

View File

@ -185,9 +185,18 @@ class PacketSender {
private void sendDestroyEntitiesPacket(Player player, List<Integer> ids) {
WrapperPlayServerEntityDestroy packet = new WrapperPlayServerEntityDestroy();
packet.setEntities(ids);
packet.sendPacket(player);
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_17_R1)) {
// Requires multiple packets
for (Integer id : ids) {
WrapperPlayServerEntityDestroy packet = new WrapperPlayServerEntityDestroy();
packet.setEntity(id);
packet.sendPacket(player);
}
} else {
WrapperPlayServerEntityDestroy packet = new WrapperPlayServerEntityDestroy();
packet.setEntities(ids);
packet.sendPacket(player);
}
}

View File

@ -56,4 +56,11 @@ public class WrapperPlayServerEntityDestroy extends AbstractPacket {
setEntities(Ints.toArray(entities));
}
/**
* Set the entity that will be destroyed. To be used from Minecraft 1.17 and higher.
*/
public void setEntity(Integer entity) {
handle.getIntegers().write(0, entity);
}
}