Jump to content

[1.14] Capabilities for stamina?


nenikitov

Recommended Posts

Hello!

I'm currently working on adding stamina system in minecraft and i face a problem where i need to add "stamina" variable to each client.

Firstly, I would like to know did I get it right that capabilities is the correct way of doing it.

Secondly, i have watched already numerous tutorials and have red documentation about capabilities, but I still can't get how to make it work, I don't understand how to make your own capability and attach it to the PlayerEntity.

Thanks in advance.

Link to comment
Share on other sites

1. What are forge provided capabilities for? I get what is IItemHandler, but the other 2, like what is fluid inventory and energy container?

2. What is EnumFacing?

3. Documentation shows the creation of custom capabilities with 3 separate classes, capability, storage and factory. Then they show what is written in storage and factory class. So they leave cabability class empty or what should be written there?

4. After i ve written a custom capability, where should i inject it? In which class?

5. I didnt get in which class i should register my capability?

---------

6. Maybe there is an example code of working capability which i can read to understand better what and where should be done?

Link to comment
Share on other sites

After creating a PlayerCapabilities class and making it implement ICapabilitySerializable, importing everything and adding unemplemented methods i get this:

package com.nenikitov.nemod;

import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.LazyOptional;

public class PlayerCapabilities implements ICapabilitySerializable<INBT>
{
	@Override
	public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public INBT serializeNBT() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void deserializeNBT(INBT nbt) {
		// TODO Auto-generated method stub
		
	}

}

1. Its here after "public class PlayerCapabilities implements ICapabilitySerializable<INBT> {" that I should write all my new variables that I want to add as stats to the player, right?

 

2. When i'm regestering PlayerCapabilities (i'm doing it inside FMLCommonSetupEvent in my mod class), what should i put as storage and factory?

CapabilityManager.INSTANCE.register(PlayerCapabilities.class, storage, factory);

 

3. For adding capabilities to the PLayerEntity, in my mod calss i wrote

private static ResourceLocation PlayerCapabilitiesResourceLocation = new ResourceLocation(modid, "player_capabilities");

And then i wrote this method

	@SubscribeEvent
	public static void attachPlayerCapabilities(AttachCapabilitiesEvent<Entity> event)
	{
		if (event.getObject() instanceof PlayerEntity)
		{
			event.addCapability(PlayerCapabilitiesResourceLocation, cap);
		}
	}

What should go in cap?

Link to comment
Share on other sites

1 hour ago, nenikitov said:

After creating a PlayerCapabilities class and making it implement ICapabilitySerializable, importing everything and adding unemplemented methods i get this:


package com.nenikitov.nemod;

import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.LazyOptional;

public class PlayerCapabilities implements ICapabilitySerializable<INBT>
{
	@Override
	public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public INBT serializeNBT() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void deserializeNBT(INBT nbt) {
		// TODO Auto-generated method stub
		
	}

}

1. Its here after "public class PlayerCapabilities implements ICapabilitySerializable<INBT> {" that I should write all my new variables that I want to add as stats to the player, right?

 

2. When i'm regestering PlayerCapabilities (i'm doing it inside FMLCommonSetupEvent in my mod class), what should i put as storage and factory?


CapabilityManager.INSTANCE.register(PlayerCapabilities.class, storage, factory);

 

3. For adding capabilities to the PLayerEntity, in my mod calss i wrote


private static ResourceLocation PlayerCapabilitiesResourceLocation = new ResourceLocation(modid, "player_capabilities");

And then i wrote this method


	@SubscribeEvent
	public static void attachPlayerCapabilities(AttachCapabilitiesEvent<Entity> event)
	{
		if (event.getObject() instanceof PlayerEntity)
		{
			event.addCapability(PlayerCapabilitiesResourceLocation, cap);
		}
	}

What should go in cap?

Sounds like the capability you are trying to create should go in "cap".

 

I have created a custom capability for tile entities and am also looking for an answer to this. I too would like more information. 

Edited by Kenneth201998
Link to comment
Share on other sites

9 hours ago, Kenneth201998 said:

Sounds like the capability you are trying to create should go in "cap".

 

I have created a custom capability for tile entities and am also looking for an answer to this. I too would like more information. 

At cap, you should pass a new instance of the default implementation for your capability. I just got into capabilities myself lately, and they are a handful if you never worked with such things before. Very tricky to get things working because the docs are a little outdated.

Link to comment
Share on other sites

4 hours ago, Cerandior said:

At cap, you should pass a new instance of the default implementation for your capability. I just got into capabilities myself lately, and they are a handful if you never worked with such things before. Very tricky to get things working because the docs are a little outdated.

Did you succeed on making a custom working capability?

Link to comment
Share on other sites

2 minutes ago, Kenneth201998 said:

What I am wondering is how to make the capability apply to the player. 

Quote
  • AttachCapabilitiesEvent<Entity>: Fires only for entities.
  • AttachCapabilitiesEvent<TileEntity>: Fires only for tile entities.
  • AttachCapabilitiesEvent<ItemStack>: Fires only for item stacks.
  • AttachCapabilitiesEvent<World>: Fires only for worlds.
  • AttachCapabilitiesEvent<Chunk>: Fires only for chunks.

That's from the docs. Those are the events you must subscribe to depending on what type of thing you want to attach your capability. In your case. You use the one for entities and check if the entity is an instance of a player. If yes, attach it to that player.

 

 

Link to comment
Share on other sites

10 minutes ago, Cerandior said:

Yes, if you want to have a look at it, go here: https://github.com/Cerandior/VanillaExtended/tree/master/src/main/java/teabx/vanillaextended

I got my Event Handler under "main" package.

OK, thank you.

I hope it helps me because all the tutorials and examples i saw, they wrote all differently + they were outdated.

 

