Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PacketByteBuf: Rename IntArray to VarIntArray #3186

Open
wants to merge 8 commits into
base: 1.19.1
Choose a base branch
from

Conversation

Bixilon
Copy link
Contributor

@Bixilon Bixilon commented May 23, 2022

The name IntArray is quite confusing, I am thinking at 4 bytes, not 1-5 bytes.

Copy link
Contributor

@apple502j apple502j left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, a method reading/writing X should always be called readX or writeX. The var-int part is an implementation detail.

mappings/net/minecraft/network/PacketByteBuf.mapping Outdated Show resolved Hide resolved
@Bixilon
Copy link
Contributor Author

Bixilon commented May 23, 2022

Yes, but imho this is a special case. Minecraft can write ints and var ints. If minecraft only used var ints, then it would be obvious and an implmentation detail. We need to make a clear difference between those two, they might break stuff while reversing the protocol/protocol changes.

@apple502j apple502j added refactor A PR that renames existing names. snapshot A PR that targets a snapshot version of Minecraft impactful A change that is likely to affect some mods. Will require more reviews. labels May 23, 2022
@apple502j
Copy link
Contributor

apple502j commented May 23, 2022

@Bixilon From the user (usually modder, since Fabric is mostly a modding project) perspective, the method's purpose is more important than what it does internally. Even if the method sent the int list by stringifying and concatenating with a space it should still be writeIntList because the method's purpose is to write an int list. (Implementation details are usually written in the javadoc.)

@Bixilon
Copy link
Contributor Author

Bixilon commented May 23, 2022

So, I am mainly using yarn to check the (minecraft) protocol changes between 2 versions. When I see writeIntArray then I immediately check for a real int. After doing that mistake, I need to debug and check, compare, ... That would not be necessary if the name would be clearer on that the method does.

What about writeInt and writeVarInt? Technically that method is used to write an int. The critical difference is in the implementation. The same applies for the list or the array (depite only having 1 method and not method for real ints).

Normally the name should be what the method is used to or what it does. I'd name your example probably writeConcatedList.

@apple502j
Copy link
Contributor

apple502j commented May 23, 2022

@Bixilon writeInt/writeVarInt is named that way only because there are two different methods doing two different things and Java doesn't allow such kinds of overloading (obviously). This time there is only one method. Unless you're checking the raw packet, the information on whether the integer is var or not is useless - and if you're using Yarn for that purpose, javadoc is your friend.

@haykam821 haykam821 added the update-base Add this label to a pull request to automatically change the target branch to the default branch. label May 23, 2022
@github-actions
Copy link
Contributor

🚀 Target branch has been updated to 1.19-pre2

@github-actions github-actions bot changed the base branch from 1.19-pre1 to 1.19-pre2 May 23, 2022 17:38
@github-actions github-actions bot removed the update-base Add this label to a pull request to automatically change the target branch to the default branch. label May 23, 2022
@apple502j apple502j added the update-base Add this label to a pull request to automatically change the target branch to the default branch. label May 25, 2022
@github-actions github-actions bot changed the base branch from 1.19-pre2 to 1.19-pre3 May 25, 2022 14:36
@github-actions
Copy link
Contributor

🚀 Target branch has been updated to 1.19-pre3

@github-actions github-actions bot removed the update-base Add this label to a pull request to automatically change the target branch to the default branch. label May 25, 2022
@liach
Copy link
Contributor

liach commented May 26, 2022

@apple502j: var ints are not simply implementation details. If there's a list of ints like uuid, it's preferable to be written as regular int array given its uniform distribution. var ints are only good if the value is potentially small; if it's uniformly distributed within the range of int/long, regular int or long are more preferable.

@apple502j apple502j added the update-base Add this label to a pull request to automatically change the target branch to the default branch. label May 30, 2022
@github-actions github-actions bot changed the base branch from 1.19-pre3 to 1.19-pre4 May 30, 2022 17:02
@github-actions
Copy link
Contributor

🚀 Target branch has been updated to 1.19-pre4

@github-actions github-actions bot removed the update-base Add this label to a pull request to automatically change the target branch to the default branch. label May 30, 2022
@liach liach requested a review from a team May 31, 2022 13:01
@liach liach added the bug Fixes or discusses a bug within the mappings label May 31, 2022
@apple502j apple502j added the update-base Add this label to a pull request to automatically change the target branch to the default branch. label Jun 1, 2022
@github-actions github-actions bot removed the update-base Add this label to a pull request to automatically change the target branch to the default branch. label Jun 1, 2022
@Bixilon
Copy link
Contributor Author

Bixilon commented Jun 6, 2022

Can we get this before 1.19? (tomorrow)

(then it really might be impactful)

@liach liach requested review from apple502j and modmuss50 June 6, 2022 12:39
@apple502j
Copy link
Contributor

@Bixilon Generally, impactful renames should not be done during pre-release/release candidate phase. That said, if others agree we should merge this now, then I suppose it's fine.

@liach
Copy link
Contributor

liach commented Jun 6, 2022

This isn't really impactful as this is clarifying and there is no fixed-size-int arrays in PacketByteBuf that may cause major confusions.

@haykam821 haykam821 added the update-base Add this label to a pull request to automatically change the target branch to the default branch. label Jun 14, 2022
@github-actions github-actions bot changed the base branch from 1.19-pre5 to 1.19 June 14, 2022 03:27
@github-actions
Copy link
Contributor

🚀 Target branch has been updated to 1.19

@github-actions github-actions bot added release A PR that targets a release version of Minecraft and removed snapshot A PR that targets a snapshot version of Minecraft update-base Add this label to a pull request to automatically change the target branch to the default branch. labels Jun 14, 2022
Copy link
Collaborator

@sfPlayer1 sfPlayer1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the encoding of the length would be an implementation detail that shouldn't affect the name, but the encoding of each element is very functionally relevant and thus should be reflected in the method name.

@Bixilon
Copy link
Contributor Author

Bixilon commented Jul 17, 2022

so...anything here?

@liach liach added the update-base Add this label to a pull request to automatically change the target branch to the default branch. label Jul 17, 2022
@github-actions github-actions bot changed the base branch from 1.19 to 1.19.1-pre5 July 17, 2022 15:13
@github-actions
Copy link
Contributor

🚀 Target branch has been updated to 1.19.1-pre5

@github-actions github-actions bot added snapshot A PR that targets a snapshot version of Minecraft and removed release A PR that targets a release version of Minecraft update-base Add this label to a pull request to automatically change the target branch to the default branch. labels Jul 17, 2022
@haykam821 haykam821 added the update-base Add this label to a pull request to automatically change the target branch to the default branch. label Jul 28, 2022
@github-actions
Copy link
Contributor

🚀 Target branch has been updated to 1.19.1

@github-actions github-actions bot changed the base branch from 1.19.1-pre5 to 1.19.1 July 28, 2022 17:46
@github-actions github-actions bot added release A PR that targets a release version of Minecraft and removed snapshot A PR that targets a snapshot version of Minecraft update-base Add this label to a pull request to automatically change the target branch to the default branch. labels Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes or discusses a bug within the mappings impactful A change that is likely to affect some mods. Will require more reviews. refactor A PR that renames existing names. release A PR that targets a release version of Minecraft
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants