Class OperatorLPElement
java.lang.Object
org.cyclops.integrateddynamics.core.logicprogrammer.OperatorLPElement
- All Implemented Interfaces:
IGuiInputElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>, ILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>
public class OperatorLPElement
extends Object
implements ILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>
Element for operator.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic final recordWhat an element knows about referenced variables. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Called when this element is activated.voidaddReferences(OperatorLPElement.References references) Take over what another element knew about referenced variables, for when an expression moves to the element of another root operator.applyExpressionAction(ContainerLogicProgrammerBase container, ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.CompoundTag action) Apply an expression edit action, on both client and server.booleanIf this element in its current state can be deactivated because of another item being inserted into the write slot.protected booleanbooleanvoidCalled when this element is deactivated.booleanvoidfindReferencedCards(net.minecraft.world.entity.player.Player player) Look for the variable cards that are referenced in the loaded expression in the player's inventory, so their actual types are known and the actual cards can be shown in the slots.intintgetColor()static it.unimi.dsi.fastutil.ints.Int2ObjectMap<IValueType<?>> getInventoryCardTypes(net.minecraft.world.entity.player.Player player) protected static ValueTypeItemStackLPElement.IItemStackToValue<?> getItemConverter(IValueType<?> type) static net.minecraft.world.item.ItemStackgetItemOfValue(ExpressionNode node) intnet.minecraft.network.chat.ComponentgetName()protected net.minecraft.world.item.ItemStackgetReferenceItem(int variableId) intgetType()getValueNotShownByItem(int slotId) protected IValuegetValueOfItem(int slotId, net.minecraft.world.item.ItemStack itemStack) protected int[]getVariableIds(IVariableFacade[] inputVariables) inthashCode()booleanbooleanisFor(IVariableFacade variableFacade) booleanisItemValidForSlot(int slotId, net.minecraft.world.item.ItemStack itemStack) Check if the given item can be inserted into the given slot.voidloadElement(IVariableFacade variableFacade) The variable facade to load onto this element.voidloadTooltip(Consumer<net.minecraft.network.chat.Component> tooltipAdder) booleanmatchesInput(IValueType valueType) If the given value type matches with this element's input.booleanmatchesOutput(IValueType valueType) If the given value type matches with this element's output.voidonInputSlotUpdated(net.minecraft.world.entity.player.Player player, int slotId, net.minecraft.world.item.ItemStack itemStack) Called when an input item slot has been updated.voidsetArmedParameter(int armedParameter) voidsetExpression(Expression expression) Replace the whole expression, such as one that was typed as text.voidsetExpression(Expression expression, int[] editPath, String text) Replace the whole expression, and open the operator at the given path if it is one.voidsetFocused(boolean focused) voidsetInputVariables(IVariableFacade[] inputVariables) voidsetSelectedSlot(int selectedSlot) voidsetValueInContainer(ContainerLogicProgrammerBase container) Set the currently stored value in the given container.booleanslotClick(int slotId, net.minecraft.world.inventory.Slot slot, int mouseButton, net.minecraft.world.inventory.ContainerInput clickType, net.minecraft.world.entity.player.Player player) Called when a player clicks on a slot.toString()net.minecraft.network.chat.Componentvalidate()Validates the current state of the element.net.minecraft.world.item.ItemStackwriteElement(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack itemStack) The stack to write the current state of this element to.Methods inherited from interface ILogicProgrammerElement
createSlot
-
Constructor Details
-
OperatorLPElement
-
-
Method Details
-
getClient
- Specified by:
getClientin interfaceIGuiInputElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>
-
getType
- Specified by:
getTypein interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Returns:
- The element type.
-
getMatchString
- Specified by:
getMatchStringin interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Returns:
- The string used to match regex searching.
-
matchesInput
Description copied from interface:ILogicProgrammerElementIf the given value type matches with this element's input.- Specified by:
matchesInputin interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Parameters:
valueType- The value type to match.- Returns:
- If it matches
-
matchesOutput
Description copied from interface:ILogicProgrammerElementIf the given value type matches with this element's output.- Specified by:
matchesOutputin interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Parameters:
valueType- The value type to match.- Returns:
- If it matches
-
getName
public net.minecraft.network.chat.Component getName()- Specified by:
getNamein interfaceIGuiInputElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Returns:
- Name used for rendering.
-
loadTooltip
- Specified by:
loadTooltipin interfaceIGuiInputElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Parameters:
tooltipAdder- The list to add tooltip lines to.
-
getCurrentOperator
- Returns:
- The operator of the node that is currently being edited.
-
getRenderPattern
- Specified by:
getRenderPatternin interfaceIGuiInputElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Returns:
- The render pattern.
-
getValueOfItem
- Parameters:
slotId- A slot of the current node.itemStack- An item that is not a variable card.- Returns:
- The constant that the item gives when placed in the slot: the item itself in a slot that takes items, and otherwise the value that the element of the slot's type reads from it, such as the fluid in a bucket. Null if it gives none.
-
getItemOfValue
- Parameters:
node- A node in a slot.- Returns:
- The item that a constant is shown as in its slot: the item itself, or the item that the element of its type shows it as, such as a bucket for a fluid. Empty if the node is not a constant that can be shown as an item.
-
getValueNotShownByItem
- Parameters:
slotId- A slot of the current node.- Returns:
- The constant in the slot if the item it is shown as does not show it exactly, so its tooltip can, such as 250 mB of lava shown as a bucket. Null otherwise.
-
getItemConverter
@Nullable protected static ValueTypeItemStackLPElement.IItemStackToValue<?> getItemConverter(IValueType<?> type) - Parameters:
type- A value type.- Returns:
- How the element of the type in the logic programmer reads values from items and shows them as items, or null if it does not.
-
onInputSlotUpdated
public void onInputSlotUpdated(net.minecraft.world.entity.player.Player player, int slotId, net.minecraft.world.item.ItemStack itemStack) Description copied from interface:ILogicProgrammerElementCalled when an input item slot has been updated.- Specified by:
onInputSlotUpdatedin interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Parameters:
player-slotId- The slot id.itemStack- The itemstack currently in the slot, can be null.
-
canWriteElementPre
public boolean canWriteElementPre()- Specified by:
canWriteElementPrein interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Returns:
- If this element can be written to an item in its current state.
-
getVariableIds
-
writeElement
public net.minecraft.world.item.ItemStack writeElement(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack itemStack) Description copied from interface:ILogicProgrammerElementThe stack to write the current state of this element to.- Specified by:
writeElementin interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Parameters:
player- The player that is writing the element.itemStack- The stack to write to.- Returns:
- The resulting itemstack.
-
loadElement
Description copied from interface:ILogicProgrammerElementThe variable facade to load onto this element.- Specified by:
loadElementin interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Parameters:
variableFacade- The variable facade to load.
-
findReferencedCards
public void findReferencedCards(net.minecraft.world.entity.player.Player player) Look for the variable cards that are referenced in the loaded expression in the player's inventory, so their actual types are known and the actual cards can be shown in the slots.- Parameters:
player- The player.
-
getInventoryCardTypes
public static it.unimi.dsi.fastutil.ints.Int2ObjectMap<IValueType<?>> getInventoryCardTypes(net.minecraft.world.entity.player.Player player) - Parameters:
player- The player.- Returns:
- The output types of the variable cards in the player's inventory, by variable id.
-
setExpression
Replace the whole expression, such as one that was typed as text.- Parameters:
expression- An expression with this element's operator as root.
-
setExpression
Replace the whole expression, and open the operator at the given path if it is one.- Parameters:
expression- An expression with this element's operator as root.editPath- The path of the operator to open, such as the one that was open before.text- The text it was typed as, or null if it is printed.
-
getReferences
- Returns:
- What this element knows about referenced variables, to take over in another element.
-
addReferences
Take over what another element knew about referenced variables, for when an expression moves to the element of another root operator.- Parameters:
references- The references of the other element.
-
getReferenceItem
protected net.minecraft.world.item.ItemStack getReferenceItem(int variableId) - Parameters:
variableId- A referenced variable id.- Returns:
- The item to show in a slot for the given reference, the actual card if it is known, otherwise a placeholder.
-
setValueInContainer
Description copied from interface:ILogicProgrammerElementSet the currently stored value in the given container. This is only relevant to values that use things like slots, which must be updated server-side as well.- Specified by:
setValueInContainerin interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Parameters:
container- The container to put the currently stored value in.
-
applyExpressionAction
public ExpressionEditor.ActionResult applyExpressionAction(ContainerLogicProgrammerBase container, ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.CompoundTag action) Apply an expression edit action, on both client and server.- Parameters:
container- The container.valueDeseralizationContext- The deserialization context.action- The action, seeExpressionEditor.- Returns:
- The result.
-
canCurrentlyReadFromOtherItem
public boolean canCurrentlyReadFromOtherItem()Description copied from interface:ILogicProgrammerElementIf this element in its current state can be deactivated because of another item being inserted into the write slot.- Specified by:
canCurrentlyReadFromOtherItemin interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Returns:
- If this element can be deactivated.
-
activate
public void activate()Description copied from interface:IGuiInputElementCalled when this element is activated.- Specified by:
activatein interfaceIGuiInputElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>
-
deactivate
public void deactivate()Description copied from interface:IGuiInputElementCalled when this element is deactivated.- Specified by:
deactivatein interfaceIGuiInputElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>
-
validate
public net.minecraft.network.chat.Component validate()Description copied from interface:IGuiInputElementValidates the current state of the element.- Specified by:
validatein interfaceIGuiInputElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Returns:
- An error or null.
-
getColor
public int getColor()- Specified by:
getColorin interfaceIGuiInputElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Returns:
- The color used to identify this element.
-
getSymbol
- Specified by:
getSymbolin interfaceIGuiInputElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Returns:
- The symbol used to identify this element.
-
isFor
- Specified by:
isForin interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Parameters:
variableFacade- A variable facade- Returns:
- If this element corresponds to the given variable facade.
-
isItemValidForSlot
public boolean isItemValidForSlot(int slotId, net.minecraft.world.item.ItemStack itemStack) Description copied from interface:ILogicProgrammerElementCheck if the given item can be inserted into the given slot.- Specified by:
isItemValidForSlotin interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Parameters:
slotId- The slot id.itemStack- The item that will be inserted.- Returns:
- If it can be inserted.
-
slotClick
public boolean slotClick(int slotId, net.minecraft.world.inventory.Slot slot, int mouseButton, net.minecraft.world.inventory.ContainerInput clickType, net.minecraft.world.entity.player.Player player) Description copied from interface:ILogicProgrammerElementCalled when a player clicks on a slot.- Specified by:
slotClickin interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Parameters:
slotId- The slot id.slot- The slot.mouseButton- The mouse buttong id.clickType- The click type.player- The clicking player.- Returns:
- If further processing of the clicking should stop.
-
getItemStackSizeLimit
public int getItemStackSizeLimit()- Specified by:
getItemStackSizeLimitin interfaceILogicProgrammerElement<RenderPattern, ContainerScreenLogicProgrammerBase<?>, ContainerLogicProgrammerBase, OperatorLPElementClient<?>>- Returns:
- The max stacksize.
-
getOperator
-
getEditor
-
getSelectedSlot
public int getSelectedSlot()- Returns:
- The selected slot in the client-side UI, or -1 if none.
-
setSelectedSlot
public void setSelectedSlot(int selectedSlot) -
getArmedParameter
public int getArmedParameter()- Returns:
- The parameter that is armed for placing in a slot in the client-side UI, or -1 if none.
-
setArmedParameter
public void setArmedParameter(int armedParameter) -
getInputVariables
-
setInputVariables
-
isFocused
public boolean isFocused() -
setFocused
public void setFocused(boolean focused) -
equals
-
canEqual
-
hashCode
-
toString
-