Search in sources :

Example 6 with IRadioWaveReceiver

use of com.builtbroken.mc.api.map.radio.IRadioWaveReceiver in project Engine by VoltzEngine-Project.

the class RadioMap method updateChunkCache.

protected void updateChunkCache(IRadioWaveReceiver receiver, Cube range) {
    List<ChunkCoordIntPair> list = range.getChunkCoords();
    //Update chunk position map
    for (ChunkCoordIntPair pair : list) {
        List<IRadioWaveReceiver> receivers = chunk_to_entities.get(pair);
        if (receivers == null) {
            receivers = new ArrayList();
        }
        if (!receivers.contains(receiver)) {
            receivers.add(receiver);
        }
        chunk_to_entities.put(pair, receivers);
    }
    //Update receiver map
    receive_to_chunks.put(receiver, list);
}
Also used : IRadioWaveReceiver(com.builtbroken.mc.api.map.radio.IRadioWaveReceiver) ChunkCoordIntPair(net.minecraft.world.ChunkCoordIntPair) ArrayList(java.util.ArrayList)

Example 7 with IRadioWaveReceiver

use of com.builtbroken.mc.api.map.radio.IRadioWaveReceiver in project Engine by VoltzEngine-Project.

the class RadioMap method updateSenderCache.

protected void updateSenderCache(IRadioWaveReceiver receiver, Cube range) {
    if (range != null) {
        //Update sender cache
        for (IRadioWaveSender sender : sender_to_receivers_cache.keySet()) {
            Cube senderRange = sender.getRadioSenderRange();
            if (senderRange.doesOverlap(range)) {
                List<IRadioWaveReceiver> receivers = sender_to_receivers_cache.get(sender);
                if (receivers == null) {
                    receivers = new ArrayList();
                }
                if (!receivers.contains(receiver)) {
                    receivers.add(receiver);
                }
                sender_to_receivers_cache.put(sender, receivers);
            }
        }
    }
}
Also used : IRadioWaveReceiver(com.builtbroken.mc.api.map.radio.IRadioWaveReceiver) Cube(com.builtbroken.mc.imp.transform.region.Cube) IRadioWaveSender(com.builtbroken.mc.api.map.radio.IRadioWaveSender) ArrayList(java.util.ArrayList)

Aggregations

IRadioWaveReceiver (com.builtbroken.mc.api.map.radio.IRadioWaveReceiver)7 Cube (com.builtbroken.mc.imp.transform.region.Cube)5 ArrayList (java.util.ArrayList)5 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)3 IRadioWaveSender (com.builtbroken.mc.api.map.radio.IRadioWaveSender)2 RadioMap (com.builtbroken.mc.lib.world.radio.RadioMap)1 Entity (net.minecraft.entity.Entity)1 TileEntity (net.minecraft.tileentity.TileEntity)1