#dev-general

1 messages · Page 313 of 1

old wyvern
#
(f << g)
#

Would be the one we would assume

prisma wave
#

oh yeah

old wyvern
prisma wave
#

ha

#

i'd like to see haskell do that

old wyvern
#

f>>g's haskell equivalent f >>> g and f<<g's haskell equivalent f . g

#

😌

prisma wave
#

ah i didnt know >>> existed

#

nice

#

therefore both languages are good

old wyvern
jovial warren
#

lol

#

I think functional programming definitely has it's uses

#

stuff like Minecraft is not one of them though

old wyvern
#

Why not?

jovial warren
#

because Minecraft requires a hell of a lot of data storage

old wyvern
#

So?

jovial warren
#

and unless your language is good at representing data in memory, you'll have a hard job with Minecraft

old wyvern
#

Im pretty sure that statement is biased towards oop

jovial warren
#

maybe

old wyvern
#

Obviously you wouldnt model your application in the same way

jovial warren
#

yeah

#

but you still have a lot of data to represent

old wyvern
#

No issues with that tho?

jovial warren
#

worlds, dimensions, biomes, players, etc.

old wyvern
#

There still is no issue

jovial warren
#

idk what functional languages are like at storing data

regal gale
#

Suggestion for my nms practice pls?

hot hull
#

You don't even need to use NMS to achieve that, pretty boring

jovial warren
#

take a look at SSB (Superior Skyblock) for examples

jovial warren
#

suppose it varies

prisma wave
#

Functional languages still have records or similar things

old wyvern
#

mhm

jovial warren
#

some do

prisma wave
#

Most do

old wyvern
prisma wave
#

Any language without data types is pretty much useless

jovial warren
#

very true

old wyvern
#

mhm

prisma wave
#

Even more useless than a 100% pure language

jovial warren
#

might as well be assembly if it has no data types lel

#

but even assembly has data types

prisma wave
#

Now you might have a point if you said that games usually require a lot of state changing

#

Although most fp languages have abstractions for this

#

Because ofc state is necessary sometimes

jovial warren
#

also, I'm using bit shifting over multiplication from now on

prisma wave
#

🤨

jovial warren
#

why u no embed

#

multiplication = 1.18ms

#

bit shifting = 1.22us (micro seconds?)

#

almost 1000x faster

hot hull
#

Sadge

prisma wave
#

Oh god that's barely even a microbenchmark

jovial warren
#

that difference may not seem like much, but when that calculation is being performed at least 3 times every time a player moves, that will make a difference

prisma wave
#

those results aren't gonna be remotely accurate

jovial warren
#

at scale, that's the difference between lag and no lag

jovial warren
#

and they produce the same results

#

any optimisation I can get with a packet that you can receive thousands of every second is a good one

prisma wave
#

no but

#

you shouldn't be making changes based on those results

jovial warren
#

well I can try it out with the new algorithm can't I

#

and see if it actually makes a noticeable difference

prisma wave
#

yeah but please for the love of god don't benchmark stuff like that

jovial warren
#

don't benchmark what?

prisma wave
#

anything

old wyvern
#

He means not to benchmark things in the way that you did, not to not benchmark stuff

prisma wave
#

^^

jovial warren
#

ah right

#

is there something wrong with measureTime? or is it that I'm not factoring in all the other stuff?

prisma wave
#

o reinstalling the gradle wrapper fixed my issue btw

#

ez

old wyvern
#

You need to take averages of multiple runs and account for cold start ig

prisma wave
#

^

#

idk much about benchmarking but if you want accurate results you should probably use something like jmh

jovial warren
#

I gotta factor in the list filtering as well

#

that's probably the most expensive thing here

old wyvern
#

wdym?

jovial warren
#

isn't filtering done linearly?

#

it has to linear search, comparing every item to the given predicate, and then remove any items that don't match it

old wyvern
#

Yes obviously, whats the issue with that?

jovial warren
#

linear search is O(n) on the worst case

old wyvern
#

also if you have chains of these sequence operations kotlin does optimize it to a single loop I think

old wyvern
jovial warren
#

and in our case, it's always O(n) isn't it?

old wyvern
#

It is linear time in execution but not linear search

prisma wave
#

the entire operation will run in linear time

jovial warren
#

since it always has to run through all the elements

old wyvern
#

linear search reffers to searching for a particular element in an iteration

jovial warren
#

true

#

