Skip to content

Commit

Permalink
Unify the pivot position of status hologram elements
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 committed Jul 25, 2024
1 parent 1bcbe57 commit 96fb1b4
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.haykam821.lastcard.game.map;

import org.joml.Vector3f;

import eu.pb4.polymer.virtualentity.api.ElementHolder;
import eu.pb4.polymer.virtualentity.api.attachment.ChunkAttachment;
import eu.pb4.polymer.virtualentity.api.elements.DisplayElement;
Expand All @@ -25,7 +27,7 @@ public final class StatusHologram {
public StatusHologram(AbstractPlayerEntry player) {
this.player = player;

this.headStackElement = createItemElement();
this.headStackElement = createHeadStackElement();
this.headStackHolder = createHolder(this.headStackElement);

this.textElement = createTextElement();
Expand All @@ -43,8 +45,10 @@ public void tick() {
}

public void attach(ServerWorld world, Vec3d pos) {
ChunkAttachment.of(this.headStackHolder, world, pos.add(0, 0.56, 0));
ChunkAttachment.of(this.textHolder, world, pos.subtract(0, 0.12, 0));
Vec3d attachmentPos = pos.subtract(0, 0.12, 0);

ChunkAttachment.of(this.headStackHolder, world, attachmentPos);
ChunkAttachment.of(this.textHolder, world, attachmentPos);
}

public void destroy() {
Expand All @@ -59,6 +63,15 @@ public static ElementHolder createHolder(DisplayElement element) {
return holder;
}

public static ItemDisplayElement createHeadStackElement() {
ItemDisplayElement element = createItemElement();

element.setScale(new Vector3f(1, 1, 0.01f));
element.setTranslation(new Vector3f(0, 0.68f, 0));

return element;
}

public static ItemDisplayElement createItemElement() {
ItemDisplayElement element = new ItemDisplayElement();

Expand Down

0 comments on commit 96fb1b4

Please sign in to comment.