net.minecraft.client.renderer.block.model.ModelResourceLocation Java Examples

The following examples show how to use net.minecraft.client.renderer.block.model.ModelResourceLocation. 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 vote down vote up
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: Fluids.java    From BaseMetals with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SideOnly(Side.CLIENT)
public static void bakeModels(String modID){
	for(Fluid fluid : fluidBlocks.keySet()){
		BlockFluidBase block = fluidBlocks.get(fluid);
		Item item = Item.getItemFromBlock(block);
		final ModelResourceLocation fluidModelLocation = new ModelResourceLocation(
				modID.toLowerCase() + ":" + fluidBlockNames.get(block), "fluid");
           ModelBakery.registerItemVariants(item);
		ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition()
		{
			public ModelResourceLocation getModelLocation(ItemStack stack)
			{
				return fluidModelLocation;
			}
		});
		ModelLoader.setCustomStateMapper(block, new StateMapperBase()
		{
			protected ModelResourceLocation getModelResourceLocation(IBlockState state)
			{
				return fluidModelLocation;
			}
		});
	}
}
 
Example #3
Source File: VariantLoader.java    From VanillaFix with MIT License 6 votes vote down vote up
@Override
public IModel loadModel(ResourceLocation modelLocation) throws Exception {
    ModelResourceLocation variant = (ModelResourceLocation) modelLocation;
    ModelBlockDefinition definition = getModelBlockDefinition(variant);

    if (definition.hasVariant(variant.getVariant())) {
        return new WeightedRandomModel(definition.getVariant(variant.getVariant()));
    } else {
        if (definition.hasMultipartData()) {
            Block block = ModelLocationInformation.getBlockFromBlockstateLocation(new ResourceLocation(variant.getNamespace(), variant.getPath()));
            if (block != null) {
                definition.getMultipartData().setStateContainer(block.getBlockState());
            }
        }

        return new MultipartModel(new ResourceLocation(variant.getNamespace(), variant.getPath()), definition.getMultipartData());
    }
}
 
Example #4
Source File: ClientProxy.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static void registerItemModelWithVariants(ItemEnderUtilities item)
{
    if (item.isEnabled())
    {
        ResourceLocation[] variants = item.getItemVariants();
        NonNullList<ItemStack> items = NonNullList.create();
        item.getSubItems(item.getCreativeTab(), items);

        int i = 0;
        for (ItemStack stack : items)
        {
            ModelResourceLocation mrl = (variants[i] instanceof ModelResourceLocation) ?
                                        (ModelResourceLocation)variants[i] : new ModelResourceLocation(variants[i], "inventory");
            ModelLoader.setCustomModelResourceLocation(stack.getItem(), stack.getMetadata(), mrl);
            i++;
        }
    }
}
 
Example #5
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 #6
Source File: ItemIceMelter.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public ResourceLocation[] getItemVariants()
{
    String rl = Reference.MOD_ID + ":" + "item_" + this.name;

    return new ModelResourceLocation[] {
            new ModelResourceLocation(rl, "type=basic"),
            new ModelResourceLocation(rl, "type=super")
    };
}
 
Example #7
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 #8
Source File: ItemPebble.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
@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 #9
Source File: ClientProxy.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void registerItemModelWithNameSuffix(ItemEnderUtilities item, int meta, String nameSuffix)
{
    if (item.isEnabled())
    {
        ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName() + nameSuffix, "inventory"));
    }
}
 
Example #10
Source File: ItemRake.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
public List<Tuple<Integer, ModelResourceLocation>> getModelDefinitions() {
    return ImmutableList.of(
            new Tuple<>(0, new ModelResourceLocation(this.getRegistryName() + "")),
            new Tuple<>(1, new ModelResourceLocation(this.getRegistryName() + "_iron"))
    );
}
 
Example #11
Source File: ItemOre.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
@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 #12
Source File: MetaBlocks.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #13
Source File: MetaBlocks.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
private static void registerItemModelWithOverride(Block block, Map<IProperty<?>, Comparable<?>> stateOverrides) {
    for (IBlockState state : block.getBlockState().getValidStates()) {
        HashMap<IProperty<?>, Comparable<?>> stringProperties = new HashMap<>(state.getProperties());
        stringProperties.putAll(stateOverrides);
        //noinspection ConstantConditions
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block),
            block.getMetaFromState(state),
            new ModelResourceLocation(block.getRegistryName(),
                statePropertiesToString(stringProperties)));
    }
}
 
Example #14
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 #15
Source File: MeshDef.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) 
{
	if(rl.length > 1 && stack.getItemDamage() < rl.length)
		return rl[stack.getItemDamage()];

	return rl[0];
}
 