okay idk whether I'm doing something wrong here, but I've just used measureTime on two separate operations: ```kotlin
TEST_LIST.filter { it != 2 }
TEST_LIST.asSequence().filter { it != 2 }

#

this is a set of the numbers 1-6

prisma wave
#

literally none of these results are reliable

jovial warren
#

yeah they vary so much

#

and the multiplication time seems to now have magically gone down to micro seconds and nano seconds now wtf

prisma wave
#

obviously

#

multiplication is very fast

jovial warren
#

yeah but before it was milliseconds and micro seconds

#

by adding these two, the other times have now decreased

prisma wave
#

because it's a microbenchmark

#

barely even that

jovial warren
#

what is a microbenchmark?

prisma wave
#

it's not a benchmark

pure arrow
#

how can i get the number of items/string size of a itemstack

old wyvern
prisma wave
#

Some common traps in Java micro-benchmarks are:

writing code that the compiler can deduce does not useful work, and therefore optimize away entirely,
not taking account of the "lumpy" nature of Java memory management, and
not taking account of JVM startup effects; e.g. the time take to load and JIT compile classes, and (conversely) the execution speedup that happens once the methods have been JIT compiled.

jovial warren
#

ah right

lunar cypress
#

Lazy

prisma wave
#

^^

old wyvern
#

There is no terminal operation there xD

prisma wave
#

sequences dont process anything until a terminal operation

#

similar to streams

jovial warren
#

ah right

#

so what would be a terminal operation?

prisma wave
#

toList

#

take

jovial warren
#

forEach?

lunar cypress
#

No not take

prisma wave
#

anything that returns something that isn't a Sequence

#

oh yeah not take my bad

lunar cypress
#

Any reduction

prisma wave
#

first

#

yea

jovial warren
#

what if my case never has any of those?

prisma wave
#

then nothing will happen

jovial warren
#

I filter and throw it into forEach

prisma wave
#

forEach is terminal

old wyvern
#

forEach is terminal

prisma wave
#

lol

old wyvern
#

xD

jovial warren
#

ah

#

using println(it) in a forEach on both still seems to have sequences measured slower, not 100% sure if I trust measureTime though

prisma wave
#

because you shouldn't

jovial warren
#

where do sequences generally perform better btw?

prisma wave
#

lots of intermediary operations

#

lots of filters, maps, etc

jovial warren
#

so if I only have one filter followed by a foreach, then sequences aren't really of use to me

prisma wave
#

they might perform better

#

hard to say without an actual benchmark

#

they probably would if the dataset is big

#

otherwise it's probably not noticable

jovial warren
#

is converting to sequences expensive though?

prisma wave
#

not particularly

jovial warren
#

depends how it does it I suppose

#

kinda wanna see how Mojang does it, out of curiosity lol

#

yeah it does a lot more than this lol

#

also, seems like the bit shift method broke positioning lol

#

just reverted back to the method from wiki.vg and it works fine again, with bit shifting it sometimes works and sometimes doesn't

#

player's heads don't move in the yaw axis yet though, which is frustrating because I believe that may be a separate packet

#

yeah it is

old wyvern
#

@prisma wave arrays from python's array module are dynamic arrays right?

prisma wave
#

afaik

old wyvern
#

alrighty

hot hull
#

Yugi, I played around with the game engine a tad, pretty cool

jovial warren
#

anyone wanna help test this btw?

hot hull
#

Goddamn you Bardy, just closed mc

jovial warren
#

MineKraft 0.5 xD

hot hull
#

Gimme a sec

hot hull
#

I'm gonna start from scratch, cause structure fucked again lmao

jovial warren
#

also, @prisma wave, another reason why I'd rather not have a 33 MB jar is because it takes me like 30 seconds to upload to my server via SFTP every time lol

prisma wave
#

build on the server

jovial warren
#

may not be such a bad idea

#

also, gotta handle disconnects at some point, since atm, you can reconnect and there will be two of you

hot hull
#

Bardy inception

jovial warren
#

kek

hot hull
#

btw, skins are still cucked

#

You're only showing the first layer ;C

jovial warren
#

yeah ik lol

hot hull
#

I need my hat

jovial warren
#

metadata defaults are false for everything

#

not 100% sure why you can't see your own skin stuff though

hot hull
#

You mean the layers

#

Cause I can see my skin just fine

jovial warren
#

yeah

hot hull
#

Also no cape, sadge

jovial warren
#

not sure if it's metadata or something

stuck harbor
#

sneeze imagine having a test server

hot hull
#

Imagine not having a test dedi

jovial warren
#

it's not even a dedi lol

#

it's just my main 2 GB RAM VPS xD

stuck harbor
#

if it compiles, it works on my machine™️

hot hull
#

Mine is cause I speshul

jovial warren
#

I got a dedi for testing on the server I'm head dev for, but that's for use with that server only

hot hull
#

It fucks it hardcore when genning worlds

#

Would be a bitch to gen on a vps lmao

jovial warren
#

eh, we'll see

#

depends what world gen system we use

hot hull
#

Mine :hopefully:

jovial warren
#

if it gens worlds like vanilla then sure

hot hull
#

Will have a vanilla styled world preset as well yea

#

Some day™️

#

Got 1 week of vacation, gonna see if I can get the current shit working by the end of the week

jovial warren
#

also, trying to think of how to fix the repeated code I currently have

#

since I have 3 different methods

hot hull
#

Show

jovial warren
#

one for handling the position packet, one for handling the rotation packet, and one for handling both the position and the rotation

stuck harbor
#

how does one make gradle build on a test server?

#

wait google

jovial warren
stuck harbor
jovial warren
#

actually that reminds me that I gotta extract the whacky algorithm to a function

stuck harbor
#

imma make eclipselang

#

:)

jovial warren
stuck harbor
#

kotlin is m

#

k

hot hull
#

Why not have the handles return the built packet, and then handling it from there

stuck harbor
#

imagine if every word had a vowel in it

#

that would be mad innit

jovial warren
#

you mean handling them by combining them into a PPAR packet?

hot hull
#

I don't know what I mean honestly

jovial warren
#

lol

stuck harbor
#
Kotlin trash
   - BomBardyGamer, Feburary 2021
jovial warren
#

also, btw, if you're wondering what an Angle is, it's basically an unsigned byte that represents an angle measured in 256ths of a full turn

#

using UByte because using Byte was a bit whack sometimes

#

e.g. making a Byte of value 128 would give you a Byte with value -128, which meant that both those values would produce the same result

#

with UByte, we don't worry about any of that whack, since there are no negatives

prisma wave
#

Kotlin trash

jovial warren
#

literally just ```kotlin
/**

  • Represents a protocol angle, measured in 256ths of a full turn
    */
    data class Angle(val value: UByte) : Comparable<Angle> {

    override operator fun compareTo(other: Angle) = if (value == other.value) 0 else if (value < other.value) -1 else 1

    fun toDegrees() = ((value.toFloat() / 256.0f) * 360.0f)
    }

fun Float.toAngle() = Angle(((this / 360.0f) * 256.0f).toInt().toUByte())

jovial warren
prisma wave
#

Inline class you coward

jovial warren
#

difference?

prisma wave
#

Fast

jovial warren
#

never used an inline class before

#

ah, so it allows you to wrap values without having to actually wrap them at runtime

#

it doesn't actually create any instances of the wrapper class

prisma wave
#

the closest thing kotlin has to structs

jovial warren
#

what even are structs?

prisma wave
#

java inline classes > tho

#

value types

#

no object headers

#

just the value

jovial warren
#

also, how are Java's inline classes different?

prisma wave
#

actually native to the JVM

#

Work everywhere

#

Multiple fields

jovial warren
#

ah right

old wyvern
#

Java doesnt have inline classes yet tho right?

jovial warren
#

has Kotlin not quite made them native yet or what?

old wyvern
#

part of valhalla I think

jovial warren
#

ah yeah, it is

hot hull
old wyvern
#

Haskell gang Hype

jovial warren
#

I kinda really wanna see if I can optimise that toAngle algorithm, since division slow lol

prisma wave
jovial warren
#

