Search in sources :

Example 1 with NetworkEvent

use of org.terasology.engine.network.NetworkEvent in project Terasology by MovingBlocks.

the class EventSystemReplayImpl method broadcastEvent.

private void broadcastEvent(EntityRef entity, Event event, EventMetadata metadata) {
    if (networkSystem.getMode().isServer()) {
        NetworkComponent netComp = entity.getComponent(NetworkComponent.class);
        BlockComponent blockComp = entity.getComponent(BlockComponent.class);
        if (netComp != null || blockComp != null) {
            Client instigatorClient = null;
            if (metadata.isSkipInstigator() && event instanceof NetworkEvent) {
                instigatorClient = networkSystem.getOwner(((NetworkEvent) event).getInstigator());
            }
            for (Client client : networkSystem.getPlayers()) {
                if (!client.equals(instigatorClient)) {
                    client.send(event, entity);
                }
            }
        }
    }
}
Also used : BlockComponent(org.terasology.engine.world.block.BlockComponent) NetworkComponent(org.terasology.engine.network.NetworkComponent) NetworkEvent(org.terasology.engine.network.NetworkEvent) Client(org.terasology.engine.network.Client)

Aggregations

Client (org.terasology.engine.network.Client)1 NetworkComponent (org.terasology.engine.network.NetworkComponent)1 NetworkEvent (org.terasology.engine.network.NetworkEvent)1 BlockComponent (org.terasology.engine.world.block.BlockComponent)1