katubug

crafttweaker sleeping script

Jan 10th, 2020
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. import crafttweaker.event.PlayerInteractBlockEvent;
  2. import crafttweaker.event.PlayerInteractEvent;
  3. import crafttweaker.world.IWorld;
  4. import crafttweaker.player.IPlayer;
  5. import crafttweaker.event.PlayerSleepInBedEvent;
  6.  
  7. //This script will hopefully check whether the player has the Restful potion effect or if the weather is not clear, and prevent sleeping otherwise. I probably don't need all those imports but I really am not certain.
  8.  
  9. /*Reference pages:
  10. https://docs.blamejared.com/1.12/en/#Vanilla/Events/Events/PlayerInteractBlock/#playerinteractblock
  11. https://docs.blamejared.com/1.12/en/#Vanilla/Events/Events/PlayerInteract/
  12. https://docs.blamejared.com/1.12/en/#Vanilla/World/IWorld/
  13. https://docs.blamejared.com/1.12/en/#Vanilla/Events/Events/PlayerSleepInBed/
  14.  
  15. */
  16.  
  17. //Should I be doing InteractBlockEvent? PlayerSleepInBed seems more appropriate but I don't see that it can access the world states?
  18.  
  19. events.onPlayerInteractBlockEvent(function(event as crafttweaker.event.PlayerInteractEvent){
  20. if (world.isDaytime(false)) {
  21. if (world.isRaining(true) | world.isThundering(true) | player.activePotionEffects(/*????*/)) {
  22. //Then let sleep happen?
  23. }
  24. }
  25. if (world.isDayTime(true)) {
  26. event.cancel();
  27. }
  28. }
  29. );
  30.  
  31. /*
  32. world:
  33. isRaining()
  34. isThundering()
  35. isDayTime()
  36.  
  37. player:
  38. activePotionEffects(List<IPotionEffect>) <--- I have no idea whatsoever how the syntax for this works. The potion name is "simplytea.effect.restful" and the registry name is just "simplytea:restful"
  39. */
Advertisement
Add Comment
Please, Sign In to add comment