#Packets and shit

1 messages · Page 1 of 1 (latest)

long jewel
#

Is there a way i can reliably calculate entity movement speed with this packet?

When sending it, if I send the value of one block in one packet 4 it is very fast to move the 4 blocks

but splitting the packet distance by half, and spreading it out over every 2 * x ticks x times, the entity moves a lot slower in said direction

Is there some way i can somehow calculate speed with this? Reason being is i need to get when the entity reaches a specific location in the world, and i dont want to rely on a client sending me the information that an entity is at x location for obvious reasons

gilded skiff
#

why do you need to calculate the speed - that is a PlayOut packet no?

#

i think the server does it by sending the location every 50ms, which makes it smooth enough for a client

long jewel
#

Yes, but the issue is say i want to move the entity in one block, sending the on block distance (4096) they move near instantly

#

you can see them move, but its just so fast

long jewel
#

its a client sided entity

#

this is moving the entity half a block each packet

gilded skiff
long jewel
#

yep thats what im setting up right now

gilded skiff
#

oh awesome lol

long jewel
#

its just i need to actually have some way to calculate the speed, reliable if that makes sense

gilded skiff
#

why do you need the speed?

long jewel
#

moveTo(vector, withSpeed);

#

a method like that essentially

#

in normal MC you can effect a entities speed by a single float value

gilded skiff
#

well speed is a scalar quantity so just find the default walk speed in mc

long jewel
#

Its just 1

gilded skiff
#

oh lol

#

does that work?

long jewel
#

well

#

idk how to actually do the math for it, thats my question kek

gilded skiff
#

well, what specifically is the issue?

long jewel
#

i assume i need to break the distance of up into seperate packets, based upon a specific speed divider?

long jewel
#

this is rly hard to explain

gilded skiff
#

id just take the difference between the current and next location, then use the components as the dx, dy, dz and plug that into the formula.

#

oh wait nvm you just need the current and target components for the formula

long jewel
#

Yeah, and another reason i want speed too

#

is sequential order of operations

I only want to send new instructions once current once complete, so waiting until it reached x distance is rather crucial

#

sec im trying to get a video

gilded skiff
#

how does jumping work? does it just go up?

long jewel
long jewel
long jewel
# long jewel

this is what happens when you send the max value (8 blocks) to the packet

#

its just so stupidly fast

#

but if i split the packet into smaller chunks and send them every say, 4 ticks then they move slower

#

so i need some formula to calculate that part there specifically

#

basically:

If I want an entity to move, at the default MC walking speed 2 blocks forward

What divider do I divide Vector(9332, 0, 32768) by (2 blocks) to get a list of Vectors to send to the packet, as well as what interval would they need to get sent at?

#

I think thats the absolute best way ican explain it

#

wait

#

i could do blocks per tick?

#

wait that might work

#

okay i got something kind of down

#

but, unable to figure out some type of formula for the max x 🤔

gilded skiff
#

i’ll take a look in a bit - am out walking

long jewel
#

kk!

#

oh oh

#

think i got it

#

time to test

#

ouu

#

i guess thats about walking speed huh

gilded skiff
long jewel
#

raw NMS

#

well

#

remapped

gilded skiff
#

huh ok

#

didn’t realise there was a static .Pos constructor

long jewel
#

Yeah Col mentioned it yesterday

#

it matches that entity packet position

#

next part is calculating the fall speed when entity walks over air now kek

gilded skiff
#

that will give you like (2, 0, 0)

long jewel
gilded skiff
#

which is the movement vector

long jewel
#

i just wanted to get speed working before i added the actual max, that parts easy

#

because when i did the movement in one packet, it was near instant

#

cause your pathfinding is in block increments, it sent 1, 0, 1 like so and it did stuff like

#

this one sec

#

This is them moving one block specifically using my location - my location + 1 on x and z

which would be, one block

#

and they basically move the one single block instantaneously

long jewel
# long jewel

so i needed them to slow down base on a specific rate thats easily controlled by a number which this seems to do

#

lemme try something and ill brb

gilded skiff
#

but if you can find a way to do that, it would be handy

#

i was looking at splines, but that’s a lot of maths. it’s is conceptually just an algorithm for generating a polynomial close to the path for the points

gilded skiff
#

