Search in sources :

Example 1 with TObjectIntHashMap

use of gnu.trove.map.hash.TObjectIntHashMap in project Charset by CharsetMC.

the class BlockStacks method getDrops.

@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, @Nullable TileEntity te, int fortune, boolean silkTouch) {
    if (te instanceof TileEntityStacks) {
        TObjectIntMap<ItemMaterial> materials = new TObjectIntHashMap<>();
        for (ItemMaterial material : ((TileEntityStacks) te).stacks) {
            materials.adjustOrPutValue(material, 1, 1);
        }
        for (ItemMaterial material : materials.keySet()) {
            ItemStack stack = material.getStack();
            if (!stack.isEmpty()) {
                int count = materials.get(material);
                for (int i = 0; i < count; i += stack.getMaxStackSize()) {
                    stack = stack.copy();
                    stack.setCount(Math.min(count - i, stack.getMaxStackSize()));
                    drops.add(stack);
                }
            }
        }
    }
}
Also used : TObjectIntHashMap(gnu.trove.map.hash.TObjectIntHashMap) ItemMaterial(pl.asie.charset.lib.material.ItemMaterial) ItemStack(net.minecraft.item.ItemStack)

Example 2 with TObjectIntHashMap

use of gnu.trove.map.hash.TObjectIntHashMap in project Tropicraft by Tropicraft.

the class ItemFishBucket method addInformation.

@Override
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flagIn) {
    NBTTagList fishList = getFishList(stack);
    TObjectIntMap<String> fishCounts = new TObjectIntHashMap<>();
    for (int i = 0; i < fishList.tagCount(); i++) {
        // TODO this is awful
        String color = EntityTropicalFish.names[fishList.getCompoundTagAt(i).getInteger("Color")];
        fishCounts.adjustOrPutValue(color, 1, 1);
    }
    for (String s : fishCounts.keySet()) {
        String line = s;
        int count = fishCounts.get(s);
        if (count > 1) {
            line += " (x" + count + ")";
        }
        tooltip.add(line);
    }
    super.addInformation(stack, world, tooltip, flagIn);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) TObjectIntHashMap(gnu.trove.map.hash.TObjectIntHashMap)

Example 3 with TObjectIntHashMap

use of gnu.trove.map.hash.TObjectIntHashMap in project OpenTripPlanner by opentripplanner.

the class PointSet method buildIdIndexMapIfNeeded.

/**
 * Build the ID - Index map if needed.
 */
private synchronized void buildIdIndexMapIfNeeded() {
    // by this method in another thread while this instantiation was blocked.
    if (idIndexMap == null) {
        // make a local object, don't expose to public view until it's built
        TObjectIntMap idIndexMap = new TObjectIntHashMap<String>(this.capacity, 1f, -1);
        for (int i = 0; i < this.capacity; i++) {
            if (ids[i] != null) {
                if (idIndexMap.containsKey(ids[i])) {
                    LOG.error("Duplicate ID {} in pointset.", ids[i]);
                } else {
                    idIndexMap.put(ids[i], i);
                }
            }
        }
        // now expose to public view; reference assignment is an atomic operation
        this.idIndexMap = idIndexMap;
    }
}
Also used : TObjectIntMap(gnu.trove.map.TObjectIntMap) TObjectIntHashMap(gnu.trove.map.hash.TObjectIntHashMap)

Example 4 with TObjectIntHashMap

use of gnu.trove.map.hash.TObjectIntHashMap in project DynamicSurroundings by OreCruncher.

the class SoundEngine method diagnostics.

/**
 * Event handler for the diagnostic event.
 *
 * @param event
 *            Event that has been raised.
 */
@SubscribeEvent(priority = EventPriority.LOW)
public void diagnostics(final DiagnosticEvent.Gather event) {
    final int soundCount = currentSoundCount();
    final int maxCount = maxSounds;
    event.output.add("SoundSystem: " + soundCount + "/" + maxCount);
    final TObjectIntHashMap<ResourceLocation> counts = new TObjectIntHashMap<>();
    final Iterator<Entry<String, ISound>> iterator = getPlayingSounds().entrySet().iterator();
    while (iterator.hasNext()) {
        final Entry<String, ISound> entry = iterator.next();
        final ISound isound = entry.getValue();
        counts.adjustOrPutValue(isound.getSound().getSoundLocation(), 1, 1);
    }
    final List<String> results = new ArrayList<>();
    final TObjectIntIterator<ResourceLocation> itr = counts.iterator();
    while (itr.hasNext()) {
        itr.advance();
        results.add(String.format(TextFormatting.GOLD + "%s: %d", itr.key().toString(), itr.value()));
    }
    Collections.sort(results);
    event.output.addAll(results);
}
Also used : ISound(net.minecraft.client.audio.ISound) Entry(java.util.Map.Entry) TObjectIntHashMap(gnu.trove.map.hash.TObjectIntHashMap) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with TObjectIntHashMap

use of gnu.trove.map.hash.TObjectIntHashMap in project BuildCraft by BuildCraft.

the class WorkbenchCrafting method hasExactStacks.

private boolean hasExactStacks() {
    TObjectIntMap<ItemStackKey> required = new TObjectIntHashMap<>(getSizeInventory());
    for (int s = 0; s < getSizeInventory(); s++) {
        ItemStack req = invBlueprint.getStackInSlot(s);
        if (!req.isEmpty()) {
            int count = req.getCount();
            if (count != 1) {
                req = req.copy();
                req.setCount(1);
            }
            ItemStackKey key = new ItemStackKey(req);
            required.adjustOrPutValue(key, count, count);
        }
    }
    return required.forEachEntry((stack, count) -> {
        ArrayStackFilter filter = new ArrayStackFilter(stack.baseStack);
        ItemStack inInventory = invMaterials.extract(filter, count, count, true);
        return !inInventory.isEmpty() && inInventory.getCount() == count;
    });
}
Also used : ArrayStackFilter(buildcraft.lib.inventory.filter.ArrayStackFilter) TObjectIntHashMap(gnu.trove.map.hash.TObjectIntHashMap) ItemStack(net.minecraft.item.ItemStack) ItemStackKey(buildcraft.lib.misc.ItemStackKey)

Aggregations

TObjectIntHashMap (gnu.trove.map.hash.TObjectIntHashMap)14 TObjectIntMap (gnu.trove.map.TObjectIntMap)4 ArrayList (java.util.ArrayList)3 TripPattern (org.opentripplanner.routing.edgetype.TripPattern)3 Entry (java.util.Map.Entry)2 ItemStack (net.minecraft.item.ItemStack)2 QualifiedModeSet (org.opentripplanner.api.parameter.QualifiedModeSet)2 FrequencyEntry (org.opentripplanner.routing.trippattern.FrequencyEntry)2 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)2 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)2 ArrayStackFilter (buildcraft.lib.inventory.filter.ArrayStackFilter)1 ItemStackKey (buildcraft.lib.misc.ItemStackKey)1 HashMultimap (com.google.common.collect.HashMultimap)1 Multimap (com.google.common.collect.Multimap)1 Ints (com.google.common.primitives.Ints)1 LineString (com.vividsolutions.jts.geom.LineString)1 TObjectIntIterator (gnu.trove.iterator.TObjectIntIterator)1 TIntSet (gnu.trove.set.TIntSet)1 TIntHashSet (gnu.trove.set.hash.TIntHashSet)1 File (java.io.File)1