Я пытаюсь создать супер конструктор, но я все еще получаю ошибку: неявный супер конструктор Block() не определен. Необходимо явно вызвать другой конструктор. также кажется, что в главном классе есть 2 конструктора? но я не думаю, что это вызывает ошибку.Конструктор Java super() не работает?
Основной класс:
public Block(Material blockMaterialIn, MapColor blockMapColorIn)
{
this.enableStats = true;
this.blockSoundType = SoundType.STONE;
this.blockParticleGravity = 1.0F;
this.slipperiness = 0.6F;
this.blockMaterial = blockMaterialIn;
this.blockMapColor = blockMapColorIn;
this.blockState = this.createBlockState();
this.setDefaultState(this.blockState.getBaseState());
this.fullBlock = this.getDefaultState().isOpaqueCube();
this.lightOpacity = this.fullBlock ? 255 : 0;
this.translucent = !blockMaterialIn.blocksLight();
}
public Block(Material materialIn)
{
this(materialIn, materialIn.getMaterialMapColor());
}
подклассов:
public class ItemVoidiom_Ore extends Block {
public ItemVoidiom_Ore(Material materialIn) {
super(materialIn);
}
public ItemVoidiom_Ore() /** the error is here, Implicit super constructor Block() is undefined. Must explicitly invoke another constructor. */
{ setUnlocalizedName(Reference.enumstuff.VOIDIOM_ORE.getUnlocalizedName());
setRegistryName(Reference.enumstuff.VOIDIOM_ORE.getRegistryName());
}
} Спасибо за любую помощь!
Edit: я уже определил объект здесь, в другом классе
public static Block voidiom_ore;
public static void init()
{
voidiom_ore = new ItemVoidiom_Ore();
}
Edit: исправлена, спасибо за помощь!
'ItemVoidiom_Ore()' пытается вызвать 'Block()', который не существует. Вы должны указать, какой конструктор суперкласса выполнить явно. – Eran
'ItemVoidiom_Ore()' неявно начинается с 'super()', что означает, что он пытается использовать конструктор, соответствующий 'Block()'. – khelwood
Я не совсем понимаю Eran .. – itay51998