but I'm not going to bother yet

prisma wave
#

Early stages

old wyvern
#

ah

prisma wave
lunar cypress
hot hull
#

Took you long enough

lunar cypress
#

They simply don't exist after compilation

jovial warren
#

^

old wyvern
#

The wrapper classes still exist in some cases I think

jovial warren
#

for nullables they do

#

but for non-null, nope

#

poof

#

gone

#

not 100% sure if it applies for unsigned types though

#

according to Kotlin bytecode, it still seems to exist though

old wyvern
#

Also generics

prisma wave
#

They aren't actually supported on the JVM, it's just a compiler trick

jovial warren
#

toAngle seems to return a byte though, instead of the wrapper class

#

so they must vanish I guess

lunar cypress
#

Usually when talking about this I focus on the language level

old wyvern
lunar cypress
#

Because I don't really care about implementation detail

prisma wave
#

🥲

#

Yeah

regal gale
#

And I focus on math stuff

#

When I saw toAngle 👀

jovial warren
#

unsigned types are definitely a hack

prisma wave
#

But in comparison to Java's implementation they're not "native" in the same way

old wyvern
#

^

jovial warren
#

it's measured in 256ths of a full turn

lunar cypress
#

Because if you looked at implementation level there would be no differences between jvm languages whatsoever

jovial warren
#

likely to save space by keeping it within a single byte

lunar cypress
#

They'd all have the same feature set by that logic

old wyvern
#

john, have you used numpy's arrays?

jovial warren
#

it is funny how Mojang cares much more about the server's outbound packets than the client's

lunar cypress
#

I have not

jovial warren
#

since the client always sends absolute positions and degree angles

old wyvern
#

ah nvm

#

bsck to googling I guess

jovial warren
#

it's your job to calculate the relative positioning and convert to what I'm going to call "protocol angles"

regal gale
#

All of a sudden I am interested in using ASM bytecode manipulation... without knowing anything at all

jovial warren
#

lol

prisma wave
#

ASM is cool

old wyvern
#

A certain specific port

jovial warren
#

okay, idk whether it's just me, but I seem to be able to tell an ever so slight difference between using an inline class and a data class for the angle, being that head movements seem to be ever so slightly faster and more precise

#

and so, in that case, BM, you have now been promoted to God++

regal gale
#

Bruh how did this happen thonking

#

There's already Go implementation?

old wyvern
#

Where?

regal gale
old wyvern
#

Do mean that there is another one?

regal gale
#

Oh was confused

jovial warren
#

that's the Java one lol

old wyvern
#

Yea thats on the jvm

regal gale
#

I was focused on that lol

jovial warren
#

they want to be able to read JVM bytecode from Go lol

old wyvern
#

write*

prisma wave
old wyvern
#

and read too Ig

prisma wave
#

Manipulate

jovial warren
#

may just be me

#

MineKraft 0.6 is now a thing

#

because I now know how to space out commits a bit better lol

old wyvern
#

Wasnt it 0.4 like an hour ago

jovial warren
#

0.5 yeah

#

0.5 yesterday

#

also, me.bristermitten.minekraft.entity.cardinal, what a package xD

old wyvern
#

Shouldnt* you be going throught 0.5.1 ..ect for minor changes

#

i.e, patches

jovial warren
#

that's not a patch though

#

I added new features

old wyvern
#

Alrighty

jovial warren
#

I added support for player rotation and player position & rotation

#

right, now what next?

hot hull
#

skins pl0x

old wyvern
#

btw frost the components got built. Started building the frost frame

hot hull
#

Neato

#

I thought I had some Carrier Prime relics but I don't

#

Was gonna farm you a set so it picks shit up for you

old wyvern
#

o.o

hot hull
#

You got 100k credits by any chance?

old wyvern
#

yea

#

150k i think

hot hull
#

Go to market and buy Carrier

#

Then build it

old wyvern
#

alrighty

#

Ill play after an hour or something

#

Have a document to write rn

hot hull
#

Imagine having school shit to do

#

As I have like 4 assignments to finish

old wyvern
#

Its not an assignment from uni welp, part of the codechef chapter's work

hot hull
#

ah

old wyvern
hot hull
#

Imma go fuck around with this rendering I guess

jovial warren
#

what is this for?

jovial warren
#

@hot hull figured out why skins aren't showing lel

#

you gotta send a metadata packet with the skin settings sent in client settings

#

this sneaky mother fucker

jovial warren
#

not yet, working on it now lol

#

anyone got any idea if there's an easy way to split an unsigned byte into 8 booleans?

hot hull
#

wow that's dumb, why does groovy not allow variables in

plugins {
}
jovial warren
#

limitations

hot hull
#

lame

