net.minecraftforge.client.event.ModelBakeEvent Java Examples

The following examples show how to use net.minecraftforge.client.event.ModelBakeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModelErrorSuppressor.java    From AgriCraft with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onModelBakePost(ModelBakeEvent event) {
    if (supressErrors) {
        Map<ResourceLocation, Exception> modelErrors = (Map<ResourceLocation, Exception>) ReflectionHelper.getPrivateValue(ModelLoader.class, event.getModelLoader(), "loadingExceptions");
        Set<ModelResourceLocation> missingVariants = (Set<ModelResourceLocation>) ReflectionHelper.getPrivateValue(ModelLoader.class, event.getModelLoader(), "missingVariants");

        List<ResourceLocation> errored = modelErrors.keySet().stream().filter((r) -> IGNORES.contains(r.getResourceDomain())).collect(Collectors.toList());
        List<ResourceLocation> missing = missingVariants.stream().filter((r) -> IGNORES.contains(r.getResourceDomain())).collect(Collectors.toList());

        errored.forEach(modelErrors::remove);
        missing.forEach(missingVariants::remove);

        AgriCore.getLogger("agricraft").info("Suppressed {0} Model Loading Errors!", errored.size());
        AgriCore.getLogger("agricraft").info("Suppressed {0} Missing Model Variants!", missing.size());
    }
}
 
Example #2
Source File: EventsClient.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent
public void onModelBake(ModelBakeEvent event) {
    GibsModelRegistry.onModelBakeEvent(event);

    ResourceLocation modelResourceLocation = new ResourceLocation(ValkyrienSkiesMod.MOD_ID,
        "item/infuser_core_main");
    try {
        IModel model = ModelLoaderRegistry.getModel(modelResourceLocation);
        IBakedModel inventoryModel = model
            .bake(model.getDefaultState(), DefaultVertexFormats.ITEM,
                ModelLoader.defaultTextureGetter());
        IBakedModel handModel = event.getModelRegistry()
            .getObject(new ModelResourceLocation(
                ValkyrienSkiesMod.MOD_ID + ":" + ValkyrienSkiesMod.INSTANCE.physicsCore
                    .getTranslationKey()
                    .substring(5), "inventory"));

        event.getModelRegistry()
            .putObject(
                new ModelResourceLocation(ValkyrienSkiesMod.MOD_ID + ":testmodel", "inventory"),
                new InfuserCoreBakedModel(handModel, inventoryModel));
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
Example #3
Source File: ModelBakeHandler.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onModelBake(ModelBakeEvent event) 
{
	// tool tables
	replaceAnvilModel(locAnvilN, Core.CreateRes(Reference.ModID + ":block/anvil"), event);
	replaceAnvilModel(locAnvilS, Core.CreateRes(Reference.ModID + ":block/anvil"), event);
	replaceAnvilModel(locAnvilE, Core.CreateRes(Reference.ModID + ":block/anvil"), event);
	replaceAnvilModel(locAnvilW, Core.CreateRes(Reference.ModID + ":block/anvil"), event);

	replacePitKilnModel(locPitKilnCharcoal, Core.CreateRes(Reference.ModID + ":block/pitkiln/pitkiln_0"), event);
	replacePitKilnModel(locPitKilnStraw, Core.CreateRes(Reference.ModID + ":block/pitkiln/pitkiln_0"), event);

	replaceSmallVesselModel(locSmallVessel, Core.CreateRes(Reference.ModID + ":block/smallvessel"), event);

	// silence the missing-model message for the default itemblock
	//event.getModelRegistry().putObject(locAnvil, event.getModelRegistry().getObject(locAnvil));
}
 
Example #4
Source File: ProxyClient.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onModelBake(ModelBakeEvent event) {
	MODEL_BACKPACK        = bakeBlockModel("wearablebackpacks:block/backpack");
	MODEL_BACKPACK_TOP    = bakeBlockModel("wearablebackpacks:block/backpack_top");
	MODEL_BACKPACK_STRAPS = bakeBlockModel("wearablebackpacks:block/backpack_straps");
	
	MODEL_BACKPACK_ENCH     = new BakedModelDefaultTexture(MODEL_BACKPACK);
	MODEL_BACKPACK_ENCH_TOP = new BakedModelDefaultTexture(MODEL_BACKPACK_TOP);
	
	MODEL_BACKPACK_BOX = ModelAABBCalculator.calcFrom(MODEL_BACKPACK, MODEL_BACKPACK_TOP);
}
 
Example #5
Source File: MetaItems.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
private static void registerSpecialItemModel(ModelBakeEvent event, MetaValueItem metaValueItem, IBakedModel bakedModel) {
    //god these casts when intellij says you're fine but compiler complains about shit boundaries
    //noinspection RedundantCast
    ResourceLocation modelPath = ((MetaItem) metaValueItem.getMetaItem()).createItemModelPath(metaValueItem, "");
    ModelResourceLocation modelResourceLocation = new ModelResourceLocation(modelPath, "inventory");
    event.getModelRegistry().putObject(modelResourceLocation, bakedModel);
}
 
Example #6
Source File: ModelBakeHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static void replaceSmallVesselModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) {
	try {
		IModel model = ModelLoaderRegistry.getModel(modelLocation);
		IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation);
		if(standard instanceof IPerspectiveAwareModel) {
			IBakedModel finalModel = new BakedSmallVesselModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK);

			event.getModelRegistry().putObject(modelVariantLocation, finalModel);
		}

	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example #7
Source File: ModelBakeHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static void replacePitKilnModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) {
	try {
		IModel model = ModelLoaderRegistry.getModel(modelLocation);
		IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation);
		if(standard instanceof IPerspectiveAwareModel) {
			IBakedModel finalModel = new BakedPitKilnModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK);

			event.getModelRegistry().putObject(modelVariantLocation, finalModel);
		}

	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example #8
