Search in sources :

Example 1 with EntityTrackerEntryHandle

use of com.bergerkiller.generated.net.minecraft.server.EntityTrackerEntryHandle in project BKCommonLib by bergerhealer.

the class EntityTrackerHook method updateTrackers.

private void updateTrackers(List<?> list) {
    EntityHandle entityHandle = EntityHandle.createHandle(controller.getEntity().getHandle());
    EntityTrackerEntryHandle handle = EntityTrackerEntryHandle.createHandle(instance());
    if (handle.isSynched()) {
        double lastSyncX = handle.getPrevX();
        double lastSyncY = handle.getPrevY();
        double lastSyncZ = handle.getPrevZ();
        double distance = entityHandle.calculateDistance(lastSyncX, lastSyncY, lastSyncZ);
        if (distance <= 16.0) {
            return;
        }
    }
    // Update tracking data
    handle.setPrevX(entityHandle.getLocX());
    handle.setPrevY(entityHandle.getLocY());
    handle.setPrevZ(entityHandle.getLocZ());
    handle.setSynched(true);
    scanPlayers(list);
}
Also used : EntityTrackerEntryHandle(com.bergerkiller.generated.net.minecraft.server.EntityTrackerEntryHandle) EntityHandle(com.bergerkiller.generated.net.minecraft.server.EntityHandle)

Aggregations

EntityHandle (com.bergerkiller.generated.net.minecraft.server.EntityHandle)1 EntityTrackerEntryHandle (com.bergerkiller.generated.net.minecraft.server.EntityTrackerEntryHandle)1