mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-19 15:09:23 +00:00
improve rendering
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
package net.momirealms.customnameplates.api;
|
package net.momirealms.customnameplates.api;
|
||||||
|
|
||||||
import net.momirealms.customnameplates.api.feature.bossbar.BossBar;
|
import net.momirealms.customnameplates.api.feature.bossbar.BossBar;
|
||||||
|
import net.momirealms.customnameplates.api.feature.tag.NameTagConfig;
|
||||||
import net.momirealms.customnameplates.api.network.PacketEvent;
|
import net.momirealms.customnameplates.api.network.PacketEvent;
|
||||||
import net.momirealms.customnameplates.api.placeholder.Placeholder;
|
import net.momirealms.customnameplates.api.placeholder.Placeholder;
|
||||||
import net.momirealms.customnameplates.api.util.Alignment;
|
import net.momirealms.customnameplates.api.util.Alignment;
|
||||||
@@ -189,13 +190,7 @@ public interface Platform {
|
|||||||
*/
|
*/
|
||||||
Consumer<List<Object>> createTranslationModifier(Vector3 translation);
|
Consumer<List<Object>> createTranslationModifier(Vector3 translation);
|
||||||
|
|
||||||
/**
|
Consumer<List<Object>> createSneakModifier(boolean isSneaking, NameTagConfig config);
|
||||||
* Creates a modifier to change the opacity of a text display.
|
|
||||||
*
|
|
||||||
* @param opacity the new opacity
|
|
||||||
* @return a consumer that applies the modifier to a list of packets
|
|
||||||
*/
|
|
||||||
Consumer<List<Object>> createOpacityModifier(byte opacity);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates an existing text display entity with modifiers.
|
* Updates an existing text display entity with modifiers.
|
||||||
|
|||||||
@@ -162,13 +162,6 @@ public abstract class AbstractTag implements Tag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void darkTag(CNPlayer viewer, boolean dark) {
|
|
||||||
Consumer<List<Object>> modifiers = CustomNameplates.getInstance().getPlatform().createOpacityModifier(dark ? 64 : opacity());
|
|
||||||
Object packet = CustomNameplates.getInstance().getPlatform().updateTextDisplayPacket(entityID, List.of(modifiers));
|
|
||||||
CustomNameplates.getInstance().getPacketSender().sendPacket(viewer, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerScaleUpdate(double scale) {
|
public void onPlayerScaleUpdate(double scale) {
|
||||||
for (CNPlayer viewer : viewerArray) {
|
for (CNPlayer viewer : viewerArray) {
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ public interface NameTagConfig {
|
|||||||
*
|
*
|
||||||
* @return true if the name tag is see-through, false otherwise
|
* @return true if the name tag is see-through, false otherwise
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
boolean isSeeThrough();
|
boolean isSeeThrough();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import net.momirealms.customnameplates.api.util.Vector3;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class NameTag extends AbstractTag implements RelationalFeature {
|
public class NameTag extends AbstractTag implements RelationalFeature {
|
||||||
|
|
||||||
@@ -74,6 +75,13 @@ public class NameTag extends AbstractTag implements RelationalFeature {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void darkTag(CNPlayer viewer, boolean dark) {
|
||||||
|
Consumer<List<Object>> modifiers = CustomNameplates.getInstance().getPlatform().createSneakModifier(dark, this.config);
|
||||||
|
Object packet = CustomNameplates.getInstance().getPlatform().updateTextDisplayPacket(entityID, List.of(modifiers));
|
||||||
|
CustomNameplates.getInstance().getPacketSender().sendPacket(viewer, packet);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (timeLeft > 0)
|
if (timeLeft > 0)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import net.momirealms.customnameplates.api.ConfigManager;
|
|||||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||||
import net.momirealms.customnameplates.api.Platform;
|
import net.momirealms.customnameplates.api.Platform;
|
||||||
import net.momirealms.customnameplates.api.feature.bossbar.BossBar;
|
import net.momirealms.customnameplates.api.feature.bossbar.BossBar;
|
||||||
|
import net.momirealms.customnameplates.api.feature.tag.NameTagConfig;
|
||||||
import net.momirealms.customnameplates.api.helper.AdventureHelper;
|
import net.momirealms.customnameplates.api.helper.AdventureHelper;
|
||||||
import net.momirealms.customnameplates.api.helper.VersionHelper;
|
import net.momirealms.customnameplates.api.helper.VersionHelper;
|
||||||
import net.momirealms.customnameplates.api.network.PacketEvent;
|
import net.momirealms.customnameplates.api.network.PacketEvent;
|
||||||
@@ -638,7 +639,7 @@ public class BukkitPlatform implements Platform {
|
|||||||
EntityData.LineWidth.addEntityDataIfNotDefaultValue( lineWidth, values);
|
EntityData.LineWidth.addEntityDataIfNotDefaultValue( lineWidth, values);
|
||||||
EntityData.Scale.addEntityDataIfNotDefaultValue( scale.toVec3(), values);
|
EntityData.Scale.addEntityDataIfNotDefaultValue( scale.toVec3(), values);
|
||||||
EntityData.Translation.addEntityDataIfNotDefaultValue( translation.toVec3(), values);
|
EntityData.Translation.addEntityDataIfNotDefaultValue( translation.toVec3(), values);
|
||||||
EntityData.TextDisplayMasks.addEntityDataIfNotDefaultValue(EntityData.encodeMask(hasShadow, isSeeThrough, useDefaultBackgroundColor, alignment.getId()), values);
|
EntityData.TextDisplayMasks.addEntityDataIfNotDefaultValue(EntityData.encodeMask(hasShadow, !isCrouching, useDefaultBackgroundColor, alignment.getId()), values);
|
||||||
|
|
||||||
Object setDataPacket = Reflections.constructor$ClientboundSetEntityDataPacket.newInstance(entityID, values);
|
Object setDataPacket = Reflections.constructor$ClientboundSetEntityDataPacket.newInstance(entityID, values);
|
||||||
|
|
||||||
@@ -678,8 +679,11 @@ public class BukkitPlatform implements Platform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Consumer<List<Object>> createOpacityModifier(byte opacity) {
|
public Consumer<List<Object>> createSneakModifier(boolean sneak, NameTagConfig config) {
|
||||||
return (values) -> EntityData.TextOpacity.addEntityData(opacity, values);
|
return (values) -> {
|
||||||
|
EntityData.TextOpacity.addEntityData(sneak ? 64 : config.opacity(), values);
|
||||||
|
EntityData.TextDisplayMasks.addEntityData(EntityData.encodeMask(config.hasShadow(), !sneak, config.useDefaultBackgroundColor(), config.alignment().getId()), values);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user