Thread saftey (#24)

* Update BS

* Thread Safety
This commit is contained in:
Jason Mitchell authored and GitHub committed 2024-05-26 12:41:45 +02:00
1 parent b60993f39b
commit 2abb775696
6 files changed
+28 -10

No files matched your search

+1 -1
View File
@@ -117,7 +117,7 @@ minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories.
# Adds the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.14'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.22'
}
@@ -10,17 +10,31 @@ import codechicken.lib.vec.{Cuboid6, Vector3}
import net.minecraft.entity.player.EntityPlayer
import codechicken.lib.render.{
CCRenderPipeline,
ColourMultiplier,
CCRenderState
CCRenderState,
ColourMultiplier
}
import codechicken.microblock.handler.MicroblockProxy
import net.minecraft.entity.Entity
import codechicken.lib.render.uv.{UVTransformation, MultiIconTransformation}
import cpw.mods.fml.common.registry.{GameRegistry, GameData}
import java.util.function.Supplier
private class ThreadState {
var pass = 0
var builder: CCRenderPipeline#PipelineBuilder = _
}
object MaterialRenderHelper {
private var pass = 0
private var builder: CCRenderPipeline#PipelineBuilder = _
private val threadState =
ThreadLocal.withInitial[ThreadState](new Supplier[ThreadState]() {
override def get(): ThreadState = new ThreadState()
})
def pass = threadState.get().pass
def pass_=(pass: Int) = threadState.get().pass = pass
def builder = threadState.get().builder
def builder_=(builder: CCRenderPipeline#PipelineBuilder) =
threadState.get().builder = builder
def start(pos: Vector3, pass: Int, uvt: UVTransformation) = {
this.pass = pass
@@ -7,6 +7,7 @@ import org.lwjgl.opengl.GL11._
import codechicken.lib.render.{CCRenderState, TextureUtils}
import codechicken.lib.render.BlockRenderer.BlockFace
import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial
import java.util.function.Supplier
object MicroblockRender {
def renderHighlight(
@@ -55,7 +56,9 @@ object MicroblockRender {
glPopMatrix()
}
val face = new BlockFace()
val face = ThreadLocal.withInitial[BlockFace](new Supplier[BlockFace]() {
override def get(): BlockFace = new BlockFace()
})
def renderCuboid(
pos: Vector3,
mat: IMicroMaterial,
@@ -63,9 +66,10 @@ object MicroblockRender {
c: Cuboid6,
faces: Int
) {
CCRenderState.instance().setModel(face)
val localFace = face.get()
CCRenderState.instance().setModel(localFace)
for (s <- 0 until 6 if (faces & 1 << s) == 0) {
face.loadCuboidFace(c, s)
localFace.loadCuboidFace(c, s)
mat.renderMicroFace(pos, pass, c)
}
}