jovial warren
#
fun fromProtocol(byte: UByte): SkinFlags {
    val int = byte.toUInt()
    return SkinFlags(
        (int and 0x01u) != 0u,
        (int and 0x02u) != 0u,
        (int and 0x04u) != 0u,
        (int and 0x08u) != 0u,
        (int and 0x10u) != 0u,
        (int and 0x20u) != 0u,
        (int and 0x40u) != 0u
    )
}
```that should work I think
#

and I gotta convert to an int there because otherwise you get some whack where 0x01u and 0u are UInts

#

you can't define bytes like that for whatever reason

heady birch
#

(int.toInt() & 0x01) != 0?

jovial warren
#

yeah that might work, but isn't that a bit wasteful?

heady birch
#

What with the .toInt() ? I'm not sure how kotlin handles it

jovial warren
#

actually what am I on about

#

that'll just get yeeted after it's done

#

oh also, if I have more than one predicate, is it best to call filter twice or just use &&?

lunar cypress
#

if it is a sequence it does not matter

jovial warren
#

it's currently just using the collection method

lunar cypress
#

do you need a filtered collection?

jovial warren
#

I need to just filter a collection and iterate over it's elements

lunar cypress
#

so you don't

jovial warren
#

probably best to make it a sequence and call filter twice then right?

lunar cypress
#

every transformation on a collection is O(n) space complexity

#

so if you only use one filter you save a factor of two

#

sequences should be O(1) space

jovial warren
#

O(1)?

#

how can you filter in O(1)?

lunar cypress
#

space

jovial warren
#

ah right

#

so space complexity is the amount of space it requires then?

#

and then time complexity is how long it takes

lunar cypress
#

time complexity is O(n) in both cases but in contrast to collections multiple transformations on sequences do not factor the steps

jovial warren
#

what's conversion to sequences like?

lunar cypress
#

should be O(1)

jovial warren
#

time complexity?

lunar cypress
#

both time and space

jovial warren
#

right then, sequences it is

lunar cypress
#

but I'd have to double check that

old wyvern
#

yes, It only exists for the compiler in most cases

lunar cypress
#

note that this does not say anything about how long this takes in seconds or similar

old wyvern
#

its simplified into a single loop

jovial warren
#

asSequence just returns Sequence { this.iterator() }

lunar cypress
#

yeah that's constant

jovial warren
#

so O(1) right?

lunar cypress
#

yes

#

big O tells you how the complexity grows with input size

jovial warren
#

yeah

lunar cypress
#

and even though technically both sequences and collections end up with O(n) in time as long as you're doing a constant amount of transformations, sequences are still better in practice because you still reduce the amount of steps by that constant factor

jovial warren
#

yeah

remote goblet
#

So how fast is while(true)

jovial warren
#

O(∞)

old wyvern
#

well, technically O(1)

#

xD

lunar cypress
#

no

#

none

remote goblet
#

so how fast is that smolSadgeSit

#

in actual timeunits

jovial warren
#

doesn't have a time complexity because it's infinite right?

old wyvern
#

Wouldnt it be 1 since there is no external input that affects the execution?

lunar cypress
#

if it doesn't halt at all you can't determine the max. number of steps it takes until it halts

#

no function grows asymptotically faster than infinity because there is no such thing as a function from N -> N that "reaches" infinity

#

or to put it in another way it doesn't make sense to define the "growth" of infinity

jovial warren
#

if I'm only performing a single operation, e.g. filter, followed by map for example, then it's not worth using sequences for that right?

old wyvern
#

Wouldnt the growth of infinity be no growth at all tho

lunar cypress
#

no because infinity is not a constant or a number that abides by any of our rules for natural numbers

remote goblet
#

so in short

#

fast

#

thanks

lunar cypress
#

Maybe someone defined it differently idk, but to me it does not make sense to define

lunar cypress
#

it always depends

jovial warren
#

no it just does filter then map

lunar cypress
#

do you want it as a collection in the end? then for two operations I'd probably do it without a sequence, yeah

#

although it wouldn't hurt

#

and is still technically better because you save a factor of 2 in space

jovial warren
#

seemed to get rid of them lol

lunar cypress
#

keep in mind that with small input lengths factors like that don't really matter all that much

jovial warren
#

right, I need a bit of help figuring something out

#

those all have defaults set

#

now, my issue is that I need both the defaults, but also a way to recognise if we just want to send a single part, or only parts of the metadata, and not the full monty

#

I would do this by making them nullable with a default of null, but then how would you tell the difference between optional metadata and other metadata?

#

e.g. you can send a packet with only 2 out of all the metadata values with no issues, but you also have required and optional metadata, where the difference is that the former must be present and non-null if you choose to send it, whereas the latter you have to send a boolean value indicating whether it's present or not

lunar cypress
#

that's the issue with place oriented programming fingerguns

jovial warren
#

with what?

old wyvern
prisma wave
#

richard 🤤

jovial warren
#

yeah I'm reading the transcript rn

#

well that kinda went right over my head

#

so it's kinda where you have addresses and you can free and allocate those addresses and put and replace things there right?

#

that's what he's talking about

hot hull
jovial warren
#

anyone got any ideas of possible solutions to my issue?

jovial warren
hot hull
#

Yea it's really good

#

Could be better with some polishing, but for a blocky game it's pretty decent

wind patio
#

any linux/unix users here?

jovial warren
#

which kinda unix?

forest pecan
#

unix 🤮

jovial warren
#

Linux is unix-like, but yeah

wind patio
#

yea, just in general

#

shell

forest pecan
#

linux > unix

wind patio
#

judging by this screenshot

jovial warren
#

so you want bash support, not unix support

wind patio
#

can user linadoma write to the directory xz?

jovial warren
#

yes

wind patio
#

then wtf is wrong with my lecturers

jovial warren
#

let me break down those permissions

#

first, we have d, which indicates this is a directory

wind patio
#

yeah, I mean, I understand it, but,

jovial warren
#

then, we have the first rwx, which indicates the read, write and execute flags for the user who owns this

wind patio
#

we had like self assessment test

#

and it says he can't

jovial warren
#

then, we have the second rwx, which indicates the read, write and execute flags for the group of the user who owns this

#

then the third and final set of rwx flags indicate the permissions of other, basically everyone else

regal gale
#

Thanks mojang api for letting me know the actual reason how our MC uuid randomize between Alex and Steve 👀

jovial warren
#

in this case, linadoma can read and write, users can read and execute, and everyone else can read and execute

wind patio
#

yeah, knew most of it, thanks for further explanation though

hot hull
#

Should I be generating the permutation table myself, or should I just be using existing patterns?

jovial warren
#

thinking of having required fields be nullable and optionals using Java's Optional

#

bit ew but it'll work

lunar cypress
jovial warren
#

ah

#

what's my solution then?

lunar cypress
#

This is hard to do in a statically typed language and Kotlin doesn't have a solution for this

#

You have to work your way around it somehow

#

But I wouldn't use Optional

#

rather wrap it yourself somehow

jovial warren
#

I could just make my own optional yeah

#

since the problem with optional is it just sets null values to empty

#

I need an optional that can have 3 states: present and non-null, present and null, or not present

lunar cypress
#

sealed class

jovial warren
#
sealed class Optional<T>

object EmptyOptional : Optional<*>

object NullOptional : Optional<Nothing?>

class PresentOptional<T>(val value: T) : Optional<T>
```?
#

probably a better way to do that

heady birch
jovial warren
heady birch
prisma wave
#

Maybe IO List String

jovial warren
#
sealed class Optional<T>

object EmptyOptional : Optional<Unit>()

object NullOptional : Optional<Nothing?>()

