Skip to content

Commit

Permalink
Merge pull request #4 from MisledWater79/main
Browse files Browse the repository at this point in the history
Update Raknet start.md
  • Loading branch information
theaddonn authored Nov 12, 2024
2 parents 60b2fb5 + a52a1ca commit 8c64d52
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 17 deletions.
111 changes: 111 additions & 0 deletions docs/.vitepress/theme/CustomLayout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<script setup lang="ts">
import DefaultTheme from 'vitepress/theme';
import { useData } from "vitepress";
import { ref, watch, onMounted } from "vue";
const { Layout } = DefaultTheme;
const { frontmatter } = useData();
const contributors = ref([]);
async function getGitHubAuthor(login) {
const headers = {
...(!!import.meta.env.GITHUB_TOKEN && {
Authorization: `Bearer ${import.meta.env.GITHUB_TOKEN}`,
}),
};
try {
const res = await fetch(`https://api.github.com/users/${login}`, { headers });
if (res.ok) {
return await res.json();
} else {
console.error(`Failed to fetch GitHub user: ${login}`);
return null;
}
} catch (e) {
console.error(e);
return null;
}
}
async function getContributors() {
if (!Array.isArray(frontmatter.value.mentions)) return [];
const contributorsList = [];
for (const login of frontmatter.value.mentions) {
const user = await getGitHubAuthor(login);
if (user) contributorsList.push(user);
}
return contributorsList;
};
watch(frontmatter, async () => {
contributors.value = await getContributors();
});
onMounted(async () => {
contributors.value = await getContributors();
});
</script>

<template>
<Suspense>
<Layout>
<template v-if="frontmatter.Layout != 'home'" #doc-footer-before>
<hr style="margin: 16px 0; border: none; border-top: 1px solid var(--vp-c-divider);">
<h2 class="contributors" style="font-size: large; font-weight: 600;">Contributors</h2>
<div v-if="contributors.length > 0" class="contributors">
<a
v-for="contributor in contributors"
:key="contributor.login"
:href="contributor.html_url"
:alt="contributor.login"
target="_blank"
rel="noopener noreferrer"
>
<img :src="contributor.avatar_url" :alt="contributor.login" :title="contributor.login" />
</a>
</div>
<div v-else>No contributors found.</div>
</template>
</Layout>
</Suspense>
</template>

<style lang="css">
.contributors {
a {
display: inline-block;
background-color: var(--bg-color);
border: var(--border);
border-radius: 50%;
overflow: hidden;
line-height: 1;
margin-inline: 0.2em -0.6em;
transition-delay: 0.1s;
transition:
margin 0.2s,
transform 0.2s;
img {
width: 2em;
height: 2em;
vertical-align: middle;
}
&:hover {
transform: translateY(-0.3em);
}
}
&:hover,
&:focus-within {
a {
margin-right: 0.2em;
}
}
}
</style>
7 changes: 2 additions & 5 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import { h } from 'vue'
import type { Theme } from 'vitepress'
import DefaultTheme from "vitepress/theme"
import './style.css'
import CustomLayout from './CustomLayout.vue'

