修复vertex传参问题
This commit is contained in:
parent
eae5b4f69c
commit
41f09641b0
3 changed files with 51 additions and 45 deletions
|
@ -9,6 +9,7 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||||
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -72,13 +73,13 @@ public abstract class AbstractLaserEntityRenderer<T extends AbstractLaserEntity>
|
||||||
float maxU = minU + 16F / TEXTURE_WIDTH;
|
float maxU = minU + 16F / TEXTURE_WIDTH;
|
||||||
float maxV = minV + 16F / TEXTURE_HEIGHT;
|
float maxV = minV + 16F / TEXTURE_HEIGHT;
|
||||||
float SIZE = this.quadRadius + (inGround ? 0.2F : 0);
|
float SIZE = this.quadRadius + (inGround ? 0.2F : 0);
|
||||||
PoseStack.Pose matrix$stack$entry = matrixStackIn.last();
|
PoseStack.Pose pose = matrixStackIn.last();
|
||||||
Matrix4f matrix4f = matrix$stack$entry.pose();
|
Matrix4f matrix4f = pose.pose();
|
||||||
Matrix3f matrix3f = matrix$stack$entry.normal();
|
Matrix3f matrix3f = pose.normal();
|
||||||
drawVertex(matrix4f, matrix3f, builder, -SIZE, -SIZE, 0, minU, minV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, -SIZE, -SIZE, 0, minU, minV, packedLightIn);
|
||||||
drawVertex(matrix4f, matrix3f, builder, -SIZE, SIZE, 0, minU, maxV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, -SIZE, SIZE, 0, minU, maxV, packedLightIn);
|
||||||
drawVertex(matrix4f, matrix3f, builder, SIZE, SIZE, 0, maxU, maxV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, SIZE, SIZE, 0, maxU, maxV, packedLightIn);
|
||||||
drawVertex(matrix4f, matrix3f, builder, SIZE, -SIZE, 0, maxU, minV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, SIZE, -SIZE, 0, maxU, minV, packedLightIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderStart(T entity, int frame, PoseStack matrixStackIn, VertexConsumer builder, float delta, int packedLightIn) {
|
protected void renderStart(T entity, int frame, PoseStack matrixStackIn, VertexConsumer builder, float delta, int packedLightIn) {
|
||||||
|
@ -144,22 +145,22 @@ public abstract class AbstractLaserEntityRenderer<T extends AbstractLaserEntity>
|
||||||
float minV = 16 / TEXTURE_HEIGHT + 1 / TEXTURE_HEIGHT * frame;
|
float minV = 16 / TEXTURE_HEIGHT + 1 / TEXTURE_HEIGHT * frame;
|
||||||
float maxU = minU + 20 / TEXTURE_WIDTH;
|
float maxU = minU + 20 / TEXTURE_WIDTH;
|
||||||
float maxV = minV + 1 / TEXTURE_HEIGHT;
|
float maxV = minV + 1 / TEXTURE_HEIGHT;
|
||||||
PoseStack.Pose matrix$stack$entry = matrixStackIn.last();
|
PoseStack.Pose pose = matrixStackIn.last();
|
||||||
Matrix4f matrix4f = matrix$stack$entry.pose();
|
Matrix4f matrix4f = pose.pose();
|
||||||
Matrix3f matrix3f = matrix$stack$entry.normal();
|
Matrix3f matrix3f = pose.normal();
|
||||||
float offset = 0;
|
float offset = 0;
|
||||||
float size = this.beamRadius;
|
float size = this.beamRadius;
|
||||||
drawVertex(matrix4f, matrix3f, builder, -size, offset, 0, minU, minV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, -size, offset, 0, minU, minV, packedLightIn);
|
||||||
drawVertex(matrix4f, matrix3f, builder, -size, length, 0, minU, maxV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, -size, length, 0, minU, maxV, packedLightIn);
|
||||||
drawVertex(matrix4f, matrix3f, builder, size, length, 0, maxU, maxV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, size, length, 0, maxU, maxV, packedLightIn);
|
||||||
drawVertex(matrix4f, matrix3f, builder, size, offset, 0, maxU, minV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, size, offset, 0, maxU, minV, packedLightIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawVertex(Matrix4f matrix, Matrix3f normals, VertexConsumer vertexBuilder, float offsetX, float offsetY, float offsetZ, float textureX, float textureY, int packedLightIn) {
|
protected void drawVertex(Matrix4f matrix, Matrix3f normals, PoseStack.Pose pose, VertexConsumer vertexBuilder, float offsetX, float offsetY, float offsetZ, float textureX, float textureY, int packedLightIn) {
|
||||||
// TODO drawVertex
|
vertexBuilder.addVertex(matrix, offsetX, offsetY, offsetZ)
|
||||||
// vertexBuilder.addVertex(matrix, offsetX, offsetY, offsetZ).setColor(1F, 1F, 1F, 1F).setUv(textureX, textureY).setOverlay(OverlayTexture.NO_OVERLAY).setLight(packedLightIn)
|
.setColor(1F, 1F, 1F, 1F).setUv(textureX, textureY)
|
||||||
// .setNormal(normals, 0.0F, 1.0F, 0.0F)
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(packedLightIn)
|
||||||
// .endVertex();
|
.setNormal(pose, 0.0F, 1.0F, 0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||||
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
@ -30,28 +31,32 @@ public class FlareDecoyEntityRenderer extends EntityRenderer<FlareDecoyEntity> {
|
||||||
pMatrixStack.scale(1.0F, 1.0F, 1.0F);
|
pMatrixStack.scale(1.0F, 1.0F, 1.0F);
|
||||||
pMatrixStack.mulPose(this.entityRenderDispatcher.cameraOrientation());
|
pMatrixStack.mulPose(this.entityRenderDispatcher.cameraOrientation());
|
||||||
pMatrixStack.mulPose(Axis.YP.rotationDegrees(180.0F));
|
pMatrixStack.mulPose(Axis.YP.rotationDegrees(180.0F));
|
||||||
PoseStack.Pose $$6 = pMatrixStack.last();
|
PoseStack.Pose pose = pMatrixStack.last();
|
||||||
Matrix4f $$7 = $$6.pose();
|
Matrix4f matrix = pose.pose();
|
||||||
Matrix3f $$8 = $$6.normal();
|
Matrix3f normal = pose.normal();
|
||||||
VertexConsumer $$9 = pBuffer.getBuffer(RenderType.entityCutoutNoCull(texture(pEntity)));
|
VertexConsumer consumer = pBuffer.getBuffer(RenderType.entityCutoutNoCull(texture(pEntity)));
|
||||||
vertex($$9, $$7, $$8, pPackedLight, 0.0F, 0, 0, 1);
|
vertex(consumer, matrix, pose, normal, pPackedLight, 0.0F, 0, 0, 1);
|
||||||
vertex($$9, $$7, $$8, pPackedLight, 1.0F, 0, 1, 1);
|
vertex(consumer, matrix, pose, normal, pPackedLight, 1.0F, 0, 1, 1);
|
||||||
vertex($$9, $$7, $$8, pPackedLight, 1.0F, 1, 1, 0);
|
vertex(consumer, matrix, pose, normal, pPackedLight, 1.0F, 1, 1, 0);
|
||||||
vertex($$9, $$7, $$8, pPackedLight, 0.0F, 1, 0, 0);
|
vertex(consumer, matrix, pose, normal, pPackedLight, 0.0F, 1, 0, 0);
|
||||||
pMatrixStack.popPose();
|
pMatrixStack.popPose();
|
||||||
super.render(pEntity, pEntityYaw, pPartialTicks, pMatrixStack, pBuffer, pPackedLight);
|
super.render(pEntity, pEntityYaw, pPartialTicks, pMatrixStack, pBuffer, pPackedLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void vertex(VertexConsumer pConsumer, Matrix4f pPose, Matrix3f pNormal, int pLightmapUV, float pX, float pY, int pU, int pV) {
|
private static void vertex(VertexConsumer consumer, Matrix4f matrix, PoseStack.Pose pose, Matrix3f normal, int lightmapUV, float pX, float pY, int pU, int pV) {
|
||||||
// TODO vertex
|
consumer.addVertex(matrix, pX - 0.5F, pY - 0.25F, 0.0F)
|
||||||
// pConsumer.vertex(pPose, pX - 0.5F, pY - 0.25F, 0.0F).color(255, 255, 255, 255).uv((float)pU, (float)pV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(pLightmapUV).normal(pNormal, 0.0F, 1.0F, 0.0F).endVertex();
|
.setColor(255, 255, 255, 255)
|
||||||
|
.setUv((float) pU, (float) pV)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY)
|
||||||
|
.setNormal(pose, 0.0F, 1.0F, 0.0F)
|
||||||
|
.setLight(lightmapUV);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ResourceLocation texture(Entity entity) {
|
private static ResourceLocation texture(Entity entity) {
|
||||||
return Mod.loc("textures/particle/fire_star_" + (entity.tickCount % 8 + 1) + ".png");
|
return Mod.loc("textures/particle/fire_star_" + (entity.tickCount % 8 + 1) + ".png");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceLocation getTextureLocation(FlareDecoyEntity pEntity) {
|
public @NotNull ResourceLocation getTextureLocation(@NotNull FlareDecoyEntity pEntity) {
|
||||||
return texture(pEntity);
|
return texture(pEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,13 +53,13 @@ public class LaserEntityRenderer extends AbstractLaserEntityRenderer<LaserEntity
|
||||||
float maxU = minU + 16F / TEXTURE_WIDTH;
|
float maxU = minU + 16F / TEXTURE_WIDTH;
|
||||||
float maxV = minV + 16F / TEXTURE_HEIGHT;
|
float maxV = minV + 16F / TEXTURE_HEIGHT;
|
||||||
float size = 0.25f;
|
float size = 0.25f;
|
||||||
PoseStack.Pose matrix$stack$entry = matrixStackIn.last();
|
PoseStack.Pose pose = matrixStackIn.last();
|
||||||
Matrix4f matrix4f = matrix$stack$entry.pose();
|
Matrix4f matrix4f = pose.pose();
|
||||||
Matrix3f matrix3f = matrix$stack$entry.normal();
|
Matrix3f matrix3f = pose.normal();
|
||||||
drawVertex(matrix4f, matrix3f, builder, -size, -size, 0, minU, minV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, -size, -size, 0, minU, minV, packedLightIn);
|
||||||
drawVertex(matrix4f, matrix3f, builder, -size, size, 0, minU, maxV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, -size, size, 0, minU, maxV, packedLightIn);
|
||||||
drawVertex(matrix4f, matrix3f, builder, size, size, 0, maxU, maxV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, size, size, 0, maxU, maxV, packedLightIn);
|
||||||
drawVertex(matrix4f, matrix3f, builder, size, -size, 0, maxU, minV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, size, -size, 0, maxU, minV, packedLightIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,14 +74,14 @@ public class LaserEntityRenderer extends AbstractLaserEntityRenderer<LaserEntity
|
||||||
float minV = 16 / TEXTURE_HEIGHT + 1 / TEXTURE_HEIGHT * frame;
|
float minV = 16 / TEXTURE_HEIGHT + 1 / TEXTURE_HEIGHT * frame;
|
||||||
float maxU = minU + 20 / TEXTURE_WIDTH;
|
float maxU = minU + 20 / TEXTURE_WIDTH;
|
||||||
float maxV = minV + 1 / TEXTURE_HEIGHT;
|
float maxV = minV + 1 / TEXTURE_HEIGHT;
|
||||||
PoseStack.Pose matrix$stack$entry = matrixStackIn.last();
|
PoseStack.Pose pose = matrixStackIn.last();
|
||||||
Matrix4f matrix4f = matrix$stack$entry.pose();
|
Matrix4f matrix4f = pose.pose();
|
||||||
Matrix3f matrix3f = matrix$stack$entry.normal();
|
Matrix3f matrix3f = pose.normal();
|
||||||
float offset = playerView ? -1 : 0;
|
float offset = playerView ? -1 : 0;
|
||||||
float size = 0.2f;
|
float size = 0.2f;
|
||||||
drawVertex(matrix4f, matrix3f, builder, -size, offset, 0, minU, minV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, -size, offset, 0, minU, minV, packedLightIn);
|
||||||
drawVertex(matrix4f, matrix3f, builder, -size, length, 0, minU, maxV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, -size, length, 0, minU, maxV, packedLightIn);
|
||||||
drawVertex(matrix4f, matrix3f, builder, size, length, 0, maxU, maxV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, size, length, 0, maxU, maxV, packedLightIn);
|
||||||
drawVertex(matrix4f, matrix3f, builder, size, offset, 0, maxU, minV, packedLightIn);
|
drawVertex(matrix4f, matrix3f, pose, builder, size, offset, 0, maxU, minV, packedLightIn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue