Skip to content

Commit 3b569c3

Browse files
committed
Update
1 parent 6c43ca3 commit 3b569c3

5 files changed

Lines changed: 61 additions & 44 deletions

File tree

dependency-reduced-pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<dependency>
6565
<groupId>org.geysermc.geyser</groupId>
6666
<artifactId>core</artifactId>
67-
<version>2.7.1-SNAPSHOT</version>
67+
<version>2.9.0-SNAPSHOT</version>
6868
<scope>system</scope>
6969
<systemPath>${project.basedir}/libs/Geyser-Standalone.jar</systemPath>
7070
</dependency>

libs/Geyser-Standalone.jar

-3.21 MB
Binary file not shown.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<dependency>
8484
<groupId>org.geysermc.geyser</groupId>
8585
<artifactId>core</artifactId>
86-
<version>2.7.1-SNAPSHOT</version>
86+
<version>2.9.0-SNAPSHOT</version>
8787
<scope>system</scope>
8888
<systemPath>${project.basedir}/libs/Geyser-Standalone.jar</systemPath>
8989
</dependency>

src/main/java/me/zimzaza4/geyserdisplayentity/ExtensionMain.java

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
import org.cloudburstmc.nbt.NbtMap;
77
import org.cloudburstmc.nbt.NbtType;
88
import org.geysermc.event.subscribe.Subscribe;
9+
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineEntityPropertiesEvent;
910
import org.geysermc.geyser.api.event.lifecycle.GeyserPostInitializeEvent;
1011
import org.geysermc.geyser.api.extension.Extension;
1112
import org.geysermc.geyser.api.extension.ExtensionLogger;
13+
import org.geysermc.geyser.api.util.Identifier;
1214
import org.geysermc.geyser.entity.EntityDefinition;
1315
import org.geysermc.geyser.entity.properties.GeyserEntityProperties;
16+
import org.geysermc.geyser.entity.properties.type.FloatProperty;
17+
import org.geysermc.geyser.entity.properties.type.IntProperty;
1418
import org.geysermc.geyser.entity.type.Entity;
1519
import org.geysermc.geyser.registry.Registries;
1620
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataTypes;
@@ -25,6 +29,11 @@ public class ExtensionMain implements Extension {
2529
private static EntityDefinition<ItemDisplayEntity> ITEM_DISPLAY;
2630
private static EntityDefinition<BlockDisplayEntity> BLOCK_DISPLAY;
2731

32+
33+
public static final Integer MAX_VALUE = 1000000;
34+
35+
public static final Integer MIN_VALUE = -1000000;
36+
2837
// From Kastle's Geyser branch
2938
@Subscribe
3039
public void onLoad(GeyserPostInitializeEvent event) {
@@ -35,7 +44,10 @@ public void onLoad(GeyserPostInitializeEvent event) {
3544
} else {
3645
Settings.IMP.reload(configFile);
3746
}
47+
}
3848

49+
@Subscribe
50+
public void onDefine(GeyserDefineEntityPropertiesEvent event) {
3951
try {
4052
EntityDefinition<Entity> entityBase = EntityDefinition.builder(Entity::new)
4153
.addTranslator(MetadataTypes.BYTE, Entity::setFlags)
@@ -48,20 +60,20 @@ public void onLoad(GeyserPostInitializeEvent event) {
4860
.addTranslator(MetadataTypes.INT, Entity::setFreezing)
4961
.build();
5062

51-
GeyserEntityProperties.Builder displayPropBuilder = new GeyserEntityProperties.Builder()
52-
.addInt("geyser:s_id")
53-
.addInt("geyser:s_int")
54-
.addFloat("geyser:i_dur")
55-
.addFloat("geyser:r_x", -180F, 180F)
56-
.addFloat("geyser:r_y", -180F, 180F)
57-
.addFloat("geyser:r_z", -180F, 180F)
58-
.addFloat("geyser:t_x")
59-
.addFloat("geyser:t_y")
60-
.addFloat("geyser:t_z")
61-
.addFloat("geyser:s_x")
62-
.addFloat("geyser:s_y")
63-
.addFloat("geyser:s_z")
64-
.addFloat("geyser:s_q");
63+
GeyserEntityProperties.Builder displayPropBuilder = new GeyserEntityProperties.Builder("geyser:item_display")
64+
.add(new IntProperty(Identifier.of("geyser:s_id"), MAX_VALUE, MIN_VALUE, 0))
65+
.add(new IntProperty(Identifier.of("geyser:s_int"), MAX_VALUE, MIN_VALUE, 0))
66+
.add(new FloatProperty(Identifier.of("geyser:i_dur"), MAX_VALUE, MIN_VALUE, 0F))
67+
.add(new FloatProperty(Identifier.of("geyser:r_x"), 180F, -180F, 0F))
68+
.add(new FloatProperty(Identifier.of("geyser:r_y"), 180F, -180F, 0F))
69+
.add(new FloatProperty(Identifier.of("geyser:r_z"), 180F, -180F, 0F))
70+
.add(new FloatProperty(Identifier.of("geyser:t_x"), MAX_VALUE, MIN_VALUE, 0F))
71+
.add(new FloatProperty(Identifier.of("geyser:t_y"), MAX_VALUE, MIN_VALUE, 0F))
72+
.add(new FloatProperty(Identifier.of("geyser:t_z"), MAX_VALUE, MIN_VALUE, 0F))
73+
.add(new FloatProperty(Identifier.of("geyser:s_x"), MAX_VALUE, MIN_VALUE, 0F))
74+
.add(new FloatProperty(Identifier.of("geyser:s_y"), MAX_VALUE, MIN_VALUE, 0F))
75+
.add(new FloatProperty(Identifier.of("geyser:s_z"), MAX_VALUE, MIN_VALUE, 0F))
76+
.add(new FloatProperty(Identifier.of("geyser:s_q"), MAX_VALUE, MIN_VALUE, 0F));
6577
EntityDefinition<SlotDisplayEntity> slotDisplayBase = EntityDefinition.inherited(SlotDisplayEntity::new, entityBase)
6678
.addTranslator(null) // Interpolation start ticks
6779
.addTranslator(null) // Interpolation duration ID
@@ -82,14 +94,14 @@ public void onLoad(GeyserPostInitializeEvent event) {
8294
BLOCK_DISPLAY = EntityDefinition.inherited(BlockDisplayEntity::new, slotDisplayBase)
8395
.type(EntityType.BLOCK_DISPLAY)
8496
.height(1.975f).width(0.2f)
85-
.registeredProperties(displayPropBuilder.build())
97+
.propertiesBuilder(displayPropBuilder)
8698
.identifier("geyser:block_display")
8799
.addTranslator(MetadataTypes.BLOCK_STATE, BlockDisplayEntity::setDisplayedBlockState)
88100
.build();
89101
ITEM_DISPLAY = EntityDefinition.inherited(ItemDisplayEntity::new, slotDisplayBase)
90102
.type(EntityType.ITEM_DISPLAY)
91103
.height(1.975f).width(0.2f)
92-
.registeredProperties(displayPropBuilder.build())
104+
.propertiesBuilder(displayPropBuilder)
93105
.identifier("geyser:item_display")
94106
.addTranslator(MetadataTypes.ITEM_STACK, ItemDisplayEntity::setDisplayedItem)
95107
.addTranslator(MetadataTypes.BYTE, ItemDisplayEntity::setDisplayType)

src/main/java/me/zimzaza4/geyserdisplayentity/entity/SlotDisplayEntity.java

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
package me.zimzaza4.geyserdisplayentity.entity;
32

43
import me.zimzaza4.geyserdisplayentity.ExtensionMain;
@@ -9,14 +8,20 @@
98
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
109
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
1110
import org.cloudburstmc.protocol.bedrock.packet.MoveEntityAbsolutePacket; // added
11+
import org.geysermc.geyser.api.util.Identifier;
1212
import org.geysermc.geyser.entity.EntityDefinition;
13+
import org.geysermc.geyser.entity.properties.type.FloatProperty;
14+
import org.geysermc.geyser.entity.properties.type.IntProperty;
1315
import org.geysermc.geyser.entity.type.Entity;
1416
import org.geysermc.geyser.session.GeyserSession;
1517
import org.geysermc.geyser.util.MathUtils;
1618
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
1719

1820
import java.util.UUID;
1921

22+
import static me.zimzaza4.geyserdisplayentity.ExtensionMain.MAX_VALUE;
23+
import static me.zimzaza4.geyserdisplayentity.ExtensionMain.MIN_VALUE;
24+
2025
public 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

Comments
 (0)