diff --git a/gradle.properties b/gradle.properties index cff79bd..ce46c9e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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. diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd49..e644113 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a80b22c..b82aa23 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/settings.gradle b/settings.gradle index 16a5b4c..94c2daf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,7 +17,7 @@ pluginManagement { } plugins { - id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.14' + id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.22' } diff --git a/src/main/scala/codechicken/microblock/BlockMicroMaterial.scala b/src/main/scala/codechicken/microblock/BlockMicroMaterial.scala index 24044f7..de371b6 100644 --- a/src/main/scala/codechicken/microblock/BlockMicroMaterial.scala +++ b/src/main/scala/codechicken/microblock/BlockMicroMaterial.scala @@ -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 diff --git a/src/main/scala/codechicken/microblock/MicroblockRender.scala b/src/main/scala/codechicken/microblock/MicroblockRender.scala index 7939355..51803f4 100644 --- a/src/main/scala/codechicken/microblock/MicroblockRender.scala +++ b/src/main/scala/codechicken/microblock/MicroblockRender.scala @@ -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) } }