- 1,470
- 19
- 189
Сделал капу, но крашит
Как исправить?
Код:
Description: Ticking memory connection
java.lang.NullPointerException: Ticking memory connection
at ru.nix13.mac.capabilities.PlayerProvider.<init>(PlayerProvider.java:18)
at ru.nix13.mac.capabilities.CapabilityHandler.attachCapability(CapabilityHandler.java:19)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_CapabilityHandler_attachCapability_AttachCapabilitiesEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179)
at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:617)
at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:587)
at net.minecraft.entity.Entity.<init>(Entity.java:267)
at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:213)
at net.minecraft.entity.player.EntityPlayer.<init>(EntityPlayer.java:192)
at net.minecraft.entity.player.EntityPlayerMP.<init>(EntityPlayerMP.java:181)
at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:537)
at net.minecraft.server.network.NetHandlerLoginServer.tryAcceptPlayer(NetHandlerLoginServer.java:139)
at net.minecraft.server.network.NetHandlerLoginServer.update(NetHandlerLoginServer.java:67)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307)
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:196)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:863)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:741)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:590)
at java.lang.Thread.run(Thread.java:748)
Java:
public class PlayerProvider implements ICapabilitySerializable<NBTBase> {
@CapabilityInject(IPlayer.class)
public static final Capability<IPlayer> PLAYER_CAPABILITY = null;
private IPlayer instance = PLAYER_CAPABILITY.getDefaultInstance();
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == PLAYER_CAPABILITY;
}
@Nullable
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
return capability == PLAYER_CAPABILITY ? PLAYER_CAPABILITY.<T> cast(this.instance) : null;
}
@Override
public NBTBase serializeNBT() {
return PLAYER_CAPABILITY.getStorage().writeNBT(PLAYER_CAPABILITY, this.instance, null);
}
@Override
public void deserializeNBT(NBTBase nbt) {
PLAYER_CAPABILITY.getStorage().readNBT(PLAYER_CAPABILITY, this.instance, null, nbt);
}
}
Как исправить?