Search in sources :

Example 11 with Pair

use of net.minecraft.util.Pair in project Biome-Makeover by Lemonszz.

the class IvyBlock method getNearbyIvyCount.

private Pair<Integer, Integer> getNearbyIvyCount(World world, BlockPos pos) {
    int distance = 3;
    // -1 because it counts itself and this was easier lol
    int count = -1;
    for (int x = -distance; x < distance; x++) {
        for (int z = -distance; z < distance; z++) {
            for (int y = -distance; y < distance; y++) {
                if (world.getBlockState(pos.add(x, y, z)).isOf(this))
                    count++;
            }
        }
    }
    int adjacent = 0;
    for (Direction dir : Direction.values()) if (world.getBlockState(pos.offset(dir)).isOf(this))
        adjacent++;
    return new Pair<>(count, adjacent);
}
Also used : Direction(net.minecraft.util.math.Direction) Pair(net.minecraft.util.Pair)

Example 12 with Pair

use of net.minecraft.util.Pair in project allium by hugeblank.

the class Plugin method unload.

public void unload() {
    PLUGINS.remove(getId(), this);
    this.executor.getState().abandon();
    for (Event e : Event.getEvents().values()) {
        List<Pair<Plugin, LuaFunction>> listeners = e.getListeners();
        listeners.removeIf(pair -> pair.getLeft().equals(this));
        PACK.drop(path);
    }
}
Also used : Event(me.hugeblank.allium.lua.event.Event) Pair(net.minecraft.util.Pair)

Example 13 with Pair

use of net.minecraft.util.Pair in project Client by MatHax.

the class LeftRightListSettingScreen method initWidgets.

private void initWidgets(Registry<T> registry) {
    // Left (all)
    WTable left = abc(pairs -> registry.forEach(t -> {
        if (skipValue(t) || collection.contains(t))
            return;
        int words = Utils.search(getValueName(t), filterText);
        if (words > 0)
            pairs.add(new Pair<>(t, words));
    }), true, t -> {
        addValue(registry, t);
        T v = getAdditionalValue(t);
        if (v != null)
            addValue(registry, v);
    });
    if (left.cells.size() > 0)
        table.add(theme.verticalSeparator()).expandWidgetY();
    // Right (selected)
    abc(pairs -> {
        for (T value : collection) {
            if (skipValue(value))
                continue;
            int words = Utils.search(getValueName(value), filterText);
            if (words > 0)
                pairs.add(new Pair<>(value, words));
        }
    }, false, t -> {
        removeValue(registry, t);
        T v = getAdditionalValue(t);
        if (v != null)
            removeValue(registry, v);
    });
}
Also used : Utils(mathax.client.utils.Utils) Pair(net.minecraft.util.Pair) GuiTheme(mathax.client.gui.GuiTheme) Collection(java.util.Collection) Registry(net.minecraft.util.registry.Registry) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) Cell(mathax.client.gui.utils.Cell) WTable(mathax.client.gui.widgets.containers.WTable) List(java.util.List) Setting(mathax.client.settings.Setting) WTextBox(mathax.client.gui.widgets.input.WTextBox) WPressable(mathax.client.gui.widgets.pressable.WPressable) Comparator(java.util.Comparator) WindowScreen(mathax.client.gui.WindowScreen) WWidget(mathax.client.gui.widgets.WWidget) WTable(mathax.client.gui.widgets.containers.WTable) Pair(net.minecraft.util.Pair)

Example 14 with Pair

use of net.minecraft.util.Pair in project ThonkUtil by LimeAppleBoat.

the class LivingEntityMixin method pickOutCape.