6 minutes ago, Kenneth201998 said:

What I am wondering is how to make the capability apply to the player. 

@SubscribeEvent
public static void attachPlayerCapabilities(AttachCapabilitiesEvent<Entity> event)
	{
		if (event.getObject() instanceof PlayerEntity)
		{
			event.addCapability();
		}

But the line event.addCapability(); isnt finished and there should be something written inside () , still dont know what because i didnt get to this point

Edited by nenikitov
Link to comment
Share on other sites

18 minutes ago, nenikitov said:

OK, thank you.

I hope it helps me because all the tutorials and examples i saw, they wrote all differently + they were outdated.

 


@SubscribeEvent
public static void attachPlayerCapabilities(AttachCapabilitiesEvent<Entity> event)
	{
		if (event.getObject() instanceof PlayerEntity)
		{
			event.addCapability();
		}

But the line event.addCapability(); isnt finished and there should be something written inside () , still dont know what because i didnt get to this point

The first parameter you pass is a resource location containing your modid and a string name for your capability.
The second parameter, you have to pass a new instance of the default implementation of your capability.

This what I did and it works: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/main/EventHandler.java

Link to comment
Share on other sites

Any idea why this is happening?

In CapabilityRegistry

@Override
public INBT writeNBT(Capability<INeModPlayerCapabilities> capability, INeModPlayerCapabilities instance, Direction side)
{
	CompoundNBT nbt = new CompoundNBT();
    nbt.putDouble("stamina", instance.GetStamina());
    return nbt;
}

I get "GetStamina()" unerlined red

image.png.92a03c9b8cdd690907477c0d18c3a927.png

Although I have this method in my INeModPlayerCapabilities

public double GetStamina();

And inide my NeModPlayerCapabilities

@Override
	public double GetStamina() {
		return this.Stamina;
	}

 

 

 

Actually same thing with

@Override
	public void readNBT(Capability<INeModPlayerCapabilities> capability, INeModPlayerCapabilities instance, Direction side, INBT nbt)
	{
		CompoundNBT tag = (CompoundNBT) nbt;
		instance.SetStaminaValue(tag.getDouble("stamina"));
	}

image.png.f3de1a0af038bfeaa0a9c4f1b51ccb97.png

Edited by nenikitov
Link to comment
Share on other sites

package com.nenikitov.nemod.playerCapabilities;

import javax.annotation.Nullable;

import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;

public class CapabilityRegestry
{
	@CapabilityInject(INeModPlayerCapabilities.class)
    public static Capability<INeModPlayerCapabilities> COOLDOWN_ITEM = null;

    public static void registerCapabilities(){
        CapabilityManager.INSTANCE.register(INeModPlayerCapabilities.class, new INeModPlayerCapabilities() ,INeModPlayerCapabilities::new);
    }

    public static class INeModPlayerCapabilities implements Capability.IStorage<INeModPlayerCapabilities>{

		@Override
		public INBT writeNBT(Capability<INeModPlayerCapabilities> capability, INeModPlayerCapabilities instance, Direction side)
		{
			CompoundNBT nbt = new CompoundNBT();
            nbt.putDouble("stamina", instance.GetStamina());
            return nbt;
		}

		@Override
		public void readNBT(Capability<INeModPlayerCapabilities> capability, INeModPlayerCapabilities instance, Direction side, INBT nbt)
		{
	            CompoundNBT tag = (CompoundNBT) nbt;
	            instance.SetStaminaValue(tag.getDouble("stamina"));
		}


    }
}

Yeah, but it shouldnt get these 2 methods from INeModPlayerCapabilities?

Link to comment
Share on other sites

1 minute ago, nenikitov said:

package com.nenikitov.nemod.playerCapabilities;

import javax.annotation.Nullable;

import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;

public class CapabilityRegestry
{
	@CapabilityInject(INeModPlayerCapabilities.class)
    public static Capability<INeModPlayerCapabilities> COOLDOWN_ITEM = null;

    public static void registerCapabilities(){
        CapabilityManager.INSTANCE.register(INeModPlayerCapabilities.class, new INeModPlayerCapabilities() ,INeModPlayerCapabilities::new);
    }

    public static class INeModPlayerCapabilities implements Capability.IStorage<INeModPlayerCapabilities>{

		@Override
		public INBT writeNBT(Capability<INeModPlayerCapabilities> capability, INeModPlayerCapabilities instance, Direction side)
		{
			CompoundNBT nbt = new CompoundNBT();
            nbt.putDouble("stamina", instance.GetStamina());
            return nbt;
		}

		@Override
		public void readNBT(Capability<INeModPlayerCapabilities> capability, INeModPlayerCapabilities instance, Direction side, INBT nbt)
		{
	            CompoundNBT tag = (CompoundNBT) nbt;
	            instance.SetStaminaValue(tag.getDouble("stamina"));
		}


    }
}

Yeah, but it shouldnt get these 2 methods from INeModPlayerCapabilities?

Where you register the capability, at the second parameter you don't pass an instance of your capability interface. You have to pass an instance of your storage class. The last parameter is a new instance of your default implementation of your capability. The one that implements your interface.

Edited by Cerandior
Link to comment
Share on other sites

Just a note. Don't just copy and paste the code I gave you. I have nothing against it, but if you don't understand what's going on then It's kind of pointless because even if you get it working, you won't be able to change anything.

Also, for some of those methods, like the one that registers your capability, you can use your IDE to get to an implementation of that method to see what exactly that method is expecting for parameters, and what it does with them (ctl+b if on IntelliJ).

Edited by Cerandior
Link to comment
Share on other sites

Just now, Cerandior said:

Just a note. Don't just copy and paste the code I gave you. I have nothing against it, but if you don't understand what's going on then It's kind of pointless because even if you get it working, you won't be able to change anything.

Also, for some of those methods, like the one that registers your capability, you can use your IDE to get to an implementation of that method to see what exactly that method is expecting for parameters, and what it does with it (ctl+b if on IntelliJ).

Yeah, I know and I'm getting whats happening.

And sorry about copying your code.

Link to comment
Share on other sites

So, after spending almost the whole day reading and rereading different tutorials, forum topics and source codes, after restarting 5 times i still didnt make it XD.

I get a crash while attaching capabilities on PlayerEntity, more precisely on calling event.getObject() inside NeModEventHandler;

Here are classes, their code and crash report:

 

NeModEventHandler:

Spoiler

package com.nenikitov.nemod;

import com.nenikitov.nemod.playerCapabilities.NePlayerCapabilitiesProvider;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

public class NeModEventHandler
{
	@SubscribeEvent
	public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) {
		if (event.getObject() instanceof PlayerEntity && event.getObject() != null) {
			System.out.println("Capability is attached to " + event.getObject());
			event.addCapability(new ResourceLocation(NeMod.modid, "ne_player_capabilities"), new NePlayerCapabilitiesProvider());
		}
	}

}

 

INePlayerCapabilities:

Spoiler

package com.nenikitov.nemod.playerCapabilities;

public interface INePlayerCapabilities
{
	//STAMINA
		//Set
		void SetStamina(double value);
		void SetStaminaDecrease(double value);
		void SetMaxStamina(double value);
		//Get
		double GetStamina();
		double GetStaminaDecrease();
		double GetMaxStamina();
		//Update
		void StaminaUpdate();
		
	//DASH
		//Set
		void SetDashLength(double value);
		//Get
		double GetDashLength();
		//Update
		void UpdateDashLength();
		
	//DASH COOL DOWN
		//Set
		void SetDashCoolDownValue(double value);
		void SetDashCoolDownTime(double value);
		void SetDashIsOnCoolDown(boolean  value);
		//Get
		double GetDashCoolDownValue();
		double GetDashCoolDownTime();
		boolean GetDashIsOnCoolDown();
		//Update
		void DashCoolDownUpdate();
	
	//ARMOR CLASSES
		//Set
		void SetBootsArmorClass(String value);
		void SetLeggingsArmorClass(String value);
		void SetChestplateArmorClass(String value);
		void SetHelmetArmorClass(String value);
		//Get
		String GetBootsArmorClassString();
		String GetLeggingsArmorClass();
		String GetChestplateArmorClass();
		String GetHelmetArmorClass();
		//Update
		void UpdateArmorClasses();
}

 

NePlayerCapabilities:

Spoiler

package com.nenikitov.nemod.playerCapabilities;

public class NePlayerCapabilities implements INePlayerCapabilities
{
	//Stamina variables
	private double Stamina = 1;
	private double StaminaDecreaseValue = 0.1;
	private double MaxStamina = 1;
	//Dash variables
	private double DashLength = 0.35;
	//Cool down on dash variables
	private double DashCoolDownValue = 0;
	private double DashCoolDownTime = 2;
	private boolean DashIsOnCooldown = false;
	//Armor class variables
	private String BootsArmorCalss = "air";
	private String LeggingsArmorCalss = "air";
	private String ChestplateArmorCalss = "air";
	private String HelmetArmorCalss = "air";
	
	public NePlayerCapabilities() {
		this.Stamina = 1;
		this.StaminaDecreaseValue = 0.1;
		this.MaxStamina = 1;
		this.DashLength = 0.35;
		this.DashCoolDownValue = 0;
		this.DashCoolDownTime = 2;
		this.DashIsOnCooldown = false;
		this.BootsArmorCalss = "air";
		this.LeggingsArmorCalss = "air";
		this.ChestplateArmorCalss = "air";
		this.HelmetArmorCalss = "air";
	}
	
	//STAMINA
		//Set
	@Override
		public void SetStamina(double value) {
			this.Stamina = value;
		}
		@Override
		public void SetStaminaDecrease(double value) {
			this.StaminaDecreaseValue = value;
		}
		@Override
		public void SetMaxStamina(double value) {
			this.MaxStamina = value;
		}
		//Get
		@Override
		public double GetStamina() {
			return this.Stamina;
		}
		@Override
		public double GetStaminaDecrease() {
			return this.StaminaDecreaseValue;
		}
		@Override
		public double GetMaxStamina() {
			return this.MaxStamina;
		}
		//Update
		@Override
		public void StaminaUpdate() {
		//TODO
		}
	
	//DASH
		//Set
		@Override
		public void SetDashLength(double value) {
			this.DashLength = value;
		}
		//Get
		@Override
		public double GetDashLength() {
			return this.DashLength;
		}
		//Update	
		@Override
		public void UpdateDashLength() {
			// TODO
		}
	
	//DASH COOL DOWN
		//Set
		@Override
		public void SetDashCoolDownValue(double value) {
			this.DashCoolDownValue = value;
		}
		@Override
		public void SetDashCoolDownTime(double value) {
			this.DashCoolDownTime = value;
		}
		@Override
		public void SetDashIsOnCoolDown(boolean value) {
			this.DashIsOnCooldown = value;
		}
		//Get
		@Override
		public double GetDashCoolDownValue() {
			return this.DashCoolDownValue;
		}
		@Override
		public double GetDashCoolDownTime() {
			return this.DashCoolDownTime;
		}
		@Override
		public boolean GetDashIsOnCoolDown() {
			return this.DashIsOnCooldown;
		}
		//Update
		@Override
		public void DashCoolDownUpdate() {
			// TODO
		}
	
	//ARMOR CLASSES
		//Set
		@Override
		public void SetBootsArmorClass(String value) {
			this.BootsArmorCalss = value;
		}
		@Override
		public void SetLeggingsArmorClass(String value) {
			this.LeggingsArmorCalss = value;
		}
		@Override
		public void SetChestplateArmorClass(String value) {
			this.ChestplateArmorCalss = value;
		}
		@Override
		public void SetHelmetArmorClass(String value) {
			this.HelmetArmorCalss = value;
			
		}
		//Get
		@Override
		public String GetBootsArmorClassString() {
			return this.BootsArmorCalss;
		}
		@Override
		public String GetLeggingsArmorClass() {
			return this.LeggingsArmorCalss;
		}
		@Override
		public String GetChestplateArmorClass() {
			return this.ChestplateArmorCalss;
		}
		@Override
		public String GetHelmetArmorClass() {
			return this.HelmetArmorCalss;
		}
		//Update
		@Override
		public void UpdateArmorClasses() {
		}

}

 

NePlayerCapabilitiesProvider:

Spoiler

package com.nenikitov.nemod.playerCapabilities;

import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.LazyOptional;

public class NePlayerCapabilitiesProvider implements ICapabilitySerializable<INBT> {

	@CapabilityInject(INePlayerCapabilities.class)
	public static final Capability<INePlayerCapabilities> I_NE_PLAYER_CAPABILITIES = null;

	private LazyOptional<INePlayerCapabilities> InterfaceInstance = LazyOptional.of(I_NE_PLAYER_CAPABILITIES::getDefaultInstance);

	
	@Override
	public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
	{
		if (cap == I_NE_PLAYER_CAPABILITIES)
			return InterfaceInstance.cast();
		else
			return LazyOptional.empty();
	}

	@Override
	public INBT serializeNBT() {
		return I_NE_PLAYER_CAPABILITIES.getStorage().writeNBT(I_NE_PLAYER_CAPABILITIES, this.InterfaceInstance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null);
	}

	@Override
	public void deserializeNBT(INBT nbt) {
		I_NE_PLAYER_CAPABILITIES.getStorage().readNBT(I_NE_PLAYER_CAPABILITIES, this.InterfaceInstance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null, nbt);
	}

}

 

NePlayerCapabilitiesStorage:

Spoiler

package com.nenikitov.nemod.playerCapabilities;

import com.nenikitov.nemod.NeMod;

import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.Capability.IStorage;

public class NePlayerCapabilitiesStorage implements IStorage<INePlayerCapabilities>
{	
	//Capabilities methods
	@Override
	public INBT writeNBT(Capability<INePlayerCapabilities> capability, INePlayerCapabilities instance, Direction side)
	{
		CompoundNBT CNBT = new CompoundNBT();
		//Stamina values
		CNBTPutDouble(CNBT, "stamina", instance.GetStamina());
		CNBTPutDouble(CNBT, "stamina_decrease", instance.GetStaminaDecrease());
		CNBTPutDouble(CNBT, "max_stamina", instance.GetMaxStamina());
		//Dash values
		CNBTPutDouble(CNBT, "dash_length", instance.GetDashLength());
		//Dash cool down values
		CNBTPutDouble(CNBT, "dash_cool_down_value", instance.GetDashCoolDownValue());
		CNBTPutDouble(CNBT, "dash_cool_down_time", instance.GetDashCoolDownTime());
		CNBTPutBoolean(CNBT, "dash_is_on_cool_down", instance.GetDashIsOnCoolDown());
		//Armor classes values
		CNBTPutString(CNBT, "boots_armor_class", instance.GetBootsArmorClassString());
		CNBTPutString(CNBT, "leggings_armor_class", instance.GetLeggingsArmorClass());
		CNBTPutString(CNBT, "chestplate_armor_class", instance.GetChestplateArmorClass());
		CNBTPutString(CNBT, "helmet_armor_class", instance.GetHelmetArmorClass());
		return CNBT;
	}

	@Override
	public void readNBT(Capability<INePlayerCapabilities> capability, INePlayerCapabilities instance, Direction side, INBT nbt)
	{
		System.out.println("read NBT");
		//Stamina values
		instance.SetStamina(NBTGetDouble(nbt, "stamina"));
		instance.SetStaminaDecrease(NBTGetDouble(nbt, "stamina_decrease"));
		instance.SetMaxStamina(NBTGetDouble(nbt, "max_stamina"));
		//Dash values
		instance.SetDashLength(NBTGetDouble(nbt, "dash_length"));
		//Dash cool down values
		instance.SetDashCoolDownValue(NBTGetDouble(nbt, "dash_cool_down_value"));
		instance.SetDashCoolDownTime(NBTGetDouble(nbt, "dash_cool_down_time"));
		instance.SetDashIsOnCoolDown(NBTGetBoolean(nbt, "dash_is_on_cool_down"));
		//Armor classes values
		instance.SetBootsArmorClass(NBTGetString(nbt, "boots_armor_class"));
		instance.SetLeggingsArmorClass(NBTGetString(nbt, "leggings_armor_class"));
		instance.SetChestplateArmorClass(NBTGetString(nbt, "chestplate_armor_class"));
		instance.SetHelmetArmorClass(NBTGetString(nbt, "helmet_armor_class"));
	}

	
	//Helper methods
	private void CNBTPutDouble(CompoundNBT cnbt, String name, double value)
	{
		cnbt.putDouble(NBTKey(name), value);
	}
	private void CNBTPutBoolean(CompoundNBT cnbt, String name, boolean value)
	{
		cnbt.putBoolean(NBTKey(name), value);
	}
	private void CNBTPutString(CompoundNBT cnbt, String name, String value)
	{
		cnbt.putString(NBTKey(name), value);
	}
	private double NBTGetDouble(INBT nbt,  String name)
	{
		return ((CompoundNBT)nbt).getDouble(NBTKey(name));
	}
	private boolean NBTGetBoolean(INBT nbt,  String name)
	{
		return ((CompoundNBT)nbt).getBoolean(NBTKey(name));
	}
	private String NBTGetString(INBT nbt,  String name)
	{
		return ((CompoundNBT)nbt).getString(NBTKey(name));
	}
	private String NBTKey(String key)
	{
		return NeMod.modid + "_" + key;
	}
}

 

 

And here is my crash report:

Spoiler

---- Minecraft Crash Report ----
// Shall we play a game?

Time: 01.12.19 21:51
Description: Ticking memory connection

java.lang.NullPointerException: Ticking memory connection
    at net.minecraft.entity.player.PlayerEntity.getName(PlayerEntity.java:1858) ~[?:?] {pl:accesstransformer:B}
    at net.minecraft.entity.Entity.toString(Entity.java:2361) ~[?:?] {pl:accesstransformer:B}
    at java.lang.String.valueOf(Unknown Source) ~[?:1.8.0_231] {}
    at java.lang.StringBuilder.append(Unknown Source) ~[?:1.8.0_231] {}
    at com.nenikitov.nemod.NeModEventHandler.onAttachCapabilities(NeModEventHandler.java:16) ~[main/:?] {}
    at net.minecraftforge.eventbus.ASMEventHandler_0_NeModEventHandler_onAttachCapabilities_AttachCapabilitiesEvent.invoke(.dynamic) ~[?:?] {}
    at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80) ~[eventbus-1.0.0-service.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) ~[eventbus-1.0.0-service.jar:?] {}
    at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:560) ~[?:?] {}
    at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:554) ~[?:?] {}
    at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:48) ~[?:?] {}
    at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:44) ~[?:?] {}
    at net.minecraft.entity.Entity.<init>(Entity.java:222) ~[?:?] {pl:accesstransformer:B}
    at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:192) ~[?:?] {}
    at net.minecraft.entity.player.PlayerEntity.<init>(PlayerEntity.java:162) ~[?:?] {pl:accesstransformer:B}
    at net.minecraft.entity.player.ServerPlayerEntity.<init>(ServerPlayerEntity.java:163) ~[?:?] {pl:accesstransformer:B}
    at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:390) ~[?:?] {}
    at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:119) ~[?:?] {}
    at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:63) ~[?:?] {}
    at net.minecraft.network.NetworkManager.tick(NetworkManager.java:241) ~[?:?] {}
    at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:148) ~[?:?] {}
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:882) ~[?:?] {pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:800) ~[?:?] {pl:accesstransformer:B}
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[?:?] {pl:runtimedistcleaner:A}
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:646) [?:?] {pl:accesstransformer:B}
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_231] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Server thread
Stacktrace:
    at net.minecraft.entity.player.PlayerEntity.getName(PlayerEntity.java:1858)
    at net.minecraft.entity.Entity.toString(Entity.java:2361)
    at java.lang.String.valueOf(Unknown Source)
    at java.lang.StringBuilder.append(Unknown Source)
    at com.nenikitov.nemod.NeModEventHandler.onAttachCapabilities(NeModEventHandler.java:16)
    at net.minecraftforge.eventbus.ASMEventHandler_0_NeModEventHandler_onAttachCapabilities_AttachCapabilitiesEvent.invoke(.dynamic)
    at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80)
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258)
    at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:560)
    at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:554)
    at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:48)
    at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:44)
    at net.minecraft.entity.Entity.<init>(Entity.java:222)
    at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:192)
    at net.minecraft.entity.player.PlayerEntity.<init>(PlayerEntity.java:162)
    at net.minecraft.entity.player.ServerPlayerEntity.<init>(ServerPlayerEntity.java:163)
    at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:390)
    at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:119)
    at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:63)
    at net.minecraft.network.NetworkManager.tick(NetworkManager.java:241)