class PresentOptional<T>(val value: T) : Optional<T>()
```or maybe this
#

using unit there seems like a bit of a hack though

heady birch
#

Could you not just use null? Since kotlins null safety stuff im pretty sure isn't zero cost like rust

jovial warren
#

let me explain why null won't work

prisma wave
#

it's pretty much zero cost

jovial warren
#

I need to represent 3 states

#

not just 2

prisma wave
#

but there is a cost because of interop

jovial warren
#

I need to represent when we don't want to send the metadata value, when we want to send a required metadata value (one that must not be null and is not prefixed with a boolean), and when we want to send an optional metadata value (one that needs to be prefixed with a boolean stating whether it's present or not)

forest pecan
hot hull
#

No u

heady birch
#

enum Metadata<T> {
Required {
value: [T]
},
Optional {
value: Option<[T]>
}
}

lunar cypress
#

if that's supposed to be rust idk why you put square brackets there

heady birch
#

Surprisingly, I have never done generics (in rust), I just put together what I remembered, obviously remembered it wrong lol

lunar cypress
#
enum Metadata<T> {
  Required(T),
  Optional(Option<T>),
}```
jovial warren
#

I've thought of a hack that will work for this lol

#

what if I use Java's Optional, but I have not only the optional's value be nullable, but also the optional itself

wind patio
# jovial warren yw

well, I wrote the email to the lecturer
he still says you can't write a file to it since you don't have execute permission

jovial warren
#

you can write to a file, you just can't execute it

#

those are two separate things

jovial warren
#

it's a hack, but it'll work

#

and better than doing whacky casting

lunar cypress
#

it violates the contract of optional and is worse than making a sealed class in every regard

wind patio
jovial warren
#

you can

#

you just can't execute it

#

iirc

lunar cypress
jovial warren
#

like having to cast x to y

prisma wave
#

Pattern matching🙂

lunar cypress
#

and what do you think will you do with optionals? not null check, get, map or whatever?

#

you can implement the same operations on your custom wrapper

jovial warren
#

if optional not null, write optional metadata

wind patio
jovial warren
#

no?

#

actually, he's right

#

that's really weird

lunar cypress
jovial warren
#

because we'd have to check if it's not an instance of NullOptional and then cast to PresentOptional if it's not

lunar cypress
#

no

jovial warren
#

actually I suppose that's not bad

jovial warren
#

right, if in doubt, bring the notchian server out

prisma wave
#

rust enums

jovial warren
#
public static class DataItem<T> {
    private final EntityDataAccessor<T> accessor;
    private T value;
    private boolean dirty;

    public DataItem(EntityDataAccessor<T> param_0, T param_1) {
        this.accessor = param_0;
        this.value = param_1;
        this.dirty = true;
    }

    public EntityDataAccessor<T> getAccessor() {
        return this.accessor;
    }

    public void setValue(T param_0) {
        this.value = param_0;
    }

    public T getValue() {
        return this.value;
    }

    public boolean isDirty() {
        return this.dirty;
    }

    public void setDirty(boolean param_0) {
        this.dirty = param_0;
    }

    public DataItem<T> copy() {
        return new DataItem<T>(this.accessor, this.accessor.getSerializer().copy(this.value));
    }
}
#

sends a list of those

lunar cypress
#

first of all, using the official server as a style guide is not a good idea

jovial warren
#

yeah ik

#

I just wanted to see what it did

#

CrudeIncrementalIntIdentityHashBiMap very nice

#

okay yeah, it has a serialiser per type

#

so it has a different EntityDataSerializer implementation for each of the 19 different types

#

I mean, I should kinda just have this be a list

#

instead of wrapping it all in horrible looking classes

lunar cypress
#

But the point of this is to make an abstraction

#

it's supposed to represent an object

#

If you're writing to the protocol directly you might as well ask why bother doing anything other than just raw bytes

forest pecan
#

DeluxeConcurrentAsyncAbstractTreeCrudeIncrementalIntIdentityHashBiMapImpl

jovial warren
#

also, stuff like this shouldn't really be wrapped in classes anyway

#

since there's just so many metadata flags that will just be repeated in every subclass

#

and it's not like I have to read this anyway

#

I just write it all and send it off

#

also gives me an excuse to use generics 🙂

lunar cypress
#

anyway, just to give an example of what I recommended earlier

#
sealed class Metadata<T> {
    abstract val value: T?
}

class Required<T>(override val value: T) : Metadata<T>() 

class Optional<T>(override val value: T?) : Metadata<T>()```
jovial warren
#

not bad

prisma wave
#

data Metadata t

jovial warren
#

wat?

lunar cypress
#

circlejerk all you want, the real problem behind this is only fixed by something like Clojure

prisma wave
#

🤣

lunar cypress
#

where you just use a map and omission

prisma wave
#

nil

#

Dear clojure users

You claim to fix many programming problems, and yet a function in Clojure cannot be guaranteed to be pure

Curious...

lunar cypress
#

dear haskell users

you claim to have a rich type system, yet you encode every little problem as an own type, distracting from the actual types of your program

jovial warren
#

actually my solution kinda runs into the same issue lol

#

unless I do what Mojang did

#

fuck it, Johnny, I'm using your solution

prisma wave
#

Dear clojure users

You claim types are bad, yet you spend hours debugging vague errors that a statically typed compiler could check within milliseconds

old wyvern
#

😌

obtuse gale
#

Dear programmer:

You suck
Go fuck yourself

jovial warren
#

this is actually kinda nice ngl Johnny

#

one question though

#

how can I deal with knowing whether the user wants to give it a value or sending nothing at all?

#

just use Required? for example?

lunar cypress
#

oh uh

#

you could either make this nullable, or, probably better, add a third "empty" type

#

But currently it should already support everything hold on

#

oh no it doesn't, right

#

yeah it'd need a third variant

jovial warren
#

so just ```kotlin
class Empty<T> : Metadata<T>() {
override val value: Nothing? = null
}

lunar cypress
#

wait but optional metadata values can be absent right

jovial warren
#

yeah

#

but so can required metadata values

lunar cypress
#

oh

#

uh

#

hold on

#

can you also pass null to required?

wicked raft
#

can someone help me to why this doesn't work

package me.blazen.starter;


import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerMoveEvent;

public class SpeedA implements Listener {

    private double lastDist;
    private boolean lastOnGround;