Source File: ModelBakeHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static void replaceAnvilModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) {
	try {
		IModel model = ModelLoaderRegistry.getModel(modelLocation);
		IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation);
		if(standard instanceof IPerspectiveAwareModel) {
			IBakedModel finalModel = new BakedAnvilModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK);

			event.getModelRegistry().putObject(modelVariantLocation, finalModel);
		}

	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example #9
Source File: ClientProxy.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@SubscribeEvent
public void modelBakeEvent(ModelBakeEvent event) {
	Object object =  event.getModelRegistry().getObject(ModelRocket.resource);
	if (object instanceof IBakedModel) {
		IBakedModel existingModel = (IBakedModel)object;
		ModelRocket customModel = new ModelRocket();
		event.getModelRegistry().putObject(ModelRocket.resource, existingModel);
	}
}
 
Example #10
Source File: FluidPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onModelsBake(ModelBakeEvent event) {
    event.getModelRegistry().putObject(MODEL_LOCATION, this);
}
 
Example #11
Source File: ModelRegistryHelper.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SubscribeEvent
public void onModelBake(ModelBakeEvent event) {
    for(Pair<ModelResourceLocation, IBakedModel> pair : registerModels)
        event.modelRegistry.putObject(pair.getKey(), pair.getValue());
}
 
Example #12
Source File: ModelNullifierBaked.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public static void onModelbakeEvent(ModelBakeEvent event)
{
    MODEL_LOADER = event.getModelLoader();
}
 
Example #13
Source File: GibsModelRegistry.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
public static void onModelBakeEvent(ModelBakeEvent event) {
    System.out.println(
        "Valkyrien Skies got a model bake event! " + NAMES_TO_RESOURCE_LOCATION.size());
}
 
Example #14
Source File: MixinModelManager.java    From VanillaFix with MIT License 4 votes vote down vote up
/**
 * @reason Don't set up the ModelLoader. Instead, set up the caching DynamicModelProvider
 * and DynamicBakedModelProviders, which will act as the model registry.
 */
@Overwrite
public void onResourceManagerReload(IResourceManager resourceManager) {
    // Generate information about model locations, such as the blockstate location to block map
    // and the item variant to model location map.
    ModelLocationInformation.init(modelProvider.getBlockStateMapper());

    // Get custom loaders
    Set<ICustomModelLoader> loaders;
    try {
        Field loadersField = ModelLoaderRegistry.class.getDeclaredField("loaders");
        loadersField.setAccessible(true);
        // noinspection unchecked
        loaders = (Set<ICustomModelLoader>) loadersField.get(null);
    } catch (ReflectiveOperationException e) {
        throw new RuntimeException(e);
    }

    // Create the dynamic model and bake model providers
    DynamicModelProvider dynamicModelProvider = new DynamicModelProvider(loaders);
    DynamicModelProvider.instance = dynamicModelProvider;
    DynamicBakedModelProvider dynamicBakedModelProvider = new DynamicBakedModelProvider(dynamicModelProvider);
    DynamicBakedModelProvider.instance = dynamicBakedModelProvider;
    modelRegistry = dynamicBakedModelProvider;

    // Create the texture map
    ((DynamicTextureMap) texMap).init();

    // Get the default model, returned by getModel when the model provider returns null
    defaultModel = modelRegistry.getObject(new ModelResourceLocation("builtin/missing", "missing"));

    // Register the universal bucket item
    if (FluidRegistry.isUniversalBucketEnabled()) {
        ModelLoader.setBucketModelDefinition(ForgeModContainer.getInstance().universalBucket);
    }

    // Post the event, but just log an error if a listener throws an exception. The ModelLoader is
    // null, but very few mods use it. Custom support will be needed for those that do.
    EventUtil.postEventAllowingErrors(new ModelBakeEvent((ModelManager) (Object) this, modelRegistry, null));

    // Make the model provider load blockstate to model information. See MixinBlockModelShapes
    modelProvider.reloadModels();
}
 
Example #15
Source File: MetaItems.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void registerBakedModels(ModelBakeEvent event) {
    GTLog.logger.info("Registering special item models");
    registerSpecialItemModel(event, COVER_FACADE, new FacadeItemModel());
}
 
Example #16
Source File: CableRenderer.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onModelsBake(ModelBakeEvent event) {
    GTLog.logger.info("Injected cable render model");
    event.getModelRegistry().putObject(MODEL_LOCATION, this);
}
 
Example #17
Source File: InvPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onModelsBake(ModelBakeEvent event) {
    event.getModelRegistry().putObject(MODEL_LOCATION, this);
}
 
Example #18
Source File: MetaTileEntityRenderer.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onModelsBake(ModelBakeEvent event) {
    GTLog.logger.info("Injected MetaTileEntity render model");
    event.getModelRegistry().putObject(MODEL_LOCATION, this);
}
 
Example #19
Source File: ModelRegistryHelper.java    From CodeChickenLib with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * A Simple callback for model baking.
 *
 * @param modelRegistry The Model registry.
 */
void onModelBake(ModelBakeEvent event);
 
Example #20
Source File: ModelRegistryHelper.java    From CodeChickenLib with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Called before CCL does anything to the ModelRegistry.
 * Useful for wrapped models, Use this in the constructor of the wrapped model.
 *
 * @param modelRegistry The Model registry.
 */
void onModelBakePre(ModelBakeEvent event);