dfpyre 0.4.6__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dfpyre might be problematic. Click here for more details.
- dfpyre/items.py +70 -152
- dfpyre/pyre.py +135 -209
- dfpyre/style.py +14 -14
- {dfpyre-0.4.6.dist-info → dfpyre-0.5.0.dist-info}/METADATA +77 -79
- dfpyre-0.5.0.dist-info/RECORD +9 -0
- dfpyre-0.4.6.dist-info/RECORD +0 -9
- {dfpyre-0.4.6.dist-info → dfpyre-0.5.0.dist-info}/LICENSE +0 -0
- {dfpyre-0.4.6.dist-info → dfpyre-0.5.0.dist-info}/WHEEL +0 -0
dfpyre/items.py
CHANGED
|
@@ -4,35 +4,24 @@ Contains class definitions for code items.
|
|
|
4
4
|
|
|
5
5
|
from enum import Enum
|
|
6
6
|
from typing import Literal, Dict
|
|
7
|
-
from dfpyre.style import
|
|
7
|
+
from dfpyre.style import is_ampersand_coded, ampersand_to_minimessage
|
|
8
|
+
from mcitemlib.itemlib import Item as NbtItem
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
def _add_slot(d: Dict, slot: int|None):
|
|
11
12
|
if slot is not None:
|
|
12
13
|
d['slot'] = slot
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
class item:
|
|
15
|
+
class item(NbtItem):
|
|
16
16
|
"""
|
|
17
17
|
Represents a Minecraft item.
|
|
18
18
|
"""
|
|
19
19
|
type = 'item'
|
|
20
20
|
|
|
21
|
-
def __init__(self, itemID: str, count: int=1):
|
|
22
|
-
self.id = itemID
|
|
23
|
-
self.count = count
|
|
24
|
-
|
|
25
21
|
def format(self, slot: int|None):
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"data": {
|
|
30
|
-
"item": f"{{DF_NBT:2586,id:\"{self.id}\",Count:{self.count}b}}"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
_add_slot(formattedDict, slot)
|
|
35
|
-
return formattedDict
|
|
22
|
+
formatted_dict = {"item": {"id": self.type, "data": {"item": self.get_nbt()}}}
|
|
23
|
+
_add_slot(formatted_dict, slot)
|
|
24
|
+
return formatted_dict
|
|
36
25
|
|
|
37
26
|
|
|
38
27
|
class string:
|
|
@@ -45,16 +34,9 @@ class string:
|
|
|
45
34
|
self.value = value
|
|
46
35
|
|
|
47
36
|
def format(self, slot: int|None):
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"data": {
|
|
52
|
-
"name": self.value
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
_add_slot(formattedDict, slot)
|
|
57
|
-
return formattedDict
|
|
37
|
+
formatted_dict = {"item": {"id": self.type, "data": {"name": self.value}}}
|
|
38
|
+
_add_slot(formatted_dict, slot)
|
|
39
|
+
return formatted_dict
|
|
58
40
|
|
|
59
41
|
|
|
60
42
|
class text:
|
|
@@ -64,21 +46,14 @@ class text:
|
|
|
64
46
|
type = 'comp'
|
|
65
47
|
|
|
66
48
|
def __init__(self, value: str):
|
|
67
|
-
if
|
|
68
|
-
value =
|
|
49
|
+
if is_ampersand_coded(value):
|
|
50
|
+
value = ampersand_to_minimessage(value)
|
|
69
51
|
self.value = value
|
|
70
|
-
|
|
52
|
+
|
|
71
53
|
def format(self, slot: int|None):
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"data": {
|
|
76
|
-
"name": self.value
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
_add_slot(formattedDict, slot)
|
|
81
|
-
return formattedDict
|
|
54
|
+
formatted_dict = {"item": {"id": self.type, "data": {"name": self.value}}}
|
|
55
|
+
_add_slot(formatted_dict, slot)
|
|
56
|
+
return formatted_dict
|
|
82
57
|
|
|
83
58
|
|
|
84
59
|
class num:
|
|
@@ -91,16 +66,9 @@ class num:
|
|
|
91
66
|
self.value = num
|
|
92
67
|
|
|
93
68
|
def format(self, slot: int|None):
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"data": {
|
|
98
|
-
"name": str(self.value)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
_add_slot(formattedDict, slot)
|
|
103
|
-
return formattedDict
|
|
69
|
+
formatted_dict = {"item": {"id": self.type, "data": {"name": str(self.value)}}}
|
|
70
|
+
_add_slot(formatted_dict, slot)
|
|
71
|
+
return formatted_dict
|
|
104
72
|
|
|
105
73
|
|
|
106
74
|
class loc:
|
|
@@ -117,23 +85,21 @@ class loc:
|
|
|
117
85
|
self.yaw = float(yaw)
|
|
118
86
|
|
|
119
87
|
def format(self, slot: int|None):
|
|
120
|
-
|
|
121
|
-
"
|
|
122
|
-
|
|
123
|
-
"data": {
|
|
88
|
+
formatted_dict = {"item": {
|
|
89
|
+
"id": self.type,
|
|
90
|
+
"data": {
|
|
124
91
|
"isBlock": False,
|
|
125
92
|
"loc": {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
93
|
+
"x": self.x,
|
|
94
|
+
"y": self.y,
|
|
95
|
+
"z": self.z,
|
|
96
|
+
"pitch": self.pitch,
|
|
97
|
+
"yaw": self.yaw
|
|
131
98
|
}
|
|
132
|
-
}
|
|
133
99
|
}
|
|
134
|
-
|
|
135
|
-
_add_slot(
|
|
136
|
-
return
|
|
100
|
+
}}
|
|
101
|
+
_add_slot(formatted_dict, slot)
|
|
102
|
+
return formatted_dict
|
|
137
103
|
|
|
138
104
|
|
|
139
105
|
class var:
|
|
@@ -147,17 +113,9 @@ class var:
|
|
|
147
113
|
self.scope = scope
|
|
148
114
|
|
|
149
115
|
def format(self, slot: int|None):
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
"data": {
|
|
154
|
-
"name": self.name,
|
|
155
|
-
"scope": self.scope
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
_add_slot(formattedDict, slot)
|
|
160
|
-
return formattedDict
|
|
116
|
+
formatted_dict = {"item": {"id": self.type,"data": {"name": self.name, "scope": self.scope}}}
|
|
117
|
+
_add_slot(formatted_dict, slot)
|
|
118
|
+
return formatted_dict
|
|
161
119
|
|
|
162
120
|
|
|
163
121
|
class sound:
|
|
@@ -172,18 +130,9 @@ class sound:
|
|
|
172
130
|
self.vol = vol
|
|
173
131
|
|
|
174
132
|
def format(self, slot: int|None):
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
"data": {
|
|
179
|
-
"sound": self.name,
|
|
180
|
-
"pitch": self.pitch,
|
|
181
|
-
"vol": self.vol
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
_add_slot(formattedDict, slot)
|
|
186
|
-
return formattedDict
|
|
133
|
+
formatted_dict = {"item": {"id": self.type,"data": {"sound": self.name, "pitch": self.pitch, "vol": self.vol}}}
|
|
134
|
+
_add_slot(formatted_dict, slot)
|
|
135
|
+
return formatted_dict
|
|
187
136
|
|
|
188
137
|
|
|
189
138
|
class particle:
|
|
@@ -203,27 +152,24 @@ class particle:
|
|
|
203
152
|
self.motionVariation = motionVariation
|
|
204
153
|
|
|
205
154
|
def format(self, slot: int|None):
|
|
206
|
-
|
|
207
|
-
"
|
|
208
|
-
"id": self.type,
|
|
209
|
-
"data": {
|
|
155
|
+
formatted_dict = {"item": {"id": self.type,
|
|
156
|
+
"data": {
|
|
210
157
|
"particle": self.name,
|
|
211
158
|
"cluster": {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
159
|
+
"amount": self.amount,
|
|
160
|
+
"horizontal": self.horizontal,
|
|
161
|
+
"vertical": self.vertical
|
|
215
162
|
},
|
|
216
163
|
"data": {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
164
|
+
"x": self.x,
|
|
165
|
+
"y": self.y,
|
|
166
|
+
"z": self.z,
|
|
167
|
+
"motionVariation": self.motionVariation
|
|
221
168
|
}
|
|
222
|
-
}
|
|
223
169
|
}
|
|
224
|
-
|
|
225
|
-
_add_slot(
|
|
226
|
-
return
|
|
170
|
+
}}
|
|
171
|
+
_add_slot(formatted_dict, slot)
|
|
172
|
+
return formatted_dict
|
|
227
173
|
|
|
228
174
|
|
|
229
175
|
class potion:
|
|
@@ -238,18 +184,9 @@ class potion:
|
|
|
238
184
|
self.amp = amp
|
|
239
185
|
|
|
240
186
|
def format(self, slot: int|None):
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
"data": {
|
|
245
|
-
"pot": self.name,
|
|
246
|
-
"dur": self.dur,
|
|
247
|
-
"amp": self.amp
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
_add_slot(formattedDict, slot)
|
|
252
|
-
return formattedDict
|
|
187
|
+
formatted_dict = {"item": {"id": self.type,"data": {"pot": self.name, "dur": self.dur, "amp": self.amp}}}
|
|
188
|
+
_add_slot(formatted_dict, slot)
|
|
189
|
+
return formatted_dict
|
|
253
190
|
|
|
254
191
|
|
|
255
192
|
class gamevalue:
|
|
@@ -263,17 +200,9 @@ class gamevalue:
|
|
|
263
200
|
self.target = target
|
|
264
201
|
|
|
265
202
|
def format(self, slot: int|None):
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
"data": {
|
|
270
|
-
"type": self.name,
|
|
271
|
-
"target": self.target
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
_add_slot(formattedDict, slot)
|
|
276
|
-
return formattedDict
|
|
203
|
+
formatted_dict = {"item": {"id": self.type, "data": {"type": self.name, "target": self.target}}}
|
|
204
|
+
_add_slot(formatted_dict, slot)
|
|
205
|
+
return formatted_dict
|
|
277
206
|
|
|
278
207
|
|
|
279
208
|
class vector:
|
|
@@ -288,18 +217,9 @@ class vector:
|
|
|
288
217
|
self.z = float(z)
|
|
289
218
|
|
|
290
219
|
def format(self, slot: int|None):
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
"data": {
|
|
295
|
-
"x": self.x,
|
|
296
|
-
"y": self.y,
|
|
297
|
-
"z": self.z
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
_add_slot(formattedDict, slot)
|
|
302
|
-
return formattedDict
|
|
220
|
+
formatted_dict = {"item": {"id": self.type, "data": {"x": self.x, "y": self.y, "z": self.z}}}
|
|
221
|
+
_add_slot(formatted_dict, slot)
|
|
222
|
+
return formatted_dict
|
|
303
223
|
|
|
304
224
|
|
|
305
225
|
PARAMETER_TYPE_LOOKUP = ['txt', 'comp', 'num', 'loc', 'vec', 'snd', 'part', 'pot', 'item', 'any', 'var', 'list', 'dict']
|
|
@@ -328,34 +248,32 @@ class parameter:
|
|
|
328
248
|
"""
|
|
329
249
|
type = 'pn_el'
|
|
330
250
|
|
|
331
|
-
def __init__(self, name: str,
|
|
251
|
+
def __init__(self, name: str, param_type: ParameterType, plural: bool=False, optional: bool=False, description: str="", note: str="", default_value=None):
|
|
332
252
|
self.name = name
|
|
333
|
-
self.
|
|
253
|
+
self.param_type = param_type
|
|
334
254
|
self.plural = plural
|
|
335
255
|
self.optional = optional
|
|
336
256
|
self.description = description
|
|
337
257
|
self.note = note
|
|
338
|
-
self.
|
|
258
|
+
self.default_value = default_value
|
|
339
259
|
|
|
340
260
|
|
|
341
261
|
def format(self, slot: int):
|
|
342
|
-
|
|
343
|
-
"
|
|
344
|
-
|
|
345
|
-
"data": {
|
|
262
|
+
formatted_dict = {"item": {
|
|
263
|
+
"id": self.type,
|
|
264
|
+
"data": {
|
|
346
265
|
"name": self.name,
|
|
347
|
-
"type": self.
|
|
266
|
+
"type": self.param_type.get_string_value(),
|
|
348
267
|
"plural": self.plural,
|
|
349
268
|
"optional": self.optional,
|
|
350
|
-
|
|
351
|
-
},
|
|
269
|
+
}},
|
|
352
270
|
"slot": slot
|
|
353
|
-
|
|
271
|
+
}
|
|
354
272
|
if self.description:
|
|
355
|
-
|
|
273
|
+
formatted_dict['item']['data']['description'] = self.description
|
|
356
274
|
if self.note:
|
|
357
|
-
|
|
358
|
-
if self.
|
|
359
|
-
|
|
275
|
+
formatted_dict['item']['data']['note'] = self.note
|
|
276
|
+
if self.default_value is not None and not self.plural and self.optional:
|
|
277
|
+
formatted_dict['item']['data']['default_value'] = self.default_value.format(None)['item']
|
|
360
278
|
|
|
361
|
-
return
|
|
279
|
+
return formatted_dict
|