-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78266c5
commit 886c692
Showing
4 changed files
with
7 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,16 @@ | ||
package miyucomics.hexical.entities | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem | ||
import miyucomics.hexical.utils.RenderUtils | ||
import net.minecraft.client.MinecraftClient | ||
import net.minecraft.client.render.Frustum | ||
import net.minecraft.client.render.GameRenderer | ||
import net.minecraft.client.render.VertexConsumerProvider | ||
import net.minecraft.client.render.entity.EntityRenderer | ||
import net.minecraft.client.render.entity.EntityRendererFactory | ||
import net.minecraft.client.util.math.MatrixStack | ||
import net.minecraft.util.Identifier | ||
import net.minecraft.util.math.Vec3f | ||
|
||
class MeshRenderer(ctx: EntityRendererFactory.Context) : EntityRenderer<MeshEntity>(ctx) { | ||
override fun getTexture(entity: MeshEntity?): Identifier? = null | ||
override fun shouldRender(entity: MeshEntity?, frustum: Frustum?, x: Double, y: Double, z: Double) = true | ||
override fun render(entity: MeshEntity?, yaw: Float, tickDelta: Float, matrices: MatrixStack, vertexConsumers: VertexConsumerProvider, light: Int) { | ||
val oldShader = RenderSystem.getShader() | ||
RenderSystem.setShader(GameRenderer::getPositionColorShader) | ||
RenderSystem.enableDepthTest() | ||
matrices.push() | ||
|
||
val pos = MinecraftClient.getInstance().player!!.pos | ||
if (entity!!.yaw != 0.0f) | ||
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-entity.yaw)) | ||
if (entity.pitch != 0.0f) | ||
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(entity.pitch)) | ||
if (entity.clientRoll != 0.0f) | ||
matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(entity.clientRoll)) | ||
matrices.scale(entity!!.clientSize, entity.clientSize, entity.clientSize) | ||
matrices.translate(entity.x - pos.x, entity.y - pos.y, entity.z - pos.z) | ||
|
||
RenderSystem.disableCull() | ||
RenderUtils.sentinelLike(matrices, entity.clientVertices, 5f, entity.clientPigment) | ||
RenderSystem.enableCull() | ||
|
||
matrices.pop() | ||
RenderSystem.setShader { oldShader } | ||
} | ||
} |
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