Move render helper to kotlin

This commit is contained in:
DBotThePony 2022-08-23 18:26:39 +07:00
parent c24176374c
commit 03f62b2d0e
Signed by: DBot
GPG Key ID: DCC23B5715498507
18 changed files with 576 additions and 566 deletions

View File

@ -1,455 +0,0 @@
package ru.dbotthepony.mc.otm.client.render;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import com.mojang.math.Matrix4f;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.resources.ResourceLocation;
import ru.dbotthepony.mc.otm.OverdriveThatMatters;
import ru.dbotthepony.mc.otm.core.RGBAColor;
import java.util.Stack;
import static org.lwjgl.opengl.GL11.GL_ALWAYS;
/**
* I am too lazy to learn how Mojang's API works
* so I just recreate part of GMod's API in here
*
* also contains texture widgets
*/
public class RenderHelper {
private static final Matrix4f identity = new Matrix4f();
public static final ResourceLocation WIDGETS = new ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets.png");
public static final ResourceLocation WIDGETS_18 = new ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_18.png");
public static final ResourceLocation WIDGETS_8 = new ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_8.png");
public static final ResourceLocation SCROLL = new ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/scroll.png");
static {
identity.setIdentity();
}
public static float depth_z = 0;
public static void setUpcomingDepth(float depth) {
depth_z = depth;
}
public static void clearUpcomingDepth() {
depth_z = 0;
}
// Regular functions
/**
* Draws a textured rectangle on screen
* translated by a given matrix
*
* @param matrix Matrix translation to use
* @param x screen X position (with matrix transformation)
* @param y screen Y position (with matrix transformation)
* @param width width of drawn rectangle
* @param height height of drawn rectangle
* @param u0 initial U position ranging from 0-1 (single) or beyond (repetitive)
* @param v0 initial V position ranging from 0-1 (single) or beyond (repetitive)
* @param u1 final U position ranging from 0-1 (single) or beyond (repetitive)
* @param v1 final V position ranging from 0-1 (single) or beyond (repetitive)
*/
public static void drawTexturedRectUV(
Matrix4f matrix,
float x,
float y,
float width,
float height,
float u0,
float v0,
float u1,
float v1
) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.enableTexture();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.depthFunc(GL_ALWAYS);
var builder = Tesselator.getInstance().getBuilder();
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
builder.vertex(matrix, x, y + height, depth_z).uv(u0, v1).endVertex();
builder.vertex(matrix, x + width, y + height, depth_z).uv(u1, v1).endVertex();
builder.vertex(matrix, x + width, y, depth_z).uv(u1, v0).endVertex();
builder.vertex(matrix, x, y, depth_z).uv(u0, v0).endVertex();
BufferUploader.drawWithShader(builder.end());
}
public static void drawTexturedRectUV(
Matrix4f matrix,
float x,
float y,
float width,
float height,
UVCoords uv
) {
drawTexturedRectUV(matrix, x, y, width, height, uv.u0(), uv.v0(), uv.u1(), uv.v1());
}
public static void colorSphere(Matrix4f matrix, float radius) {
final int fragments = 32;
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
var builder = Tesselator.getInstance().getBuilder();
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
final double turn_step = Math.PI * (1 / (double) fragments) * 2;
final double stripe_step = Math.PI * (1 / (double) fragments);
for (int turn = 0; turn < fragments; turn++) {
final double turn_pre = turn_step * turn;
final double turn_post = turn_step * (turn + 1);
for (int sector = 0; sector < fragments; sector++) {
final double tilt_pre = Math.PI / 2 - stripe_step * (sector);
final double tilt_post = Math.PI / 2 - stripe_step * (sector + 1);
final float x_pre = (float) Math.sin(turn_pre) * radius;
final float x_post = (float) Math.sin(turn_post) * radius;
final float z_pre = (float) Math.cos(turn_pre) * radius;
final float z_post = (float) Math.cos(turn_post) * radius;
final float y_pre = (float) (Math.sin(tilt_pre) + 0.5) * radius;
final float y_post = (float) (Math.sin(tilt_post) + 0.5) * radius;
builder.vertex(matrix, x_pre * (float) Math.cos(tilt_post), y_post, z_pre * (float) Math.cos(tilt_post))
.color(draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue(), draw_color.getAlpha())
.endVertex();
builder.vertex(matrix, x_post * (float) Math.cos(tilt_post), y_post, z_post * (float) Math.cos(tilt_post))
.color(draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue(), draw_color.getAlpha())
.endVertex();
builder.vertex(matrix, x_post * (float) Math.cos(tilt_pre), y_pre, z_post * (float) Math.cos(tilt_pre))
.color(draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue(), draw_color.getAlpha())
.endVertex();
builder.vertex(matrix, x_pre * (float) Math.cos(tilt_pre), y_pre, z_pre * (float) Math.cos(tilt_pre))
.color(draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue(), draw_color.getAlpha())
.endVertex();
}
}
BufferUploader.drawWithShader(builder.end());
}
public static void colorSphere(PoseStack stack, float radius) {
colorSphere(stack.last().pose(), radius);
}
/**
* Draws a textured rectangle on screen
*
* @param x screen X position (with matrix transformation)
* @param y screen Y position (with matrix transformation)
* @param width width of drawn rectangle
* @param height height of drawn rectangle
* @param u0 initial U position ranging from 0-1 (single) or beyond (repetitive)
* @param v0 initial V position ranging from 0-1 (single) or beyond (repetitive)
* @param u1 final U position ranging from 0-1 (single) or beyond (repetitive)
* @param v1 final V position ranging from 0-1 (single) or beyond (repetitive)
*/
public static void drawTexturedRectUV(
float x,
float y,
float width,
float height,
float u0,
float v0,
float u1,
float v1
) {
drawTexturedRectUV(identity, x, y, width, height, u0, v0, u1, v1);
}
public static void drawTexturedRectUV(
float x,
float y,
float width,
float height,
UVCoords uv
) {
drawTexturedRectUV(identity, x, y, width, height, uv.u0(), uv.v0(), uv.u1(), uv.v1());
}
/**
* Draws a textured rectangle on screen
* with matrix from pose
*
* @param stack PoseStack containing translation matrix
* @param x screen X position (with matrix transformation)
* @param y screen Y position (with matrix transformation)
* @param width width of drawn rectangle
* @param height height of drawn rectangle
* @param u0 initial U position ranging from 0-1 (single) or beyond (repetitive)
* @param v0 initial V position ranging from 0-1 (single) or beyond (repetitive)
* @param u1 final U position ranging from 0-1 (single) or beyond (repetitive)
* @param v1 final V position ranging from 0-1 (single) or beyond (repetitive)
*/
public static void drawTexturedRectUV(
PoseStack stack,
float x,
float y,
float width,
float height,
float u0,
float v0,
float u1,
float v1
) {
drawTexturedRectUV(stack.last().pose(), x, y, width, height, u0, v0, u1, v1);
}
public static void drawTexturedRectUV(
PoseStack stack,
float x,
float y,
float width,
float height,
UVCoords uv
) {
drawTexturedRectUV(stack.last().pose(), x, y, width, height, uv.u0(), uv.v0(), uv.u1(), uv.v1());
}
/**
* @param stack stack to take transformation matrix from
* @param x position x on screen
* @param y position y on screen
* @param width drawn rectangle width
* @param height drawn rectangle height
* @param image_x absolute asset x, to compute U0 coordinate from
* @param image_y absolute asset y, to compute V0 coordinate from
* @param mapped_width absolute asset width, to compute U1 coordinate from
* @param mapped_height absolute asset height, to compute V1 coordinate from
*/
public static void drawTexturedRectAuto(
PoseStack stack,
float x,
float y,
float width,
float height,
float image_x,
float image_y,
float mapped_width,
float mapped_height
) {
drawTexturedRectUV(stack.last().pose(), x, y, width, height, image_x / mapped_width, image_y / mapped_height, (image_x + width) / mapped_width, (image_y + height) / mapped_height);
}
public static void drawTexturedRectAuto(
PoseStack stack,
float x,
float y,
float width,
float height,
float image_x,
float image_y,
float mapped_width,
float mapped_height,
UVWindingOrder order
) {
drawTexturedRectUV(stack.last().pose(), x, y, width, height, order.translate(image_x / mapped_width, image_y / mapped_height, (image_x + width) / mapped_width, (image_y + height) / mapped_height));
}
public static void drawTexturedRectAuto(
PoseStack stack,
float x,
float y,
float width,
float height,
float image_x,
float image_y
) {
drawTexturedRectAuto(stack, x, y, width, height, image_x, image_y, 256, 256);
}
public static void drawTexturedRectAuto(
PoseStack stack,
float x,
float y,
float width,
float height,
float image_x,
float image_y,
UVWindingOrder order
) {
drawTexturedRectAuto(stack, x, y, width, height, image_x, image_y, 256, 256, order);
}
/**
* Draws a textured rectangle on screen
* with matrix from pose
* UVs are 0-1
*
* @param stack PoseStack containing translation matrix
* @param x screen X position (with matrix transformation)
* @param y screen Y position (with matrix transformation)
* @param width width of drawn rectangle
* @param height height of drawn rectangle
*/
public static void drawTexturedRect(
PoseStack stack,
float x,
float y,
float width,
float height
) {
drawTexturedRectUV(stack, x, y, width, height, 0, 0, 1, 1);
}
public static void drawRegularSlot(
PoseStack stack,
float x,
float y
) {
RenderSystem.setShaderTexture(0, WIDGETS);
drawTexturedRectAuto(stack, x, y, 18, 18, 0, 96, 256, 256);
}
public static void drawBigSlot(
PoseStack stack,
float x,
float y
) {
RenderSystem.setShaderTexture(0, WIDGETS);
drawTexturedRectAuto(stack, x, y, 26, 26, 18, 96, 256, 256);
}
public static RGBAColor getDrawColor() {
return draw_color;
}
public static void setDrawColor(RGBAColor rect_color) {
RenderHelper.draw_color = rect_color;
}
public static void setShaderColor(RGBAColor rect_color) {
RenderSystem.setShaderColor(rect_color.getRed(), rect_color.getGreen(), rect_color.getBlue(), rect_color.getAlpha());
}
private static RGBAColor draw_color = new RGBAColor(255, 255, 255, 255);
public static boolean forwardWinding = true;
/**
* Draws a solid color rectangle on screen, defined by last setDrawColor(RGBColor rect_color) call
*
* @param matrix matrix to translate by
* @param x x screen coordinate
* @param y y screen coordinate
* @param width rectangle width
* @param height rectangle height
*/
public static void drawRect(
Matrix4f matrix,
float x,
float y,
float width,
float height
) {
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.depthFunc(GL_ALWAYS);
var tess = Tesselator.getInstance();
BufferBuilder builder = tess.getBuilder();
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
if (forwardWinding) {
builder.vertex(matrix, x, y + height, depth_z).color(draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue(), draw_color.getAlpha()).endVertex();
builder.vertex(matrix, x + width, y + height, depth_z).color(draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue(), draw_color.getAlpha()).endVertex();
builder.vertex(matrix, x + width, y, depth_z).color(draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue(), draw_color.getAlpha()).endVertex();
builder.vertex(matrix, x, y, depth_z).color(draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue(), draw_color.getAlpha()).endVertex();
} else {
builder.vertex(matrix, x, y, depth_z).color(draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue(), draw_color.getAlpha()).endVertex();
builder.vertex(matrix, x + width, y, depth_z).color(draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue(), draw_color.getAlpha()).endVertex();
builder.vertex(matrix, x + width, y + height, depth_z).color(draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue(), draw_color.getAlpha()).endVertex();
builder.vertex(matrix, x, y + height, depth_z).color(draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue(), draw_color.getAlpha()).endVertex();
}
tess.end();
RenderSystem.enableTexture();
}
/**
* Draws a solid color rectangle on screen, defined by last setDrawColor(RGBColor rect_color) call
*
* @param stack stack to translate by
* @param x x screen coordinate
* @param y y screen coordinate
* @param width rectangle width
* @param height rectangle height
*/
public static void drawRect(
PoseStack stack,
float x,
float y,
float width,
float height
) {
drawRect(stack.last().pose(), x, y, width, height);
}
record ScissorRect(int x, int y, int width, int height) {}
private static final Stack<ScissorRect> SCISSOR = new Stack<>();
public static void ensureScissorStackEmpty() {
if (!SCISSOR.empty()) {
throw new IllegalStateException("Unbalanced scissor rects: Popping less than pushing");
}
}
public static void pushScissorRect(int x, int y, int width, int height) {
if (!SCISSOR.empty()) {
final var peek = SCISSOR.peek();
x = Math.max(x, peek.x);
y = Math.max(y, peek.y);
width = Math.min(width, peek.width);
height = Math.min(height, peek.height);
}
SCISSOR.push(new ScissorRect(x, y, width, height));
final var window = Minecraft.getInstance().getWindow();
y = window.getHeight() - y - height;
RenderSystem.enableScissor(x, y, width, height);
}
public static void popScissorRect() {
if (SCISSOR.empty()) {
throw new IllegalStateException("Unbalanced scissor rects: Popping more than pushing");
}
SCISSOR.pop();
if (SCISSOR.empty()) {
RenderSystem.disableScissor();
return;
}
final var value = SCISSOR.peek();
final var window = Minecraft.getInstance().getWindow();
final var y = window.getHeight() - value.y - value.height;
RenderSystem.enableScissor(value.x, y, value.width, value.height);
}
}

View File

@ -1,4 +0,0 @@
package ru.dbotthepony.mc.otm.client.render;
public record UVCoords(float u0, float v0, float u1, float v1) {
}

View File

@ -1,40 +0,0 @@
package ru.dbotthepony.mc.otm.client.render;
public enum UVWindingOrder {
NORMAL(0, 1, 2, 3), // normal operation
U0_V0_U1_V1(0, 1, 2, 3), // normal operation
U0_V1_U1_V0(0, 3, 2, 1), // mirror y
FLIP(0, 3, 2, 1), // mirror y
U1_V0_U0_V1(2, 1, 0, 3), // mirror x
FLOP(2, 1, 0, 3), // mirror x
U1_V1_U0_V0(2, 3, 0, 1), // mirror both
FLIP_FLOP(2, 3, 0, 1); // mirror both
public static final int U0 = 0;
public static final int V0 = 1;
public static final int U1 = 2;
public static final int V1 = 3;
public final int u0;
public final int v0;
public final int u1;
public final int v1;
private final float[] uv_map = new float[4];
UVWindingOrder(int u0, int v0, int u1, int v1) {
this.u0 = u0;
this.v0 = v0;
this.u1 = u1;
this.v1 = v1;
}
public UVCoords translate(float u0, float v0, float u1, float v1) {
uv_map[0] = u0;
uv_map[1] = v0;
uv_map[2] = u1;
uv_map[3] = v1;
return new UVCoords(uv_map[this.u0], uv_map[this.v0], uv_map[this.u1], uv_map[this.v1]);
}
}

