Add MultipartContainer#getParts(Multipart)
This commit is contained in:
parent
d411a15bba
commit
835d75f06e
|
@ -21,6 +21,7 @@ import net.minecraft.world.World;
|
||||||
import net.minecraft.world.loot.context.LootContext;
|
import net.minecraft.world.loot.context.LootContext;
|
||||||
import net.minecraft.world.loot.context.Parameters;
|
import net.minecraft.world.loot.context.Parameters;
|
||||||
import net.shadowfacts.simplemultipart.SimpleMultipart;
|
import net.shadowfacts.simplemultipart.SimpleMultipart;
|
||||||
|
import net.shadowfacts.simplemultipart.multipart.Multipart;
|
||||||
import net.shadowfacts.simplemultipart.multipart.MultipartState;
|
import net.shadowfacts.simplemultipart.multipart.MultipartState;
|
||||||
import net.shadowfacts.simplemultipart.multipart.entity.MultipartEntity;
|
import net.shadowfacts.simplemultipart.multipart.entity.MultipartEntity;
|
||||||
import net.shadowfacts.simplemultipart.multipart.entity.MultipartEntityProvider;
|
import net.shadowfacts.simplemultipart.multipart.entity.MultipartEntityProvider;
|
||||||
|
@ -63,6 +64,13 @@ public abstract class AbstractContainerBlockEntity extends BlockEntity implement
|
||||||
return !parts.isEmpty();
|
return !parts.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<MultipartView> getParts(Multipart type) {
|
||||||
|
return parts.stream()
|
||||||
|
.filter(e -> e.getState().getMultipart() == type)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultipartView getPart(Direction side) {
|
public MultipartView getPart(Direction side) {
|
||||||
Entry existing = sidePartCache.get(side);
|
Entry existing = sidePartCache.get(side);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.shadowfacts.simplemultipart.container;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.shadowfacts.simplemultipart.multipart.Multipart;
|
||||||
import net.shadowfacts.simplemultipart.multipart.MultipartView;
|
import net.shadowfacts.simplemultipart.multipart.MultipartView;
|
||||||
import net.shadowfacts.simplemultipart.multipart.MultipartState;
|
import net.shadowfacts.simplemultipart.multipart.MultipartState;
|
||||||
|
|
||||||
|
@ -40,6 +41,14 @@ public interface MultipartContainer {
|
||||||
*/
|
*/
|
||||||
boolean hasParts();
|
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.
|
* Gets the part on the given side.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue