use of net.minecraft.util.Pair in project Biome-Makeover by Lemonszz.
the class LivingEntityMixin method tick.
@Inject(at = @At("TAIL"), method = "tick")
public void tick(CallbackInfo cbi) {
if (!getEntityWorld().isClient()) {
Iterator<Pair<EquipmentSlot, ItemStack>> it = attributeStacks.iterator();
while (it.hasNext()) {
Pair<EquipmentSlot, ItemStack> pair = it.next();
ItemStack st = pair.getRight();
if (!hasStackEquipInSlot(st, pair.getLeft())) {
ItemUtil.forEachEnchantment((en, stack, lvl) -> {
if (en instanceof BMEnchantment) {
((BMEnchantment) en).removeAttributes((LivingEntity) (Object) this, pair.getLeft());
}
}, st, true);
it.remove();
}
}
for (EquipmentSlot slot : EquipmentSlot.values()) {
ItemStack stack = getEquippedStack(slot);
if (!stack.isEmpty()) {
ItemUtil.forEachEnchantment((en, st, lvl) -> {
if (en instanceof BMEnchantment) {
((BMEnchantment) en).onTick((LivingEntity) (Object) this, st, lvl);
if (!hasAttributeStack(st) && ((BMEnchantment) en).addAttributes((LivingEntity) (Object) this, st, slot, lvl)) {
attributeStacks.add(new Pair<>(slot, st));
}
}
}, stack);
}
}
if (slideTime > 0) {
slideTime--;
if (slideTime <= 0) {
syncSlideTime();
}
} else {
if (random.nextInt(500) == 0) {
slideTime = 250 + random.nextInt(800);
syncSlideTime();
}
}
}
}
use of net.minecraft.util.Pair in project Client by MatHax.
the class LeftRightListSettingScreen method abc.
private WTable abc(Consumer<List<Pair<T, Integer>>> addValues, boolean isLeft, Consumer<T> buttonAction) {
// Create
Cell<WTable> cell = this.table.add(theme.table()).top();
WTable table = cell.widget();
Consumer<T> forEach = t -> {
if (!includeValue(t))
return;
table.add(getValueWidget(t));
WPressable button = table.add(isLeft ? theme.plus() : theme.minus()).expandCellX().right().widget();
button.action = () -> buttonAction.accept(t);
table.row();
};
// Sort
List<Pair<T, Integer>> values = new ArrayList<>();
addValues.accept(values);
if (!filterText.isEmpty())
values.sort(Comparator.comparingInt(value -> -value.getRight()));
for (Pair<T, Integer> pair : values) forEach.accept(pair.getLeft());
if (table.cells.size() > 0)
cell.expandX();
return table;
}
Aggregations