-- Ticking connection --
Details:
    Connection: net.minecraft.network.NetworkManager@c594c87
Stacktrace:
    at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:148)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:882)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:800)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:646)
    at java.lang.Thread.run(Unknown Source)

-- System Details --
Details:
    Minecraft Version: 1.14.4
    Minecraft Version ID: 1.14.4
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_231, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 692512840 bytes (660 MB) / 2216165376 bytes (2113 MB) up to 3799515136 bytes (3623 MB)
    CPUs: 8
    JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
    ModLauncher: 3.2.0+60+b86c1d4
    ModLauncher launch target: fmluserdevclient
    ModLauncher naming: mcp
    ModLauncher services: 
        /eventbus-1.0.0-service.jar eventbus PLUGINSERVICE 
        /forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar object_holder_definalize PLUGINSERVICE 
        /forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar runtime_enum_extender PLUGINSERVICE 
        /accesstransformers-1.0.0-shadowed.jar accesstransformer PLUGINSERVICE 
        /forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar capability_inject_definalize PLUGINSERVICE 
        /forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar runtimedistcleaner PLUGINSERVICE 
        /forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar fml TRANSFORMATIONSERVICE 
    FML: 28.1
    Forge: net.minecraftforge:28.1.0
    FML Language Providers: 
        javafml@28.1
        minecraft@1
    Mod List: 
        forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar Forge {forge@28.1.0 DONE}
        main NE Mod {nemod@0.1 DONE}
        client-extra.jar Minecraft {minecraft@1.14.4 DONE}
    Player Count: 0 / 8; []
    Data Packs: vanilla, mod:nemod, mod:forge
    Type: Integrated Server (map_client.txt)
    Is Modded: Definitely; Client brand changed to 'forge'

