Package alexiil.mc.lib.multipart.api
Interface MultipartContainer
public interface MultipartContainer
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interface -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault MultipartHolderShorter form ofofferNewPart(MultipartCreator, boolean)followed by adding the offer if it was allowed.default MultipartHolderaddNewPart(MultipartContainer.MultipartCreator creator, boolean respectEntityBBs) Shorter form ofofferNewPart(MultipartCreator, boolean)followed by adding the offer if it was allowed.booleancanPlayerInteract(PlayerEntity player) default booleanfireEvent(MultipartEvent event) Fires the given event on thegetEventBus()viaMultipartEventBus.fireEvent(MultipartEvent).default List<AbstractPart>getAllParts(Predicate<AbstractPart> filter) default DimensionTypedefault <P> PgetFirstPart(Class<P> clazz) default <P> PgetFirstPart(Class<P> clazz, Predicate<P> filter) default AbstractPartgetFirstPart(Predicate<AbstractPart> filter) getPart(long uniqueId) Retrieves the part whoseAbstractPart.getOutlineShape()contains the givenVec3d.default <P> List<P>default <P> List<P>booleandefault booleanvoiddefault MultipartContainer.PartOfferOffers a new part to this container, respecting nearby entities' bounding boxes.offerNewPart(MultipartContainer.MultipartCreator creator, boolean respectEntityBBs) Offers a new part to this container.voidRecalculatesgetCurrentShape()andgetCollisionShape().voidRedraws this multipart, if any of it's parts return differentAbstractPart.getModelKey().booleanremovePart(AbstractPart part) default <T> voidsendNetworkUpdate(T obj, NetIdDataK<T> netId, NetIdDataK.IMsgDataWriterK<T> writer) Sends the givenNetIdDataKto every player currently watching thisgetMultipartBlockEntity(), with a customNetIdDataK.IMsgDataWriterK.default <T> voidsendNetworkUpdate(T obj, NetIdTyped<T> netId) Sends the givenNetIdDataKorNetIdSignalKto every player currently watching thisgetMultipartBlockEntity().<T> voidsendNetworkUpdateExcept(PlayerEntity except, T obj, NetIdDataK<T> netId, NetIdDataK.IMsgDataWriterK<T> writer) Sends the givenNetIdDataKto every player currently watching thisgetMultipartBlockEntity(), with a customNetIdDataK.IMsgDataWriterK, except for the given player.<T> voidsendNetworkUpdateExcept(PlayerEntity except, T obj, NetIdTyped<T> netId) Sends the givenNetIdDataKorNetIdSignalKto every player currently watching thisgetMultipartBlockEntity(), except for the given player.default booleandefault booleantestNewPart(MultipartContainer.MultipartCreator creator, boolean respectEntityBBs)
-
Field Details
-
ATTRIBUTE
-
-
Method Details
-
getMultipartWorld
World getMultipartWorld() -
getMultipartPos
BlockPos getMultipartPos() -
getMultipartBlockEntity
BlockEntity getMultipartBlockEntity() -
markChunkDirty
void markChunkDirty() -
getDimension
-
isClientWorld
default boolean isClientWorld() -
canPlayerInteract
- Returns:
- true if the player should be able to interact with this container in GUI form. Implementors should generally check to ensure they are still present in-world.
-
getNeighbourBlockEntity
-
getAllParts
List<AbstractPart> getAllParts() -
getAllParts
-
getParts
-
getParts
-
getFirstPart
-
getFirstPart
-
getFirstPart
-
getPart
Retrieves the part whoseAbstractPart.getOutlineShape()contains the givenVec3d.- Parameters:
vec- The vector. This should be in the range 0 to 1, rather than be local to this block.- Returns:
- The part, or null if there is no part at that vector.
-
getPart
- Returns:
- The part that has the given
container-only unique ID, or null if no parts have that unique id.
-
offerNewPart
@Nullable MultipartContainer.PartOffer offerNewPart(MultipartContainer.MultipartCreator creator, boolean respectEntityBBs) Offers a new part to this container. Note that this can be called on the client as well as the server, however the client cannot add the resulting part offer to this container.- Parameters:
creator- The creator which can create the actual part.respectEntityBBs- whether to respect nearby entities bounding boxes, or not- Returns:
- either null (if the offered part was refused) or an offer object which lets you either add it via
MultipartContainer.PartOffer.apply(), or do nothing
-
offerNewPart
@Nullable default MultipartContainer.PartOffer offerNewPart(MultipartContainer.MultipartCreator creator) Offers a new part to this container, respecting nearby entities' bounding boxes. Note that this can be called on the client as well as the server, however the client cannot add the resulting part offer to this container.- Parameters:
creator- The creator which can create the actual part.- Returns:
- either null (if the offered part was refused) or an offer object which lets you either add it via
MultipartContainer.PartOffer.apply(), or do nothing
-
addNewPart
@Nullable default MultipartHolder addNewPart(MultipartContainer.MultipartCreator creator, boolean respectEntityBBs) Shorter form ofofferNewPart(MultipartCreator, boolean)followed by adding the offer if it was allowed.- Returns:
- The holder for the part if it was added, or null if it was not.
-
addNewPart
Shorter form ofofferNewPart(MultipartCreator, boolean)followed by adding the offer if it was allowed.- Returns:
- The holder for the part if it was added, or null if it was not.
-
testNewPart
- Returns:
- True if the part could have been added to the container, false otherwise.
Note that this will never actually add a part to the container, so it is safe to be called on the client side.
-
testNewPart
- Returns:
- True if the part could have been added to the container, false otherwise.
Note that this will never actually add a part to the container, so it is safe to be called on the client side.
-
removePart
- Parameters:
part- The part to remove- Returns:
- True if the part used to be contained by this container, false otherwise.
-
getCurrentShape
VoxelShape getCurrentShape()- Returns:
- The current
VoxelShapeof every containedAbstractPart.getShape().
-
getCollisionShape
VoxelShape getCollisionShape()- Returns:
- The current
VoxelShapeof every containedAbstractPart.getCollisionShape().
-
getOutlineShape
VoxelShape getOutlineShape()- Returns:
- A complete
VoxelShapeof every containedAbstractPart.getOutlineShape()
-
recalculateShape
void recalculateShape()RecalculatesgetCurrentShape()andgetCollisionShape().AbstractPart's should call this when their own shape changes. -
sendNetworkUpdate
Sends the givenNetIdDataKorNetIdSignalKto every player currently watching thisgetMultipartBlockEntity(). -
sendNetworkUpdate
default <T> void sendNetworkUpdate(T obj, NetIdDataK<T> netId, NetIdDataK.IMsgDataWriterK<T> writer) Sends the givenNetIdDataKto every player currently watching thisgetMultipartBlockEntity(), with a customNetIdDataK.IMsgDataWriterK. -
sendNetworkUpdateExcept
Sends the givenNetIdDataKorNetIdSignalKto every player currently watching thisgetMultipartBlockEntity(), except for the given player. -
sendNetworkUpdateExcept
<T> void sendNetworkUpdateExcept(@Nullable PlayerEntity except, T obj, NetIdDataK<T> netId, NetIdDataK.IMsgDataWriterK<T> writer) Sends the givenNetIdDataKto every player currently watching thisgetMultipartBlockEntity(), with a customNetIdDataK.IMsgDataWriterK, except for the given player. -
getEventBus
MultipartEventBus getEventBus() -
fireEvent
Fires the given event on thegetEventBus()viaMultipartEventBus.fireEvent(MultipartEvent).- Returns:
- True if any listeners received the given event, false if none did. This may be useful for optimisation purposes.
- See Also:
-
hasTicked
boolean hasTicked()- Returns:
- True if
PartTickEventhas been fired yet, or false if it hasn't. This is useful in cases where a part might need to do world-dependent calculations inAbstractPart.onAdded(MultipartEventBus)
-
getProperties
MultipartPropertyContainer getProperties() -
redrawIfChanged
void redrawIfChanged()Redraws this multipart, if any of it's parts return differentAbstractPart.getModelKey().On the server this just sends a message to inform the client to check.
-