Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Null-Name while registering
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
Oberschiene

Null-Name while registering

By Oberschiene, May 11 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Oberschiene    0

Oberschiene

Oberschiene    0

  • Tree Puncher
  • Oberschiene
  • Members
  • 0
  • 8 posts
Posted May 11

Hello, i'm trying myself in coding a Mod for 1.13.2 and while creating and testing my first ore, i ran into this error:

"Exception caught during firing event: Can't use a null-name for the registry, object Block{minecraft:air}."

I use the latest forge mdk.

I did not touch the minecraft:air, i just added a new ore. I also set its registry name in the ore-class-constructor like so: 

this.setRegistryName("mangan_ore");

I will add the log and this is my ModBlocks file, where i register all my blocks/itemblocks:

package com.versio.init;

import static com.versio.util.InjectionUtil.Null;
import com.google.common.base.Preconditions;
import com.versio.Versio;
import com.versio.block.BlockJar;
import com.versio.block.BlockManganOre;
import net.minecraft.block.Block;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ObjectHolder;

@ObjectHolder(Versio.MODID)
public class ModBlocks {

    public static final BlockManganOre MANGAN_ORE = Null();
    public static final BlockJar JAR = Null();

    @Mod.EventBusSubscriber(modid = Versio.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
    public static class Register {

        @SubscribeEvent
        public static void registerBlock(final RegistryEvent.Register<Block> event) {
            final Block[] blocks = {new BlockManganOre(), new BlockJar()};

            event.getRegistry().registerAll(blocks);
        }

        @SubscribeEvent
        public static void registerItemBlocks(final RegistryEvent.Register<Item> event) {
            final ItemBlock[] items = {
                    new ItemBlock(MANGAN_ORE,
                            new Item.Properties().maxStackSize(64).rarity(EnumRarity.UNCOMMON)
                                    .group(Versio.MODTAB)),
                    new ItemBlock(JAR, new Item.Properties().maxStackSize(16)
                            .rarity(EnumRarity.UNCOMMON).group(Versio.MODTAB))};

            for (final ItemBlock item : items) {
                final Block block = item.getBlock();
                final ResourceLocation registryName = Preconditions.checkNotNull(
                        block.getRegistryName(), "Block %s has a null registry name", block);

                event.getRegistry().register(item.setRegistryName(registryName));
            }
        }
    }
}

Does someone know, what the cause of that error is?

latest.log

  • Quote

Share this post


Link to post
Share on other sites

V0idWa1k3r    386

V0idWa1k3r

V0idWa1k3r    386

  • World Shaper
  • V0idWa1k3r
  • Members
  • 386
  • 1773 posts
Posted May 11

All I can tell you is one of your blocks has a null registry name. Can't tell you which one since you've never provided the code for said blocks.

  • Quote

Share this post


Link to post
Share on other sites

Oberschiene    0

Oberschiene

Oberschiene    0

  • Tree Puncher
  • Oberschiene
  • Members
  • 0
  • 8 posts
Posted May 11

Thanks for the quick reply!

I only have two blocks and these are the classes:

Thats the first one:

package com.versio.block;

import com.versio.init.ModItems;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;

public class BlockManganOre extends Block {

    public BlockManganOre() {
        super(Properties.create(Material.ROCK, MaterialColor.RED).hardnessAndResistance(3.0F, 2.0F)
                .sound(SoundType.STONE));
        this.setRegistryName("mangan_ore");
    }

    @Override
    public int getHarvestLevel(IBlockState state) {
        return 2;
    }

    @Override
    public ToolType getHarvestTool(IBlockState state) {
        return ToolType.PICKAXE;
    }

    @Override
    public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos,
            int fortune) {
        drops.add(new ItemStack(ModItems.MANGAN, 1 + fortune));
    }
}

 

And thats the second:

package com.versio.block;

import com.versio.init.ModItems;
import com.versio.tileentity.TileEntityJar;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;

public class BlockJar extends Block {

    public BlockJar() {
        super(Properties.create(Material.GLASS).hardnessAndResistance(.6F));
        this.setRegistryName("jar");
    }

    @Override
    public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos,
            EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY,
            float hitZ) {
        TileEntityJar jar = (TileEntityJar) worldIn.getTileEntity(pos);
        if (jar.amount() < 64 && !player.getHeldItem(hand).isEmpty()
                && player.getHeldItem(hand).getItem().equals(ModItems.MANGAN)
                && !player.isSneaking()) {
            player.getHeldItem(hand).shrink(1);
            jar.addCrystals();
            return true;
        } else if (player.isSneaking() && jar.amount() > 0) {
            player.addItemStackToInventory(new ItemStack(ModItems.MANGAN));
            jar.removeCrystals();
            return true;
        }
        return false;
    }

    @Override
    public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state,
            TileEntity te, ItemStack stack) {
        TileEntityJar jar = (TileEntityJar) te;
        while (jar.amount() > 0) {
            if (!worldIn.isRemote) {
                worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(),
                        new ItemStack(ModItems.MANGAN)));
                jar.removeCrystals();
            }
        }
        super.harvestBlock(worldIn, player, pos, state, te, stack);
    }

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

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

    @Override
    public BlockRenderLayer getRenderLayer() {
        return BlockRenderLayer.CUTOUT;
    }

    @Override
    public VoxelShape getShape(IBlockState state, IBlockReader worldIn, BlockPos pos) {
        return Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 13.0D, 13.0D);
    }

    @Override
    public boolean hasTileEntity(IBlockState state) {
        return true;
    }

    @Override
    public TileEntity createTileEntity(IBlockState state, IBlockReader world) {
        return new TileEntityJar();
    }
}

 

  • Quote

