Package alexiil.mc.lib.multipart.api
Interface MultipartContainer
public interface MultipartContainer
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceMultipartContainer.MultipartCreatorstatic interfaceMultipartContainer.PartOffer -
Field Summary
Fields Modifier and Type Field Description static alexiil.mc.lib.attributes.Attribute<MultipartContainer>ATTRIBUTE -
Method Summary
Modifier and Type Method Description default MultipartHolderaddNewPart(MultipartContainer.MultipartCreator creator)Shorter 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(net.minecraft.entity.player.PlayerEntity player)default booleanfireEvent(MultipartEvent event)Fires the given event on thegetEventBus()viaMultipartEventBus.fireEvent(MultipartEvent).java.util.List<AbstractPart>getAllParts()default java.util.List<AbstractPart>getAllParts(java.util.function.Predicate<AbstractPart> filter)net.minecraft.util.shape.VoxelShapegetCollisionShape()net.minecraft.util.shape.VoxelShapegetCurrentShape()default net.minecraft.world.dimension.DimensionTypegetDimension()MultipartEventBusgetEventBus()default <P> PgetFirstPart(java.lang.Class<P> clazz)default <P> PgetFirstPart(java.lang.Class<P> clazz, java.util.function.Predicate<P> filter)default AbstractPartgetFirstPart(java.util.function.Predicate<AbstractPart> filter)net.minecraft.block.entity.BlockEntitygetMultipartBlockEntity()net.minecraft.util.math.BlockPosgetMultipartPos()net.minecraft.world.WorldgetMultipartWorld()net.minecraft.block.entity.BlockEntitygetNeighbourBlockEntity(net.minecraft.util.math.Direction dir)net.minecraft.util.shape.VoxelShapegetOutlineShape()AbstractPartgetPart(long uniqueId)default <P> java.util.List<P>getParts(java.lang.Class<P> clazz)default <P> java.util.List<P>getParts(java.lang.Class<P> clazz, java.util.function.Predicate<P> filter)MultipartPropertyContainergetProperties()booleanhasTicked()default booleanisClientWorld()default MultipartContainer.PartOfferofferNewPart(MultipartContainer.MultipartCreator creator)Offers a new part to this container, respecting nearby entities' bounding boxes.MultipartContainer.PartOfferofferNewPart(MultipartContainer.MultipartCreator creator, boolean respectEntityBBs)Offers a new part to this container.voidrecalculateShape()RecalculatesgetCurrentShape()andgetCollisionShape().voidredrawIfChanged()Redraws this multipart, if any of it's parts return differentAbstractPart.getModelKey().booleanremovePart(AbstractPart part)default <T> voidsendNetworkUpdate(T obj, alexiil.mc.lib.net.NetIdDataK<T> netId, alexiil.mc.lib.net.NetIdDataK.IMsgDataWriterK<T> writer)Sends the givenNetIdDataKto every player currently watching thisgetMultipartBlockEntity(), with a customNetIdDataK.IMsgDataWriterK.default <T> voidsendNetworkUpdate(T obj, alexiil.mc.lib.net.NetIdTyped<T> netId)Sends the givenNetIdDataKorNetIdSignalKto every player currently watching thisgetMultipartBlockEntity().<T> voidsendNetworkUpdateExcept(net.minecraft.entity.player.PlayerEntity except, T obj, alexiil.mc.lib.net.NetIdDataK<T> netId, alexiil.mc.lib.net.NetIdDataK.IMsgDataWriterK<T> writer)Sends the givenNetIdDataKto every player currently watching thisgetMultipartBlockEntity(), with a customNetIdDataK.IMsgDataWriterK, except for the given player.<T> voidsendNetworkUpdateExcept(net.minecraft.entity.player.PlayerEntity except, T obj, alexiil.mc.lib.net.NetIdTyped<T> netId)Sends the givenNetIdDataKorNetIdSignalKto every player currently watching thisgetMultipartBlockEntity(), except for the given player.default booleantestNewPart(MultipartContainer.MultipartCreator creator)default booleantestNewPart(MultipartContainer.MultipartCreator creator, boolean respectEntityBBs)
-
Field Details
-
Method Details
-
getMultipartWorld
net.minecraft.world.World getMultipartWorld() -
getMultipartPos
net.minecraft.util.math.BlockPos getMultipartPos() -
getMultipartBlockEntity
net.minecraft.block.entity.BlockEntity getMultipartBlockEntity() -
getDimension
default net.minecraft.world.dimension.DimensionType getDimension() -
isClientWorld
default boolean isClientWorld() -
canPlayerInteract
boolean canPlayerInteract(net.minecraft.entity.player.PlayerEntity player)- 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
@Nullable net.minecraft.block.entity.BlockEntity getNeighbourBlockEntity(net.minecraft.util.math.Direction dir) -
getAllParts
java.util.List<AbstractPart> getAllParts() -
getAllParts
default java.util.List<AbstractPart> getAllParts(java.util.function.Predicate<AbstractPart> filter) -
getParts
default <P> java.util.List<P> getParts(java.lang.Class<P> clazz) -
getParts
default <P> java.util.List<P> getParts(java.lang.Class<P> clazz, java.util.function.Predicate<P> filter) -
getFirstPart
-
getFirstPart
@Nullable default <P> P getFirstPart(java.lang.Class<P> clazz) -
getFirstPart
@Nullable default <P> P getFirstPart(java.lang.Class<P> clazz, java.util.function.Predicate<P> filter) -
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
net.minecraft.util.shape.VoxelShape getCurrentShape()- Returns:
- The current
VoxelShapeof every containedAbstractPart.getShape().
-
getCollisionShape
net.minecraft.util.shape.VoxelShape getCollisionShape()- Returns:
- The current
VoxelShapeof every containedAbstractPart.getCollisionShape().
-
getOutlineShape
net.minecraft.util.shape.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
default <T> void sendNetworkUpdate(T obj, alexiil.mc.lib.net.NetIdTyped<T> netId)Sends the givenNetIdDataKorNetIdSignalKto every player currently watching thisgetMultipartBlockEntity(). -
sendNetworkUpdate
default <T> void sendNetworkUpdate(T obj, alexiil.mc.lib.net.NetIdDataK<T> netId, alexiil.mc.lib.net.NetIdDataK.IMsgDataWriterK<T> writer)Sends the givenNetIdDataKto every player currently watching thisgetMultipartBlockEntity(), with a customNetIdDataK.IMsgDataWriterK. -
sendNetworkUpdateExcept
<T> void sendNetworkUpdateExcept(@Nullable net.minecraft.entity.player.PlayerEntity except, T obj, alexiil.mc.lib.net.NetIdTyped<T> netId)Sends the givenNetIdDataKorNetIdSignalKto every player currently watching thisgetMultipartBlockEntity(), except for the given player. -
sendNetworkUpdateExcept
<T> void sendNetworkUpdateExcept(@Nullable net.minecraft.entity.player.PlayerEntity except, T obj, alexiil.mc.lib.net.NetIdDataK<T> netId, alexiil.mc.lib.net.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:
MultipartEventBus.fireEvent(MultipartEvent)
-
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.
-