Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ public class SlotDisplayEntity extends Entity {
protected Quaternionf lastRight = Quaternionf.IDENTITY;

public SlotDisplayEntity(GeyserSession session, int entityId, long geyserId, UUID uuid,
EntityDefinition<?> definition,
Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
EntityDefinition<?> definition,
Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);

// Ensure options is never null
if (this.options == null) {
this.options = Settings.IMP.GENERAL != null ? Settings.IMP.GENERAL : new Settings.DisplayEntityOptions();
}
}

public void updateMainHand(GeyserSession session) {
Expand All @@ -58,24 +63,33 @@ public void initializeMetadata() {
validQScale = false;
rotationUpdated = false;

propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:t_x"), MAX_VALUE, MIN_VALUE, 0F), translation.getX() * 10);
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:t_y"), MAX_VALUE, MIN_VALUE, 0F), translation.getY() * 10);
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:t_z"), MAX_VALUE, MIN_VALUE, 0F), translation.getZ() * 10);
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:t_x"), MAX_VALUE, MIN_VALUE, 0F),
translation.getX() * 10);
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:t_y"), MAX_VALUE, MIN_VALUE, 0F),
translation.getY() * 10);
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:t_z"), MAX_VALUE, MIN_VALUE, 0F),
translation.getZ() * 10);

propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_x"), MAX_VALUE, MIN_VALUE, 0F), scale.getX());
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_y"), MAX_VALUE, MIN_VALUE, 0F), scale.getY());
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_z"), MAX_VALUE, MIN_VALUE, 0F), scale.getZ());
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_x"), MAX_VALUE, MIN_VALUE, 0F),
scale.getX());
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_y"), MAX_VALUE, MIN_VALUE, 0F),
scale.getY());
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_z"), MAX_VALUE, MIN_VALUE, 0F),
scale.getZ());

if (options == null) {
options = Settings.IMP.GENERAL;
}
if (options.VANILLA_SCALE) {
if (options != null && options.VANILLA_SCALE) {
applyScale();
}

propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:r_x"), 180F, -180F, 0F), MathUtils.wrapDegrees(rotation.getX()));
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:r_y"), 180F, -180F, 0F), MathUtils.wrapDegrees(-rotation.getY()));
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:r_z"), 180F, -180F, 0F), MathUtils.wrapDegrees(-rotation.getZ()));
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:r_x"), 180F, -180F, 0F),
MathUtils.wrapDegrees(rotation.getX()));
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:r_y"), 180F, -180F, 0F),
MathUtils.wrapDegrees(-rotation.getY()));
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:r_z"), 180F, -180F, 0F),
MathUtils.wrapDegrees(-rotation.getZ()));

propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_q"), MAX_VALUE, MIN_VALUE, 0F), qScale);

Expand All @@ -90,7 +104,8 @@ public void updateBedrockEntityProperties() {

if (propertyManager.hasProperties()) {
rotationUpdated = false;
propertyManager.addProperty(new IntProperty(Identifier.of("geyser:s_id"), MAX_VALUE, MIN_VALUE, 0), (int) (Math.random() * MAX_VALUE));
propertyManager.addProperty(new IntProperty(Identifier.of("geyser:s_id"), MAX_VALUE, MIN_VALUE, 0),
(int) (Math.random() * MAX_VALUE));
}

super.updateBedrockEntityProperties();
Expand All @@ -104,28 +119,35 @@ public void updateBedrockMetadata() {

public void setTranslation(EntityMetadata<Vector3f, ?> entityMetadata) {
this.translation = entityMetadata.getValue();
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:t_x"), MAX_VALUE, MIN_VALUE, 0F), translation.getX() * 10);
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:t_y"), MAX_VALUE, MIN_VALUE, 0F), translation.getY() * 10);
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:t_z"), MAX_VALUE, MIN_VALUE, 0F), translation.getZ() * 10);
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:t_x"), MAX_VALUE, MIN_VALUE, 0F),
translation.getX() * 10);
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:t_y"), MAX_VALUE, MIN_VALUE, 0F),
translation.getY() * 10);
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:t_z"), MAX_VALUE, MIN_VALUE, 0F),
translation.getZ() * 10);
}

public void setScale(EntityMetadata<Vector3f, ?> entityMetadata) {

this.scale = entityMetadata.getValue();

if (options.VANILLA_SCALE) {
if (options != null && options.VANILLA_SCALE) {
applyScale();
}
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_x"), MAX_VALUE, MIN_VALUE, 0F), scale.getX());
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_y"), MAX_VALUE, MIN_VALUE, 0F), scale.getY());
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_z"), MAX_VALUE, MIN_VALUE, 0F), scale.getZ());
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_x"), MAX_VALUE, MIN_VALUE, 0F),
scale.getX());
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_y"), MAX_VALUE, MIN_VALUE, 0F),
scale.getY());
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_z"), MAX_VALUE, MIN_VALUE, 0F),
scale.getZ());
}


protected void applyScale() {
Vector3f vector3f = this.scale;
float scale = (vector3f.getX() + vector3f.getY() + vector3f.getZ()) / 3;
if (options.VANILLA_SCALE) {

if (options != null && options.VANILLA_SCALE) {
scale *= (float) options.VANILLA_SCALE_MULTIPLIER;
}

Expand Down Expand Up @@ -165,9 +187,12 @@ protected void setRotation(Quaternionf q) {
this.rotation = r;
}

propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:r_x"), 180F, -180F, 0F), MathUtils.wrapDegrees(rotation.getX()));
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:r_y"), 180F, -180F, 0F), MathUtils.wrapDegrees(-rotation.getY()));
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:r_z"), 180F, -180F, 0F), MathUtils.wrapDegrees(-rotation.getZ()));
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:r_x"), 180F, -180F, 0F),
MathUtils.wrapDegrees(rotation.getX()));
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:r_y"), 180F, -180F, 0F),
MathUtils.wrapDegrees(-rotation.getY()));
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:r_z"), 180F, -180F, 0F),
MathUtils.wrapDegrees(-rotation.getZ()));

this.qScale = s;
propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_q"), MAX_VALUE, MIN_VALUE, 0F), qScale);
Expand Down