-
Notifications
You must be signed in to change notification settings - Fork 6
Using (Spawned)DisplayEntityGroups
Jay edited this page Apr 22, 2025
·
15 revisions
//Get a DisplayEntityGroup from an InputStream
DisplayEntityGroup groupFromStream = DisplayGroupManager.getGroup(InputStream);
//Get a DisplayEntityGroup from a File
DisplayEntityGroup groupFromFile = DisplayGroupManager.getGroup(File);
//Get a DisplayEntityGroup from a storage location (LOCAL, MONGODB, or MYSQL)
DisplayEntityGroup groupFromStorage = DisplayGroupManager.getGroup(LoadMethod.LOCAL, "groupTag");
//Get a DisplayEntityGroup stored in a plugin's resources
DisplayEntityGroup groupFromResources = DisplayGroupManager.getGroup(MyPlugin.getInstance(), "groupTag")//After getting your saved DisplayEntityGroup spawn it at a specified location (respects location direction)
SpawnedDisplayEntityGroup spawnedGroup = savedGroup.spawn(Location, GroupSpawnedEvent.SpawnReason.CUSTOM);
//Now the SpawnedDisplayEntityGroup can be used for animations, used as entity equipment, etc.
//Spawn a Group with GroupSpawnSettings to apply properties to a group before it is spawned
GroupSpawnSettings settings = new GroupSpawnSettings();
settings.setTeleportationDuration(2)
.hideInteractions(true);
SpawnedDisplayEntityGroup spawnedGroup = savedGroup.spawn(Location, GroupSpawnedEvent.SpawnReason.CUSTOM, settings);//Get a GroupResult containing the nearest SpawnedDisplayEntityGroup within 7 blocks of location
GroupResult result = DisplayGroupManager.getSpawnedGroupNearLocation(location, 7);
//Get the SpawnedDisplayEntityGroup from the group result
SpawnedDisplayEntityGroup group = result.group();
//True if this group was already loaded/registered during this play session and hasn't been unregistered since
boolean wasAlreadyLoaded = result.alreadyLoaded();//Unregister a SpawnedDisplayEntityGroup and despawn, forcing chunk loading to ensure entity removal
spawnedGroup.unregister(true, true);
//Unregister a SpawnedDisplayEntityGroup and despawn, unforced
spawnedGroup.unregister(true, false);
//Unregister a SpawnedDisplayEntityGroup without despawning it
spawnedGroup.unregister(false, false);//Teleport a SpawnedDisplayEntityGroup to a location and respect the location's pitch and yaw, not the group's
spawnedGroup.teleport(Location, false);
//Teleport a SpawnedDisplayEntityGroup to a location and respect the group's pitch and yaw, not the location's
spawnedGroup.teleport(Location, true);
//Teleport a SpawnedDisplayEntityGroup in a direction over time
double distance = 5;
int teleportDuration = 2; //in ticks
spawnedGroup.teleportMove(Direction, distance, teleportDuration);
//Teleport in a direction over time with a Vector
spawnedGroup.teleportMove(Vector, distance, teleportDuration);
//Translate a SpawnedDisplayEntityGroup in any direction
int translationDuration = 2; //in ticks
int delayBeforeTranslation = 5 //in ticks
spawnedDisplayEntityGroup.translate(Direction, distance, translationDuration, delayBeforeTranslation);
//Translate a SpawnedDisplayEntityGroup with a Vector
spawnedDisplayEntityGroup.translate(Vector, distance, translationDuration, delayBeforeTranslation);//Create a clone of a SpawnedDisplayEntityGroup
Location cloningLocation;
SpawnedDisplayEntityGroup clonedGroup = spawnedDisplayEntityGroup.clone(cloningLocation)//Convert a SpawnedDisplayEntityGroup into a DisplayEntityGroup, which is serializable
spawnedDisplayEntityGroup.toDisplayEntityGroup();