#Actions when clicking certain blocks

1 messages ยท Page 1 of 1 (latest)

ancient marten
#

.

#

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

pseudo tiger
#

i'd make a Map<Location, Consumer<PlayerInteractEvent>>

ancient marten
#

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

icy estuary
#

yeah was just about to say that parts a little extensive

pseudo tiger
#

oh ye you might use pdc too to identify a block

pseudo tiger
#

saving it on the chunk ๐Ÿฅบ

ancient marten
icy estuary
#

yes that one

#

i forgot alex wrote that

ancient marten
icy estuary
#

fuckyoualexwhycouldntidiscoverthatfirst

#

jkjk

#

< 3

ancient marten
#

I had that idea in a dream, fr

pseudo tiger
#

why doesnt every block has a pdc?

icy estuary
#

damn good dream

icy estuary
ancient marten
icy estuary
#

they dont extend PersistantContainer thingy

#

oh god

pseudo tiger
#

does the game saves stuff in the pdc or do only plugins save stuff there?

ancient marten
pseudo tiger
#

ahh

ancient marten
#

it internally uses NBT tags called "BukkitValues" for entities and chunks, or "PublicBukkitValues" for ItemMeta

pseudo tiger
#

oh ye ive seen that when doing /data entity ...

ancient marten
#

it's basically a wrapper for PDC stuff. that's also why PDC by default only supports data types that NBT supports

icy estuary
#

yeah they still write to the actual game files

ancient marten
#

a PersistentDataContainer is basically a NBT TagCompoundd

icy estuary
#

^^

#

well

pseudo tiger
#

never worked with that :D

icy estuary
#

wouldnt it be TagContainer?

ancient marten
#

"basically"

#

erm maybe

icy estuary
#

oh

ancient marten
#

I dont know much about NBT

icy estuary
#

TagContainer deprected

#

since when

ancient marten
#

today was the first time that I used NBT myself

icy estuary
#

DeprecatedCustomTagContainer ๐Ÿ˜

#

they deprecate it :((

ancient marten
#

lmao

icy estuary
#

rly annoying cx

#

thats why i just use NBTApi

#

even if i am already using remapped for something

#

imma use that

ancient marten
#

yeah but NBT cannot store custom tags on entities

#

that's why I always go for my beloved PDC

icy estuary
#

are you sure?

ancient marten
#

anyway, we kinda hijacked this thread but who cares lol

icy estuary
#

did you try it today?

ancient marten
icy estuary
ancient marten
#

I wrote a huge library for all NBT stuff

icy estuary
ancient marten
#

then removed it all again because it didnt save custom tags

icy estuary
#

Entities and TileEntity NBT

#

need to be saved directly to chunk when written

#

or they dont save

ancient marten
#

I dont know. I just decided to go PDC all the way since that at least properly works for everything

icy estuary
#

yeah since 1.14 thats all ive used

#

nbt is useless mostly now a days since pdt added

ancient marten
#

btw @icy estuary have you seen my PDC collections library? ๐Ÿ˜›

icy estuary
#

i have nor

#

cant i make pdt Particle?

ancient marten
#

what?

#

a particle datatype?

icy estuary
#

sorry im tired and tried making a joke

ancient marten
#

lol

icy estuary
#

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

ancient marten
ancient marten
icy estuary
#

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

ancient marten
#
Map<String,ItemStack> map = pdc.get(someKey, DataType.asMap(DataType.STRING, DataType.ITEM_STACK));
#

took me days to get this to work lol

icy estuary
#

primitive map parsing

#

:c

#

i wonder how bad that was to impl lol

ancient marten
#

just look at it. it's not so bad imho ๐Ÿ˜„

icy estuary
#

oh

pseudo tiger
#

saved as a byte array ig?

icy estuary
#

you just stored as byte array

#

yep

pseudo tiger
#

i already looked at it ๐Ÿ™„

icy estuary
#

yeah i just now looked at it

#

sorry im not fast :(((

ancient marten
#

am I getting hate now? D:

icy estuary
#

nono

pseudo tiger
#

not from me atleast

icy estuary
#

i expected it to be harder than that

ancient marten
#

it's not a byte array btw

#

it's a PersistentDataContainer

icy estuary
#

i thought it was gonna be some complex parsing stuff xD

ancient marten
#

nah

icy estuary
#

nono

#

your toPrimitive methods

ancient marten
#

the toPrimitive returns a PDC

icy estuary
#

not the one im looking at

pseudo tiger
#

hot

ancient marten
#

what are you looking at, then ๐Ÿ˜„

#

ooh yeah a boolean array is just a byte array

icy estuary
#

oh

#

so i just looked at the only one that was byte array lmfao

#

unlucky

ancient marten
#

well no

#

many things are byte[]

#

but the collections / maps / array datatypes can be generically created, and they are stored as nested PDC

icy estuary
#

i wonder if anyones will ever ask you to store plugin instances

ancient marten
#

lmao

icy estuary
#

thats a lot of types

ancient marten
#

that's why it's called MorePersistentDataTypes ๐Ÿ˜„

icy estuary
#

Actually alex

#

I have a suggestion

#

And you might like it

ancient marten
#

go ahead

icy estuary
#

What are the off chances of storing a runnable or FunctionalInterfave to PDC somehiw

ancient marten
#

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?

icy estuary
#

I think you might be able to just store the Class<?> that references said thing

icy estuary
#

get("thing").run

ancient marten
#

but that function would have to be hardcoded anyway, so you could also just store sth like an identifier

icy estuary
#

Yeah probably

#

Imma pr it

ancient marten
#

but yeah I also thought about that, e.g. for inventory GUIs

icy estuary
#

Just to be annoying

#

My GUI is a wrapped item stack

ancient marten
#

it would of course be possible to just store the byte[] of the runnable, then turn it back into an object

icy estuary
#

With a functional interface for interactions

Pdc didnt see right at the time

#

Oh fr?

ancient marten
#

should be easily possible with a normal Input/Output Stream

icy estuary
#

Oh no

#

Streams

#

I dont need it btw was just curious haha it actually interested me

ancient marten
#

yeah but I'm bored anyway

icy estuary
#

Cause if it existed I was gonna think on using it

#

It would be useful in one usecase

ancient marten
#

I guess, not sure, that one can turn ANY object into a byte array with a regular ByteArrayOutputStream

#

and vice versa

icy estuary
#

And it would be for inventory libs that accept dynamic functions for itmens

#

What about

#

FunctionalInterfaces?

ancient marten
#

well the interface itself is not an object

#

so I doubt that that would somehow work

icy estuary
#

Yeah you just store the object value of function when you set it

ancient marten
#

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?

icy estuary
#

But idk if thats doable

icy estuary
#

Cause method needs to be set first

#

Unless your constructors doing some fuck super() shit

ancient marten
#

also I think that getting an object from a PDC byte[] is probbably quite shitty for performance. But it's an interesting idea nonetheless ๐Ÿ˜„

icy estuary
#

Idea

#

Hear me out

#

Dont block me

#

Store them as strings instead

#

And parse it back to valid java aussieKekw

#

But yeah it prolly wouldn't be best on performance

#

Especially storing class<?>

#

You'd need newInstance everytime u want it

ancient marten
#

I might just do that, just for fun because I love reflection lol

icy estuary
#

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

ancient marten
#

๐Ÿ˜„

#

I need a name idea

#

OmniSerializer

#

new OmniSerializer<OmniSerializer>(OmniSerializer.class);

icy estuary
#

like Omni man

#

sorry i was sleeping

#

Did you manage to get far at all on it or was it a big nope

ancient marten
#

havent checked it out further