use of net.minecraft.world.WorldlyContainer in project SpongeCommon by SpongePowered.
the class DefaultSingleBlockCarrier method inventory.
static Inventory inventory(final Direction from, final BlockCarrier thisThing) {
if (thisThing instanceof WorldlyContainer) {
final net.minecraft.core.Direction facing = DirectionFacingProvider.INSTANCE.get(from).get();
final int[] slots = ((WorldlyContainer) thisThing).getSlotsForFace(facing);
if (slots.length == 0) {
return new EmptyInventoryImpl(thisThing.inventory());
}
// build query for each slot
final Query.Builder builder = Query.builder();
Arrays.stream(slots).mapToObj(slot -> QueryTypes.KEY_VALUE.get().of(SlotMatchers.index(slot))).forEach(builder::and);
final Query query = builder.build();
return thisThing.inventory().query(query);
}
return thisThing.inventory();
}
Aggregations