Skip to content

Commit

Permalink
Fixed dispensers not being able to equip friendship bracelets and amu…
Browse files Browse the repository at this point in the history
…lets when trinkets is installed
  • Loading branch information
Sollace committed Sep 22, 2022
1 parent 48f3550 commit 9ce27c3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static boolean dispenseArmor(BlockPointer pointer, ItemStack armor) {
return pointer.getWorld().getEntitiesByClass(
LivingEntity.class,
new Box(pointer.getPos().offset(pointer.getBlockState().get(DispenserBlock.FACING))),
EntityPredicates.EXCEPT_SPECTATOR.and(new EntityPredicates.Equipable(armor))
EntityPredicates.EXCEPT_SPECTATOR
)
.stream()
.flatMap(entity -> TrinketsDelegate.getInstance()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.minelittlepony.unicopia.trinkets;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import net.fabricmc.loader.api.FabricLoader;
Expand Down Expand Up @@ -48,11 +49,7 @@ default boolean equipStack(LivingEntity entity, Identifier slot, ItemStack stack
}

default Set<Identifier> getAvailableTrinketSlots(LivingEntity entity, Set<Identifier> probedSlots) {
return Set.of();
}

default Stream<ItemStack> getEquipped(LivingEntity entity) {
return Stream.empty();
return probedSlots.stream().filter(slot -> getEquipped(entity, slot).count() == 0).collect(Collectors.toSet());
}

default Stream<ItemStack> getEquipped(LivingEntity entity, Identifier slot) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ public Set<Identifier> getAvailableTrinketSlots(LivingEntity entity, Set<Identif
return probedSlots;
}

@Override
public Stream<ItemStack> getEquipped(LivingEntity entity) {
return getInventories(entity).flatMap(InventoryUtil::stream).filter(s -> !s.isEmpty());
}

@Override
public Stream<ItemStack> getEquipped(LivingEntity entity, Identifier slot) {
return getInventory(entity, slot).stream().flatMap(InventoryUtil::stream).filter(s -> !s.isEmpty());
Expand Down

0 comments on commit 9ce27c3

Please sign in to comment.