Skip to content

Commit

Permalink
🎨 De-marvinization 2
Browse files Browse the repository at this point in the history
  • Loading branch information
PriestOfFerns committed Apr 15, 2024
1 parent 77529cf commit e056b93
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies {
compileOnly("org.valkyrienskies.core:util:${rootProject.vs_core_version}")
compileOnly("org.valkyrienskies.core:impl:${rootProject.vs_core_version}")

api "com.github.M-Marvin:LIBRARY-UnifiedVectors:$univec_version"
//api "com.github.M-Marvin:LIBRARY-UnifiedVectors:$univec_version"


api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.priestoffern.vs_ship_assembler.items

import de.m_marvin.univec.impl.Vec3d

import io.github.priestoffern.vs_ship_assembler.rendering.Renderer
import io.github.priestoffern.vs_ship_assembler.rendering.RenderingData
import io.github.priestoffern.vs_ship_assembler.rendering.SelectionZoneRenderer
Expand Down Expand Up @@ -91,8 +91,9 @@ class ShipAssemblerItem(properties: Properties): Item(properties) {
if (SelectionZone!=null) Renderer.removeRenderOfType(SelectionZone!!)
SelectionZone = null;

val SZ = SelectionZoneRenderer(Vec3d(firstPosition!!.x.toDouble(),
firstPosition!!.y.toDouble(), firstPosition!!.z.toDouble()),Vec3d(res.blockPos.x.toDouble(),res.blockPos.y.toDouble(),res.blockPos.z.toDouble()), Color.GREEN);
val SZ = SelectionZoneRenderer(Vector3d(firstPosition!!.x.toDouble(),
firstPosition!!.y.toDouble(), firstPosition!!.z.toDouble()),
Vector3d(res.blockPos.x.toDouble(),res.blockPos.y.toDouble(),res.blockPos.z.toDouble()), Color.GREEN);
SelectionZone = Renderer.addRender(SZ)
} else {
player.sendMessage(TextComponent("Selected position is invalid").withStyle(ChatFormatting.RED), Util.NIL_UUID)
Expand Down Expand Up @@ -140,11 +141,11 @@ class ShipAssemblerItem(properties: Properties): Item(properties) {


val SZ = SelectionZoneRenderer(
Vec3d(
Vector3d(
otherPos!!.x.toDouble(),
otherPos.y.toDouble(), otherPos.z.toDouble()
),
Vec3d(res.blockPos.x.toDouble(), res.blockPos.y.toDouble(), res.blockPos.z.toDouble()),
Vector3d(res.blockPos.x.toDouble(), res.blockPos.y.toDouble(), res.blockPos.z.toDouble()),
Color.GREEN
);
SelectionZone = Renderer.addRender(SZ)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ package io.github.priestoffern.vs_ship_assembler.rendering
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.*
import com.mojang.math.Matrix4f
import de.m_marvin.univec.impl.Vec3d
import net.minecraft.client.Camera
import net.minecraft.client.renderer.GameRenderer
import org.joml.Vector3d
import org.lwjgl.opengl.GL11
import java.awt.Color

class SelectionZoneRenderer() : RenderingData {

var point0 = Vec3d();
var point1 = Vec3d();
var point0 = Vector3d(0.0,0.0, 0.0);
var point1 = Vector3d(0.0,0.0, 0.0);
var color: Color = Color(0)
override var Id: Long = 0
override var type: String = "Ship_Assembler_Selection_Zone"
constructor(
point0: Vec3d,
point1: Vec3d,
point0: Vector3d,
point1: Vector3d,
color: Color,
): this() {
this.point0 = point0
Expand Down Expand Up @@ -47,11 +48,11 @@ class SelectionZoneRenderer() : RenderingData {

val cameraPos = camera.position

val Add1 = Vec3d(if (point0.x>=point1.x) 1.0 else 0.0, if (point0.y>=point1.y) 1.0 else 0.0, if (point0.z>=point1.z) 1.0 else 0.0)
val Add2 = Vec3d(if (point1.x>point0.x) 1.0 else 0.0, if (point1.y>point0.y) 1.0 else 0.0, if (point1.z>point0.z) 1.0 else 0.0)
val Add1 = Vector3d(if (point0.x>=point1.x) 1.0 else 0.0, if (point0.y>=point1.y) 1.0 else 0.0, if (point0.z>=point1.z) 1.0 else 0.0)
val Add2 = Vector3d(if (point1.x>point0.x) 1.0 else 0.0, if (point1.y>point0.y) 1.0 else 0.0, if (point1.z>point0.z) 1.0 else 0.0)

val tpos1 = Vec3d(point0.x-cameraPos.x,point0.y-cameraPos.y,point0.z-cameraPos.z).add(Add1)
val tpos2 = Vec3d(point1.x-cameraPos.x,point1.y-cameraPos.y,point1.z-cameraPos.z).add(Add2)
val tpos1 = Vector3d(point0.x-cameraPos.x,point0.y-cameraPos.y,point0.z-cameraPos.z).add(Add1)
val tpos2 = Vector3d(point1.x-cameraPos.x,point1.y-cameraPos.y,point1.z-cameraPos.z).add(Add2)

val matrix = poseStack.last().pose()
makeBox(
Expand All @@ -70,7 +71,7 @@ class SelectionZoneRenderer() : RenderingData {
fun tof(n: Double) = n.toFloat()
fun makeBox(buf: VertexConsumer, matrix: Matrix4f,
r: Int, g: Int, b: Int, a: Int, lightmapUV: Int,
A: Vec3d, B:Vec3d
A: Vector3d, B:Vector3d
) {
buf.vertex(matrix, tof(A.x), tof(A.y), tof(A.z)).color(r, g, b, a).uv2(lightmapUV).endVertex()
buf.vertex(matrix, tof(A.x), tof(A.y), tof(B.z)).color(r, g, b, a).uv2(lightmapUV).endVertex()
Expand Down
2 changes: 1 addition & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dependencies {
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }

include(api "com.github.M-Marvin:LIBRARY-UnifiedVectors:$univec_version")
//include(api "com.github.M-Marvin:LIBRARY-UnifiedVectors:$univec_version")
}

processResources {
Expand Down
2 changes: 1 addition & 1 deletion forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dependencies {

// Kotlin for Forge
implementation "thedarkcolour:kotlinforforge:$forge_kotlin_version"
include(forgeRuntimeLibrary "com.github.M-Marvin:LIBRARY-UnifiedVectors:$univec_version")
//include(forgeRuntimeLibrary "com.github.M-Marvin:LIBRARY-UnifiedVectors:$univec_version")

}

Expand Down

0 comments on commit e056b93

Please sign in to comment.