MECHA - Multiple Entity Collision Hitboxes API 图标

MECHA - Multiple Entity Collision Hitboxes API

作者:rebot | 分类:模组

价格:0 墨喵币 下载量:0 点赞:0 版本 0.1.2
本资源为搬运资源,原资源地址: https://modrinth.com/mod/mecha-api
资源信息

Minecraft 版本: 1.19.4 1.20 1.20.1 1.20.2 1.20.3 1.20.4 1.20.5 1.20.6 1.21 1.21.1

平台: fabric

标签: game-mechanics library utility

资源介绍

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() { ... }
}
下载太慢?试试 墨喵加速站,支持 Modrinth 和外网直链高速下载! 用的人越多,下载的越快!
下载与版本
评论(0)
登录 后发表评论。

暂无评论,抢个沙发吧~

举报此资源

请登录后举报

🔥 相关推荐
Ore Regeneration

价格:0 墨喵币
下载量:0

查看详情
DrSounds

价格:0 墨喵币
下载量:0

查看详情
Simply Perfected

价格:0 墨喵币
下载量:0

查看详情
HealthXP

价格:0 墨喵币
下载量:0

查看详情