make metadata always send

This commit is contained in:
Pyrbu 2023-05-11 05:38:47 +01:00
parent 37a093b037
commit 74ed109543
7 changed files with 22 additions and 27 deletions

@ -4,7 +4,7 @@ import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
public class V1_14Factory extends V1_13Factory { public class V1_14Factory extends V1_13Factory {
@Override @Override
public EntityData skinLayers() { public EntityData skinLayers(boolean enabled) {
return createSkinLayers(15); return createSkinLayers(15, enabled);
} }
} }

@ -4,7 +4,7 @@ import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
public class V1_16Factory extends V1_14Factory { public class V1_16Factory extends V1_14Factory {
@Override @Override
public EntityData skinLayers() { public EntityData skinLayers(boolean enabled) {
return createSkinLayers(16); return createSkinLayers(16, enabled);
} }
} }

@ -4,7 +4,7 @@ import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
public class V1_17Factory extends V1_16Factory { public class V1_17Factory extends V1_16Factory {
@Override @Override
public EntityData skinLayers() { public EntityData skinLayers(boolean enabled) {
return createSkinLayers(17); return createSkinLayers(17, enabled);
} }
} }

@ -10,8 +10,8 @@ import java.util.Collection;
public class V1_8Factory implements MetadataFactory { public class V1_8Factory implements MetadataFactory {
@Override @Override
public EntityData skinLayers() { public EntityData skinLayers(boolean enabled) {
return createSkinLayers(12); return createSkinLayers(12, enabled);
} }
@Override @Override
@ -28,11 +28,11 @@ public class V1_8Factory implements MetadataFactory {
} }
@Override @Override
public EntityData silent() { public EntityData silent(boolean enabled) {
return new EntityData(4, EntityDataTypes.BYTE, 1); return new EntityData(4, EntityDataTypes.BYTE, enabled ? 1 : 0);
} }
protected EntityData createSkinLayers(int index) { protected EntityData createSkinLayers(int index, boolean enabled) {
return new EntityData(index, EntityDataTypes.BYTE, Byte.MAX_VALUE); return new EntityData(index, EntityDataTypes.BYTE, enabled ? Byte.MAX_VALUE : 0);
} }
} }

@ -10,8 +10,8 @@ import java.util.Collection;
public class V1_9Factory extends V1_8Factory { public class V1_9Factory extends V1_8Factory {
@Override @Override
public EntityData skinLayers() { public EntityData skinLayers(boolean enabled) {
return createSkinLayers(13); return createSkinLayers(13, enabled);
} }
@Override @Override
@ -28,7 +28,7 @@ public class V1_9Factory extends V1_8Factory {
} }
@Override @Override
public EntityData silent() { public EntityData silent(boolean enabled) {
return new EntityData(4, EntityDataTypes.BOOLEAN, true); return new EntityData(4, EntityDataTypes.BOOLEAN, enabled);
} }
} }

@ -109,11 +109,9 @@ public class V1_8Factory implements PacketFactory {
@Override @Override
public void sendAllMetadata(Player player, PacketEntity entity, PropertyHolder properties) { public void sendAllMetadata(Player player, PacketEntity entity, PropertyHolder properties) {
ArrayList<EntityData> data = new ArrayList<>(); ArrayList<EntityData> data = new ArrayList<>();
if (entity.getType() == EntityTypes.PLAYER && properties.getProperty(EntityPropertyImpl.SKIN_LAYERS)) data.add(MetadataFactory.get().skinLayers()); if (entity.getType() == EntityTypes.PLAYER) data.add(MetadataFactory.get().skinLayers(properties.getProperty(EntityPropertyImpl.SKIN_LAYERS)));
boolean fire = properties.getProperty(EntityPropertyImpl.FIRE); data.add(MetadataFactory.get().effects(properties.getProperty(EntityPropertyImpl.FIRE), false, properties.getProperty(EntityPropertyImpl.INVISIBLE)));
boolean invisible = properties.getProperty(EntityPropertyImpl.INVISIBLE); data.add(MetadataFactory.get().silent(properties.getProperty(EntityPropertyImpl.SILENT)));
if (fire || invisible) data.add(MetadataFactory.get().effects(fire, false, invisible));
if (properties.getProperty(EntityPropertyImpl.SILENT)) data.add(MetadataFactory.get().silent());
if (properties.hasProperty(EntityPropertyImpl.NAME)) data.addAll(MetadataFactory.get().name(properties.getProperty(EntityPropertyImpl.NAME))); if (properties.hasProperty(EntityPropertyImpl.NAME)) data.addAll(MetadataFactory.get().name(properties.getProperty(EntityPropertyImpl.NAME)));
sendMetadata(player, entity, data); sendMetadata(player, entity, data);
} }

@ -14,12 +14,9 @@ public class V1_9Factory extends V1_8Factory {
@Override @Override
public void sendAllMetadata(Player player, PacketEntity entity, PropertyHolder properties) { public void sendAllMetadata(Player player, PacketEntity entity, PropertyHolder properties) {
ArrayList<EntityData> data = new ArrayList<>(); ArrayList<EntityData> data = new ArrayList<>();
if (entity.getType() == EntityTypes.PLAYER && properties.getProperty(EntityPropertyImpl.SKIN_LAYERS)) data.add(MetadataFactory.get().skinLayers()); if (entity.getType() == EntityTypes.PLAYER) data.add(MetadataFactory.get().skinLayers(properties.getProperty(EntityPropertyImpl.SKIN_LAYERS)));
boolean glow = properties.hasProperty(EntityPropertyImpl.GLOW); data.add(MetadataFactory.get().effects(properties.getProperty(EntityPropertyImpl.FIRE), properties.hasProperty(EntityPropertyImpl.GLOW), properties.getProperty(EntityPropertyImpl.INVISIBLE)));
boolean fire = properties.getProperty(EntityPropertyImpl.FIRE); data.add(MetadataFactory.get().silent(properties.getProperty(EntityPropertyImpl.SILENT)));
boolean invisible = properties.getProperty(EntityPropertyImpl.INVISIBLE);
if (glow || fire || invisible) data.add(MetadataFactory.get().effects(fire, glow, invisible));
if (properties.getProperty(EntityPropertyImpl.SILENT)) data.add(MetadataFactory.get().silent());
if (properties.hasProperty(EntityPropertyImpl.NAME)) data.addAll(MetadataFactory.get().name(properties.getProperty(EntityPropertyImpl.NAME))); if (properties.hasProperty(EntityPropertyImpl.NAME)) data.addAll(MetadataFactory.get().name(properties.getProperty(EntityPropertyImpl.NAME)));
sendMetadata(player, entity, data); sendMetadata(player, entity, data);
} }