Jump to content

Recommended Posts

Posted

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));
            }
        }
    }

 

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

 

Posted

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));
                });

 

Posted
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));
        }
    }

 

Posted

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.

Posted

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.

Posted

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.

Posted (edited)

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 by Luis_ST
Posted

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.

Posted

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

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I've been using this modpack for a few days now with no issues, it was working properly just an hour or two ago and now all of a sudden when I try to load it I get this error: 'The game crashed: exception in server tick loop Error: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $' debug log: https://pastebin.com/1htBuhsP crash report: https://pastebin.com/QggHKYDg
    • Everything worked fine until I decided to install supplementaries squared, amendments and a couple other mods like artifacts, and compats for it. I'm having a hard time fixing this, and I get this crash whenever I try to enter a world. Not even a new world is feasible. Any help would be highly appreciated!! https://pastebin.com/7KXYZ6fM
    • Internal Exception: com.google.gson.JsonParseException: Error loading registry data: Unknown element: ResourceKey[minecraft:worldgen/configured_feature / minecraft:crimson_forest_vegetation]   This error is there when i try to join my friends server. We had some mods and it was okay but after 3 days i cant join.
    • It just says the mod i had but i dont have now.. and i didnt even use these mods and it still was crashing with the mods  
    • Hello,   I've been back and forth in emails with some CurseForge support staff on the issue but there's been no progress. In the CurseForge app, I have custom profiles and some public modpacks that will not load no matter what. I've goen through every link sent to me, I've reinstalled Minecraft, reinstalled the launcher, repaired the installations individually, uninstalled and reinstalled the public modpacks, downloaded the latest Java--all of it. But each time, I'm always met with either "java runtime exception", "exit code 1" on the rare occasions Minecraft does launch, or "java is out of date" (which literally cannot be possible since I reinstalled the latest version a few different times.) Making a new profile works, but I want to be able to play the ones I had before.  I had gotten one of the old public Minecraft modpacks to work, the prehistoric one about dinosaurs being featured right now, but then it only worked once. I've tried to retrace my steps and it just would not work. I have genuinely no clue what's going on.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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