通过单一界面轻松且方便地调整方块大小和旋转(包括其方块实体渲染器和碰撞箱)。
这是一个适用于 Minecraft Forge 1.20.1 的库模组。让你的 Block 实现 IScalableBlock 和/或 IRotatableBlock,它便会自动获得缩放/旋转模型渲染、BER 渲染以及 VoxelShape 碰撞检测,无需为每个方块单独注册 mixin。
特性
- 一个接口,全部缩放:实现
IScalableBlock,返回 SBSProp 配置即可。
- 一个接口,全部旋转:实现
IRotatableBlock,返回 SBSRProp 配置,方块可围绕任意轴以任意角度旋转。
- 方块模型渲染:在模型烘焙时通过
BakedModel 代理转换 BakedQuad 顶点,确保与 Embeddium 和 Oculus 等渲染替换器的兼容性。
- 方块实体渲染:BER(箱子、告示牌等)通过向
BlockEntityRenderDispatcher 注入 Mixin,随父方块一起缩放和旋转。
- 碰撞箱缩放与平移:启用
scaleShape 时自动转换 VoxelShape;智能平移以匹配旋转后的模型中心。
- 复合变换:方块可实现两个接口——先应用旋转,再应用缩放。
- 可配置的枢轴点:可在方块内的任意锚点进行缩放和旋转。
- 零配置:无需 mixin 配置、JSON 或数据生成。纯 API。
用法
public class MyBlock extends Block implements IScalableBlock, IRotatableBlock {
@Override
public SBSProp getScaleConfig(BlockState state) {
// 围绕方块中心缩放至 50%,包括碰撞箱
return new SBSProp(0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, true);
}
@Override
public SBSRProp getRotationConfig(BlockState state) {
// 围绕 Y 轴旋转 45°,以方块为中心
return new SBSRProp(45f, Direction.Axis.Y, 0.5f, 0.5f, 0.5f);
}
@Override
public VoxelShape getShape(BlockState state,
BlockGetter level,
BlockPos pos,
CollisionContext ctx) {
VoxelShape rotatedShape = getTranslatedShape(state, level, pos, ctx,
super.getShape(state, level, pos, ctx));
return getScaledShape(state, level, pos, ctx, rotatedShape);
}
}
SBSProp 参数
| 字段 |
描述 |
scaleX / Y / Z |
各轴的缩放倍数(1.0 = 原始大小) |
pivotX / Y / Z |
方块坐标系中的锚点(0~1,0.5 = 中心) |
scaleShape |
是否同时缩放碰撞 VoxelShape |
SBSRProp 参数
| 字段 |
描述 |
degree |
旋转角度(度) |
axis |
旋转轴(Direction.Axis.X / Y / Z) |
pivotX / Y / Z |
方块坐标系中的锚点(0~1,0.5 = 中心) |
兼容性
本模组旨在与 Embeddium 和 Oculus 兼容。如发现任何不兼容问题,欢迎反馈。
反馈
如果您有问题或 PR 要提交,请先将问题的简要描述发送至 3485874663@qq.com,您将收到重定向至 Gitea 网站的用户名和密码。您可以在那里继续提交您的 issue 或 PR。
Easily and conveniently resize and rotate blocks (including their block entity renderers and collision boxes) with a single interface.
This is a library mod for Minecraft Forge 1.20.1. Have your Block implement IScalableBlock and/or IRotatableBlock, and it automatically gets scaled/rotated model rendering, BER rendering, and VoxelShape collision, no per-block mixin registration required.
Features
- One interface, everything scaled: implement
IScalableBlock, return an SBSProp config, done.
- One interface, everything rotated: implement
IRotatableBlock, return an SBSRProp config, and blocks rotate around any axis at any angle.
- Block model rendering: BakedQuad vertices transformed via
BakedModel proxy at model bake time, ensuring compatibility with rendering replacers like Embeddium & Oculus.
- Block entity rendering: BERs (chests, signs, etc.) scale and rotate together with their parent block via Mixin injection into
BlockEntityRenderDispatcher.
- Collision box scaling & translation: VoxelShape automatically transformed when
scaleShape is enabled; intelligently translated to match rotated model center.
- Compound transforms: blocks can implement both interfaces — rotation is applied first, then scaling.
- Configurable pivot: scale and rotate around any anchor point within the block.
- Zero configuration: no mixin config, no JSON, no data-gen. Pure API.
Usage
public class MyBlock extends Block implements IScalableBlock, IRotatableBlock {
@Override
public SBSProp getScaleConfig(BlockState state) {
// Scale to 50% around the block center, including collision
return new SBSProp(0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, true);
}
@Override
public SBSRProp getRotationConfig(BlockState state) {
// Rotate 45° around Y axis, centered on the block
return new SBSRProp(45f, Direction.Axis.Y, 0.5f, 0.5f, 0.5f);
}
@Override
public VoxelShape getShape(BlockState state,
BlockGetter level,
BlockPos pos,
CollisionContext ctx) {
VoxelShape rotatedShape = getTranslatedShape(state, level, pos, ctx,
super.getShape(state, level, pos, ctx));
return getScaledShape(state, level, pos, ctx, rotatedShape);
}
}
SBSProp Parameters
| Field |
Description |
scaleX / Y / Z |
Scale multiplier per axis (1.0 = original) |
pivotX / Y / Z |
Anchor point in block coordinates (0~1, 0.5 = center) |
scaleShape |
Whether to also scale the collision VoxelShape |
SBSRProp Parameters
| Field |
Description |
degree |
Rotation angle in degrees |
axis |
Rotation axis (Direction.Axis.X / Y / Z) |
pivotX / Y / Z |
Anchor point in block coordinates (0~1, 0.5 = center) |
Compatible
This mod is designed to be compatible with Embeddium & Oculus. Any incompatibility is welcome to feedback.
Feedback
If you have issues/pr to submit, please first send a brief description about the issue to 3485874663@qq.com, you will be redirected to a gitea website with username & password. You can continue your issues/pr there.
评论 0
登录后参与评分
还没有评论,来抢沙发吧