aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-08-12 01:32:26 +0200
committerLinnea Gräf <nea@nea.moe>2025-08-12 01:32:26 +0200
commitf9686df919a6b80e7c788ec66f25dd8296e95c41 (patch)
tree5c1f313c5e9cd77954129fcf06165fe31580c7ea /src/main/kotlin/util
parent6d0c39c46fe090cf4394fda61bfe6de50799cfc6 (diff)
parent98a080099683f9354ec4e02e47ff39b30caa8590 (diff)
downloadFirmament-f9686df919a6b80e7c788ec66f25dd8296e95c41.tar.gz
Firmament-f9686df919a6b80e7c788ec66f25dd8296e95c41.tar.bz2
Firmament-f9686df919a6b80e7c788ec66f25dd8296e95c41.zip
refactor: merge 1.21.5 changes back into 1.21.7
Diffstat (limited to 'src/main/kotlin/util')
-rw-r--r--src/main/kotlin/util/render/CustomRenderLayers.kt3
-rw-r--r--src/main/kotlin/util/render/RenderInWorldContext.kt114
-rw-r--r--src/main/kotlin/util/skyblock/SkyBlockItems.kt1
3 files changed, 82 insertions, 36 deletions
diff --git a/src/main/kotlin/util/render/CustomRenderLayers.kt b/src/main/kotlin/util/render/CustomRenderLayers.kt
index a133cbf..d88a1e4 100644
--- a/src/main/kotlin/util/render/CustomRenderLayers.kt
+++ b/src/main/kotlin/util/render/CustomRenderLayers.kt
@@ -87,8 +87,7 @@ object CustomRenderLayers {
val COLORED_QUADS = RenderLayer.of(
"firmament_quads",
RenderLayer.DEFAULT_BUFFER_SIZE,
- false,
- true,
+ false, true,
CustomRenderPipelines.COLORED_OMNIPRESENT_QUADS,
RenderLayer.MultiPhaseParameters.builder()
.lightmap(RenderPhase.DISABLE_LIGHTMAP)
diff --git a/src/main/kotlin/util/render/RenderInWorldContext.kt b/src/main/kotlin/util/render/RenderInWorldContext.kt
index 1077060..0898190 100644
--- a/src/main/kotlin/util/render/RenderInWorldContext.kt
+++ b/src/main/kotlin/util/render/RenderInWorldContext.kt
@@ -18,7 +18,6 @@ import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Vec3d
import moe.nea.firmament.events.WorldRenderLastEvent
import moe.nea.firmament.util.FirmFormatters
-import moe.nea.firmament.util.IntUtil.toRGBA
import moe.nea.firmament.util.MC
@RenderContextDSL
@@ -35,6 +34,38 @@ class RenderInWorldContext private constructor(
matrixStack.pop()
}
+ fun sharedVoxelSurface(blocks: Set<BlockPos>, color: Int) {
+ val m = BlockPos.Mutable()
+ val l = vertexConsumers.getBuffer(CustomRenderLayers.COLORED_QUADS)
+ blocks.forEach {
+ matrixStack.push()
+ matrixStack.translate(it.x.toFloat(), it.y.toFloat(), it.z.toFloat())
+ val p = matrixStack.peek().positionMatrix
+ m.set(it)
+ if (m.setX(it.x + 1) !in blocks) {
+ buildFaceXP(p, l, color)
+ }
+ if (m.setX(it.x - 1) !in blocks) {
+ buildFaceXN(p, l, color)
+ }
+ m.set(it)
+ if (m.setY(it.y + 1) !in blocks) {
+ buildFaceYP(p, l, color)
+ }
+ if (m.setY(it.y - 1) !in blocks) {
+ buildFaceYN(p, l, color)
+ }
+ m.set(it)
+ if (m.setZ(it.z + 1) !in blocks) {
+ buildFaceZP(p, l, color)
+ }
+ if (m.setZ(it.z - 1) !in blocks) {
+ buildFaceZN(p, l, color)
+ }
+ matrixStack.pop()
+ }
+ }
+
enum class VerticalAlign {
TOP, BOTTOM, CENTER;
@@ -192,41 +223,56 @@ class RenderInWorldContext private constructor(
}
}
- private fun buildCube(matrix: Matrix4f, buf: VertexConsumer, colorInt: Int) {
- val (r, g, b, a) = colorInt.toRGBA()
-
- // Y-
- buf.vertex(matrix, 0F, 0F, 0F).color(r, g, b, a)
- buf.vertex(matrix, 0F, 0F, 1F).color(r, g, b, a)
- buf.vertex(matrix, 1F, 0F, 1F).color(r, g, b, a)
- buf.vertex(matrix, 1F, 0F, 0F).color(r, g, b, a)
- // Y+
- buf.vertex(matrix, 0F, 1F, 0F).color(r, g, b, a)
- buf.vertex(matrix, 1F, 1F, 0F).color(r, g, b, a)
- buf.vertex(matrix, 1F, 1F, 1F).color(r, g, b, a)
- buf.vertex(matrix, 0F, 1F, 1F).color(r, g, b, a)
- // X-
- buf.vertex(matrix, 0F, 0F, 0F).color(r, g, b, a)
- buf.vertex(matrix, 0F, 0F, 1F).color(r, g, b, a)
- buf.vertex(matrix, 0F, 1F, 1F).color(r, g, b, a)
- buf.vertex(matrix, 0F, 1F, 0F).color(r, g, b, a)
- // X+
- buf.vertex(matrix, 1F, 0F, 0F).color(r, g, b, a)
- buf.vertex(matrix, 1F, 1F, 0F).color(r, g, b, a)
- buf.vertex(matrix, 1F, 1F, 1F).color(r, g, b, a)
- buf.vertex(matrix, 1F, 0F, 1F).color(r, g, b, a)
- // Z-
- buf.vertex(matrix, 0F, 0F, 0F).color(r, g, b, a)
- buf.vertex(matrix, 1F, 0F, 0F).color(r, g, b, a)
- buf.vertex(matrix, 1F, 1F, 0F).color(r, g, b, a)
- buf.vertex(matrix, 0F, 1F, 0F).color(r, g, b, a)
- // Z+
- buf.vertex(matrix, 0F, 0F, 1F).color(r, g, b, a)
- buf.vertex(matrix, 0F, 1F, 1F).color(r, g, b, a)
- buf.vertex(matrix, 1F, 1F, 1F).color(r, g, b, a)
- buf.vertex(matrix, 1F, 0F, 1F).color(r, g, b, a)
+ private fun buildFaceZP(matrix: Matrix4f, buf: VertexConsumer, rgba: Int) {
+ buf.vertex(matrix, 0F, 0F, 1F).color(rgba)
+ buf.vertex(matrix, 0F, 1F, 1F).color(rgba)
+ buf.vertex(matrix, 1F, 1F, 1F).color(rgba)
+ buf.vertex(matrix, 1F, 0F, 1F).color(rgba)
+ }
+
+ private fun buildFaceZN(matrix: Matrix4f, buf: VertexConsumer, rgba: Int) {
+ buf.vertex(matrix, 0F, 0F, 0F).color(rgba)
+ buf.vertex(matrix, 1F, 0F, 0F).color(rgba)
+ buf.vertex(matrix, 1F, 1F, 0F).color(rgba)
+ buf.vertex(matrix, 0F, 1F, 0F).color(rgba)
+ }
+
+ private fun buildFaceXP(matrix: Matrix4f, buf: VertexConsumer, rgba: Int) {
+ buf.vertex(matrix, 1F, 0F, 0F).color(rgba)
+ buf.vertex(matrix, 1F, 1F, 0F).color(rgba)
+ buf.vertex(matrix, 1F, 1F, 1F).color(rgba)
+ buf.vertex(matrix, 1F, 0F, 1F).color(rgba)
+ }
+
+ private fun buildFaceXN(matrix: Matrix4f, buf: VertexConsumer, rgba: Int) {
+ buf.vertex(matrix, 0F, 0F, 0F).color(rgba)
+ buf.vertex(matrix, 0F, 0F, 1F).color(rgba)
+ buf.vertex(matrix, 0F, 1F, 1F).color(rgba)
+ buf.vertex(matrix, 0F, 1F, 0F).color(rgba)
}
+ private fun buildFaceYN(matrix: Matrix4f, buf: VertexConsumer, rgba: Int) {
+ buf.vertex(matrix, 0F, 0F, 0F).color(rgba)
+ buf.vertex(matrix, 0F, 0F, 1F).color(rgba)
+ buf.vertex(matrix, 1F, 0F, 1F).color(rgba)
+ buf.vertex(matrix, 1F, 0F, 0F).color(rgba)
+ }
+
+ private fun buildFaceYP(matrix: Matrix4f, buf: VertexConsumer, rgba: Int) {
+ buf.vertex(matrix, 0F, 1F, 0F).color(rgba)
+ buf.vertex(matrix, 1F, 1F, 0F).color(rgba)
+ buf.vertex(matrix, 1F, 1F, 1F).color(rgba)
+ buf.vertex(matrix, 0F, 1F, 1F).color(rgba)
+ }
+
+ private fun buildCube(matrix4f: Matrix4f, buf: VertexConsumer, rgba: Int) {
+ buildFaceXP(matrix4f, buf, rgba)
+ buildFaceXN(matrix4f, buf, rgba)
+ buildFaceYP(matrix4f, buf, rgba)
+ buildFaceYN(matrix4f, buf, rgba)
+ buildFaceZP(matrix4f, buf, rgba)
+ buildFaceZN(matrix4f, buf, rgba)
+ }
fun renderInWorld(event: WorldRenderLastEvent, block: RenderInWorldContext. () -> Unit) {
diff --git a/src/main/kotlin/util/skyblock/SkyBlockItems.kt b/src/main/kotlin/util/skyblock/SkyBlockItems.kt
index d552fd7..32c4aab 100644
--- a/src/main/kotlin/util/skyblock/SkyBlockItems.kt
+++ b/src/main/kotlin/util/skyblock/SkyBlockItems.kt
@@ -19,5 +19,6 @@ object SkyBlockItems {
val BONE_BOOMERANG = SkyblockId("BONE_BOOMERANG")
val STARRED_BONE_BOOMERANG = SkyblockId("STARRED_BONE_BOOMERANG")
val TRIBAL_SPEAR = SkyblockId("TRIBAL_SPEAR")
+ val BLOCK_ZAPPER = SkyblockId("BLOCK_ZAPPER")
val HUNTING_TOOLKIT = SkyblockId("HUNTING_TOOLKIT")
}