Search in sources :

Example 1 with ModelLoader

use of net.minecraftforge.client.model.ModelLoader in project AgriCraft by AgriCraft.

the class ModelAndTextureHandler method onModelLoadEvent.

// Used to add the models used in seed rendering
@SubscribeEvent
@SuppressWarnings("unused")
public void onModelLoadEvent(ModelRegistryEvent event) {
    // Jsons
    AgriCore.getPlants().getAllElements().stream().map(AgriPlant::getSeedModel).map(this::toResourceLocation).forEach(ModelLoader::addSpecialModel);
    // no plant instance
    ModelLoader.addSpecialModel(NoPlant.getInstance().getSeedModel());
    // seed bag models
    ModelLoader.addSpecialModel(new ResourceLocation(AgriCraft.instance.getModId(), "item/agri_seed_bag_empty"));
    ModelLoader.addSpecialModel(new ResourceLocation(AgriCraft.instance.getModId(), "item/agri_seed_bag_partial"));
    ModelLoader.addSpecialModel(new ResourceLocation(AgriCraft.instance.getModId(), "item/agri_seed_bag_full"));
    // channel valve hand Wheel
    ModelLoader.addSpecialModel(TileEntityIrrigationChannelRenderer.MODEL_HANDWHEEL);
}
Also used : ModelLoader(net.minecraftforge.client.model.ModelLoader) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) AgriPlant(com.agricraft.agricore.plant.AgriPlant) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with ModelLoader

use of net.minecraftforge.client.model.ModelLoader in project AgriCraft by AgriCraft.

the class AgriPlantQuadGenerator method fetchQuads.

@SuppressWarnings("deprecation")
public List<BakedQuad> fetchQuads(@Nonnull ResourceLocation location) {
    ModelLoader loader = ModelLoader.instance();
    if (loader == null) {
        return ImmutableList.of();
    }
    IBakedModel model = loader.getBakedModel(location, ModelRotation.X0_Y0, this::getSprite);
    return model == null ? ImmutableList.of() : model.getQuads(null, null, this.getRandom());
}
Also used : ModelLoader(net.minecraftforge.client.model.ModelLoader)

Example 3 with ModelLoader

use of net.minecraftforge.client.model.ModelLoader in project BiomesOPlenty by Glitchfiend.

the class LeavesModelEventHandler method onModelBake.

@SubscribeEvent
public void onModelBake(ModelBakeEvent event) throws Exception {
    ModelLoader loader = event.getModelLoader();
    IRegistry<ModelResourceLocation, IBakedModel> registry = event.getModelRegistry();
    IBakedModel originalBakedModel = registry.getObject(LEAVES_LOC);
    // Load and bake the fast flowering leaves model
    IModel fastModel = ModelLoaderRegistry.getModel(new ResourceLocation("biomesoplenty:block/flowering_leaves_fast"));
    IBakedModel bakedFastModel = fastModel.bake(fastModel.getDefaultState(), DefaultVertexFormats.BLOCK, ModelLoader.defaultTextureGetter());
    registry.putObject(LEAVES_LOC, new ModelLeaves(originalBakedModel, bakedFastModel));
}
Also used : ModelLoader(net.minecraftforge.client.model.ModelLoader) IModel(net.minecraftforge.client.model.IModel) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ModelLoader (net.minecraftforge.client.model.ModelLoader)3 ResourceLocation (net.minecraft.util.ResourceLocation)2 AgriPlant (com.agricraft.agricore.plant.AgriPlant)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 ModelResourceLocation (net.minecraft.client.renderer.model.ModelResourceLocation)1 IModel (net.minecraftforge.client.model.IModel)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1