Jump to content

Ritzga

Vintarian
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Ritzga

  1. Hello, maybe this class can help you https://github.com/anegostudios/vsapi/blob/9bf26b71970ff2168d6f8534cf6ee4a914087511/Common/API/IGameCalendar.cs#L49 and where its implemented and used here https://github.com/anegostudios/vsapi/blob/9bf26b71970ff2168d6f8534cf6ee4a914087511/Client/API/IClientWorldAccessor.cs#L79 so you load it like here: IClientWorldAccessor clientWorld = (IClientWorldAccessor)Api.World; Good luck!
  2. *sigh* That was the problem, thanks!
  3. Hello! I need some help for the development of an class mod: https://mods.vintagestory.at/minerz The idea is that the hunger rate should be lowered if you are in closed rooms/underground. I used the body temperature behaviour because I have no access to the Rooms-Class (or idk how to access it). Just like this: This is how I do it at the moment but its very ineffective and may needs too much. I would like to create a own behaviour to detect if the player is in a room (or just detect the sun light) and trigger the change. How do I add a new behaviour to the registry ? [HarmonyPrefix] [HarmonyPatch(typeof(EntityBehaviorBodyTemperature), "OnGameTick")] public static void OnBodyTemperatureTickBefore(ref bool ___inEnclosedRoom, ref EntityAgent ___eagent, ref ICoreAPI ___api, ref float ___slowaccum) { if (___slowaccum > 2) { if (___inEnclosedRoom && ___api.ModLoader.GetModSystem<CharacterSystem>() .HasTrait((___eagent as EntityPlayer)?.Player, "lovesUnderground")) { ___eagent.Stats.Set("hungerrate", "minerstat", (float)-hungerrate); } } } [HarmonyPostfix] [HarmonyPatch(typeof(EntityBehaviorBodyTemperature), "OnGameTick")] public static void OnBodyTemperatureTickAfter(ref bool ___inEnclosedRoom, ref EntityAgent ___eagent, ref ICoreAPI ___api, ref float ___slowaccum) { if (___slowaccum > 2) { if (___inEnclosedRoom && !___inEnclosedRoom && ___inEnclosedRoom && ___api.ModLoader .GetModSystem<CharacterSystem>() .HasTrait((___eagent as EntityPlayer)?.Player, "lovesUnderground")) { ___eagent.Stats.Set("hungerrate", "minerstat", 0.0f); } } } Did someone know how to do it in a better way ? Or give me an advice ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.