-
Notifications
You must be signed in to change notification settings - Fork 551
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
Draft: Feature/replace blockstorage #4036
Draft: Feature/replace blockstorage #4036
Conversation
Your Pull Request was automatically labelled as: "🎈 Feature" |
@@ -86,6 +87,7 @@ public final class SlimefunRegistry { | |||
|
|||
private final Map<UUID, PlayerProfile> profiles = new ConcurrentHashMap<>(); | |||
private final Map<String, BlockStorage> worlds = new ConcurrentHashMap<>(); | |||
private final Map<String, LegacyBlockStorage> legacyWorlds = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will likely be removed since LegacyBlockStorage wont be needed at all.
src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java
Outdated
Show resolved
Hide resolved
A worry I have with this a chunk can hold x amount of data before it resets Minecraft has never solved it only increased the limit. Won’t we run into this problem? |
src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java
Outdated
Show resolved
Hide resolved
import org.bukkit.persistence.PersistentDataType; | ||
import org.bukkit.plugin.Plugin; | ||
|
||
import com.jeff_media.customblockdata.CustomBlockData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs to be the shaded dependency
src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java
Outdated
Show resolved
Hide resolved
src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java
Outdated
Show resolved
Hide resolved
src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java
Outdated
Show resolved
Hide resolved
...main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java
Outdated
Show resolved
Hide resolved
...va/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java
Outdated
Show resolved
Hide resolved
...java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java
Outdated
Show resolved
Hide resolved
...in/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
Outdated
Show resolved
Hide resolved
...n/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java
Outdated
Show resolved
Hide resolved
src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java
Outdated
Show resolved
Hide resolved
src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java
Outdated
Show resolved
Hide resolved
...in/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java
Outdated
Show resolved
Hide resolved
src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/TrashCan.java
Outdated
Show resolved
Hide resolved
...io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java
Outdated
Show resolved
Hide resolved
...ava/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java
Outdated
Show resolved
Hide resolved
...slimefun4/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java
Outdated
Show resolved
Hide resolved
This comment was marked as off-topic.
This comment was marked as off-topic.
...t/slimefun4/implementation/items/electric/machines/accelerators/AnimalGrowthAccelerator.java
Outdated
Show resolved
Hide resolved
...uit/slimefun4/implementation/items/electric/machines/accelerators/CropGrowthAccelerator.java
Outdated
Show resolved
Hide resolved
...uit/slimefun4/implementation/items/electric/machines/accelerators/TreeGrowthAccelerator.java
Outdated
Show resolved
Hide resolved
...scuit/slimefun4/implementation/items/electric/machines/entities/AbstractEntityAssembler.java
Outdated
Show resolved
Hide resolved
import org.bukkit.persistence.PersistentDataType; | ||
import org.bukkit.plugin.Plugin; | ||
|
||
import com.jeff_media.customblockdata.CustomBlockData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably be shadowed import, not the original? Who knows, Java is strange 🤷
Plugin plugin = Slimefun.getPlugin(Slimefun.class); | ||
CustomBlockData blockData = new CustomBlockData(b, plugin); | ||
blockData.set(new NamespacedKey(plugin, "preset"), PersistentDataType.STRING, preset.getID()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert to use BlockStorage.addBlockInfo instead of directly accessing this in such a horrible way
e.printStackTrace(); | ||
return; | ||
} | ||
blockData.set( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
Plugin plugin = Slimefun.getPlugin(Slimefun.class); | ||
CustomBlockData blockData = new CustomBlockData(b, plugin); | ||
blockData.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clear with BlockStorage class directly, dont access CustomBlockData so directly
import org.bukkit.util.io.BukkitObjectInputStream; | ||
import org.bukkit.util.io.BukkitObjectOutputStream; | ||
|
||
public class ItemStackSerializer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI You can literally convert anything with this exact same Class template - just update the ItemStack type to whatever the data type is... crazy
@@ -1,54 +0,0 @@ | |||
package io.github.thebusybiscuit.slimefun4.core.services; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no global key anymore.... so this test is kinda impossible. Maybe there's a better way - you're a smart reviewer, you tell me how to do this cause I'm an idiot :))
@J3fftw1 This is also something I'm a bit weary of. Individual blocks storing their small state here like power should be okay, but my worry is blocks with inventory storage - a whole inventory, even if byte[] is much larger than a single integer. I guess only one way to find out by doing it and then figuring out how much stuff we can fit into a chunk before Paper complains it's >16MB. I think too one of the problems with BlockStorage is everything is stored as a string. PersistentData stuff is much more powerful and can support serialising basically anything to a byte[] and deserialising it back to the original instance without loss (see ItemStackSerializer that's been added). Absolutely open to all thoughts and suggestions on this. |
@SchnTgaiSpock Viewing it in GitHub file change view makes it a bit easier to review it "separately" in my mind. I'm also aware the linter in my IDE has decided imports no longer need to be in blocks, which is annoying and I would not notice without the file change view here. 🤷 You don't have to look at the PR, come back after a week when I have my shit together :)) |
5ece28c
to
641baca
Compare
yeah ok and you pinging me just resubscribed me :)) |
so many reviews why not using formatter in IDEA |
Hey, Thank you so much for putting this up and taking the time to do this! This is an area I've been thinking about a lot lately, I like the general idea but am not sure about the execution. I also want to make sure we start on something smaller first, BS is a huge huge thing (as your PR shows) with a very large consequence when things go wrong. I recommend reading my doc here for my plan: https://github.com/WalshyDev/Slimefun4/blob/e491dda6e5397e5d70366ebdb5eba4082f8c1ffe/docs/adr/0001-storage-layer.md I'd absolutely love your feedback and general help on this, it very much needs to be a collaborative effort and I really appreciate the work put in here. I want to make sure it isn't wasted but that we do it the right way. If you aren't already, I'd recommend joining the Discord, discussion is best done real-time there - https://discord.gg/slimefun |
TBH I'm not really comfortable with using a third-party lib to handle the storage of data, we don't have as much control over the API/etc in that case. |
You could write exactly the same thing again as a Slimefun data storage version if you wanted.... but then again why use built in MC data storage since you don't have control over it's API etc. Seems like a bit of a stupid argument imo. Maybe coming from NodeJS background to me it's more normal to use other dependencies - something like this though I think is perfectly fine to use. |
Definitely not a stupid argument....? It's a valid point regardless of the context. And kinda disrespectful to call it stupid even if it wasn't one. Using any APIs not controlled by ourselves leaves us vulnerable to a lot more breaking changes, unwanted behavior, lack of control over updates, etc etc. We don't know what all we want this api to do which is why Walshy is trying to have those discussions. More than likely there won't be any existing APIs that will fit our needs perfectly or better than something we could create ourselves. This is something that needs to be done collaboratively and the best way to do that is not with a pre-existing dependency, it's with one made by those collaborating. |
As Per Discord, this isn't how contributors want to implement a fixed version of BlockStorage, so not much I can do to help out. Storing block data in SQL is extremely dumb though, and if you do it, I guarantee you're not going to solve any problems - in fact you might even cause more. I eagerly await the updated BlockStorage and hope it fixes the issues I have to deal with on servers I'm playing on. |
All reviews and updates from others welcome on the branch - feel free to open a PR targeting the branch in my repo if you'd like to contribute to this change. It's a big one.
Changes Checklist
Description
BlockStorage causes a lot of problems. Not great performancewise, and can desync stored data so blocks convert to their vanilla counterparts. This is a much needed overhaul, though it will require a lot of testing and reviewing.
Proposed changes
Proposing to use PersistentDataContainer - directly for Chunks to store their Geo-Scan resource status, but also using https://github.com/mfnalex/CustomBlockData for storing data in ALL blocks, not just tile entities. Internally it works by storing the data on the chunk if it has to. This is a much better and more consistent way of storing data.
Related Issues (if applicable)
If we listed issues we'd be here all day.
Checklist
Nonnull
andNullable
annotations to my methods to indicate their behaviour for null values