Skip to content

Commit

Permalink
Fine
Browse files Browse the repository at this point in the history
  • Loading branch information
KrLite committed Jul 12, 2024
1 parent 9a02b2d commit 799ff43
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 33 deletions.
7 changes: 4 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies {

modApi(libs.cloth.config)
modApi(libs.modmenu)
modApi(libs.night.auto.config)
}

java {
Expand Down Expand Up @@ -86,15 +87,15 @@ publisher {

versionType.set("release")
projectVersion.set(project.version.toString())
gameVersions.set(listOf("1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4"))
gameVersions.set(listOf("1.21"))
loaders.set(listOf("fabric", "quilt"))
curseEnvironment.set("both")

modrinthDepends.required("fabric-api")
modrinthDepends.required("fabric-api", "night-auto-config")
modrinthDepends.optional()
modrinthDepends.embedded()

curseDepends.required("fabric-api")
curseDepends.required("fabric-api", "night-auto-config")
curseDepends.optional()
curseDepends.embedded()

Expand Down
12 changes: 7 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ archives-name = "ivespoken"
mod = "2.1.0"
loader = "fabric"

minecraft = "1.20"
yarn = "1.20+build.1"
minecraft = "1.21"
yarn = "1.21+build.9"
fabric-loader = "0.16.0"
fabric-api = "0.83.0+1.20"
fabric-api = "0.100.6+1.21"
fabric-loom = "1.6-SNAPSHOT"
modpublisher = "2.1.0"

cloth-config = "11.1.118"
modmenu = "7.0.1"
cloth-config = "15.0.127"
modmenu = "11.0.1"
night-auto-config = "1.0.3-fabric1.21"

# id
id-modrinth = "OidSa416"
Expand All @@ -31,6 +32,7 @@ fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.r

cloth-config = { group = "me.shedaniel.cloth", name = "cloth-config-fabric", version.ref = "cloth-config" }
modmenu = { group = "com.terraformersmc", name = "modmenu", version.ref = "modmenu" }
night-auto-config = { group = "com.github.KessokuTeaTime", name = "Night-Auto-Config", version.ref = "night-auto-config" }

[plugins]
fabric-loom = { id = "fabric-loom", version.ref = "fabric-loom" }
Expand Down
47 changes: 26 additions & 21 deletions src/main/java/band/kessokuteatime/ivespoken/IveSpoken.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.EntityAttachmentType;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
import org.slf4j.Logger;
Expand Down Expand Up @@ -94,36 +96,39 @@ public static long timestamp(UUID uuid) {
.setStyle(content.getStyle().withColor(Formatting.GRAY));
}

public static void renderDialog(AbstractClientPlayerEntity player, MatrixStack matrixStack, VertexConsumerProvider vertexConsumers, int light) {
public static void renderDialog(AbstractClientPlayerEntity player, MatrixStack matrixStack, VertexConsumerProvider vertexConsumers, int light, float tickDelta) {
@Nullable Text dialog = dialog(player.getUuid());
if (dialog == null) return;

boolean sneaky = !player.isSneaky();
int y = (player.getName().getString().equals("deadmau5") ? -10 : 0) - 10;
Vec3d pos = player.getAttachments().getPointNullable(EntityAttachmentType.NAME_TAG, 0, player.getYaw(tickDelta));
if (pos != null) {
int y = (player.getName().getString().equals("deadmau5") ? -10 : 0) - 10;

matrixStack.push();
matrixStack.translate(0, player.getNameLabelHeight(), 0);
matrixStack.multiply(MinecraftClient.getInstance().getEntityRenderDispatcher().getRotation());
matrixStack.scale(-0.025F, -0.025F, 0.025F);
Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
matrixStack.push();
matrixStack.translate(0, pos.getY() + 0.5, 0);
matrixStack.multiply(MinecraftClient.getInstance().getEntityRenderDispatcher().getRotation());
matrixStack.scale(-0.025F, -0.025F, 0.025F);
Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();

int backgroundColor = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F) * 255.0F) << 24;
float x = (float) -MinecraftClient.getInstance().textRenderer.getWidth(dialog) / 2;
int backgroundColor = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F) * 255.0F) << 24;
float x = (float) -MinecraftClient.getInstance().textRenderer.getWidth(dialog) / 2;

MinecraftClient.getInstance().textRenderer.draw(
dialog, x, y, 0x20FFFFFF, false, matrix4f, vertexConsumers,
sneaky ? TextRenderer.TextLayerType.SEE_THROUGH : TextRenderer.TextLayerType.NORMAL,
backgroundColor, light
);

if (sneaky) {
MinecraftClient.getInstance().textRenderer.draw(
dialog, x, y, 0xFFFFFFFF, false, matrix4f, vertexConsumers,
TextRenderer.TextLayerType.NORMAL,
0, light
dialog, x, y, 0x20FFFFFF, false, matrix4f, vertexConsumers,
sneaky ? TextRenderer.TextLayerType.SEE_THROUGH : TextRenderer.TextLayerType.NORMAL,
backgroundColor, light
);
}

matrixStack.pop();
if (sneaky) {
MinecraftClient.getInstance().textRenderer.draw(
dialog, x, y, 0xFFFFFFFF, false, matrix4f, vertexConsumers,
TextRenderer.TextLayerType.NORMAL,
0, light
);
}

matrixStack.pop();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ protected DialogRenderer(EntityRendererFactory.Context ctx) {
super(ctx);
}

@Inject(method = "renderLabelIfPresent*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V"))
private void renderDialog(AbstractClientPlayerEntity player, Text text, MatrixStack matrixStack, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
@Inject(
method = "renderLabelIfPresent*",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V"
)
)
private void renderDialog(AbstractClientPlayerEntity player, Text text, MatrixStack matrixStack, VertexConsumerProvider vertexConsumers, int light, float tickDelta, CallbackInfo ci) {
if (!IveSpoken.CONFIG.get().enabled) return;

double distance = this.dispatcher.getSquaredDistanceToCamera(player);
if (distance > 4096) return;

IveSpoken.renderDialog(player, matrixStack, vertexConsumers, light);
IveSpoken.renderDialog(player, matrixStack, vertexConsumers, light, tickDelta);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"depends": {
"fabricloader": "*",
"fabric-api": "*",
"minecraft": "1.20.x"
"minecraft": "1.21.x"
},
"suggests": {
}
Expand Down

0 comments on commit 799ff43

Please sign in to comment.