Advertisement
v1993

Untitled

Nov 9th, 2021
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. import crafttweaker.data.IData;
  2. import crafttweaker.player.IPlayer;
  3.  
  4. //import mods.hungertweaker.events;
  5.  
  6. // Helper functions to manage custom per-player data.
  7.  
  8. function SetSoLData(pl as IPlayer, solData as IData) {
  9. var plData = pl.nbt as IData;
  10. val solDataContainer as IData = {
  11. solData: solData
  12. };
  13.  
  14. pl.nbt = plData + solDataContainer;
  15. }
  16.  
  17. function GetSoLData(pl as IPlayer) as IData {
  18. // Try to read solData from player data
  19. var plData = pl.nbt as IData;
  20. var solData = plData.solData;
  21.  
  22. if (!isNull(solData)) {
  23. // Per-player data found, check version
  24. val ver = solData.dataVersion;
  25. // TODO: move into value at the top
  26. if (ver.asInt() == 0) {
  27. return solData;
  28. } else {
  29. print("Spice Of Life: CT Edition: invalid data version found, resetting data");
  30. }
  31. }
  32.  
  33. print("Spice Of Life: CT Edition: generating new data");
  34. val tastedFoods = {} as IData;
  35. val recentFoods = {} as IData;
  36. solData = {
  37. tastedFoods: tastedFoods,
  38. recentFoods: recentFoods,
  39.  
  40. dataVersion: 0
  41. } as IData;
  42. SetSoLData(pl, solData);
  43. return solData;
  44. }
  45.  
  46. // Calculate modified food value
  47. // TESTING ONLY - WILL CHANGE LATER!!!
  48.  
  49. mods.hungertweaker.events.HungerEvents.onGetFoodValues(function(event as mods.hungertweaker.events.GetFoodValuesEvent) {
  50. val dat = GetSoLData(event.player);
  51. //print("Read data!");
  52. });
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement