Record Class PartConfigSnapshot
java.lang.Object
java.lang.Record
org.cyclops.integrateddynamics.core.part.PartConfigSnapshot
- Record Components:
version- The version of this snapshot format.sourcePartType- The unique name of the part type this snapshot was taken from.partSettings- The non-default general part settings.aspectProperties- The serialized non-default aspect properties, by aspect unique name.variableCards- All variables, of every section.extraData- The state that the part type itself stored, by section.disabledEntries- The entries that the player switched off, which are kept but not pasted.
public record PartConfigSnapshot(int version, net.minecraft.resources.Identifier sourcePartType, Optional<PartConfigSnapshot.PartSettings> partSettings, Map<net.minecraft.resources.Identifier, net.minecraft.nbt.CompoundTag> aspectProperties, List<PartConfigSnapshot.VariableCard> variableCards, Map<PartConfigSection, net.minecraft.nbt.CompoundTag> extraData, List<String> disabledEntries)
extends Record
An immutable snapshot of the configuration of a part, which can be pasted onto another part.
Only things that a player can configure are stored,
so no part id, enabled state, error messages or active aspect.
Only values that differ from the defaults of the copied part are stored,
so that pasting only overwrites what was deliberately configured.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe general settings of a part.static final recordA variable card inside one of the inventories of a part. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<PartConfigSnapshot> static final com.mojang.serialization.Codec<PartConfigSnapshot.PartSettings> static final com.mojang.serialization.Codec<PartConfigSnapshot.VariableCard> static final StringThe inventory name under which the active variable inventory of a part is stored.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionPartConfigSnapshot(int version, net.minecraft.resources.Identifier sourcePartType, Optional<PartConfigSnapshot.PartSettings> partSettings, Map<net.minecraft.resources.Identifier, net.minecraft.nbt.CompoundTag> aspectProperties, List<PartConfigSnapshot.VariableCard> variableCards, Map<PartConfigSection, net.minecraft.nbt.CompoundTag> extraData) A snapshot in which nothing is switched off yet.PartConfigSnapshot(int version, net.minecraft.resources.Identifier sourcePartType, Optional<PartConfigSnapshot.PartSettings> partSettings, Map<net.minecraft.resources.Identifier, net.minecraft.nbt.CompoundTag> aspectProperties, List<PartConfigSnapshot.VariableCard> variableCards, Map<PartConfigSection, net.minecraft.nbt.CompoundTag> extraData, List<String> disabledEntries) Creates an instance of aPartConfigSnapshotrecord class. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAspectEntries(ValueDeseralizationContext valueDeseralizationContext, List<PartConfigEntry> entries, IPartType<?, ?> partType, net.minecraft.resources.Identifier aspectName, List<PartConfigSnapshot.VariableCard> cards) Add everything that this snapshot holds for one aspect, starting with the card that makes it the aspect that the part uses, followed by its properties, each one directly above the variable that drives it.protected voidaddPartSetting(List<PartConfigEntry> entries, String setting, Optional<net.minecraft.network.chat.Component> value) protected voidaddPartSetting(List<PartConfigEntry> entries, String setting, Optional<net.minecraft.network.chat.Component> value, net.minecraft.world.item.ItemStack icon) Map<net.minecraft.resources.Identifier, net.minecraft.nbt.CompoundTag> Returns the value of theaspectPropertiesrecord component.Returns the value of thedisabledEntriesrecord component.final booleanIndicates whether some other object is "equal to" this one.Map<PartConfigSection, net.minecraft.nbt.CompoundTag> Returns the value of theextraDatarecord component.static Optional<PartConfigSnapshot> fromNBT(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag tag) protected static OptionalIntgetAspectColor(IAspect<?, ?> aspect) getEntries(ValueDeseralizationContext valueDeseralizationContext) The entries are what the player switches on and off, so this lists everything that this snapshot holds, whether it is switched on or not.net.minecraft.nbt.CompoundTaggetExtraData(PartConfigSection section) Part types can store anything that this snapshot does not know about itself, such as the state that an addon adds to its own part types.static net.minecraft.world.item.ItemStackgetOffsetEnhancements(int maxOffset) intgetRequiredBlankVariables(Set<PartConfigSection> sections) intgetRequiredMaxOffset(Set<PartConfigSection> sections) The offset enhancements that a part holds can not be taken out again without breaking the part, so pasting them has to consume enhancements from the player, just like the variable cards do.protected static IAspect<?, ?> getVariableCardAspect(IPartType<?, ?> partType, PartConfigSnapshot.VariableCard card) protected static net.minecraft.network.chat.ComponentgetVariableCardGroup(PartConfigSnapshot.VariableCard card, IAspect<?, ?> cardAspect) protected static net.minecraft.network.chat.ComponentgetVariableCardLabel(PartConfigSnapshot.VariableCard card, IAspect<?, ?> cardAspect) protected static StringgetVariableCardPropertyKey(IAspect<?, ?> aspect, PartConfigSnapshot.VariableCard card) getVariableCards(Set<PartConfigSection> sections) protected booleanprotected booleanfinal inthashCode()Returns a hash code value for this object.booleanhasSection(PartConfigSection section) booleanisEmpty()booleanReturns the value of thepartSettingsrecord component.protected static net.minecraft.network.chat.ComponentreadPropertyValue(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.CompoundTag property) net.minecraft.resources.IdentifierReturns the value of thesourcePartTyperecord component.net.minecraft.nbt.CompoundTagtoNBT(net.minecraft.core.HolderLookup.Provider provider) final StringtoString()Returns a string representation of this record class.protected static PartConfigEntryvariableCardEntry(PartConfigSnapshot.VariableCard card, IAspect<?, ?> cardAspect) Returns the value of thevariableCardsrecord component.intversion()Returns the value of theversionrecord component.withEntryEnabled(String id, boolean enabled)
-
Field Details
-
VERSION
public static final int VERSION- See Also:
-
SETTING_UPDATE_INTERVAL
- See Also:
-
SETTING_PRIORITY
- See Also:
-
SETTING_CHANNEL
- See Also:
-
SETTING_TARGET_SIDE
- See Also:
-
SETTING_TARGET_OFFSET
- See Also:
-
SETTING_MAX_OFFSET
- See Also:
-
INVENTORY_NAME_ACTIVE
The inventory name under which the active variable inventory of a part is stored. This can not clash with named inventories, as those are derived from resource locations.- See Also:
-
CODEC_PART_SETTINGS
public static final com.mojang.serialization.Codec<PartConfigSnapshot.PartSettings> CODEC_PART_SETTINGS -
CODEC_VARIABLE_CARD
public static final com.mojang.serialization.Codec<PartConfigSnapshot.VariableCard> CODEC_VARIABLE_CARD -
CODEC
-
-
Constructor Details
-
PartConfigSnapshot
public PartConfigSnapshot(int version, net.minecraft.resources.Identifier sourcePartType, Optional<PartConfigSnapshot.PartSettings> partSettings, Map<net.minecraft.resources.Identifier, net.minecraft.nbt.CompoundTag> aspectProperties, List<PartConfigSnapshot.VariableCard> variableCards, Map<PartConfigSection, net.minecraft.nbt.CompoundTag> extraData) A snapshot in which nothing is switched off yet. -
PartConfigSnapshot
public PartConfigSnapshot(int version, net.minecraft.resources.Identifier sourcePartType, Optional<PartConfigSnapshot.PartSettings> partSettings, Map<net.minecraft.resources.Identifier, net.minecraft.nbt.CompoundTag> aspectProperties, List<PartConfigSnapshot.VariableCard> variableCards, Map<PartConfigSection, net.minecraft.nbt.CompoundTag> extraData, List<String> disabledEntries) Creates an instance of aPartConfigSnapshotrecord class.- Parameters:
version- the value for theversionrecord componentsourcePartType- the value for thesourcePartTyperecord componentpartSettings- the value for thepartSettingsrecord componentaspectProperties- the value for theaspectPropertiesrecord componentvariableCards- the value for thevariableCardsrecord componentextraData- the value for theextraDatarecord componentdisabledEntries- the value for thedisabledEntriesrecord component
-
-
Method Details
-
getVariableCards
- Parameters:
sections- The sections that will be pasted.- Returns:
- The variables that this snapshot holds for the given sections.
-
getExtraData
Part types can store anything that this snapshot does not know about itself, such as the state that an addon adds to its own part types.- Parameters:
section- A config section.- Returns:
- What the part type stored for the given section, which is empty if it stored nothing.
-
getRequiredMaxOffset
The offset enhancements that a part holds can not be taken out again without breaking the part, so pasting them has to consume enhancements from the player, just like the variable cards do.- Parameters:
sections- The sections that will be pasted.- Returns:
- The offset enhancement value that pasting those sections needs at most.
-
getRequiredBlankVariables
- Parameters:
sections- The sections that will be pasted.- Returns:
- The number of blank Variable Cards that pasting those sections needs at most.
-
isEnabled
- Parameters:
id- The identifier of an entry.- Returns:
- If that entry is pasted, as opposed to being switched off by the player.
-
withEntryEnabled
- Parameters:
id- The identifier of an entry.enabled- If that entry should be pasted.- Returns:
- A copy of this snapshot in which that entry is switched on or off.
-
getEntries
The entries are what the player switches on and off, so this lists everything that this snapshot holds, whether it is switched on or not.- Returns:
- Everything inside this snapshot, in the order that it is shown in.
-
addAspectEntries
protected void addAspectEntries(ValueDeseralizationContext valueDeseralizationContext, List<PartConfigEntry> entries, @Nullable IPartType<?, ?> partType, net.minecraft.resources.Identifier aspectName, List<PartConfigSnapshot.VariableCard> cards) Add everything that this snapshot holds for one aspect, starting with the card that makes it the aspect that the part uses, followed by its properties, each one directly above the variable that drives it.- Parameters:
valueDeseralizationContext- A value deserialization context.entries- The entries so far.partType- The part type this snapshot was taken from, or null if it is no longer known.aspectName- The unique name of the aspect.cards- The cards of that aspect.
-
variableCardEntry
protected static PartConfigEntry variableCardEntry(PartConfigSnapshot.VariableCard card, @Nullable IAspect<?, ?> cardAspect) - Parameters:
card- A variable card inside this snapshot.cardAspect- The aspect that it drives, if any.- Returns:
- The entry for that card.
-
getVariableCardPropertyKey
@Nullable protected static String getVariableCardPropertyKey(@Nullable IAspect<?, ?> aspect, PartConfigSnapshot.VariableCard card) - Parameters:
aspect- The aspect of a setting variable, if it is known.card- A variable card inside this snapshot.- Returns:
- The name of the property that the card drives, or null if it drives no property.
-
getAspectColor
- Parameters:
aspect- An aspect, or null if the entry belongs to none.- Returns:
- The colour that a part gui shows that aspect in, so that both guis colour the same thing the same way.
-
getVariableCardAspect
@Nullable protected static IAspect<?,?> getVariableCardAspect(@Nullable IPartType<?, ?> partType, PartConfigSnapshot.VariableCard card) - Parameters:
partType- The part type this snapshot was taken from, or null if it is no longer known.card- A variable card inside this snapshot.- Returns:
- The aspect that the card drives, or null if it drives something else than an aspect.
-
getVariableCardGroup
protected static net.minecraft.network.chat.Component getVariableCardGroup(PartConfigSnapshot.VariableCard card, @Nullable IAspect<?, ?> cardAspect) - Parameters:
card- A variable card inside this snapshot.cardAspect- The aspect that it drives, if any.- Returns:
- What the card belongs to, which is empty when the name of the card already says it.
-
getVariableCardLabel
protected static net.minecraft.network.chat.Component getVariableCardLabel(PartConfigSnapshot.VariableCard card, @Nullable IAspect<?, ?> cardAspect) - Parameters:
card- A variable card inside this snapshot.cardAspect- The aspect that it drives, if any.- Returns:
- What the card drives, rather than the name of the card itself.
-
addPartSetting
protected void addPartSetting(List<PartConfigEntry> entries, String setting, Optional<net.minecraft.network.chat.Component> value) -
addPartSetting
protected void addPartSetting(List<PartConfigEntry> entries, String setting, Optional<net.minecraft.network.chat.Component> value, net.minecraft.world.item.ItemStack icon) -
getOffsetEnhancements
public static net.minecraft.world.item.ItemStack getOffsetEnhancements(int maxOffset) - Parameters:
maxOffset- A maximum offset.- Returns:
- The offset enhancements that raising a part to that offset takes.
-
readPropertyValue
protected static net.minecraft.network.chat.Component readPropertyValue(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.CompoundTag property) - Parameters:
valueDeseralizationContext- A value deserialization context.property- One stored aspect property.- Returns:
- The value of that property, in the same compact shape that the part gui shows it in.
-
hasSection
- Parameters:
section- A config section.- Returns:
- If this snapshot holds anything for the given section.
-
hasEnabledPartSetting
-
hasEnabledAspectProperty
protected boolean hasEnabledAspectProperty() -
getSections
- Returns:
- All sections that this snapshot holds something for.
-
isEmpty
public boolean isEmpty()- Returns:
- If this snapshot holds nothing at all.
-
toNBT
public net.minecraft.nbt.CompoundTag toNBT(net.minecraft.core.HolderLookup.Provider provider) - Parameters:
provider- A holder lookup provider, used to serialize the variable cards.- Returns:
- The NBT representation of this snapshot.
-
fromNBT
public static Optional<PartConfigSnapshot> fromNBT(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag tag) - Parameters:
provider- A holder lookup provider, used to deserialize the variable cards.tag- An NBT representation of a snapshot.- Returns:
- The snapshot, or empty if it could not be read.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
version
-
sourcePartType
public net.minecraft.resources.Identifier sourcePartType()Returns the value of thesourcePartTyperecord component.- Returns:
- the value of the
sourcePartTyperecord component
-
partSettings
Returns the value of thepartSettingsrecord component.- Returns:
- the value of the
partSettingsrecord component
-
aspectProperties
Returns the value of theaspectPropertiesrecord component.- Returns:
- the value of the
aspectPropertiesrecord component
-
variableCards
Returns the value of thevariableCardsrecord component.- Returns:
- the value of the
variableCardsrecord component
-
extraData
-
disabledEntries
Returns the value of thedisabledEntriesrecord component.- Returns:
- the value of the
disabledEntriesrecord component
-