#Actions when clicking certain blocks
1 messages ยท Page 1 of 1 (latest)
.
okay so, first thing - you wanna listen to the PlayerInteractEvent. It gets fired whennever someone clicks on a block. Now you want to be able to identify your "custom" blocks somehow. You could store a list of the locationns or similar
i'd make a Map<Location, Consumer<PlayerInteractEvent>>
I also have a library that you can use to store data in blocks
e.g. you could just store a boolean like "isThisMyCustomBlock" inside your custo,m diamond blocks
yeah was just about to say that parts a little extensive
oh ye you might use pdc too to identify a block
saving it on the chunk ๐ฅบ
ohhh
yes that one
i forgot alex wrote that
why not? the blocks also gets saved to the chunk ๐
I had that idea in a dream, fr
why doesnt every block has a pdc?
damn good dream
they literally cant sadly
PR it ๐
does the game saves stuff in the pdc or do only plugins save stuff there?
actual game
PDC is purely a bukkit invention
ahh
it internally uses NBT tags called "BukkitValues" for entities and chunks, or "PublicBukkitValues" for ItemMeta
oh ye ive seen that when doing /data entity ...
it's basically a wrapper for PDC stuff. that's also why PDC by default only supports data types that NBT supports
yeah they still write to the actual game files
a PersistentDataContainer is basically a NBT TagCompoundd
never worked with that :D
wouldnt it be TagContainer?
oh
I dont know much about NBT
today was the first time that I used NBT myself
lmao
its work
rly annoying cx
thats why i just use NBTApi
even if i am already using remapped for something
imma use that
yeah but NBT cannot store custom tags on entities
that's why I always go for my beloved PDC
are you sure?
anyway, we kinda hijacked this thread but who cares lol
did you try it today?
yes
he hasnt talked lol
I wrote a huge library for all NBT stuff
iirc
then removed it all again because it didnt save custom tags
Entities and TileEntity NBT
need to be saved directly to chunk when written
or they dont save
I dont know. I just decided to go PDC all the way since that at least properly works for everything
btw @icy estuary have you seen my PDC collections library? ๐
what?
a particle datatype?
sorry im tired and tried making a joke
lol
and grammar got fucked
Can i add PDT to a Particle
if the lib doesnt do that sorry i cant use it
i need to store player data in particles
anyway, I'm extremely proud of this. It allows to do stuff like PersistentDataType<byte[],Map<String,List<ItemStack>>>
๐
omg
why not classify that xD
so you dont have 20 keysets haha xD
seems messy to read those diamon brackets xD
however
this is nice
Map<String,ItemStack> map = pdc.get(someKey, DataType.asMap(DataType.STRING, DataType.ITEM_STACK));
took me days to get this to work lol
just look at it. it's not so bad imho ๐
https://github.com/JEFF-Media-GbR/MorePersistentDataTypes/blob/master/src/main/java/com/jeff_media/morepersistentdatatypes/datatypes/collections/MapDataType.java here's the generic Map datatype
Adds a ton of new PersistentDataTypes, including support for all collections, maps and arrays to the Bukkit API! - MorePersistentDataTypes/MapDataType.java at master ยท JEFF-Media-GbR/MorePersistent...
oh
saved as a byte array ig?
i already looked at it ๐
am I getting hate now? D:
nono
not from me atleast
i expected it to be harder than that
i thought it was gonna be some complex parsing stuff xD
nah
the toPrimitive returns a PDC
not the one im looking at
hot
well no
many things are byte[]
but the collections / maps / array datatypes can be generically created, and they are stored as nested PDC
lmao
that's why it's called MorePersistentDataTypes ๐
go ahead
What are the off chances of storing a runnable or FunctionalInterfave to PDC somehiw
I also thought about that
and came to the conclusion that there is no reason to store runnables
I mean, what's the use case for this?
I think you might be able to just store the Class<?> that references said thing
Store a function for an item
get("thing").run
but that function would have to be hardcoded anyway, so you could also just store sth like an identifier
but yeah I also thought about that, e.g. for inventory GUIs
it would of course be possible to just store the byte[] of the runnable, then turn it back into an object
should be easily possible with a normal Input/Output Stream
Oh no
Streams

I dont need it btw was just curious haha it actually interested me
yeah but I'm bored anyway
I guess, not sure, that one can turn ANY object into a byte array with a regular ByteArrayOutputStream
and vice versa
And it would be for inventory libs that accept dynamic functions for itmens
What about
FunctionalInterfaces?
well the interface itself is not an object
so I doubt that that would somehow work
Yeah you just store the object value of function when you set it
I mean even if you could get a Class<?> object of your interface, how would you use that in your code without having the actual interface as source?
But idk if thats doable
Yeah class wouldn't work on functional interfaces
Cause method needs to be set first
Unless your constructors doing some fuck super() shit
also I think that getting an object from a PDC byte[] is probbably quite shitty for performance. But it's an interesting idea nonetheless ๐
Idea
Hear me out
Dont block me
Store them as strings instead
And parse it back to valid java 
But yeah it prolly wouldn't be best on performance
Especially storing class<?>
You'd need newInstance everytime u want it
I might just do that, just for fun because I love reflection lol
Omg alex
Make it a side project
And like just make a super serious github repo for it
Once it's working post to spigot like you just discovered the wheel
๐
Satire spigot posting
๐
I need a name idea
OmniSerializer
new OmniSerializer<OmniSerializer>(OmniSerializer.class);
OmniSerializer haha
like Omni man
sorry i was sleeping
Did you manage to get far at all on it or was it a big nope
havent checked it out further