    @EventHandler
    public void onPlayerMove(PlayerMoveEvent e) {
        if (e instanceof PlayerMoveEvent) {
            PlayerMoveEvent event = ((PlayerMoveEvent) e);

            double distX = event.getTo().getX() - event.getFrom().getX();
            double distZ = event.getTo().getZ() - event.getFrom().getZ();
            double dist = (distX * distX) + (distZ * distZ);
            double lastDist = this.lastDist;
            this.lastDist = dist;

            boolean onGround = event.getPlayer().isOnGround();
            boolean lastOnGround = this.lastOnGround;
            this.lastOnGround = onGround;

            float friction = 0.91F;
            double shiftedLastDist = lastDist * friction;
            double equalness = dist - shiftedLastDist;

            Bukkit.broadcastMessage(equalness + "");

        }
    }

}```

 I was following a tutorial for some of it but it didnt have all of it so I did the rest on my own but it doesnt broadcast any messages in my server. I am pretty new to coding plugins so I probably messed something up.
jovial warren
#

that would just make it indistinguishable from Optional though

lunar cypress
#

yeah that's why I'm asking

#

I suppose I don't really understand what "required" means here

jovial warren
#

take a read

lunar cypress
#

to me it sounds like you always need to send it

jovial warren
#

"it is not required to send all metadata fields, or even any metadata fields, so long as the terminating entry is correctly sent"

#

some of those types in that list though are optional, meaning they can be sent but absent

#

some of them must be sent if they are present

lunar cypress
#

oh I would take a different approach here

wicked raft
jovial warren
#

also, what's the purpose of the cast there?

#

you unnecessarily check if the event is a PlayerMoveEvent, when we already know it's a PlayerMoveEvent because that's the type passed to this method

jovial warren
wicked raft
#

that is true

lunar cypress
#

is there an actual meaning to something being null?

#

anywhere

jovial warren
#

wdym?

#

no null values are ever sent

lunar cypress
#

ok

#

then I would do the following

wicked raft
lunar cypress
#

have nullability represent whether something should be sent or not, i.e. null = do not send

#

and for optionality use a sealed class

#

so all of your fields are nullable

jovial warren
#

that was exactly what I was trying to do lol

lunar cypress
#

what's the issue you're facing with that?

jovial warren
#

nothing

#

I just got a bit confused

lunar cypress
#

then I must have misunderstood you in the beginning

#

other than the fact that I still wouldn't use java.util.Optional

jovial warren
#

I suggested using nullable for not sent and a sealed class for optional values

#

actually, I don't even need a sealed class, I just need a class that wraps a nullable value

jovial warren
#

also, can someone who knows more about this than me tell me why you can't use a smart cast on an open property?

old wyvern
jovial warren
#

actually that's not it, but it makes sense now why that occurs

#

iirc, you can override vals with vars

old wyvern
#

huh?

jovial warren
#

or something like that

old wyvern
#

oh right

#

yes

jovial warren
#

it has to have something to do with it being able to be overridden with a mutable property

#

love how I'm complaining now and I haven't even got to the part where most call it quits yet lol

wicked raft
#

@jovial warren is there a way to broadcast what a variable is ```@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
PlayerMoveEvent event = ((PlayerMoveEvent) e);

        double distX = event.getTo().getX() - event.getFrom().getX();
        double distZ = event.getTo().getZ() - event.getFrom().getZ();
        double dist = (distX * distX) + (distZ * distZ);
        double lastDist = this.lastDist;
        this.lastDist = dist;

        boolean onGround = event.getPlayer().isOnGround();
        boolean lastOnGround = this.lastOnGround;
        this.lastOnGround = onGround;

        float friction = 0.91F;
        double shiftedLastDist = lastDist * friction;
        double equalness = dist - shiftedLastDist;
        double scaledEqualness = equalness * 138;


        if (!onGround && !lastOnGround) {
            if (scaledEqualness >= 1.0) {
                Bukkit.broadcastMessage(scaledEqualness + "");
            }
        }
    }``` I want to see what onGround and lastOnGround are to see what they are outputting
jovial warren
#

System.out.println?

#

or just log it?

wicked raft
#

ok

jovial warren
#

you can use the logger from your plugin instance

steel heart
#

PlayerMoveEvent event = ((PlayerMoveEvent) e);

#

why?

jovial warren
#

yeah there's no need to cast there either

#

your IDE should flag that up as a redundant cast

#

he's still learning

#

give him a break guys

wicked raft
#

do I not have to do that?

jovial warren
#

no

wicked raft
#

oh ok

jovial warren
#

casting is when you want to turn one object into another

#

in your case, it's already the object that you're casting to, so there's no point in casting there

#

just rename your parameter name from e to event and you're good

wicked raft
#

ok

prisma wave
#

Hahahaha imagine having casting in your language

#

Good news everyone

#

Go 1.16 added unicode 13.0.0 support

#

Meaning 🥲 is now supported

obtuse gale
#

🥲

jovial warren
prisma wave
#

It's not applicable

jovial warren
#

I have to specify @JvmName there to avoid overload resolution ambiguity

jovial warren
prisma wave
#

Probably cuz it's an extension function

jovial warren
#

but IntelliJ doesn't complain about it, which confuses me

#

if I decompile the bytecode, I can see it applies it correctly

#

and I saw a suggestion to use @JvmName to avoid ambiguity there on StackOverflow

forest pecan
#

ah yes, I can cast door onto door and get door

jovial warren
#

and it's also the suggestion that the official article about Java interoperability suggests

prisma wave
#

let writeOptionalMetadata buf index chat =

#

writeOptionalMetadata :: ByteBuf -> UByte -> Maybe Component -> IO ()

jovial warren
#

stop it

#

that's not helpful

#

you agree though right? this literally makes 0 sense

prisma wave
#

dev-general

#

I suppose

jovial warren
#

trying to think of my options now

prisma wave
#

fn writeOptionalMetadata (buf: &ByteBuf, index: u8, chat: Option<Component>)

jovial warren
#

what are you trying to suggest?

prisma wave
#

Nothing

old wyvern
#

That haskell is superior*

prisma wave
#

Oh yeah that goes without saying

jovial warren
old wyvern
#

bm

prisma wave
#

oui?

old wyvern
#

Can you proof read something I wrote? I wanna make sure not to include any dumb mistakes 😬

prisma wave
#

Sure

ocean quartz
prisma wave
#

😊

jovial warren
#

true

old wyvern
#

Alrighty ill dm it to you in 5 mins

prisma wave
#

Okey

#

(defn writeOptionalMetadata [buf ^ByteBuf index ^byte chat ^Component])

jovial warren
#

I just really don't get it

#

why tf is this not applicable

#

it makes 0 sense

frail glade
#

Good Afternoon smart people.

jovial warren
#

good afternoon Glare

old wyvern
#
extend ByteBuf as buf {
  let writeOptionalMetadata(Byte index, Result<Component> chat) => {
     buf.writeUByte(index)
     if index != 0xFF.toUByte() {
       buf.writeVarInt(MetaDataType.OPTIONAL_CHAT, id)
       buf.writeOptionalChat(chat)
     }
  }
}
forest pecan
#

Pancake King

jovial warren
#

seems to be a Kotlin bug btw, using @Suppress("INAPPLICABLE_JVM_NAME") seems to have fixed it

#

and skins now work

frail glade
#

Ooo that's fancy.

jovial warren
#

@hot hull you can see your own skin now

#

🙂

hot hull
#

Coolio

jovial warren
#

can't see others' skins yet because I'm still working on that, but it's a start

distant sun
#

Is anybody else having issue with iij not being able to access the source of certain library(libraries)?

jovial warren
#

MineKraft is now 0.7 🙂

#

actually not sure if that should've been a patch

#

yeah I'm making that a patch

frail glade
#

MineKraft O.o

prisma wave
jovial warren
frail glade
#

How's that going for ya?

jovial warren
#

actually pretty well

#

you can join into a world with a single 16x16x16 cube of stone

#

you can see other players

frail glade
#

Ooo

ocean quartz
jovial warren
#

more like an infamous book from an infamous fascist dictator

frail glade
#

So what is the benefit of writing a Kotlin implementation for this?

jovial warren
#

just a fun side project

static zealot
#

its kotlin fingerguns xD

jovial warren
#

also will hopefully multithread properly

frail glade
#

Could design it to be a lightweight limbo server?

ocean quartz
#

If done well Coroutines could be a big benefit

old wyvern
#

HasKraft 🔜

jovial warren
#

BM's already spoke about changing the name, but no one can come up with any good ideas lol

static zealot
#

KotlinCraft

distant sun
#

Kraft

obtuse gale
#

K-Craft

static zealot
#

KraftMine

surreal quarry
#

Kraft - Mac and Cheese

jovial warren
#

I kinda want a name that doesn't contain any variation on the words "Kotlin", "Craft" or "Mine"

obtuse gale
#

So nothing that actually hints what the project is about

#

Lmao

static zealot
#

Cleo

distant sun
#

KineMraft

jovial warren
prisma wave
#

F#Craft

ocean quartz
prisma wave
#

We are announcing the addition of the Zombie monad

frail glade
#

So have you done any benchmark testing to see how it runs so far or is it not to that point yet?

jovial warren
#

I might rename that at some point

jovial warren
static zealot
#

Hector Hughes

jovial warren
#

you gotta learn to run before you can walk

#

it hardly functions as a proper Minecraft server yet

#

also, I will rename Komponent at some point if I come up with a better name

frail glade
#

Yo website is down bm

static zealot
#

KraftTheCraft

prisma wave
#

ElmCraft

#

LispCraft

jovial warren
#

what did I say

prisma wave
#

ClojureCraft

prisma wave
#

the root one?

frail glade
#

prev

static zealot
#

Nice Muffin

jovial warren
#

lol

static zealot
#
Minebug
Minekitten```
jovial warren
#