Any ideas what is happening?

Link to comment
Share on other sites

4 hours ago, nenikitov said:

So, after spending almost the whole day reading and rereading different tutorials, forum topics and source codes, after restarting 5 times i still didnt make it XD.

I get a crash while attaching capabilities on PlayerEntity, more precisely on calling event.getObject() inside NeModEventHandler;

Here are classes, their code and crash report:

 

NeModEventHandler:

  Reveal hidden contents


package com.nenikitov.nemod;

import com.nenikitov.nemod.playerCapabilities.NePlayerCapabilitiesProvider;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

public class NeModEventHandler
{
	@SubscribeEvent
	public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) {
		if (event.getObject() instanceof PlayerEntity && event.getObject() != null) {
			System.out.println("Capability is attached to " + event.getObject());
			event.addCapability(new ResourceLocation(NeMod.modid, "ne_player_capabilities"), new NePlayerCapabilitiesProvider());
		}
	}

}

 

INePlayerCapabilities:

  Reveal hidden contents


package com.nenikitov.nemod.playerCapabilities;

public interface INePlayerCapabilities
{
	//STAMINA
		//Set
		void SetStamina(double value);
		void SetStaminaDecrease(double value);
		void SetMaxStamina(double value);
		//Get
		double GetStamina();
		double GetStaminaDecrease();
		double GetMaxStamina();
		//Update
		void StaminaUpdate();
		