export default {
extends: DefaultTheme,
Layout: () => {
return h(DefaultTheme.Layout, null, {
// https://vitepress.dev/guide/extending-default-theme#layout-slots
})
},
Layout: CustomLayout,
enhanceApp({ app, router, siteData }) {

}
Expand Down
6 changes: 6 additions & 0 deletions docs/bedrock/codec.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
---
mentions:
- akashic-records-of-the-abyss
- theaddonn
---

# Codec
7 changes: 7 additions & 0 deletions docs/bedrock/login.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
mentions:
- akashic-records-of-the-abyss
- theaddonn
---

# Login
8 changes: 6 additions & 2 deletions docs/bedrock/nbt.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# NBTs
---
mentions:
- akashic-records-of-the-abyss
- theaddonn
---

NBTs in the Bedrock Protocol.
# NBTs
6 changes: 6 additions & 0 deletions docs/bedrock/start.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
---
mentions:
- akashic-records-of-the-abyss
- theaddonn
---

# Bedrock Protocol
5 changes: 5 additions & 0 deletions docs/info/contributing.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
mentions:
- MisledWater79
---

# Contribute Guide

Welcome to the community!
Expand Down
4 changes: 3 additions & 1 deletion docs/info/learn.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
mentions:
- MisledWater79
next:
text: 'Learning RakNet'
link: '/raknet/start'
Expand All @@ -18,4 +20,4 @@ RakNet is the base transport layer, uses UDP, and is open source. NetherNet is a

#### Is NetherNet replacing RakNet?

Not entirely, NetherNet is not meant to (and can't) replace all of RakNet. It is only used for LAN games, and any friend games (Xbox or In-Game) which both use to use RakNet.
Not entirely, NetherNet is not meant to (and can't) replace all of RakNet. It is only used for LAN games, and any friend games (Xbox or In-Game) which both use to use RakNet.
6 changes: 6 additions & 0 deletions docs/nethernet/start.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
---
mentions:
- akashic-records-of-the-abyss
- theaddonn
---

# NetherNet Protocol
8 changes: 7 additions & 1 deletion docs/raknet/data-types.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# Data Types
---
mentions:
- akashic-records-of-the-abyss
- theaddonn
---

# Data Types
7 changes: 7 additions & 0 deletions docs/raknet/frames.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
mentions:
- akashic-records-of-the-abyss
- theaddonn
---

# Frames
22 changes: 14 additions & 8 deletions docs/raknet/start.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---
mentions:
- akashic-records-of-the-abyss
- theaddonn
- Misledwater79
- Tom-Teclador
prev:
text: 'Learning MCBE Protocol'
next:
Expand All @@ -16,30 +21,31 @@ RakNet is a UDP transfer layer. It is mainly used in Minecraft Bedrock, but is u

## How does RakNet work?

As mentioned before, RakNet protocol uses UDP. This means that the [Packets]() that are sent, might not always make it. This doesn't matter for things like [Pings]() and [Pongs](), but when dealing with more important information, we want to make sure the clients(players) get that data. To combat this, RakNet uses [Frame Set]() packets. These split data up if its too big and also keep track of what data didn't make it to the client and in that case resend it. This uses [ACK]() & [NACK]() packets which the recipient of a [Frame Set]() packet sends back to either say it got this part of the data or is missing this part of the data.
As mentioned before, RakNet protocol uses UDP. This means that the [Packets]() that are sent, might not always make it. This doesn't matter for things like [Pings]() and [Pongs](), but when dealing with more important information, we want to make sure the clients(players) get that data. To combat this, RakNet uses [Frame Set]() packets. These split data up if it's too big and also keeps track of what data did or didn't make it to the recipient. If it didn't recieve it, the sender will resend it. This uses [ACK]() & [NACK]() packets which the receiver of a [Frame Set]() packet sends back to either say it got this part of the data or is missing this part of the data.

## Handshake sequence

This is what happens for every client wanting to connect.
This is the sequence that an client(s) and the server go through to verify and connect said client(s). (The following will be in the perspective of one client and one sevrer)

---

* Clients Pings the server, and the Server sends back a Pong
* A client would then send an [Open Connection Request 1]()
> [!NOTE]
> Unconnected client(s) will be sending [Unconnected Pings]() and in responce, recieve [Unconnected Pongs]() from the server. This is how the client recieves the [MOTD]() of the server.
* The client sends an [Open Connection Request 1]()
* Server responds by sending an [Open Connection Reply 1]()
* Client sends an [Open Connection Request 2]()
* Server replys with an [Open Connection Reply 2]()

> [!NOTE]
> From here, the connection is made and we start sending packets in [Frame Sets]()
>
> Along with that, the client now sends [Connected Pings]() and in responce, recieve [Connected Pong]() from the server. No longer sending the unconnected versions of said packets. (If stopped, we have lost connection)
* Clients sends a [Connected Ping](), and the Server replies with a [Connected Pong]()
* Client sends a [Connection Request]()
* Server responds with a [Connection Request Accepted]()
* Lastly, Client sends a [New Incoming Connection]()
* Lastly, client sends a [New Incoming Connection]()

> [!NOTE]
> From here, both Clients and Server regularly send [Connected Pings]() and reply with [Connected Pongs](). (If stopped, we have lost connection)
---

Now, all data recieved from frame sets are [Game Packets](). The data recieved from the game packet is now delt with by the [Bedrock Protocol]() (We will go over it after RakNet).
Expand Down

0 comments on commit 8c64d52

Please sign in to comment.