use of net.minecraftforge.client.ItemModelMesherForge in project FoamFix by asiekierka.
the class FoamFixModelRegistryDuplicateWipe method onTextureStitchPost.
@SubscribeEvent
public void onTextureStitchPost(TextureStitchEvent.Post event) {
ItemModelMesher imm = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
BlockModelShapes bms = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
ModelManager mgr = bms.getModelManager();
Field f = ReflectionHelper.findField(ModelManager.class, "modelRegistry", "field_174958_a");
try {
IRegistry<ModelResourceLocation, IBakedModel> registry = (IRegistry<ModelResourceLocation, IBakedModel>) f.get(mgr);
FoamFix.logger.info("Clearing unnecessary model registry of size " + registry.getKeys().size() + ".");
for (ModelResourceLocation l : registry.getKeys()) {
registry.putObject(l, ProxyClient.DUMMY_MODEL);
}
} catch (Exception e) {
e.printStackTrace();
}
f = ReflectionHelper.findField(BlockModelShapes.class, "bakedModelStore", "field_178129_a");
try {
Map<IBlockState, IBakedModel> modelStore = (Map<IBlockState, IBakedModel>) f.get(bms);
FoamFix.logger.info("Clearing unnecessary model store of size " + modelStore.size() + ".");
modelStore.clear();
} catch (Exception e) {
e.printStackTrace();
}
if (imm instanceof ItemModelMesherForge) {
f = ReflectionHelper.findField(ItemModelMesherForge.class, "models");
try {
Map<IRegistryDelegate<Item>, TIntObjectHashMap<IBakedModel>> modelStore = (Map<IRegistryDelegate<Item>, TIntObjectHashMap<IBakedModel>>) f.get(imm);
FoamFix.logger.info("Clearing unnecessary item shapes cache of size " + modelStore.size() + ".");
modelStore.clear();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aggregations