	//DASH
		//Set
		void SetDashLength(double value);
		//Get
		double GetDashLength();
		//Update
		void UpdateDashLength();
		
	//DASH COOL DOWN
		//Set
		void SetDashCoolDownValue(double value);
		void SetDashCoolDownTime(double value);
		void SetDashIsOnCoolDown(boolean  value);
		//Get
		double GetDashCoolDownValue();
		double GetDashCoolDownTime();
		boolean GetDashIsOnCoolDown();
		//Update
		void DashCoolDownUpdate();
	
	//ARMOR CLASSES
		//Set
		void SetBootsArmorClass(String value);
		void SetLeggingsArmorClass(String value);
		void SetChestplateArmorClass(String value);
		void SetHelmetArmorClass(String value);
		//Get
		String GetBootsArmorClassString();
		String GetLeggingsArmorClass();
		String GetChestplateArmorClass();
		String GetHelmetArmorClass();
		//Update
		void UpdateArmorClasses();
}

 

NePlayerCapabilities:

  Reveal hidden contents


package com.nenikitov.nemod.playerCapabilities;

public class NePlayerCapabilities implements INePlayerCapabilities
{
	//Stamina variables
	private double Stamina = 1;
	private double StaminaDecreaseValue = 0.1;
	private double MaxStamina = 1;
	//Dash variables
	private double DashLength = 0.35;
	//Cool down on dash variables
	private double DashCoolDownValue = 0;
	private double DashCoolDownTime = 2;
	private boolean DashIsOnCooldown = false;
	//Armor class variables
	private String BootsArmorCalss = "air";
	private String LeggingsArmorCalss = "air";
	private String ChestplateArmorCalss = "air";
	private String HelmetArmorCalss = "air";
	
