你是否曾想过,当箱子打开时,物品为什么不会掉进去?
……好吧,我承认,我之前也没这么想过,直到我有了这个想法。但仔细想想……
这很合理,对吧?
现在,你可以自豪地说:“箱子就是箱子”!并享受让物品自动落入储物箱中, 而不是笨拙地手动一个个放入的乐趣!
不过,既然物品可以掉落进一个打开的箱子…… 那么如果箱子在正确的侧面是打开的,它们是否也应该能从箱子里掉出来呢? 因此,你可以设置成:当木桶打开且朝向下方时,将其所有内容物都掉落到地面上!
回到箱子,如果你能打开盖子让物品掉进去,那么打开盖子时,盖子是否应该把站在上面的物品甩出去呢? 没错!使用这个模组,你可以实现:打开箱子时,将所有放置在箱子上的物品甩飞出去! (仅限物品,为了大家的生命安全着想)
最后但同样重要的是,由于到目前为止,打开容器始终是一项手动操作, 为了让你能够自动化这些新功能,现在可以通过激活指向该容器的空发射器来打开容器!
现在游戏会感觉更自然一些了,哪怕只是一点点,你不觉得吗?
功能
- 将物品插入打开的容器中
- 默认:启用
- 玩家规则:
chests.insertOpen
- 使物品从底部打开的容器中掉落
- 默认:禁用
- 玩家规则:
chests.barrelFall - 特殊物品掉落行为(例如雪球作为投掷出的实际雪球掉落)
- 默认:启用
- 玩家规则:
chests.barrelFall.throwableSpecial - 物品标签:
#chests_are_chests:special_fall
- 使箱盖甩出物品
- 默认:禁用
- 玩家规则:
chests.lidFling - 实体类型标签:
#chests_are_chests:flingable - 水平甩出速度
- 默认:0.25
- 玩家规则:
chests.lidFling.horizontalPower
- 垂直甩出速度
- 默认:0.6
- 玩家规则:
chests.lidFling.verticalPower
- 通过充能空发射器来打开容器
- 默认:启用
- 玩家规则:
chests.dispenserOpen - 自动化打开持续时间(以世界刻为单位)
- 默认:10
- 玩家规则:
chests.dispenserOpen.duration
依赖
模组兼容性
内部兼容性
虽然计划了兼容性支持,但由模组自身直接实现始终是被优先推荐的。 因此,如果你的模组已列入计划、正在开发中或甚至已经实现, 请毫不犹豫地自行实现,如有需要,我们可以提供帮助,或者告知我们无需再维护我们自己的兼容性代码。
已实现
- Anner's Iron Chests
- Mythic Metals Decorations
- Reinforced Chests
- Expanded Storage
- Spectrum
原生兼容
已知(应)与该模组具有原生兼容性、无需额外实现的模组
正在开发中
计划中
- myLoot
- More Chests
- Compact Storage
内部拒绝
- Iron Chests: Restocked 由于模组作者名称注册不佳,该模组难以处理。 因此,决定不再尝试实现内置兼容性。
自行实现
容器实现
该模组调整了方块实体和物品实体的行为。
为了实现与此模组的兼容性,你的自定义方块实体需要实现
mc.recraftors.chestsarechests.util.FallInContainer 接口。
你也可以使用其他接口,例如 mc.recraftors.chestsarechests.util.BlockOpenableContainer
或 mc.recraftors.chestsarechests.util.BooleanHolder,你可以随意使用它们,
或者如果你已经扩展了原版箱子或木桶类,可以利用它们。
不要犹豫去查看 箱子 和木桶 的实现,以参考如何在提供的方法中处理方块打开和方向。
也不要担心未来更新会增加更多方法而你的模组未实现从而导致问题。 没有计划删除任何方法,也不会改变主版本号。所有新方法都会始终附带默认实现,以避免无意义的问题。
物品实现
该模组允许某些物品(注册在相应的物品标签中)在从容器“掉落”时具有自定义行为。为此,物品本身必须实现
mc.recraftors.chestsarechests.util.ContainerItemHelper 接口。
该接口包含两个要实现的方法。第一个方法是可选的,用于指示物品的掉落方向。 这允许指定物品可以从容器的哪个打开侧出来。(例如,受向上重力影响的物品可以指定向上的掉落方向)
默认情况下,此第一个方法将返回 DOWN。
第二种方法用于实现特殊的掉落行为。它应使用第一种方法来判断是否执行,并执行相应的逻辑。该方法的返回值表示物品堆叠是否掉落(理论上被消耗)或未掉落;因此,不应再尝试使其向同一方向掉落,以避免增加运行时计算压力。
不妨参考 箭 或 雪球 的实现,以了解如何处理特殊物品的掉落。
此外,无需担心更新后会新增更多方法,因为所有新方法在可能的情况下都会包含基于已有方法的默认实现。
示例
更新至 0.5 版本
容器实现
public class MyCustomBlockEntity extends BlockEntity implements FallInContainer {
private boolean isOpen;
private final int size;
private final DefaultedList<ItemStack> content;
private final Map<Integer, Integer> fallUpdateMap = new HashMap<>();
@Override
public boolean chests$tryInsertion(ItemEntity entity) {
return FallInContainer.chests$inventoryInsertion(this.content, entity, this::setStack);
}
@Override
public boolean chests$isOpen() {
return isOpen;
}
@Override
public VoxelShape chests$InputAreaShape() {
return FallInContainer.ABOVE;
}
@Override
public void chests$forceOpen(ServerWorld world, BlockPos at, BlockState from) {
this.isOpen = true;
this.onOpen();
}
@Override
public boolean chests$tryForceOpen(BlockState from) {
ServerWorld serverWorld = (ServerWorld) this.getWorld();
BlockPos blockPos = this.getPos();
this.chests$forceOpen(serverWorld, blockPos, from);
ChestsAreChests.scheduleTick(serverWorld, blockPos, duration);
}
@Override
public boolean chests$forceClose() {
this.isOpen = false;
this.onClose();
}
@Override
public Map<Integer, Integer> getFallUpdateMap() {
return this.fallUpdateMap;
}
void onOpen() {
// ...
// 潜在的渲染相关代码
ChestsAreChests.ejectAbove(Direction.UP, this);
}
}
物品实现
public class MyCustomItem extends Item implements ContainerItemHelper {
public Direction[] chests$getFallDirection(ItemStack stack) {
return new Direction[]{Directions.UP};
}
public boolean defaultOnOpenTick(ItemStack stack, FallInContainer container, Direction direction, World world, Vec3d pos, Vec3d velocity) {
if (!ChestsAreChests.isInArray(direction, chests$getFallDirection(stack))) return false;
MyGravitatedEntity entity = new MyGravitatedEntity(world, pos.x, pos.y, pos.z, stack.copy());
entity.setVelocity(velocity);
world.spawnEntity(entity);
return true;
}
}
展示
Ever wondered why, when a chest is open, items don't fall in?
... Okay, I'll admit, me neither, not until I had this idea. But when you think of it...
It just makes sense, right?
So now, you can proudly say that Chests are chests! And enjoy making items fall into your storage instead of lamely putting them in by hand!
But as items can fall into an open box... Shouldn't they be able to fall down from one as well, provided it was open on the right side? Thus, you can make it so barrels, when open and facing down, drop all of their content to the ground!
Going back to the chest, if you can open the lid to make items fall in, shouldn't the lid throw items away upon being opened? That's right! With this mod, you can make it so opening a chest throws all the items standing on it upon opening! (Limited to items only for the sake of one's life preservation)
Last but not least, since opening a container has always only been a manual task so far, in order to allow you to automate these new options, opening a container can now be done by activating an empty dispenser pointing at said container!
Now the game will feel more natural, even just a little bit, won't you agree?
Features
- Inserting items in open containers
- default: enabled
- gamerule:
chests.insertOpen
- Making item fall from open-from-below containers
- default: disabled
- gamerule:
chests.barrelFall - Special item fall (e.g. snowballs falling as actual thrown snowballs)
- default: enabled
- gamerule:
chests.barrelFall.throwableSpecial - item tag:
#chests_are_chests:special_fall
- Making chest lids throw items
- default: disabled
- gamerule:
chests.lidFling - entity type tag:
#chests_are_chests:flingable - Horizontal flinging velocity
- default: 0.25
- gamerule:
chests.lidFling.horizontalPower
- Vertical flinging velocity
- default: 0.6
- gamerule:
chests.lidFling.verticalPower
- Opening containers by powering empty dispensers
- default: enabled
- gamerule:
chests.dispenserOpen - Automated opening duration (in world ticks)
- default: 10
- gamerule:
chests.dispenserOpen.duration
Dependencies
Mod compatibilities
Internal compatibilities
While compatibilities are planned, direct implementation by the mods themselves would always be preferred. Hence, if a mod of yours is planned, being worked on, or even already implemented, don't hesitate to make your own, and if need be, contact us either for help or to tell us that we have no need to keep our own compatibility.
Implemented
- Anner's Iron Chests
- Mythic Metals Decorations
- Reinforced Chests
- Expanded Storage
- Spectrum
Natural
Known mods that (should) have natural compatibility with this mod, with no extra implementation
Being worked on
Planned
- myLoot
- More Chests
- Compact Storage
Internally refused
- Iron Chests: Restocked Due to mod author names poorly registered, this mod cannot be easily be dealt with. Hence, it has been decided no to attempt implementing builtin compatibility.
Make your own
Container implementation
The mod tweaks the block entities' and item entities' behaviours.
In order to implement compatibility with this mod, you need your custom block entity to implement
the mc.recraftors.chestsarechests.util.FallInContainer interface.
You may as well make use of other interfaces, such as mc.recraftors.chestsarechests.util.BlockOpenableContainer
or mc.recraftors.chestsarechests.util.BooleanHolder, which you can either use as you please, or can exploit
if you already extend the vanilla chest or barrel classes.
Don't hesitate to look at the chest and barrel implementations for a reference of how to handle block opening and orientation within the provided methods.
Also don't fear about more methods appearing with updates and your mod not implementing them, causing issues. No methods are planned for deletion, or would include a change of primary version. And all new method will always come with a default implementation, to avoid pointless issues.
Item implementation
The mod enables for some item (registered in the appropriate item tag) to have a custom behaviour upon "falling"
from a container. In order to do that, the item itself must implement the
mc.recraftors.chestsarechests.util.ContainerItemHelper interface.
This interface comes up with two methods to be implemented. The first one, optional, indicates the item fall directions. This allows to specify on which open side of a container can the item come out. (e.g. upwards-gravitated items may specify an upward fall direction)
By default, this first method will return DOWN.
The second one makes the actual implementation of a special fall behaviour. It should use the first method to know whether to run it or not, and execute what is intended. This method's return value indicates whether the item stack fell (and theoretically is consumed), or not, and therefore shouldn't be bothered with attempting to make it fall in the same direction, to avoid causing more runtime computing stress.
Don't hesitate to look at the arrow or snowball implementations for a reference of how to handle special item fall.
Then again, don't fear about more methods appearing with updates, for all new one will then again include a default implementation, if possible based on already existing methods.
Examples
Up to date with version 0.5
Container implementation
public class MyCustomBlockEntity extends BlockEntity implements FallInContainer {
private boolean isOpen;
private final int size;
private final DefaultedList<ItemStack> content;
private final Map<Integer, Integer> fallUpdateMap = new HashMap<>();
@Override
public boolean chests$tryInsertion(ItemEntity entity) {
return FallInContainer.chests$inventoryInsertion(this.content, entity, this::setStack);
}
@Override
public boolean chests$isOpen() {
return isOpen;
}
@Override
public VoxelShape chests$InputAreaShape() {
return FallInContainer.ABOVE;
}
@Override
public void chests$forceOpen(ServerWorld world, BlockPos at, BlockState from) {
this.isOpen = true;
this.onOpen();
}
@Override
public boolean chests$tryForceOpen(BlockState from) {
ServerWorld serverWorld = (ServerWorld) this.getWorld();
BlockPos blockPos = this.getPos();
this.chests$forceOpen(serverWorld, blockPos, from);
ChestsAreChests.scheduleTick(serverWorld, blockPos, duration);
}
@Override
public boolean chests$forceClose() {
this.isOpen = false;
this.onClose();
}
@Override
public Map<Integer, Integer> getFallUpdateMap() {
return this.fallUpdateMap;
}
void onOpen() {
// ...
// potential rendering stuff
ChestsAreChests.ejectAbove(Direction.UP, this);
}
}
Item implementation
public class MyCustomItem extends Item implements ContainerItemHelper {
public Direction[] chests$getFallDirection(ItemStack stack) {
return new Direction[]{Directions.UP};
}
public boolean defaultOnOpenTick(ItemStack stack, FallInContainer container, Direction direction, World world, Vec3d pos, Vec3d velocity) {
if (!ChestsAreChests.isInArray(direction, chests$getFallDirection(stack))) return false;
MyGravitatedEntity entity = new MyGravitatedEntity(world, pos.x, pos.y, pos.z, stack.copy());
entity.setVelocity(velocity);
world.spawnEntity(entity);
return true;
}
}
Showcase
下载 Chests are Chests
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Chests are Chests
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Chests are Chests
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Chests are Chests
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Chests are Chests
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Chests are Chests
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Chests are Chests
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Chests are Chests
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Chests are Chests
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Chests are Chests
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
适用于 Fabric 1.20 的 0.10 版本
- 添加了可配置的物品掉落扩散范围
- 修复了自动开合导致的掉落问题
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
AE2:一款流行的自动化与存储模组
模组
那是什么?一个 Waila/Hwyla 的分支。

评论 0
登录后参与评分
还没有评论,来抢沙发吧