2828import java .awt .*;
2929import java .util .ArrayList ;
3030import java .util .List ;
31- import java .util .Objects ;
3231import java .util .function .Consumer ;
3332import java .util .stream .Collectors ;
3433
3534/**
3635 * The hologram for FancyHolograms
3736 */
3837public class FHHologram implements me .hsgamer .unihologram .common .api .Hologram <Location >, Colored , PlayerVisibility , DisplayHologram <Location > {
39- private static final double LINE_HEIGHT = 0.25 ;
4038 private final Hologram hologram ;
4139
4240 /**
@@ -60,36 +58,6 @@ public FHHologram(Hologram hologram) {
6058 this .hologram = hologram ;
6159 }
6260
63- private static Location getTopLocation (Location location , float scale , int lineCount ) {
64- Location newLocation = Objects .requireNonNull (location ).clone ();
65- newLocation .setY (newLocation .getY () + LINE_HEIGHT * scale * lineCount );
66- return newLocation ;
67- }
68-
69- private static Location getBottomLocation (Location location , float yScale , int lineCount ) {
70- Location newLocation = Objects .requireNonNull (location ).clone ();
71- newLocation .setY (newLocation .getY () - LINE_HEIGHT * yScale * lineCount );
72- return newLocation ;
73- }
74-
75- private Location getTopLocation () {
76- return getTopLocation (hologram .getData ().getLocation (), hologram .getData ().getScale ().y , hologram .getData ().getText ().size ());
77- }
78-
79- private void setTopLocation (Location location ) {
80- hologram .getData ().setLocation (getBottomLocation (location , hologram .getData ().getScale ().y , hologram .getData ().getText ().size ()));
81- }
82-
83- private void updateTopLocation (float yScale , int lineCount ) {
84- Location topLocation = getTopLocation (hologram .getData ().getLocation (), hologram .getData ().getScale ().y , hologram .getData ().getText ().size ());
85- Location bottomLocation = getBottomLocation (topLocation , yScale , lineCount );
86- hologram .getData ().setLocation (bottomLocation );
87- }
88-
89- private void updateTopLocation (int lineCount ) {
90- updateTopLocation (hologram .getData ().getScale ().y , lineCount );
91- }
92-
9361 private void checkHologramInitialized () {
9462 Preconditions .checkArgument (isInitialized (), "Hologram is not initialized" );
9563 }
@@ -132,7 +100,6 @@ private void editLine(Consumer<List<HologramLine>> consumer) {
132100 checkHologramInitialized ();
133101 List <HologramLine > lines = new ArrayList <>(getLines ());
134102 consumer .accept (lines );
135- updateTopLocation (lines .size ());
136103 setLines (lines );
137104 }
138105
@@ -178,13 +145,13 @@ public boolean isInitialized() {
178145 @ Override
179146 public Location getLocation () {
180147 checkHologramInitialized ();
181- return getTopLocation ();
148+ return hologram . getData (). getLocation ();
182149 }
183150
184151 @ Override
185152 public void setLocation (Location location ) {
186153 checkHologramInitialized ();
187- setTopLocation (location );
154+ hologram . getData (). setLocation (location );
188155 updateHologram ();
189156 }
190157
@@ -242,7 +209,6 @@ public DisplayScale getScale() {
242209 @ Override
243210 public void setScale (DisplayScale scale ) {
244211 checkHologramInitialized ();
245- updateTopLocation (scale .y , hologram .getData ().getText ().size ());
246212 hologram .getData ().setScale (scale .x , scale .y , scale .z );
247213 updateHologram ();
248214 }
@@ -350,17 +316,4 @@ public void setAlignment(DisplayTextAlignment alignment) {
350316 }
351317 updateHologram ();
352318 }
353-
354- @ Override
355- public Location getOriginLocation () {
356- checkHologramInitialized ();
357- return hologram .getData ().getLocation ();
358- }
359-
360- @ Override
361- public void setOriginLocation (Location originLocation ) {
362- checkHologramInitialized ();
363- hologram .getData ().setLocation (originLocation );
364- updateHologram ();
365- }
366319}
0 commit comments