	public NePlayerCapabilities() {
		this.Stamina = 1;
		this.StaminaDecreaseValue = 0.1;
		this.MaxStamina = 1;
		this.DashLength = 0.35;
		this.DashCoolDownValue = 0;
		this.DashCoolDownTime = 2;
		this.DashIsOnCooldown = false;
		this.BootsArmorCalss = "air";
		this.LeggingsArmorCalss = "air";
		this.ChestplateArmorCalss = "air";
		this.HelmetArmorCalss = "air";
	}
	
	//STAMINA
		//Set
	@Override
		public void SetStamina(double value) {
			this.Stamina = value;
		}
		@Override
		public void SetStaminaDecrease(double value) {
			this.StaminaDecreaseValue = value;
		}
		@Override
		public void SetMaxStamina(double value) {
			this.MaxStamina = value;
		}
		//Get
		@Override
		public double GetStamina() {
			return this.Stamina;
		}
		@Override
		public double GetStaminaDecrease() {
			return this.StaminaDecreaseValue;
		}
		@Override
		public double GetMaxStamina() {
			return this.MaxStamina;
		}
		//Update
		@Override
		public void StaminaUpdate() {
		//TODO
		}
	
	//DASH
		//Set
		@Override
		public void SetDashLength(double value) {
			this.DashLength = value;
		}
		//Get
		@Override
		public double GetDashLength() {
			return this.DashLength;
		}
		//Update	
		@Override
		public void UpdateDashLength() {
			// TODO
		}
	
	//DASH COOL DOWN
		//Set
		@Override
		public void SetDashCoolDownValue(double value) {
			this.DashCoolDownValue = value;
		}
		@Override
		public void SetDashCoolDownTime(double value) {
			this.DashCoolDownTime = value;
		}
		@Override
		public void SetDashIsOnCoolDown(boolean value) {
			this.DashIsOnCooldown = value;
		}
		//Get
		@Override
		public double GetDashCoolDownValue() {
			return this.DashCoolDownValue;
		}
		@Override
		public double GetDashCoolDownTime() {
			return this.DashCoolDownTime;
		}
		@Override
		public boolean GetDashIsOnCoolDown() {
			return this.DashIsOnCooldown;
		}
		//Update
		@Override
		public void DashCoolDownUpdate() {
			// TODO
		}
	
