Port to 1.21

This commit is contained in:
desyncfy
2024-08-17 10:59:09 -07:00
parent 242fabdadb
commit 9e02764180
6 changed files with 33 additions and 34 deletions

View File

@@ -47,46 +47,44 @@ class Bars {
val yHealth = 5f
val xReality = 5f
val yReality = 10f + height
HudRenderCallback.EVENT.register(HudRenderCallback { drawContext: DrawContext?, _: Float ->
HudRenderCallback.EVENT.register(HudRenderCallback { drawContext: DrawContext, _: RenderTickCounter ->
val tessellator: Tessellator = Tessellator.getInstance()
val buffer: BufferBuilder = tessellator.buffer
val positionMatrix = drawContext?.matrices?.peek()?.positionMatrix
val buffer: BufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR)
val positionMatrix = drawContext.matrices?.peek()?.positionMatrix
if (MinecraftClient.getInstance().networkHandler?.serverInfo?.address == "dungeonfy.minehut.gg" ||
MinecraftClient.getInstance().networkHandler?.serverInfo?.address == "51.222.121.148:25599" ||
MinecraftClient.getInstance().networkHandler?.serverInfo?.address == "minehut.com" ||
modDisableOverride) {
if (barsToggle) {
if (MinecraftClient.getInstance().networkHandler?.serverInfo?.address == "51.222.121.148:25599") {
buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE)
buffer.vertex(positionMatrix, xReality, yReality, 0f).color(1f, 1f, 1f, 1f).texture(0f, 0f).next()
buffer.vertex(positionMatrix, xReality, yReality + height, 0f).color(1f, 1f, 1f, 1f).texture(0f, 1f).next()
buffer.vertex(positionMatrix, xReality + width, yReality + height, 0f).color(1f, 1f, 1f, 1f).texture(1f, 1f).next()
buffer.vertex(positionMatrix, xReality + width, yReality, 0f).color(1f, 1f, 1f, 1f).texture(1f, 0f).next()
RenderSystem.setShader { GameRenderer.getPositionColorTexProgram() }
RenderSystem.setShaderTexture(0, Identifier("scify", "healthmana/mana/mana_${mana}.png"))
buffer.vertex(positionMatrix, xReality, yReality, 0f).color(1f, 1f, 1f, 1f).texture(0f, 0f)
buffer.vertex(positionMatrix, xReality, yReality + height, 0f).color(1f, 1f, 1f, 1f).texture(0f, 1f)
buffer.vertex(positionMatrix, xReality + width, yReality + height, 0f).color(1f, 1f, 1f, 1f).texture(1f, 1f)
buffer.vertex(positionMatrix, xReality + width, yReality, 0f).color(1f, 1f, 1f, 1f).texture(1f, 0f)
RenderSystem.setShader { GameRenderer.getPositionTexColorProgram() }
RenderSystem.setShaderTexture(0, Identifier.of("scify", "healthmana/mana/mana_${mana}.png"))
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
tessellator.draw()
BufferRenderer.drawWithGlobalProgram(buffer.end())
}
buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE)
/*buffer.vertex(positionMatrix, MinecraftClient.getInstance().window.scaledWidth.toFloat()/2-180, MinecraftClient.getInstance().window.scaledHeight.toFloat() - 40, 0F).color(1f, 1f, 1f, 1f).texture(0f, 0f).next()
buffer.vertex(positionMatrix, MinecraftClient.getInstance().window.scaledWidth.toFloat()/2-180, MinecraftClient.getInstance().window.scaledHeight.toFloat(), 0F).color(1f, 1f, 1f, 1f).texture(0f, 1f).next()
buffer.vertex(positionMatrix, MinecraftClient.getInstance().window.scaledWidth.toFloat()/2-140, MinecraftClient.getInstance().window.scaledHeight.toFloat(), 0F).color(1f, 1f, 1f, 1f).texture(1f, 1f).next()
buffer.vertex(positionMatrix, MinecraftClient.getInstance().window.scaledWidth.toFloat()/2-140, MinecraftClient.getInstance().window.scaledHeight.toFloat() - 40, 0F).color(1f, 1f, 1f, 1f).texture(1f, 0f).next()*/
buffer.vertex(positionMatrix, xHealth, yHealth, 0f).color(1f, 1f, 1f, 1f).texture(0f, 0f).next()
buffer.vertex(positionMatrix, xHealth, yHealth+height, 0f).color(1f, 1f, 1f, 1f).texture(0f, 1f).next()
buffer.vertex(positionMatrix, xHealth+width, yHealth+height, 0f).color(1f, 1f, 1f, 1f).texture(1f, 1f).next()
buffer.vertex(positionMatrix, xHealth+width, yHealth, 0f).color(1f, 1f, 1f, 1f).texture(1f, 0f).next()
buffer.vertex(positionMatrix, xHealth, yHealth, 0f).color(1f, 1f, 1f, 1f).texture(0f, 0f)
buffer.vertex(positionMatrix, xHealth, yHealth+height, 0f).color(1f, 1f, 1f, 1f).texture(0f, 1f)
buffer.vertex(positionMatrix, xHealth+width, yHealth+height, 0f).color(1f, 1f, 1f, 1f).texture(1f, 1f)
buffer.vertex(positionMatrix, xHealth+width, yHealth, 0f).color(1f, 1f, 1f, 1f).texture(1f, 0f)
val maxHealthDivided = MinecraftClient.getInstance().player?.maxHealth?.div(20)?.toInt()
val health = if (MinecraftClient.getInstance().player?.health?.toInt()?.div(maxHealthDivided!!)!! <= 20) MinecraftClient.getInstance().player?.health?.toInt()?.div(maxHealthDivided!!) else 20
RenderSystem.setShader { GameRenderer.getPositionColorTexProgram() }
RenderSystem.setShaderTexture(0, Identifier("scify", "healthmana/health/health_${health}.png"))
RenderSystem.setShader { GameRenderer.getPositionTexColorProgram() }
RenderSystem.setShaderTexture(0, Identifier.of("scify", "healthmana/health/health_${health}.png"))
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
tessellator.draw()
BufferRenderer.drawWithGlobalProgram(buffer.end())
}
}
})
/*HudRenderCallback.EVENT.register(HudRenderCallback { drawContext: DrawContext, _: RenderTickCounter ->
val color = -0x10000 // Red
drawContext.fill(0, 0, 100, 100, 0, color)
})*/
}
}