where you getting these? GitHub's name generator?

static zealot
#
Kraftbob
Minebob
prisma wave
frail glade
jovial warren
#

I can't go with the naming scheme of that lel

#

also, that's not his site

#

that's mine

frail glade
#

Yo website is down

jovial warren
#

yeah ik

static zealot
#

insidious restaurant

jovial warren
#

I don't even have one lol

frigid badge
#

'High quality software'

#

lmfao

static zealot
#

:doubt:

jovial warren
#

yeah nothing ever got done with that

ocean quartz
#

Quality

Someone rewrite this for me lol

jovial warren
#

look at what that is

#

also, love how that email address doesn't exist any more either

#

the only Prevarinite emails I have are my personal one, abuse, admin and reports

#

I would revive Prevarinite again, if the members wanted to stick around as well lol

prisma wave
jovial warren
#

also, the naming for that was just "Prevaricate" (my favourite word at the time), and a bit of manipulation, I think from the word "Ignite", which came from a previous project of mine, "Inferno"

#

love how because we're all developers, none of us are good at naming things lol

old wyvern
#

Nah man, it has anything to do with kotlin, we gotta sneak in that K somehow

jovial warren
#

I mean, I personally would be happy to settle on MineKraft, but BM doesn't like it

old wyvern
#

Kongress

surreal quarry
#

Krap

jovial warren
#

also, if you're talking about naming relating to other things, Spigot and Paper for example are two names of projects that have nothing to do with what they're named after

static zealot
#

Khrist

#

MineKhrist

jovial warren
#

no

obtuse gale
#

text

#

adventure

jovial warren
#

oh come on, at least someone here has to be half decent at naming

static zealot
#

double-text

prisma wave
#

Rust

jovial warren
#

@obtuse gale another good example

prisma wave
#

Name it after someone famous

old wyvern
#

We need SpiJot nad Japer

jovial warren
#

I was thinking of naming it after an element on the periodic table

obtuse gale
old wyvern
#

or Pajer

static zealot
#

PopularGameThatIsPopularAndStartsWithMineAndEndsWithCraftWrittenInKotlin

old wyvern
#

idk

prisma wave
#

Name it after someone like famous mathematician Haskell Curry

jovial warren
#

no

static zealot
#

CurryKraft

obtuse gale
#

Samuel L Jackson

old wyvern
#

MineCur

#

MineKell

prisma wave
jovial warren
#

how about Oxide?

static zealot
#

Dioxide

old wyvern
#

How about Peroxide?

prisma wave
#

Michael Jacksoncraft

static zealot
#

kraft*

#

Jacksonkraft

