amulet-core 2.0a7__cp311-cp311-win_amd64.whl → 2.0a8__cp311-cp311-win_amd64.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 amulet-core might be problematic. Click here for more details.

Files changed (80) hide show
  1. amulet/__init__.cp311-win_amd64.pyd +0 -0
  2. amulet/__init__.py.cpp +2 -0
  3. amulet/__init__.pyi +2 -0
  4. amulet/_version.py +3 -3
  5. amulet/chunk.hpp +2 -1
  6. amulet/level/abc/_chunk_handle.py +45 -22
  7. amulet/mesh/block/__init__.pyi +301 -0
  8. amulet/mesh/block/_cube.py +198 -0
  9. amulet/mesh/block/{missing_block.py → _missing_block.py} +2 -2
  10. amulet/mesh/block/block_mesh.cpp +107 -0
  11. amulet/mesh/block/block_mesh.hpp +207 -0
  12. amulet/resource_pack/__init__.py +16 -15
  13. amulet/resource_pack/abc/resource_pack_manager.py +3 -5
  14. amulet/resource_pack/java/resource_pack_manager.py +185 -173
  15. amulet/utils/cast.py +10 -0
  16. amulet/utils/shareable_lock.py +2 -2
  17. {amulet_core-2.0a7.dist-info → amulet_core-2.0a8.dist-info}/METADATA +2 -2
  18. {amulet_core-2.0a7.dist-info → amulet_core-2.0a8.dist-info}/RECORD +21 -75
  19. {amulet_core-2.0a7.dist-info → amulet_core-2.0a8.dist-info}/WHEEL +1 -1
  20. amulet/mesh/block/__init__.py +0 -1
  21. amulet/mesh/block/block_mesh.py +0 -369
  22. amulet/mesh/block/cube.py +0 -149
  23. amulet/resource_pack/bedrock/__init__.py +0 -2
  24. amulet/resource_pack/bedrock/bedrock_vanilla_fix/pack_icon.png +0 -0
  25. amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/grass_carried.png +0 -0
  26. amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/grass_side_carried.png +0 -0
  27. amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/water.png +0 -0
  28. amulet/resource_pack/bedrock/blockshapes/__init__.py +0 -31
  29. amulet/resource_pack/bedrock/blockshapes/air.py +0 -35
  30. amulet/resource_pack/bedrock/blockshapes/base_blockshape.py +0 -29
  31. amulet/resource_pack/bedrock/blockshapes/bubble_column.py +0 -29
  32. amulet/resource_pack/bedrock/blockshapes/cake.py +0 -46
  33. amulet/resource_pack/bedrock/blockshapes/chest.py +0 -54
  34. amulet/resource_pack/bedrock/blockshapes/comparator.py +0 -51
  35. amulet/resource_pack/bedrock/blockshapes/cross_texture.py +0 -186
  36. amulet/resource_pack/bedrock/blockshapes/cross_texture0.py +0 -17
  37. amulet/resource_pack/bedrock/blockshapes/cross_texture_green.py +0 -16
  38. amulet/resource_pack/bedrock/blockshapes/cube.py +0 -38
  39. amulet/resource_pack/bedrock/blockshapes/default.py +0 -14
  40. amulet/resource_pack/bedrock/blockshapes/door.py +0 -38
  41. amulet/resource_pack/bedrock/blockshapes/door1.py +0 -14
  42. amulet/resource_pack/bedrock/blockshapes/door2.py +0 -14
  43. amulet/resource_pack/bedrock/blockshapes/door3.py +0 -14
  44. amulet/resource_pack/bedrock/blockshapes/door4.py +0 -14
  45. amulet/resource_pack/bedrock/blockshapes/door5.py +0 -14
  46. amulet/resource_pack/bedrock/blockshapes/door6.py +0 -14
  47. amulet/resource_pack/bedrock/blockshapes/double_plant.py +0 -40
  48. amulet/resource_pack/bedrock/blockshapes/enchanting_table.py +0 -22
  49. amulet/resource_pack/bedrock/blockshapes/farmland.py +0 -22
  50. amulet/resource_pack/bedrock/blockshapes/fence.py +0 -22
  51. amulet/resource_pack/bedrock/blockshapes/flat.py +0 -55
  52. amulet/resource_pack/bedrock/blockshapes/flat_wall.py +0 -55
  53. amulet/resource_pack/bedrock/blockshapes/furnace.py +0 -44
  54. amulet/resource_pack/bedrock/blockshapes/furnace_lit.py +0 -14
  55. amulet/resource_pack/bedrock/blockshapes/green_cube.py +0 -39
  56. amulet/resource_pack/bedrock/blockshapes/ladder.py +0 -36
  57. amulet/resource_pack/bedrock/blockshapes/lilypad.py +0 -14
  58. amulet/resource_pack/bedrock/blockshapes/partial_block.py +0 -57
  59. amulet/resource_pack/bedrock/blockshapes/piston.py +0 -44
  60. amulet/resource_pack/bedrock/blockshapes/piston_arm.py +0 -72
  61. amulet/resource_pack/bedrock/blockshapes/portal_frame.py +0 -22
  62. amulet/resource_pack/bedrock/blockshapes/pressure_plate.py +0 -29
  63. amulet/resource_pack/bedrock/blockshapes/pumpkin.py +0 -36
  64. amulet/resource_pack/bedrock/blockshapes/pumpkin_carved.py +0 -14
  65. amulet/resource_pack/bedrock/blockshapes/pumpkin_lit.py +0 -14
  66. amulet/resource_pack/bedrock/blockshapes/red_dust.py +0 -14
  67. amulet/resource_pack/bedrock/blockshapes/repeater.py +0 -53
  68. amulet/resource_pack/bedrock/blockshapes/slab.py +0 -33
  69. amulet/resource_pack/bedrock/blockshapes/slab_double.py +0 -15
  70. amulet/resource_pack/bedrock/blockshapes/tree.py +0 -41
  71. amulet/resource_pack/bedrock/blockshapes/turtle_egg.py +0 -15
  72. amulet/resource_pack/bedrock/blockshapes/vine.py +0 -52
  73. amulet/resource_pack/bedrock/blockshapes/wall.py +0 -22
  74. amulet/resource_pack/bedrock/blockshapes/water.py +0 -38
  75. amulet/resource_pack/bedrock/download_resources.py +0 -147
  76. amulet/resource_pack/bedrock/resource_pack.py +0 -40
  77. amulet/resource_pack/bedrock/resource_pack_manager.py +0 -361
  78. amulet/resource_pack/bedrock/sort_blockshapes.py +0 -15
  79. {amulet_core-2.0a7.dist-info → amulet_core-2.0a8.dist-info}/entry_points.txt +0 -0
  80. {amulet_core-2.0a7.dist-info → amulet_core-2.0a8.dist-info}/top_level.txt +0 -0
