Skip to content

Commit

Permalink
Tweaked halo renderer so it ticks like clock
Browse files Browse the repository at this point in the history
  • Loading branch information
kitminty committed Nov 22, 2024
1 parent a7d0239 commit 8c67861
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# RedefinedLight
RedefinedLight

Save:
Lemniscate formula [
int sized = 1;
double xx = (sized*Math.sin(2*((livingEntity.tickCount+partialTicks)*0.05)))/(3-Math.cos(2*((livingEntity.tickCount+partialTicks)*0.05)));
double zz = (2*sized*Math.cos(((livingEntity.tickCount+partialTicks)*0.05)))/(3-Math.cos(2*((livingEntity.tickCount+partialTicks)*0.05)));
]

Todo:
1. add config to enable access to Halo Customizer
2. ~~edit icon~~
Expand Down
26 changes: 11 additions & 15 deletions src/main/java/kitminty/redefinedlight/RedefinedLight.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.blaze3d.vertex.VertexFormat;
import kitminty.redefinedlight.mixin.RenderTypeAccessor;
import net.minecraft.client.KeyMapping;
Expand Down Expand Up @@ -33,7 +32,6 @@
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import org.jetbrains.annotations.NotNull;
import org.joml.Matrix4f;
import org.joml.Quaternionf;
import org.lwjgl.glfw.GLFW;

Expand All @@ -49,7 +47,6 @@ public class RedefinedLight {
public static final String RLKEY = "key.redefinedlight.activatelight";
public static final KeyMapping RLKEYM = new KeyMapping(RLKEY, KeyConflictContext.IN_GAME, InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_O, RLCAT);
private static ShaderInstance halo;
static boolean DebugMode = false;

public RedefinedLight() {
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ClientConfig.SPEC, "redefinedlight-client-config.toml");
Expand Down Expand Up @@ -85,17 +82,16 @@ public Renderer(RenderLayerParent<T,M> renderer) {
@Override
public void render(@NotNull PoseStack poseStack, @NotNull MultiBufferSource buffer, int packedLight, T livingEntity, float limbSwing, float limbSwingAmount, float partialTicks, float age, float netHeadYaw, float headPitch) {
if(!livingEntity.isInvisible() && ClientForgeEvents.alternator && livingEntity.getName().getString().equals(Objects.requireNonNull(Minecraft.getInstance().player).getName().getString())) {
poseStack.translate(0.2, -0.65, 0);
poseStack.mulPose(RedefinedLight.rotateZ(30)); //makes halo tilted
poseStack.mulPose(RedefinedLight.rotateY(livingEntity.tickCount + partialTicks)); //turns the halo
poseStack.scale(0.75F, -0.75F, -0.75F);
VertexConsumer bufferd = buffer.getBuffer(RenderHelper.HALO);
Matrix4f mat = poseStack.last().pose();
bufferd.vertex(mat, -1F, 0, -1F).color(1.0F, 1.0F, 1.0F, 1.0F).uv(0, 0).endVertex();
bufferd.vertex(mat, 1F, 0, -1F).color(1.0F, 1.0F, 1.0F, 1.0F).uv(1, 0).endVertex();
bufferd.vertex(mat, 1F, 0, 1F).color(1.0F, 1.0F, 1.0F, 1.0F).uv(1, 1).endVertex();
bufferd.vertex(mat, -1F, 0, 1F).color(1.0F, 1.0F, 1.0F, 1.0F).uv(0, 1).endVertex();
if (DebugMode) Minecraft.getInstance().player.sendSystemMessage(Component.literal(String.valueOf(ClientConfig.ZROT.get())));
poseStack.translate(0.2, -0.65, 0); //determines halo position
//Boo - Isaac
poseStack.mulPose(RedefinedLight.rotateZ(ClientConfig.ZROT.get())); //makes halo tilted
poseStack.mulPose(RedefinedLight.rotateY((float)((Math.floor((livingEntity.tickCount+partialTicks)*0.1/2)+(((livingEntity.tickCount+partialTicks)*0.1%2<=1)?0:0.5*Math.sin(Math.PI*((livingEntity.tickCount+partialTicks)*0.1-1)-0.5*Math.PI)+0.5))*27)+((livingEntity.tickCount+partialTicks)*0.027F))); //turns the halo like a clock
poseStack.scale(0.75F, -0.75F, -0.75F); //sets halo size
buffer.getBuffer(RenderHelper.HALO).vertex(poseStack.last().pose(),-1F,0,-1F).color(1.0F,1.0F,1.0F,1.0F).uv(0,0).endVertex();
buffer.getBuffer(RenderHelper.HALO).vertex(poseStack.last().pose(),1F,0,-1F).color(1.0F,1.0F,1.0F,1.0F).uv(1,0).endVertex();
buffer.getBuffer(RenderHelper.HALO).vertex(poseStack.last().pose(),1F,0,1F).color(1.0F,1.0F,1.0F,1.0F).uv(1,1).endVertex();
buffer.getBuffer(RenderHelper.HALO).vertex(poseStack.last().pose(),-1F,0,1F).color(1.0F,1.0F,1.0F,1.0F).uv(0,1).endVertex();
//Minecraft.getInstance().player.sendSystemMessage(Component.literal(String.valueOf(ClientConfig.ZROT.get())));
}
}
}
Expand All @@ -112,7 +108,7 @@ public static class ClientConfig {
static {
BUILDER.push("Configs");

ZROT = BUILDER.comment("Rotation of Z Axis").define("ZRotation", 0);
ZROT = BUILDER.comment("Rotation of Z Axis").define("ZRotation", 30);

BUILDER.pop();
SPEC = BUILDER.build();
Expand Down

0 comments on commit 8c67861

Please sign in to comment.