1-
21package me .zimzaza4 .geyserdisplayentity .entity ;
32
43import me .zimzaza4 .geyserdisplayentity .ExtensionMain ;
98import org .cloudburstmc .protocol .bedrock .data .entity .EntityDataTypes ;
109import org .cloudburstmc .protocol .bedrock .data .inventory .ItemData ;
1110import org .cloudburstmc .protocol .bedrock .packet .MoveEntityAbsolutePacket ; // added
11+ import org .geysermc .geyser .api .util .Identifier ;
1212import org .geysermc .geyser .entity .EntityDefinition ;
13+ import org .geysermc .geyser .entity .properties .type .FloatProperty ;
14+ import org .geysermc .geyser .entity .properties .type .IntProperty ;
1315import org .geysermc .geyser .entity .type .Entity ;
1416import org .geysermc .geyser .session .GeyserSession ;
1517import org .geysermc .geyser .util .MathUtils ;
1618import org .geysermc .mcprotocollib .protocol .data .game .entity .metadata .EntityMetadata ;
1719
1820import java .util .UUID ;
1921
22+ import static me .zimzaza4 .geyserdisplayentity .ExtensionMain .MAX_VALUE ;
23+ import static me .zimzaza4 .geyserdisplayentity .ExtensionMain .MIN_VALUE ;
24+
2025public class SlotDisplayEntity extends Entity {
2126
2227 protected ItemData item = ItemData .AIR ;
@@ -53,13 +58,13 @@ public void initializeMetadata() {
5358 validQScale = false ;
5459 rotationUpdated = false ;
5560
56- propertyManager .add ( "geyser:t_x" , translation .getX () * 10 );
57- propertyManager .add ( "geyser:t_y" , translation .getY () * 10 );
58- propertyManager .add ( "geyser:t_z" , translation .getZ () * 10 );
61+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:t_x" ), MAX_VALUE , MIN_VALUE , 0F ) , translation .getX () * 10 );
62+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:t_y" ), MAX_VALUE , MIN_VALUE , 0F ) , translation .getY () * 10 );
63+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:t_z" ), MAX_VALUE , MIN_VALUE , 0F ) , translation .getZ () * 10 );
5964
60- propertyManager .add ( "geyser:s_x" , scale .getX ());
61- propertyManager .add ( "geyser:s_y" , scale .getY ());
62- propertyManager .add ( "geyser:s_z" , scale .getZ ());
65+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:s_x" ), MAX_VALUE , MIN_VALUE , 0F ) , scale .getX ());
66+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:s_y" ), MAX_VALUE , MIN_VALUE , 0F ) , scale .getY ());
67+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:s_z" ), MAX_VALUE , MIN_VALUE , 0F ) , scale .getZ ());
6368
6469 if (options == null ) {
6570 options = Settings .IMP .GENERAL ;
@@ -68,11 +73,11 @@ public void initializeMetadata() {
6873 applyScale ();
6974 }
7075
71- propertyManager .add ( "geyser:r_x" , MathUtils .wrapDegrees (rotation .getX ()));
72- propertyManager .add ( "geyser:r_y" , MathUtils .wrapDegrees (-rotation .getY ()));
73- propertyManager .add ( "geyser:r_z" , MathUtils .wrapDegrees (-rotation .getZ ()));
76+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:r_x" ), 180F , - 180F , 0F ) , MathUtils .wrapDegrees (rotation .getX ()));
77+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:r_y" ), 180F , - 180F , 0F ) , MathUtils .wrapDegrees (-rotation .getY ()));
78+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:r_z" ), 180F , - 180F , 0F ) , MathUtils .wrapDegrees (-rotation .getZ ()));
7479
75- propertyManager .add ( "geyser:s_q" , qScale );
80+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:s_q" ), MAX_VALUE , MIN_VALUE , 0F ) , qScale );
7681
7782 updateBedrockEntityProperties ();
7883 }
@@ -85,7 +90,7 @@ public void updateBedrockEntityProperties() {
8590
8691 if (propertyManager .hasProperties ()) {
8792 rotationUpdated = false ;
88- propertyManager .add ( "geyser:s_id" , (int ) (Math .random () * 1000000F ));
93+ propertyManager .addProperty ( new IntProperty ( Identifier . of ( "geyser:s_id" ), MAX_VALUE , MIN_VALUE , 0 ), (int ) (Math .random () * MAX_VALUE ));
8994 }
9095
9196 super .updateBedrockEntityProperties ();
@@ -99,9 +104,9 @@ public void updateBedrockMetadata() {
99104
100105 public void setTranslation (EntityMetadata <Vector3f , ?> entityMetadata ) {
101106 this .translation = entityMetadata .getValue ();
102- propertyManager .add ( "geyser:t_x" , translation .getX () * 10 );
103- propertyManager .add ( "geyser:t_y" , translation .getY () * 10 );
104- propertyManager .add ( "geyser:t_z" , translation .getZ () * 10 );
107+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:t_x" ), MAX_VALUE , MIN_VALUE , 0F ) , translation .getX () * 10 );
108+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:t_y" ), MAX_VALUE , MIN_VALUE , 0F ) , translation .getY () * 10 );
109+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:t_z" ), MAX_VALUE , MIN_VALUE , 0F ) , translation .getZ () * 10 );
105110 }
106111
107112 public void setScale (EntityMetadata <Vector3f , ?> entityMetadata ) {
@@ -111,9 +116,9 @@ public void setScale(EntityMetadata<Vector3f, ?> entityMetadata) {
111116 if (options .VANILLA_SCALE ) {
112117 applyScale ();
113118 }
114- propertyManager .add ( "geyser:s_x" , scale .getX ());
115- propertyManager .add ( "geyser:s_y" , scale .getY ());
116- propertyManager .add ( "geyser:s_z" , scale .getZ ());
119+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:s_x" ), MAX_VALUE , MIN_VALUE , 0F ) , scale .getX ());
120+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:s_y" ), MAX_VALUE , MIN_VALUE , 0F ) , scale .getY ());
121+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:s_z" ), MAX_VALUE , MIN_VALUE , 0F ) , scale .getZ ());
117122 }
118123
119124
@@ -150,12 +155,12 @@ protected void setRotation(Quaternionf q) {
150155 this .rotation = r ;
151156 }
152157
153- propertyManager .add ( "geyser:r_x" , MathUtils .wrapDegrees (rotation .getX ()));
154- propertyManager .add ( "geyser:r_y" , MathUtils .wrapDegrees (-rotation .getY ()));
155- propertyManager .add ( "geyser:r_z" , MathUtils .wrapDegrees (-rotation .getZ ()));
158+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:r_x" ), 180F , - 180F , 0F ) , MathUtils .wrapDegrees (rotation .getX ()));
159+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:r_y" ), 180F , - 180F , 0F ) , MathUtils .wrapDegrees (-rotation .getY ()));
160+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:r_z" ), 180F , - 180F , 0F ) , MathUtils .wrapDegrees (-rotation .getZ ()));
156161
157162 this .qScale = s ;
158- propertyManager .add ( "geyser:s_q" , qScale );
163+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:s_q" ), MAX_VALUE , MIN_VALUE , 0F ) , qScale );
159164 }
160165
161166 protected void applyBedrockYawPitchFromCombined () {
@@ -212,9 +217,9 @@ public float magnitude(Quaternionf q) {
212217 }
213218
214219 protected void hackRotation (float x , float y , float z ) {
215- propertyManager .add ( "geyser:r_x" , x );
216- propertyManager .add ( "geyser:r_y" , y );
217- propertyManager .add ( "geyser:r_z" , z );
220+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:r_x" ), 180F , - 180F , 0F ) , x );
221+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:r_y" ), 180F , - 180F , 0F ) , y );
222+ propertyManager .addProperty ( new FloatProperty ( Identifier . of ( "geyser:r_z" ), 180F , - 180F , 0F ) , z );
218223 updateBedrockEntityProperties ();
219224 }
220- }
225+ }
0 commit comments