mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-19 06:59:26 +00:00
fixed is see through
This commit is contained in:
@@ -190,7 +190,7 @@ public interface Platform {
|
||||
*/
|
||||
Consumer<List<Object>> createTranslationModifier(Vector3 translation);
|
||||
|
||||
Consumer<List<Object>> createSneakModifier(boolean isSneaking, NameTagConfig config);
|
||||
Consumer<List<Object>> createSneakModifier(boolean isSneaking, boolean seeThrough, NameTagConfig config);
|
||||
|
||||
/**
|
||||
* Updates an existing text display entity with modifiers.
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.momirealms.customnameplates.api.feature.CarouselText;
|
||||
import net.momirealms.customnameplates.api.requirement.Requirement;
|
||||
import net.momirealms.customnameplates.api.util.Alignment;
|
||||
import net.momirealms.customnameplates.api.util.Vector3;
|
||||
import net.momirealms.customnameplates.common.util.Tristate;
|
||||
|
||||
/**
|
||||
* NameTag Configuration
|
||||
@@ -79,10 +80,8 @@ public interface NameTagConfig {
|
||||
/**
|
||||
* Checks if the name tag is see-through.
|
||||
*
|
||||
* @return true if the name tag is see-through, false otherwise
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isSeeThrough();
|
||||
Tristate isSeeThrough();
|
||||
|
||||
/**
|
||||
* Checks if the default background color is used.
|
||||
@@ -245,7 +244,7 @@ public interface NameTagConfig {
|
||||
* @param seeThrough true if the name tag is see-through, false otherwise
|
||||
* @return the builder instance
|
||||
*/
|
||||
Builder seeThrough(boolean seeThrough);
|
||||
Builder seeThrough(Tristate seeThrough);
|
||||
|
||||
/**
|
||||
* Sets whether the name tag uses the default background color.
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.momirealms.customnameplates.api.feature.CarouselText;
|
||||
import net.momirealms.customnameplates.api.requirement.Requirement;
|
||||
import net.momirealms.customnameplates.api.util.Alignment;
|
||||
import net.momirealms.customnameplates.api.util.Vector3;
|
||||
import net.momirealms.customnameplates.common.util.Tristate;
|
||||
|
||||
/**
|
||||
* Implementation of NameTagConfig
|
||||
@@ -34,7 +35,7 @@ public class NameTagConfigImpl implements NameTagConfig {
|
||||
private final byte opacity;
|
||||
private final int backgroundColor;
|
||||
private final boolean hasShadow;
|
||||
private final boolean isSeeThrough;
|
||||
private final Tristate isSeeThrough;
|
||||
private final boolean useDefaultBackgroundColor;
|
||||
private final Alignment alignment;
|
||||
private final float viewRange;
|
||||
@@ -46,7 +47,7 @@ public class NameTagConfigImpl implements NameTagConfig {
|
||||
private final boolean affectedByScale;
|
||||
private final boolean affectedBySpectator;
|
||||
|
||||
private NameTagConfigImpl(String id, Requirement[] ownerRequirements, Requirement[] viewerRequirements, CarouselText[] carouselTexts, int lineWidth, byte opacity, int backgroundColor, boolean hasShadow, boolean isSeeThrough, boolean useDefaultBackgroundColor, Alignment alignment, float viewRange, float shadowRadius, float shadowStrength, Vector3 scale, Vector3 translation, boolean affectedByCrouching, boolean affectedByScale, boolean affectedBySpectator) {
|
||||
private NameTagConfigImpl(String id, Requirement[] ownerRequirements, Requirement[] viewerRequirements, CarouselText[] carouselTexts, int lineWidth, byte opacity, int backgroundColor, boolean hasShadow, Tristate isSeeThrough, boolean useDefaultBackgroundColor, Alignment alignment, float viewRange, float shadowRadius, float shadowStrength, Vector3 scale, Vector3 translation, boolean affectedByCrouching, boolean affectedByScale, boolean affectedBySpectator) {
|
||||
this.id = id;
|
||||
this.ownerRequirements = ownerRequirements;
|
||||
this.viewerRequirements = viewerRequirements;
|
||||
@@ -104,7 +105,7 @@ public class NameTagConfigImpl implements NameTagConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSeeThrough() {
|
||||
public Tristate isSeeThrough() {
|
||||
return isSeeThrough;
|
||||
}
|
||||
|
||||
@@ -175,7 +176,7 @@ public class NameTagConfigImpl implements NameTagConfig {
|
||||
private byte opacity;
|
||||
private int backgroundColor;
|
||||
private boolean hasShadow;
|
||||
private boolean isSeeThrough;
|
||||
private Tristate isSeeThrough;
|
||||
private boolean useDefaultBackgroundColor;
|
||||
private Alignment alignment;
|
||||
private float viewRange;
|
||||
@@ -236,7 +237,7 @@ public class NameTagConfigImpl implements NameTagConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder seeThrough(boolean seeThrough) {
|
||||
public Builder seeThrough(Tristate seeThrough) {
|
||||
this.isSeeThrough = seeThrough;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,21 @@ public enum Tristate {
|
||||
this.booleanValue = booleanValue;
|
||||
}
|
||||
|
||||
public boolean or(boolean val) {
|
||||
if (this == UNDEFINED) {
|
||||
return val;
|
||||
} else {
|
||||
return this.booleanValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static Tristate fromBoolean(Boolean val) {
|
||||
if (val == null) {
|
||||
return UNDEFINED;
|
||||
}
|
||||
return val ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the Tristate as a boolean.
|
||||
*
|
||||
|
||||
@@ -66,7 +66,7 @@ public class NameTag extends AbstractTag implements RelationalFeature {
|
||||
0, 0, 0,
|
||||
component, config.backgroundColor(),
|
||||
(owner.isSpectator() && affectedBySpectator()) || (owner.isCrouching() && affectedByCrouching()) ? 64 : opacity(),
|
||||
config.hasShadow(), config.isSeeThrough(), config.useDefaultBackgroundColor(),
|
||||
config.hasShadow(), config.isSeeThrough().asBoolean() && (!affectedByCrouching() || !tracker.isCrouching()), config.useDefaultBackgroundColor(),
|
||||
config.alignment(), config.viewRange(), config.shadowRadius(), config.shadowStrength(),
|
||||
(affectedByScaling() ? scale(viewer).multiply(tracker.getScale()) : scale(viewer)),
|
||||
(affectedByScaling() ? translation(viewer).multiply(tracker.getScale()) : translation(viewer)),
|
||||
@@ -77,7 +77,9 @@ 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);
|
||||
Tracker tracker = owner.getTracker(viewer);
|
||||
boolean seeThrough = config.isSeeThrough().asBoolean() && (!affectedByCrouching() || !tracker.isCrouching());
|
||||
Consumer<List<Object>> modifiers = CustomNameplates.getInstance().getPlatform().createSneakModifier(dark, seeThrough, this.config);
|
||||
Object packet = CustomNameplates.getInstance().getPlatform().updateTextDisplayPacket(entityID, List.of(modifiers));
|
||||
CustomNameplates.getInstance().getPacketSender().sendPacket(viewer, packet);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import net.momirealms.customnameplates.api.requirement.Requirement;
|
||||
import net.momirealms.customnameplates.api.util.Alignment;
|
||||
import net.momirealms.customnameplates.api.util.ConfigUtils;
|
||||
import net.momirealms.customnameplates.api.util.Vector3;
|
||||
import net.momirealms.customnameplates.common.util.Tristate;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -302,7 +303,7 @@ public class UnlimitedTagManagerImpl implements UnlimitedTagManager, PlayerListe
|
||||
.shadowStrength(section.getFloat("shadow-strength", 1f))
|
||||
.lineWidth(section.getInt("line-width", 200))
|
||||
.hasShadow(section.getBoolean("has-shadow", false))
|
||||
.seeThrough(section.getBoolean("is-see-through", false))
|
||||
.seeThrough(Tristate.fromBoolean((Boolean) section.get("is-see-through")))
|
||||
.opacity(section.getByte("opacity", (byte) -1))
|
||||
.useDefaultBackgroundColor(section.getBoolean("use-default-background-color", false))
|
||||
.backgroundColor(ConfigUtils.argb(section.getString("background-color", "64,0,0,0")))
|
||||
|
||||
@@ -22,6 +22,7 @@ unlimited:
|
||||
affected-by-spectator: true
|
||||
line-width: 1024
|
||||
background-color: 64,0,0,0
|
||||
is-see-through: false
|
||||
tag_image_part:
|
||||
text: '%np_tag-image%'
|
||||
translation: 0,0.2,0
|
||||
@@ -35,6 +36,7 @@ unlimited:
|
||||
affected-by-spectator: true
|
||||
line-width: 1024
|
||||
background-color: 0,0,0,0
|
||||
is-see-through: false
|
||||
tag_text_part:
|
||||
text: '%np_tag-text%'
|
||||
translation: 0.01,0.2,0.01
|
||||
@@ -47,4 +49,5 @@ unlimited:
|
||||
affected-by-scale-attribute: true
|
||||
affected-by-spectator: true
|
||||
line-width: 1024
|
||||
background-color: 0,0,0,0
|
||||
background-color: 0,0,0,0
|
||||
is-see-through: false
|
||||
@@ -1,6 +1,6 @@
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=3.0.34
|
||||
project_version=3.0.34.1
|
||||
config_version=38
|
||||
project_group=net.momirealms
|
||||
|
||||
@@ -47,9 +47,9 @@ lwjgl_version=3.3.6
|
||||
fastutil_version=8.5.18
|
||||
|
||||
# Proxy settings
|
||||
#systemProp.socks.proxyHost=127.0.0.1
|
||||
#systemProp.socks.proxyPort=7890
|
||||
#systemProp.http.proxyHost=127.0.0.1
|
||||
#systemProp.http.proxyPort=7890
|
||||
#systemProp.https.proxyHost=127.0.0.1
|
||||
#systemProp.https.proxyPort=7890
|
||||
systemProp.socks.proxyHost=127.0.0.1
|
||||
systemProp.socks.proxyPort=7890
|
||||
systemProp.http.proxyHost=127.0.0.1
|
||||
systemProp.http.proxyPort=7890
|
||||
systemProp.https.proxyHost=127.0.0.1
|
||||
systemProp.https.proxyPort=7890
|
||||
|
||||
@@ -639,7 +639,7 @@ public class BukkitPlatform implements Platform {
|
||||
EntityData.LineWidth.addEntityDataIfNotDefaultValue( lineWidth, values);
|
||||
EntityData.Scale.addEntityDataIfNotDefaultValue( scale.toVec3(), values);
|
||||
EntityData.Translation.addEntityDataIfNotDefaultValue( translation.toVec3(), values);
|
||||
EntityData.TextDisplayMasks.addEntityDataIfNotDefaultValue(EntityData.encodeMask(hasShadow, !isCrouching, useDefaultBackgroundColor, alignment.getId()), values);
|
||||
EntityData.TextDisplayMasks.addEntityDataIfNotDefaultValue(EntityData.encodeMask(hasShadow, isSeeThrough, useDefaultBackgroundColor, alignment.getId()), values);
|
||||
|
||||
Object setDataPacket = Reflections.constructor$ClientboundSetEntityDataPacket.newInstance(entityID, values);
|
||||
|
||||
@@ -679,10 +679,10 @@ public class BukkitPlatform implements Platform {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<List<Object>> createSneakModifier(boolean sneak, NameTagConfig config) {
|
||||
public Consumer<List<Object>> createSneakModifier(boolean sneak, boolean seeThrough, NameTagConfig config) {
|
||||
return (values) -> {
|
||||
EntityData.TextOpacity.addEntityData(sneak ? 64 : config.opacity(), values);
|
||||
EntityData.TextDisplayMasks.addEntityData(EntityData.encodeMask(config.hasShadow(), !sneak, config.useDefaultBackgroundColor(), config.alignment().getId()), values);
|
||||
EntityData.TextDisplayMasks.addEntityData(EntityData.encodeMask(config.hasShadow(), seeThrough, config.useDefaultBackgroundColor(), config.alignment().getId()), values);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user