Skip to content

Commit 6f7aa02

Browse files
committed
project(structure, docs): Redo docs and move around some files
1 parent b6c521e commit 6f7aa02

26 files changed

Lines changed: 601 additions & 336 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ Please be aware that BiomesAPI is in active development, and some features may n
2727

2828
## Getting Started ⭐
2929

30-
BiomesAPI is built using Gradle and is hosted on my repository (rep.jsinco.dev). To get started with BiomesAPI,
30+
BiomesAPI is built using Gradle and is hosted on my repository (repo.jsinco.dev). To get started with BiomesAPI,
3131
follow the instructions below to add BiomesAPI to your project.
3232

33-
1. Find the latest version of BiomesAPI [HERE](https://repo.jsinco.dev/#/releases/me/outspending/biomesapi/BiomesAPI). Versions with a git commit has at the end are snapshot builds and may be unstable.
33+
1. Find the latest version of BiomesAPI [HERE](https://repo.jsinco.dev/#/releases/me/outspending/biomesapi/BiomesAPI). Versions with a git commit hash at the end are snapshot builds and may be unstable.
3434
2. Add the repository to your `build.gradle.kts`, `build.gradle`, or `pom.xml` file.
3535

3636
And example for Gradle Kotlin DSL is provided below:
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: BiomeResourceKey
3+
description: NamespacedKeys for custom biomes
4+
---
5+
6+
import { Tabs, TabItem } from "@astrojs/starlight/components";
7+
8+
The `BiomeResourceKey` is a common component in BiomesAPI that is used to identify biomes.
9+
It is used extensively throughout the interfaces in BiomesAPI and is functionally identical to Namespaced keys along with beind a wrapper around Minecraft's internal **Identifier** (or **ResourceLocation** in older versions).
10+
11+
12+
## Usage
13+
14+
<Tabs syncKey="language">
15+
<TabItem label="Java">
16+
```java
17+
public class ExampleClass {
18+
public boolean exampleUsage() {
19+
BiomeResourceKey resourceKey1 = BiomeResourceKey.of("example", "fancybiome");
20+
String resourceKey1AsString = resourceKey1.toString();
21+
22+
BiomeResourceKey resouceKey2 = BiomeResourceKey.fromString(resourceKey1AsString);
23+
24+
return resourceKey1.equals(resouceKey2);
25+
}
26+
}
27+
```
28+
</TabItem>
29+
<TabItem label="Kotlin">
30+
```kotlin
31+
class ExampleClass {
32+
fun exampleUsage(): Boolean {
33+
val resourceKey1 = BiomeResourceKey.of("example", "fancybiome")
34+
val resourceKey1AsString = resourceKey1.toString()
35+
36+
val resourceKey2 = BiomeResourceKey.fromString(resourceKey1AsString)
37+
38+
return resourceKey1 == resourceKey2
39+
}
40+
}
41+
```
42+
</TabItem>
43+
</Tabs>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: BlockReplacement
3+
description: Block replacements for phony custom biomes
4+
---
5+
6+
import { Tabs, TabItem } from "@astrojs/starlight/components";
7+
8+
A `BlockReplacement` is a record of two materials. The first material **points** to what it should become.
9+
This component is only used when working with the [`PacketHandler`](/guides/components/packet-handler).
10+
A `BlockReplacement` makes a specific block type appear as another block without changing it on the server.
11+
12+
13+
## Usage
14+
15+
<Tabs syncKey="language">
16+
<TabItem label="Java">
17+
```java
18+
public class ExampleClass {
19+
public boolean exampleUsage(@NotNull CustomBiome customBiome) {
20+
// Makes all grass blocks appear as diamond blocks in the biome
21+
BlockReplacement blockReplacement = BlockReplacement.of(Material.GRASS_BLOCK, Material.DIAMOND_BLOCK);
22+
23+
// Let's add it to our custom biome
24+
customBiome.setBlockReplacements(blockReplacement);
25+
}
26+
}
27+
```
28+
</TabItem>
29+
<TabItem label="Kotlin">
30+
```kotlin
31+
class ExampleClass {
32+
fun exampleUsage(customBiome: CustomBiome) {
33+
// Makes all grass blocks appear as diamond blocks in the biome
34+
val blockReplacement = BlockReplacement.of(Material.GRASS_BLOCK, Material.DIAMOND_BLOCK);
35+
36+
// Let's add it to our custom biome
37+
customBiome.setBlockReplacements(blockReplacement);
38+
}
39+
}
40+
```
41+
</TabItem>
42+
</Tabs>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: ChunkLocation
3+
description: Represents a chunk's x and z coordinates
4+
---
5+
6+
import { Tabs, TabItem } from "@astrojs/starlight/components";
7+
8+
A `ChunkLocation` simply represents a specific chunk's x and z coordinates.
9+
10+
11+
## Usage
12+
13+
<Tabs syncKey="language">
14+
<TabItem label="Java">
15+
```java
16+
public class ExampleClass {
17+
public boolean exampleUsage(@NotNull Block block) {
18+
// Get the chunk at 0, 0
19+
ChunkLocation chunkLocation = ChunkLocation.of(0, 0);
20+
ChunkLocation chunkLocation2 = ChunkLocation.fromBlockCoords(block.getX(), block.getZ());
21+
22+
// Check if the second chunk location is within a 4 chunk radius of the first one
23+
return chunkLocation.isWithinRadius(chunkLocation2, 4);
24+
}
25+
}
26+
```
27+
</TabItem>
28+
<TabItem label="Kotlin">
29+
```kotlin
30+
class ExampleClass {
31+
fun exampleUsage(block: Block): Boolean {
32+
// Get the chunk at 0, 0
33+
val chunkLocation = ChunkLocation.of(0, 0)
34+
val chunkLocation2 = ChunkLocation.fromBlockCoords(block.x, block.z)
35+
36+
// Check if the second chunk location is within a 4 chunk radius of the first one
37+
return chunkLocation.isWithinRadius(chunkLocation2, 4)
38+
}
39+
}
40+
```
41+
</TabItem>
42+
</Tabs>

docs/src/content/docs/guides/creating-custom-biomes.mdx

Lines changed: 0 additions & 86 deletions
This file was deleted.

docs/src/content/docs/guides/getting-started.mdx

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: The BiomeRegistry
3+
description: All about BiomesAPI's BiomeRegistry
4+
---
5+
6+
import { Tabs, TabItem } from "@astrojs/starlight/components";
7+
8+
The `BiomeRegistry` is abstraction of Minecraft's `worldgen/biome` registry.
9+
When using **BiomesAPI**, the `BiomeRegistry` is available to use, but is not generally needed since BiomeRegistry actions can be performed directly from `CustomBiome`s.
10+
(e.g. `CustomBiome#register` or `CustomBiome#modify`.)
11+
12+
13+
### Registry De-sync
14+
15+
Adding biomes to the registry can be done at any point during your plugin's lifecycle, but players **must** relog because of registry de-sync!
16+
If you try to send a newly created `CustomBiome` either through the `BiomeSetter` or `BiomeHandler` to a player, their client will disconnect itself or crash!
17+
Minecraft's **worldgen/biome** registry is synced between the server and the client during the configuration phase and that phase **MUST** be repeated before a player can see a new biome!
18+
19+
If you are using the `PacketHandler` to send biomes to players, you may include additional logic in your **conditional** to ensure players which have not yet re-logged do not see your newly created biome.
20+
If you are using the `BiomeSetter`, you will need to forcefully disconnect the client or intercept the biome packets yourself, less the client will disconnect or crash itself when rendering your biome.
21+
22+
23+
### Unregistering Biomes
24+
25+
CustomBiomes, and by extension **Minecraft biomes in general** can not be unregistered (at least not easily). There is no limit to how many biomes you can register, but you cannot unregister them without
26+
fully restarting the server.
27+
28+
29+
## Examples
30+
31+
<Tabs syncKey="language">
32+
<TabItem label="Java">
33+
```java
34+
public class ExampleClass {
35+
36+
private static final BiomeRegistry BIOME_REGISTRY = BiomeRegistry.newRegistry();
37+
38+
public void exampleUsage(@NotNull CustomBiome customBiome) {
39+
BIOME_REGISTRY.register(customBiome); // Registered!
40+
41+
// Let's change the color of our biome's foliage and modify it:
42+
int red = 0xFF0000;
43+
customBiome.setFoliageColor(red);
44+
BIOME_REGISTRY.modify(customBiome);
45+
}
46+
}
47+
```
48+
</TabItem>
49+
<TabItem label="Kotlin">
50+
```kotlin
51+
class ExampleClass {
52+
53+
companion object {
54+
private val BIOME_REGISTRY: BiomeRegistry = BiomeRegistry.newRegistry()
55+
}
56+
57+
fun exampleUsage(customBiome: CustomBiome) {
58+
BIOME_REGISTRY.register(customBiome) // Registered!
59+
60+
// Let's change the color of our biome's foliage and modify it:
61+
val red = 0xFF0000
62+
customBiome.foliageColor = red
63+
BIOME_REGISTRY.modify(customBiome)
64+
}
65+
}
66+
```
67+
</TabItem>
68+
</Tabs>

0 commit comments

Comments
 (0)