41 lines
1.6 KiB
Java
41 lines
1.6 KiB
Java
package net.minecraft.client.data.models.model;
|
|
|
|
import java.util.function.UnaryOperator;
|
|
import net.fabricmc.api.EnvType;
|
|
import net.fabricmc.api.Environment;
|
|
import net.minecraft.core.registries.BuiltInRegistries;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.world.item.Item;
|
|
import net.minecraft.world.level.block.Block;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public class ModelLocationUtils {
|
|
@Deprecated
|
|
public static ResourceLocation decorateBlockModelLocation(String name) {
|
|
return ResourceLocation.withDefaultNamespace("block/" + name);
|
|
}
|
|
|
|
public static ResourceLocation decorateItemModelLocation(String name) {
|
|
return ResourceLocation.withDefaultNamespace("item/" + name);
|
|
}
|
|
|
|
public static ResourceLocation getModelLocation(Block block, String suffix) {
|
|
ResourceLocation resourceLocation = BuiltInRegistries.BLOCK.getKey(block);
|
|
return resourceLocation.withPath((UnaryOperator<String>)(string2 -> "block/" + string2 + suffix));
|
|
}
|
|
|
|
public static ResourceLocation getModelLocation(Block block) {
|
|
ResourceLocation resourceLocation = BuiltInRegistries.BLOCK.getKey(block);
|
|
return resourceLocation.withPrefix("block/");
|
|
}
|
|
|
|
public static ResourceLocation getModelLocation(Item item) {
|
|
ResourceLocation resourceLocation = BuiltInRegistries.ITEM.getKey(item);
|
|
return resourceLocation.withPrefix("item/");
|
|
}
|
|
|
|
public static ResourceLocation getModelLocation(Item item, String suffix) {
|
|
ResourceLocation resourceLocation = BuiltInRegistries.ITEM.getKey(item);
|
|
return resourceLocation.withPath((UnaryOperator<String>)(string2 -> "item/" + string2 + suffix));
|
|
}
|
|
}
|