Oberschiene Posted May 11, 2019 Posted May 11, 2019 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.logFetching info... Quote
V0idWa1k3r Posted May 11, 2019 Posted May 11, 2019 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
Oberschiene Posted May 11, 2019 Author Posted May 11, 2019 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
V0idWa1k3r Posted May 11, 2019 Posted May 11, 2019 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
Oberschiene Posted May 11, 2019 Author Posted May 11, 2019 Okay, here's the link: https://github.com/jonas69/Versio And thanks for your effort:) Quote
Oberschiene Posted May 11, 2019 Author Posted May 11, 2019 My bad, heres the new log: latest.logFetching info... Quote
Oberschiene Posted May 11, 2019 Author Posted May 11, 2019 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
Oberschiene Posted May 11, 2019 Author Posted May 11, 2019 Okay i didn't thought of that, but now it works! Thank you very much, esp. that your responses were so quick:) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.