Пример #1
0
        private BlockModel ModelResolver(string arg)
        {
            if (ResourcePack.TryGetBlockModel(arg, out var model))
            {
                return(model);
            }

            return(null);
        }
Пример #2
0
        public static bool ResolveItemTexture(string itemName, out Texture2D texture)
        {
            if (ResourcePack.ItemModels.TryGetValue(itemName, out ResourcePackItem item))
            {
                var texture0 = item.Textures.FirstOrDefault();
                if (texture0.Value != null)
                {
                    if (ResourcePack.TryGetBitmap(texture0.Value, out Bitmap bmp))
                    {
                        texture = TextureUtils.BitmapToTexture2D(Alex.Instance.GraphicsDevice, bmp);
                        return(true);
                    }
                    else
                    {
                        Log.Debug($"Could not find texture for item: {itemName} (Search Term: {texture0.Value})");
                    }
                }
            }
            else
            {
                if (ResourcePack.TryGetBlockModel(itemName, out var b))
                {
                    var texture0 = b.Textures.OrderBy(x => x.Value.Contains("side")).FirstOrDefault();
                    if (texture0.Value != null)
                    {
                        if (ResourcePack.TryGetBitmap(texture0.Value, out Bitmap bmp))
                        {
                            texture = TextureUtils.BitmapToTexture2D(Alex.Instance.GraphicsDevice, bmp);
                            return(true);
                        }
                        else
                        {
                            Log.Debug($"Could not find texture for item: {itemName} (Search Term: {texture0.Value})");
                        }
                    }
                }
                else
                {
                    Log.Debug($"Could not find model for item: {itemName}");
                }
            }

            texture = null;
            return(false);
        }