-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpeaceful_mode.py
More file actions
57 lines (47 loc) Β· 1.62 KB
/
peaceful_mode.py
File metadata and controls
57 lines (47 loc) Β· 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
"""Set peaceful conditions - no mobs, daytime"""
from mcrcon import MCRcon
import time
import threading
RCON_HOST = "localhost"
RCON_PORT = 25575
RCON_PASSWORD = "minecraft123"
def execute_command(command):
with MCRcon(RCON_HOST, RCON_PASSWORD, port=RCON_PORT) as mcr:
response = mcr.command(command)
return response
print("π
Setting peaceful conditions...")
print()
# Set to daytime
print("βοΈ Setting time to day...")
response = execute_command("time set day")
print(f" {response}")
# Disable mob spawning
print("π« Disabling mob spawning...")
response = execute_command("gamerule doMobSpawning false")
print(f" {response}")
# Clear existing hostile mobs
print("π Clearing existing hostile mobs...")
for mob in ["zombie", "skeleton", "creeper", "spider", "witch"]:
response = execute_command(f"kill @e[type={mob}]")
if "Killed" in response:
print(f" {response}")
print()
print("β
Peaceful mode activated!")
print()
print("Mob spawning will be disabled for 1 hour.")
print("The world is now safe to explore! π°")
print()
# Schedule re-enabling after 1 hour
def re_enable_mobs():
time.sleep(3600) # Wait 1 hour (3600 seconds)
print("\nβ° 1 hour has passed!")
print("π Re-enabling mob spawning...")
response = execute_command("gamerule doMobSpawning true")
print(f" {response}")
print("β
Normal mob spawning restored!")
# Start timer in background
timer_thread = threading.Thread(target=re_enable_mobs, daemon=True)
timer_thread.start()
print("Timer started: Mobs will return in 1 hour")
print("(Script will keep running in background)")