-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcreatespawners.py
48 lines (37 loc) · 1.42 KB
/
createspawners.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
# Feel free to modify and use this filter however you wish. If you do,
# please give credit to SethBling.
# http://youtube.com/SethBling
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 TileEntity
displayName = "Create Spawners"
inputs = (
("Include position data", False),
)
def perform(level, box, options):
includePos = options["Include position data"]
entitiesToRemove = []
for (chunk, slices, point) in level.getChunkSlices(box):
for entity in chunk.Entities:
x = int(entity["Pos"][0].value)
y = int(entity["Pos"][1].value)
z = int(entity["Pos"][2].value)
if x >= box.minx and x < box.maxx and y >= box.miny and y < box.maxy and z >= box.minz and z < box.maxz:
entitiesToRemove.append((chunk, entity))
level.setBlockAt(x, y, z, 52)
spawner = TileEntity.Create("MobSpawner")
TileEntity.setpos(spawner, (x, y, z))
spawner["Delay"] = TAG_Short(120)
spawner["SpawnData"] = entity
if not includePos:
spawner["SpawnData"].value.remove(entity["Pos"])
spawner["EntityId"] = entity["id"]
chunk.TileEntities.append(spawner)
for (chunk, entity) in entitiesToRemove:
chunk.Entities.remove(entity)