You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every time one of the players on my server changes dimension (nether portal, teleport, etc), their hunger is immediately reset to a fixed value (usually full hunger bar and around 6 points of saturation).
Our server has vertically stacked overworld and skyblock, so people change dimension often. This means that any food eaten over 3 shanks of saturation is wasted whenever you switch maps, and some players have learned they no longer need to eat as long as they step through once in a while.
The text was updated successfully, but these errors were encountered:
The problem appears to be in MyEventHandler.java, where whenever a player joins a world, the mod replaces the player's foodStats with a new custom FoodStats object which has been initialized with default values of 20 food and 5 saturation.
The fix is twofold. First, check if the FoodStats object is already from this mod, in which case no action is needed. This solves the problem of the stats getting reset when a player changes dimensions. To fix the stats reset when a player logs out and back in, you can copy the values from the old FoodStats before replacing them.
@Mod.EventBusSubscriber(modid = Oversaturation.MODID)
public class MyEventHandler {
@SubscribeEvent
public static void onEntityJoinWorld(EntityJoinWorldEvent event) {
if (event.getEntity() instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer) event.getEntity();
FoodStats oldStats = player.getFoodStats();
if (null != oldStats && !(oldStats instanceof com.nachie.oversaturation.FoodStats)) {
FoodStats newStats = new FoodStats();
NBTTagCompound foodnbt = new NBTTagCompound();
oldStats.writeNBT(foodnbt);
newStats.readNBT(foodnbt);
player.foodStats = newStats;
}
}
}
}
The repository doesn't appear to be in a buildable state (no build.gradle), so I haven't tested this fix. Please let me know if you need anything further.
Every time one of the players on my server changes dimension (nether portal, teleport, etc), their hunger is immediately reset to a fixed value (usually full hunger bar and around 6 points of saturation).
Our server has vertically stacked overworld and skyblock, so people change dimension often. This means that any food eaten over 3 shanks of saturation is wasted whenever you switch maps, and some players have learned they no longer need to eat as long as they step through once in a while.
The text was updated successfully, but these errors were encountered: