Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement scaling for display entities #4111

Open
wants to merge 3 commits into
base: api-11
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -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<Vector3f> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ public void onRegisterCommand(final RegisterCommandEvent<Parameterized> 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);
Expand Down
Loading