Search in sources :

Example 26 with TIntIterator

use of gnu.trove.iterator.TIntIterator in project Terasology by MovingBlocks.

the class ServerImpl method sendEntities.

private void sendEntities(NetData.NetMessage.Builder message) {
    TIntIterator dirtyIterator = netDirty.iterator();
    while (dirtyIterator.hasNext()) {
        int netId = dirtyIterator.next();
        EntityRef entity = networkSystem.getEntity(netId);
        if (isOwned(entity)) {
            Set<Class<? extends Component>> emptyComponentClassSet = Collections.emptySet();
            EntityData.PackedEntity entityData = entitySerializer.serialize(entity, emptyComponentClassSet, changedComponents.get(netId), emptyComponentClassSet, new ClientComponentFieldCheck());
            if (entityData != null) {
                message.addUpdateEntity(NetData.UpdateEntityMessage.newBuilder().setEntity(entityData).setNetId(netId));
            }
        }
    }
    netDirty.clear();
}
Also used : TIntIterator(gnu.trove.iterator.TIntIterator) EntityData(org.terasology.protobuf.EntityData) BlockComponent(org.terasology.world.block.BlockComponent) NetworkComponent(org.terasology.network.NetworkComponent) Component(org.terasology.entitySystem.Component) EntityRef(org.terasology.entitySystem.entity.EntityRef) ClientComponentFieldCheck(org.terasology.network.serialization.ClientComponentFieldCheck)

Example 27 with TIntIterator

use of gnu.trove.iterator.TIntIterator in project Charset by CharsetMC.

the class AudioStreamManagerClient method removeAll.

@Override
public void removeAll() {
    TIntIterator iterator = streams.keySet().iterator();
    while (iterator.hasNext()) {
        streams.get(iterator.next()).stop();
    }
    streams.clear();
}
Also used : TIntIterator(gnu.trove.iterator.TIntIterator)

Example 28 with TIntIterator

use of gnu.trove.iterator.TIntIterator in project Charset by CharsetMC.

the class IngredientGroup method createMatchingStacks.

@Override
protected ItemStack[][] createMatchingStacks() {
    TIntList list = new TIntArrayList();
    Entry e = entryMap.get(type);
    if (e == null) {
        return new ItemStack[0][0];
    }
    TIntIterator iterator = e.typeMap.keySet().iterator();
    while (iterator.hasNext()) {
        int id = iterator.next();
        if (!blacklistedIds.contains(id)) {
            list.add(id);
        }
    }
    ItemStack[][] stacks = new ItemStack[list.size()][];
    for (int i = 0; i < stacks.length; i++) {
        Collection c = e.typeMap.get(list.get(i));
        int length = 0;
        for (Object o : c) {
            if (o instanceof String) {
                length += OreDictionary.getOres((String) o).size();
            } else if (o instanceof ItemStack) {
                length++;
            }
        }
        stacks[i] = new ItemStack[length];
        int j = 0;
        for (Object o : c) {
            if (o instanceof String) {
                NonNullList<ItemStack> stackList = OreDictionary.getOres((String) o);
                for (ItemStack stack : stackList) {
                    stacks[i][j++] = stack;
                }
            } else if (o instanceof ItemStack) {
                stacks[i][j++] = (ItemStack) o;
            }
        }
    }
    return stacks;
}
Also used : TIntIterator(gnu.trove.iterator.TIntIterator) JsonObject(com.google.gson.JsonObject) TIntList(gnu.trove.list.TIntList) ItemStack(net.minecraft.item.ItemStack) TIntArrayList(gnu.trove.list.array.TIntArrayList)

Example 29 with TIntIterator

use of gnu.trove.iterator.TIntIterator in project Osmand by osmandapp.

the class RouteResultPreparation method inferSlightTurnFromLanes.