View File

@ -359,7 +359,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter
private fun diffTracked(slot: Int, diff: Int) {
val scannedMap = checkNotNull(scannedMap[slot]) { "Not tracking slot $slot" }
val item = scannedMap.children[slot] ?: throw IllegalStateException("${scannedMap.id} does not track $slot")
val item = checkNotNull(scannedMap.children[slot]) { "${scannedMap.id} does not track $slot" }
val oldCount = scannedMap.stack.count
item.stack.count += diff

View File

@ -91,7 +91,7 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context
i: Int,
i1: Int
) {
RenderHelper.setDrawColor(RGBAColor.BLACK)
setDrawColor(RGBAColor.BLACK)
RenderSystem.setShader(GameRenderer::getPositionColorShader)
RenderSystem.depthFunc(GL30.GL_LESS)
@ -101,7 +101,7 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context
poseStack.pushPose()
poseStack.translate(0.5, -tile.gravitationStrength / 2 + 0.5, 0.5)
RenderHelper.colorSphere(poseStack, tile.gravitationStrength.toFloat())
colorSphere(poseStack, tile.gravitationStrength.toFloat())
RenderSystem.enableCull()
RenderSystem.enableTexture()

View File

@ -0,0 +1,373 @@
package ru.dbotthepony.mc.otm.client.render
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.*
import com.mojang.math.Matrix4f
import net.minecraft.client.renderer.GameRenderer
import net.minecraft.resources.ResourceLocation
import org.lwjgl.opengl.GL11
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.RGBAColor
import kotlin.math.cos
import kotlin.math.sin
private val identity = Matrix4f().also { it.setIdentity() }
object WidgetLocation {
val WIDGETS = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets.png")
val WIDGETS_18 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_18.png")
val WIDGETS_8 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_8.png")
val SCROLL = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/scroll.png")
}
var zLevel = 0f
var drawColor = RGBAColor(255, 255, 255, 255)
@JvmName("setDrawColor\$JVM")
fun setDrawColor(color: RGBAColor) {
drawColor = color
}
// Regular functions
fun drawTexturedRect(
matrix: Matrix4f,
x: Float,
y: Float,
width: Float,
height: Float,
u0: Float = 0f,
v0: Float = 0f,
u1: Float = 1f,
v1: Float = 1f
) {
RenderSystem.setShader { GameRenderer.getPositionTexShader() }
RenderSystem.enableTexture()
RenderSystem.enableBlend()
RenderSystem.defaultBlendFunc()
RenderSystem.depthFunc(GL11.GL_ALWAYS)
val builder = Tesselator.getInstance().builder
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX)
builder.vertex(matrix, x, y + height, zLevel).uv(u0, v1).endVertex()
builder.vertex(matrix, x + width, y + height, zLevel).uv(u1, v1).endVertex()
builder.vertex(matrix, x + width, y, zLevel).uv(u1, v0).endVertex()
builder.vertex(matrix, x, y, zLevel).uv(u0, v0).endVertex()
BufferUploader.drawWithShader(builder.end())
}
fun drawTexturedRect(
matrix: Matrix4f,
x: Float,
y: Float,
width: Float,
height: Float,
uv: IUVCoords
) = drawTexturedRect(matrix, x, y, width, height, uv.u0, uv.v0, uv.u1, uv.v1)
fun drawTexturedRect(
stack: PoseStack,
x: Float,
y: Float,
width: Float,
height: Float,
uv: IUVCoords
) = drawTexturedRect(stack.last().pose(), x, y, width, height, uv.u0, uv.v0, uv.u1, uv.v1)
fun drawTexturedRect(
stack: PoseStack,
x: Float,
y: Float,
width: Float,
height: Float,
u0: Float,
v0: Float,
u1: Float,
v1: Float
) = drawTexturedRect(stack.last().pose(), x, y, width, height, u0, v0, u1, v1)
fun drawTexturedRect(
x: Float,
y: Float,
width: Float,
height: Float,
uv: IUVCoords
) = drawTexturedRect(identity, x, y, width, height, uv.u0, uv.v0, uv.u1, uv.v1)
fun drawTexturedRect(
x: Float,
y: Float,
width: Float,
height: Float,
u0: Float,
v0: Float,
u1: Float,
v1: Float
) = drawTexturedRect(identity, x, y, width, height, u0, v0, u1, v1)
fun colorSphere(matrix: Matrix4f, radius: Float) {
val fragments = 32
RenderSystem.enableBlend()
RenderSystem.defaultBlendFunc()
val builder = Tesselator.getInstance().builder
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR)
val turnStep = Math.PI * (1 / fragments.toDouble()) * 2
val stripeStep = Math.PI * (1 / fragments.toDouble())
for (turn in 0 until fragments) {
val turnPre = turnStep * turn
val turnPost = turnStep * (turn + 1)
for (sector in 0 until fragments) {
val tiltPre = Math.PI / 2 - stripeStep * sector
val tiltPost = Math.PI / 2 - stripeStep * (sector + 1)
val xPre = sin(turnPre).toFloat() * radius
val xPost = sin(turnPost).toFloat() * radius
val zPre = cos(turnPre).toFloat() * radius
val zPost = cos(turnPost).toFloat() * radius
val yPre = (sin(tiltPre) + 0.5).toFloat() * radius
val yPost = (sin(tiltPost) + 0.5).toFloat() * radius
builder.vertex(matrix, xPre * cos(tiltPost).toFloat(), yPost, zPre * cos(tiltPost).toFloat())
.color(drawColor)
.endVertex()
builder.vertex(matrix, xPost * cos(tiltPost).toFloat(), yPost, zPost * cos(tiltPost).toFloat())
.color(drawColor)
.endVertex()
builder.vertex(matrix, xPost * cos(tiltPre).toFloat(), yPre, zPost * cos(tiltPre).toFloat())
.color(drawColor)
.endVertex()
builder.vertex(matrix, xPre * cos(tiltPre).toFloat(), yPre, zPre * cos(tiltPre).toFloat())
.color(drawColor)
.endVertex()
}
}
BufferUploader.drawWithShader(builder.end())
}
fun colorSphere(pose: PoseStack, radius: Float) = colorSphere(pose.last().pose(), radius)
fun drawTexturedRectAuto(
stack: PoseStack,
x: Float,
y: Float,
width: Float,
height: Float,
image_x: Float,
image_y: Float,
mapped_width: Float,
mapped_height: Float
) = drawTexturedRect(
stack,
x,
y,
width,
height,
image_x / mapped_width,
image_y / mapped_height,
(image_x + width) / mapped_width,
(image_y + height) / mapped_height
)
fun drawTexturedRectAuto(
stack: PoseStack,
x: Float,
y: Float,
width: Float,
height: Float,
image_x: Float,
image_y: Float,
mapped_width: Float,
mapped_height: Float,
order: UVWindingOrder
) = drawTexturedRect(
stack,
x,
y,
width,
height,
order.translate(
image_x / mapped_width,
image_y / mapped_height,
(image_x + width) / mapped_width,
(image_y + height) / mapped_height
)
)
fun drawTexturedRectAuto(
matrix: Matrix4f,
x: Float,
y: Float,
width: Float,
height: Float,
image_x: Float,
image_y: Float,
mapped_width: Float,
mapped_height: Float
) = drawTexturedRect(
matrix,
x,
y,
width,
height,
image_x / mapped_width,
image_y / mapped_height,
(image_x + width) / mapped_width,
(image_y + height) / mapped_height
)
fun drawTexturedRectAuto(
matrix: Matrix4f,
x: Float,
y: Float,
width: Float,
height: Float,
image_x: Float,
image_y: Float,
mapped_width: Float,
mapped_height: Float,
order: UVWindingOrder
) = drawTexturedRect(
matrix,
x,
y,
width,
height,
order.translate(
image_x / mapped_width,
image_y / mapped_height,
(image_x + width) / mapped_width,
(image_y + height) / mapped_height
)
)
fun drawTexturedRectAuto(
x: Float,
y: Float,
width: Float,
height: Float,
image_x: Float,
image_y: Float,
mapped_width: Float,
mapped_height: Float
) = drawTexturedRect(
x,
y,
width,
height,
image_x / mapped_width,
image_y / mapped_height,
(image_x + width) / mapped_width,
(image_y + height) / mapped_height
)
fun drawTexturedRectAuto(
x: Float,
y: Float,
width: Float,
height: Float,
image_x: Float,
image_y: Float,
mapped_width: Float,
mapped_height: Float,
order: UVWindingOrder
) = drawTexturedRect(
x,
y,
width,
height,
order.translate(
image_x / mapped_width,
image_y / mapped_height,
(image_x + width) / mapped_width,
(image_y + height) / mapped_height
)
)
fun drawRect(
matrix: Matrix4f,
x: Float,
y: Float,
width: Float,
height: Float
) {
RenderSystem.disableTexture()
RenderSystem.enableBlend()
RenderSystem.defaultBlendFunc()
RenderSystem.setShader(GameRenderer::getPositionColorShader)
RenderSystem.depthFunc(GL11.GL_ALWAYS)
val tess = Tesselator.getInstance()
val builder = tess.builder
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR)
builder.vertex(matrix, x, y + height, zLevel).color(drawColor).endVertex()
builder.vertex(matrix, x + width, y + height, zLevel).color(drawColor).endVertex()
builder.vertex(matrix, x + width, y, zLevel).color(drawColor).endVertex()
builder.vertex(matrix, x, y, zLevel).color(drawColor).endVertex()
tess.end()
RenderSystem.enableTexture()
}
fun drawRect(
pose: PoseStack,
x: Float,
y: Float,
width: Float,
height: Float
) = drawRect(pose.last().pose(), x, y, width, height)
private data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int)
private val scissorStack = ArrayDeque<ScissorRect>()
@Suppress("NAME_SHADOWING")
fun pushScissorRect(x: Int, y: Int, width: Int, height: Int) {
var x = x
var y = y
var width = width
var height = height
val peek = scissorStack.lastOrNull()
if (peek != null) {
x = x.coerceAtLeast(peek.x)
y = y.coerceAtLeast(peek.y)
width = width.coerceAtMost(peek.width)
height = height.coerceAtMost(peek.height)
if (peek.x == x && peek.y == y && peek.width == width && peek.height == height) {
scissorStack.add(peek)
return
}
}
scissorStack.add(ScissorRect(x, y, width, height))
y = minecraft.window.height - y - height
RenderSystem.enableScissor(x, y, width, height)
}
fun popScissorRect() {
scissorStack.removeLast()
val peek = scissorStack.lastOrNull()
if (peek == null) {
RenderSystem.disableScissor()
return
}
val y = minecraft.window.height - peek.y - peek.height
RenderSystem.enableScissor(peek.x, y, peek.width, peek.height)
}

