forked from Podshot/MCEdit-Filters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Minecart Creator.py
113 lines (97 loc) · 3.8 KB
/
Minecart Creator.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# This is filter that creates a custom minecart in the selection box
# 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
from pymclevel import TileEntity
displayName = "Custom Minecart Creator"
VERSION = "1.7.0"
UPDATE_URL = "http://podshot.github.io/update/Minecart%20Creator.json"
carts = {
"Ridable": 1,
"Furnace": 2,
"TNT": 3,
"Chest": 4,
"Hopper": 5,
"Spawner": 6,
"Command Block": 7,
}
inputs = (
("Block:", "blocktype"),
("Block Data:", (0,0,16)),
("Block Height from Cart:", 0),
("A Height of 16 will move the block up by exactly one multiple of its height.", "label"),
("Type of Cart:", tuple(sorted(carts.keys()))),
("Version: 1.7","label"),
)
def perform(level, box, options):
block = options["Block:"].ID
data = options["Block Data:"]
height = options["Block Height from Cart:"]
typ = options["Type of Cart:"]
tileEntitiesToRemove = []
if typ == "Ridable":
mc = TAG_String("MinecartRideable")
elif typ == "Furnace":
mc = TAG_String("MinecartFurnace")
elif typ == "TNT":
mc = TAG_String("MinecartTNT")
elif typ == "Chest":
mc = TAG_String("MinecartChest")
elif typ == "Hopper":
mc = TAG_String("MinecartHopper")
elif typ == "Spawner":
mc = TAG_String("MinecartSpawner")
elif typ == "Command Block":
mc = TAG_String("MinecartCommandBlock")
for (chunk, slices, point) in level.getChunkSlices(box):
for t in chunk.TileEntities:
x = t["x"].value
y = t["y"].value
z = t["z"].value
tileEntitiesToRemove.append((chunk, t))
level.setBlockAt(x, y, z, 0)
cart = TAG_Compound()
cart["Air"] = TAG_Short(300)
cart["FallDistance"] = TAG_Float(0)
cart["Fire"] = TAG_Short(-1)
cart["id"] = mc
cart["Invulnerable"] = TAG_Byte(0)
cart["Motion"] = TAG_List()
cart["Motion"].append(TAG_Double(0))
cart["Motion"].append(TAG_Double(-0))
cart["Motion"].append(TAG_Double(0))
cart["OnGround"] = TAG_Byte(1)
cart["Pos"] = TAG_List()
cart["Pos"].append(TAG_Double(box.minx + 0.5))
cart["Pos"].append(TAG_Double(box.miny + 1))
cart["Pos"].append(TAG_Double(box.minz + 0.5))
cart["Rotation"] = TAG_List()
cart["Rotation"].append(TAG_Float(0))
cart["Rotation"].append(TAG_Float(0))
cart["CustomDisplayTile"] = TAG_Byte(1)
cart["DisplayTile"] = TAG_Int(block)
cart["DisplayData"] = TAG_Int(data)
cart["DisplayOffset"] = TAG_Int(height)
if typ == "Spawner":
for tag in t:
if tag not in ["id", "x", "y", "z"]:
cart[tag] = t[tag]
if typ == "MinecartCommandBlock":
if t["id"] == "Control":
cart["Command"] = t["Command"]
cart["CustomName"] = t["CustomName"]
chunk.Entities.append(cart)
chunk.dirty = True
for (chunk, t) in tileEntitiesToRemove:
chunk.TileEntities.remove(t)