Пропадает текстура итема при смене языка

Версия Minecraft
1.12.2
25
6
И снова здравствуйте. Заметил что при смене языка пропадают текстуры блоков без метадаты в инвентаре и руке и они заменяются на фиолетово-черные кубы. Если блок поставить то он с текстурой. В консоли пишет, что мол не найдено столько-то моделей. Если перезапустить клиент и перезайти в игру - всё становится нормально.
У блоков с метадатой всё ок.
Кто сталкивался с такой ситуацией? Проблема вроде как незначительная, но всё же.


BlocksRegister.class:
package de.shittyco.morematerials.blocks;

import de.shittyco.morematerials.blocks.fence.BlockBrickFence;
import de.shittyco.morematerials.blocks.fence.BlockBrickFenceGate;
import de.shittyco.morematerials.blocks.roof.BlockStainedBrickRoofing;
import de.shittyco.morematerials.blocks.roof.BlockThatchedRoofing;
import de.shittyco.morematerials.blocks.slab.BlockDoubleStainedBrickSlab;
import de.shittyco.morematerials.blocks.slab.BlockHalfStainedBrickSlab;
import de.shittyco.morematerials.blocks.slab.BlockStainedBrickSlab;
import de.shittyco.morematerials.blocks.stairs.BlockStainedBrickStairs;
import de.shittyco.morematerials.blocks.stone.BlockStainedBricks;
import de.shittyco.morematerials.blocks.stone.ItemBlockStainedBricks;
import de.shittyco.morematerials.blocks.wall.BlockBrickWall;
import de.shittyco.morematerials.blocks.wall.BlockHardenedClayWall;
import de.shittyco.morematerials.blocks.wall.BlockStainedBrickWall;
import de.shittyco.morematerials.blocks.wall.BlockStainedHardenedClayWall;
import de.shittyco.morematerials.blocks.wattle.BlockWattleAndDaub;
import de.shittyco.morematerials.blocks.wattle.BlockWattlePanel;
import de.shittyco.morematerials.blocks.wood.BlockBackslashWoodenFrame;
import de.shittyco.morematerials.blocks.wood.BlockCrossWoodenFrame;
import de.shittyco.morematerials.blocks.wood.BlockSlashWoodenFrame;
import de.shittyco.morematerials.blocks.wood.BlockWoodenFrame;
import de.shittyco.morematerials.blocks.wood.ItemBlockWoodenFrame;
import de.shittyco.morematerials.utils.ColorUtility;
import de.shittyco.morematerials.utils.WoodUtility;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemSlab;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlocksRegister {
   
    public static BlockStainedBricks stainedBrickBlocks = new BlockStainedBricks();
   
    public static Block[] stainedBrickSlabBlocks = new BlockStainedBrickSlab[2 * ColorUtility.COLOR_COUNT];
   
    public static Block[] stainedBrickWallBlocks = new BlockStainedBrickWall[ColorUtility.COLOR_COUNT];
   
    public static Block brickWall = new BlockBrickWall();
   
    public static Block[] stainedHardenedClayWallBlocks = new BlockStainedHardenedClayWall[ColorUtility.COLOR_COUNT];
   
    public static Block wattlePanel = new BlockWattlePanel();
   
    public static Block wattleAndDaub = new BlockWattleAndDaub();

    public static Block woodenFrame = new BlockWoodenFrame();
   
    public static Block crossWoodenFrame = new BlockCrossWoodenFrame();
   
    public static Block slashWoodenFrame = new BlockSlashWoodenFrame();

    public static Block backslashWoodenFrame = new BlockBackslashWoodenFrame();
   
    public static Block thatchedRoofing = new BlockThatchedRoofing();
   
    public static Block[] stainedBrickRoofingBlocks = new BlockStainedBrickRoofing[ColorUtility.COLOR_COUNT];
   
    public static Block hardenedClayWall = new BlockHardenedClayWall();
   
    public static Block[] stainedBrickStairsBlocks = new BlockStainedBrickStairs[ColorUtility.COLOR_COUNT];
   
    public static Block[] stainedBrickFenceBlocks = new BlockBrickFence[ColorUtility.COLOR_COUNT];
   
    public static Block[] stainedBrickFenceGateBlocks = new BlockBrickFenceGate[ColorUtility.COLOR_COUNT];

    public static void register()
    {
        setRegister(stainedBrickBlocks, new ItemBlockStainedBricks(stainedBrickBlocks));
        setRegister(woodenFrame, new ItemBlockWoodenFrame(woodenFrame));
        setRegister(backslashWoodenFrame, new ItemBlockWoodenFrame(backslashWoodenFrame));
        setRegister(crossWoodenFrame, new ItemBlockWoodenFrame(crossWoodenFrame));
        setRegister(slashWoodenFrame, new ItemBlockWoodenFrame(slashWoodenFrame));

        for (int i = 0; i < ColorUtility.COLOR_COUNT; i++) {
            BlockHalfStainedBrickSlab slab = new BlockHalfStainedBrickSlab(i);
            BlockDoubleStainedBrickSlab doubleSlab = new BlockDoubleStainedBrickSlab(i);
            stainedBrickSlabBlocks[2 * i] = slab;
            stainedBrickSlabBlocks[2 * i + 1] = doubleSlab;
            setRegister(slab, new ItemSlab(slab, slab, doubleSlab), true);
           
            BlockStainedBrickWall wall = new BlockStainedBrickWall(stainedBrickBlocks, i);
            stainedBrickWallBlocks[i] = wall;
            setRegister(wall);
           
            BlockStainedHardenedClayWall clayWall = new BlockStainedHardenedClayWall(i);
            stainedHardenedClayWallBlocks[i] = clayWall;
            setRegister(clayWall);
           
            BlockStainedBrickRoofing roof = new BlockStainedBrickRoofing(stainedBrickBlocks, i);
            stainedBrickRoofingBlocks[i] = roof;
            setRegister(roof);
           
            BlockStainedBrickStairs stair = new BlockStainedBrickStairs(stainedBrickBlocks, i);
            stainedBrickStairsBlocks[i] = stair;
            setRegister(stair);
           
            BlockBrickFence fence = new BlockBrickFence(i);
            stainedBrickFenceBlocks[i] = fence;
            setRegister(fence);
           
            BlockBrickFenceGate gate = new BlockBrickFenceGate(i);
            stainedBrickFenceGateBlocks[i] = gate;
            setRegister(gate);
        }
    }

    @SideOnly(Side.CLIENT)
    public static void registerRender()
    {
        setRender(stainedBrickBlocks, ColorUtility.COLOR_COUNT, ColorUtility.COLOR_IDS);
        setRender(woodenFrame, WoodUtility.WOOD_TYPE_COUNT, WoodUtility.WOOD_TYPE_IDS);
        setRender(backslashWoodenFrame, WoodUtility.WOOD_TYPE_COUNT, WoodUtility.WOOD_TYPE_IDS);
        setRender(crossWoodenFrame, WoodUtility.WOOD_TYPE_COUNT, WoodUtility.WOOD_TYPE_IDS);
        setRender(slashWoodenFrame, WoodUtility.WOOD_TYPE_COUNT, WoodUtility.WOOD_TYPE_IDS);
       
        for (int i = 0; i < stainedBrickSlabBlocks.length; i++) {
            setRender(stainedBrickSlabBlocks[i]);
        }
       
        for(int i = 0; i < ColorUtility.COLOR_COUNT; i++)
        {
            setRender(stainedBrickWallBlocks[i]);
            setRender(stainedHardenedClayWallBlocks[i]);
            setRender(stainedBrickRoofingBlocks[i]);
            setRender(stainedBrickStairsBlocks[i]);
            setRender(stainedBrickFenceBlocks[i]);
            setRender(stainedBrickFenceGateBlocks[i]);
        }
       
        setRender(brickWall);
        setRender(wattlePanel);
        setRender(wattleAndDaub);
        setRender(thatchedRoofing);
        setRender(hardenedClayWall);
    }

    private static void setRegister(Block block)
    {
        ForgeRegistries.BLOCKS.register(block);
        ForgeRegistries.ITEMS.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
    }

    public static void setRegister(Block block, ItemBlock itemBlock)
    {
        ForgeRegistries.BLOCKS.register(block);
        ForgeRegistries.ITEMS.register(itemBlock.setRegistryName(block.getRegistryName()));
    }
   
    public static void setRegister(Block block, ItemBlock itemBlock, boolean isSLab)
    {
        ForgeRegistries.ITEMS.register(itemBlock.setRegistryName(block.getRegistryName()));
    }

    @SideOnly(Side.CLIENT)
    private static void setRender(Block block)
    {
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
        ModelBakery.registerItemVariants(
                Item.getItemFromBlock(block),
                new ModelResourceLocation(
                        "morematerials:" + block.getRegistryName(),
                        "variant=" + block.getRegistryName()));
    }

    @SideOnly(Side.CLIENT)
    private static void setRender(Block block, int meta_count, String[] meta_name)
    {
        for (int i = 0; i < meta_count; i++) {
            Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), i, new ModelResourceLocation(block.getRegistryName() + "_" + meta_name[i], "inventory"));
            ModelBakery.registerItemVariants(
                    Item.getItemFromBlock(block),
                    new ModelResourceLocation(
                            "morematerials:" + block.getRegistryName(),
                            "variant=" + block.getRegistryName() + "_" + meta_name[i]));
        }
    }
}
RegMetaBlocks.class:
package de.shittyco.morematerials.blocks.metablocks;

