forked from Podshot/MCEdit-Filters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenchanter.py
62 lines (53 loc) · 1.61 KB
/
enchanter.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
from pymclevel.nbt import *
displayName = "Enchanter"
VERSION = "1.0.0"
UPDATE_URL = "http://podshot.github.io/update/enchanter.json"
Effects = {
"*None": None,
"Protection": 0,
"Fire Protection": 1,
"Feather Falling": 2,
"Blast Protection": 3,
"Projectile Protection": 4,
"Respiration": 5,
"Aqua Affinity": 6,
"Thorns": 7,
"Sharpness": 16,
"Smite": 17,
"Bane of Arthropods": 18,
"Knockback": 19,
"Fire Aspect": 20,
"Looting": 21,
"Efficiency": 32,
"Silk Touch": 33,
"Unbreaking": 34,
"Fortune": 35,
"Power": 48,
"Punch": 49,
"Flame": 50,
"Infinity": 51,
}
inputs = (
("Enchantment", tuple(sorted(Effects.keys()))),
("Enchantment Level", (1, 1, 127))
)
def perform(level, box, options):
ent = options["Enchantment"]
lvl = options["Enchantment Level"]
for (chunk, slices, point) in level.getChunkSlices(box):
for t in chunk.TileEntities:
if t["id"].value == "Trap" or t["id"].value == "Dropper" or t["id"].value == "Chest":
x = t["x"].value
y = t["y"].value
z = t["z"].value
if (x,y,z) in box:
for item in t["Items"]:
if "tag" not in item:
item["tag"] = TAG_Compound()
if "ench" not in item["tag"]:
item["tag"]["ench"] = TAG_List()
bre = TAG_Compound()
bre["id"] = TAG_Short(ent)
bre["lvl"] = TAG_Short(lvl)
item["tag"]["ench"].append(bre)
chunk.dirty = True