-
Notifications
You must be signed in to change notification settings - Fork 15
/
Item_Fort_java_bedrock.py
192 lines (165 loc) · 6.45 KB
/
Item_Fort_java_bedrock.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
from amulet.api.selection import SelectionGroup
from amulet.api.level import BaseLevel
from amulet.api.data_types import Dimension
from amulet_map_editor.programs.edit.api.operations.errors import OperationError
from amulet.api.block import Block
from amulet.api.block_entity import BlockEntity
from amulet_nbt import *
import amulet_nbt
import json
import random
import os
from os import path
import sys
def create_all_items_in_boxes(
world: BaseLevel, dimension: Dimension, selection: SelectionGroup, options: dict
):
fileP = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"itemdef.json"
)
print(fileP)
with open(fileP, "r") as fj:
jdata = json.load(fj)
pos = px, py, pz = selection.min_x, selection.min_y, selection.min_z
cntslot = 0
pxx = 0
cnt_boxs = 0
pyy = 0
pzz = 0
if world.level_wrapper.platform == "java":
bp = "java"
bv = (1, 17, 0)
for k, v in jdata['Items'].items():
if v.get('java') != "None":
if cntslot == 0:
theNBT = TAG_Compound({
"isMovable": TAG_Byte(1),
"Findable": TAG_Byte(0),
# "CustomName": TAG_String("§l§bEverything"), #TODO ADD NAME FOR JAVA
"Items": TAG_List(),
})
Slots = TAG_Compound({
"id": TAG_String("minecraft:" + v.get('java')),
"Count": TAG_Byte(64),
"Slot": TAG_Byte(cntslot)
})
if v.get('jsnbt') != None:
data = v.get('jsnbt').replace("'", "\"")
nbt = amulet_nbt.from_snbt("{" + data + "}")
try:
Slots['tag'] = nbt['tag']
except:
Slots['Block'] = nbt['Block']
cntslot += 1
theNBT["Items"].append(Slots)
if cntslot > 26 or int(k) == len(jdata['Items']) - 1:
blockEntity = BlockEntity("", "ShulkerBox", 0, 0, 0, NBTFile(theNBT))
cnt_boxs += 1
if cnt_boxs > 15:
block = Block("minecraft", "shulker_box", {"facing": TAG_String("east")})
elif cnt_boxs > 10:
block = Block("minecraft", "shulker_box", {"facing": TAG_String("north")})
elif cnt_boxs > 5:
block = Block("minecraft", "shulker_box", {"facing": TAG_String("west")})
elif cnt_boxs <= 5:
block = Block("minecraft", "shulker_box", {"facing": TAG_String("south")})
world.set_version_block(
px + pxx, py + pyy, pz + pzz, dimension, (bp, bv), block, blockEntity
)
block, blockEntity = world.get_version_block(
px + pxx, py + pyy, pz + pzz, dimension, (bp, bv)
)
cntslot = 0
if cnt_boxs == 5:
pzz += 1
if cnt_boxs == 10:
pxx -= 1
if cnt_boxs == 15:
pzz -= 1
if cnt_boxs == 16: # LEAVE A GAP
pxx -= 1
if cnt_boxs <= 5:
pxx += 1
elif cnt_boxs < 11:
pzz += 1
elif cnt_boxs < 16:
pxx -= 1
elif cnt_boxs <= 20:
pzz -= 1
if cnt_boxs >= 20:
pzz = 0
pxx = 0
pyy += 1
cnt_boxs = 0
if world.level_wrapper.platform == "bedrock":
bp = "bedrock"
bv = (1, 17, 0)
for k, v in jdata['Items'].items():
if v.get('bedrock') != "None":
if cntslot == 0:
theNBT = TAG_Compound({
"isMovable": TAG_Byte(1),
"Findable": TAG_Byte(0),
"CustomName": TAG_String("§l§bEverything"),
"Items": TAG_List(),
})
Slots = TAG_Compound({
"Name": TAG_String("minecraft:" + v.get('bedrock')),
"Damage": TAG_Short(v.get('DV')),
"Count": TAG_Byte(64),
"Slot": TAG_Byte(cntslot)
})
if v.get('bsnbt') != None:
data = v.get('bsnbt').replace("'", "\"")
nbt = amulet_nbt.from_snbt("{" + data + "}")
try:
Slots['tag'] = nbt['tag']
except:
Slots['Block'] = nbt['Block']
cntslot += 1
theNBT["Items"].append(Slots)
if cntslot > 26 or int(k) == len(jdata['Items']) - 1:
block = Block("minecraft", "shulker_box")
blockEntity = BlockEntity("", "ShulkerBox", 0, 0, 0, NBTFile(theNBT))
cnt_boxs += 1
if cnt_boxs > 15:
theNBT['facing'] = TAG_Byte(5)
elif cnt_boxs > 10:
theNBT['facing'] = TAG_Byte(2)
elif cnt_boxs > 5:
theNBT['facing'] = TAG_Byte(4)
elif cnt_boxs <= 5:
theNBT['facing'] = TAG_Byte(3)
world.set_version_block(
px + pxx, py + pyy, pz + pzz, dimension, (bp, bv), block, blockEntity
)
block, blockEntity = world.get_version_block(
px + pxx, py + pyy, pz + pzz, dimension, (bp, bv)
)
cntslot = 0
if cnt_boxs == 5:
pzz += 1
if cnt_boxs == 10:
pxx -= 1
if cnt_boxs == 15:
pzz -= 1
if cnt_boxs == 16: # LEAVE A GAP
pxx -= 1
if cnt_boxs <= 5:
pxx += 1
elif cnt_boxs < 11:
pzz += 1
elif cnt_boxs < 16:
pxx -= 1
elif cnt_boxs <= 20:
pzz -= 1
if cnt_boxs >= 20:
pzz = 0
pxx = 0
pyy += 1
cnt_boxs = 0
export = {
"name": "#A Fort of all Items", #by PremiereHell
"operation": create_all_items_in_boxes,
}