Jump to content

Oberschiene

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by Oberschiene

  1. So I'm trying to include a config-file in my 1.13.2 mod. And I've added a boolean in my config to regulate if an ore should be generated or not. Now I've got a problem with that because i get an 

    java.lang.NullPointerException: Cannot get config value without assigned Config object present

    when testing on those boolean values.

    The error come up on the OreGeneration.java in the if-statements in setupOreGen()

    Does anybody have an idea why that happens or could someone have a look in my code?

    Thanks in advantage:)

    Here's the link to my GitHub: https://github.com/jonas69/Versio

  2. 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

  3. 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();
        }
    }

     

  4. 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

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.