mirror of
https://github.com/GTNewHorizons/GTNHLib.git
synced 2026-11-28 15:36:03 +00:00
Make ModelISBRH.INSTANCE ThreadLocal to fix race condition (#320)
Co-authored-by: ah-OOG-ah <[email protected]>
This commit is contained in:
1 parent
7a8c5f5d3e
commit
e06c7a764d
6 files changed
+8
-8
No files matched your search
@@ -48,7 +48,7 @@ public class ClientProxy extends CommonProxy {
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
super.preInit(event);
|
||||
|
||||
RenderingRegistry.registerBlockHandler(ModelISBRH.INSTANCE);
|
||||
RenderingRegistry.registerBlockHandler(ModelISBRH.INSTANCE.get());
|
||||
|
||||
// External model loader handlers. For the low low price of calling this method (and having your jar scanned),
|
||||
// you too can automatically load textures for your models!
|
||||
|
||||
@@ -44,7 +44,7 @@ import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
@ThreadSafeISBRH(perThread = true)
|
||||
public class ModelISBRH implements ISimpleBlockRenderingHandler, IItemRenderer {
|
||||
|
||||
public static final ModelISBRH INSTANCE = new ModelISBRH();
|
||||
public static final ThreadLocal<ModelISBRH> INSTANCE = ThreadLocal.withInitial(ModelISBRH::new);
|
||||
|
||||
/// Any blocks using a JSON model may return this for [Block#getRenderType()]. However, models are primarily
|
||||
/// identified via the presence of a blockstate -> model map for the block. If you don't have such a file, you can
|
||||
|
||||
@@ -211,7 +211,7 @@ public class ModelRegistry {
|
||||
block.getLocalizedName());
|
||||
return;
|
||||
}
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(block), ModelISBRH.INSTANCE);
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(block), ModelISBRH.INSTANCE.get());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -83,12 +83,12 @@ public class BlockIconTransformer implements IClassTransformer {
|
||||
///
|
||||
/// This is what our hook is injecting for the IBlockAccess variant:
|
||||
/// ```java
|
||||
/// if (this.nhlib$isModeled) return ModelISBRH.INSTANCE.getParticleIcon(world, x, y, z);
|
||||
/// if (this.nhlib$isModeled) return ModelISBRH.INSTANCE.get().getParticleIcon(world, x, y, z);
|
||||
/// ```
|
||||
///
|
||||
/// This is what our hook is injecting for the side:meta and just side variants:
|
||||
/// ```java
|
||||
/// if (this.nhlib$isModeled) return ModelISBRH.INSTANCE.getMissingIcon();
|
||||
/// if (this.nhlib$isModeled) return ModelISBRH.INSTANCE.get().getMissingIcon();
|
||||
/// ```
|
||||
/// This is because modeled blocks *need* world access to properly get their particle icons. Returning missingno
|
||||
/// fails loudly, allowing us to find and patch out the incorrect usages.
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ public class MixinEffectRenderer_FixParticleIcons {
|
||||
@Local(ordinal = 0, argsOnly = true) int x, @Local(ordinal = 1, argsOnly = true) int y,
|
||||
@Local(ordinal = 2, argsOnly = true) int z) {
|
||||
if (((BlockModelInfo) block).nhlib$isModeled())
|
||||
original.setParticleIcon(ModelISBRH.INSTANCE.getParticleIcon(worldObj, x, y, z));
|
||||
original.setParticleIcon(ModelISBRH.INSTANCE.get().getParticleIcon(worldObj, x, y, z));
|
||||
return original;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class MixinEffectRenderer_FixParticleIcons {
|
||||
@Local(ordinal = 0, argsOnly = true) int x, @Local(ordinal = 1, argsOnly = true) int y,
|
||||
@Local(ordinal = 2, argsOnly = true) int z) {
|
||||
if (((BlockModelInfo) block).nhlib$isModeled())
|
||||
original.setParticleIcon(ModelISBRH.INSTANCE.getParticleIcon(worldObj, x, y, z));
|
||||
original.setParticleIcon(ModelISBRH.INSTANCE.get().getParticleIcon(worldObj, x, y, z));
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public abstract class MixinRenderBlocks {
|
||||
@Local(name = "l") int renderType) {
|
||||
if (((BlockModelInfo) block).nhlib$isModeled()) {
|
||||
cir.setReturnValue(
|
||||
ModelISBRH.INSTANCE
|
||||
ModelISBRH.INSTANCE.get()
|
||||
.renderWorldBlock(blockAccess, x, y, z, block, renderType, (RenderBlocks) (Object) this));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user