Что ему не нравится?

Версия Minecraft
1.12.2
683
3
21
Когда я возвращаю свой базовый блок он ругается на super в конструкторе,хотя в базовом блоке все так что ему не нравится не пойму...
Java:
package en.tiref.la.objects.Blocks;

import java.util.Random;

import en.tiref.la.Main;
import en.tiref.la.init.BlockInit;
import en.tiref.la.init.ItemInit;
import en.tiref.la.util.IHasModel;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;

public class BlockBase extends Block implements IHasModel
{

    public BlockBase(String name)
    {
        super(Material.ROCK);
        
        this.setUnlocalizedName(name);
        this.setRegistryName(name);
        this.setSoundType(SoundType.STONE);
        this.setCreativeTab(Main.ancient_tab);
        this.setHardness(2);
        this.setResistance(20);
        this.setHarvestLevel("pickaxe", 1);
        //this.setBlockUnbreakable();
        //this.setLightOpacity(0);
        //this.setLightLevel(3);
        
        BlockInit.BLOCKS.add(this);
        ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
    }

    @Override
    public void registerModels()
    {
      Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");   
    }
// @Override
// public Item getItemDropped(IBlockState state, Random rand, int fortune)
// {
//    return Items.APPLE;
// }
}

Java:
package en.tiref.la.objects.Blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;

public class RemainsBlock extends BlockBase {

    public static AxisAlignedBB RemainsBlock_AABB = new AxisAlignedBB(0, 0, 0, 1, 0.5, 1);
    
    public RemainsBlock(String name) {
        super(Material.ROCK);
        
        setUnlocalizedName(name);
        setRegistryName(name);
        
    }

@Override
public boolean isOpaqueCube(IBlockState state) {
    return false;
   }

@Override
public boolean isFullCube(IBlockState state) {
       return false;
   }
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess acess, BlockPos pos) {
     return RemainsBlock_AABB;
  }
}

1551553632599.png
 
683
3
21
А в базовом блоке я же возвращаю материал и он не ругается
 
1,450
19
162
почитай книжек по жаве. ты ничего не понимаешь.
 
1,450
19
162
в базовом блоке ты наследуешь Block, у которого в конструкторе материал, а у самого базового блока в конструкторе уже имя.
 
683
3
21
окей значит я теперь возвращаю материал
Java:
    public BlockBase(String name, Material material)
    {
        super(material);
        
        this.setUnlocalizedName(name);
        this.setRegistryName(name);
        this.setSoundType(SoundType.STONE);
        this.setCreativeTab(Main.ancient_tab);
        this.setHardness(2);
        this.setResistance(20);
        this.setHarvestLevel("pickaxe", 1);
        //this.setBlockUnbreakable();
        //this.setLightOpacity(0);
        //this.setLightLevel(3);
        
        BlockInit.BLOCKS.add(this);
        ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
    }
 
683
3
21
хмм теперь крашится майн хотя у меня только 1 блок с таким именем и я его не менял
Код:
---- Minecraft Crash Report ----
// Oh - I know what I did wrong!

Time: 3/3/19 1:13 PM
Description: Initializing game

java.lang.ExceptionInInitializerError
    at en.tiref.la.util.handlers.RegistryHandlers.onBlockRegister(RegistryHandlers.java:24)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_RegistryHandlers_onBlockRegister_Register.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:775)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    at net.minecraft.client.Minecraft.init(Minecraft.java:466)
    at net.minecraft.client.Minecraft.run(Minecraft.java:377)
    at net.minecraft.client.main.Main.main(SourceFile:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)
Caused by: java.lang.IllegalStateException: Attempted to set registry name with existing registry name! New: remains_block Old: ar:remains_block
    at net.minecraftforge.registries.IForgeRegistryEntry$Impl.setRegistryName(IForgeRegistryEntry.java:71)
    at en.tiref.la.objects.Blocks.RemainsBlock.<init>(RemainsBlock.java:18)
    at en.tiref.la.init.BlockInit.<clinit>(BlockInit.java:16)
    ... 23 more


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
    at en.tiref.la.util.handlers.RegistryHandlers.onBlockRegister(RegistryHandlers.java:24)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_RegistryHandlers_onBlockRegister_Register.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:775)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    at net.minecraft.client.Minecraft.init(Minecraft.java:466)

-- Initialization --
Details:
Stacktrace:
    at net.minecraft.client.Minecraft.run(Minecraft.java:377)
    at net.minecraft.client.main.Main.main(SourceFile:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)

-- System Details --
Details:
    Minecraft Version: 1.12.2
    Operating System: Windows 7 (amd64) version 6.1
    Java Version: 1.8.0_202, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 856482336 bytes (816 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP 9.42 Powered by Forge 14.23.5.2768 5 mods loaded, 5 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    | State | ID        | Version      | Source                           | Signature |
    |:----- |:--------- |:------------ |:-------------------------------- |:--------- |
    | UCH   | minecraft | 1.12.2       | minecraft.jar                    | None      |
    | UCH   | mcp       | 9.42         | minecraft.jar                    | None      |
    | UCH   | FML       | 8.0.99.99    | forgeBin-1.12.2-14.23.5.2768.jar | None      |
    | UCH   | forge     | 14.23.5.2768 | forgeBin-1.12.2-14.23.5.2768.jar | None      |
    | UCH   | ar        | 0.0.1        | bin                              | None      |

    Loaded coremods (and transformers):
    GL info: ' Vendor: 'ATI Technologies Inc.' Version: '2.1.9116' Renderer: 'AMD 760G'
    Launched Version: 1.12.2
    LWJGL: 2.9.4
    OpenGL: AMD 760G GL version 2.1.9116, ATI Technologies Inc.
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because ARB_framebuffer_object is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs:
    Current Language: Русский (Россия)
    Profiler Position: N/A (disabled)
    CPU: 2x AMD Athlon(tm) II X2 240 Processor
 
690
29
93
А ты ему registry name указываешь?
 
2,990
190
576
590
25
107
Ты пытаешься зарегистрировать блок не после того как он создан, а внутри его конструктора. А в этот момент, блок ещё не создался.
 

tox1cozZ

aka Agravaine
Модератор
7,122
455
2,144
Как это не создался? Конструктор вызван, значит объект уже есть.
Я всегда регаю так и все норм.
 
590
25
107
а ну вот, ты его дважды регистрируешь наверное
Caused by: java.lang.IllegalStateException: Attempted to set registry name with existing registry name! New: remains_block Old: ar:remains_block
а если обратить внимание на examplemod, то у него есть метод интересный в самом низу Почему бы не посмотреть сколько раз ты его регистрируешь и после чего?

Код:
    // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
    // Event bus for receiving Registry Events)
    @Mod.EventBusSubscriber()
    public static class RegistryEvents {
        @SubscribeEvent
        public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
            // register a new block here
            System.out.println("HELLO from Register Block: " + blockRegistryEvent);
        }
    }
}
 
Последнее редактирование:
2,990
190
576
Attempted to set registry name with existing registry name!
А ничего, что конкретно в строке краша ничего не сказано про регистрацию?
А сказано лишь про registry name, регистрационное имя.

А как связана регистрация (добавление итема/блоки "
 
683
3
21
Стоп мне во втором блоке убрать unlocolized name?или что я не понялo_O
 
690
29
93
Убери setUnlocalizedName и setRegistryName с RemainsBlock
 
2,990
190
576
Сверху