29 juil. 2019, 15:15

Bonjour,
J’ai une vague rouge en-dessous du " NonNullList " ( ligne 41 ) et j ai beau relire le tuto je ne sais pas pk. Aidez moi svp ( je suis en 1.10.2 )

package fr.lebourguignon.bourguimod.block;

import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraft.block.Block;

public class Test extends Block
{
    public static final String NAME = "test";
    
    public static final PropertyEnum<Test.EnumType> VARIANT = PropertyEnum.<Test.EnumType>create("variant", Test.EnumType.class);
    
    public Test(Material material)
    {
        super(material);
     
        BourguiModBlocks.setBlockName(this, NAME);
        setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, Test.EnumType.FIRST));

        setLightOpacity(255);
        setLightLevel(1);
        setResistance(5.0F);
        setHardness(3.0F);
        setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
    }
    
    @Override
    public int damageDropped(IBlockState state)
    {
        return state.getValue(VARIANT).getMetadata();
    }
 
    @Override
    public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList <ItemStack> list)
    {
        for (Test.EnumType type : Test.EnumType.values())
        {
            list.add(new ItemStack(itemIn, 1, type.getMetadata()));
        }
    }
 
    @Override
    public IBlockState getStateFromMeta(int meta)
    {
        return this.getDefaultState().withProperty(VARIANT, Test.EnumType.byMetadata(meta));
    }
 
    @Override
    public int getMetaFromState(IBlockState state)
    {
        return ((Test.EnumType)state.getValue(VARIANT)).getMetadata();
    }
 
    @Override
    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {VARIANT});
    }
 
    public static enum EnumType implements IStringSerializable
    {
        FIRST(0, "test", "test_white"),
        SECOND(1, "test2", "test_black");

        ;
 
        private static final Test.EnumType[] META_LOOKUP = new Test.EnumType[values().length];
        private final int meta;
        private final String name;
        private final String unlocalizedName;
 
        private EnumType(int metaIn, String nameIn, String unlocalizedIn)
        {
            this.meta = metaIn;
            this.name = nameIn;
            this.unlocalizedName = unlocalizedIn;
        }
 
        public static String[] getUnlocalizedNames()
        {
            String[] names = new String[values().length];
            
            for (int i = 0; i < META_LOOKUP.length; i++)
                names[i] = META_LOOKUP[i].unlocalizedName;
         
            return names;
        }
 
        public int getMetadata()
        {
            return this.meta;
        }
 
        public static Test.EnumType byMetadata(int meta)
        {
            if (meta < 0 || meta >= META_LOOKUP.length)
            {
                meta = 0;
            }
         
            return META_LOOKUP[meta];
        }
 
        public String toString()
        {
            return this.name;
        }
 
        @Override
        public String getName()
        {
            return this.name;
        }
        static
        {
            for (Test.EnumType type : values())
            {
                META_LOOKUP[type.getMetadata()] = type;
            }
        }
    }
}