net.minecraftforge.client.model.ModelLoader Java Examples
The following examples show how to use
net.minecraftforge.client.model.ModelLoader.
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: RegistryItemQueue.java From TFC2 with GNU General Public License v3.0 | 7 votes |
private void registerEntry(Entry e) { if(e.item instanceof IRegisterSelf) { for(int c = 0; c < ((IRegisterSelf)e.item).getSubTypeNames().length; c++) { String path = ((IRegisterSelf)e.item).getPath(); String subName = ((IRegisterSelf)e.item).getSubTypeNames()[c]; ModelLoader.setCustomModelResourceLocation(e.item, c, new ModelResourceLocation(Reference.ModID + ":"+path+subName, "inventory")); } } else { ModelLoader.setCustomModelResourceLocation(e.item, 0, new ModelResourceLocation(Reference.ModID + ":"+e.item.getRegistryName().getResourcePath(), "inventory")); } }
Example #2
Source File: ClientProxy.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void preInit(FMLPreInitializationEvent event) { super.preInit(event); if (ConfigValues.versionCheckerEnabled) VersionChecker.register(); ModEntities.initModels(); CustomBlockMapSprites.INSTANCE.register(new ResourceLocation(Wizardry.MODID, "blocks/mana_crystal_ring")); CustomBlockMapSprites.INSTANCE.register(new ResourceLocation(Wizardry.MODID, "blocks/mana_crystal_ring_outer")); CustomBlockMapSprites.INSTANCE.register(new ResourceLocation(Wizardry.MODID, "blocks/mana_crystal")); CustomBlockMapSprites.INSTANCE.register(new ResourceLocation(Wizardry.MODID, "blocks/outputPearl")); CustomBlockMapSprites.INSTANCE.register(new ResourceLocation(Wizardry.MODID, "blocks/mana_orb")); CustomBlockMapSprites.INSTANCE.register(new ResourceLocation(Wizardry.MODID, "blocks/mana_pearl_cube")); CustomBlockMapSprites.INSTANCE.register(new ResourceLocation(Wizardry.MODID, "blocks/nacre_pearl_cube")); // Load and bake the 2D models ModelBakery.registerItemVariants(ModItems.BOOK, new ModelResourceLocation("wizardry:book", "inventory")); ModelResourceLocation default3dPath = new ModelResourceLocation("wizardry:book", "inventory"); ModelLoader.setCustomMeshDefinition(ModItems.BOOK, stack -> default3dPath); ModKeybinds.register(); }
Example #3
Source File: EventsClient.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@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 #4
Source File: PLModelRegistry.java From Production-Line with MIT License | 6 votes |
public static void loadBlockModels() { registerBlockModel(PLBlocks.oreIridium); registerBlockModel(PLBlocks.airBrakeCasing); registerBlockModel(PLBlocks.compressedWaterHyacinth); registerBlockModel(PLBlocks.dehydratedWaterHyacinthblock); ModelLoader.setCustomStateMapper(PLBlocks.machine, new StateMap.Builder().withName(BlockMachine.PROPERTY_TYPE).build()); registerBlockModel(PLBlocks.carbonizeFurnace); registerBlockModel(PLBlocks.heatDryer); registerBlockModel(PLBlocks.evsu); registerBlockModel(PLBlocks.cseu); registerBlockModel(PLBlocks.parallelSpaceSU); registerBlockModel(PLBlocks.advSolar); registerBlockModel(PLBlocks.fluidKineticGenerator); registerBlockModel(PLBlocks.packager); }
Example #5
Source File: MetaBlocks.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@SideOnly(Side.CLIENT) public static void registerItemModels() { ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MACHINE), stack -> MetaTileEntityRenderer.MODEL_LOCATION); ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(CABLE), stack -> CableRenderer.MODEL_LOCATION); ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(FLUID_PIPE), stack -> FluidPipeRenderer.MODEL_LOCATION); registerItemModel(BOILER_CASING); registerItemModel(BOILER_FIREBOX_CASING); registerItemModel(METAL_CASING); registerItemModel(TURBINE_CASING); registerItemModel(MACHINE_CASING); registerItemModel(MUTLIBLOCK_CASING); registerItemModel(WIRE_COIL); registerItemModel(WARNING_SIGN); registerItemModel(GRANITE); registerItemModel(MINERAL); registerItemModel(CONCRETE); registerItemModelWithOverride(LOG, ImmutableMap.of(BlockGregLog.LOG_AXIS, EnumAxis.Y)); registerItemModel(LEAVES); registerItemModel(SAPLING); COMPRESSED.values().stream().distinct().forEach(MetaBlocks::registerItemModel); FRAMES.values().forEach(it -> registerItemModelWithFilteredProperties(it)); ORES.stream().distinct().forEach(MetaBlocks::registerItemModel); }
Example #6
Source File: RenderHandler.java From EmergingTechnology with MIT License | 6 votes |
public static void registerMeshesAndStatesForBlock(Block block) { ModelResourceLocation resourceLocation = new ModelResourceLocation( block.getRegistryName(), "fluid"); ItemMeshDefinition meshDefinition = new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return resourceLocation; } }; StateMapperBase stateMapper = new StateMapperBase() { @Override public ModelResourceLocation getModelResourceLocation(IBlockState state) { return resourceLocation; } }; ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(block), meshDefinition); ModelLoader.setCustomStateMapper(block, stateMapper); }
Example #7
Source File: ModelErrorSuppressor.java From AgriCraft with MIT License | 6 votes |
@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 #8
Source File: DynamicTextureMap.java From VanillaFix with MIT License | 6 votes |
public void init() { deleteGlTexture(); int maximumTextureSize = Minecraft.getGLMaximumTextureSize(); stitcher = new DynamicStitcher(maximumTextureSize, maximumTextureSize, 0, mipmapLevels); listAnimatedSprites.clear(); initMissingImage(); missingImage.generateMipmaps(mipmapLevels); spritesNeedingUpload.add(missingImage); stitcher.addSprite(missingImage); TextureUtil.allocateTextureImpl(getGlTextureId(), mipmapLevels, stitcher.getImageWidth(), stitcher.getImageHeight()); LOGGER.info("Created {}x{} '{}' atlas", stitcher.getImageWidth(), stitcher.getImageHeight(), basePath); EventUtil.postEventAllowingErrors(new TextureStitchEvent.Pre(this)); ModelLoader.White.INSTANCE.register(this); mapRegisteredSprites.put("builtin/white", ModelLoader.White.INSTANCE); // TODO: why is this necessary ModelDynBucket.LoaderDynBucket.INSTANCE.register(this); EventUtil.postEventAllowingErrors(new TextureStitchEvent.Post(this)); }
Example #9
Source File: RegistrationHandler.java From EmergingTechnology with MIT License | 5 votes |
@SideOnly(Side.CLIENT) public static void registerModels(ModelRegistryEvent event) { for (Block block : ModBlocks.getBlocks()) { registerModel(Item.getItemFromBlock(block)); } for (Item item : ModItems.getItems()) { registerModel(item); } registerModTissueModels(); // Hydroponic TESR ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.hydroponic), 0, new ModelResourceLocation(ModBlocks.hydroponic.getRegistryName(), "inventory")); ClientRegistry.bindTileEntitySpecialRenderer(HydroponicTileEntity.class, new HydroponicTESR()); ClientRegistry.bindTileEntitySpecialRenderer(TidalGeneratorTileEntity.class, new AnimationTESR<TidalGeneratorTileEntity>()); ClientRegistry.bindTileEntitySpecialRenderer(WindTileEntity.class, new AnimationTESR<WindTileEntity>()); ClientRegistry.bindTileEntitySpecialRenderer(ScrubberTileEntity.class, new AnimationTESR<ScrubberTileEntity>()); ClientRegistry.bindTileEntitySpecialRenderer(HarvesterTileEntity.class, new AnimationTESR<HarvesterTileEntity>()); RenderHandler.registerMeshesAndStatesForBlock(ModBlocks.carbondioxideblock); RenderHandler.registerMeshesAndStatesForBlock(ModBlocks.nutrientblock); }
Example #10
Source File: ClientProxy.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void registerItem(FWItem item) { super.registerItem(item); //Hacks to inject custom item definition ModelLoader.setCustomMeshDefinition(item, stack -> new ModelResourceLocation(Item.REGISTRY.getNameForObject(item), "inventory")); }
Example #11
Source File: ClientProxy.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void postRegisterBlock(FWBlock block) { super.postRegisterBlock(block); //Hack to inject custom itemblock definition Item itemFromBlock = Item.getItemFromBlock(block); ModelLoader.setCustomMeshDefinition(itemFromBlock, stack -> new ModelResourceLocation(Item.REGISTRY.getNameForObject(itemFromBlock), "inventory")); }
Example #12
Source File: BaublesPlugin.java From AgriCraft with MIT License | 5 votes |
@SubscribeEvent public void registerItems(RegistryEvent.Register<Item> event) { if (ENABLE_AGRI_BAUBLE) { final ItemAgriBauble agriBauble = new ItemAgriBauble(); agriBauble.setUnlocalizedName("agricraft:agri_bauble"); agriBauble.setRegistryName("agricraft:agri_bauble"); event.getRegistry().register(agriBauble); if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { for (Tuple<Integer, ModelResourceLocation> entry : agriBauble.getModelDefinitions()) { ModelLoader.setCustomModelResourceLocation(agriBauble, entry.getFirst(), entry.getSecond()); } } } }
Example #13
Source File: MetaBlocks.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@SideOnly(Side.CLIENT) private static void registerItemModel(Block block) { for (IBlockState state : block.getBlockState().getValidStates()) { //noinspection ConstantConditions ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), block.getMetaFromState(state), new ModelResourceLocation(block.getRegistryName(), statePropertiesToString(state.getProperties()))); } }
Example #14
Source File: BakedModelHandler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public void addBuiltInBlock(Block block, String particleTexture) { this.builtInBlocks.add(new Tuple<>(block, particleTexture)); ModelLoader.setCustomStateMapper(block, SIMPLE_STATE_MAPPER); Item itemFromBlock = Item.getItemFromBlock(block); if (itemFromBlock != Items.AIR) { ModelLoader.setCustomMeshDefinition(itemFromBlock, SIMPLE_MESH_DEFINITION); } }
Example #15
Source File: RegistryItemQueue.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@SideOnly(Side.CLIENT) public void registerMeshes() { Entry e; while (!listMesh.isEmpty()) { e = listMesh.pop(); ModelLoader.setCustomMeshDefinition(e.item, new MeshDef(new ModelResourceLocation(Reference.ModID + ":"+e.item.getRegistryName(), "inventory"))); } }
Example #16
Source File: ModelMethods.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
public static void setBlockStateMapper(Block block, String fileName, String path, String variant) { final String slash = !path.isEmpty() ? "/" : ""; ModelLoader.setCustomStateMapper(block, new DefaultStateMapper() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getNamespace(), path + slash + fileName), variant); } }); }
Example #17
Source File: ModelMethods.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
public static void setBlockStateMapper(Block block, String fileName, String path, IProperty... ignoredProperties) { final String slash = !path.isEmpty() ? "/" : ""; ModelLoader.setCustomStateMapper(block, new DefaultStateMapper() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { Map<IProperty<?>, Comparable<?>> map = Maps.<IProperty<?>, Comparable<?>>newLinkedHashMap(state.getProperties()); for (IProperty<?> iproperty : ignoredProperties) { map.remove(iproperty); } return new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getNamespace(), path + slash + fileName), this.getPropertyString(map)); } }); }
Example #18
Source File: ClientProxy.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void postRegisterBlock(FWBlock block) { super.postRegisterBlock(block); //Hack to inject custom itemblock definition Item itemFromBlock = Item.getItemFromBlock(block); ModelLoader.setCustomMeshDefinition(itemFromBlock, stack -> { ResourceLocation itemRL = (ResourceLocation) Item.itemRegistry.getNameForObject(itemFromBlock); return new ModelResourceLocation(itemRL, "inventory"); }); }
Example #19
Source File: ClientProxy.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private static void registerItemModel(ItemEnderUtilities item, int meta) { if (item.isEnabled()) { ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), "inventory")); } }
Example #20
Source File: ClientProxy.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private static void registerItemModelWithNameSuffix(ItemEnderUtilities item, int meta, String nameSuffix) { if (item.isEnabled()) { ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName() + nameSuffix, "inventory")); } }
Example #21
Source File: ItemResource.java From ExNihiloAdscensio with MIT License | 5 votes |
@SideOnly(Side.CLIENT) public void initModel() { for (int i = 0 ; i < names.size() ; i ++) { String variant = "type="+names.get(i); ModelLoader.setCustomModelResourceLocation(this, i, new ModelResourceLocation("exnihiloadscensio:itemMaterial", variant)); } }
Example #22
Source File: ClientProxy.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private static void registerBlockModels() { ModelLoader.setCustomStateMapper(EnderUtilitiesBlocks.BARREL, new BakedModelBarrel.StateMapper()); ModelLoaderRegistry.registerLoader(new BakedModelBarrel.ModelLoaderBarrel()); ModelLoader.setCustomStateMapper(EnderUtilitiesBlocks.INSERTER, new BakedModelInserter.StateMapper()); ModelLoaderRegistry.registerLoader(new BakedModelInserter.ModelLoaderInserter()); ModelLoaderRegistry.registerLoader(new ModelCamouflageBlock.ModelLoaderCamouflageBlocks()); ModelLoader.setCustomStateMapper(EnderUtilitiesBlocks.ELEVATOR, (new StateMap.Builder()).ignore(BlockElevator.COLOR).build()); ModelLoader.setCustomStateMapper(EnderUtilitiesBlocks.ELEVATOR_SLAB, (new StateMap.Builder()).ignore(BlockElevator.COLOR).build()); ModelLoader.setCustomStateMapper(EnderUtilitiesBlocks.ELEVATOR_LAYER, (new StateMap.Builder()).ignore(BlockElevator.COLOR).build()); }
Example #23
Source File: ItemDoll.java From ExNihiloAdscensio with MIT License | 5 votes |
@SideOnly(Side.CLIENT) public void initModel() { for (int i = 0 ; i < names.size() ; i ++) { String variant = "type="+names.get(i); ModelLoader.setCustomModelResourceLocation(this, i, new ModelResourceLocation("exnihiloadscensio:itemDoll", variant)); } }
Example #24
Source File: ProxyClient.java From WearableBackpacks with MIT License | 5 votes |
@SubscribeEvent public void onRegisterModels(ModelRegistryEvent event) { if (BackpacksContent.BACKPACK != null) { ModelLoader.setCustomModelResourceLocation(BackpacksContent.BACKPACK, 0, new ModelResourceLocation("wearablebackpacks:backpack", "inventory")); } }
Example #25
Source File: ItemOre.java From ExNihiloAdscensio with MIT License | 5 votes |
@SideOnly(Side.CLIENT) public void initModel() { ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation("exnihiloadscensio:itemOre", "type=piece")); ModelLoader.setCustomModelResourceLocation(this, 1, new ModelResourceLocation("exnihiloadscensio:itemOre", "type=hunk")); ModelLoader.setCustomModelResourceLocation(this, 2, new ModelResourceLocation("exnihiloadscensio:itemOre", "type=dust")); if (registerIngot) ModelLoader.setCustomModelResourceLocation(this, 3, new ModelResourceLocation("exnihiloadscensio:itemOre", "type=ingot")); }
Example #26
Source File: ItemPebble.java From ExNihiloAdscensio with MIT License | 5 votes |
@SideOnly(Side.CLIENT) public void initModel() { for (int i = 0; i < names.size(); i++) { String variant = "type=" + names.get(i); ModelLoader.setCustomModelResourceLocation(this, i, new ModelResourceLocation("exnihiloadscensio:itemPebble", variant)); } }
Example #27
Source File: ItemMesh.java From ExNihiloAdscensio with MIT License | 5 votes |
@SideOnly(Side.CLIENT) public void initModel() { ModelLoader.setCustomModelResourceLocation(this, 1, new ModelResourceLocation("exnihiloadscensio:itemMeshString")); ModelLoader.setCustomModelResourceLocation(this, 2, new ModelResourceLocation("exnihiloadscensio:itemMeshFlint")); ModelLoader.setCustomModelResourceLocation(this, 3, new ModelResourceLocation("exnihiloadscensio:itemMeshIron")); ModelLoader.setCustomModelResourceLocation(this, 4, new ModelResourceLocation("exnihiloadscensio:itemMeshDiamond")); }
Example #28
Source File: ClientProxy.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
private void regRenderer(Item item, int meta, String modId, String name) { String resourceName; if (modId != null) { resourceName = modId + ":" + name; } else { resourceName = name; } ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(resourceName, "inventory")); }
Example #29
Source File: BlockCrucible.java From ExNihiloAdscensio with MIT License | 5 votes |
@SideOnly(Side.CLIENT) public void initModel() { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "inventory")); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 1, new ModelResourceLocation(getRegistryName(), "inventory")); }
Example #30
Source File: OreRegistry.java From ExNihiloAdscensio with MIT License | 5 votes |
@SideOnly(Side.CLIENT) public static void initModels() { final ItemMeshDefinition ORES = new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { switch (stack.getItemDamage()) { case 0: return new ModelResourceLocation("exnihiloadscensio:itemOre", "type=piece"); case 1: return new ModelResourceLocation("exnihiloadscensio:itemOre", "type=hunk"); case 2: return new ModelResourceLocation("exnihiloadscensio:itemOre", "type=dust"); case 3: return new ModelResourceLocation("exnihiloadscensio:itemOre", "type=ingot"); default: return new ModelResourceLocation(stack.getItem().getRegistryName(), "inventory"); } } }; for (ItemOre ore : itemOreRegistry) { ModelLoader.setCustomMeshDefinition(ore, ORES); ModelBakery.registerItemVariants(ore, new ModelResourceLocation("exnihiloadscensio:itemOre", "type=piece"), new ModelResourceLocation("exnihiloadscensio:itemOre", "type=hunk"), new ModelResourceLocation("exnihiloadscensio:itemOre", "type=dust"), new ModelResourceLocation("exnihiloadscensio:itemOre", "type=ingot")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ore, ORES); } }