Posted August 9, 20223 yr Attempts to attach capabilities to the player but receives this error. [10:27:23] [Server thread/ERROR] [ne.mi.ev.EventBus/EVENTBUS]: Exception caught during firing event: Cannot invoke "net.minecraftforge.common.util.LazyOptional.cast()" because "this.playerJoinedHandler" is null Index: 1 Listeners: 0: NORMAL 1: ASM: class me.squander.backpack.event.AttachCapabilities onAttachCapabilities(Lnet/minecraftforge/event/AttachCapabilitiesEvent;)V java.lang.NullPointerException: Cannot invoke "net.minecraftforge.common.util.LazyOptional.cast()" because "this.playerJoinedHandler" is null at TRANSFORMER/[email protected]/net.minecraft.world.entity.player.Player.getCapability(Player.java:2228) at TRANSFORMER/[email protected]/net.minecraftforge.common.capabilities.ICapabilityProvider.getCapability(ICapabilityProvider.java:34) at TRANSFORMER/[email protected]/me.squander.backpack.event.AttachCapabilities.onAttachCapabilities(AttachCapabilities.java:19) at net.minecraftforge.eventbus.ASMEventHandler_1_AttachCapabilities_onAttachCapabilities_AttachCapabilitiesEvent.invoke(.dynamic) at MC-BOOTSTRAP/[email protected]/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) at MC-BOOTSTRAP/[email protected]/net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) at MC-BOOTSTRAP/[email protected]/net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) at TRANSFORMER/[email protected]/net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:593) at TRANSFORMER/[email protected]/net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:587) at TRANSFORMER/[email protected]/net.minecraftforge.common.capabilities.CapabilityProvider.doGatherCapabilities(CapabilityProvider.java:73) at TRANSFORMER/[email protected]/net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:68) at TRANSFORMER/[email protected]/net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:52) at TRANSFORMER/[email protected]/net.minecraft.world.entity.Entity.<init>(Entity.java:257) at TRANSFORMER/[email protected]/net.minecraft.world.entity.LivingEntity.<init>(LivingEntity.java:234) at TRANSFORMER/[email protected]/net.minecraft.world.entity.player.Player.<init>(Player.java:172) at TRANSFORMER/[email protected]/net.minecraft.server.level.ServerPlayer.<init>(ServerPlayer.java:238) at TRANSFORMER/[email protected]/net.minecraft.server.players.PlayerList.getPlayerForLogin(PlayerList.java:412) at TRANSFORMER/[email protected]/net.minecraft.server.network.ServerLoginPacketListenerImpl.handleAcceptedLogin(ServerLoginPacketListenerImpl.java:124) at TRANSFORMER/[email protected]/net.minecraft.server.network.ServerLoginPacketListenerImpl.tick(ServerLoginPacketListenerImpl.java:70) at TRANSFORMER/[email protected]/net.minecraft.network.Connection.tick(Connection.java:267) at TRANSFORMER/[email protected]/net.minecraft.server.network.ServerConnectionListener.tick(ServerConnectionListener.java:160) at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:947) at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:873) at TRANSFORMER/[email protected]/net.minecraft.client.server.IntegratedServer.tickServer(IntegratedServer.java:90) at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:704) at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:262) at java.base/java.lang.Thread.run(Thread.java:833) [10:27:23] [Server thread/ERROR] [minecraft/ServerLoginPacketListenerImpl]: Couldn't place player in world java.lang.NullPointerException: Cannot invoke "net.minecraftforge.common.util.LazyOptional.cast()" because "this.playerJoinedHandler" is null at net.minecraft.world.entity.player.Player.getCapability(Player.java:2228) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading,pl:accesstransformer:B} at net.minecraftforge.common.capabilities.ICapabilityProvider.getCapability(ICapabilityProvider.java:34) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2378%2385!/:?] {re:classloading} at me.squander.backpack.event.AttachCapabilities.onAttachCapabilities(AttachCapabilities.java:19) ~[%2384!/:?] {re:classloading} at net.minecraftforge.eventbus.ASMEventHandler_1_AttachCapabilities_onAttachCapabilities_AttachCapabilitiesEvent.invoke(.dynamic) ~[?:?] {} at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-5.0.7.jar%2310!/:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-5.0.7.jar%2310!/:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-5.0.7.jar%2310!/:?] {} at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:593) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2378%2385!/:?] {re:classloading} at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:587) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2378%2385!/:?] {re:classloading} at net.minecraftforge.common.capabilities.CapabilityProvider.doGatherCapabilities(CapabilityProvider.java:73) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2378%2385!/:?] {re:classloading} at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:68) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2378%2385!/:?] {re:classloading} at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:52) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2378%2385!/:?] {re:classloading} at net.minecraft.world.entity.Entity.<init>(Entity.java:257) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.entity.LivingEntity.<init>(LivingEntity.java:234) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading} at net.minecraft.world.entity.player.Player.<init>(Player.java:172) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.level.ServerPlayer.<init>(ServerPlayer.java:238) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.players.PlayerList.getPlayerForLogin(PlayerList.java:412) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading} at net.minecraft.server.network.ServerLoginPacketListenerImpl.handleAcceptedLogin(ServerLoginPacketListenerImpl.java:124) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.network.ServerLoginPacketListenerImpl.tick(ServerLoginPacketListenerImpl.java:70) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.network.Connection.tick(Connection.java:267) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading} at net.minecraft.server.network.ServerConnectionListener.tick(ServerConnectionListener.java:160) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading} at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:947) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:873) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.client.server.IntegratedServer.tickServer(IntegratedServer.java:90) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:704) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:262) ~[forge-1.18.2-40.1.68_mapped_parchment_2022.07.17-1.18.2-recomp.jar%2379!/:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:833) [?:?] {} [10:27:23] [Server thread/INFO] [minecraft/ServerLoginPacketListenerImpl]: com.mojang.authlib.GameProfile@5e18a6a7[id=380df991-f603-344c-a090-369bad2a924a,name=Dev,properties={},legacy=false] (local:E:d56832b6) lost connection: Invalid player data [10:27:23] [Server thread/WARN] [minecraft/Connection]: handleDisconnection() called twice @SubscribeEvent public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event){ if(event.getObject() instanceof Player){ if(!event.getObject().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent()){ event.addCapability(new ResourceLocation(BackpackMod.MODID, "extra_storage"), new ExtraStorageInventory(9)); } } }
August 9, 20223 yr Author Okay, after opening the menu, the items in the slots are the same as in the hotbar.
August 9, 20223 yr Author public class ExtraStorageInventory extends ItemStackHandler implements ICapabilityProvider { private final LazyOptional<IItemHandler> optional = LazyOptional.of(() -> this); public ExtraStorageInventory(int size){ this.setSize(size); } @NotNull @Override public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) { return cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? optional.cast() : LazyOptional.empty(); } }
August 9, 20223 yr Author I did a new capability but still have items from the hotbar. public static final Capability<IItemHandler> EXTRA_STORAGE = CapabilityManager.get(new CapabilityToken<>(){}); private final LazyOptional<IItemHandler> optional = LazyOptional.of(() -> this); public ExtraStorageInventory(int size){ this.setSize(size); } @NotNull @Override public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) { return cap == EXTRA_STORAGE ? optional.cast() : LazyOptional.empty(); } player.getCapability(ExtraStorageInventory.EXTRA_STORAGE).ifPresent(handler -> { NetworkHooks.openGui((ServerPlayer) player, new SimpleMenuProvider((id, inv, plr) -> new ExtraStorageMenu(id, inv, handler), new TextComponent("EXTRA STORAGE")), buffer -> buffer.writeVarInt(9)); });
August 9, 20223 yr Author public ExtraStorageMenu(int pContainerId, Inventory inventory, FriendlyByteBuf buffer) { this(pContainerId, inventory, new ItemStackHandler(buffer.readVarInt())); } public ExtraStorageMenu(int pContainerId, Inventory inventory, IItemHandler handler) { super(MenuTypeInit.EXTRA_STORAGE.get(), pContainerId); for(int i = 0; i < 9; ++i) { this.addSlot(new SlotItemHandler(handler, i, 1 + i * 18, 1)); } this.addPlayerInventory(inventory); this.addPlayerHotbar(inventory); } private void addPlayerInventory(Inventory inventory){ for(int i = 0; i < 3; ++i) { for(int j = 0; j < 9; ++j) { this.addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } } private void addPlayerHotbar(Inventory inventory){ for(int k = 0; k < 9; ++k) { this.addSlot(new Slot(inventory, k, 8 + k * 18, 142)); } }
August 9, 20223 yr You should get the IItemHandler on server and client from the Player whihc you can get from the given Inventory. 22 minutes ago, Squander said: I did a new capability but still have items from the hotbar. You have in the Slots of your IItemHandler the Items from the Hotbar right? Please post a git repo of your Mod.
August 9, 20223 yr Author Can't finish GitHub sharing process Successfully created project 'Backpack1.18.2' on GitHub, but initial commit failed: gpg: skipped "Squander12 <[email protected]>": No secret key gpg: signing failed: No secret key gpg failed to sign the data failed to write commit object I get this error all the time.
August 9, 20223 yr Did you try to push the commit within the git feature of your IDE or did you use a Git Client (second is recommend).
August 9, 20223 yr Use a git client, then you shouldn't have any problems. The recommended git client is GitHub Desktop. I assume that your problem is your IDE has not the permission to commit to your Git repo.
August 9, 20223 yr Your git repo is missing the gradle folder is existential. Please do not use the files upload use a git client as I have already told you. Edited August 9, 20223 yr by Luis_ST
August 9, 20223 yr Author Okay, I don't have the strength to bother with this anymore. Nothing works. Screw it.
August 9, 20223 yr Author error: cannot spawn gpg: No such file or directory error: gpg failed to sign the data fatal: failed to write commit object
August 9, 20223 yr Edit: ignore this i'll take a look at that and come back if i found a solution Where did you get this issue? Edited August 9, 20223 yr by Luis_ST
August 9, 20223 yr As far as i can find out this has something to do with commit signing. You can disable this via the following command or your edit the config file of your git repo: command: git config commit.gpgsign false config file (git repo/.git/config), Note the .git folder is hidden by default. [commit] gpgsign = false Source: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits
August 9, 20223 yr Author okay i run github desktop then file tab then add local repository i gave the path of my mod, all files are like loaded but i don't really know what to do now.
August 9, 20223 yr Author My config in my mod project [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = [email protected]:/Squander12/Backpack1.18.2.git fetch = +refs/heads/*:refs/remotes/origin/* [remote "github"] url = [email protected]:/Squander12/Backpack_1.18.2.git fetch = +refs/heads/*:refs/remotes/github/* [lfs] repositoryformatversion = 0 [remote "githubh"] url = [email protected]:/Squander12/Backpack_1.18.2.git fetch = +refs/heads/*:refs/remotes/githubh/* [remote "githubasd"] url = [email protected]:/Squander12/Backpack1.18.2123.git fetch = +refs/heads/*:refs/remotes/githubasd/* [remote "originn"] url = [email protected]:/Squander12/Backpack-1.18.2.git fetch = +refs/heads/*:refs/remotes/originn/* [remote "githubheunyrty"] url = [email protected]:/Squander12/aaaa.git fetch = +refs/heads/*:refs/remotes/githubheunyrty/* [commit] gpgsign = false
August 9, 20223 yr 28 minutes ago, Squander said: okay i run github desktop then file tab then add local repository i gave the path of my mod, all files are like loaded but i don't really know what to do now. You need to create a public repo not a local, if you done this you need to publish the repo (Note make sure you uncheck "keep this repo private"). The publish it and post the like here.
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.