@@ -1,8 +1,8 @@
1
1
  from __future__ import annotations
2
2
  from typing import TYPE_CHECKING
3
3
 
4
- from .block_mesh import BlockMesh
5
- from .cube import get_unit_cube
4
+ from amulet.mesh.block import BlockMesh
5
+ from ._cube import get_unit_cube
6
6
 
7
7
  if TYPE_CHECKING:
8
8
  from amulet.resource_pack.abc import BaseResourcePackManager
@@ -0,0 +1,107 @@
1
+ #include <string>
2
+ #include <array>
3
+ #include <functional>
4
+ #include "block_mesh.hpp"
5
+
6
+ namespace Amulet {
7
+
8
+ const std::array<BlockMeshCullDirection, 4> roty_map = { BlockMeshCullNorth, BlockMeshCullEast, BlockMeshCullSouth, BlockMeshCullWest };
9
+
10
+ const RotationCullMapType RotationCullMap = []() {
11
+ RotationCullMapType cull_map;
12
+ for (std::int8_t roty = -3; roty < 4; roty++) {
13
+ // Create the rotated Y array
14
+ std::array<BlockMeshCullDirection, 4> roty_map_rotated;
15
+ auto split_y_point = 0 <= roty ? roty : roty + roty_map.size();
16
+ std::copy(roty_map.begin() + split_y_point, roty_map.end(), roty_map_rotated.begin());
17
+ std::copy(roty_map.begin(), roty_map.begin() + split_y_point, roty_map_rotated.end() - split_y_point);
18
+ // Create the X array
19
+ const std::array<BlockMeshCullDirection, 4> rotx_map = { roty_map_rotated[0], BlockMeshCullDown, roty_map_rotated[2], BlockMeshCullUp };
20
+
21
+ for (std::int8_t rotx = -3; rotx < 4; rotx++) {
22
+ // Create the rotated X array
23
+ std::array<BlockMeshCullDirection, 4> rotx_map_rotated;
24
+ auto split_x_point = 0 <= rotx ? rotx : rotx + rotx_map.size();
25
+ std::copy(rotx_map.begin() + split_x_point, rotx_map.end(), rotx_map_rotated.begin());
26
+ std::copy(rotx_map.begin(), rotx_map.begin() + split_x_point, rotx_map_rotated.end() - split_x_point);
27
+
28
+ cull_map[std::make_pair(roty, rotx)] = {
29
+ BlockMeshCullNone,
30
+ rotx_map_rotated[3],
31
+ rotx_map_rotated[1],
32
+ rotx_map_rotated[0],
33
+ roty_map_rotated[1],
34
+ rotx_map_rotated[2],
35
+ roty_map_rotated[3]
36
+ };
37
+ }
38
+ }
39
+ return cull_map;
40
+ }();
41
+
42
+ BlockMesh merge_block_meshes(std::vector<std::reference_wrapper<const BlockMesh>> meshes) {
43
+ BlockMesh new_mesh;
44
+ new_mesh.transparency = BlockMeshTransparency::Partial;
45
+ std::map<std::string, size_t> texture_index_map;
46
+ for (const auto& wrapper : meshes) {
47
+ const auto& temp_mesh = wrapper.get();
48
+ // Get the minimum transparency of the two meshes.
49
+ new_mesh.transparency = std::min(new_mesh.transparency, temp_mesh.transparency);
50
+
51
+ // Copy over mesh parts
52
+ for (std::uint8_t cull_direction = 0; cull_direction < 7; cull_direction++) {
53
+ const auto& temp_mesh_part = temp_mesh.parts[cull_direction];
54
+ if (temp_mesh_part) {
55
+ auto& new_mesh_part = new_mesh.parts[cull_direction];
56
+ if (!new_mesh_part) {
57
+ // Initialise the mesh part if it is null.
58
+ new_mesh_part = BlockMeshPart();
59
+ }
60
+ // Get the number of triangles before copying
61
+ size_t vert_count = new_mesh_part->verts.size();
62
+ size_t triangle_count = new_mesh_part->triangles.size();
63
+
64
+ auto& new_verts = new_mesh_part->verts;
65
+ auto& temp_verts = temp_mesh_part->verts;
66
+ auto& new_triangles = new_mesh_part->triangles;
67
+ auto& temp_triangles = temp_mesh_part->triangles;
68
+
69
+ // Copy over vertices
70
+ new_verts.insert(
71
+ new_verts.end(),
72
+ temp_verts.begin(),
73
+ temp_verts.end());
74
+ // Copy over triangles
75
+ new_triangles.insert(
76
+ new_triangles.end(),
77
+ temp_triangles.begin(),
78
+ temp_triangles.end());
79
+
80
+ for (size_t i = triangle_count; i < new_mesh_part->triangles.size(); i++) {
81
+ // Update the triangle indexes
82
+ auto& triangle = new_mesh_part->triangles[i];
83
+ triangle.vert_index_a += vert_count;
84
+ triangle.vert_index_b += vert_count;
85
+ triangle.vert_index_c += vert_count;
86
+ if (temp_mesh.textures.size() <= triangle.texture_index) {
87
+ throw std::invalid_argument("Texture index is higher than the number of textures.");
88
+ }
89
+ const auto& texture_path = temp_mesh.textures[triangle.texture_index];
90
+ auto it = texture_index_map.find(texture_path);
91
+ if (it == texture_index_map.end()) {
92
+ // Texture has not been added yet.
93
+ size_t texture_index = new_mesh.textures.size();
94
+ new_mesh.textures.push_back(texture_path);
95
+ triangle.texture_index = texture_index;
96
+ texture_index_map[texture_path] = texture_index;
97
+ } else {
98
+ triangle.texture_index = it->second;
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+ return new_mesh;
105
+ }
106
+
107
+ }
@@ -0,0 +1,207 @@
1
+ #pragma once
2
+ #include <array>
3
+ #include <cmath>
4
+ #include <map>
5
+ #include <numbers>
6
+ #include <optional>
7
+ #include <stdexcept>
8
+ #include <string>
9
+ #include <vector>
10
+ #include <functional>
11
+
12
+ namespace Amulet {
13
+
14
+ class FloatVec2 {
15
+ public:
16
+ float x;
17
+ float y;
18
+
19
+ FloatVec2(float x, float y)
20
+ : x(x)
21
+ , y(y)
22
+ {
23
+ }
24
+ };
25
+
26
+ class FloatVec3 {
27
+ public:
28
+ float x;
29
+ float y;
30
+ float z;
31
+
32
+ FloatVec3(float x, float y, float z)
33
+ : x(x)
34
+ , y(y)
35
+ , z(z)
36
+ {
37
+ }
38
+ };
39
+
40
+ class Vertex {
41
+ public:
42
+ // The world coordinate
43
+ FloatVec3 coord;
44
+ // The texture coordinate
45
+ FloatVec2 texture_coord;
46
+ // The tint colour
47
+ FloatVec3 tint;
48
+
49
+ Vertex(
50
+ const FloatVec3& coord,
51
+ const FloatVec2& texture_coord,
52
+ const FloatVec3& tint)
53
+ : coord(coord)
54
+ , texture_coord(texture_coord)
55
+ , tint(tint)
56
+ {
57
+ }
58
+ };
59
+
60
+ class Triangle {
61
+ public:
62
+ // The indicies of the vertexes in BlockMeshPart::verts.
63
+ size_t vert_index_a;
64
+ size_t vert_index_b;
65
+ size_t vert_index_c;
66
+ // The index of the texture in BlockMesh::textures.
67
+ size_t texture_index;
68
+
69
+ Triangle(
70
+ size_t vert_index_a,
71
+ size_t vert_index_b,
72
+ size_t vert_index_c,
73
+ size_t texture_index)
74
+ : vert_index_a(vert_index_a)
75
+ , vert_index_b(vert_index_b)
76
+ , vert_index_c(vert_index_c)
77
+ , texture_index(texture_index)
78
+ {
79
+ }
80
+ };
81
+
82
+ class BlockMeshPart {
83
+ public:
84
+ // The vertices in this mesh part.
85
+ std::vector<Vertex> verts;
86
+ // The triangles in this mesh part.
87
+ std::vector<Triangle> triangles;
88
+
89
+ BlockMeshPart(): verts(), triangles() {}
90
+ BlockMeshPart(
91
+ const std::vector<Vertex>& verts,
92
+ const std::vector<Triangle>& triangles)
93
+ : verts(verts)
94
+ , triangles(triangles)
95
+ {
96
+ }
97
+ };
98
+
99
+ enum class BlockMeshTransparency : std::uint8_t {
100
+ // The block is a full block with opaque textures
101
+ FullOpaque,
102
+ // The block is a full block with transparent / translucent textures
103
+ FullTranslucent,
104
+ // The block is not a full block
105
+ Partial
106
+ };
107
+
108
+ enum BlockMeshCullDirection {
109
+ BlockMeshCullNone,
110
+ BlockMeshCullUp,
111
+ BlockMeshCullDown,
112
+ BlockMeshCullNorth,
113
+ BlockMeshCullEast,
114
+ BlockMeshCullSouth,
115
+ BlockMeshCullWest
116
+ };
117
+
118
+ typedef std::map<
119
+ std::pair<std::int8_t, std::int8_t>,
120
+ std::array<BlockMeshCullDirection, 7>>
121
+ RotationCullMapType;
122
+
123
+ // For every combination of 90 degree rotations in y and x axis
124
+ // gives the rotated cull direction.
125
+ extern const RotationCullMapType RotationCullMap;
126
+
127
+ class BlockMesh {
128
+ public:
129
+ BlockMeshTransparency transparency;
130
+ std::vector<std::string> textures;
131
+ // The mesh parts. Index matches BlockMeshCullDirection.
132
+ std::array<std::optional<BlockMeshPart>, 7> parts;
133
+
134
+ BlockMesh()
135
+ : transparency()
136
+ , textures()
137
+ , parts()
138
+ {
139
+ }
140
+ BlockMesh(
141
+ BlockMeshTransparency transparency,
142
+ const std::vector<std::string>& textures,
143
+ const std::array<std::optional<BlockMeshPart>, 7>& parts)
144
+ : transparency(transparency)
145
+ , textures(textures)
146
+ , parts(parts)
147
+ {
148
+ }
149
+
150
+ BlockMesh rotate(std::int8_t rotx, std::int8_t roty) const
151
+ {
152
+ if (rotx || roty) {
153
+ auto rotation_key = std::make_pair(rotx, roty);
154
+ auto it = RotationCullMap.find(rotation_key);
155
+ if (it != RotationCullMap.end()) {
156
+ const auto& cull_map = it->second;
157
+ BlockMesh mesh;
158
+ mesh.transparency = transparency;
159
+ mesh.textures = textures;
160
+
161
+ // Compuate rotation values
162
+ float theta_x = std::numbers::pi * rotx / 2.0;
163
+ float theta_y = std::numbers::pi * roty / 2.0;
164
+ float sin_x = std::sin(theta_x);
165
+ float cos_x = std::cos(theta_x);
166
+ float sin_y = std::sin(theta_y);
167
+ float cos_y = std::cos(theta_y);
168
+
169
+ for (std::uint8_t cull_direction = 0; cull_direction < 7; cull_direction++) {
170
+ // Copy the part to the new cull direction.
171
+ auto new_cull_direction = cull_map[cull_direction];
172
+ auto& part = mesh.parts[new_cull_direction] = parts[cull_direction];
173
+
174
+ if (part) {
175
+ // Rotate the vertex coords.
176
+ for (auto& vertex : part->verts) {
177
+ auto& coord = vertex.coord;
178
+ float x = coord.x - 0.5;
179
+ float y = coord.y - 0.5;
180
+ float z = coord.z - 0.5;
181
+
182
+ // Rotate in X axis
183
+ float y_ = y * cos_x - z * sin_x;
184
+ z = y * sin_x + z * cos_x;
185
+ y = y_;
186
+
187
+ // Rotate in Y axis
188
+ float x_ = x * cos_y + z * sin_y;
189
+ z = -x * sin_y + z * cos_y;
190
+ x = x_;
191
+
192
+ coord.x = x + 0.5;
193
+ coord.y = y + 0.5;
194
+ coord.z = z + 0.5;
195
+ }
196
+ }
197
+ }
198
+ return mesh;
199
+ }
200
+ }
201
+ return *this;
202
+ }
203
+ };
204
+
205
+ BlockMesh merge_block_meshes(std::vector<std::reference_wrapper<const BlockMesh>>);
206
+
207
+ }
@@ -8,18 +8,19 @@ from amulet.resource_pack.java import (
8
8
  JavaResourcePack,
9
9
  JavaResourcePackManager,
10
10
  )
11
- from amulet.resource_pack.bedrock import (
12
- BedrockResourcePack,
13
- BedrockResourcePackManager,
14
- )
11
+
12
+ # from amulet.resource_pack.bedrock import (
13
+ # BedrockResourcePack,
14
+ # BedrockResourcePackManager,
15
+ # )
15
16
  from .unknown_resource_pack import UnknownResourcePack
16
17
 
17
18
 
18
19
  def load_resource_pack(resource_pack_path: str) -> BaseResourcePack:
19
20
  if JavaResourcePack.is_valid(resource_pack_path):
20
21
  return JavaResourcePack(resource_pack_path)
21
- elif BedrockResourcePack.is_valid(resource_pack_path):
22
- return BedrockResourcePack(resource_pack_path)
22
+ # elif BedrockResourcePack.is_valid(resource_pack_path):
23
+ # return BedrockResourcePack(resource_pack_path)
23
24
  else:
24
25
  return UnknownResourcePack(resource_pack_path)
25
26
 
@@ -48,15 +49,15 @@ def load_resource_pack_manager(
48
49
  [pack for pack in resource_packs if isinstance(pack, JavaResourcePack)],
49
50
  load,
50
51
  )
51
- elif isinstance(resource_packs[0], BedrockResourcePack):
52
- return BedrockResourcePackManager(
53
- [
54
- pack
55
- for pack in resource_packs
56
- if isinstance(pack, BedrockResourcePack)
57
- ],
58
- load,
59
- )
52
+ # elif isinstance(resource_packs[0], BedrockResourcePack):
53
+ # return BedrockResourcePackManager(
54
+ # [
55
+ # pack
56
+ # for pack in resource_packs
57
+ # if isinstance(pack, BedrockResourcePack)
58
+ # ],
59
+ # load,
60
+ # )
60
61
 
61
62
  raise NotImplementedError
62
63
  # return UnknownResourcePackManager()
@@ -1,12 +1,10 @@
1
1
  from typing import Optional, Iterator, TypeVar, Generic
2
2
  import json
3
- import copy
4
3
 
5
4
  from amulet.block import Block, BlockStack
6
- from amulet.mesh.block import BlockMesh
5
+ from amulet.mesh.block import BlockMesh, merge_block_meshes, get_missing_block
7
6
  from amulet.resource_pack.abc.resource_pack import BaseResourcePack
8
7
  from amulet.img import missing_no_icon_path
9
- from amulet.mesh.block.missing_block import get_missing_block
10
8
 
11
9
  PackT = TypeVar("PackT", bound=BaseResourcePack)
12
10
 
@@ -74,14 +72,14 @@ class BaseResourcePackManager(Generic[PackT]):
74
72
  block_stack.base_block
75
73
  )
76
74
  else:
77
- self._cached_models[block_stack] = BlockMesh.merge(
75
+ self._cached_models[block_stack] = merge_block_meshes(
78
76
  (self._get_model(block_stack.base_block),)
79
77
  + tuple(
80
78
  self._get_model(block_) for block_ in block_stack.extra_blocks
81
79
  )
82
80
  )
83
81
 
84
- return copy.deepcopy(self._cached_models[block_stack])
82
+ return self._cached_models[block_stack]
85
83
 
86
84
  def _get_model(self, block: Block) -> BlockMesh:
87
85
  raise NotImplementedError