Added cape property
This commit is contained in:
parent
fa0b82cde5
commit
640f7a8f8d
11 changed files with 60 additions and 14 deletions
|
@ -31,6 +31,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
|||
registerType("skin", SkinDescriptor.class);
|
||||
registerType("name", Component.class);
|
||||
registerType("look", false);
|
||||
registerType("cape", true);
|
||||
|
||||
registerType("helmet", ItemStack.class);
|
||||
registerType("chestplate", ItemStack.class);
|
||||
|
|
|
@ -6,21 +6,21 @@ import net.kyori.adventure.text.Component;
|
|||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 1.8 https://wiki.vg/index.php?title=Entity_metadata&oldid=7415
|
||||
* 1.9 https://wiki.vg/index.php?title=Entity_metadata&oldid=7968
|
||||
* 1.10 https://wiki.vg/index.php?title=Entity_metadata&oldid=8241
|
||||
* 1.11 https://wiki.vg/index.php?title=Entity_metadata&oldid=8534
|
||||
* 1.12 https://wiki.vg/index.php?title=Entity_metadata&oldid=14048
|
||||
* 1.13 https://wiki.vg/index.php?title=Entity_metadata&oldid=14800
|
||||
* 1.14 https://wiki.vg/index.php?title=Entity_metadata&oldid=15240
|
||||
* 1.15 https://wiki.vg/index.php?title=Entity_metadata&oldid=15991
|
||||
* 1.16 https://wiki.vg/index.php?title=Entity_metadata&oldid=16539
|
||||
* 1.17 https://wiki.vg/index.php?title=Entity_metadata&oldid=17521
|
||||
* 1.18 NOTHING CHANGED
|
||||
* 1.19 https://wiki.vg/index.php?title=Entity_metadata
|
||||
* 1.8 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=7415">...</a>
|
||||
* 1.9 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=7968">...</a>
|
||||
* 1.10 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=8241">...</a>
|
||||
* 1.11 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=8534">...</a>
|
||||
* 1.12 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=14048">...</a>
|
||||
* 1.13 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=14800">...</a>
|
||||
* 1.14 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=15240">...</a>
|
||||
* 1.15 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=15991">...</a>
|
||||
* 1.16 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=16539">...</a>
|
||||
* 1.17 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=17521">...</a>
|
||||
* 1.18-1.19 <a href="https://wiki.vg/index.php?title=Entity_metadata">...</a>
|
||||
*/
|
||||
public interface MetadataFactory {
|
||||
EntityData skinLayers(boolean enabled);
|
||||
EntityData cape(boolean enabled);
|
||||
EntityData effects(boolean onFire, boolean glowing, boolean invisible);
|
||||
EntityData silent(boolean enabled);
|
||||
Collection<EntityData> name(Component name);
|
||||
|
|
|
@ -4,6 +4,11 @@ import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
|||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
|
||||
public class V1_10MetadataFactory extends V1_9MetadataFactory {
|
||||
@Override
|
||||
public EntityData cape(boolean enabled) {
|
||||
return createCape(13, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData noGravity() {
|
||||
return new EntityData(5, EntityDataTypes.BOOLEAN, true);
|
||||
|
|
|
@ -7,4 +7,9 @@ public class V1_14MetadataFactory extends V1_13MetadataFactory {
|
|||
public EntityData skinLayers(boolean enabled) {
|
||||
return createSkinLayers(15, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData cape(boolean enabled) {
|
||||
return createCape(15, enabled);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package lol.pyr.znpcsplus.metadata;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
|
||||
public class V1_15MetadataFactory extends V1_14MetadataFactory {
|
||||
|
||||
@Override
|
||||
public EntityData cape(boolean enabled) {
|
||||
return createCape(16, enabled);
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@ package lol.pyr.znpcsplus.metadata;
|
|||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
|
||||
public class V1_16MetadataFactory extends V1_14MetadataFactory {
|
||||
public class V1_16MetadataFactory extends V1_15MetadataFactory {
|
||||
@Override
|
||||
public EntityData skinLayers(boolean enabled) {
|
||||
return createSkinLayers(16, enabled);
|
||||
|
|
|
@ -7,4 +7,9 @@ public class V1_17MetadataFactory extends V1_16MetadataFactory {
|
|||
public EntityData skinLayers(boolean enabled) {
|
||||
return createSkinLayers(17, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData cape(boolean enabled) {
|
||||
return createCape(17, enabled);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ public class V1_8MetadataFactory implements MetadataFactory {
|
|||
return createSkinLayers(12, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData cape(boolean enabled) {
|
||||
return createCape(10, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData effects(boolean onFire, boolean glowing, boolean invisible) {
|
||||
return new EntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (invisible ? 0x20 : 0)));
|
||||
|
@ -40,4 +45,8 @@ public class V1_8MetadataFactory implements MetadataFactory {
|
|||
protected EntityData createSkinLayers(int index, boolean enabled) {
|
||||
return new EntityData(index, EntityDataTypes.BYTE, enabled ? Byte.MAX_VALUE : 0);
|
||||
}
|
||||
|
||||
protected EntityData createCape(int index, boolean enabled) {
|
||||
return new EntityData(index, EntityDataTypes.BYTE, (byte) (enabled ? 0x01 : 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ public class V1_9MetadataFactory extends V1_8MetadataFactory {
|
|||
return createSkinLayers(13, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData cape(boolean enabled) {
|
||||
return createCape(12, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData effects(boolean onFire, boolean glowing, boolean invisible) {
|
||||
return new EntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (invisible ? 0x20 : 0) | (glowing ? 0x40 : 0)));
|
||||
|
|
|
@ -76,6 +76,7 @@ public class NpcTypeImpl implements NpcType {
|
|||
allowedProperties.add(propertyRegistry.getByName("invisible"));
|
||||
allowedProperties.add(propertyRegistry.getByName("silent"));
|
||||
allowedProperties.add(propertyRegistry.getByName("look"));
|
||||
allowedProperties.add(propertyRegistry.getByName("cape"));
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9))
|
||||
allowedProperties.add(propertyRegistry.getByName("glow"));
|
||||
return new NpcTypeImpl(name, type, hologramOffset, new HashSet<>(allowedProperties));
|
||||
|
|
|
@ -126,7 +126,10 @@ public class V1_8PacketFactory implements PacketFactory {
|
|||
@Override
|
||||
public Map<Integer, EntityData> generateMetadata(Player player, PacketEntity entity, PropertyHolder properties) {
|
||||
HashMap<Integer, EntityData> data = new HashMap<>();
|
||||
if (entity.getType() == EntityTypes.PLAYER) add(data, metadataFactory.skinLayers(properties.getProperty(propertyRegistry.getByName("skin_layers", Boolean.class))));
|
||||
if (entity.getType() == EntityTypes.PLAYER) {
|
||||
add(data, metadataFactory.skinLayers(properties.getProperty(propertyRegistry.getByName("skin_layers", Boolean.class))));
|
||||
add(data, metadataFactory.cape(properties.getProperty(propertyRegistry.getByName("cape", Boolean.class))));
|
||||
}
|
||||
add(data, metadataFactory.effects(properties.getProperty(propertyRegistry.getByName("fire", Boolean.class)), false, properties.getProperty(propertyRegistry.getByName("fire", Boolean.class))));
|
||||
add(data, metadataFactory.silent(properties.getProperty(propertyRegistry.getByName("silent", Boolean.class))));
|
||||
if (properties.hasProperty(propertyRegistry.getByName("name"))) addAll(data, metadataFactory.name(properties.getProperty(propertyRegistry.getByName("name", Component.class))));
|
||||
|
|
Loading…
Reference in a new issue