-
Notifications
You must be signed in to change notification settings - Fork 11
Changes for more diesel machines #524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
666770a
add disallowAddingItems
LordIdra 7679680
Add new overload
LordIdra 75c7627
just a ton of changes (i forgot to commit until now...)
LordIdra d525bfe
ok i give up on good commit messages
LordIdra c98bdf5
nvm
LordIdra 6da2e79
synthetic
LordIdra 3652c67
Merge branch 'recipe-processor-conversion' into moar-diesel-thingies
LordIdra 71150a7
Merge branch 'recipe-processor-conversion' into moar-diesel-thingies
LordIdra 6565830
Merge branch 'master' into moar-diesel-thingies
LordIdra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
34 changes: 34 additions & 0 deletions
34
...core/src/main/kotlin/io/github/pylonmc/pylon/core/datatypes/DurationPersistentDataType.kt
This file contains hidden or 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,34 @@ | ||
| package io.github.pylonmc.pylon.core.datatypes | ||
|
|
||
| import io.github.pylonmc.pylon.core.util.position.BlockPosition | ||
| import io.github.pylonmc.pylon.core.util.pylonKey | ||
| import io.papermc.paper.command.brigadier.argument.ArgumentTypes.world | ||
| import org.bukkit.persistence.PersistentDataAdapterContext | ||
| import org.bukkit.persistence.PersistentDataContainer | ||
| import org.bukkit.persistence.PersistentDataType | ||
| import java.time.Duration | ||
|
|
||
| object DurationPersistentDataType : PersistentDataType<PersistentDataContainer, Duration> { | ||
| val secondsKey = pylonKey("seconds") | ||
| val nanosKey = pylonKey("nanos") | ||
|
|
||
| override fun getPrimitiveType(): Class<PersistentDataContainer> = PersistentDataContainer::class.java | ||
|
|
||
| override fun getComplexType(): Class<Duration> = Duration::class.java | ||
|
|
||
| override fun fromPrimitive( | ||
| primitive: PersistentDataContainer, | ||
| context: PersistentDataAdapterContext | ||
| ): Duration { | ||
| val seconds = primitive.get(secondsKey, PersistentDataType.LONG)!! | ||
| val nanos = primitive.get(nanosKey, PylonSerializers.INTEGER)!! | ||
| return Duration.ofSeconds(seconds, nanos.toLong()) | ||
| } | ||
|
|
||
| override fun toPrimitive(complex: Duration, context: PersistentDataAdapterContext): PersistentDataContainer { | ||
| val pdc = context.newPersistentDataContainer() | ||
| pdc.set(secondsKey, PersistentDataType.LONG, complex.seconds) | ||
| pdc.set(nanosKey, PersistentDataType.INTEGER, complex.nano) | ||
| return pdc | ||
| } | ||
| } |
This file contains hidden or 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
42 changes: 42 additions & 0 deletions
42
.../src/main/kotlin/io/github/pylonmc/pylon/core/datatypes/ProgressItemPersistentDataType.kt
This file contains hidden or 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,42 @@ | ||
| package io.github.pylonmc.pylon.core.datatypes | ||
|
|
||
| import io.github.pylonmc.pylon.core.util.gui.ProgressItem | ||
| import io.github.pylonmc.pylon.core.util.position.BlockPosition | ||
| import io.github.pylonmc.pylon.core.util.pylonKey | ||
| import io.github.pylonmc.pylon.core.util.setNullable | ||
| import io.papermc.paper.command.brigadier.argument.ArgumentTypes.world | ||
| import org.bukkit.persistence.PersistentDataAdapterContext | ||
| import org.bukkit.persistence.PersistentDataContainer | ||
| import org.bukkit.persistence.PersistentDataType | ||
|
|
||
| object ProgressItemPersistentDataType : PersistentDataType<PersistentDataContainer, ProgressItem> { | ||
| val itemStackKey = pylonKey("item_stack") | ||
| val countDownKey = pylonKey("count_down") | ||
| val totalTimeKey = pylonKey("total_time") | ||
| val progressKey = pylonKey("progress") | ||
|
|
||
| override fun getPrimitiveType(): Class<PersistentDataContainer> = PersistentDataContainer::class.java | ||
|
|
||
| override fun getComplexType(): Class<ProgressItem> = ProgressItem::class.java | ||
|
|
||
| override fun fromPrimitive( | ||
| primitive: PersistentDataContainer, | ||
| context: PersistentDataAdapterContext | ||
| ): ProgressItem { | ||
| val stack = primitive.get(itemStackKey, PylonSerializers.ITEM_STACK)!! | ||
| val countDown = primitive.get(countDownKey, PylonSerializers.BOOLEAN)!! | ||
| val item = ProgressItem(stack, countDown) | ||
| item.totalTime = primitive.get(totalTimeKey, PylonSerializers.DURATION) | ||
| item.progress = primitive.get(progressKey, PylonSerializers.DOUBLE)!! | ||
| return item | ||
| } | ||
|
|
||
| override fun toPrimitive(complex: ProgressItem, context: PersistentDataAdapterContext): PersistentDataContainer { | ||
| val pdc = context.newPersistentDataContainer() | ||
| pdc.set(itemStackKey, PylonSerializers.ITEM_STACK, complex.itemStackBuilder.stack) | ||
| pdc.set(countDownKey, PylonSerializers.BOOLEAN, complex.countDown) | ||
| pdc.setNullable(totalTimeKey, PylonSerializers.DURATION, complex.totalTime) | ||
| pdc.set(progressKey, PylonSerializers.DOUBLE, complex.progress) | ||
| return pdc | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.