Skip to content

Commit

Permalink
sa
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Jan 12, 2024
1 parent cf5f606 commit ff6339e
Showing 1 changed file with 74 additions and 74 deletions.
148 changes: 74 additions & 74 deletions src/main/scala/mrtjp/core/render/TCubeMapRender.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,88 +14,88 @@ import net.minecraft.util.IIcon
import net.minecraft.world.IBlockAccess

object TCubeMapRender {
val models = {
val array = Array.ofDim[CCModel](6, 4)
val box = CCModel.quadModel(24).generateBlock(0, Cuboid6.full)
for (s <- 0 until 6) for (r <- 0 until 4) {
val m = box.copy.apply(Rotation.sideOrientation(s, r).at(Vector3.center))
m.computeNormals()
array(s)(r) = m
}
array
val models = {
val array = Array.ofDim[CCModel](6, 4)
val box = CCModel.quadModel(24).generateBlock(0, Cuboid6.full)
for (s <- 0 until 6) for (r <- 0 until 4) {
val m = box.copy.apply(Rotation.sideOrientation(s, r).at(Vector3.center))
m.computeNormals()
array(s)(r) = m
}
array
}

val invTranslation = new Translation(-0.5, -0.5, -0.5)
val invTranslation = new Translation(-0.5, -0.5, -0.5)
}

trait TCubeMapRender extends TInstancedBlockRender {
import mrtjp.core.render.TCubeMapRender._
import mrtjp.core.render.TCubeMapRender._

override def renderWorldBlock(
r: RenderBlocks,
w: IBlockAccess,
x: Int,
y: Int,
z: Int,
meta: Int
) {
val (s, rot, icon) = getData(w, x, y, z)
TextureUtils.bindAtlas(0)
val state = CCRenderState.instance
state.reset()
state.lightMatrix.locate(w, x, y, z)
models(s)(rot).render(
new Translation(x, y, z),
icon,
state.lightMatrix
)
}
override def renderWorldBlock(
r: RenderBlocks,
w: IBlockAccess,
x: Int,
y: Int,
z: Int,
meta: Int
) {
val (s, rot, icon) = getData(w, x, y, z)
TextureUtils.bindAtlas(0)
val state = CCRenderState.instance
state.reset()
state.lightMatrix.locate(w, x, y, z)
models(s)(rot).render(
new Translation(x, y, z),
icon,
state.lightMatrix
)
}

override def renderBreaking(
w: IBlockAccess,
x: Int,
y: Int,
z: Int,
icon: IIcon
) {
val b = w.getBlock(x, y, z)
val state = CCRenderState.instance
state.reset()
state.setPipeline(
new Translation(x, y, z),
new IconTransformation(icon)
)
BlockRenderer.renderCuboid(
new Cuboid6(
b.getBlockBoundsMinX,
b.getBlockBoundsMinY,
b.getBlockBoundsMinZ,
b.getBlockBoundsMaxX,
b.getBlockBoundsMaxY,
b.getBlockBoundsMaxZ
),
0
)
}
override def renderBreaking(
w: IBlockAccess,
x: Int,
y: Int,
z: Int,
icon: IIcon
) {
val b = w.getBlock(x, y, z)
val state = CCRenderState.instance
state.reset()
state.setPipeline(
new Translation(x, y, z),
new IconTransformation(icon)
)
BlockRenderer.renderCuboid(
new Cuboid6(
b.getBlockBoundsMinX,
b.getBlockBoundsMinY,
b.getBlockBoundsMinZ,
b.getBlockBoundsMaxX,
b.getBlockBoundsMaxY,
b.getBlockBoundsMaxZ
),
0
)
}

override def renderInvBlock(r: RenderBlocks, meta: Int) {
val (s, r, icon) = getInvData
override def renderInvBlock(r: RenderBlocks, meta: Int) {
val (s, r, icon) = getInvData

TextureUtils.bindAtlas(0)
val state = CCRenderState.instance
state.reset()
state.setDynamic()
state.pullLightmap()
state.startDrawing()
models(s)(r).render(invTranslation, icon)
state.draw()
}
TextureUtils.bindAtlas(0)
val state = CCRenderState.instance
state.reset()
state.setDynamic()
state.pullLightmap()
state.startDrawing()
models(s)(r).render(invTranslation, icon)
state.draw()
}

def getData(
w: IBlockAccess,
x: Int,
y: Int,
z: Int
): (Int, Int, UVTransformation)
def getInvData: (Int, Int, UVTransformation)
def getData(
w: IBlockAccess,
x: Int,
y: Int,
z: Int
): (Int, Int, UVTransformation)
def getInvData: (Int, Int, UVTransformation)
}

0 comments on commit ff6339e

Please sign in to comment.