Recognise food level change

Dear all,

I am trying to figure out how I can recognise players food level changes. Inside the java docs I coulnd’t find any event that could provide such data. Based on some research inside this forum maybe the ChangeDataHolderEvent can provide me the information I need. I tried to get use to handle the event data, but I can’t figure out how I have to work with it to determine a food level change of a player.

Can anyone can give me some advises here or references that would help me out? Is it possiable to get the information I need with the ChangeDataHolderEvent?

I would appreciate any help


Use ChangeDataHolderEvent.ChangeValue from there you getOriginalChanges and find out the data that is being used

Thanks for the hint. I figured out how to get the key changes by writing the following code

	public void onFoodLevelChange(ChangeDataHolderEvent.ValueChange event) {
		if (event.getOriginalChanges().isSuccessful())
			for (ImmutableValue<?> immutableValue : event.getOriginalChanges().getSuccessfulData())
				if (immutableValue.getKey() == Keys.FOOD_LEVEL);

Unfortunately when the players food level is changing its not printing out the current value. Seems food level changes didn’t get handled here. If I remove the key condition I get several output from sprinting, healing and so on. Do I have to pay attention to something special for the food level change or isn’t it implemented here?

I still need some help here. Does anyone know how to determine a food level change?

An all else fails attempt you can use a scheduler until the food level is implemented into the data api. Its not the best idea but if you store the players food level and then check the latest food level with the old data, you can use the scheduler to do what you want…

Ps. Im very tipsy … Not quite drunk so sorry about spelling and grammar mistakes.