Posted January 24, 20187 yr I get a nullPointerException when trying to join a world: Spoiler ---- Minecraft Crash Report ---- // Ouch. That hurt :( Time: 1/24/18 11:42 AM Description: Ticking memory connection java.lang.NullPointerException: Ticking memory connection at net.insane96mcp.galaxite.capabilities.PlayerDataProvider.<init>(PlayerDataProvider.java:14) at net.insane96mcp.galaxite.capabilities.CapabilityHandler.EventAttachCapability(CapabilityHandler.java:19) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_21_CapabilityHandler_EventAttachCapability_AttachCapabilitiesEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:619) at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:589) at net.minecraft.entity.Entity.<init>(Entity.java:263) at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:198) at net.minecraft.entity.player.EntityPlayer.<init>(EntityPlayer.java:182) at net.minecraft.entity.player.EntityPlayerMP.<init>(EntityPlayerMP.java:170) at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:514) at net.minecraft.server.network.NetHandlerLoginServer.tryAcceptPlayer(NetHandlerLoginServer.java:141) at net.minecraft.server.network.NetHandlerLoginServer.update(NetHandlerLoginServer.java:68) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:309) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:818) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:699) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:548) at java.lang.Thread.run(Thread.java:748) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at net.insane96mcp.galaxite.capabilities.PlayerDataProvider.<init>(PlayerDataProvider.java:14) at net.insane96mcp.galaxite.capabilities.CapabilityHandler.EventAttachCapability(CapabilityHandler.java:19) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_21_CapabilityHandler_EventAttachCapability_AttachCapabilitiesEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:619) at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:589) at net.minecraft.entity.Entity.<init>(Entity.java:263) at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:198) at net.minecraft.entity.player.EntityPlayer.<init>(EntityPlayer.java:182) at net.minecraft.entity.player.EntityPlayerMP.<init>(EntityPlayerMP.java:170) at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:514) at net.minecraft.server.network.NetHandlerLoginServer.tryAcceptPlayer(NetHandlerLoginServer.java:141) at net.minecraft.server.network.NetHandlerLoginServer.update(NetHandlerLoginServer.java:68) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:309) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@3d1a47b2 Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:818) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:699) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:548) at java.lang.Thread.run(Thread.java:748) -- System Details -- Details: Minecraft Version: 1.11.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_151, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 689937536 bytes (657 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95 FML: MCP 9.38 Powered by Forge 13.20.1.2530 14 mods loaded, 14 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA minecraft{1.11.2} [Minecraft] (minecraft.jar) UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.11.2-13.20.1.2530.jar) UCHIJAAAA forge{13.20.1.2530} [Minecraft Forge] (forgeSrc-1.11.2-13.20.1.2530.jar) UCHIJAAAA balancedbonemeal{1.0.0} [Balanced Bonemeal] (bin) UCHIJAAAA carbonado{1.4.2} [Carbonado] (bin) UCHIJAAAA naturalbabyanimals{1.1.3} [Natural Baby Animals] (bin) UCHIJAAAA naturalnetherportals{1.2.0} [Natural Nether Portals] (bin) UCHIJAAAA nethergoldore{1.1.1} [Nether Gold Ore] (bin) UCHIJAAAA vulcanite{1.3.4} [Vulcanite] (bin) UCHIJAAAA mobspropertiesrandomness{1.1.3} [Mobs Properties Randomness] (bin) UCHIJAAAA examplemod{1.0} [Example Mod] (bin) UCHIJAAAA galaxite{1.0.0} [Galaxite] (bin) UCHIJAAAA waila{1.8.22} [Waila] (Hwyla-1.8.22-B37_1.11.jar) Loaded coremods (and transformers): GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Player Count: 0 / 8; [] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' [11:42:14] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2018-01-24_11.42.14-server.txt [11:42:14] [Client thread/INFO] [FML]: Waiting for the server to terminate/save. [11:42:14] [Server thread/INFO]: Saving chunks for level 'Test'/Nether [11:42:14] [Server thread/INFO]: Saving chunks for level 'Test'/The End [11:42:14] [Server thread/INFO] [FML]: Unloading dimension 0 [11:42:14] [Server thread/INFO] [FML]: Unloading dimension -1 [11:42:14] [Server thread/INFO] [FML]: Unloading dimension 1 [11:42:14] [Server thread/INFO] [FML]: Applying holder lookups [11:42:14] [Server thread/INFO] [FML]: Holder lookups applied [11:42:14] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded. [11:42:14] [Client thread/INFO] [FML]: Server terminated. [11:42:14] [Client Shutdown Thread/INFO]: Stopping server [11:42:14] [Client Shutdown Thread/INFO]: Saving players [11:42:14] [Client Shutdown Thread/INFO]: Saving worlds AL lib: (EE) alc_cleanup: 1 device not closed Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release Here's the the code of PlayerDataProvider Spoiler package net.insane96mcp.galaxite.capabilities; import net.minecraft.nbt.NBTBase; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.ICapabilitySerializable; public class PlayerDataProvider implements ICapabilitySerializable<NBTBase>{ @CapabilityInject(IPlayerData.class) public static final Capability<IPlayerData> PLAYER_DATA_CAP = null; private IPlayerData instance = PLAYER_DATA_CAP.getDefaultInstance(); @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { return capability == PLAYER_DATA_CAP; } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { return capability == PLAYER_DATA_CAP ? PLAYER_DATA_CAP.<T> cast(this.instance) : null; } @Override public NBTBase serializeNBT() { return PLAYER_DATA_CAP.getStorage().writeNBT(PLAYER_DATA_CAP, this.instance, null); } @Override public void deserializeNBT(NBTBase nbt) { PLAYER_DATA_CAP.getStorage().readNBT(PLAYER_DATA_CAP, this.instance, null, nbt); } } And CapabilityHandler Spoiler package net.insane96mcp.galaxite.capabilities; import net.insane96mcp.galaxite.Galaxite; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class CapabilityHandler { public static final ResourceLocation PLAYER_DATA_CAP = new ResourceLocation(Galaxite.MOD_ID, "playerData"); @SubscribeEvent public static void EventAttachCapability(AttachCapabilitiesEvent<Entity> event) { if (!(event.getObject() instanceof EntityPlayer)) return; event.addCapability(PLAYER_DATA_CAP, new PlayerDataProvider()); } @SubscribeEvent public static void EventPlayerClone(PlayerEvent.Clone event) { EntityPlayer player = event.getEntityPlayer(); IPlayerData playerData = player.getCapability(PlayerDataProvider.PLAYER_DATA_CAP, null); IPlayerData oldPlayerData = event.getOriginal().getCapability(PlayerDataProvider.PLAYER_DATA_CAP, null); playerData.clone(oldPlayerData.getInventorySaved()); } } Here's the full code: https://github.com/Insane-96/GalaxiteMod/tree/master/common/net/insane96mcp/galaxite/capabilities I really don't know what's causing this. Edited January 24, 20187 yr by Insane96MCP
January 24, 20187 yr Author 33 minutes ago, diesieben07 said: You are not registering your capability. Oh gosh, thank you. Another question. the register method for capabilities is Deprecated (in 1.12). How to use the new register?
January 24, 20187 yr Author 22 minutes ago, diesieben07 said: What part do you not understand about it? The old I should pass it the Interface class, an implementation of IStorate and the implementation of the interface. The new one asks for a constructor reference. Nevermind, just found out that I have to use PlayerData::new. I don't even know what that means. Sorry for bothering you but another question: Shouldn't capabilities be saved after quitting a world? I've quit my world but upon logging in the capabilities were empty
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.