private int inferSlightTurnFromLanes(int[] oLanes, RoadSplitStructure rs) {
    TIntHashSet possibleTurns = new TIntHashSet();
    for (int i = 0; i < oLanes.length; i++) {
        if ((oLanes[i] & 1) == 0) {
            continue;
        }
        if (possibleTurns.isEmpty()) {
            // Nothing is in the list to compare to, so add the first elements
            possibleTurns.add(TurnType.getPrimaryTurn(oLanes[i]));
            if (TurnType.getSecondaryTurn(oLanes[i]) != 0) {
                possibleTurns.add(TurnType.getSecondaryTurn(oLanes[i]));
            }
            if (TurnType.getTertiaryTurn(oLanes[i]) != 0) {
                possibleTurns.add(TurnType.getTertiaryTurn(oLanes[i]));
            }
        } else {
            TIntArrayList laneTurns = new TIntArrayList();
            laneTurns.add(TurnType.getPrimaryTurn(oLanes[i]));
            if (TurnType.getSecondaryTurn(oLanes[i]) != 0) {
                laneTurns.add(TurnType.getSecondaryTurn(oLanes[i]));
            }
            if (TurnType.getTertiaryTurn(oLanes[i]) != 0) {
                laneTurns.add(TurnType.getTertiaryTurn(oLanes[i]));
            }
            possibleTurns.retainAll(laneTurns);
            if (possibleTurns.isEmpty()) {
                // No common turns, so can't determine anything.
                return 0;
            }
        }
    }
    // Remove all turns from lanes not selected...because those aren't it
    for (int i = 0; i < oLanes.length; i++) {
        if ((oLanes[i] & 1) == 0 && !possibleTurns.isEmpty()) {
            possibleTurns.remove((Integer) TurnType.getPrimaryTurn(oLanes[i]));
            if (TurnType.getSecondaryTurn(oLanes[i]) != 0) {
                possibleTurns.remove((Integer) TurnType.getSecondaryTurn(oLanes[i]));
            }
            if (TurnType.getTertiaryTurn(oLanes[i]) != 0) {
                possibleTurns.remove((Integer) TurnType.getTertiaryTurn(oLanes[i]));
            }
        }
    }
    // remove all non-slight turns // TEST don't pass
    // if(possibleTurns.size() > 1) {
    // TIntIterator it = possibleTurns.iterator();
    // while(it.hasNext()) {
    // int nxt = it.next();
    // if(!TurnType.isSlightTurn(nxt)) {
    // it.remove();
    // }
    // }
    // }
    int infer = 0;
    if (possibleTurns.size() == 1) {
        infer = possibleTurns.iterator().next();
    } else if (possibleTurns.size() > 1) {
        if (rs.keepLeft && rs.keepRight && possibleTurns.contains(TurnType.C)) {
            infer = TurnType.C;
        } else if (rs.keepLeft || rs.keepRight) {
            TIntIterator it = possibleTurns.iterator();
            infer = it.next();
            while (it.hasNext()) {
                int next = it.next();
                int orderInfer = TurnType.orderFromLeftToRight(infer);
                int orderNext = TurnType.orderFromLeftToRight(next);
                if (rs.keepLeft && orderNext < orderInfer) {
                    infer = next;
                } else if (rs.keepRight && orderNext > orderInfer) {
                    infer = next;
                }
            }
        }
    }
    // Checking to see that there is only one unique turn
    if (infer != 0) {
        for (int i = 0; i < oLanes.length; i++) {
            if (TurnType.getSecondaryTurn(oLanes[i]) == infer) {
                int pt = TurnType.getPrimaryTurn(oLanes[i]);
                int en = oLanes[i] & 1;
                TurnType.setPrimaryTurnAndReset(oLanes, i, infer);
                oLanes[i] |= en;
                TurnType.setSecondaryTurn(oLanes, i, pt);
            }
        }
    }
    return infer;
}
Also used : TIntIterator(gnu.trove.iterator.TIntIterator) TIntHashSet(gnu.trove.set.hash.TIntHashSet) TIntArrayList(gnu.trove.list.array.TIntArrayList)

Example 30 with TIntIterator

use of gnu.trove.iterator.TIntIterator in project Terasology by MovingBlocks.

the class NetClient method sendRemovedEntities.

private void sendRemovedEntities(NetData.NetMessage.Builder message) {
    TIntIterator initialIterator = netRemoved.iterator();
    while (initialIterator.hasNext()) {
        message.addRemoveEntity(NetData.RemoveEntityMessage.newBuilder().setNetId(initialIterator.next()));
    }
    netRemoved.clear();
}
Also used : TIntIterator(gnu.trove.iterator.TIntIterator)

Aggregations

TIntIterator (gnu.trove.iterator.TIntIterator)39 MutableBlockPos (net.minecraft.util.math.BlockPos.MutableBlockPos)13 BlockPos (net.minecraft.util.math.BlockPos)8 ArrayList (java.util.ArrayList)5 TIntArrayList (gnu.trove.list.array.TIntArrayList)4 TIntHashSet (gnu.trove.set.hash.TIntHashSet)4 IBlockState (net.minecraft.block.state.IBlockState)4 Chunk (net.minecraft.world.chunk.Chunk)4 EntityData (org.terasology.protobuf.EntityData)4 TIntList (gnu.trove.list.TIntList)3 HashSet (java.util.HashSet)3 ExtendedBlockStorage (net.minecraft.world.chunk.storage.ExtendedBlockStorage)3 Vector (ValkyrienWarfareBase.API.Vector)2 TFloatArrayList (gnu.trove.list.array.TFloatArrayList)2 ItemStack (net.minecraft.item.ItemStack)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)2 EntityRef (org.terasology.entitySystem.entity.EntityRef)2 VWChunkCache (ValkyrienWarfareBase.Relocation.VWChunkCache)1