Share this post


Link to post
Share on other sites

V0idWa1k3r    386

V0idWa1k3r

V0idWa1k3r    386

  • World Shaper
  • V0idWa1k3r
  • Members
  • 386
  • 1773 posts
Posted May 11

Your code looks fine to me at a first glance.

Could you provide a link to your github repository so I can debug it locally?

  • Quote

Share this post


Link to post
Share on other sites

Oberschiene    0

Oberschiene

Oberschiene    0

  • Tree Puncher
  • Oberschiene
  • Members
  • 0
  • 8 posts
Posted May 11

Okay, here's the link:

https://github.com/jonas69/Versio

 

And thanks for your effort:)

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted May 11

The code on Github does not match up with the provided crash report. The stacktrace points at ModBlocks line 29, which is a comment in the code you posted.

Please provide up-to-date code and logs.

  • Quote

Share this post


Link to post
Share on other sites

Oberschiene    0

Oberschiene

Oberschiene    0

  • Tree Puncher
  • Oberschiene
  • Members
  • 0
  • 8 posts
Posted May 11

Oh right, it should be now:)

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted May 11

Line 29 is still a comment.

You have not provided an updated log.

  • Quote

Share this post


Link to post
Share on other sites

Oberschiene    0

Oberschiene

Oberschiene    0

  • Tree Puncher
  • Oberschiene
  • Members
  • 0
  • 8 posts
Posted May 11

My bad, heres the new log:

latest.log

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted May 11

Dude.

Quote

    at com.versio.init.ModBlocks$Register.registerBlock(ModBlocks.java:29)

https://github.com/jonas69/Versio/blob/master/src/main/java/com/versio/init/ModBlocks.java#L29

 

This does not match up.

  • Quote

Share this post


Link to post
Share on other sites

Oberschiene    0

Oberschiene

Oberschiene    0

  • Tree Puncher
  • Oberschiene
  • Members
  • 0
  • 8 posts
Posted May 11

Yes exactly, thats the strange thing. I know that there's a comment in this line, but if i run the client (with the code just like on github), i get this log with those error-messages. I just tried it again, chose the client in run-config, then the game startet and gave me this latest.log with exactly the line 29 even though there's java-doc

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted May 11

Make sure you are not running with outdated build artifacts (the class files).

Your IDE should give you an option to completely rebuild the project.

  • Quote

Share this post


Link to post
Share on other sites

Oberschiene    0

Oberschiene

Oberschiene    0

  • Tree Puncher
  • Oberschiene
  • Members
  • 0
  • 8 posts
Posted May 11

Okay i didn't thought of that, but now it works! Thank you very much, esp. that your responses were so quick:)

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • DaemonUmbra
      pointing to MCP folder instead of MDK ???

      By DaemonUmbra · Posted 10 minutes ago

      This entire issue is apparently surrounding your workspace apparently utilizing some mcp folder which shouldn't exist. Can you show me where your IDE mentions this mcp folder?
    • DaemonUmbra
      Error with running modpack on twitch

      By DaemonUmbra · Posted 11 minutes ago

      Please restart your launcher, reproduce this error, close your launcher, and share launcher_log.txt via one of the paste sites in my signature
    • DaemonUmbra
      Minecraft Modded Server jar doesn't like having more Memory...

      By DaemonUmbra · Posted 13 minutes ago

      I'm not 100% of what you're saying because you don't appear to be using English as I understand it. It sounds like you're using Hamachi and trying to set your server to use a specific port that Hamachi opens?
    • DaemonUmbra
      Optifine 1.14.4 U HD F4 crash froge

      By DaemonUmbra · Posted 18 minutes ago

      Please don't hijack other peoples threads. If you have an issue please make your own thread.
    • DaemonUmbra
      Forge 1.14.4 crashes.

      By DaemonUmbra · Posted 19 minutes ago

      Upload debug.log to one of the paste sites listed in my signature
  • Topics

    • JMAS
      10
      pointing to MCP folder instead of MDK ???

      By JMAS
      Started Thursday at 09:21 PM

    • bluey418
      1
      Error with running modpack on twitch

      By bluey418
      Started 55 minutes ago

    • Misterboy64
      1
      Minecraft Modded Server jar doesn't like having more Memory...

      By Misterboy64
      Started 3 hours ago

    • DarkZapato
      3
      Optifine 1.14.4 U HD F4 crash froge

      By DarkZapato
      Started Thursday at 04:09 PM

    • Darth_Cobalt
      1
      Forge 1.14.4 crashes.

      By Darth_Cobalt
      Started 10 hours ago

  • Who's Online (See full list)

    • SapphireSky
    • Legenes
    • Oliviafrostpaw
    • Edivad99
    • DaemonUmbra
    • Alexiy
    • Jaffaaaaa
    • Kerman
    • Alatyami
    • geekles
    • Rick57
    • PrinceRaiden
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Null-Name while registering
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community