Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v0.7' into v0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeGodSRC committed Oct 14, 2024
2 parents 0d0ac0c + 74819b3 commit 03872b6
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

package io.fairyproject.mc.hologram.entity.impl;

import com.github.retrooper.packetevents.PacketEvents;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
Expand Down Expand Up @@ -72,8 +74,8 @@ public void update(MCPlayer player) {
WrapperPlayServerEntityTeleport packet = new WrapperPlayServerEntityTeleport(
this.entityId,
this.packetPosition(),
this.hologram.getPosition().getPitch(),
this.hologram.getPosition().getYaw(),
this.hologram.getPosition().getPitch(),
false
);
WrapperPlayServerEntityMetadata metadataPacket = new WrapperPlayServerEntityMetadata(
Expand All @@ -99,12 +101,13 @@ public void hide(MCPlayer player) {
}

private List<EntityData> createEntityData(MCPlayer mcPlayer) {
boolean modern = PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_20_2);
List<EntityData> entityDataList = new ArrayList<>();

entityDataList.add(new EntityData(22, EntityDataTypes.COMPONENT, MCAdventure.asItemString(line.render(mcPlayer), mcPlayer.getLocale()))); // text
entityDataList.add(new EntityData(23, EntityDataTypes.CAT_VARIANT, 200)); // line width
entityDataList.add(new EntityData(24, EntityDataTypes.CAT_VARIANT, 0x40000000)); // background color
entityDataList.add(new EntityData(25, EntityDataTypes.CAT_VARIANT, -1)); // text opacity
entityDataList.add(new EntityData(modern ? 23 : 22, EntityDataTypes.COMPONENT, MCAdventure.asItemString(line.render(mcPlayer), mcPlayer.getLocale()))); // text
entityDataList.add(new EntityData(modern ? 24 : 23, EntityDataTypes.INT, 200)); // line width
entityDataList.add(new EntityData(modern ? 25 : 24, EntityDataTypes.INT, 0x40000000)); // background color
entityDataList.add(new EntityData(modern ? 26 : 25, EntityDataTypes.BYTE, (byte) -1)); // text opacity
/**
* bit mask
* 0x01 = has shadow
Expand All @@ -116,7 +119,7 @@ private List<EntityData> createEntityData(MCPlayer mcPlayer) {
boolean isSeeThrough = false;
boolean useDefaultBackgroundColor = true;
int alignment = 0;
entityDataList.add(new EntityData(26, EntityDataTypes.CAT_VARIANT, (hasShadow ? 0x01 : 0) | (isSeeThrough ? 0x02 : 0) | (useDefaultBackgroundColor ? 0x04 : 0) | alignment));
entityDataList.add(new EntityData(modern ? 27 : 26, EntityDataTypes.BYTE, (byte)((hasShadow ? 0x01 : 0) | (isSeeThrough ? 0x02 : 0) | (useDefaultBackgroundColor ? 0x04 : 0) | alignment)));

return entityDataList;
}
Expand Down

0 comments on commit 03872b6

Please sign in to comment.