Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Fixed some broken links, and removed others. #45

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions feature/entities/ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ Every tick, the entity will find the goal to follow based on its priority. If th

## Groups

You might find yourself wanting to have multiple goals being executed at the same time. For example, having an entity attacking its target while swimming to avoid dying. This is done by adding multiple `EntityAIGroup` to the entity, each group contains a list of goals to be executed independently.
You might find yourself wanting to have multiple goals being executed at the same time. For example, having an entity attacking its target while swimming to avoid dying. This is done by adding multiple `EntityAIGroup` to the entity, each group contains a list of goals to be executed independently.

## Example

In this example, instances of ZombieCreature will attack nearby players or walk around based on if a player is nearby.

```java
package demo.entity;
Expand All @@ -29,9 +33,14 @@ public class ZombieCreature extends EntityCreature {
public ZombieCreature() {
super(EntityType.ZOMBIE);
addAIGroup(
new EntityAIGroupBuilder()
.addGoalSelector(new RandomLookAroundGoal(this, 20))
.build()
List.of(
new MeleeAttackGoal(this, 1.6, 20, TimeUnit.SERVER_TICK), // Attack the target
new RandomStrollGoal(this, 20) // Walk around
)
List.of(
new LastEntityDamagerTarget(this, 32), // First target the last entity which attacked you
new ClosestEntityTarget(this, 32, entity -> entity instanceof Player) // If there is none, target the nearest player
)
);
}
}
Expand Down
6 changes: 2 additions & 4 deletions feature/map-rendering/glfwmaprendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ In the case that you want to render continuously, it is advised to use `setupRen

This sets up a repeating task through the SchedulerManager to automatically render contents every `period`. It also binds to the correct thread before rendering for the first time.

For more in-depth examples, look at the [demo package](https://github.com/Minestom/Minestom/tree/master/src/lwjgl/java/net/minestom/demo/largeframebuffers).

## Color mapping

As said in the [Map Rendering article](https://github.com/Minestom/Minestom/wiki/Map-Rendering), maps do not use RGB, but an index into a color palette. By default, Minestom will convert the RGB pixels from the framebuffer on the CPU after each rendering. While this works and gives appreciable results, this conversion is not done in parallel, and the higher the resolution, the longer it takes.
Maps do not use RGB, but an index into a color palette. By default, Minestom will convert the RGB pixels from the framebuffer on the CPU after each rendering. While this works and gives appreciable results, this conversion is not done in parallel, and the higher the resolution, the longer it takes.

Although Graphics2D framebuffers are not able to accelerate this process, GLFW capable buffers provide a way to quickly convert. There are two ways of doing this conversion.

Expand Down Expand Up @@ -78,4 +76,4 @@ Required files for this to work (all inside classpath, src/_something_/resources
* `/shaders/mapcolorconvert.fragment.glsl` fragment shader responsible for converting RGB to map colors
* `/textures/palette.png` the color palette used by maps. Can be autogenerated via `net.minestom.server.map.PaletteGenerator`, outputs to `src/lwjgl/resources/textures/palette.png`.

This renderer works by rendering your content inside an OpenGL framebuffer (see [MapColorRenderer constructor](https://github.com/Minestom/Minestom/blob/master/src/lwjgl/java/net/minestom/server/map/framebuffers/MapColorRenderer.java) for more control over the framebuffer format. By default, RGBA color texture, Depth 24 bits, and Stencil 8 bits render buffer), and then rendering a full-screen quad (with texture unit 0 containing your color result and texture unit 1 containing the palette) with the `mapcolorconvert` shader.
This renderer works by rendering your content inside an OpenGL framebuffer for more control over the framebuffer format. By default, RGBA color texture, Depth 24 bits, and Stencil 8 bits render buffer), and then rendering a full-screen quad (with texture unit 0 containing your color result and texture unit 1 containing the palette) with the `mapcolorconvert` shader.
20 changes: 20 additions & 0 deletions feature/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ A [`PermissionVerifier`](https://minestom.github.io/Minestom/net/minestom/server

Alternatively, `PermissionHandler#hasPermission(Permission)` can be used. It does require both the permission name and the data to be equal.

## Adding permissions to players and checking them

In order to add a permission to a player, you will have to call the `Player#addPermission(Permission)` function, an example of proper usage would be

```java
player.addPermission(new Permission("operator"));
```

If you want to check, if a player has a permission, you can use the `Player#hasPermission(Permission)` function, here is an example of checking for a permission inside of a command:

```java
public class StopCommand extends Command {
public StopCommand() {
super("stop");
setCondition((sender, commandString) -> sender.hasPermission(new Permission("operator"));
setDefaultExecutor((sender, context) -> MinecraftServer.stopCleanly());
}
}
```

## Permission serialisation

Nothing is automatically saved persistently in Minestom, permissions are not an exception.
Expand Down
23 changes: 23 additions & 0 deletions world/anvilloader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
description: >-
This page describes how to load a world folder using AnvilLoader
---

## Loading a world using AnvilLoader

In order to load a world into an instance, use the `InstanceContainer#setChunkLoader(IChunkLoader)` function.

An example of using this method to load a world is:
```java
InstanceContainer.setChunkLoader(new AnvilLoader("worlds/world"));
```

This will load the world inside of the `worlds/world` directory into the InstanceContainer, allowing you to use the instance as before but having the world loaded inside.

In order to load a world, the world folder will only need the `/region` folder, as it contains the block data.

## Saving a world

In order to save a world, you will have to use the `InstanceContainer#saveChunksToStorage()` function,
this will only work if you have previously loaded a world into the instance using AnvilLoader.

13 changes: 1 addition & 12 deletions world/instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You can create an `InstanceContainer` by calling:
InstanceContainer instanceContainer = instanceManager.createInstanceContainer();
```

In order to have a valid world generation, you need to specify which `ChunkGenerator` the instance should use, without it no chunk can be generated. (check [here](https://github.com/Minestom/Minestom/wiki/Chunk-generator) to make your own)
In order to have a valid world generation, you need to specify which `ChunkGenerator` the instance should use, without it no chunk can be generated. (check [here](https://github.com/Minestom/Minestom/wiki/world/generation) to make your own)

```java
instance.setChunkGenerator(YOUR_GENERATOR);
Expand Down Expand Up @@ -54,14 +54,3 @@ instanceManager.registerInstance(YOUR_CUSTOM_INSTANCE);

This method is ONLY required if you instantiate your instance object manually, `InstanceManager#createInstanceContainer` and `InstanceManager#createSharedInstance` already register the instance internally.

## Save your instances/chunks

It is also essential to notice that, by default, the chunks of the instance are only stored in memory. In order to have them stored in a persistent way, you need to serialize and deserialize them. Please check the [Chunks management](chunk-management.md) page for further information.

Minestom uses Anvil as its default world format, conveniently located in the `AnvilLoader` class. Just put your world in the `world` folder, and see it work :)

```java
var instance = instanceManager.createInstanceContainer();
// Save all currently loaded chunks to the IChunkLoader
instanceContainer.saveChunksToStorage();
```