private Item pickOutCape() {
    boolean a = false;
    if (((LivingEntity) (Object) this).getType().equals(EntityType.ZOMBIE))
        a = true;
    if (((LivingEntity) (Object) this).getType().equals(EntityType.HUSK))
        a = true;
    if (((LivingEntity) (Object) this).getType().equals(EntityType.DROWNED))
        a = true;
    if (((LivingEntity) (Object) this).getType().equals(EntityType.ZOMBIFIED_PIGLIN))
        a = true;
    if (((LivingEntity) (Object) this).getType().equals(EntityType.SKELETON))
        a = true;
    if (((LivingEntity) (Object) this).getType().equals(EntityType.STRAY))
        a = true;
    if (!a)
        return Items.AIR;
    ArrayList<Pair<Item, Integer>> capCapes = new ArrayList<>();
    capCapes.add(new Pair<>(Registry.ITEM.get(new Identifier("thonkutil:migration_cape")), 50));
    capCapes.add(new Pair<>(Registry.ITEM.get(new Identifier("thonkutil:founders_cape")), 25));
    capCapes.add(new Pair<>(Registry.ITEM.get(new Identifier("thonkutil:pan_cape")), 25));
    capCapes.add(new Pair<>(Registry.ITEM.get(new Identifier("thonkutil:new_year_2011_cape")), 15));
    capCapes.add(new Pair<>(Registry.ITEM.get(new Identifier("thonkutil:minecon_2016_cape")), 7));
    capCapes.add(new Pair<>(Registry.ITEM.get(new Identifier("thonkutil:minecon_2015_cape")), 5));
    capCapes.add(new Pair<>(Registry.ITEM.get(new Identifier("thonkutil:minecon_2013_cape")), 3));
    capCapes.add(new Pair<>(Registry.ITEM.get(new Identifier("thonkutil:minecon_2012_cape")), 2));
    capCapes.add(new Pair<>(Registry.ITEM.get(new Identifier("thonkutil:minecon_2011_cape")), 1));
    capCapes.add(new Pair<>(Registry.ITEM.get(new Identifier("thonkutil:translator_cape")), 1));
    capCapes.add(new Pair<>(Registry.ITEM.get(new Identifier("thonkutil:animated_christmas_2010_cape")), 1));
    final Object[] c = capCapes.toArray();
    final int b = (int) (Math.random() * c.length);
    return ((Pair<Item, Integer>) c[b]).getRight() >= (Math.random() * 100) + 1 ? ((Pair<Item, Integer>) c[b]).getLeft() : Items.AIR;
}
Also used : CapeItem(com.jab125.thonkutil.api.CapeItem) Item(net.minecraft.item.Item) Identifier(net.minecraft.util.Identifier) ArrayList(java.util.ArrayList) Pair(net.minecraft.util.Pair)

Example 15 with Pair

use of net.minecraft.util.Pair in project Polymorph by TheIllusiveC4.

the class AbstractHighlightedRecipeData method getPacketData.

@Override
public Pair<SortedSet<RecipePair>, Identifier> getPacketData() {
    SortedSet<RecipePair> recipesList = this.getRecipesList();
    Identifier selected = null;
    if (!recipesList.isEmpty()) {
        selected = this.getSelectedRecipe().map(Recipe::getId).orElse(recipesList.first().getIdentifier());
    }
    return new Pair<>(recipesList, selected);
}
Also used : Identifier(net.minecraft.util.Identifier) RecipePair(top.theillusivec4.polymorph.api.common.base.RecipePair) Recipe(net.minecraft.recipe.Recipe) Pair(net.minecraft.util.Pair) RecipePair(top.theillusivec4.polymorph.api.common.base.RecipePair)

Aggregations

Pair (net.minecraft.util.Pair)17 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Collection (java.util.Collection)4 Comparator (java.util.Comparator)4 Consumer (java.util.function.Consumer)4 ItemStack (net.minecraft.item.ItemStack)4 Registry (net.minecraft.util.registry.Registry)4 BlockPos (net.minecraft.util.math.BlockPos)3 Direction (net.minecraft.util.math.Direction)3 Helper (com.qouteall.immersive_portals.Helper)2 IntegerAABBInclusive (com.qouteall.immersive_portals.my_util.IntegerAABBInclusive)2 Arrays (java.util.Arrays)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 Predicate (java.util.function.Predicate)2 IntStream (java.util.stream.IntStream)2 Stream (java.util.stream.Stream)2 GuiTheme (mathax.client.gui.GuiTheme)2 WindowScreen (mathax.client.gui.WindowScreen)2