	//ARMOR CLASSES
		//Set
		@Override
		public void SetBootsArmorClass(String value) {
			this.BootsArmorCalss = value;
		}
		@Override
		public void SetLeggingsArmorClass(String value) {
			this.LeggingsArmorCalss = value;
		}
		@Override
		public void SetChestplateArmorClass(String value) {
			this.ChestplateArmorCalss = value;
		}
		@Override
		public void SetHelmetArmorClass(String value) {
			this.HelmetArmorCalss = value;
			
		}
		//Get
		@Override
		public String GetBootsArmorClassString() {
			return this.BootsArmorCalss;
		}
		@Override
		public String GetLeggingsArmorClass() {
			return this.LeggingsArmorCalss;
		}
		@Override
		public String GetChestplateArmorClass() {
			return this.ChestplateArmorCalss;
		}
		@Override
		public String GetHelmetArmorClass() {
			return this.HelmetArmorCalss;
		}
		//Update
		@Override
		public void UpdateArmorClasses() {
		}

}

 

NePlayerCapabilitiesProvider:

  Reveal hidden contents


package com.nenikitov.nemod.playerCapabilities;

import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.LazyOptional;

public class NePlayerCapabilitiesProvider implements ICapabilitySerializable<INBT> {

	@CapabilityInject(INePlayerCapabilities.class)
	public static final Capability<INePlayerCapabilities> I_NE_PLAYER_CAPABILITIES = null;

	private LazyOptional<INePlayerCapabilities> InterfaceInstance = LazyOptional.of(I_NE_PLAYER_CAPABILITIES::getDefaultInstance);

	
	@Override
	public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
	{
		if (cap == I_NE_PLAYER_CAPABILITIES)
			return InterfaceInstance.cast();
		else
			return LazyOptional.empty();
	}

	@Override
	public INBT serializeNBT() {
		return I_NE_PLAYER_CAPABILITIES.getStorage().writeNBT(I_NE_PLAYER_CAPABILITIES, this.InterfaceInstance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null);
	}

	@Override
	public void deserializeNBT(INBT nbt) {
		I_NE_PLAYER_CAPABILITIES.getStorage().readNBT(I_NE_PLAYER_CAPABILITIES, this.InterfaceInstance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null, nbt);
	}

}

 

NePlayerCapabilitiesStorage:

  Reveal hidden contents


package com.nenikitov.nemod.playerCapabilities;

import com.nenikitov.nemod.NeMod;

import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.Capability.IStorage;

public class NePlayerCapabilitiesStorage implements IStorage<INePlayerCapabilities>
{	
	//Capabilities methods
	@Override
	public INBT writeNBT(Capability<INePlayerCapabilities> capability, INePlayerCapabilities instance, Direction side)
	{
		CompoundNBT CNBT = new CompoundNBT();
		//Stamina values
		CNBTPutDouble(CNBT, "stamina", instance.GetStamina());
		CNBTPutDouble(CNBT, "stamina_decrease", instance.GetStaminaDecrease());
		CNBTPutDouble(CNBT, "max_stamina", instance.GetMaxStamina());
		//Dash values
		CNBTPutDouble(CNBT, "dash_length", instance.GetDashLength());
		//Dash cool down values
		CNBTPutDouble(CNBT, "dash_cool_down_value", instance.GetDashCoolDownValue());
		CNBTPutDouble(CNBT, "dash_cool_down_time", instance.GetDashCoolDownTime());
		CNBTPutBoolean(CNBT, "dash_is_on_cool_down", instance.GetDashIsOnCoolDown());
		//Armor classes values
		CNBTPutString(CNBT, "boots_armor_class", instance.GetBootsArmorClassString());
		CNBTPutString(CNBT, "leggings_armor_class", instance.GetLeggingsArmorClass());
		CNBTPutString(CNBT, "chestplate_armor_class", instance.GetChestplateArmorClass());
		CNBTPutString(CNBT, "helmet_armor_class", instance.GetHelmetArmorClass());
		return CNBT;
	}

	@Override
	public void readNBT(Capability<INePlayerCapabilities> capability, INePlayerCapabilities instance, Direction side, INBT nbt)
	{
		System.out.println("read NBT");
		//Stamina values
		instance.SetStamina(NBTGetDouble(nbt, "stamina"));
		instance.SetStaminaDecrease(NBTGetDouble(nbt, "stamina_decrease"));
		instance.SetMaxStamina(NBTGetDouble(nbt, "max_stamina"));
		//Dash values
		instance.SetDashLength(NBTGetDouble(nbt, "dash_length"));
		//Dash cool down values
		instance.SetDashCoolDownValue(NBTGetDouble(nbt, "dash_cool_down_value"));
		instance.SetDashCoolDownTime(NBTGetDouble(nbt, "dash_cool_down_time"));
		instance.SetDashIsOnCoolDown(NBTGetBoolean(nbt, "dash_is_on_cool_down"));
		//Armor classes values
		instance.SetBootsArmorClass(NBTGetString(nbt, "boots_armor_class"));
		instance.SetLeggingsArmorClass(NBTGetString(nbt, "leggings_armor_class"));
		instance.SetChestplateArmorClass(NBTGetString(nbt, "chestplate_armor_class"));
		instance.SetHelmetArmorClass(NBTGetString(nbt, "helmet_armor_class"));
	}

	
	//Helper methods
	private void CNBTPutDouble(CompoundNBT cnbt, String name, double value)
	{
		cnbt.putDouble(NBTKey(name), value);
	}
	private void CNBTPutBoolean(CompoundNBT cnbt, String name, boolean value)
	{
		cnbt.putBoolean(NBTKey(name), value);
	}
	private void CNBTPutString(CompoundNBT cnbt, String name, String value)
	{
		cnbt.putString(NBTKey(name), value);
	}
	private double NBTGetDouble(INBT nbt,  String name)
	{
		return ((CompoundNBT)nbt).getDouble(NBTKey(name));
	}
	private boolean NBTGetBoolean(INBT nbt,  String name)
	{
		return ((CompoundNBT)nbt).getBoolean(NBTKey(name));
	}
	private String NBTGetString(INBT nbt,  String name)
	{
		return ((CompoundNBT)nbt).getString(NBTKey(name));
	}
	private String NBTKey(String key)
	{
		return NeMod.modid + "_" + key;
	}
}

 

 