then you could sample that, but eh it looked a lot of work

grim iris
#

One thing that made me overthink interpolation is like

long jewel
#

I personally like the per block pathfinding, its perfect for mc protocol

grim iris
#

what if we made a 3d algorithm for smooth camera movement

#

where we defined a couple points and it made a round movement set

gilded skiff
# long jewel wym by that?

as in, you give it 3 points and it generates the 0.1 distance locations between them. that could be quite easy if you just want locations between two points actually

long jewel
#

omg

#

its working

#

nvm

#

he ran away

gilded skiff
#

the maths gets out of hand kinda fast, a lot of variables and i find it hard to know how to sample

#

would be cool tho - probably some existing code

gilded skiff
#

oh cool 😎

long jewel
#

Im just making a basic moveTo(x, y, z)

And its going to be just x y z from pathetic points

#

which are, almost always 1, just in a specific direction

#

i was actually thinking about just block per block moving

#

like move(Direction)

#

and it moves the direction one block

#

but for now moveTo

gilded skiff
#

could have a direction enum, but i think it would look nicer broken into smaller intervals

#

rather than like teleporting ahaha

long jewel
#

thats essentially what im trying to do, break the points into smaller

#

the actual speed is fine, but it doesnt respect the destination

#

im running that method every 60 ticks and x y z is my player location

#

and he kinda just:

#

but you can see there he just...

#

walks away lol

gilded skiff
#

he walks through you no?

long jewel
#

thats fine for now

#

ignore all that stuff

#

only his movements, ill work on the gravity and him going through blocks later

#

hes not a real entity so you have to manually do all that

gilded skiff
#

looks good atm tho - i would probably structure the code differently to you but that’s just personal preference :) - i’ll check in #1001384149246038048 tomorrow for any updates ahahah

long jewel
long jewel
#

man this shits hard as fuck

#

why cant anything in mc ever be simple lmao

#

got everything now besides my distance calculations fucked somehow for his movements kek

#

i think its sending too many packets and makes em go over

long jewel
long jewel
#

AYOOOOO

#
[14:35:44 WARN]: [Civilizations] Task #103492 for Civilizations v1.0-SNAPSHOT generated an exception
java.lang.ArithmeticException: / by zero

nOICE

bbl

gilded skiff
long jewel
#

that one was actually broken

#

this one, not :))

#

im working on chunk calculations and redoing the packet sending format

#

ill need to fix rotation of but thats simple

#

i think the hard part is gonna keeping location synced for all players

gilded skiff
#

i think if you do xx+=2 that might look better

#

but yeah looks good

grim iris
#

sure it has some more network overhead but it's simpler than all the cpu stuff you'd do to keep it in sync

gilded skiff
grim iris
#

Other than that, you can also look into lerping rotation like mobs do

#

say like, rotate a max of 5deg / tick

#

you can get the yaw by doing double angleInRad = playerDirection.angle(targetLocation)

long jewel
#

so you increase the speed

long jewel
#

The NPC implements a Navigator class

#

ignore tickRate

grim iris
#

or if you want to do fancy yaw and pitch angles

long jewel
#

cause it does slide a lil at the end

grim iris
#
double xDiff = targetLocation.getX() - entityLocation.getX();
double yDiff = targetLocation.getY() - entityLocation.getY();   
double zDiff = targetLocation.getZ() - entityLocation.getZ();

double distanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff);
double newPitch = Math.acos(yDiff / distanceY) * 180 / Math.PI - 90;
double newYaw = (Math.atan2(zDiff, xDiff) * 180 / Math.PI) - 90;
long jewel
#

yeah i need to figure out yaw and pitch

#

i need a naw before i do tho xD

grim iris
#

sleep is for the weak

gilded skiff
#

@long jewel are you still using Pathetic - or are you just using this vector stuff to walk places

#

cause it would probably be quite easy to use this now for the points you get from pathetic

long jewel
#

pathetic is the end goal

#

but i need to handle a bunch of shit first manually

gilded skiff
#

sounds fun :)))

long jewel
#

saving that in here

grim iris
#

💀

long jewel
#

theres no colllide() method

#

oh

#

collideBoundingBox?

#

wait no thats not block collisions

grim iris
#

might be a paper method

