Class ServerCitizenInteraction
java.lang.Object
com.minecolonies.api.colony.interactionhandling.AbstractInteractionResponseHandler
com.minecolonies.core.colony.interactionhandling.ServerCitizenInteraction
- All Implemented Interfaces:
IInteractionResponseHandler,net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
- Direct Known Subclasses:
PosBasedInteraction,RecruitmentInteraction,RequestBasedInteraction,StandardInteraction
The server side interaction response handler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Set<net.minecraft.network.chat.Component> All registered parents of this response handler.protected net.minecraft.network.chat.ComponentThe id of the validator. -
Constructor Summary
ConstructorsConstructorDescriptionWay to load the response handler for a citizen.ServerCitizenInteraction(net.minecraft.network.chat.Component inquiry, boolean primary, IChatPriority priority, Predicate<ICitizenData> validator, @NotNull net.minecraft.network.chat.Component validatorId, Tuple<net.minecraft.network.chat.Component, net.minecraft.network.chat.Component>... responseTuples) The server interaction response handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddParent(net.minecraft.network.chat.Component parent) Add a parent to the list.voiddeserializeNBT(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.nbt.CompoundTag compoundNBT) Deserialize the response handler from NBT.net.minecraft.network.chat.ComponentgetId()Get the id.booleanisValid(ICitizenData citizen) Check if this response handler is still valid.booleanisVisible(net.minecraft.world.level.Level world) Check if this response handler is still visible for the player.protected voidLoad the validator.booleanonClientResponseTriggered(int responseId, net.minecraft.world.entity.player.Player player, ICitizenDataView data, com.ldtteam.blockui.views.BOWindow window) Client side action triggered on a possible response.voidonServerResponseTriggered(int responseId, net.minecraft.world.entity.player.Player player, ICitizenData data) Server side action triggered on a possible response.voidremoveParent(net.minecraft.network.chat.Component oldParent) Remove an old parent and return true if no parent is left.net.minecraft.nbt.CompoundTagserializeNBT(net.minecraft.core.HolderLookup.Provider provider) Serialize the response handler to NBT.Methods inherited from class com.minecolonies.api.colony.interactionhandling.AbstractInteractionResponseHandler
getInquiry, getPossibleResponses, getPriority, getResponseResult, isPrimaryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.interactionhandling.IInteractionResponseHandler
genChildInteractions, getInquiry, getInteractionIcon, getType, onClosed, onOpened, onWindowOpened
-
Field Details
-
validatorId
protected net.minecraft.network.chat.Component validatorIdThe id of the validator. -
parents
All registered parents of this response handler.
-
-
Constructor Details
-
ServerCitizenInteraction
@SafeVarargs public ServerCitizenInteraction(net.minecraft.network.chat.Component inquiry, boolean primary, IChatPriority priority, Predicate<ICitizenData> validator, @NotNull @NotNull net.minecraft.network.chat.Component validatorId, Tuple<net.minecraft.network.chat.Component, net.minecraft.network.chat.Component>... responseTuples) The server interaction response handler.- Parameters:
inquiry- the client inquiry.primary- if primary interaction.priority- the interaction priority.validator- validation predicate to check if this interaction is still valid.validatorId- the id of the validator.responseTuples- the tuples mapping player responses to further interactions.
-
ServerCitizenInteraction
Way to load the response handler for a citizen.- Parameters:
data- the citizen owning this handler.
-
-
Method Details
-
isVisible
public boolean isVisible(net.minecraft.world.level.Level world) Description copied from interface:IInteractionResponseHandlerCheck if this response handler is still visible for the player.- Specified by:
isVisiblein interfaceIInteractionResponseHandler- Overrides:
isVisiblein classAbstractInteractionResponseHandler- Parameters:
world- the world this citizen is in.- Returns:
- true if so.
-
isValid
Description copied from interface:IInteractionResponseHandlerCheck if this response handler is still valid.- Specified by:
isValidin interfaceIInteractionResponseHandler- Overrides:
isValidin classAbstractInteractionResponseHandler- Parameters:
citizen- the colony the citizen is in.- Returns:
- true if still valid, else false.
-
addParent
public void addParent(net.minecraft.network.chat.Component parent) Add a parent to the list.- Parameters:
parent- the parent to add.
-
removeParent
public void removeParent(net.minecraft.network.chat.Component oldParent) Remove an old parent and return true if no parent is left.- Parameters:
oldParent- the parent to remove.
-
onServerResponseTriggered
public void onServerResponseTriggered(int responseId, net.minecraft.world.entity.player.Player player, ICitizenData data) Description copied from interface:IInteractionResponseHandlerServer side action triggered on a possible response.- Parameters:
responseId- the clicked string response of the player.player- the world it was triggered in.data- the citizen related to it.
-
onClientResponseTriggered
public boolean onClientResponseTriggered(int responseId, net.minecraft.world.entity.player.Player player, ICitizenDataView data, com.ldtteam.blockui.views.BOWindow window) Description copied from interface:IInteractionResponseHandlerClient side action triggered on a possible response.- Parameters:
responseId- the clicked index.player- the client side world.data- the citizen data assigned to it.window- the window it was triggered in.- Returns:
- if wishing to continue interacting.
-
serializeNBT
public net.minecraft.nbt.CompoundTag serializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider) Description copied from class:AbstractInteractionResponseHandlerSerialize the response handler to NBT.- Specified by:
serializeNBTin interfacenet.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>- Overrides:
serializeNBTin classAbstractInteractionResponseHandler- Returns:
- the serialized data.
-
deserializeNBT
public void deserializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compoundNBT) Description copied from class:AbstractInteractionResponseHandlerDeserialize the response handler from NBT.- Specified by:
deserializeNBTin interfacenet.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>- Overrides:
deserializeNBTin classAbstractInteractionResponseHandler
-
loadValidator
protected void loadValidator()Load the validator. -
getId
public net.minecraft.network.chat.Component getId()Description copied from interface:IInteractionResponseHandlerGet the id.- Returns:
- the id.
-