Example #16
Source File: ClientProxy.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #17
Source File: ModelMethods.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 TFC2 with GNU General Public License v3.0 5 votes vote down vote up
private void registerVariantModel(Item item, String path, String[] variantNames, int metaStart, int metaEnd)
{
	for(int meta = metaStart; meta < metaEnd; meta++)
	{
		String vName = Core.textConvert(variantNames[meta]);
		ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation(Reference.ModID + ":" + path + vName, "inventory");
		ModelLoader.setCustomModelResourceLocation(item, meta, itemModelResourceLocation);
		//ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(new ResourceLocation(Reference.ModID, item.getRegistryName().getResourcePath()), vName));
	}
}
 
Example #19
Source File: ItemTrowel.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
public List<Tuple<Integer, ModelResourceLocation>> getModelDefinitions() {
    return ImmutableList.of(
            new Tuple<>(0, new ModelResourceLocation(this.getRegistryName() + "")),
            new Tuple<>(1, new ModelResourceLocation(this.getRegistryName() + "_full"))
    );
}
 
Example #20
Source File: MixinItemModelMesherForge.java    From VanillaFix with MIT License 5 votes vote down vote up
/**
 * @reason Get the stored location for that item and meta, and get the model
 * from that location from the model manager.
 **/
@Overwrite
@Override
protected IBakedModel getItemModel(Item item, int meta) {
    TIntObjectHashMap<ModelResourceLocation> map = locations.get(item.delegate);
    return map == null ? null : getModelManager().getModel(map.get(meta));
}
 
Example #21
Source File: MixinItemModelMesherForge.java    From VanillaFix with MIT License 5 votes vote down vote up
/**
 * @reason Don't get all models during init (with dynamic loading, that would
 * generate them all). Just store location instead.
 **/
@Overwrite
@Override
public void register(Item item, int meta, ModelResourceLocation location) {
    IRegistryDelegate<Item> key = item.delegate;
    TIntObjectHashMap<ModelResourceLocation> locs = locations.get(key);
    if (locs == null) {
        locs = new TIntObjectHashMap<>();
        locations.put(key, locs);
    }
    locs.put(meta, location);
}
 
Example #22
Source File: VariantSelectorData.java    From OpenModsLib with MIT License 5 votes vote down vote up
private static Set<ResourceLocation> parseArrayOfLocations(String name, JsonElement value) {
	final ImmutableSet.Builder<ResourceLocation> result = ImmutableSet.builder();

	for (JsonElement e : value.getAsJsonArray()) {
		if (e.isJsonPrimitive()) {
			final ResourceLocation loc = new ModelResourceLocation(value.getAsString());
			result.add(loc);
		} else {
			throw new JsonSyntaxException("Expected elements of " + name + " to be a string, was " + JsonUtils.toString(e));
		}
	}

	return result.build();
}
 
Example #23
Source File: ClientProxy.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
private static void registerItemModel(Item toRegister) {
    RenderItem renderItem = Minecraft.getMinecraft()
        .getRenderItem();
    renderItem.getItemModelMesher()
        .register(toRegister, 0, new ModelResourceLocation(
            ValkyrienSkiesMod.MOD_ID + ":" + toRegister.getTranslationKey()
                .substring(5), "inventory"));
}
 
Example #24
Source File: ClientProxy.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void registerItemBlockModel(BlockEnderUtilities blockIn, int meta, String fullVariant)
{
    if (blockIn.isEnabled())
    {
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(blockIn), meta,
            new ModelResourceLocation(blockIn.getRegistryName(), fullVariant));
    }
}
 
Example #25
Source File: ItemEnderCapacitor.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public ModelResourceLocation getModelLocation(ItemStack stack)
{
    String pre = this.getCharge(stack) > 0 ? "tex=charged_" : "tex=empty_";
    int index = MathHelper.clamp(stack.getMetadata(), 0, 3);

    return new ModelResourceLocation(Reference.MOD_ID + ":" + "item_" + this.name, pre + index);
}
 
Example #26
Source File: ClientProxyControl.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
private static void registerItemModel(Item toRegister) {
    RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
    ModelResourceLocation modelResourceLocation = new ModelResourceLocation(
        ValkyrienSkiesControl.MOD_ID + ":" + toRegister.getTranslationKey()
            .substring(5), "inventory");
    renderItem.getItemModelMesher()
        .register(toRegister, 0, modelResourceLocation);
}
 
Example #27
Source File: ItemEnderPearlReusable.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public ResourceLocation[] getItemVariants()
{
    String rl = Reference.MOD_ID + ":" + "item_" + this.name;

    return new ResourceLocation[] {
            new ModelResourceLocation(rl, "elite=false"),
            new ModelResourceLocation(rl, "elite=true")
    };
}
 
Example #28
Source File: ProxyClient.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onRegisterModels(ModelRegistryEvent event) {
	if (BackpacksContent.BACKPACK != null) {
		ModelLoader.setCustomModelResourceLocation(BackpacksContent.BACKPACK, 0,
			new ModelResourceLocation("wearablebackpacks:backpack", "inventory"));
	}
}
 
Example #29
Source File: RegistryItemQueue.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@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 #30
Source File: ItemMesh.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
@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"));
}