Package alexiil.mc.lib.multipart.api
Interface MultipartContainer
public interface MultipartContainer
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
static interface
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault MultipartHolder
Shorter form ofofferNewPart(MultipartCreator, boolean)
followed by adding the offer if it was allowed.default MultipartHolder
addNewPart(MultipartContainer.MultipartCreator creator, boolean respectEntityBBs)
Shorter form ofofferNewPart(MultipartCreator, boolean)
followed by adding the offer if it was allowed.boolean
canPlayerInteract(PlayerEntity player)
default boolean
fireEvent(MultipartEvent event)
Fires the given event on thegetEventBus()
viaMultipartEventBus.fireEvent(MultipartEvent)
.default List<AbstractPart>
getAllParts(Predicate<AbstractPart> filter)
default DimensionType
default <P> P
getFirstPart(Class<P> clazz)
default <P> P
getFirstPart(Class<P> clazz, Predicate<P> filter)
default AbstractPart
getFirstPart(Predicate<AbstractPart> filter)
getPart(long uniqueId)
default <P> List<P>
default <P> List<P>
boolean
default boolean
default MultipartContainer.PartOffer
Offers a new part to this container, respecting nearby entities' bounding boxes.offerNewPart(MultipartContainer.MultipartCreator creator, boolean respectEntityBBs)
Offers a new part to this container.void
RecalculatesgetCurrentShape()
andgetCollisionShape()
.void
Redraws this multipart, if any of it's parts return differentAbstractPart.getModelKey()
.boolean
removePart(AbstractPart part)
default <T> void
sendNetworkUpdate(T obj, NetIdDataK<T> netId, NetIdDataK.IMsgDataWriterK<T> writer)
Sends the givenNetIdDataK
to every player currently watching thisgetMultipartBlockEntity()
, with a customNetIdDataK.IMsgDataWriterK
.default <T> void
sendNetworkUpdate(T obj, NetIdTyped<T> netId)
Sends the givenNetIdDataK
orNetIdSignalK
to every player currently watching thisgetMultipartBlockEntity()
.<T> void
sendNetworkUpdateExcept(PlayerEntity except, T obj, NetIdDataK<T> netId, NetIdDataK.IMsgDataWriterK<T> writer)
Sends the givenNetIdDataK
to every player currently watching thisgetMultipartBlockEntity()
, with a customNetIdDataK.IMsgDataWriterK
, except for the given player.<T> void
sendNetworkUpdateExcept(PlayerEntity except, T obj, NetIdTyped<T> netId)
Sends the givenNetIdDataK
orNetIdSignalK
to every player currently watching thisgetMultipartBlockEntity()
, except for the given player.default boolean
default boolean
testNewPart(MultipartContainer.MultipartCreator creator, boolean respectEntityBBs)
-
Field Details
-
ATTRIBUTE
-
-
Method Details
-
getMultipartWorld
World getMultipartWorld() -
getMultipartPos
BlockPos getMultipartPos() -
getMultipartBlockEntity
BlockEntity getMultipartBlockEntity() -
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
- 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
VoxelShape
of every containedAbstractPart.getShape()
.
-
getCollisionShape
VoxelShape getCollisionShape()- Returns:
- The current
VoxelShape
of every containedAbstractPart.getCollisionShape()
.
-
getOutlineShape
VoxelShape getOutlineShape()- Returns:
- A complete
VoxelShape
of every containedAbstractPart.getOutlineShape()
-
recalculateShape
void recalculateShape()RecalculatesgetCurrentShape()
andgetCollisionShape()
.AbstractPart
's should call this when their own shape changes. -
sendNetworkUpdate
Sends the givenNetIdDataK
orNetIdSignalK
to every player currently watching thisgetMultipartBlockEntity()
. -
sendNetworkUpdate
default <T> void sendNetworkUpdate(T obj, NetIdDataK<T> netId, NetIdDataK.IMsgDataWriterK<T> writer)Sends the givenNetIdDataK
to every player currently watching thisgetMultipartBlockEntity()
, with a customNetIdDataK.IMsgDataWriterK
. -
sendNetworkUpdateExcept
Sends the givenNetIdDataK
orNetIdSignalK
to 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 givenNetIdDataK
to 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:
MultipartEventBus.fireEvent(MultipartEvent)
-
hasTicked
boolean hasTicked()- Returns:
- True if
PartTickEvent
has 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.
-