All Mods Resource Packs Data Packs Shaders Modpacks Plugins
MECHA - Multiple Entity Collision Hitboxes API

MECHA - Multiple Entity Collision Hitboxes API

by byteManiak • Downloads: 0 • Followers: 0
Description
Gallery
Changelog
Versions

A simple API for enabling custom entities to implement more than one collision box.

Setup

Add the Modrinth Maven and the right version of the mod to your build.gradle file:

repositories {
    maven { url 'https://api.modrinth.com/maven' }
}

dependencies {
    modImplementation "maven.modrinth:mecha-api:VERSION_GOES_HERE"
}

Usage

Implement MultiCollidable in your custom entity class, and override getColliders to add extra colliders to the entity.

Example

The following example code adds 2 colliders to an entity, each the size of a slab:

public CustomEntity extends Entity implements MultiCollidable {
    public List<VoxelShape> getColliders() {
        List<VoxelShape> colliders = new ArrayList<>();
        BlockPos pos = this.blockPos();
        double x = pos.getX();
        double y = pos.getY();
        double z = pos.getZ();
        colliders.add(VoxelShapes.cuboid(x, y, z, x+1, y+0.5, z+1));
        colliders.add(VoxelShapes.cuboid(x, y+0.5, z, x+1, y+1, z+1));
        return colliders;
    }
}

For 0.1.2 and newer, there is now also a custom entity type, DynamicBoundingBoxEntity, which has a dynamic bounding box based on the list returned by getColliders():

public CustomEntity extends DynamicBoundingBoxEntity {
    // The bounding box of this entity will dynamically resize
    // to fit the colliders returned by this function
    @Override
    public List<VoxelShape> getColliders() { ... }
}

How to Install MECHA - Multiple Entity Collision Hitboxes API (Mod)

MECHA - Multiple Entity Collision Hitboxes API by byteManiak is verified for Fabric across Minecraft versions 1.19.4, 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6 (latest release: 0.1.2, file size: 12 KB). Follow the steps below to install it safely from ModCraft.tv:

  1. Click the Download button above and select your Minecraft version (1.19.4, 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6) and platform (Fabric).
  2. Make sure you have the compatible loader or environment installed for Fabric.
  3. Move the downloaded MECHA - Multiple Entity Collision Hitboxes API file into your Minecraft .minecraft/mods folder and launch the game.

All Versions

+ Add Version
Name Game version Platforms Published Downloads Actions
1.21.x 1.20.x 1.19.4
Fabric
last yr. 1
1.20.x
Fabric
last yr. 1
1.19.4
Fabric
last yr. 1
1.20.x
Fabric
last yr. 1
1.19.4
Fabric
last yr. 1
Added DynamicBoundingBoxEntity used together with getColliders() to create an entity with a dynamically resizing bounding box
Fix collisions only working on singleplayer worlds.
Fix collisions only working in singleplayer worlds.
Initial 1.20.x version
Initial version.
Expose interface MultiCollidable that entities can implement.
MECHA - Multiple Entity Collision Hitboxes API Icon
Download MECHA - Multiple Entity Collision Hitboxes API
Select game version
Select platform