forked from Podshot/MCEdit-Filters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Name Mobs.py
82 lines (72 loc) · 2.28 KB
/
Name Mobs.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# This is filter that renames existing mobs, requested by VideoGameMaster on The Minecraft Forums
# This filter was created by Podshot
# If you redistribute/modify, please give credit to Podshot
# ================================================================
# Have an idea? Can you improve this code? Fork the Github!
# Link: https://github.com/Podshot/MCEdit-Filters
from pymclevel import TAG_Compound
from pymclevel import TAG_Int
from pymclevel import TAG_Short
from pymclevel import TAG_Byte
from pymclevel import TAG_String
from pymclevel import TAG_Float
from pymclevel import TAG_Double
from pymclevel import TAG_List
from pymclevel import MCSchematic
VERSION = "1.8.0"
UPDATE_URL = "http://podshot.github.io/update/Name%20Mobs.json"
formatting = {
"Bold":"l",
"Strikethrough":"m",
"Underline":"n",
"Itallics":"o"
}
colors = {
"White": "f",
"Black": "0",
"Dark Blue": "1",
"Dark Green": "2",
"Dark Aqua": "3",
"Dark Red": "4",
"Purple": "5",
"Gold": "6",
"Gray": "7",
"Dark Gray": "8",
"Indigo": "9",
"Bright Green": "a",
"Aqua": "b",
"Red": "c",
"Pink": "d",
"Yellow": "e",
}
displayName = "Name Mobs"
inputs = (
("Name",("string","value=")),
("Name Color",tuple(sorted(colors.keys()))),
("Name Bold", False),
("Name Itallics", False),
("Name Strikethrough", False),
("Name Underline", False),
("Version: 1.8","label")
)
formatChar = unichr(167)
def perform(level, box, options):
formatCode = formatChar + colors[options["Name Color"]]
if options["Name Bold"]:
formatCode += formatChar + formatting["Bold"]
if options["Name Itallics"]:
formatCode += formatChar + formatting["Itallics"]
if options["Name Strikethrough"]:
formatCode += formatChar + formatting["Strikethrough"]
if options["Name Underline"]:
formatCode += formatChar + formatting["Underline"]
name = TAG_String(formatCode + options["Name"] + formatChar + "r")
for (chunk, slices, point) in level.getChunkSlices(box):
for e in chunk.Entities:
x = e["Pos"][0].value
y = e["Pos"][1].value
z = e["Pos"][2].value
if (x,y,z) in box:
e["CustomNameVisible"] = TAG_Byte(1)
e["CustomName"] = name
chunk.dirty = True