long jewel
#

ah

#

checkInsideBlocks

#

nice mojang

grim iris
#

that's not really the mojang method you're looking for

#

I'll just paste code for the fake-block zombie collision stuff I made on 1.18.1

long jewel
#

oh okay, thought there was just a universal method for collisions ngl xD

#

hooooly

#

ahh

#

it uses so much paper :((

#

okay fuck it

#

imma scratch all this shit

#

and just make a zombie, but send packets to make it apply as a player

#

cba with this math shit z_aCRYYY

grim iris
#

you know you can just copypaste paper's methods and change them

#

collision is kinda specific

#

but it starts by grabbing the entity's aabb and shifting it by the velocity vector

#

then grabs that new AABB and checks for blocks based on their known hitbox

#

if it's air, it don't care

#

if it's a known full block, it makes a full block hitbox

#

otherwise it checks for fancy shapes

long jewel
#

so it just makes everything so much harder lmao

grim iris
#

AABB is an AxisAlignedBoundingBox

#

basically a 3d box that can do collision

long jewel
#

yeah thing is, with a fake ServerPlayer it wouldnt even have one tho, since its not actually spawned in the world

#

it doesnt exist server side

grim iris
#

an aabb is just an object

#

it doesn't care about the entity behind it

#

you can make aabbs whatever size you want

#

this is a shitty 2d representation of an aabb

#

the arrow and "x" indicator are an example of a collision

long jewel
grim iris
#

where you can check for exact collision spots given an incoming vector

long jewel
#

ahh

grim iris
long jewel
#

Wait AABB has direct checking methods Eyes ?

grim iris
#

not really but it has basic ray tracing iirc

#

you can expand and contract the box

#

and its scale will always be the same

#

I mean if you contract only in a certain axis it won't

long jewel
#

I couldnt just use contains on a positional vector on the targets AABB?

#

Or i gotta do all this complex shit

grim iris
#

ehh not really

#

you gotta do complex shit

long jewel
#

Dang :/ probably explains why no client sided server player or entity library exists lmao

Well ty for explaining it to me, its way out of my league math wise, I didn't even pass basic algebra in HS lmfao

long jewel
#

i stand corrected

#

some giga chad did make one

grim iris
#

I hate the HS topics but rest is fine

long jewel
# grim iris math is fun

It really does seem fun but, my brain cant handle it

Yet i can handle 20 different threads at a time while throwing them back onto main for a quick method call then yanking them back async all over the place kek

#

kinda of amazing i made it as far as i did without any math

grim iris
#

I mean

#

I failed trig in math class yet I'm still making particle effects

#

brains are weird

long jewel
#

Ngl im could probably manage together particles

#

Seems a tad bit easier than doing collisions based on the code i saw Eyes

long jewel
#

i got this but f_ew

grim iris
#

Looks accurate

grim iris
long jewel
#

wym re-syncing?

grim iris
#

sending a teleport packet on the start and finish

#

to resync the entity position with what the palyer sees

long jewel
#

i do send it at the very last position but

#

i dont notice it

#

its in that vid

#

for some reason pathfinding it putting blocks in air

#

i idnt do collisions btw

#

i just set the entity to walk on the pathfinder

grim iris
#

oh fun

#

well

#

I'm not gonna look into it for now

#

got out of bed at 5am to setup a minigame map

long jewel
#

ouff xD

grim iris
#

because my homie hasn't set it up for the past 2 weeks

long jewel
long jewel
#

2 weeks?

grim iris
#

yeh

grim iris
long jewel
#

Is this for the NRK?

#

They had a dev working on the same thing a while back 🤔

grim iris
#

idek what the nrk is

#

this is just a side project I picked up for a server like a month or two ago

long jewel
#

ahh

#

NRK Is another server, i know a fwe devs from it and they legit asked for the exact same type of game mode ahaha xD

grim iris
#

ehh

#

this is like

#

95% from scratch

long jewel
#

oh yeah no doubt, just simnilar idea they wanted

grim iris
#

only external plugins I couldn't bother to remake were tab, corpses and protocollib

long jewel
#

NO MATH

#

NO BULLSHIT

#

i just need to lock the pathfinder to lowest y

grim iris
#

That's a bit goofy

#

Zig zagging