repo for my hex addons :3
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

handrolled rendering

+283 -225
+2
build.gradle.kts
··· 190 190 include(modImplementation("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_version")}+$minecraft_version")!!) 191 191 include(modApi("dev.onyxstudios.cardinal-components-api:cardinal-components-base:$cca_version")!!) 192 192 include(modApi("dev.onyxstudios.cardinal-components-api:cardinal-components-world:$cca_version")!!) 193 + include("maven.modrinth:cardinal-components-api:$cca_version") 193 194 include(modImplementation("com.github.Chocohead:Fabric-ASM:v2.3")!!) 195 + // include(modImplementation("maven.modrinth:familiar-magic:1.1.4")!!) 194 196 //include(modImplementation("io.github.0x3c50.renderer:renderer-fabric:2.1.2")!!) 195 197 //mergedDeps("org.scala-lang:scala-library:2.12.21-M2") 196 198 //include("org.scala-lang:scala-library:2.12.21-M2")
+2 -2
gradle.properties
··· 17 17 kotlin_loader_version=1.13.4+kotlin.2.2.0 18 18 scala_loader_version=0.3.1.11 19 19 # Mod Properties 20 - mod_version=0.0.6 21 - maven_group=org.net.eu.pool.mica 20 + mod_version=0.0.7 21 + maven_group=org.eu.net.pool 22 22 archives_base_name=mica 23 23 # Dependencies 24 24 # check this on https://modmuss50.me/fabric.html
+4 -1
src/client/resources/mica.client.mixins.json
··· 9 9 }, 10 10 "overwrites": { 11 11 "requireAnnotations": true 12 - } 12 + }, 13 + "client": [ 14 + "WorldRendererMixin" 15 + ] 13 16 }
+223 -222
src/client/scala/org/net/eu/pool/mica/client/MicaClient.scala
··· 3 3 import com.google.gson.{JsonArray, JsonElement, JsonObject} 4 4 import com.mojang.blaze3d.systems.RenderSystem 5 5 import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricModelProvider 6 - import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents 6 + import net.fabricmc.fabric.api.client.rendering.v1.{WorldRenderContext, WorldRenderEvents} 7 7 import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator 8 8 import net.fabricmc.fabric.api.datagen.v1.provider.FabricAdvancementProvider 9 9 import net.fabricmc.fabric.api.renderer.v1.render.RenderLayerHelper ··· 40 40 case class Vertex(pos: V3, uv: UV, color: RGB, light: I2, overlay: I2) 41 41 42 42 given runeExt: AnyRef with 43 - extension (r: Rune) 44 - def spriteTexture: Identifier = registryFor[Rune].getId(r).withPrefixedPath("block/rune_") 45 - def sprite: Sprite = blockAtlas(r.spriteTexture) 46 - def surface: Sprite = blockAtlas(r.surfaceSprite) 43 + extension (r: Rune) 44 + def spriteTexture: Identifier = registryFor[Rune].getId(r).withPrefixedPath("block/rune_") 45 + def sprite: Sprite = blockAtlas(r.spriteTexture) 46 + def surface: Sprite = blockAtlas(r.surfaceSprite) 47 47 48 48 class Renderer(val buffer: VertexConsumer, val matrices: MatrixStack): 49 - var sprite: Option[Sprite] = None 49 + var sprite: Option[Sprite] = None 50 50 51 - def forSprite(uv: UV): UV = 52 - sprite match 53 - case Some(value) => ( 54 - u = MathHelper.lerp(uv.u, value.getMinU, value.getMaxU), 55 - v = MathHelper.lerp(uv.v, value.getMinV, value.getMaxV), 56 - ) 57 - case None => uv 51 + def forSprite(uv: UV): UV = 52 + sprite match 53 + case Some(value) => ( 54 + u = MathHelper.lerp(uv.u, value.getMinU, value.getMaxU), 55 + v = MathHelper.lerp(uv.v, value.getMinV, value.getMaxV), 56 + ) 57 + case None => uv 58 58 59 - def vert(vertex: Vertex, normal: V3): Unit = 60 - val Vertex(pos, uv, color, light, overlay) = vertex 61 - val newUV = forSprite(uv) 62 - buffer.vertex(matrices.peek, pos.x, pos.y, pos.z) 63 - .texture(newUV.u, newUV.v) 64 - .color(color.r, color.g, color.b, color.a) 65 - .light(light._1, light._2) 66 - .overlay(overlay._1, overlay._2) 67 - .normal(matrices.peek, normal.x, normal.y, normal.z) 59 + def vert(vertex: Vertex, normal: V3): Unit = 60 + val Vertex(pos, uv, color, light, overlay) = vertex 61 + val newUV = forSprite(uv) 62 + buffer.vertex(matrices.peek, pos.x, pos.y, pos.z) 63 + .texture(newUV.u, newUV.v) 64 + .color(color.r, color.g, color.b, color.a) 65 + .light(light._1, light._2) 66 + .overlay(overlay._1, overlay._2) 67 + .normal(matrices.peek, normal.x, normal.y, normal.z) 68 68 69 - // vtx0 ─── vtx1 70 - // │ │ 71 - // vtx3 ─── vtx2 72 - def quad(vtx0: Vertex, vtx1: Vertex, vtx2: Vertex, vtx3: Vertex, normal: V3): Unit = 73 - vert(vtx0, normal) 74 - vert(vtx1, normal) 75 - vert(vtx2, normal) 76 - vert(vtx3, normal) 69 + // vtx0 ─── vtx1 70 + // │ │ 71 + // vtx3 ─── vtx2 72 + def quad(vtx0: Vertex, vtx1: Vertex, vtx2: Vertex, vtx3: Vertex, normal: V3): Unit = 73 + vert(vtx0, normal) 74 + vert(vtx1, normal) 75 + vert(vtx2, normal) 76 + vert(vtx3, normal) 77 77 78 - def rect(vtx0: Vertex, vtx1: Vertex, vtx2: Vertex, normal: V3): Unit = 79 - // vtx0 ─── vtx1 80 - // │ │ 81 - // vtx3 ─── vtx2 82 - val vtx3 = Vertex(pos = vtx0.pos + (vtx2.pos - vtx1.pos), uv = vtx0.uv + (vtx2.uv - vtx1.uv), color = vtx1.color, light = vtx1.light, overlay = vtx1.overlay) 83 - quad(vtx0, vtx1, vtx2, vtx3, normal = normal) 78 + def rect(vtx0: Vertex, vtx1: Vertex, vtx2: Vertex, normal: V3): Unit = 79 + // vtx0 ─── vtx1 80 + // │ │ 81 + // vtx3 ─── vtx2 82 + val vtx3 = Vertex(pos = vtx0.pos + (vtx2.pos - vtx1.pos), uv = vtx0.uv + (vtx2.uv - vtx1.uv), color = vtx1.color, light = vtx1.light, overlay = vtx1.overlay) 83 + quad(vtx0, vtx1, vtx2, vtx3, normal = normal) 84 84 object Renderer: 85 - def get(using VertexConsumer, MatrixStack): Renderer = Renderer(summon, summon) 86 - def forLayer(layer: RenderLayer)(using p: VertexConsumerProvider, m: MatrixStack) = Renderer(p.getBuffer(layer), m) 85 + def get(using VertexConsumer, MatrixStack): Renderer = Renderer(summon, summon) 86 + def forLayer(layer: RenderLayer)(using p: VertexConsumerProvider, m: MatrixStack) = Renderer(p.getBuffer(layer), m) 87 87 88 88 given v3Ext: AnyRef with 89 - extension (v: V3) 90 - def +(other: V3): V3 = 91 - (x = v.x + other.x, y = v.y + other.y, z = v.z + other.z) 92 - def -(other: V3): V3 = 93 - (x = v.x - other.x, y = v.y - other.y, z = v.z - other.z) 89 + extension (v: V3) 90 + def +(other: V3): V3 = 91 + (x = v.x + other.x, y = v.y + other.y, z = v.z + other.z) 92 + def -(other: V3): V3 = 93 + (x = v.x - other.x, y = v.y - other.y, z = v.z - other.z) 94 94 given uvExt: AnyRef with 95 - extension (v: UV) 96 - def +(other: UV): UV = 97 - (u = v.u + other.u, v = v.v + other.v) 98 - def -(other: UV): UV = 99 - (u = v.u - other.u, v = v.v - other.v) 95 + extension (v: UV) 96 + def +(other: UV): UV = 97 + (u = v.u + other.u, v = v.v + other.v) 98 + def -(other: UV): UV = 99 + (u = v.u - other.u, v = v.v - other.v) 100 100 101 101 inline def withMatrices[T](body: => T)(using m: MatrixStack): T = 102 - m.push() 103 - try 104 - body 105 - finally 106 - m.pop() 102 + m.push() 103 + try 104 + body 105 + finally 106 + m.pop() 107 107 108 - def init(): Unit = 109 - WorldRenderEvents.BEFORE_ENTITIES.register: ctx => 110 - given matrices: MatrixStack = ctx.matrixStack 111 - given VertexConsumerProvider = ctx.consumers 112 - given r: Renderer = Renderer.forLayer(TexturedRenderLayers.getEntityCutout) 113 - withMatrices: 114 - matrices.translate(ctx.camera.getPos.negate) 115 - var cur = BlockPos.Mutable() 116 - RenderSystem.teardownOverlayColor() 117 - for (k, i) <- AbstractRuneStorage.keys.zipWithIndex do 118 - val c: AbstractRuneStorage = ctx.world.getComponent(k) 119 - withMatrices: 120 - val shift = RuneShift(i) 121 - matrices.translate(shift.x / 4.0, shift.y / 8.0, shift.z / 4.0) 122 - c.contents.forEach: (pos, rune) => 123 - cur.set(pos) 124 - // TODO: more quads 125 - withMatrices: 126 - matrices.translate(cur.getX, cur.getY, cur.getZ) 127 - val color: RGB = (1, 1, 1, 1) 128 - val light: I2 = (255, 0) 129 - val overlay: I2 = (0, 10) // magic number owo scary 130 - r.sprite = Some(rune.surface) 131 - r.quad( 132 - Vertex(pos = (-0.25f, 0.125f, -0.25f), uv = (0, 0), color = color, light = light, overlay = overlay), 133 - Vertex(pos = (-0.25f, 0.125f, 0.25f), uv = (0, 1), color = color, light = light, overlay = overlay), 134 - Vertex(pos = (0.25f, 0.125f, 0.25f), uv = (1, 1), color = color, light = light, overlay = overlay), 135 - Vertex(pos = (0.25f, 0.125f, -0.25f), uv = (1, 0), color = color, light = light, overlay = overlay), 136 - normal = (0, 1, 0), 137 - ) 138 - r.quad( 139 - Vertex(pos = (-0.25f, 0f, -0.25f), uv = (0, 0), color = color, light = light, overlay = overlay), 140 - Vertex(pos = (-0.25f, 0.125f, -0.25f), uv = (1, 0), color = color, light = light, overlay = overlay), 141 - Vertex(pos = (0.25f, 0.125f, -0.25f), uv = (1, 1), color = color, light = light, overlay = overlay), 142 - Vertex(pos = (0.25f, 0f, -0.25f), uv = (0, 1), color = color, light = light, overlay = overlay), 143 - normal = (0, 0, -1) 144 - ) 145 - r.sprite = Some(rune.sprite) 146 - r.quad( 147 - Vertex(pos = (-0.25f, 0.126f, -0.25f), uv = (0, 0), color = color, light = light, overlay = overlay), 148 - Vertex(pos = (-0.25f, 0.126f, 0.25f), uv = (0, 1), color = color, light = light, overlay = overlay), 149 - Vertex(pos = (0.25f, 0.126f, 0.25f), uv = (1, 1), color = color, light = light, overlay = overlay), 150 - Vertex(pos = (0.25f, 0.126f, -0.25f), uv = (1, 0), color = color, light = light, overlay = overlay), 151 - normal = (0, 1, 0), 152 - ) 153 - () 108 + def renderRunes(ctx: WorldRenderContext): Unit = 109 + given matrices: MatrixStack = ctx.matrixStack 110 + given VertexConsumerProvider = ctx.consumers 111 + given r: Renderer = Renderer.forLayer(TexturedRenderLayers.getEntityCutout) 112 + withMatrices: 113 + matrices.translate(ctx.camera.getPos.negate) 114 + var cur = BlockPos.Mutable() 115 + RenderSystem.teardownOverlayColor() 116 + for (k, i) <- AbstractRuneStorage.keys.zipWithIndex do 117 + val c: AbstractRuneStorage = ctx.world.getComponent(k) 118 + withMatrices: 119 + val shift = RuneShift(i) 120 + matrices.translate(shift.x / 4.0, shift.y / 8.0, shift.z / 4.0) 121 + c.contents.forEach: (pos, rune) => 122 + cur.set(pos) 123 + // TODO: more quads 124 + withMatrices: 125 + matrices.translate(cur.getX, cur.getY, cur.getZ) 126 + val color: RGB = (1, 1, 1, 1) 127 + val light: I2 = (255, 0) 128 + val overlay: I2 = (0, 10) // magic number owo scary 129 + r.sprite = Some(rune.surface) 130 + r.quad( 131 + Vertex(pos = (-0.25f, 0.125f, -0.25f), uv = (0, 0), color = color, light = light, overlay = overlay), 132 + Vertex(pos = (-0.25f, 0.125f, 0.25f), uv = (0, 1), color = color, light = light, overlay = overlay), 133 + Vertex(pos = (0.25f, 0.125f, 0.25f), uv = (1, 1), color = color, light = light, overlay = overlay), 134 + Vertex(pos = (0.25f, 0.125f, -0.25f), uv = (1, 0), color = color, light = light, overlay = overlay), 135 + normal = (0, 1, 0), 136 + ) 137 + r.quad( 138 + Vertex(pos = (-0.25f, 0f, -0.25f), uv = (0, 0), color = color, light = light, overlay = overlay), 139 + Vertex(pos = (-0.25f, 0.125f, -0.25f), uv = (1, 0), color = color, light = light, overlay = overlay), 140 + Vertex(pos = (0.25f, 0.125f, -0.25f), uv = (1, 1), color = color, light = light, overlay = overlay), 141 + Vertex(pos = (0.25f, 0f, -0.25f), uv = (0, 1), color = color, light = light, overlay = overlay), 142 + normal = (0, 0, -1) 143 + ) 144 + r.sprite = Some(rune.sprite) 145 + r.quad( 146 + Vertex(pos = (-0.25f, 0.126f, -0.25f), uv = (0, 0), color = color, light = light, overlay = overlay), 147 + Vertex(pos = (-0.25f, 0.126f, 0.25f), uv = (0, 1), color = color, light = light, overlay = overlay), 148 + Vertex(pos = (0.25f, 0.126f, 0.25f), uv = (1, 1), color = color, light = light, overlay = overlay), 149 + Vertex(pos = (0.25f, 0.126f, -0.25f), uv = (1, 0), color = color, light = light, overlay = overlay), 150 + normal = (0, 1, 0), 151 + ) 152 + () 154 153 155 154 class ModelBuilder extends ModelSupplier: 156 - private var parent: Option[Identifier] = None 157 - private val elements = JsonArray() 158 - private val textures = JsonObject() 159 - private val display = JsonObject() 160 - opaque type Key = String 161 - class Element private[ModelBuilder](faces: JsonObject): 162 - def face(dir: Direction, texture: Key, uv: (from: UV, to: UV) = null, cullface: Direction = null, rotation: 0 | 90 | 180 | 270 = 0, tintindex: Int = -1): Unit = 163 - if faces.has(dir.toString) then 164 - throw IllegalArgumentException(s"Duplicate face $dir in element") 165 - val faceObj = JsonObject() 166 - faceObj.addProperty("texture", s"#$texture") 167 - if uv != null then faceObj.add("uv", fromTuple((uv.from.u: Float, uv.from.v: Float, uv.to.u: Float, uv.to.v: Float))) 168 - if rotation != 0 then faceObj.addProperty("rotation", rotation) 169 - if tintindex >= 0 then faceObj.addProperty("tintindex", tintindex) 170 - faces.add(dir.toString, faceObj) 171 - private def fromTuple(t: V3): JsonArray = 172 - val ary = JsonArray() 173 - ary.add(t.x) 174 - ary.add(t.y) 175 - ary.add(t.z) 176 - ary 177 - private def fromTuple(t: UV): JsonArray = 178 - val ary = JsonArray() 179 - ary.add(t.u) 180 - ary.add(t.v) 181 - ary 182 - private def fromTuple(t: (Float, Float, Float, Float)): JsonArray = 183 - val ary = JsonArray() 184 - ary.add(t._1) 185 - ary.add(t._2) 186 - ary.add(t._3) 187 - ary.add(t._4) 188 - ary 189 - def texture(name: String, value: Identifier): Key = 190 - if textures.has(name) then 191 - throw IllegalArgumentException(s"Duplicate texture $name") 192 - textures.addProperty(name, value.toString) 193 - name 194 - def element(name: String = null, from: V3, to: V3, rotation: (origin: V3, axis: Axis, angle: Float, rescale: Boolean) = null): Element = 195 - val el = JsonObject() 196 - if name != null then el.addProperty("name", name) 197 - el.add("from", fromTuple(from)) 198 - el.add("to", fromTuple(to)) 199 - if rotation != null then 200 - val rotObject = JsonObject() 201 - rotObject.add("origin", fromTuple(rotation.origin)) 202 - rotObject.addProperty("axis", rotation.axis.toString) 203 - rotObject.addProperty("angle", rotation.angle) 204 - rotObject.addProperty("rescale", rotation.rescale) 205 - el.add("rotation", rotObject) 206 - val facesObj = JsonObject() 207 - el.add("faces", facesObj) 208 - elements.add(el) 209 - Element(facesObj) 210 - def parent(name: Identifier): Unit = 211 - parent match 212 - case None => parent = Some(name) 213 - case Some(value) => throw IllegalArgumentException(s"Attempt to change parent to '$name', but it is already specified as '$value'") 155 + private var parent: Option[Identifier] = None 156 + private val elements = JsonArray() 157 + private val textures = JsonObject() 158 + private val display = JsonObject() 159 + opaque type Key = String 160 + class Element private[ModelBuilder](faces: JsonObject): 161 + def face(dir: Direction, texture: Key, uv: (from: UV, to: UV) = null, cullface: Direction = null, rotation: 0 | 90 | 180 | 270 = 0, tintindex: Int = -1): Unit = 162 + if faces.has(dir.toString) then 163 + throw IllegalArgumentException(s"Duplicate face $dir in element") 164 + val faceObj = JsonObject() 165 + faceObj.addProperty("texture", s"#$texture") 166 + if uv != null then faceObj.add("uv", fromTuple((uv.from.u: Float, uv.from.v: Float, uv.to.u: Float, uv.to.v: Float))) 167 + if rotation != 0 then faceObj.addProperty("rotation", rotation) 168 + if tintindex >= 0 then faceObj.addProperty("tintindex", tintindex) 169 + faces.add(dir.toString, faceObj) 170 + private def fromTuple(t: V3): JsonArray = 171 + val ary = JsonArray() 172 + ary.add(t.x) 173 + ary.add(t.y) 174 + ary.add(t.z) 175 + ary 176 + private def fromTuple(t: UV): JsonArray = 177 + val ary = JsonArray() 178 + ary.add(t.u) 179 + ary.add(t.v) 180 + ary 181 + private def fromTuple(t: (Float, Float, Float, Float)): JsonArray = 182 + val ary = JsonArray() 183 + ary.add(t._1) 184 + ary.add(t._2) 185 + ary.add(t._3) 186 + ary.add(t._4) 187 + ary 188 + def texture(name: String, value: Identifier): Key = 189 + if textures.has(name) then 190 + throw IllegalArgumentException(s"Duplicate texture $name") 191 + textures.addProperty(name, value.toString) 192 + name 193 + def element(name: String = null, from: V3, to: V3, rotation: (origin: V3, axis: Axis, angle: Float, rescale: Boolean) = null): Element = 194 + val el = JsonObject() 195 + if name != null then el.addProperty("name", name) 196 + el.add("from", fromTuple(from)) 197 + el.add("to", fromTuple(to)) 198 + if rotation != null then 199 + val rotObject = JsonObject() 200 + rotObject.add("origin", fromTuple(rotation.origin)) 201 + rotObject.addProperty("axis", rotation.axis.toString) 202 + rotObject.addProperty("angle", rotation.angle) 203 + rotObject.addProperty("rescale", rotation.rescale) 204 + el.add("rotation", rotObject) 205 + val facesObj = JsonObject() 206 + el.add("faces", facesObj) 207 + elements.add(el) 208 + Element(facesObj) 209 + def parent(name: Identifier): Unit = 210 + parent match 211 + case None => parent = Some(name) 212 + case Some(value) => throw IllegalArgumentException(s"Attempt to change parent to '$name', but it is already specified as '$value'") 214 213 215 - def display(name: String, translation: V3, rotation: V3, scale: V3): Unit = 216 - if display.has(name) then 217 - throw IllegalArgumentException(s"Duplicate display $name") 218 - val obj = JsonObject() 219 - obj.add("rotation", fromTuple(rotation)) 220 - obj.add("translation", fromTuple(translation)) 221 - obj.add("scale", fromTuple(scale)) 222 - display.add(name, obj) 214 + def display(name: String, translation: V3, rotation: V3, scale: V3): Unit = 215 + if display.has(name) then 216 + throw IllegalArgumentException(s"Duplicate display $name") 217 + val obj = JsonObject() 218 + obj.add("rotation", fromTuple(rotation)) 219 + obj.add("translation", fromTuple(translation)) 220 + obj.add("scale", fromTuple(scale)) 221 + display.add(name, obj) 223 222 224 - override def get: JsonElement = 225 - val obj = JsonObject() 226 - obj.add("textures", textures) 227 - obj.add("elements", elements) 228 - obj.add("display", display) 229 - parent.foreach(i => obj.addProperty("parent", i.toString)) 230 - obj 223 + override def get: JsonElement = 224 + val obj = JsonObject() 225 + obj.add("textures", textures) 226 + obj.add("elements", elements) 227 + obj.add("display", display) 228 + parent.foreach(i => obj.addProperty("parent", i.toString)) 229 + obj 231 230 232 231 def datagenRune(rune: Rune)(using pack: FabricDataGenerator#Pack) = 233 - pack.addProvider( 234 - new FabricModelProvider(_) { 235 - override def getName: String = s"${super.getName} for rune ${registryFor[Rune].getId(rune)}" 236 - override def generateBlockStateModels(using gen: BlockStateModelGenerator): Unit = () 237 - override def generateItemModels(using gen: ItemModelGenerator): Unit = 238 - gen.register(rune.item.value) 239 - gen.modelCollector.accept(ModelIds.getItemModelId(rune.item.value), { 240 - val m = ModelBuilder() 241 - m.parent(Identifier.ofVanilla("block/stone_pressure_plate")) 242 - val surface = m.texture("surface", rune.surfaceSprite) 243 - val sprite = m.texture("sprite", rune.spriteTexture) 244 - val bottom = m.element(from = (4, 0, 4), to = (12, 2, 12)) 245 - bottom.face(Direction.UP, texture = surface, uv = (from = (0, 0), to = (16, 16))) 246 - m 247 - }) 248 - } 249 - ) 250 - val projectRoot = System.getenv("PROJECT_ROOT") 251 - if projectRoot != null then 252 - val texture = rune.spriteTexture 253 - val textureFile = Path.of(s"$projectRoot/src/client/resources/assets/${texture.getNamespace}/textures/${texture.getPath}.png") 254 - if !Files.exists(textureFile) then Files.createFile(textureFile) 232 + pack.addProvider( 233 + new FabricModelProvider(_) { 234 + override def getName: String = s"${super.getName} for rune ${registryFor[Rune].getId(rune)}" 235 + override def generateBlockStateModels(using gen: BlockStateModelGenerator): Unit = () 236 + override def generateItemModels(using gen: ItemModelGenerator): Unit = 237 + gen.register(rune.item.value) 238 + gen.modelCollector.accept(ModelIds.getItemModelId(rune.item.value), { 239 + val m = ModelBuilder() 240 + m.parent(Identifier.ofVanilla("block/stone_pressure_plate")) 241 + val surface = m.texture("surface", rune.surfaceSprite) 242 + val sprite = m.texture("sprite", rune.spriteTexture) 243 + val bottom = m.element(from = (4, 0, 4), to = (12, 2, 12)) 244 + bottom.face(Direction.UP, texture = surface, uv = (from = (0, 0), to = (16, 16))) 245 + m 246 + }) 247 + } 248 + ) 249 + val projectRoot = System.getenv("PROJECT_ROOT") 250 + if projectRoot != null then 251 + val texture = rune.spriteTexture 252 + val textureFile = Path.of(s"$projectRoot/src/client/resources/assets/${texture.getNamespace}/textures/${texture.getPath}.png") 253 + if !Files.exists(textureFile) then Files.createFile(textureFile) 255 254 256 255 def datagen(using gen: FabricDataGenerator): Unit = 257 - given pack: FabricDataGenerator#Pack = gen.createPack() 258 - registryFor[Rune].forEach(datagenRune(_)) 259 - pack.addProvider( 260 - new FabricAdvancementProvider(_, _) { 261 - override def generateAdvancement(wrapperLookup: RegistryWrapper.WrapperLookup, consumer: Consumer[AdvancementEntry]): Unit = 262 - val rootId = Identifier.of("mica", "without_me") 263 - consumer.accept(AdvancementEntry( 264 - rootId, 265 - Advancement( 266 - parent = Optional.empty, 267 - display = Optional.of(AdvancementDisplay( 268 - icon = ItemStack(Items.ENDER_EYE), 269 - title = Text.literal("Guess Who\'s Back, Back Again"), 270 - description = Text.literal("Return to a Teleport Slate from over 32 blocks away"), 271 - background = Optional.empty, 272 - frame = AdvancementFrame.CHALLENGE, 273 - showToast = true, 274 - announceToChat = true, 275 - hidden = true, 276 - )), 277 - rewards = AdvancementRewards.NONE, 278 - criteria = java.util.Map.of("mojang_won\'t_let_me_be", AdvancementCriterion(Criteria.IMPOSSIBLE, ImpossibleCriterion.Conditions())), 279 - requirements = AdvancementRequirements.allOf(Seq("mojang_won\'t_let_me_be")), 280 - sendsTelemetryEvent = false 281 - ) 282 - )) 283 - } 284 - ) 256 + given pack: FabricDataGenerator#Pack = gen.createPack() 257 + registryFor[Rune].forEach(datagenRune(_)) 258 + pack.addProvider( 259 + new FabricAdvancementProvider(_, _) { 260 + override def generateAdvancement(wrapperLookup: RegistryWrapper.WrapperLookup, consumer: Consumer[AdvancementEntry]): Unit = 261 + val rootId = Identifier.of("mica", "without_me") 262 + consumer.accept(AdvancementEntry( 263 + rootId, 264 + Advancement( 265 + parent = Optional.empty, 266 + display = Optional.of(AdvancementDisplay( 267 + icon = ItemStack(Items.ENDER_EYE), 268 + title = Text.literal("Guess Who\'s Back, Back Again"), 269 + description = Text.literal("Return to a Teleport Slate from over 32 blocks away"), 270 + background = Optional.empty, 271 + frame = AdvancementFrame.CHALLENGE, 272 + showToast = true, 273 + announceToChat = true, 274 + hidden = true, 275 + )), 276 + rewards = AdvancementRewards.NONE, 277 + criteria = java.util.Map.of("mojang_won\'t_let_me_be", AdvancementCriterion(Criteria.IMPOSSIBLE, ImpossibleCriterion.Conditions())), 278 + requirements = AdvancementRequirements.allOf(Seq("mojang_won\'t_let_me_be")), 279 + sendsTelemetryEvent = false 280 + ) 281 + )) 282 + } 283 + ) 284 + 285 + def init() = println("new dummy client init")
+49
src/client/scala/org/net/eu/pool/mica/mixin/client/WorldRendererMixin.java
··· 1 + package org.net.eu.pool.mica.mixin.client; 2 + 3 + import com.llamalad7.mixinextras.sugar.Local; 4 + import com.mojang.blaze3d.buffers.GpuBufferSlice; 5 + import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; 6 + import net.fabricmc.fabric.impl.client.rendering.WorldRenderContextImpl; 7 + import net.minecraft.client.MinecraftClient; 8 + import net.minecraft.client.render.BufferBuilderStorage; 9 + import net.minecraft.client.render.Camera; 10 + import net.minecraft.client.render.RenderTickCounter; 11 + import net.minecraft.client.render.WorldRenderer; 12 + import net.minecraft.client.util.ObjectAllocator; 13 + import net.minecraft.client.util.math.MatrixStack; 14 + import net.minecraft.client.world.ClientWorld; 15 + import org.jetbrains.annotations.Nullable; 16 + import org.joml.Matrix4f; 17 + import org.joml.Vector4f; 18 + import org.spongepowered.asm.mixin.Final; 19 + import org.spongepowered.asm.mixin.Mixin; 20 + import org.spongepowered.asm.mixin.Shadow; 21 + import org.spongepowered.asm.mixin.Unique; 22 + import org.spongepowered.asm.mixin.injection.At; 23 + import org.spongepowered.asm.mixin.injection.Inject; 24 + import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 25 + 26 + @Mixin(WorldRenderer.class) 27 + public class WorldRendererMixin { 28 + @Shadow @Final private MinecraftClient client; 29 + @Shadow @Final private BufferBuilderStorage bufferBuilders; 30 + @Shadow private @Nullable ClientWorld world; 31 + @Unique private final WorldRenderContextImpl mica_context = new WorldRenderContextImpl(); 32 + 33 + @Inject(method = "render", at = @At("HEAD")) 34 + private void beforeRender(ObjectAllocator objectAllocator, RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, Matrix4f positionMatrix, Matrix4f projectionMatrix, GpuBufferSlice slice, Vector4f skyColor, boolean thinFog, CallbackInfo ci) { 35 + mica_context.prepare((WorldRenderer) (Object) this, tickCounter, renderBlockOutline, camera, this.client.gameRenderer, positionMatrix, projectionMatrix, bufferBuilders.getEntityVertexConsumers(), MinecraftClient.isFabulousGraphicsOrBetter(), world); 36 + } 37 + 38 + @Inject( 39 + method = "method_62214", 40 + at = @At( 41 + value = "INVOKE", 42 + target = "Lnet/minecraft/client/render/WorldRenderer;renderEntities(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/RenderTickCounter;Ljava/util/List;)V" 43 + ) 44 + ) 45 + private void afterTerrainSolid(CallbackInfo ci, @Local MatrixStack matrixStack) { 46 + mica_context.setMatrixStack(matrixStack); 47 + org.net.eu.pool.mica.client.MicaClient$package.renderRunes(mica_context); 48 + } 49 + }
+3
src/main/scala/org/net/eu/pool/mica/Mica.scala
··· 1440 1440 case r: R => Some(r) 1441 1441 case _ => None 1442 1442 1443 + //@register("find_people") 1444 + 1445 + 1443 1446 @tailrec 1444 1447 def panic(reason: String): Nothing = 1445 1448 Bootstrap.SYSOUT.println(s"thread '${Thread.currentThread.getName}' panicked at '$reason'")