-
-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy pathEntityUtil.java
More file actions
23 lines (20 loc) · 801 Bytes
/
EntityUtil.java
File metadata and controls
23 lines (20 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package de.srendi.advancedperipherals.common.util;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraftforge.server.ServerLifecycleHooks;
import java.util.UUID;
public class EntityUtil {
/**
* Searches all levels for an {@link Entity} with the given {@link UUID}.
* @param uuid the unique identifier of the {@code Entity}
* @return an {@code Entity} that has the given {@code UUID} if one is found, null otherwise
*/
public static Entity getEntityFromUUID(UUID uuid) {
for (ServerLevel level : ServerLifecycleHooks.getCurrentServer().getAllLevels()) {
Entity entity = level.getEntity(uuid);
if (entity != null)
return entity;
}
return null;
}
}