Skip to content

Commit

Permalink
Merge pull request #21 from GTNewHorizons/chicken
Browse files Browse the repository at this point in the history
update to support 1.2.0 CCL - needs work to be more performant
  • Loading branch information
bombcar authored Jan 3, 2024
2 parents cb276d9 + 794c3ca commit 901dfcb
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Add your dependencies here

dependencies {
api("com.github.GTNewHorizons:CodeChickenLib:1.1.8:dev")
api("com.github.GTNewHorizons:CodeChickenLib:1.2.0:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.4.13-GTNH:dev")
}
7 changes: 0 additions & 7 deletions src/main/resources/dependencies.info

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object MaterialRenderHelper {

def start(pos: Vector3, pass: Int, uvt: UVTransformation) = {
this.pass = pass
builder = CCRenderState.pipeline.builder()
builder = CCRenderState.instance().pipeline.builder()
builder.add(pos.translation()).add(uvt)
this
}
Expand All @@ -36,7 +36,7 @@ object MaterialRenderHelper {

def lighting() = {
if (pass != -1)
builder.add(CCRenderState.lightMatrix)
builder.add(CCRenderState.instance().lightMatrix)
this
}

Expand Down Expand Up @@ -85,9 +85,10 @@ class BlockMicroMaterial(val block: Block, val meta: Int = 0)
if (pass == -1)
block.getBlockColor << 8 | 0xff
else {
val pos = CCRenderState.lightMatrix.pos
val state = CCRenderState.instance
val pos = state.lightMatrix.pos
block.colorMultiplier(
CCRenderState.lightMatrix.access,
state.lightMatrix.access,
pos.x,
pos.y,
pos.z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package codechicken.microblock

import codechicken.lib.vec.{Cuboid6, Vector3}
import net.minecraft.block.Block
import codechicken.lib.render.{ColourMultiplier, CCRenderState}
import codechicken.lib.render.CCRenderState
import net.minecraft.block.BlockGrass
import net.minecraft.init.Blocks
import codechicken.lib.render.uv.{UVTranslation, IconTransformation}
Expand All @@ -17,7 +17,7 @@ class GrassMicroMaterial extends BlockMicroMaterial(Blocks.grass, 0) {
}

override def renderMicroFace(pos: Vector3, pass: Int, bounds: Cuboid6) {
val face = CCRenderState.model.asInstanceOf[BlockFace]
val face = CCRenderState.instance().model.asInstanceOf[BlockFace]
if (pass != -1)
face.computeLightCoords()

Expand All @@ -42,7 +42,7 @@ class GrassMicroMaterial extends BlockMicroMaterial(Blocks.grass, 0) {
class TopMicroMaterial($block: Block, $meta: Int = 0)
extends BlockMicroMaterial($block, $meta) {
override def renderMicroFace(pos: Vector3, pass: Int, bounds: Cuboid6) {
val face = CCRenderState.model.asInstanceOf[BlockFace]
val face = CCRenderState.instance().model.asInstanceOf[BlockFace]
if (face.side <= 1)
MaterialRenderHelper
.start(pos, pass, icont)
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/codechicken/microblock/HollowMicroblock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Vector3._
import codechicken.lib.raytracer.IndexedCuboid6
import org.lwjgl.opengl.GL11
import codechicken.lib.render.uv.IconTransformation
import codechicken.lib.lighting.LightMatrix

object HollowPlacement extends PlacementProperties {
object HollowPlacementGrid extends FaceEdgeGrid(3 / 8d)
Expand Down Expand Up @@ -74,8 +73,9 @@ trait HollowMicroblockClient
}

override def drawBreaking(renderBlocks: RenderBlocks) {
CCRenderState.reset()
CCRenderState.setPipeline(
val state = CCRenderState.instance
state.reset()
state.setPipeline(
new Translation(x, y, z),
new IconTransformation(renderBlocks.overrideBlockTexture)
)
Expand Down
12 changes: 6 additions & 6 deletions src/main/scala/codechicken/microblock/ItemMicroPart.scala
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,17 @@ object ItemMicroPartRenderer extends IItemRenderer {
GL11.glScaled(0.5, 0.5, 0.5)
if (t == ItemRenderType.INVENTORY || t == ItemRenderType.ENTITY)
GL11.glTranslatef(-0.5f, -0.5f, -0.5f)

TextureUtils.bindAtlas(0)
CCRenderState.reset()
CCRenderState.useNormals = true
CCRenderState.pullLightmap()
CCRenderState.startDrawing()
val state = CCRenderState.instance
state.reset()
state.useNormals = true
state.pullLightmap()
state.startDrawing()
val part =
mcrClass.create(true, getMaterialID(item)).asInstanceOf[MicroblockClient]
part.setShape(size, mcrClass.itemSlot)
part.render(new Vector3(0.5, 0.5, 0.5).subtract(part.getBounds.center), -1)
CCRenderState.draw()
state.draw()
GL11.glPopMatrix()
}

Expand Down
16 changes: 8 additions & 8 deletions src/main/scala/codechicken/microblock/ItemSaw.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,25 @@ object ItemSawRenderer extends IItemRenderer {
)
case _ => return
}

CCRenderState.reset()
CCRenderState.useNormals = true
CCRenderState.pullLightmap()
val state = CCRenderState.instance
state.reset()
state.useNormals = true
state.pullLightmap()
CCRenderState.changeTexture("microblock:textures/items/saw.png")
CCRenderState.startDrawing()
state.startDrawing()
handle.render(t)
holder.render(t)
CCRenderState.draw()
state.draw()
GL11.glDisable(GL11.GL_CULL_FACE)
CCRenderState.startDrawing()
state.startDrawing()
blade.render(
t,
new UVTranslation(
0,
(item.getItem.asInstanceOf[Saw].getCuttingStrength(item) - 1) * 4 / 64d
)
)
CCRenderState.draw()
state.draw()
GL11.glEnable(GL11.GL_CULL_FACE)
}
}
15 changes: 8 additions & 7 deletions src/main/scala/codechicken/microblock/MicroblockRender.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ object MicroblockRender {
return
val pos = placement.pos
val part = placement.part.asInstanceOf[MicroblockClient]
val state = CCRenderState.instance

glPushMatrix()
glTranslated(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5)
Expand All @@ -40,14 +41,14 @@ object MicroblockRender {
glEnable(GL_BLEND)
glDepthMask(false)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

// TODO: update to use a thread local copy
TextureUtils.bindAtlas(0)
CCRenderState.reset()
CCRenderState.alphaOverride = 80
CCRenderState.useNormals = true
CCRenderState.startDrawing()
state.reset()
state.alphaOverride = 80
state.useNormals = true
state.startDrawing()
part.render(Vector3.zero, -1)
CCRenderState.draw()
state.draw()

glDisable(GL_BLEND)
glDepthMask(true)
Expand All @@ -62,7 +63,7 @@ object MicroblockRender {
c: Cuboid6,
faces: Int
) {
CCRenderState.setModel(face)
CCRenderState.instance().setModel(face)
for (s <- 0 until 6 if (faces & 1 << s) == 0) {
face.loadCuboidFace(c, s)
mat.renderMicroFace(pos, pass, c)
Expand Down
12 changes: 7 additions & 5 deletions src/main/scala/codechicken/multipart/MultipartRenderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ object MultipartRenderer
if (tmpart.partList.isEmpty)
return

CCRenderState.reset()
CCRenderState.pullLightmap()
CCRenderState.useNormals = true
val state = CCRenderState.instance
state.reset()
state.pullLightmap()
state.useNormals = true

val pos = new Vector3(x, y, z)
tmpart.renderDynamic(pos, f, pass)
Expand Down Expand Up @@ -81,8 +82,9 @@ object MultipartRenderer
return false
}

CCRenderState.reset()
CCRenderState.lightMatrix.locate(world, x, y, z)
val state = CCRenderState.instance
state.reset()
state.lightMatrix.locate(world, x, y, z)
return tmpart.renderStatic(new Vector3(x, y, z), pass)
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/codechicken/multipart/TCuboidPart.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ trait TCuboidPart extends TMultiPart {

@SideOnly(Side.CLIENT)
override def drawBreaking(renderBlocks: RenderBlocks) {
CCRenderState.reset()
CCRenderState.setPipeline(
val state = CCRenderState.instance
state.reset()
state.setPipeline(
new Translation(x, y, z),
new IconTransformation(renderBlocks.overrideBlockTexture)
)
Expand Down

0 comments on commit 901dfcb

Please sign in to comment.