prisma wave
#

Popular Minecraft server implementation "Joe Biden"

jovial warren
#

Ammonium

obtuse gale
#

Robin Williams

old wyvern
#

Or Sodium Bicarbonate Or Benzene-2-4-Dialdehyde

obtuse gale
#

Bryan Adams

jovial warren
#

Cobalt

#

Sulphur

prisma wave
#

What about something that describes the game

obtuse gale
#

Minecraft

old wyvern
#

Make a Cubic shaped carbon chain and name it its IUPAC name fingerguns

prisma wave
#

Like CraftMine or Minecraft or something

prisma wave
jovial warren
#

way too unoriginal

prisma wave
#

🥲

jovial warren
#

come on guys

prisma wave
heady birch
#

KotlinCraft

obtuse gale
#

Lorem Ipsum

jovial warren
#

Lanthanide

prisma wave
#

Intellectual Property Craft

stuck harbor
#

lol

surreal quarry
static zealot
#

MineHQCraft

surreal quarry
#

thats a good name for it

#

PeakockBlueMotnanaSapphire

old wyvern
#

Dolor sit amet

jovial warren
#

ffs guys, can't we just be at least somewhat serious for once in our lives

surreal quarry
#

IronOre

static zealot
#

BoulderKraft

heady birch
#

GoldenAppleMC

static zealot
#

CopperKraft

surreal quarry
#

GoogleKraft

jovial warren
#

I'm spitting out names and everyone's just ignoring them

old wyvern
#

FUNCraft

jovial warren
#

Nitride

prisma wave
#

Copper Wire 0.35mm Enamelled Copper Magnet Wire Round Copper Wiring Bare Copper Wire for Transformer Inductor Coil Relay Motor Coil Winding

surreal quarry
#

AmericaKraft

jovial warren
#

why do I bother asking you lot, honestly

static zealot
#

DigBuild

prisma wave
#

RepublicanCraft

static zealot
#

DrillKraft

jovial warren
#

please just be serious for once

surreal quarry
#

ChinaJoeBiden'sSonCraft

jovial warren
#

fucking hell

prisma wave
#

SleepyJoeCraft

obtuse gale
#

Queen Elizabeth the First of England

surreal quarry
#

Craft™️

obtuse gale
#

^

prisma wave
#

CraftCraft

static zealot
#

IngotCraft

heady birch
#

MineKT ? Or something

jovial warren
#

at this point, I'm just gonna pick the name

old wyvern
obtuse gale
ocean quartz
#

Lmao

old wyvern
#

xD

static zealot
#

OpenPitMiningKraft

prisma wave
old wyvern
#

When they said carbon makes up life, they werent kidding

heady birch
#

PluginnerMc

surreal quarry
#

RavineKraft

ocean quartz
#

NotJavaCraft

prisma wave
#

AmongusCraft

jovial warren
#

right, let's do some ratings

static zealot
#

ProspectingLicenceKraft

old wyvern
#

ElaraCraft

ocean quartz
#

HasKraft

jovial warren
#

I'm gonna throw names, and you guys can rate them

static zealot
#

SedimentaryRockKraft

surreal quarry
#

fuck

prisma wave
#

Lego: Minecraft server implementation

#

Nice

old wyvern
jovial warren
#

Oxygen

prisma wave
#

Elaramooncraft

old wyvern
#

If not, its a -1 from me

prisma wave
#

Me too

static zealot
#

ELARAELARAELARAELARAKRAFTELARA

surreal quarry
#

CarbonDioxideKraftImplementationFactoryGenerator

ocean quartz
prisma wave
#

What about something original like ARALE

#

Craft

jovial warren
#

that's the name of a UK mobile phone company lol

old wyvern
prisma wave
#

H2O2

static zealot
#

ZeusKraft

lunar cypress
#

H1N1

prisma wave
#

Mineplex

surreal quarry
#

O(x^x)

ocean quartz
#

Ozone 😮

forest pecan
#

O(N!!)

static zealot
#

OrthosieKraft

forest pecan
#

O(N!!!!!^N!!!!!)

jovial warren
prisma wave
#

Simon Peyton-Jones craft

static zealot
#

DysnomiaKraft

#

PraxidikeKraft

prisma wave
#

Hickeycraft

static zealot
#

ThrymrKraft

ocean quartz
forest pecan
#

Blitzcraft

jovial warren
#

I'm losing hope in you lot

old wyvern
#

WHAT!

forest pecan
#

LMAO

static zealot
#

BlitzKraft 💯

obtuse gale
#

No need to shout

old wyvern
#

Barry!!

surreal quarry
#

Why are we ruling out AmericaKraft?

forest pecan
#

lol

ocean quartz
lunar cypress
prisma wave
#

BarryCraft

forest pecan
#

barry didnt catch me

#

:)))

static zealot
#

UranusCraft

jovial warren
#

you're all useless, I swear

prisma wave
#

🥲

obtuse gale
prisma wave
#

🥲craft

ocean quartz
#

Omg

forest pecan
static zealot
#

:smiling_face_with_3_tears: craft

surreal quarry
#

Kovid i love it

forest pecan
#

Yugi

#

stop

#

shouting

old wyvern
#

God dammot

forest pecan
#

🙂

prisma wave
#

smiling_face_with_minecraft_server_implementation

jovial warren
#

everyone just stop

ocean quartz
#

Unironically would use Kovid

obtuse gale
#

XD

static zealot
#

S/2003 J9 Kraft

jovial warren
#

that's enough names

forest pecan
prisma wave
#

Pogchampcraft

old wyvern
#

KoviShield

surreal quarry
#

ChessKraft

static zealot
#

NixKraft

old wyvern
#

KKK

surreal quarry
#

PogChampsKraft

#

wait

forest pecan
#

WeirdChampKraft

heady birch
jovial warren
#

you're just taking the piss at this point

forest pecan
obtuse gale
#

FlexTapeCraft

prisma wave
ocean quartz
#

LiquidDryWallCraft

surreal quarry
#

Kraft-beta-rc-alpha-00.1 v0.0.1-Beta

static zealot
#

Margaret Craft

obtuse gale
#

-SNAPSHOT

old wyvern
#

Craft Craft

#

Craft Craft Craft

static zealot
#

KovlinCraft