Compare commits

...
3 Commits
Author SHA1 Message Date
glowredman 439243b00a Add Localization (#25) 2024-12-30 18:18:34 -06:00
Martin Robertz 38a2bf629f update 2024-05-26 12:44:42 +02:00
Jason Mitchell 2abb775696 Thread saftey (#24)
* Update BS

* Thread Safety
2024-05-26 12:41:45 +02:00
8 changed files with 32 additions and 12 deletions

No files matched your search

+1 -1
View File
@@ -3,5 +3,5 @@
dependencies { dependencies {
api("com.github.GTNewHorizons:CodeChickenLib:1.2.1:dev") api("com.github.GTNewHorizons:CodeChickenLib:1.2.1:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.17-GTNH:dev") devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.6.0-GTNH:dev")
} }
+1 -1
View File
@@ -117,7 +117,7 @@ minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes. # If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true 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 includeWellKnownRepositories = true
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven. # 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 distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
} }
plugins { plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.14' id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.22'
} }
@@ -6,6 +6,8 @@ item.microblock:sawIron.name=Iron Saw
item.microblock:sawDiamond.name=Diamond Saw item.microblock:sawDiamond.name=Diamond Saw
item.microblock:stoneRod.name=Stone Rod item.microblock:stoneRod.name=Stone Rod
item.microblock.name=Microblock
mcr_face.1.name=%s Cover mcr_face.1.name=%s Cover
mcr_face.1.subset=Cover mcr_face.1.subset=Cover
mcr_face.2.name=%s Panel mcr_face.2.name=%s Panel
@@ -36,4 +38,4 @@ mcr_cnr.4.subset=Notch
nei.subsets.Microblocks=Microblocks nei.subsets.Microblocks=Microblocks
key.control=Switch block disposition key.control=Switch block disposition
@@ -10,17 +10,31 @@ import codechicken.lib.vec.{Cuboid6, Vector3}
import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayer
import codechicken.lib.render.{ import codechicken.lib.render.{
CCRenderPipeline, CCRenderPipeline,
ColourMultiplier, CCRenderState,
CCRenderState ColourMultiplier
} }
import codechicken.microblock.handler.MicroblockProxy import codechicken.microblock.handler.MicroblockProxy
import net.minecraft.entity.Entity import net.minecraft.entity.Entity
import codechicken.lib.render.uv.{UVTransformation, MultiIconTransformation} import codechicken.lib.render.uv.{UVTransformation, MultiIconTransformation}
import cpw.mods.fml.common.registry.{GameRegistry, GameData} 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 { object MaterialRenderHelper {
private var pass = 0 private val threadState =
private var builder: CCRenderPipeline#PipelineBuilder = _ 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) = { def start(pos: Vector3, pass: Int, uvt: UVTransformation) = {
this.pass = pass this.pass = pass
@@ -7,6 +7,7 @@ import org.lwjgl.opengl.GL11._
import codechicken.lib.render.{CCRenderState, TextureUtils} import codechicken.lib.render.{CCRenderState, TextureUtils}
import codechicken.lib.render.BlockRenderer.BlockFace import codechicken.lib.render.BlockRenderer.BlockFace
import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial
import java.util.function.Supplier
object MicroblockRender { object MicroblockRender {
def renderHighlight( def renderHighlight(
@@ -55,7 +56,9 @@ object MicroblockRender {
glPopMatrix() glPopMatrix()
} }
val face = new BlockFace() val face = ThreadLocal.withInitial[BlockFace](new Supplier[BlockFace]() {
override def get(): BlockFace = new BlockFace()
})
def renderCuboid( def renderCuboid(
pos: Vector3, pos: Vector3,
mat: IMicroMaterial, mat: IMicroMaterial,
@@ -63,9 +66,10 @@ object MicroblockRender {
c: Cuboid6, c: Cuboid6,
faces: Int faces: Int
) { ) {
CCRenderState.instance().setModel(face) val localFace = face.get()
CCRenderState.instance().setModel(localFace)
for (s <- 0 until 6 if (faces & 1 << s) == 0) { for (s <- 0 until 6 if (faces & 1 << s) == 0) {
face.loadCuboidFace(c, s) localFace.loadCuboidFace(c, s)
mat.renderMicroFace(pos, pass, c) mat.renderMicroFace(pos, pass, c)
} }
} }