Download Chests are Chests — Minecraft Mods — MetaMods

Chests are Chests

Active

Downloads

20

Last update

1 year ago

Versions

1.19 — 1.20.4
Server
Fabric
Forge
Liteloader
Neoforge
Quilt
Game mechanics
Storage
Utils

Chests are Chests

Have you ever wondered why items don't fall into an open chest? Admittedly, most of us never thought about it until this mod came along. But when you think about it - it makes perfect sense!

Now chests truly behave like real containers! Instead of manually placing items, you can simply throw them into open storage - they'll fall right in.

And if items can fall into containers, why shouldn't they fall out of them? With this mod, barrels opened from below will spill all their contents onto the ground!

That's not all! When you open a chest, its lid can fling items resting on top. Of course, for safety reasons, this only works with items, not living entities.

To automate these processes, the mod allows opening containers using dispensers. Simply point an empty dispenser at a chest or barrel and activate it!

Main Features

Items falling into open containers

  • Default: enabled
  • Game rule: chests.insertOpen

Items falling from containers opened from below

  • Default: disabled
  • Game rule: chests.barrelFall
  • Special behavior for certain items (e.g., snowballs fall as thrown projectiles)
  • Game rule: chests.barrelFall.throwableSpecial
  • Item tag: #chests_are_chests:special_fall

Chest lids flinging items

  • Default: disabled
  • Game rule: chests.lidFling
  • Entity type tag: #chests_are_chests:flingable
  • Horizontal flinging velocity: chests.lidFling.horizontalPower
  • Vertical flinging velocity: chests.lidFling.verticalPower

Opening containers with dispensers

  • Default: enabled
  • Game rule: chests.dispenserOpen
  • Automated opening duration (in ticks): chests.dispenserOpen.duration

Compatibility with Other Mods

The mod already supports integration with the following addons:

  • Anner's Iron Chests
  • Mythic Metals Decorations
  • Reinforced Chests
  • Expanded Storage
  • Spectrum

Natural compatibility exists with mods like Variant Chests, Variant Barrels, Chest Colorizer, and others that change chest appearances.

For Developers

If you're creating your own mods with containers, you can easily add support for Chests are Chests. Just implement a few interfaces in your code.

Container implementation example:

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 example:

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;
    }
}

Video Showcase

Project members
Nerjal_Nosk

Nerjal_Nosk

Developer

RecraftorsMC

RecraftorsMC

Developer

Created: 30 Nov 2023

ID: 8258