And here is my crash report:

  Reveal hidden contents

---- Minecraft Crash Report ----
// Shall we play a game?

Time: 01.12.19 21:51
Description: Ticking memory connection

java.lang.NullPointerException: Ticking memory connection
    at net.minecraft.entity.player.PlayerEntity.getName(PlayerEntity.java:1858) ~[?:?] {pl:accesstransformer:B}
    at net.minecraft.entity.Entity.toString(Entity.java:2361) ~[?:?] {pl:accesstransformer:B}
    at java.lang.String.valueOf(Unknown Source) ~[?:1.8.0_231] {}
    at java.lang.StringBuilder.append(Unknown Source) ~[?:1.8.0_231] {}
    at com.nenikitov.nemod.NeModEventHandler.onAttachCapabilities(NeModEventHandler.java:16) ~[main/:?] {}
    at net.minecraftforge.eventbus.ASMEventHandler_0_NeModEventHandler_onAttachCapabilities_AttachCapabilitiesEvent.invoke(.dynamic) ~[?:?] {}
    at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80) ~[eventbus-1.0.0-service.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) ~[eventbus-1.0.0-service.jar:?] {}
    at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:560) ~[?:?] {}
    at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:554) ~[?:?] {}
    at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:48) ~[?:?] {}
    at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:44) ~[?:?] {}
    at net.minecraft.entity.Entity.<init>(Entity.java:222) ~[?:?] {pl:accesstransformer:B}
    at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:192) ~[?:?] {}
    at net.minecraft.entity.player.PlayerEntity.<init>(PlayerEntity.java:162) ~[?:?] {pl:accesstransformer:B}
    at net.minecraft.entity.player.ServerPlayerEntity.<init>(ServerPlayerEntity.java:163) ~[?:?] {pl:accesstransformer:B}
    at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:390) ~[?:?] {}
    at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:119) ~[?:?] {}
    at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:63) ~[?:?] {}
    at net.minecraft.network.NetworkManager.tick(NetworkManager.java:241) ~[?:?] {}
    at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:148) ~[?:?] {}
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:882) ~[?:?] {pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:800) ~[?:?] {pl:accesstransformer:B}
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[?:?] {pl:runtimedistcleaner:A}
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:646) [?:?] {pl:accesstransformer:B}
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_231] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Server thread
Stacktrace:
    at net.minecraft.entity.player.PlayerEntity.getName(PlayerEntity.java:1858)
    at net.minecraft.entity.Entity.toString(Entity.java:2361)
    at java.lang.String.valueOf(Unknown Source)
    at java.lang.StringBuilder.append(Unknown Source)
    at com.nenikitov.nemod.NeModEventHandler.onAttachCapabilities(NeModEventHandler.java:16)
    at net.minecraftforge.eventbus.ASMEventHandler_0_NeModEventHandler_onAttachCapabilities_AttachCapabilitiesEvent.invoke(.dynamic)
    at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80)
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258)
    at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:560)
    at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:554)
    at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:48)
    at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:44)
    at net.minecraft.entity.Entity.<init>(Entity.java:222)
    at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:192)
    at net.minecraft.entity.player.PlayerEntity.<init>(PlayerEntity.java:162)
    at net.minecraft.entity.player.ServerPlayerEntity.<init>(ServerPlayerEntity.java:163)
    at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:390)
    at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:119)
    at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:63)
    at net.minecraft.network.NetworkManager.tick(NetworkManager.java:241)

-- Ticking connection --
Details:
    Connection: net.minecraft.network.NetworkManager@c594c87
Stacktrace:
    at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:148)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:882)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:800)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:646)
    at java.lang.Thread.run(Unknown Source)

-- System Details --
Details:
    Minecraft Version: 1.14.4
    Minecraft Version ID: 1.14.4
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_231, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 692512840 bytes (660 MB) / 2216165376 bytes (2113 MB) up to 3799515136 bytes (3623 MB)
    CPUs: 8
    JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
    ModLauncher: 3.2.0+60+b86c1d4
    ModLauncher launch target: fmluserdevclient
    ModLauncher naming: mcp
    ModLauncher services: 
        /eventbus-1.0.0-service.jar eventbus PLUGINSERVICE 
        /forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar object_holder_definalize PLUGINSERVICE 
        /forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar runtime_enum_extender PLUGINSERVICE 
        /accesstransformers-1.0.0-shadowed.jar accesstransformer PLUGINSERVICE 
        /forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar capability_inject_definalize PLUGINSERVICE 
        /forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar runtimedistcleaner PLUGINSERVICE 
        /forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar fml TRANSFORMATIONSERVICE 
    FML: 28.1
    Forge: net.minecraftforge:28.1.0
    FML Language Providers: 
        javafml@28.1
        minecraft@1
    Mod List: 
        forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar Forge {forge@28.1.0 DONE}
        main NE Mod {nemod@0.1 DONE}
        client-extra.jar Minecraft {minecraft@1.14.4 DONE}
    Player Count: 0 / 8; []
    Data Packs: vanilla, mod:nemod, mod:forge
    Type: Integrated Server (map_client.txt)
    Is Modded: Definitely; Client brand changed to 'forge'

Any ideas what is happening?

Remove that println at the event handler. It's causing problems when the player object is converted to string.

Edited by Cerandior
Link to comment
Share on other sites

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

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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