diff --git a/src/integration/scala/mrtjp/projectred/integration/components.scala b/src/integration/scala/mrtjp/projectred/integration/components.scala index 6f137ad07..f25becba4 100644 --- a/src/integration/scala/mrtjp/projectred/integration/components.scala +++ b/src/integration/scala/mrtjp/projectred/integration/components.scala @@ -505,6 +505,12 @@ object WireModel3D bakeOrients(model) }) + def regenerateModels():Unit = { + val keys = cache.keySet.toSet //Copy old keyset + cache.clear() + for (k <- keys) getOrGenerateModels(k) //Regenerate all keys + } + def generateModel(data:Array[Colour]) = { val wireRectangles = TWireModel.rectangulate(data) diff --git a/src/integration/scala/mrtjp/projectred/integration/gaterenders.scala b/src/integration/scala/mrtjp/projectred/integration/gaterenders.scala index 2d74c6d3b..686832698 100644 --- a/src/integration/scala/mrtjp/projectred/integration/gaterenders.scala +++ b/src/integration/scala/mrtjp/projectred/integration/gaterenders.scala @@ -16,8 +16,11 @@ import mrtjp.projectred.integration.ComponentStore._ import net.minecraft.client.renderer.IRenderTypeBuffer import net.minecraft.item.ItemStack import net.minecraft.particles.RedstoneParticleData +import net.minecraft.resources.IResourceManager +import net.minecraftforge.resource.{IResourceType, ISelectiveResourceReloadListener, VanillaResourceType} import java.util.Random +import java.util.function.Predicate class RenderGate { @@ -95,7 +98,7 @@ class RenderGate } } -object RenderGate extends IIconRegister +object RenderGate extends IIconRegister with ISelectiveResourceReloadListener { private val instances = new ThreadLocal[RenderGate]() { override def initialValue() = new RenderGate @@ -107,6 +110,11 @@ object RenderGate extends IIconRegister ComponentStore.registerIcons(map) for (m <- instance().renderers) m.registerIcons(map) } + + override def onResourceManagerReload(resourceManager:IResourceManager, resourcePredicate:Predicate[IResourceType]):Unit = { + if (resourcePredicate.test(VanillaResourceType.TEXTURES)) + WireModel3D.regenerateModels() + } } abstract class GateRenderer[T <: GatePart] diff --git a/src/integration/scala/mrtjp/projectred/integration/proxies.scala b/src/integration/scala/mrtjp/projectred/integration/proxies.scala index 4148cd659..305f8470d 100644 --- a/src/integration/scala/mrtjp/projectred/integration/proxies.scala +++ b/src/integration/scala/mrtjp/projectred/integration/proxies.scala @@ -6,6 +6,7 @@ package mrtjp.projectred.integration import codechicken.lib.texture.{AtlasRegistrar, IIconRegister, SpriteRegistryHelper} +import codechicken.lib.util.ResourceUtils import mrtjp.projectred.ProjectRedIntegration import mrtjp.projectred.core.IProxy import net.minecraft.util.ResourceLocation @@ -43,6 +44,7 @@ class IntegrationProxyClient extends IntegrationProxy @SubscribeEvent @OnlyIn(Dist.CLIENT) override def clientSetup(event:FMLClientSetupEvent):Unit = { + ResourceUtils.registerReloadListener(RenderGate) } @OnlyIn(Dist.CLIENT)