implement armor stand rotation properties
This commit is contained in:
		
							parent
							
								
									70e1e2d0a2
								
							
						
					
					
						commit
						a4fc363454
					
				
					 2 changed files with 38 additions and 8 deletions
				
			
		| 
						 | 
					@ -72,14 +72,6 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
 | 
				
			||||||
        registerType("beam_target", null); // TODO: Make a block pos class for this
 | 
					        registerType("beam_target", null); // TODO: Make a block pos class for this
 | 
				
			||||||
        registerType("show_base", true); // TODO
 | 
					        registerType("show_base", true); // TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Armor Stand
 | 
					 | 
				
			||||||
        registerType("head_rotation", Vector3f.zero());
 | 
					 | 
				
			||||||
        registerType("body_rotation", Vector3f.zero());
 | 
					 | 
				
			||||||
        registerType("left_arm_rotation", new Vector3f(-10, 0, -10));
 | 
					 | 
				
			||||||
        registerType("right_arm_rotation", new Vector3f(-15, 0, 10));
 | 
					 | 
				
			||||||
        registerType("left_leg_rotation", new Vector3f(-1 , 0, -1));
 | 
					 | 
				
			||||||
        registerType("right_leg_rotation", new Vector3f(1, 0, 1));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Axolotl
 | 
					        // Axolotl
 | 
				
			||||||
        registerType("axolotl_variant", 0);
 | 
					        registerType("axolotl_variant", 0);
 | 
				
			||||||
        registerType("playing_dead", false); // TODO fix disabling
 | 
					        registerType("playing_dead", false); // TODO fix disabling
 | 
				
			||||||
| 
						 | 
					@ -266,6 +258,19 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        linkProperties("skin_cape", "skin_jacket", "skin_left_sleeve", "skin_right_sleeve", "skin_left_leg", "skin_right_leg", "skin_hat");
 | 
					        linkProperties("skin_cape", "skin_jacket", "skin_left_sleeve", "skin_right_sleeve", "skin_left_leg", "skin_right_leg", "skin_hat");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int armorStandRotationIndex;
 | 
				
			||||||
 | 
					        if (ver.isNewerThanOrEquals(ServerVersion.V_1_17)) armorStandRotationIndex = 16;
 | 
				
			||||||
 | 
					        else if (ver.isNewerThanOrEquals(ServerVersion.V_1_15)) armorStandRotationIndex = 15;
 | 
				
			||||||
 | 
					        else if (ver.isNewerThanOrEquals(ServerVersion.V_1_14)) armorStandRotationIndex = 14;
 | 
				
			||||||
 | 
					        else if (ver.isNewerThanOrEquals(ServerVersion.V_1_10)) armorStandRotationIndex = 12;
 | 
				
			||||||
 | 
					        else armorStandRotationIndex = 11;
 | 
				
			||||||
 | 
					        register(new RotationProperty("head_rotation", armorStandRotationIndex++, Vector3f.zero()));
 | 
				
			||||||
 | 
					        register(new RotationProperty("body_rotation", armorStandRotationIndex++, Vector3f.zero()));
 | 
				
			||||||
 | 
					        register(new RotationProperty("left_arm_rotation", armorStandRotationIndex++, new Vector3f(-10, 0, -10)));
 | 
				
			||||||
 | 
					        register(new RotationProperty("right_arm_rotation", armorStandRotationIndex++, new Vector3f(-15, 0, 10)));
 | 
				
			||||||
 | 
					        register(new RotationProperty("left_leg_rotation", armorStandRotationIndex++, new Vector3f(-1, 0, -1)));
 | 
				
			||||||
 | 
					        register(new RotationProperty("right_leg_rotation", armorStandRotationIndex, new Vector3f(1, 0, 1)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void registerSerializer(PropertySerializer<?> serializer) {
 | 
					    private void registerSerializer(PropertySerializer<?> serializer) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					package lol.pyr.znpcsplus.entity.properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
 | 
				
			||||||
 | 
					import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
 | 
				
			||||||
 | 
					import lol.pyr.znpcsplus.entity.EntityPropertyImpl;
 | 
				
			||||||
 | 
					import lol.pyr.znpcsplus.entity.PacketEntity;
 | 
				
			||||||
 | 
					import lol.pyr.znpcsplus.util.Vector3f;
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class RotationProperty extends EntityPropertyImpl<Vector3f> {
 | 
				
			||||||
 | 
					    private final int index;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public RotationProperty(String name, int index, Vector3f defaultValue) {
 | 
				
			||||||
 | 
					        super(name, defaultValue, Vector3f.class);
 | 
				
			||||||
 | 
					        this.index = index;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void apply(Player player, PacketEntity entity, boolean isSpawned, Map<Integer, EntityData> properties) {
 | 
				
			||||||
 | 
					        Vector3f vec = entity.getProperty(this);
 | 
				
			||||||
 | 
					        properties.put(index, newEntityData(index, EntityDataTypes.ROTATION, new com.github.retrooper.packetevents.util.Vector3f(vec.getX(), vec.getY(), vec.getZ())));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in a new issue