2022-12-19 16:03:35 +01:00
|
|
|
package com.minelittlepony.unicopia;
|
|
|
|
|
|
|
|
import net.minecraft.entity.Entity;
|
2022-12-19 18:13:15 +01:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.math.Vec3d;
|
2022-12-19 19:50:15 +01:00
|
|
|
import net.minecraft.world.World;
|
2022-12-19 16:03:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for things that can be owned by an entity.
|
|
|
|
* <p>
|
|
|
|
* Ownership is retained so long as the owner is still active. If the owner leaves or dies, the link is broken.
|
|
|
|
*
|
|
|
|
* @param <E> The type of object that owns us.
|
|
|
|
*/
|
2022-12-19 19:50:15 +01:00
|
|
|
public interface EntityConvertable<E extends Entity> extends WorldConvertable {
|
2022-12-19 16:03:35 +01:00
|
|
|
E asEntity();
|
2022-12-19 18:13:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the center position where this caster is located.
|
|
|
|
*/
|
|
|
|
default BlockPos getOrigin() {
|
|
|
|
return asEntity().getBlockPos();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Gets the center position where this caster is located.
|
|
|
|
*/
|
|
|
|
default Vec3d getOriginVector() {
|
|
|
|
return asEntity().getPos();
|
|
|
|
}
|
2022-12-19 19:50:15 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
default World asWorld() {
|
2023-06-03 13:40:54 +02:00
|
|
|
return asEntity().getWorld();
|
2022-12-19 19:50:15 +01:00
|
|
|
}
|
2022-12-19 16:03:35 +01:00
|
|
|
}
|