diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/minecraft/world/entity/DisplayMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/minecraft/world/entity/DisplayMixin_API.java index 7457db52f8b..76b606ae5ee 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/minecraft/world/entity/DisplayMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/minecraft/world/entity/DisplayMixin_API.java @@ -24,11 +24,30 @@ */ package org.spongepowered.common.mixin.api.minecraft.world.entity; +import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.world.entity.Display; +import org.joml.Vector3f; import org.spongepowered.api.entity.display.DisplayEntity; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.math.vector.Vector3d; @Mixin(Display.class) public abstract class DisplayMixin_API extends EntityMixin_API implements DisplayEntity { + // @formatter:off + @Shadow @Final private static EntityDataAccessor DATA_SCALE_ID; + // @formatter:on + + @Override + public void setScale(Vector3d scale) { + entityData.set(DisplayMixin_API.DATA_SCALE_ID, new Vector3f((float) scale.x(), (float) scale.y(), (float) scale.z())); + } + + @Override + public Vector3d scale() { + Vector3f scale = entityData.get(DisplayMixin_API.DATA_SCALE_ID); + return new Vector3d(scale.x, scale.y, scale.z); + } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/minecraft/world/entity/EntityMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/minecraft/world/entity/EntityMixin_API.java index d662b1576c2..7052f83e8bc 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/minecraft/world/entity/EntityMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/minecraft/world/entity/EntityMixin_API.java @@ -30,6 +30,7 @@ import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; @@ -87,6 +88,7 @@ public abstract class EntityMixin_API implements org.spongepowered.api.entity.En @Shadow protected UUID uuid; @Shadow @Final private net.minecraft.world.entity.EntityType type; @Shadow private Level level; + @Shadow @Final protected SynchedEntityData entityData; @Shadow public abstract double shadow$getX(); @Shadow public abstract double shadow$getY(); diff --git a/testplugins/src/main/java/org/spongepowered/test/entity/DisplayEntityTest.java b/testplugins/src/main/java/org/spongepowered/test/entity/DisplayEntityTest.java index 3d9c74a991a..424c58037b1 100644 --- a/testplugins/src/main/java/org/spongepowered/test/entity/DisplayEntityTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/entity/DisplayEntityTest.java @@ -234,6 +234,7 @@ public void onRegisterCommand(final RegisterCommandEvent event) { player.world().spawnEntity(blockDisplay); blockDisplay.offer(Keys.TELEPORT_DURATION, Ticks.of(20)); blockDisplay.setLocation(((ServerLocation) blockDisplay.location().add(0.0, 4.0, 0.0))); + blockDisplay.setScale(new Vector3d(1.0,5.0,1.0)); textDisplay = createEntity(player.world(), EntityTypes.TEXT_DISPLAY, centerPos, forwardDir, col7, 0);