import de.shittyco.morematerials.blocks.BlocksRegister;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

/**
[LIST]
[*]Register item inventory icons for blocks depending on their metadata count
[*]@author Tennik
[/LIST]
*
*/
public class RegMetaBlocks {
    @SubscribeEvent
    public void registerMetaBlocks(ModelRegistryEvent e) {
        for(ColorMetadata type : ColorMetadata.values())
        {
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(BlocksRegister.stainedBrickBlocks), type.getMetadata(), new ModelResourceLocation(BlocksRegister.stainedBrickBlocks.getRegistryName() + "_" + type.getName(), "inventory"));
        }
        for(WoodMetadata type : WoodMetadata.values())
        {
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(BlocksRegister.woodenFrame), type.getMetadata(), new ModelResourceLocation(BlocksRegister.woodenFrame.getRegistryName() + "_" + type.getName(), "inventory"));
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(BlocksRegister.backslashWoodenFrame), type.getMetadata(), new ModelResourceLocation(BlocksRegister.backslashWoodenFrame.getRegistryName() + "_" + type.getName(), "inventory"));
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(BlocksRegister.crossWoodenFrame), type.getMetadata(), new ModelResourceLocation(BlocksRegister.crossWoodenFrame.getRegistryName() + "_" + type.getName(), "inventory"));
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(BlocksRegister.slashWoodenFrame), type.getMetadata(), new ModelResourceLocation(BlocksRegister.slashWoodenFrame.getRegistryName() + "_" + type.getName(), "inventory"));
        }
    }
}
 

Вложения

  • 2020-02-27_16.23.32.png
    2020-02-27_16.23.32.png
    88 KB · Просмотры: 5
  • 2020-02-27_16.23.42.png
    2020-02-27_16.23.42.png
    83.7 KB · Просмотры: 4
Последнее редактирование:
Сверху