Package alexiil.mc.lib.multipart.api
Interface MultipartContainer
public interface MultipartContainer
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
MultipartContainer.MultipartCreator
static interface
MultipartContainer.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 MultipartHolder
addNewPart(MultipartContainer.MultipartCreator creator)
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(net.minecraft.entity.player.PlayerEntity player)
default boolean
fireEvent(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.VoxelShape
getCollisionShape()
net.minecraft.util.shape.VoxelShape
getCurrentShape()
default net.minecraft.world.dimension.DimensionType
getDimension()
MultipartEventBus
getEventBus()
default <P> P
getFirstPart(java.lang.Class<P> clazz)
default <P> P
getFirstPart(java.lang.Class<P> clazz, java.util.function.Predicate<P> filter)
default AbstractPart
getFirstPart(java.util.function.Predicate<AbstractPart> filter)
net.minecraft.block.entity.BlockEntity
getMultipartBlockEntity()
net.minecraft.util.math.BlockPos
getMultipartPos()
net.minecraft.world.World
getMultipartWorld()
net.minecraft.block.entity.BlockEntity
getNeighbourBlockEntity(net.minecraft.util.math.Direction dir)
net.minecraft.util.shape.VoxelShape
getOutlineShape()
AbstractPart
getPart(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)
MultipartPropertyContainer
getProperties()
boolean
hasTicked()
default boolean
isClientWorld()
default MultipartContainer.PartOffer
offerNewPart(MultipartContainer.MultipartCreator creator)
Offers a new part to this container, respecting nearby entities' bounding boxes.MultipartContainer.PartOffer
offerNewPart(MultipartContainer.MultipartCreator creator, boolean respectEntityBBs)
Offers a new part to this container.void
recalculateShape()
RecalculatesgetCurrentShape()
andgetCollisionShape()
.void
redrawIfChanged()
Redraws this multipart, if any of it's parts return differentAbstractPart.getModelKey()
.boolean
removePart(AbstractPart part)
default <T> void
sendNetworkUpdate(T obj, alexiil.mc.lib.net.NetIdDataK<T> netId, alexiil.mc.lib.net.NetIdDataK.IMsgDataWriterK<T> writer)
Sends the givenNetIdDataK
to every player currently watching thisgetMultipartBlockEntity()
, with a customNetIdDataK.IMsgDataWriterK
.default <T> void
sendNetworkUpdate(T obj, alexiil.mc.lib.net.NetIdTyped<T> netId)
Sends the givenNetIdDataK
orNetIdSignalK
to every player currently watching thisgetMultipartBlockEntity()
.<T> void
sendNetworkUpdateExcept(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 givenNetIdDataK
to every player currently watching thisgetMultipartBlockEntity()
, with a customNetIdDataK.IMsgDataWriterK
, except for the given player.<T> void
sendNetworkUpdateExcept(net.minecraft.entity.player.PlayerEntity except, T obj, alexiil.mc.lib.net.NetIdTyped<T> netId)
Sends the givenNetIdDataK
orNetIdSignalK
to every player currently watching thisgetMultipartBlockEntity()
, except for the given player.default boolean
testNewPart(MultipartContainer.MultipartCreator creator)
default boolean
testNewPart(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
VoxelShape
of every containedAbstractPart.getShape()
.
-
getCollisionShape
net.minecraft.util.shape.VoxelShape getCollisionShape()- Returns:
- The current
VoxelShape
of every containedAbstractPart.getCollisionShape()
.
-
getOutlineShape
net.minecraft.util.shape.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
default <T> void sendNetworkUpdate(T obj, alexiil.mc.lib.net.NetIdTyped<T> netId)Sends the givenNetIdDataK
orNetIdSignalK
to 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 givenNetIdDataK
to 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 givenNetIdDataK
orNetIdSignalK
to 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 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.
-