-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev/1.21' into dev/1.21
- Loading branch information
Showing
19 changed files
with
554 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/dev/dubhe/anvilcraft/client/renderer/Line.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package dev.dubhe.anvilcraft.client.renderer; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.joml.Matrix4f; | ||
|
||
public record Line(Vec3 start, Vec3 end, float length) { | ||
|
||
public void render(PoseStack pose, VertexConsumer vertex, Vec3 camera, int color) { | ||
render(pose.last(), vertex, camera, color); | ||
} | ||
|
||
public void render(PoseStack.Pose pose, VertexConsumer vertex, Vec3 camera, int color) { | ||
float dx = (float) (this.start().x - this.end().x); | ||
float dy = (float) (this.start().y - this.end().y); | ||
float dz = (float) (this.start().z - this.end().z); | ||
vertex.addVertex( | ||
pose.pose(), | ||
(float) (this.start().x - camera.x), | ||
(float) (this.start().y - camera.y), | ||
(float) (this.start().z - camera.z) | ||
).setColor(color) | ||
.setNormal(pose, dx /= this.length(), dy /= this.length(), dz /= this.length()); | ||
vertex.addVertex( | ||
pose.pose(), | ||
(float) (this.end().x - camera.x), | ||
(float) (this.end().y - camera.y), | ||
(float) (this.end().z - camera.z) | ||
).setColor(color) | ||
.setNormal(pose, dx, dy, dz); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.