View File

@ -54,8 +54,8 @@ class SkinGrid(
operator fun get(column: Int, row: Int) = SkinElement(texture, column * width, row * height, width, height, imageWidth, imageHeight)
companion object {
val WIDGETS_18 = SkinGrid(RenderHelper.WIDGETS_18, 18f, 18f)
val WIDGETS_8 = SkinGrid(RenderHelper.WIDGETS_8, 8f, 8f)
val WIDGETS_18 = SkinGrid(WidgetLocation.WIDGETS_18, 18f, 18f)
val WIDGETS_8 = SkinGrid(WidgetLocation.WIDGETS_8, 8f, 8f)
}
}
@ -185,16 +185,13 @@ class SkinElement @JvmOverloads constructor(
) {
val winded = winding.translate(u0, v0, u1, v1)
RenderHelper.drawTexturedRectUV(
drawTexturedRect(
stack,
x,
y,
width,
height,
winded.u0,
winded.v0,
winded.u1,
winded.v1,
winded,
)
}
@ -222,16 +219,13 @@ class SkinElement @JvmOverloads constructor(
val winded = winding.translate(u0, v0, u1, v1)
RenderHelper.drawTexturedRectUV(
drawTexturedRect(
stack,
x,
y,
width,
height,
winded.u0,
winded.v0,
winded.u1,
winded.v1,
winded,
)
}

View File

@ -0,0 +1,136 @@
package ru.dbotthepony.mc.otm.client.render
sealed interface IUVCoords {
val u0: Float
val v0: Float
val u1: Float
val v1: Float
operator fun get(index: Int): Float
}
private val mapImmutable = ArrayList<(input: UVCoords) -> Float>()
.also { it.add { it.u0 } }
.also { it.add { it.v0 } }
.also { it.add { it.u1 } }
.also { it.add { it.v1 } }
.toTypedArray()
private val mapMutable = ArrayList<(input: MutableUVCoords) -> Float>()
.also { it.add { it.u0 } }
.also { it.add { it.v0 } }
.also { it.add { it.u1 } }
.also { it.add { it.v1 } }
.toTypedArray()
private val mapSetMutable = ArrayList<(input: MutableUVCoords, value: Float) -> Unit>()
.also { it.add { input, value -> input.u0 = value } }
.also { it.add { input, value -> input.v0 = value } }
.also { it.add { input, value -> input.u1 = value } }
.also { it.add { input, value -> input.v1 = value } }
.toTypedArray()
data class UVCoords(
override val u0: Float,
override val v0: Float,
override val u1: Float,
override val v1: Float,
) : IUVCoords {
override fun get(index: Int): Float {
return mapImmutable[index].invoke(this)
}
}
data class MutableUVCoords(
override var u0: Float,
override var v0: Float,
override var u1: Float,
override var v1: Float,
) : IUVCoords {
override fun get(index: Int): Float {
return mapMutable[index].invoke(this)
}
operator fun set(index: Int, value: Float) {
mapSetMutable[index].invoke(this, value)
}
}
private val pickers = ArrayList<(u0: Float,
v0: Float,
u1: Float,
v1: Float) -> Float>()
.also { it.add { u0, v0, u1, v1 -> u0 } }
.also { it.add { u0, v0, u1, v1 -> v0 } }
.also { it.add { u0, v0, u1, v1 -> u1 } }
.also { it.add { u0, v0, u1, v1 -> v1 } }
.toTypedArray()
enum class UVWindingOrder(
val u0: Int,
val v0: Int,
val u1: Int,
val v1: Int,
) {
NORMAL(0, 1, 2, 3), // normal operation
U0_V0_U1_V1(0, 1, 2, 3), // normal operation
U0_V1_U1_V0(0, 3, 2, 1), // mirror y
FLIP(0, 3, 2, 1), // mirror y
U1_V0_U0_V1(2, 1, 0, 3), // mirror x
FLOP(2, 1, 0, 3), // mirror x
U1_V1_U0_V0(2, 3, 0, 1), // mirror both
FLIP_FLOP(2, 3, 0, 1); // mirror both
val u0Picker = pickers[u0]
val v0Picker = pickers[v0]
val u1Picker = pickers[u1]
val v1Picker = pickers[v1]
private val buffer = FloatArray(4)
fun translate(
u0: Float,
v0: Float,
u1: Float,
v1: Float,
): UVCoords {
synchronized(buffer) {
buffer[0] = u0
buffer[1] = v0
buffer[2] = u1
buffer[3] = v1
return UVCoords(buffer[this.u0], buffer[this.v0], buffer[this.u1], buffer[this.v1])
}
}
fun translate(
input: UVCoords
): UVCoords {
synchronized(buffer) {
buffer[0] = input.u0
buffer[1] = input.v0
buffer[2] = input.u1
buffer[3] = input.v1
return UVCoords(buffer[this.u0], buffer[this.v0], buffer[this.u1], buffer[this.v1])
}
}
fun translate(
input: MutableUVCoords
): MutableUVCoords {
synchronized(buffer) {
buffer[0] = input.u0
buffer[1] = input.v0
buffer[2] = input.u1
buffer[3] = input.v1
input[0] = buffer[this.u0]
input[1] = buffer[this.v0]
input[2] = buffer[this.u1]
input[3] = buffer[this.v1]
return input
}
}
}

View File

@ -8,9 +8,12 @@ import net.minecraft.world.item.ItemStack
import net.minecraftforge.client.extensions.common.IClientItemExtensions
import org.lwjgl.opengl.GL11
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.RGBAColor
import ru.dbotthepony.mc.otm.client.render.RenderHelper
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.render.drawColor
import ru.dbotthepony.mc.otm.client.render.drawRect
import ru.dbotthepony.mc.otm.client.render.drawTexturedRectAuto
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.core.RGBAColor
abstract class AbstractSlotPanel @JvmOverloads constructor(
screen: MatteryScreen<*>,
@ -23,7 +26,8 @@ abstract class AbstractSlotPanel @JvmOverloads constructor(
screen, parent, x, y, width, height
) {
protected open fun renderSlotBackground(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
RenderHelper.drawRegularSlot(stack, 0f, 0f)
RenderSystem.setShaderTexture(0, WidgetLocation.WIDGETS)
drawTexturedRectAuto(stack, 0f, 0f, 18f, 18f, 0f, 96f, 256f, 256f)
}
protected open fun renderRegular(stack: PoseStack, itemstack: ItemStack, count_override: String? = null) {
@ -68,8 +72,8 @@ abstract class AbstractSlotPanel @JvmOverloads constructor(
if (isHovered) {
stack.pushPose()
stack.translate(0.0, 0.0, zHeight)
RenderHelper.setDrawColor(SLOT_HIGHLIGHT)
RenderHelper.drawRect(stack, 1f, 1f, width - 1, height - 1)
drawColor = SLOT_HIGHLIGHT
drawRect(stack, 1f, 1f, width - 1, height - 1)
stack.popPose()
}
}

View File

@ -5,8 +5,8 @@ import net.minecraft.client.resources.sounds.SimpleSoundInstance
import net.minecraft.network.chat.Component
import net.minecraft.sounds.SoundEvents
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.RenderHelper
import ru.dbotthepony.mc.otm.client.render.SkinElement
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.CheckBoxPanel.Companion.REGULAR_DIMENSIONS
import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget
@ -41,7 +41,7 @@ open class CheckBoxPanel(
const val REGULAR_DIMENSIONS = 15f
val CHECKBOX_UNCHECKED = SkinElement(
RenderHelper.WIDGETS,
WidgetLocation.WIDGETS,
x = 18f,
y = 65f,
w = REGULAR_DIMENSIONS,
@ -49,7 +49,7 @@ open class CheckBoxPanel(
)
val CHECKBOX_CHECKED = SkinElement(
RenderHelper.WIDGETS,
WidgetLocation.WIDGETS,
x = 18f,
y = 80f,
w = REGULAR_DIMENSIONS,

View File

@ -7,7 +7,8 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.gui.Font
import net.minecraft.client.gui.components.events.GuiEventListener
import org.apache.logging.log4j.LogManager
import ru.dbotthepony.mc.otm.client.render.RenderHelper
import ru.dbotthepony.mc.otm.client.render.popScissorRect
import ru.dbotthepony.mc.otm.client.render.pushScissorRect
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import kotlin.math.max
@ -280,7 +281,7 @@ open class EditablePanel @JvmOverloads constructor(
if (scissor) {
val scale = Minecraft.getInstance().window.guiScale
RenderHelper.pushScissorRect(
pushScissorRect(
(absoluteX * scale).toInt(),
(absoluteY * scale).toInt(),
(width * scale).toInt() + 1,
@ -305,7 +306,7 @@ open class EditablePanel @JvmOverloads constructor(
}
if (scissor) {
RenderHelper.popScissorRect()
popScissorRect()
}
return depth

View File

@ -293,17 +293,17 @@ open class FramePanel(
const val PADDING = 8f
const val PADDING_TOP = 14f
val top_left_window_corner = SkinElement(RenderHelper.WIDGETS, x = 18f, y = 0f, w = 6f, h = 6f)
val top_right_window_corner = SkinElement(RenderHelper.WIDGETS, x = 24f, y = 0f, w = 6f, h = 6f)
val left_window_border = SkinElement(RenderHelper.WIDGETS, x = 18f, y = 4f, w = 3f, h = 5f)
val right_window_border = SkinElement(RenderHelper.WIDGETS, x = 27f, y = 3f, w = 3f, h = 5f)
val top_window_border = SkinElement(RenderHelper.WIDGETS, x = 22f, y = 0f, w = 5f, h = 3f)
val window_background = SkinElement(RenderHelper.WIDGETS, x = 30f, y = 12f, w = 6f, h = 6f)
val tab_right_connection = SkinElement(RenderHelper.WIDGETS, x = 30f, y = 0f, w = 3f, h = 5f)
val tab_left_connection = SkinElement(RenderHelper.WIDGETS, x = 33f, y = 0f, w = 3f, h = 5f)
val tab_background = SkinElement(RenderHelper.WIDGETS, x = 30f, y = 6f, w = 6f, h = 6f)
val bottom_left_window_corner = SkinElement(RenderHelper.WIDGETS, x = 18f, y = 6f, w = 6f, h = 6f)
val bottom_right_window_corner = SkinElement(RenderHelper.WIDGETS, x = 24f, y = 6f, w = 6f, h = 6f)
val bottom_window_border = SkinElement(RenderHelper.WIDGETS, x = 21f, y = 9f, w = 5f, h = 3f)
val top_left_window_corner = WidgetLocation.WIDGETS.element(x = 18f, y = 0f, w = 6f, h = 6f)
val top_right_window_corner = WidgetLocation.WIDGETS.element(x = 24f, y = 0f, w = 6f, h = 6f)
val left_window_border = WidgetLocation.WIDGETS.element(x = 18f, y = 4f, w = 3f, h = 5f)
val right_window_border = WidgetLocation.WIDGETS.element(x = 27f, y = 3f, w = 3f, h = 5f)
val top_window_border = WidgetLocation.WIDGETS.element(x = 22f, y = 0f, w = 5f, h = 3f)
val window_background = WidgetLocation.WIDGETS.element(x = 30f, y = 12f, w = 6f, h = 6f)
val tab_right_connection = WidgetLocation.WIDGETS.element(x = 30f, y = 0f, w = 3f, h = 5f)
val tab_left_connection = WidgetLocation.WIDGETS.element(x = 33f, y = 0f, w = 3f, h = 5f)
val tab_background = WidgetLocation.WIDGETS.element(x = 30f, y = 6f, w = 6f, h = 6f)
val bottom_left_window_corner = WidgetLocation.WIDGETS.element(x = 18f, y = 6f, w = 6f, h = 6f)
val bottom_right_window_corner = WidgetLocation.WIDGETS.element(x = 24f, y = 6f, w = 6f, h = 6f)
val bottom_window_border = WidgetLocation.WIDGETS.element(x = 21f, y = 9f, w = 5f, h = 3f)
}
}
}

View File

@ -140,12 +140,12 @@ open class ScrollBarPanel(screen: MatteryScreen<*>, parent: EditablePanel?, x: F
companion object {
const val WIDTH = 14f
val scroll_bar_top = RenderHelper.SCROLL.element(0f, 45f, 14f, 2f, 14f, 53f)
val scroll_bar_body = RenderHelper.SCROLL.element(0f, 46f, 14f, 6f, 14f, 53f)
val scroll_bar_bottom = RenderHelper.SCROLL.element(0f, 51f, 14f, 2f, 14f, 53f)
val scroll_bar_top = WidgetLocation.SCROLL.element(0f, 45f, 14f, 2f, 14f, 53f)
val scroll_bar_body = WidgetLocation.SCROLL.element(0f, 46f, 14f, 6f, 14f, 53f)
val scroll_bar_bottom = WidgetLocation.SCROLL.element(0f, 51f, 14f, 2f, 14f, 53f)
val scroll_bar_button = RenderHelper.SCROLL.element(0f, 0f, 12f, 15f, 14f, 53f)
val scroll_bar_button_hover = RenderHelper.SCROLL.element(0f, 15f, 12f, 15f, 14f, 53f)
val scroll_bar_button_press = RenderHelper.SCROLL.element(0f, 30f, 12f, 15f, 14f, 53f)
val scroll_bar_button = WidgetLocation.SCROLL.element(0f, 0f, 12f, 15f, 14f, 53f)
val scroll_bar_button_hover = WidgetLocation.SCROLL.element(0f, 15f, 12f, 15f, 14f, 53f)
val scroll_bar_button_press = WidgetLocation.SCROLL.element(0f, 30f, 12f, 15f, 14f, 53f)
}
}

View File

@ -6,7 +6,8 @@ import net.minecraft.ChatFormatting
import net.minecraft.client.renderer.GameRenderer
import net.minecraft.world.inventory.AbstractContainerMenu
import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.client.render.RenderHelper
import ru.dbotthepony.mc.otm.client.render.drawRect
import ru.dbotthepony.mc.otm.client.render.setDrawColor
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.menu.MatterySlot
import javax.annotation.Nonnull
@ -83,8 +84,8 @@ class SlotPanel<T : MatterySlot>(
RenderSystem.setShader(GameRenderer::getPositionTexShader)
if (dragHit) {
RenderHelper.setDrawColor(SLOT_HIGHLIGHT_DRAG)
RenderHelper.drawRect(stack, 1f, 1f, width - 1, height - 1)
setDrawColor(SLOT_HIGHLIGHT_DRAG)
drawRect(stack, 1f, 1f, width - 1, height - 1)
}
renderRegular(stack, itemstack, countOverride)

View File

@ -5,10 +5,11 @@ import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.ChatFormatting
import net.minecraft.network.chat.Component
import ru.dbotthepony.mc.otm.TranslatableComponent
import ru.dbotthepony.mc.otm.client.render.RenderHelper
import ru.dbotthepony.mc.otm.client.render.SkinElement
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.render.element
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.core.formatMatterLevel
import ru.dbotthepony.mc.otm.core.formatPowerLevel
@ -49,8 +50,8 @@ open class PowerGaugePanel @JvmOverloads constructor(
}
companion object {
val GAUGE_BACKGROUND = SkinElement(RenderHelper.WIDGETS, x = 0f, y = 48f, w = 9f, h = 48f)
val GAUGE_FOREGROUND = SkinElement(RenderHelper.WIDGETS, x = 9f, y = 48f, w = 9f, h = 48f)
val GAUGE_BACKGROUND = WidgetLocation.WIDGETS.element(x = 0f, y = 48f, w = 9f, h = 48f)
val GAUGE_FOREGROUND = WidgetLocation.WIDGETS.element(x = 9f, y = 48f, w = 9f, h = 48f)
}
}
@ -88,8 +89,8 @@ open class MatterGaugePanel @JvmOverloads constructor(
}
companion object {
val GAUGE_BACKGROUND = SkinElement(RenderHelper.WIDGETS, x = 0f, y = 0f, w = 9f, h = 48f)
val GAUGE_FOREGROUND = SkinElement(RenderHelper.WIDGETS, x = 9f, y = 0f, w = 9f, h = 48f)
val GAUGE_BACKGROUND = WidgetLocation.WIDGETS.element(x = 0f, y = 0f, w = 9f, h = 48f)
val GAUGE_FOREGROUND = WidgetLocation.WIDGETS.element(x = 9f, y = 0f, w = 9f, h = 48f)
}
}
@ -127,8 +128,8 @@ open class PatternGaugePanel @JvmOverloads constructor(
}
companion object {
val GAUGE_BACKGROUND = SkinElement(RenderHelper.WIDGETS, x = 0f, y = 148f, w = 9f, h = 48f)
val GAUGE_FOREGROUND = SkinElement(RenderHelper.WIDGETS, x = 9f, y = 148f, w = 9f, h = 48f)
val GAUGE_BACKGROUND = WidgetLocation.WIDGETS.element(x = 0f, y = 148f, w = 9f, h = 48f)
val GAUGE_FOREGROUND = WidgetLocation.WIDGETS.element(x = 9f, y = 148f, w = 9f, h = 48f)
}
}
@ -198,7 +199,7 @@ open class ProgressGaugePanel @JvmOverloads constructor(
}
companion object {
val GAUGE_BACKGROUND = SkinElement(RenderHelper.WIDGETS, x = 0f, y = 132f, w = 22f, h = 16f)
val GAUGE_FOREGROUND = SkinElement(RenderHelper.WIDGETS, x = 22f, y = 132f, w = 22f, h = 16f)
val GAUGE_BACKGROUND = WidgetLocation.WIDGETS.element(x = 0f, y = 132f, w = 22f, h = 16f)
val GAUGE_FOREGROUND = WidgetLocation.WIDGETS.element(x = 22f, y = 132f, w = 22f, h = 16f)
}
}

View File

@ -1,7 +1,6 @@
package ru.dbotthepony.mc.otm.core
import com.mojang.blaze3d.systems.RenderSystem
import ru.dbotthepony.mc.otm.client.render.RenderHelper
data class RGBAColor(val red: Float, val green: Float, val blue: Float, val alpha: Float = 1f) {
constructor(r: Int, g: Int, b: Int) : this((r / 255f), (g / 255f), (b / 255f), 1f)
@ -38,7 +37,7 @@ data class RGBAColor(val red: Float, val green: Float, val blue: Float, val alph
}
fun setDrawColor() {
RenderHelper.setDrawColor(this)
ru.dbotthepony.mc.otm.client.render.setDrawColor(this)
}
fun linearInterpolation(t: Float, other: RGBAColor): RGBAColor {

View File

@ -27,7 +27,8 @@ import net.minecraftforge.network.NetworkEvent
import ru.dbotthepony.mc.otm.*
import ru.dbotthepony.mc.otm.capability.matteryEnergy
import ru.dbotthepony.mc.otm.client.font
import ru.dbotthepony.mc.otm.client.render.RenderHelper
import ru.dbotthepony.mc.otm.client.render.drawRect
import ru.dbotthepony.mc.otm.client.render.setDrawColor
import ru.dbotthepony.mc.otm.core.*
import ru.dbotthepony.mc.otm.core.Vector
import ru.dbotthepony.mc.otm.network.MatteryNetworking
@ -450,8 +451,8 @@ abstract class AbstractWeaponItem<D : WeaponDataTable>(val tables: KClass<D>, ra
pose.mulPose(Vector3f.YP.rotationDegrees(180f))
pose.scale(0.01f, 0.01f, 0.01f)
RenderHelper.setDrawColor(holoHudBackground)
RenderHelper.drawRect(pose, -2f, -2f, 72f, 34f)
setDrawColor(holoHudBackground)
drawRect(pose, -2f, -2f, 72f, 34f)
stack.matteryEnergy?.let {
pose.pushPose()
@ -464,12 +465,12 @@ abstract class AbstractWeaponItem<D : WeaponDataTable>(val tables: KClass<D>, ra
pose.translate(60.0, 0.0, 0.0)
RenderHelper.setDrawColor(heatBackground)
RenderHelper.drawRect(pose, -1f, -1f, 9f, 32f)
setDrawColor(heatBackground)
drawRect(pose, -1f, -1f, 9f, 32f)
val heat = item.heatProgress(stack, event.partialTick.toDouble()).toFloat()
RenderHelper.setDrawColor(linearInterpolation(heat, initialHeatColor, finalHeatColor))
RenderHelper.drawRect(pose, 0f, 30f * (1f - heat), 7f, 30f * heat)
setDrawColor(linearInterpolation(heat, initialHeatColor, finalHeatColor))
drawRect(pose, 0f, 30f * (1f - heat), 7f, 30f * heat)
}
pose.popPose()

View File

@ -12,7 +12,6 @@ import ru.dbotthepony.mc.otm.android.AndroidResearch
import ru.dbotthepony.mc.otm.android.AndroidResearchType
import ru.dbotthepony.mc.otm.capability.AndroidCapability
import ru.dbotthepony.mc.otm.capability.android
import ru.dbotthepony.mc.otm.capability.android.*
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.ImpreciseFraction
import ru.dbotthepony.mc.otm.core.readImpreciseFraction