Начинающий
- Статус
- Оффлайн
- Регистрация
- 26 Июл 2025
- Сообщения
- 14
- Реакции
- 0
- Выберите загрузчик игры
- Fabric
Ss
dw
Код:
private void renderCrystals(Entity target, MatrixStack matrices, float tickDelta) {
Vec3d camPos = mc.gameRenderer.getCamera().getPos();
double x = MathHelper.lerp(tickDelta, target.prevX, target.getX()) - camPos.x;
double y = MathHelper.lerp(tickDelta, target.prevY, target.getY()) - camPos.y;
double z = MathHelper.lerp(tickDelta, target.prevZ, target.getZ()) - camPos.z;
float speed = crystalSpeed.get().floatValue();
float radius = crystalRadius.get().floatValue();
float anim = (float) animation.getOutput();
double time = (System.currentTimeMillis() - crystalStartTime) / 1000.0 * speed;
RenderSystem.disableCull();
RenderSystem.disableDepthTest();
RenderUtil.enableRender(
GlStateManager.SrcFactor.SRC_ALPHA,
GlStateManager.DstFactor.ONE
);
RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
Matrix4f matrix = matrices.peek().getPositionMatrix();
BufferBuilder buffer = IMinecraft.tessellator()
.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR);
int color = ColorUtil.getColorStyle(0);
float r = ((color >> 16) & 255) / 255f;
float g = ((color >> 8) & 255) / 255f;
float b = (color & 255) / 255f;
int crystals = 24;
float height = target.getHeight();
for(int i = 0; i < crystals; i++) {
float progress = (float)i / crystals;
double spiralOffset = progress * Math.PI * 4;
double angle1 = spiralOffset + time;
double angle2 = spiralOffset + time + Math.PI;
double yPos = y + progress * height;
double x1 = x + Math.cos(angle1) * radius * anim;
double z1 = z + Math.sin(angle1) * radius * anim;
double x2 = x + Math.cos(angle2) * radius * anim;
double z2 = z + Math.sin(angle2) * radius * anim;
drawCrystal(buffer, matrix, x1, yPos, z1, 0.13f * anim, r, g, b);
drawCrystal(buffer, matrix, x2, yPos, z2, 0.13f * anim, r, g, b);
}
RenderUtil.render3D.endBuilding(buffer);
RenderSystem.enableDepthTest();
RenderSystem.enableCull();
RenderUtil.disableRender();
}
private void drawCrystal(BufferBuilder buffer, Matrix4f matrix,
double x, double y, double z,
float size,
float r, float g, float b) {
float cx = (float)x;
float cy = (float)y;
float cz = (float)z;
float top = cy + size;
float bottom = cy - size;
float px = cx + size;
float nx = cx - size;
float pz = cz + size;
float nz = cz - size;
tri(buffer,matrix,cx,top,cz, nx,cy,cz, cx,cy,nz,r,g,b);
tri(buffer,matrix,cx,top,cz, cx,cy,nz, px,cy,cz,r,g,b);
tri(buffer,matrix,cx,top,cz, px,cy,cz, cx,cy,pz,r,g,b);
tri(buffer,matrix,cx,top,cz, cx,cy,pz, nx,cy,cz,r,g,b);
tri(buffer,matrix,cx,bottom,cz, cx,cy,nz, nx,cy,cz,r,g,b);
tri(buffer,matrix,cx,bottom,cz, px,cy,cz, cx,cy,nz,r,g,b);
tri(buffer,matrix,cx,bottom,cz, cx,cy,pz, px,cy,cz,r,g,b);
tri(buffer,matrix,cx,bottom,cz, nx,cy,cz, cx,cy,pz,r,g,b);
}
private void tri(BufferBuilder buffer, Matrix4f matrix,
float x1,float y1,float z1,
float x2,float y2,float z2,
float x3,float y3,float z3,
float r,float g,float b){
buffer.vertex(matrix,x1,y1,z1).color(r,g,b,1f);
buffer.vertex(matrix,x2,y2,z2).color(r,g,b,0.7f);
buffer.vertex(matrix,x3,y3,z3).color(r,g,b,0.7f);
}