Example usage for net.minecraftforge.event.world GetCollisionBoxesEvent getEntity

List of usage examples for net.minecraftforge.event.world GetCollisionBoxesEvent getEntity

Introduction

In this page you can find the example usage for net.minecraftforge.event.world GetCollisionBoxesEvent getEntity.

Prototype

public Entity getEntity() 

Source Link

Usage

From source file:de.sanandrew.mods.turretmod.client.event.CollisionEventHandler.java

License:Creative Commons License

@SubscribeEvent
public void onCollision(GetCollisionBoxesEvent event) {
    Entity entityIn = event.getEntity();
    AxisAlignedBB aabb = event.getAabb();

    if (entityIn instanceof EntityPlayer) {
        List<EntityTurret> turrets = entityIn.world.getEntitiesWithinAABB(EntityTurret.class, aabb.grow(0.25D));
        for (EntityTurret turret : turrets) {
            if (!entityIn.isRidingSameEntity(turret)) {
                AxisAlignedBB entityBB = turret.getEntityBoundingBox();

                if (entityBB.intersects(aabb)) {
                    event.getCollisionBoxesList().add(entityBB);
                }/*w  w  w .j av  a 2s  .c o m*/
            }
        }
    }
}

From source file:jayavery.geomastery.main.EntityEvents.java

License:Open Source License

/** Allows falling trunks to pass through leaves. */
@SubscribeEvent//ww  w .  j  a v  a2  s.com
public void getCollisionBoxes(GetCollisionBoxesEvent event) {

    if (event.getEntity() instanceof FallingTreeBlock.Trunk) {

        ((FallingTreeBlock.Trunk) event.getEntity()).getCollisionBoxes(event.getWorld(), event.getAabb(),
                event.getCollisionBoxesList());
    }
}