#Entity metadata

1 messages ยท Page 1 of 1 (latest)

lost ruin
#

Let's move this to a thread

spare lodge
lost ruin
#

And I'll have to write a full explanation here

#

You need to split your logic into multiple packets

#

Notice how this format is for the entity metadata packet?

#

Well you shouldn't try writing it in the spawn packet

spare lodge
#

like this ?

lost ruin
#

that's my guide..

spare lodge
#

yes

#

that's what I'm following

lost ruin
#

In 1.19+ I wouldn't recommend the EasyMetadataPacket utility class

#

Because you can do it natively

spare lodge
lost ruin
#

It does

#

It's on the gist

spare lodge
#

on the gist ?

lost ruin
#

Read the comments

spare lodge
#

okay

lost ruin
#

That's enough for you to work with

spare lodge
#

okay thanks ๐Ÿ‘

#

hum

#

another thing

#

how can I attach the metadata to the entity ?

#

oh found packet.getIntegers().write(0, entityId);

spare lodge
lost ruin
#

๐Ÿ™ you need a new pair of eyes

#

The gist is linked on that tutorial

spare lodge
#

My server will no longer burn with my customBlocks

spare lodge
#

oh well

#

yellow on white isn't easy to see LUL

lost ruin
#

I got no clue which one of my guides that is

#

Found it nvm

#

I got 3 packet guides

#

looks fine on black

spare lodge
lost ruin
#

Yeah

lost ruin
#

Update protocollib

spare lodge
#

okay

#

okay thanks

#

so, I "made" this:```java
public static void sendMetadataPacket(int entityId){
// https://wiki.vg/Entity_metadata#Entity_Metadata_Format
PacketContainer metadata = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);

List<WrappedDataValue> dataValues = List.of(
new WrappedDataValue(11, WrappedDataWatcher.Registry.get(Vector3f.class), new Vector3f(1.0002f, 1.0002f, 1.0002f)),
new WrappedDataValue(12, WrappedDataWatcher.Registry.get(Quaternionf.class), new Quaternionf(0.0f, 0.0f, 0.0f, 1.0f)),
new WrappedDataValue(13, WrappedDataWatcher.Registry.get(Quaternionf.class), new Quaternionf(0.0f, 0.0f, 0.0f, 1.0f)),
new WrappedDataValue(15, WrappedDataWatcher.Registry.get(Object.class), (15 << 4) | (15 << 20)),
new WrappedDataValue(22, WrappedDataWatcher.Registry.get(Integer.class), octalToDecimal("01010100"))
);

metadata.getIntegers().write(0, entityId);
metadata.getDataValueCollectionModifier().write(0, dataValues);

ProtocolLibrary.getProtocolManager().broadcastServerPacket(metadata);
}```

#

let's try ๐Ÿคž

lost ruin
#

that Object.class won't work

#

also that octalToDecimal yikes

#

just do 0b01010100

spare lodge
spare lodge
lost ruin
#

what does it say on the metadata format

spare lodge
#

in quotes ?

#

15 VarInt Brightness override (blockLight << 4 | skyLight << 20) -1

#

so it is an Integer ?

lost ruin
#

So yeah it's an int

spare lodge
#

I did this at 1A.M yesterday, looks like I was sleepy

spare lodge
lost ruin
#

why are you passing a string

spare lodge
lost ruin
#

Yeah you got no clue

spare lodge
#

what is the type of 0b01010100 ?

#

byte ?

lost ruin
#

This is part of the java basics

spare lodge
#

๐Ÿ˜…

lost ruin
#

But numbers in java are represented in a few ways

spare lodge
#

I know double, float, int and byte

lost ruin
#

12345 (decimal)
0xAF (hex)
0123123 (octal, starts with a 0)
0b101010101 (binary)

spare lodge
#

so it's octal

#

so it's binary

lost ruin
#

yes

spare lodge
#

but with a b wtf

lost ruin
#

0b

#

0x

#

0

spare lodge
lost ruin
#

it's an int

#

int joe = 0b10101010

spare lodge
#

oh well okay

#

okay thanks

lost ruin
#

int mamma = 0x123123FF

#

int deez = 012312356; // octal

#

etc

#

You get the idea

spare lodge
#

yes thanks

spare lodge