Apollo
Developers
Modules
Entity

Entity Module

Overview

The entity module allows you to interact with entities client-sided.

  • Adds the ability to render rainbow sheep, client side instead of server-sided.
  • Adds the ability to flip entities, without doing anything server-sided.

Integration

Sample Code

Explore each integration by cycling through each tab, to find the best fit for your requirements and needs.

Override Sheep rainbow state

public void overrideRainbowSheepExample(Player viewer) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
 
    apolloPlayerOpt.ifPresent(apolloPlayer -> {
        // Get all Sheep in the player's world
        List<UUID> sheepUuids = viewer.getWorld().getEntitiesByClass(Sheep.class)
            .stream().map(Sheep::getUniqueId).collect(Collectors.toList());
 
        this.entityModule.overrideRainbowSheep(apolloPlayer, sheepUuids);
    });
}

Reset Sheep rainbow state

public void resetRainbowSheepExample(Player viewer) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
 
    apolloPlayerOpt.ifPresent(apolloPlayer -> {
        // Get all Sheep in the player's world
        List<ApolloEntity> sheepEntities = viewer.getWorld().getEntitiesByClass(Sheep.class)
            .stream().map(sheep -> new ApolloEntity(sheep.getEntityId(), sheep.getUniqueId()))
            .collect(Collectors.toList());
 
        this.entityModule.resetRainbowSheep(apolloPlayer, sheepEntities);
    });
}

Override Entity flip state

public void flipEntityExample(Player viewer) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
 
    apolloPlayerOpt.ifPresent(apolloPlayer -> {
        // Get all cows within 10 blocks of the player
        List<ApolloEntity> entities = viewer.getWorld()
            .getNearbyEntities(viewer.getLocation(), 10, 10, 10)
            .stream().filter(entity -> entity instanceof Cow)
            .map(cow -> new ApolloEntity(cow.getEntityId(), cow.getUniqueId()))
            .collect(Collectors.toList());
 
        this.entityModule.flipEntity(apolloPlayer, entities);
    });
}

Reset Entity flip state

public void resetFlippedEntityExample(Player viewer) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
 
    apolloPlayerOpt.ifPresent(apolloPlayer -> {
        // Get all cows within 10 blocks of the player
        List<ApolloEntity> entities = viewer.getWorld()
            .getNearbyEntities(viewer.getLocation(), 10, 10, 10)
            .stream().filter(entity -> entity instanceof Cow)
            .map(cow -> new ApolloEntity(cow.getEntityId(), cow.getUniqueId()))
            .collect(Collectors.toList());
 
        this.entityModule.resetFlippedEntity(apolloPlayer, entities);
    });
}

overrideRainbowSheep, resetRainbowSheep, flipEntity & resetFlippedEntity Parameters

  1. Recipients recipients
    • A list of all the player(s) you want to be able to see the updated entities.
  2. List<ApolloEntity> entities
    • A list of all entities you want to reset the flip or colored sheep state from.