Created
December 27, 2022 19:18
-
-
Save hammy275/1ac8d6c8f801a6cb654a3f60b33ccff6 to your computer and use it in GitHub Desktop.
Render 16x16 PNG In-World [1.19.2]
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
Camera renderInfo = Minecraft.getInstance().gameRenderer.getMainCamera(); | |
stack.pushPose(); | |
Vec3 pos = Vec3.atCenterOf(new BlockPos(0, 140, 0)); // Replace with position to render at | |
stack.translate(-renderInfo.getPosition().x + pos.x, | |
-renderInfo.getPosition().y + pos.y, | |
-renderInfo.getPosition().z + pos.z); | |
stack.mulPose(Minecraft.getInstance().getEntityRenderDispatcher().cameraOrientation()); | |
stack.mulPose(Vector3f.YP.rotationDegrees(180)); | |
// Should be held in a field somewhere instead of creating every render | |
// Replace with a path to whatever texture you want to render | |
ResourceLocation speedLoc = new ResourceLocation("textures/mob_effect/speed.png"); | |
VertexConsumer vertexConsumer = | |
Minecraft.getInstance().renderBuffers().bufferSource().getBuffer(RenderType.entityCutoutNoCull(speedLoc)); | |
PoseStack.Pose pose = stack.last(); | |
Matrix4f matrix4f = pose.pose(); | |
Matrix3f matrix3f = pose.normal(); | |
int maxLight = LightTexture.pack(15, 15); | |
// DragonFireballRendererMixin should be a mixin that exposes the `vertex` method | |
DragonFireballRendererMixin.vertex(vertexConsumer, matrix4f, matrix3f, maxLight, 0f, 0, 0, 1); | |
DragonFireballRendererMixin.vertex(vertexConsumer, matrix4f, matrix3f, maxLight, 1f, 0, 1, 1); | |
DragonFireballRendererMixin.vertex(vertexConsumer, matrix4f, matrix3f, maxLight, 1f, 1, 1, 0); | |
DragonFireballRendererMixin.vertex(vertexConsumer, matrix4f, matrix3f, maxLight, 0f, 1, 0, 0); | |
stack.popPose(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As one would imagine, this is heavily based on DragonFireballRenderer