diff --git a/gradle.properties b/gradle.properties index 3ed167f..3704c59 100644 --- a/gradle.properties +++ b/gradle.properties @@ -33,7 +33,7 @@ mod_name=3944Realms 's Lib Mod # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=MIT # The mod version. See https://semver.org/ -mod_version=0.1.8 +mod_version=0.1.9 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/top/r3944realms/lib39/datagen/provider/SubProvidersWrapper.java b/src/main/java/top/r3944realms/lib39/datagen/provider/SubProvidersWrapper.java index d32fe75..43ff20d 100644 --- a/src/main/java/top/r3944realms/lib39/datagen/provider/SubProvidersWrapper.java +++ b/src/main/java/top/r3944realms/lib39/datagen/provider/SubProvidersWrapper.java @@ -1,6 +1,8 @@ package top.r3944realms.lib39.datagen.provider; import net.minecraft.data.loot.LootTableProvider; +import net.minecraft.data.loot.LootTableSubProvider; +import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import top.r3944realms.lib39.datagen.provider.subprovider.BlockLootTables; @@ -32,6 +34,18 @@ public class SubProvidersWrapper { return this; } + /** + * Add entry sub providers wrapper. + * + * @param subProvider the sub provider + * @param subParamSet the sub param set + * @return the sub providers wrapper + */ + public SubProvidersWrapper addEntry(LootTableSubProvider subProvider, LootContextParamSet subParamSet) { + entries.add(new LootTableProvider.SubProviderEntry(() -> subProvider, subParamSet)); + return this; + } + /** * Add block entry sub providers wrapper. * diff --git a/src/main/java/top/r3944realms/lib39/util/shape/ShapeUtil.java b/src/main/java/top/r3944realms/lib39/util/shape/ShapeUtil.java index 6531549..3b303de 100644 --- a/src/main/java/top/r3944realms/lib39/util/shape/ShapeUtil.java +++ b/src/main/java/top/r3944realms/lib39/util/shape/ShapeUtil.java @@ -62,6 +62,28 @@ public class ShapeUtil { return createRotatedDirectionMap(shape); } + /** + * 创建支持全方向的形状映射(包括上下) + * + * @param shape 基础形状(默认为NORTH方向) + * @return 全方向形状映射 + */ + public static @NotNull Map createFullDirectionMap(VoxelShape shape) { + EnumMap directionMap = new EnumMap<>(Direction.class); + + // 水平方向 + directionMap.put(Direction.NORTH, shape); + directionMap.put(Direction.EAST, rotateShape(shape, 90)); + directionMap.put(Direction.SOUTH, rotateShape(shape, 180)); + directionMap.put(Direction.WEST, rotateShape(shape, 270)); + + // 垂直方向 + directionMap.put(Direction.UP, rotateShapeToUp(shape)); + directionMap.put(Direction.DOWN, rotateShapeToDown(shape)); + + return directionMap; + } + /** * 创建原版双方块的形状映射 * @@ -100,12 +122,7 @@ public class ShapeUtil { * @return the voxel shape */ public static @NotNull VoxelShape rotateVoxelShapeXAxis(@NotNull VoxelShape shape) { - final List generatedShapes = new ArrayList<>(); - shape.forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> { - VoxelShape rotated = Shapes.box(minX, 1.0 - maxZ, minY, maxX, 1.0 - minZ, maxY); - generatedShapes.add(rotated); - }); - return combineShapes(generatedShapes); + return rotateShapeToUp(shape); } /** @@ -140,6 +157,35 @@ public class ShapeUtil { } return result; } + /** + * 将形状旋转到向上方向(绕X轴-90度) + * + * @param shape the shape + * @return the voxel shape + */ + public static @NotNull VoxelShape rotateShapeToUp(@NotNull VoxelShape shape) { + final List generatedShapes = new ArrayList<>(); + shape.forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> { + VoxelShape rotated = Shapes.box(minX, 1.0 - maxZ, minY, maxX, 1.0 - minZ, maxY); + generatedShapes.add(rotated); + }); + return combineShapes(generatedShapes); + } + + /** + * 将形状旋转到向下方向(绕X轴90度) + * + * @param shape the shape + * @return the voxel shape + */ + public static @NotNull VoxelShape rotateShapeToDown(@NotNull VoxelShape shape) { + final List generatedShapes = new ArrayList<>(); + shape.forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> { + VoxelShape rotated = Shapes.box(minX, minZ, minY, maxX, maxZ, maxY); + generatedShapes.add(rotated); + }); + return combineShapes(generatedShapes); + } // ==================== 形状组合与优化 ====================