forked from RS485/LogisticsPipes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test commit: Satellite name will store in module instead of pipe, all…
…ow it to be stored properly on early loading stage.
- Loading branch information
1 parent
4d3c4e3
commit bdd1aba
Showing
4 changed files
with
96 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/api/kotlin/network/rs485/logisticspipes/property/StringProperty.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2023 RS485 | ||
* | ||
* "LogisticsPipes" is distributed under the terms of the Minecraft Mod Public | ||
* License 1.0.1, or MMPL. Please check the contents of the license located in | ||
* https://github.com/RS485/LogisticsPipes/blob/dev/LICENSE.md | ||
* | ||
* This file can instead be distributed under the license terms of the | ||
* MIT license: | ||
* | ||
* Copyright (c) 2023 RS485 | ||
* | ||
* This MIT license was reworded to only match this file. If you use the regular | ||
* MIT license in your project, replace this copyright notice (this line and any | ||
* lines below and NOT the copyright line above) with the lines from the original | ||
* MIT license located here: http://opensource.org/licenses/MIT | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
* this file and associated documentation files (the "Source Code"), to deal in | ||
* the Source Code without restriction, including without limitation the rights to | ||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
* of the Source Code, and to permit persons to whom the Source Code is furnished | ||
* to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Source Code, which also can be | ||
* distributed under the MIT. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package network.rs485.logisticspipes.property | ||
|
||
import net.minecraft.nbt.NBTTagCompound | ||
|
||
class StringProperty(initialValue: String, override val tagKey: String, override val oldTagKey: String) : ValueProperty<String>(initialValue) { | ||
|
||
constructor(initialValue: String, tagKey: String) : this(initialValue, tagKey, "") | ||
|
||
override fun readFromNBT(tag: NBTTagCompound) { | ||
if (!oldTagKey.isEmpty() && tag.hasKey(oldTagKey)) value = tag.getString(oldTagKey) | ||
else if (tag.hasKey(tagKey)) value = tag.getString(tagKey) | ||
} | ||
|
||
override fun writeToNBT(tag: NBTTagCompound) = tag.setString(tagKey, value) | ||
|
||
override fun copyValue(): String = value | ||
|
||
override fun copyProperty(): StringProperty = StringProperty(copyValue(), tagKey) | ||
|
||
fun isEmpty(): Boolean = value.isEmpty() | ||
|
||
} |