Add MultipartContainer#getParts(Multipart)

This commit is contained in:
Shadowfacts 2019-01-05 10:04:24 -05:00
parent d411a15bba
commit 835d75f06e
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 17 additions and 0 deletions

View File

@ -21,6 +21,7 @@ import net.minecraft.world.World;
import net.minecraft.world.loot.context.LootContext;
import net.minecraft.world.loot.context.Parameters;
import net.shadowfacts.simplemultipart.SimpleMultipart;
import net.shadowfacts.simplemultipart.multipart.Multipart;
import net.shadowfacts.simplemultipart.multipart.MultipartState;
import net.shadowfacts.simplemultipart.multipart.entity.MultipartEntity;
import net.shadowfacts.simplemultipart.multipart.entity.MultipartEntityProvider;
@ -63,6 +64,13 @@ public abstract class AbstractContainerBlockEntity extends BlockEntity implement
return !parts.isEmpty();
}
@Override
public Set<MultipartView> getParts(Multipart type) {
return parts.stream()
.filter(e -> e.getState().getMultipart() == type)
.collect(Collectors.toSet());
}
@Override
public MultipartView getPart(Direction side) {
Entry existing = sidePartCache.get(side);

View File

@ -3,6 +3,7 @@ package net.shadowfacts.simplemultipart.container;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import net.shadowfacts.simplemultipart.multipart.Multipart;
import net.shadowfacts.simplemultipart.multipart.MultipartView;
import net.shadowfacts.simplemultipart.multipart.MultipartState;
@ -40,6 +41,14 @@ public interface MultipartContainer {
*/
boolean hasParts();
/**
* Gets all the multiparts in this container of the given type.
*
* @param type The multipart instance representing the multipart type.
* @return The set of all the multiparts in this container that are of that type.
*/
Set<MultipartView> getParts(Multipart type);
/**
* Gets the part on the given side.
*