Search in sources :

Example 1 with NetworkEvent

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

the class EventSystemImpl 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.world.block.BlockComponent) NetworkComponent(org.terasology.network.NetworkComponent) NetworkEvent(org.terasology.network.NetworkEvent) Client(org.terasology.network.Client)

Aggregations

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