Ejemplo n.º 1
0
        public bool TryGetBlockModel(ResourceLocation key, out ResourcePackModelBase model)
        {
            model = null;
            foreach (var resourcePack in ActiveResourcePacks.Reverse())
            {
                if (resourcePack.BlockModels.TryGetValue(key, out model))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        public bool TryGetBedrockBitmap(ResourceLocation location, out Image <Rgba32> bitmap)
        {
            bitmap = null;
            foreach (var resourcePack in ActiveBedrockResourcePacks.Reverse())
            {
                if (resourcePack.TryGetTexture(location, out var f))
                {
                    bitmap = f;
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        private static void Add(ResourceManager resourceManager, GraphicsDevice graphics, EntityDescription def, EntityModel model, ResourceLocation name)
        {
            _registeredRenderers.AddOrUpdate(name,
                                             (t) =>
            {
                if (t == null)
                {
                    var textures = def.Textures;
                    string texture;
                    if (!textures.TryGetValue("default", out texture) && !textures.TryGetValue(name.Path, out texture))
                    {
                        texture = textures.FirstOrDefault().Value;
                    }

                    if (resourceManager.BedrockResourcePack.Textures.TryGetValue(texture,
                                                                                 out var bmp))
                    {
                        t = TextureUtils.BitmapToTexture2D(graphics, bmp);
                    }
                }

                return(new EntityModelRenderer(model, t));
            },
                                             (s, func) =>
            {
                return((t) =>
                {
                    var textures = def.Textures;
                    string texture;
                    if (!(textures.TryGetValue("default", out texture) || textures.TryGetValue(name.Path, out texture)))
                    {
                        texture = textures.FirstOrDefault().Value;
                    }

                    if (resourceManager.BedrockResourcePack.Textures.TryGetValue(texture,
                                                                                 out var bmp))
                    {
                        t = TextureUtils.BitmapToTexture2D(graphics, bmp);
                    }

                    return new EntityModelRenderer(model, t);
                });
            });
        }