Posted July 16, 20178 yr Hello, I am following along with McJty's 1.12 modding tutorials and am at the point where I am creating a Tile Entity. I have followed the tutorial and there are no errors in IntelliJ. However, when I try to load the game it crashes. I was stupid and forgot to change something from his tutorial to fit my mod. Crash Log: Spoiler ---- Minecraft Crash Report ---- // Ooh. Shiny. Time: 7/15/17 5:49 PM Description: Initializing game java.lang.NullPointerException: Initializing game at atm2222.firstmod.proxy.CommonProxy.registerItems(CommonProxy.java:60) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_CommonProxy_registerItems_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:143) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:723) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:605) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:266) at net.minecraft.client.Minecraft.init(Minecraft.java:508) at net.minecraft.client.Minecraft.run(Minecraft.java:416) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) 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(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at atm2222.firstmod.proxy.CommonProxy.registerItems(CommonProxy.java:60) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_CommonProxy_registerItems_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:143) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:723) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:605) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:266) at net.minecraft.client.Minecraft.init(Minecraft.java:508) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:416) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) 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(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) -- System Details -- Details: Minecraft Version: 1.12 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_73, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 819777688 bytes (781 MB) / 1007157248 bytes (960 MB) up to 3808428032 bytes (3632 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.40 Powered by Forge 14.21.1.2413 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 UCH minecraft{1.12} [Minecraft] (minecraft.jar) UCH mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCH FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.12-14.21.1.2413.jar) UCH forge{14.21.1.2413} [Minecraft Forge] (forgeSrc-1.12-14.21.1.2413.jar) UCH firstmod{0.0.1} [Atm2222s First Mod] (FirstMod_main) Loaded coremods (and transformers): GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13474 Compatibility Profile Context 22.19.162.4' Renderer: 'AMD Radeon R9 200 Series' Launched Version: 1.12 LWJGL: 2.9.4 OpenGL: AMD Radeon R9 200 Series GL version 4.5.13474 Compatibility Profile Context 22.19.162.4, ATI Technologies Inc. GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 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: English (US) Profiler Position: N/A (disabled) CPU: 4x Intel(R) Core(TM) i5-4690K CPU @ 3.50GHz From this log, I know it occurs on line 60 or my CommonProxy Method. CommonProxy: Spoiler package atm2222.firstmod.proxy; import atm2222.firstmod.Config; import atm2222.firstmod.FirstMod; import atm2222.firstmod.ModBlocks; import atm2222.firstmod.blocks.FirstBlock; import atm2222.firstmod.blocks.datablock.DataBlock; import atm2222.firstmod.blocks.datablock.DataTileEntity; import atm2222.firstmod.items.FirstItem; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import java.io.File; @Mod.EventBusSubscriber public class CommonProxy { // Config instance public static Configuration config; public void preInit(FMLPreInitializationEvent e) { File directory = e.getModConfigurationDirectory(); config = new Configuration(new File(directory.getPath(), "modtut.cfg")); Config.readConfig(); } public void init(FMLInitializationEvent e) { } public void postInit(FMLPostInitializationEvent e) { if (config.hasChanged()) { config.save(); } } @SubscribeEvent public static void registerBlocks(RegistryEvent.Register<Block> event) { event.getRegistry().register(new FirstBlock()); event.getRegistry().register(new DataBlock()); GameRegistry.registerTileEntity(DataTileEntity.class, FirstMod.MODID + "_datablock"); } @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event) { event.getRegistry().register(new ItemBlock(ModBlocks.firstBlock).setRegistryName(ModBlocks.firstBlock.getRegistryName())); event.getRegistry().register(new ItemBlock(ModBlocks.dataBlock).setRegistryName(ModBlocks.dataBlock.getRegistryName())); event.getRegistry().register(new FirstItem()); } } Here are the two files pertaining to the TileEntity. Spoiler package atm2222.firstmod.blocks.datablock; import atm2222.firstmod.FirstMod; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; public class DataBlock extends Block implements ITileEntityProvider{ public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public DataBlock() { super(Material.ROCK); setUnlocalizedName(FirstMod.MODID + ".datablock"); setRegistryName("datablock"); } @SideOnly(Side.CLIENT) public void initModel() { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "inventory")); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new DataTileEntity(); } private DataTileEntity getTE(World world, BlockPos pos) { return (DataTileEntity) world.getTileEntity(pos); } //@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { // We only count on the server side. if (side == state.getValue(FACING)) { int counter; if (hitY < .5f) { counter = getTE(world, pos).decrement(); } else { counter = getTE(world, pos).increment(); } player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "Counter: " + counter), false); } } // Return true also on the client to make sure that MC knows we handled this and will not try to place // a block on the client return true; } @Override public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2); } @Override public IBlockState getStateFromMeta(int meta) { // Since we only allow horizontal rotation we need only 2 bits for facing. North, South, West, East start at index 2 so we have to add 2 here. return getDefaultState().withProperty(FACING, EnumFacing.getFront((meta & 3) + 2)); } @Override public int getMetaFromState(IBlockState state) { // Since we only allow horizontal rotation we need only 2 bits for facing. North, South, West, East start at index 2 so we have to subtract 2 here. return state.getValue(FACING).getIndex()-2; } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, FACING); } } Spoiler package atm2222.firstmod.blocks.datablock; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; public class DataTileEntity extends TileEntity{ private int counter = 0; public int decrement() { counter--; markDirty(); return counter; } public int increment() { counter++; markDirty(); return counter; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); counter = compound.getInteger("counter"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("counter", counter); return compound; } } Here is another possibly important class: Spoiler package atm2222.firstmod; import atm2222.firstmod.blocks.FirstBlock; import atm2222.firstmod.blocks.datablock.DataBlock; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ModBlocks { @SideOnly(Side.CLIENT) public static void initModels() { dataBlock.initModel(); } @GameRegistry.ObjectHolder("firstmod:firstblock") public static FirstBlock firstBlock; @GameRegistry.ObjectHolder("modtut:datablock") public static DataBlock dataBlock; } If anybody knows of any common causes of this issue, please tell me! Thanks!! Edited July 16, 20178 yr by Atm2222 Problem Solved
July 16, 20178 yr Author Oh, God thanks. I can't believe I was so stupid to not do that. modtut is mcjty's name, firstmod is mine. Thanks for helping by giving it a second look.
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.