mfnalex / customblockdata Goto Github PK
View Code? Open in Web Editor NEWProvides a PersistentDataContainer for every Block location
License: GNU General Public License v3.0
Provides a PersistentDataContainer for every Block location
License: GNU General Public License v3.0
I am attempted to clear all the blockdata for certain blocks that previously had data set in them, however I did some testing and it seems that after calling the clear method, all of the values are still there and persisting in the chunk.
code where i clear it:
System.out.println("Clearing data");
jukeboxData.clear();
System.out.println("Is data empty: " + jukeboxData.isEmpty());
System.out.println("UUID key: " + jukeboxData.get(Keys.OWNER, new UUIDDataType()));
output:
[13:21:05] [Server thread/INFO]: Clearing data
[13:21:05] [Server thread/INFO]: Is data empty: false
[13:21:05] [Server thread/INFO]: UUID key: 2357f9da-38ee-49ad-a1f1-2440199000ef
pros of which is high memory usage if using it on a lot of blocks
it's a new HashMap<>() for every single block, developers don't usually see it this way
and this will cause extremely high memory usages, since this is a library it's good to show them that it's not "good" to use on thousands of blocks... (It's a new HashMap<>() for every single block).
IT creates a new persistent data container to every single block that gets set
this means
it'll allocate a keyspace on the map of teh chunk + create a new full key space for each block:
this is how it ends up being like:
Map<NameKey, PersistContainer>
and each perssist data container has a new Map.
It would be nice to tell the devs about this, reverting the damage frmo this library if used on a lot of spots it's bad.
I've noticed that for blocks like cactus where when the bottom block get's broken all the cactus blocks above break, the data will not get removed from the block and stays there until something is either placed in it's location or it is manually removed. To fix this I suggest getting the cactus blocks above the broken cactus and removing data from them if they have any.
When using this on 1.20.1, the data does not seem to persist when the block gets moved. I've tried using the example plugin but I cannot seem to build it anymore. The dependency in it's pom is outdated and modifying it to the newer version just causes mismatching imports which I really don't want to fix.
I'm setting the container on a block of TNT, then requesting the data when it gets ignited during the TNTPrimeEvent. The data doesn't end up existing anymore when I retrieve it after it has been moved. When I retrieve it without the tnt moving at all from it's initial location, it still exists.
Code I use to set the data. I have confirmed this code is ran to set it.
val container = CustomBlockData(bukkitBlock, MissileWars.instance)
val key = NamespacedKey(MissileWars.instance, "owner")
container.set(key, PersistentDataType.STRING, user.player.uniqueId.toString())
Code I use to retrieve the data
@EventHandler
private fun onEntityIgnite(event: TNTPrimeEvent) {
val block = event.block
val container = CustomBlockData(block, MissileWars.instance)
val key = NamespacedKey(MissileWars.instance, "owner")
if (!container.has(key)) {
return
}
val owner = container.get(key, PersistentDataType.STRING)!!
// Additional code not relevant here
}
Not sure if this is from the library itself or just my bad maven skills, but pasting all the shadowing/repo/dependency stuff and changing it doesn't seem to want to actually shadow. In IntelliJ, the IDE recognizes the dependency, but after building, I get the NoClassDefFound error. My guess is its just an IntelliJ setting, but still making the issue just in case
When applying data to the head of a sticky piston while it is extended, it will transfer this data to the block it pulls in.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.