nametags fullbright and health display with keystrokes
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
package org.saturnclient.modules.interfaces;
|
||||||
|
|
||||||
|
public interface HealthDisplayInterface {
|
||||||
|
|
||||||
|
float getPlayerHealth();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package org.saturnclient.modules.interfaces;
|
||||||
|
|
||||||
|
public interface KeystrokesInterface {
|
||||||
|
|
||||||
|
boolean isForwardPressed();
|
||||||
|
boolean isBackPressed();
|
||||||
|
boolean isLeftPressed();
|
||||||
|
boolean isRightPressed();
|
||||||
|
boolean isJumpPressed();
|
||||||
|
boolean isAttackPressed();
|
||||||
|
boolean isUsePressed();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package org.saturnclient.modules.interfaces;
|
||||||
|
|
||||||
|
public interface NametagsInterface {
|
||||||
|
|
||||||
|
public static interface EntityState {
|
||||||
|
|
||||||
|
String getCustomName();
|
||||||
|
|
||||||
|
float getHealth();
|
||||||
|
|
||||||
|
float getMaxHealth();
|
||||||
|
|
||||||
|
EntityType getEntityType();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EntityType {
|
||||||
|
PLAYER,
|
||||||
|
PASSIVE,
|
||||||
|
HOSTILE,
|
||||||
|
OTHER
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+25
-12
@@ -4,23 +4,22 @@ import org.saturnclient.modules.HudMod;
|
|||||||
import org.saturnclient.modules.ModDimensions;
|
import org.saturnclient.modules.ModDimensions;
|
||||||
import org.saturnclient.modules.Module;
|
import org.saturnclient.modules.Module;
|
||||||
import org.saturnclient.modules.ModuleDetails;
|
import org.saturnclient.modules.ModuleDetails;
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.modules.interfaces.HealthDisplayInterface;
|
||||||
import org.saturnclient.config.manager.Property;
|
import org.saturnclient.config.manager.Property;
|
||||||
import org.saturnclient.ui.RenderScope;
|
import org.saturnclient.ui.RenderScope;
|
||||||
import org.saturnclient.ui.resources.Fonts;
|
import org.saturnclient.ui.resources.Fonts;
|
||||||
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
|
|
||||||
public class HealthDisplay extends Module implements HudMod {
|
public class HealthDisplay extends Module implements HudMod {
|
||||||
|
|
||||||
private static Property<Boolean> enabled = Property.bool(false);
|
private static Property<Boolean> enabled = Property.bool(false);
|
||||||
private static Property<Integer> displayMode = Property.select(0, "Health", "Hearts");
|
private static Property<Integer> displayMode = Property.select(0, "Health", "Hearts");
|
||||||
private static Property<Integer> decimals = Property.select(0, "0", "1", "2");
|
private static Property<Integer> decimals = Property.select(0, "0", "1", "2");
|
||||||
private static ModDimensions dimensions = new ModDimensions(40, 18);
|
|
||||||
double speed = 0.;
|
|
||||||
Vec3d velocity;
|
|
||||||
double y = 0.;
|
|
||||||
|
|
||||||
public HealthDisplay() {
|
private static ModDimensions dimensions = new ModDimensions(40, 18);
|
||||||
|
|
||||||
|
private final HealthDisplayInterface minecraft;
|
||||||
|
|
||||||
|
public HealthDisplay(HealthDisplayInterface minecraft) {
|
||||||
super(new ModuleDetails("Health display", "health")
|
super(new ModuleDetails("Health display", "health")
|
||||||
.description("Displays your current health")
|
.description("Displays your current health")
|
||||||
.version("v0.1.0")
|
.version("v0.1.0")
|
||||||
@@ -29,6 +28,8 @@ public class HealthDisplay extends Module implements HudMod {
|
|||||||
displayMode.named("Display mode"),
|
displayMode.named("Display mode"),
|
||||||
decimals.named("Decimals"),
|
decimals.named("Decimals"),
|
||||||
dimensions.prop());
|
dimensions.prop());
|
||||||
|
|
||||||
|
this.minecraft = minecraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,31 +39,43 @@ public class HealthDisplay extends Module implements HudMod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderHud(RenderScope scope) {
|
public void renderHud(RenderScope scope) {
|
||||||
float health = SaturnClient.client.player.getHealth();
|
float health = minecraft.getPlayerHealth();
|
||||||
|
|
||||||
switch (displayMode.value) {
|
switch (displayMode.value) {
|
||||||
case 1:
|
case 1:
|
||||||
health = health / 2;
|
health = health / 2;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderHealth(health, scope);
|
renderHealth(health, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderHealth(float health, RenderScope scope) {
|
public void renderHealth(float health, RenderScope scope) {
|
||||||
|
|
||||||
String text = "";
|
String text = "";
|
||||||
|
|
||||||
switch (decimals.value) {
|
switch (decimals.value) {
|
||||||
case 0:
|
case 0:
|
||||||
text = String.format("%.0f ", health);
|
text = String.format("%.0f ", health);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
text = String.format("%.1f ", health);
|
text = String.format("%.1f ", health);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
text = String.format("%.2f ", health);
|
text = String.format("%.2f ", health);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.drawText(text,
|
scope.drawText(
|
||||||
0, 0, dimensions.font.value, dimensions.fgColor.value);
|
text,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
dimensions.font.value,
|
||||||
|
dimensions.fgColor.value
|
||||||
|
);
|
||||||
|
|
||||||
dimensions.width = Fonts.getWidth(text, dimensions.font.value);
|
dimensions.width = Fonts.getWidth(text, dimensions.font.value);
|
||||||
dimensions.height = 18 * text.split("\n").length;
|
dimensions.height = 18 * text.split("\n").length;
|
||||||
}
|
}
|
||||||
@@ -81,4 +94,4 @@ public class HealthDisplay extends Module implements HudMod {
|
|||||||
public void onEnabled(boolean e) {
|
public void onEnabled(boolean e) {
|
||||||
enabled.value = e;
|
enabled.value = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+14
-10
@@ -3,10 +3,10 @@ package org.saturnclient.modules.mods;
|
|||||||
import org.saturnclient.modules.Module;
|
import org.saturnclient.modules.Module;
|
||||||
import org.saturnclient.modules.HudMod;
|
import org.saturnclient.modules.HudMod;
|
||||||
import org.saturnclient.modules.ModDimensions;
|
import org.saturnclient.modules.ModDimensions;
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.modules.ModuleDetails;
|
||||||
|
import org.saturnclient.modules.interfaces.KeystrokesInterface;
|
||||||
import org.saturnclient.config.manager.Property;
|
import org.saturnclient.config.manager.Property;
|
||||||
import org.saturnclient.ui.RenderScope;
|
import org.saturnclient.ui.RenderScope;
|
||||||
import org.saturnclient.modules.ModuleDetails;
|
|
||||||
|
|
||||||
public class Keystrokes extends Module implements HudMod {
|
public class Keystrokes extends Module implements HudMod {
|
||||||
|
|
||||||
@@ -19,6 +19,8 @@ public class Keystrokes extends Module implements HudMod {
|
|||||||
|
|
||||||
private static final ModDimensions dimensions = new ModDimensions(78, 54);
|
private static final ModDimensions dimensions = new ModDimensions(78, 54);
|
||||||
|
|
||||||
|
private final KeystrokesInterface minecraft;
|
||||||
|
|
||||||
// Key states
|
// Key states
|
||||||
private boolean w, a, s, d, lmb, rmb, space;
|
private boolean w, a, s, d, lmb, rmb, space;
|
||||||
|
|
||||||
@@ -29,7 +31,7 @@ public class Keystrokes extends Module implements HudMod {
|
|||||||
private static final int MOUSE_HEIGHT = 24;
|
private static final int MOUSE_HEIGHT = 24;
|
||||||
private static final int SPACE_HEIGHT = 19;
|
private static final int SPACE_HEIGHT = 19;
|
||||||
|
|
||||||
public Keystrokes() {
|
public Keystrokes(KeystrokesInterface minecraft) {
|
||||||
super(new ModuleDetails("Keystrokes", "keystrokes")
|
super(new ModuleDetails("Keystrokes", "keystrokes")
|
||||||
.description("Displays movement keystrokes")
|
.description("Displays movement keystrokes")
|
||||||
.version("v0.2.0")
|
.version("v0.2.0")
|
||||||
@@ -42,18 +44,20 @@ public class Keystrokes extends Module implements HudMod {
|
|||||||
clickFg.named("Clicked fg"),
|
clickFg.named("Clicked fg"),
|
||||||
clickBg.named("Clicked bg"));
|
clickBg.named("Clicked bg"));
|
||||||
|
|
||||||
|
this.minecraft = minecraft;
|
||||||
|
|
||||||
dimensions.renderBackground = false;
|
dimensions.renderBackground = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
w = SaturnClient.client.options.forwardKey.isPressed();
|
w = minecraft.isForwardPressed();
|
||||||
a = SaturnClient.client.options.leftKey.isPressed();
|
a = minecraft.isLeftPressed();
|
||||||
s = SaturnClient.client.options.backKey.isPressed();
|
s = minecraft.isBackPressed();
|
||||||
d = SaturnClient.client.options.rightKey.isPressed();
|
d = minecraft.isRightPressed();
|
||||||
lmb = SaturnClient.client.options.attackKey.isPressed();
|
lmb = minecraft.isAttackPressed();
|
||||||
rmb = SaturnClient.client.options.useKey.isPressed();
|
rmb = minecraft.isUsePressed();
|
||||||
space = SaturnClient.client.options.jumpKey.isPressed();
|
space = minecraft.isJumpPressed();
|
||||||
|
|
||||||
updateHeight();
|
updateHeight();
|
||||||
}
|
}
|
||||||
+32
-63
@@ -2,14 +2,11 @@ package org.saturnclient.modules.mods;
|
|||||||
|
|
||||||
import org.saturnclient.modules.Module;
|
import org.saturnclient.modules.Module;
|
||||||
import org.saturnclient.modules.ModuleDetails;
|
import org.saturnclient.modules.ModuleDetails;
|
||||||
import org.saturnclient.modules.mods.utils.HealthRenderState;
|
|
||||||
import org.saturnclient.config.manager.Property;
|
import org.saturnclient.config.manager.Property;
|
||||||
|
import org.saturnclient.modules.interfaces.NametagsInterface;
|
||||||
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
|
||||||
|
|
||||||
// todo: rendering modes, custom names
|
|
||||||
|
|
||||||
public class Nametags extends Module {
|
public class Nametags extends Module {
|
||||||
|
|
||||||
private static Property<Boolean> enabled = Property.bool(false);
|
private static Property<Boolean> enabled = Property.bool(false);
|
||||||
private static Property<Boolean> healthDisplay = Property.bool(false);
|
private static Property<Boolean> healthDisplay = Property.bool(false);
|
||||||
private static Property<Boolean> players = Property.bool(true);
|
private static Property<Boolean> players = Property.bool(true);
|
||||||
@@ -20,51 +17,24 @@ public class Nametags extends Module {
|
|||||||
private static Property<Integer> unit = Property.select(0, "Health", "Hearts");
|
private static Property<Integer> unit = Property.select(0, "Health", "Hearts");
|
||||||
private static Property<Integer> format = Property.select(0, "Value", "Value / Total", "%");
|
private static Property<Integer> format = Property.select(0, "Value", "Value / Total", "%");
|
||||||
private static Property<Integer> nameColor = Property.select(15,
|
private static Property<Integer> nameColor = Property.select(15,
|
||||||
"Black",
|
"Black","Dark Blue","Dark Green","Dark Aqua","Dark Red","Dark Purple","Gold","Gray",
|
||||||
"Dark Blue",
|
"Dark Gray","Blue","Green","Aqua","Red","Light Purple","Yellow","White");
|
||||||
"Dark Green",
|
|
||||||
"Dark Aqua",
|
|
||||||
"Dark Red",
|
|
||||||
"Dark Purple",
|
|
||||||
"Gold",
|
|
||||||
"Gray",
|
|
||||||
"Dark Gray",
|
|
||||||
"Blue",
|
|
||||||
"Green",
|
|
||||||
"Aqua",
|
|
||||||
"Red",
|
|
||||||
"Light Purple",
|
|
||||||
"Yellow",
|
|
||||||
"White");
|
|
||||||
private static Property<Integer> healthColor = Property.select(12,
|
private static Property<Integer> healthColor = Property.select(12,
|
||||||
"Black",
|
"Black","Dark Blue","Dark Green","Dark Aqua","Dark Red","Dark Purple","Gold","Gray",
|
||||||
"Dark Blue",
|
"Dark Gray","Blue","Green","Aqua","Red","Light Purple","Yellow","White");
|
||||||
"Dark Green",
|
|
||||||
"Dark Aqua",
|
|
||||||
"Dark Red",
|
|
||||||
"Dark Purple",
|
|
||||||
"Gold",
|
|
||||||
"Gray",
|
|
||||||
"Dark Gray",
|
|
||||||
"Blue",
|
|
||||||
"Green",
|
|
||||||
"Aqua",
|
|
||||||
"Red",
|
|
||||||
"Light Purple",
|
|
||||||
"Yellow",
|
|
||||||
"White");
|
|
||||||
|
|
||||||
private static final String[] COLOR_CODES = {
|
private static final String[] COLOR_CODES = {
|
||||||
"§0", "§1", "§2", "§3", "§4", "§5", "§6", "§7",
|
"§0", "§1", "§2", "§3", "§4", "§5", "§6", "§7",
|
||||||
"§8", "§9", "§a", "§b", "§c", "§d", "§e", "§f"
|
"§8", "§9", "§a", "§b", "§c", "§d", "§e", "§f"
|
||||||
};
|
};
|
||||||
|
|
||||||
public Nametags() {
|
private final NametagsInterface minecraft;
|
||||||
super(
|
|
||||||
new ModuleDetails("Nametags", "nametags")
|
public Nametags(NametagsInterface minecraft) {
|
||||||
.description("Allows you to modify entity nametags")
|
super(new ModuleDetails("Nametags", "nametags")
|
||||||
.tags("Camera", "Utility")
|
.description("Allows you to modify entity nametags")
|
||||||
.version("0.1.0"),
|
.tags("Camera", "Utility")
|
||||||
|
.version("0.1.0"),
|
||||||
enabled.named("Enabled"),
|
enabled.named("Enabled"),
|
||||||
healthDisplay.named("Display health"),
|
healthDisplay.named("Display health"),
|
||||||
players.named("Players"),
|
players.named("Players"),
|
||||||
@@ -76,15 +46,16 @@ public class Nametags extends Module {
|
|||||||
format.named("Format"),
|
format.named("Format"),
|
||||||
nameColor.named("Name color"),
|
nameColor.named("Name color"),
|
||||||
healthColor.named("Health color"));
|
healthColor.named("Health color"));
|
||||||
|
|
||||||
|
this.minecraft = minecraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
|
// Currently unused
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getHealthString(LivingEntityRenderState state, HealthRenderState hrs, float health,
|
public static String getHealthString(NametagsInterface.EntityState state, float health, float maxHealth) {
|
||||||
float maxHealth) {
|
|
||||||
String ret = "";
|
String ret = "";
|
||||||
|
|
||||||
switch (format.value) {
|
switch (format.value) {
|
||||||
@@ -101,28 +72,28 @@ public class Nametags extends Module {
|
|||||||
ret = String.format("%.0f%%", (health / maxHealth) * 100);
|
ret = String.format("%.0f%%", (health / maxHealth) * 100);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getNametagString(LivingEntityRenderState state) {
|
public static String getNametagString(NametagsInterface.EntityState state) {
|
||||||
if (state.customName == null)
|
if (state.getCustomName() == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (!healthDisplay.value)
|
if (!healthDisplay.value)
|
||||||
return state.customName.getString(); // name only
|
return state.getCustomName(); // name only
|
||||||
if (!(state instanceof HealthRenderState hrs))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
float health = hrs.saturn$getHealth();
|
float health = state.getHealth();
|
||||||
float maxHealth = hrs.saturn$getMaxHealth();
|
float maxHealth = state.getMaxHealth();
|
||||||
|
NametagsInterface.EntityType type = state.getEntityType();
|
||||||
|
|
||||||
HealthRenderState.EntityType type = hrs.saturn$getEntityType();
|
if (type == NametagsInterface.EntityType.PASSIVE && !passive.value)
|
||||||
if (type == HealthRenderState.EntityType.PASSIVE && !passive.value)
|
|
||||||
return null;
|
return null;
|
||||||
if (type == HealthRenderState.EntityType.HOSTILE && !hostile.value)
|
if (type == NametagsInterface.EntityType.HOSTILE && !hostile.value)
|
||||||
return null;
|
return null;
|
||||||
if (type == HealthRenderState.EntityType.PLAYER && !players.value)
|
if (type == NametagsInterface.EntityType.PLAYER && !players.value)
|
||||||
return null;
|
return null;
|
||||||
if (type == HealthRenderState.EntityType.OTHER)
|
if (type == NametagsInterface.EntityType.OTHER)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (health < 0f || maxHealth < 0f || health > maxHealth)
|
if (health < 0f || maxHealth < 0f || health > maxHealth)
|
||||||
@@ -134,10 +105,8 @@ public class Nametags extends Module {
|
|||||||
String obf = obfuscate.value ? "§k" : "";
|
String obf = obfuscate.value ? "§k" : "";
|
||||||
String reset = "§r";
|
String reset = "§r";
|
||||||
|
|
||||||
String ret = color + obf + state.customName.getString() + reset + " " + hpColor
|
return color + obf + state.getCustomName() + reset + " " + hpColor
|
||||||
+ getHealthString(state, hrs, health, maxHealth) + heart;
|
+ getHealthString(state, health, maxHealth) + heart;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldReplaceName() {
|
public static boolean shouldReplaceName() {
|
||||||
@@ -153,4 +122,4 @@ public class Nametags extends Module {
|
|||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled.value;
|
return enabled.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,8 @@ public class FabricModuleProvider implements ModuleProvider {
|
|||||||
new DayCounter(new DayCounterFabric()),
|
new DayCounter(new DayCounterFabric()),
|
||||||
new Fps(new FpsFabric()),
|
new Fps(new FpsFabric()),
|
||||||
new Freelook(new FreelookFabric()),
|
new Freelook(new FreelookFabric()),
|
||||||
|
new HealthDisplay(new HealthDisplayFabric()),
|
||||||
|
new Keystrokes(new KeystrokesFabric()),
|
||||||
new Clock(),
|
new Clock(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package org.saturnclient.impl.modules;
|
||||||
|
|
||||||
|
import org.saturnclient.modules.interfaces.HealthDisplayInterface;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
|
||||||
|
public class HealthDisplayFabric implements HealthDisplayInterface {
|
||||||
|
|
||||||
|
private final MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getPlayerHealth() {
|
||||||
|
if (mc.player == null) {
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mc.player.getHealth();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package org.saturnclient.impl.modules;
|
||||||
|
|
||||||
|
import org.saturnclient.modules.interfaces.KeystrokesInterface;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
|
||||||
|
public class KeystrokesFabric implements KeystrokesInterface {
|
||||||
|
|
||||||
|
private final MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isForwardPressed() {
|
||||||
|
return mc.options.forwardKey.isPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBackPressed() {
|
||||||
|
return mc.options.backKey.isPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLeftPressed() {
|
||||||
|
return mc.options.leftKey.isPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRightPressed() {
|
||||||
|
return mc.options.rightKey.isPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isJumpPressed() {
|
||||||
|
return mc.options.jumpKey.isPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAttackPressed() {
|
||||||
|
return mc.options.attackKey.isPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUsePressed() {
|
||||||
|
return mc.options.useKey.isPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package org.saturnclient.impl.modules;
|
||||||
|
|
||||||
|
import org.saturnclient.modules.interfaces.NametagsInterface;
|
||||||
|
import org.saturnclient.modules.mods.utils.HealthRenderState;
|
||||||
|
|
||||||
|
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
public class NametagsFabric implements NametagsInterface {
|
||||||
|
|
||||||
|
public static class EntityStateImpl implements EntityState {
|
||||||
|
|
||||||
|
private final LivingEntityRenderState state;
|
||||||
|
|
||||||
|
public EntityStateImpl(LivingEntityRenderState state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCustomName() {
|
||||||
|
Text name = state.customName;
|
||||||
|
return name != null ? name.getString() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getHealth() {
|
||||||
|
if (!(state instanceof HealthRenderState hrs))
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
|
return hrs.saturn$getHealth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getMaxHealth() {
|
||||||
|
if (!(state instanceof HealthRenderState hrs))
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
|
return hrs.saturn$getMaxHealth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityType getEntityType() {
|
||||||
|
if (!(state instanceof HealthRenderState hrs))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return hrs.saturn$getEntityType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-4
@@ -2,7 +2,7 @@ package org.saturnclient.modules.mods.mixins;
|
|||||||
|
|
||||||
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||||
|
|
||||||
import org.saturnclient.modules.mods.utils.HealthRenderState;
|
import org.saturnclient.modules.interfaces.NametagsInterface.EntityType;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ public class LivingEntityRenderStateMixin implements org.saturnclient.modules.mo
|
|||||||
|
|
||||||
@Unique private float saturn$health = 0f;
|
@Unique private float saturn$health = 0f;
|
||||||
@Unique private float saturn$maxHealth = 1f;
|
@Unique private float saturn$maxHealth = 1f;
|
||||||
@Unique private HealthRenderState.EntityType saturn$entityType = HealthRenderState.EntityType.OTHER;
|
@Unique private EntityType saturn$entityType = EntityType.OTHER;
|
||||||
|
|
||||||
public float saturn$getHealth() { return saturn$health; }
|
public float saturn$getHealth() { return saturn$health; }
|
||||||
public float saturn$getMaxHealth() { return saturn$maxHealth; }
|
public float saturn$getMaxHealth() { return saturn$maxHealth; }
|
||||||
@@ -20,7 +20,7 @@ public class LivingEntityRenderStateMixin implements org.saturnclient.modules.mo
|
|||||||
this.saturn$maxHealth = maxHealth;
|
this.saturn$maxHealth = maxHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HealthRenderState.EntityType saturn$getEntityType() { return saturn$entityType; }
|
public EntityType saturn$getEntityType() { return saturn$entityType; }
|
||||||
public void saturn$setEntityType(HealthRenderState.EntityType type) { this.saturn$entityType = type; }
|
public void saturn$setEntityType(EntityType type) { this.saturn$entityType = type; }
|
||||||
|
|
||||||
}
|
}
|
||||||
+8
-5
@@ -2,6 +2,8 @@ package org.saturnclient.modules.mods.mixins;
|
|||||||
|
|
||||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||||
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||||
|
|
||||||
|
import org.saturnclient.modules.interfaces.NametagsInterface.EntityType;
|
||||||
import org.saturnclient.modules.mods.utils.HealthRenderState;
|
import org.saturnclient.modules.mods.utils.HealthRenderState;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.mob.HostileEntity;
|
import net.minecraft.entity.mob.HostileEntity;
|
||||||
@@ -17,18 +19,19 @@ public abstract class LivingEntityRendererMixin<T extends LivingEntity, S extend
|
|||||||
|
|
||||||
@Inject(method = "updateRenderState", at = @At("TAIL"))
|
@Inject(method = "updateRenderState", at = @At("TAIL"))
|
||||||
private void saturn$captureHealth(T entity, S state, float tickDelta, CallbackInfo ci) {
|
private void saturn$captureHealth(T entity, S state, float tickDelta, CallbackInfo ci) {
|
||||||
if (!(state instanceof HealthRenderState hrs)) return;
|
if (!(state instanceof HealthRenderState hrs))
|
||||||
|
return;
|
||||||
|
|
||||||
hrs.saturn$setHealth(entity.getHealth(), entity.getMaxHealth());
|
hrs.saturn$setHealth(entity.getHealth(), entity.getMaxHealth());
|
||||||
|
|
||||||
if (entity instanceof PlayerEntity) {
|
if (entity instanceof PlayerEntity) {
|
||||||
hrs.saturn$setEntityType(HealthRenderState.EntityType.PLAYER);
|
hrs.saturn$setEntityType(EntityType.PLAYER);
|
||||||
} else if (entity instanceof HostileEntity) {
|
} else if (entity instanceof HostileEntity) {
|
||||||
hrs.saturn$setEntityType(HealthRenderState.EntityType.HOSTILE);
|
hrs.saturn$setEntityType(EntityType.HOSTILE);
|
||||||
} else if (entity instanceof PassiveEntity) {
|
} else if (entity instanceof PassiveEntity) {
|
||||||
hrs.saturn$setEntityType(HealthRenderState.EntityType.PASSIVE);
|
hrs.saturn$setEntityType(EntityType.PASSIVE);
|
||||||
} else {
|
} else {
|
||||||
hrs.saturn$setEntityType(HealthRenderState.EntityType.OTHER);
|
hrs.saturn$setEntityType(EntityType.OTHER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -6,6 +6,8 @@ import net.minecraft.client.render.entity.state.EntityRenderState;
|
|||||||
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
import org.saturnclient.impl.modules.NametagsFabric;
|
||||||
import org.saturnclient.modules.mods.Nametags;
|
import org.saturnclient.modules.mods.Nametags;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -34,7 +36,7 @@ public abstract class NametagsMixin {
|
|||||||
if (!Nametags.shouldReplaceName()) return;
|
if (!Nametags.shouldReplaceName()) return;
|
||||||
if (!(state instanceof LivingEntityRenderState living)) return;
|
if (!(state instanceof LivingEntityRenderState living)) return;
|
||||||
|
|
||||||
String replacement = Nametags.getNametagString(living);
|
String replacement = Nametags.getNametagString(new NametagsFabric.EntityStateImpl(living));
|
||||||
if (replacement == null) return;
|
if (replacement == null) return;
|
||||||
|
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
|
|||||||
+5
-4
@@ -1,14 +1,15 @@
|
|||||||
package org.saturnclient.modules.mods.utils;
|
package org.saturnclient.modules.mods.utils;
|
||||||
|
|
||||||
|
import org.saturnclient.modules.interfaces.NametagsInterface.EntityType;
|
||||||
|
|
||||||
public interface HealthRenderState {
|
public interface HealthRenderState {
|
||||||
float saturn$getHealth();
|
float saturn$getHealth();
|
||||||
|
|
||||||
float saturn$getMaxHealth();
|
float saturn$getMaxHealth();
|
||||||
|
|
||||||
void saturn$setHealth(float health, float maxHealth);
|
void saturn$setHealth(float health, float maxHealth);
|
||||||
|
|
||||||
EntityType saturn$getEntityType();
|
EntityType saturn$getEntityType();
|
||||||
void saturn$setEntityType(EntityType type);
|
|
||||||
|
|
||||||
enum EntityType {
|
void saturn$setEntityType(EntityType type);
|
||||||
PLAYER, HOSTILE, PASSIVE, OTHER
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user