26.2: Documentation for Custom Waypoints style API and Custom Entities (#161)
* Write documentation for the new custom waypoints style API * Update Rainbow's wiki page and add it to the index * Add item display disclaimer to Rainbow wiki, reference to Rainbow in custom blocks and custom resource pack articles * Some more waypoint style wiki and other small things * Update wiki/geyser/custom-waypoints.mdx Co-authored-by: Auri <auroranova8756@gmail.com> * Document (custom) entity API (#164) * Document (custom) entity API * btw you would also probably want to have a resource pack, eh? * Java 26.2 (#167) * Netherlink? No, MCCompanion. (#160) You haven't heard? We are rebranding. * Update versions.json (#162) * Java 26.2 👀 --------- Co-authored-by: Hasan <52300558+hasankayra04@users.noreply.github.com> Co-authored-by: SleepyPop <81194303+SleepyPopp@users.noreply.github.com> * Rename "custom resource pack" section to "custom content", update docs to reflect custom entity API changes * Apply suggestions from code review Co-authored-by: chris <github@onechris.mozmail.com> --------- Co-authored-by: chris <github@onechris.mozmail.com> Co-authored-by: Auri <auroranova8756@gmail.com> Co-authored-by: Hasan <52300558+hasankayra04@users.noreply.github.com> Co-authored-by: SleepyPop <81194303+SleepyPopp@users.noreply.github.com>
This commit is contained in:
10 files changed
+636
-31
No files matched your search
@@ -7,6 +7,11 @@ To setup custom blocks in geyser, you have to choose how you are going to regist
|
||||
|
||||
It should be noted that blocks and their associated components are not very stable. Mojang tends to make changes to these much more often than they do for items. This means that any components Geyser allows you to register are liable to break in future versions of Bedrock.
|
||||
|
||||
:::warning
|
||||
Geyser does not convert resource packs from Java Edition, and also does not generate custom block mappings automatically.
|
||||
However, you can use automatic tools such as [Rainbow](/wiki/other/rainbow/) to make converting content simpler.
|
||||
:::
|
||||
|
||||
## Enabling custom blocks {#enabling-custom-blocks}
|
||||
|
||||
Before beginning, ensure that `gameplay.enable-custom-content` is set to `true` in your `config.yml` file.
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
title: Custom Content
|
||||
description: How to use custom content (requiring resource packs) with Geyser.
|
||||
---
|
||||
|
||||
Geyser supports mapping various custom additions to the game via resource packs and mappings, such as custom items, blocks, and skulls. See:
|
||||
|
||||
- [Custom items](/wiki/geyser/custom-items)
|
||||
- [Custom blocks](/wiki/geyser/custom-blocks)
|
||||
- [Custom skulls](/wiki/geyser/custom-skulls)
|
||||
- [Custom waypoint icons](/wiki/geyser/custom-waypoints)
|
||||
- [Custom entities](/wiki/geyser/custom-entities)
|
||||
|
||||
:::info
|
||||
Geyser does not convert resource packs from Java Edition automatically.
|
||||
However, you can use automatic tools such as [Rainbow](/wiki/other/rainbow/) or [Thunder](/wiki/other/thunder) to make converting custom content simpler.
|
||||
:::
|
||||
@@ -0,0 +1,234 @@
|
||||
---
|
||||
title: Geyser Entity API
|
||||
description: Geyser extensions can register custom Bedrock entity definitions, modify existing entities, and replace built-in types in entity spawning events.
|
||||
---
|
||||
|
||||
:::warning Experimental API
|
||||
The (Custom) Entity API was introduced with Geyser API **2.11.0** (26.2 update) and is currently marked `@ApiStatus.Experimental`. This means that the API may change or be rewritten in parts in a future version without prior deprecation.
|
||||
If you have feedback on this API, encounter issues, or wish to request further features, please reach out to us!
|
||||
|
||||
The `GeyserDefineEntityPropertiesEvent` has been available since **2.9.0**, but its identifier parameter changed in 2.11.0: it now takes a **Bedrock** entity identifier instead of a Java one. See [Entity Properties](#entity-properties) for details.
|
||||
:::
|
||||
|
||||
:::info
|
||||
This API currently cannot be used via JSON mappings. In the future, we are planning to support entity variants, which would likely also be usable through JSON mappings.
|
||||
:::
|
||||
|
||||
Custom entities currently (as of 26.2) do not exist in Minecraft: Java Edition. Instead, they can be simulated with armor stands holding item models, or item/block display entity combinations.
|
||||
Unlike Java Edition, Bedrock does support custom entity types, but does not have item or block display entities. With this API, Geyser extensions can register custom Bedrock entity definitions to use instead of Java
|
||||
entity types in entity spawning events to properly support custom entities for Bedrock players. Further, it allows modifying entity properties and data for any entity sent to a Bedrock player at runtime.
|
||||
|
||||
Additionally to registering custom entity definitions, you will also need to provide a resource pack to players [defining custom entity textures and animations](https://wiki.bedrock.dev/guide/custom-entity).
|
||||
|
||||
## Prerequisites: Vocabulary {#vocabulary}
|
||||
|
||||
- **Bedrock Entity Definition** (`GeyserEntityDefinition` / `CustomEntityDefinition`): Identifies the Bedrock entity type to spawn, either a built-in type, or a custom type
|
||||
- **Entity Properties**: Bedrock Molang-queryable values (`query.property(...)`) registered per Bedrock entity type. See [here](https://learn.microsoft.com/en-us/minecraft/creator/documents/introductiontoentityproperties?view=minecraft-bedrock-stable) for official documentation.
|
||||
- **Entity Data Types**: Properties on entities that can be changed dynamically, such as scale, size, hitboxes, and color.
|
||||
|
||||
## Registering a Custom Entity Definition {#registering-entity-definition}
|
||||
|
||||
Custom entity definitions are registered using `GeyserDefineEntitiesEvent`, which fires once during Geyser's startup:
|
||||
|
||||
```java
|
||||
@Subscribe
|
||||
public void onDefineEntities(GeyserDefineEntitiesEvent event) {
|
||||
CustomEntityDefinition myEntity = CustomEntityDefinition.of(Identifier.of("mynamespace:my_entity"));
|
||||
event.register(myEntity);
|
||||
}
|
||||
```
|
||||
|
||||
Do note:
|
||||
- Custom entity definition type identifier must not use the `minecraft` namespace
|
||||
- Entity types must have a unique identifier
|
||||
|
||||
## Summoning custom entities {#custom-entity-spawning}
|
||||
|
||||
Whenever the Java server creates a new non-player entity for any connection, a `ServerSpawnEntityEvent` is fired. It can be used to change which Bedrock entity definition is sent to the Bedrock player or cancel the spawn entirely.
|
||||
Each connection has its own entity cache, so different players will never share the same entity instance.
|
||||
|
||||
Example:
|
||||
|
||||
```java
|
||||
private static final Identifier ZOMBIE = Identifier.of("minecraft:zombie");
|
||||
private static final CustomEntityDefinition MY_ENTITY = CustomEntityDefinition.of(Identifier.of("mynamespace:my_entity"));
|
||||
|
||||
@Subscribe
|
||||
public void onDefineEntities(GeyserDefineEntitiesEvent event) {
|
||||
event.register(MY_ENTITY);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onSpawn(ServerSpawnEntityEvent event) {
|
||||
if (event.entityType().is(ZOMBIE)) {
|
||||
event.definition(MY_ENTITY); // definition must be registered beforehand
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This example replaces all spawned zombies with our custom entity, which we registered in `onDefineEntities`.
|
||||
|
||||
:::info
|
||||
The `ServerSpawnEntityEvent` fires before the entity is spawned (since it could be canceled). You can provide a consumer for the resulting `GeyserEntity` to set initial entity data values before the entity is spawned on the client:
|
||||
|
||||
```java
|
||||
private static final Identifier ZOMBIE = Identifier.of("minecraft:zombie");
|
||||
private static final CustomEntityDefinition MY_ENTITY = CustomEntityDefinition.of(Identifier.of("mynamespace:my_entity"));
|
||||
|
||||
@Subscribe
|
||||
public void onSpawn(ServerSpawnEntityEvent event) {
|
||||
if (!event.entityType().is(ZOMBIE)) {
|
||||
return;
|
||||
}
|
||||
event.definition(MY_ENTITY);
|
||||
event.preSpawnConsumer(entity -> {
|
||||
entity.override(GeyserEntityDataTypes.SCALE, 2.0f);
|
||||
entity.override(GeyserEntityDataTypes.COLOR, (byte) 5);
|
||||
});
|
||||
}
|
||||
```
|
||||
:::
|
||||
|
||||
### Modifying shoulder parrots {#shoulder-parrots}
|
||||
|
||||
`ServerAttachParrotsEvent` fires when a parrot is attached to a player's shoulder. It extends `ServerSpawnEntityEvent`, so definition replacement, cancellation, and setting a pre spawn consumer for the
|
||||
resulting `GeyserEntity` instance are all available.
|
||||
|
||||
```java
|
||||
@Subscribe
|
||||
public void onParrotAttach(ServerAttachParrotsEvent event) {
|
||||
event.definition(myParrotReplacement); // this entity definition would also be registered previously
|
||||
}
|
||||
```
|
||||
|
||||
## Modifying entity data {#entity-data}
|
||||
|
||||
Entity data consists of runtime-modifiable values such as scale, size, and hitboxes. All constants live in `GeyserEntityDataTypes`. Values for these types can be updated on a `GeyserEntity`
|
||||
at any time using `entity.override(type, value)`, or set inside a pre-spawn consumer in the entity spawn events to modify it before the spawn packet is sent.
|
||||
|
||||
Updating any of these values will override the value sent by the server until the override is removed. To remove an override, a `null` value can be used.
|
||||
|
||||
| Constant | Value Type | Description |
|
||||
|------------------------------------|----------------|------------------------------------------------------------------------------|
|
||||
| `COLOR` | `Byte` | Bedrock color component (0–15) |
|
||||
| `VARIANT` | `Integer` | Numeric variant index, queryable via `query.variant` in resource packs |
|
||||
| `WIDTH` | `Float` | Collision box width |
|
||||
| `HEIGHT` | `Float` | Collision box height |
|
||||
| `VERTICAL_OFFSET` | `Float` | Y-axis offset applied on top of the Java entity position |
|
||||
| `SCALE` | `Float` | Visual scale multiplier |
|
||||
| `HITBOXES` | `List<Hitbox>` | Custom hitboxes. Set an empty list to remove all hitboxes |
|
||||
| `SEAT_OFFSET` | `Vector3f` | Riding position offset |
|
||||
| `ROTATION_LOCKED_TO_VEHICLE` | `Boolean` | Whether the rider's rotation is locked to the vehicle's rotation |
|
||||
| `SEAT_LOCK_RIDER_ROTATION_DEGREES` | `Float` | The degrees of rotation a rider may rotate within when mounted on an entity. |
|
||||
| `SEAT_HAS_ROTATION` | `Boolean` | Whether a seat has rotation |
|
||||
| `ROTATE_RIDER_DEGREES` | `Float` | Rotation offset for the seat in degrees |
|
||||
|
||||
:::info
|
||||
Hitbox `min`, `max` and `pivot` are absolute world coordinates, not relative to the entity's position.
|
||||
:::
|
||||
|
||||
## Entity Properties {#entity-properties}
|
||||
|
||||
Entity properties expose Java-side state to Bedrock resource packs via `query.property('namespace:name')` in Molang. Entity properties can be registered for both custom, and vanilla entity types using the `GeyserDefineEntityPropertiesEvent`, which fires during Geyser startup.
|
||||
|
||||
:::warning Breaking Change in 2.11.0
|
||||
`GeyserDefineEntityPropertiesEvent` has been available since **2.9.0**, but its first parameter changed in 2.11.0: it now takes a **Bedrock** entity type identifier.
|
||||
:::
|
||||
|
||||
A maximum of 32 properties per entity type can be registered.
|
||||
|
||||
```java
|
||||
private GeyserFloatEntityProperty aggression = null;
|
||||
private GeyserIntEntityProperty state = null;
|
||||
private GeyserBooleanEntityProperty enraged = null;
|
||||
private GeyserEnumEntityProperty<Phase> phase = null;
|
||||
private GeyserStringEnumProperty mode = null;
|
||||
|
||||
@Subscribe
|
||||
public void onDefineProperties(GeyserDefineEntityPropertiesEvent event) {
|
||||
Identifier zombieType = Identifier.of("minecraft:zombie");
|
||||
|
||||
// Float property: min, max, default (null default uses min)
|
||||
aggression = event.registerFloatProperty(zombieType, Identifier.of("mynamespace:aggression"), 0f, 1f, 0f);
|
||||
|
||||
// Integer property
|
||||
state = event.registerIntegerProperty(zombieType, Identifier.of("mynamespace:state"), 0, 10, null);
|
||||
|
||||
// Boolean property
|
||||
enraged = event.registerBooleanProperty(zombieType, Identifier.of("mynamespace:enraged"), false);
|
||||
|
||||
// Enum from a Java enum class (max 16 values, names max 32 chars, must start with a letter)
|
||||
phase = event.registerEnumProperty(zombieType, Identifier.of("mynamespace:phase"), Phase.class, Phase.IDLE);
|
||||
|
||||
// Enum from a string list
|
||||
mode = event.registerEnumProperty(zombieType, Identifier.of("mynamespace:mode"), List.of("idle", "active", "fleeing"), "idle");
|
||||
}
|
||||
```
|
||||
|
||||
Properties can be updated on a `GeyserEntity` instance at any time:
|
||||
|
||||
```java
|
||||
// Single property
|
||||
entity.updateProperty(aggression, 0.5f);
|
||||
```
|
||||
|
||||
## Looking up entities {#looking-up-entities}
|
||||
|
||||
After an entity has spawned it can be looked up through `GeyserConnection#entities()`. All lookup methods are thread-safe.
|
||||
|
||||
```java
|
||||
EntityData entityData = connection.entities();
|
||||
|
||||
// By Java entity ID (int)
|
||||
GeyserEntity entity = entityData.byJavaId(javaId);
|
||||
|
||||
// By UUID
|
||||
GeyserEntity entity = entityData.byUuid(uuid);
|
||||
|
||||
// By Geyser/Bedrock runtime ID (long)
|
||||
GeyserEntity entity = entityData.byGeyserId(geyserId);
|
||||
```
|
||||
|
||||
All three return `null` if no entity is found. A `GeyserEntity` exposes various properties, such as the entity uuid, current passengers / vehicle if applicable, and it can further be used to update
|
||||
entity properties or entity data type values.
|
||||
|
||||
## Full Example {#full-example}
|
||||
|
||||
<details>
|
||||
<summary>Expand for a full extension example</summary>
|
||||
|
||||
```java
|
||||
public class MyExtension implements Extension {
|
||||
// Create a custom entity definition
|
||||
private final CustomEntityDefinition enhancedZombie = CustomEntityDefinition.of(Identifier.of("myext:enhanced_zombie"));
|
||||
private GeyserFloatEntityProperty healthFraction = null;
|
||||
|
||||
// Register the custom entity type
|
||||
@Subscribe
|
||||
public void onDefineEntities(GeyserDefineEntitiesEvent event) {
|
||||
event.register(enhancedZombie);
|
||||
}
|
||||
|
||||
// Optionally: Register entity properties (Bedrock identifier)
|
||||
@Subscribe
|
||||
public void onDefineProperties(GeyserDefineEntityPropertiesEvent event) {
|
||||
healthFraction = event.registerFloatProperty(
|
||||
enhancedZombie.identifier(),
|
||||
Identifier.of("myext:health_fraction"),
|
||||
0f, 1f, 1f
|
||||
);
|
||||
}
|
||||
|
||||
// Replace a default Bedrock entity definition with our custom one
|
||||
@Subscribe
|
||||
public void onSpawn(ServerSpawnEntityEvent event) {
|
||||
// Unless you want to replace everything, you should probably add checks for e.g., entity type, or entity UUID
|
||||
event.definition(enhancedZombie);
|
||||
event.preSpawnConsumer(entity -> {
|
||||
entity.override(GeyserEntityDataTypes.SCALE, 1.5f);
|
||||
entity.override(GeyserEntityDataTypes.COLOR, (byte) 4);
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
</details>
|
||||
@@ -1,9 +0,0 @@
|
||||
---
|
||||
title: Custom Resource Packs
|
||||
description: How to use custom resource packs for Geyser.
|
||||
---
|
||||
|
||||
Geyser supports custom resource packs for use with custom items, blocks, and skulls. See:
|
||||
- [Custom items](/wiki/geyser/custom-items)
|
||||
- [Custom blocks](/wiki/geyser/custom-blocks)
|
||||
- [Custom skulls](/wiki/geyser/custom-skulls)
|
||||
@@ -0,0 +1,226 @@
|
||||
---
|
||||
title: Custom Waypoint Icons
|
||||
description: Geyser supports custom locator bar icons (also known as waypoint icons), though they have to be mapped manually.
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
|
||||
Minecraft: Java Edition supports showing custom icons on the locator bar. These are known as custom waypoints and, on
|
||||
Java Edition, are implemented through custom "waypoint styles" in a resource pack. These waypoint styles specify a near
|
||||
and far distance in blocks, and a list of sprites to display on the locator bar.
|
||||
|
||||
Bedrock Edition also supports custom waypoint icons through behaviour + resource packs. In Geyser, these are implemented through custom JSON mappings, similar to custom block or item mappings, alongside a Bedrock resource pack.
|
||||
|
||||
Geyser extensions can also make use out of Bedrock's support for custom waypoint icons. Unlike JSON mappings however,
|
||||
extensions have more freedom in how icons are displayed to the client.
|
||||
|
||||
When an unknown custom waypoint style is sent to Geyser by the Java server,
|
||||
Geyser will display the waypoint using vanilla's default icons.
|
||||
|
||||
:::info
|
||||
This guide only describes the steps required to write custom waypoint style mappings. You still need to create a resource pack
|
||||
for Bedrock Edition, add the waypoint icons to it, and use it in Geyser. Geyser cannot automatically pull icons from
|
||||
Java Edition resource packs.
|
||||
:::
|
||||
|
||||
:::warning
|
||||
As with custom blocks and items, Geyser does not convert resource packs from Java Edition, and also does not generate
|
||||
custom waypoint mappings automatically. However, [Rainbow](/wiki/other/rainbow/) is planning
|
||||
support for these conversions.
|
||||
:::
|
||||
|
||||
## Simple icons
|
||||
|
||||
Custom waypoint icons following Java's system of having a near- and far-distance should be mapped using JSON mappings, or,
|
||||
when using Geyser extensions, Geyser's `CustomWaypointStyle.VanillaBuilder` helper builder. Both of these methods follow
|
||||
the same format as Java's custom waypoint styles and should feel very familiar.
|
||||
|
||||
<Tabs groupId="custom-waypoint-implementation">
|
||||
<TabItem value="json" label="JSON-mappings">
|
||||
JSON mappings have to specify the `format_version` set to `1`, and list all custom waypoint styles under the
|
||||
`waypoint_styles` key. This key holds an object in which keys are identifiers of waypoint styles, and each
|
||||
value is the definition of that waypoint style.
|
||||
|
||||
For example, take the following `waypoint_mappings.json` file:
|
||||
```json
|
||||
{
|
||||
"format_version": 1,
|
||||
"waypoint_styles": {
|
||||
"geyser:my_first_waypoint": {
|
||||
"near_distance": 10,
|
||||
"far_distance": 100,
|
||||
"sprites": [
|
||||
"geyser:custom_waypoint_0",
|
||||
"geyser:custom_waypoint_1"
|
||||
]
|
||||
},
|
||||
"geyser:my_second_waypoint": {
|
||||
"sprites": [
|
||||
"geyser:second_waypoint/texture_1",
|
||||
"geyser:second_waypoint/texture_2",
|
||||
"geyser:second_waypoint/texture_3",
|
||||
"geyser:second_waypoint/texture_4"
|
||||
]
|
||||
},
|
||||
"geyser:the_best_waypoint": {
|
||||
"near_distance": 50,
|
||||
"sprites": [
|
||||
"geyser:ultimate_waypoint/near",
|
||||
"geyser:ultimate_waypoint/far"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
These mappings specify 3 custom waypoint styles, `geyser:my_first_waypoint`, `geyser:my_second_waypoint`, and
|
||||
`geyser:the_best_waypoint`.
|
||||
|
||||
Just like on Java Edition, the default value for `near_distance` when not specified is 128, and for `far_distance`
|
||||
it is 332. And, just like on Java Edition, at least one texture sprite must be specified.
|
||||
|
||||
Since namespaces do not exist in Bedrock Edition's resource packs, Geyser must flatten the texture sprite identifier
|
||||
to be used in the resource pack on Bedrock Edition. Geyser does this using the following format:
|
||||
|
||||
> `textures/ui/<namespace>/locator_bar_dot/<path>`
|
||||
|
||||
As such, in the example above, the `geyser:my_first_waypoint` waypoint style refers to the following textures in the Bedrock resource pack:
|
||||
|
||||
- `textures/ui/geyser/locator_bar_dot/custom_waypoint_0`
|
||||
- `textures/ui/geyser/locator_bar_dot/custom_waypoint_1`
|
||||
</TabItem>
|
||||
<TabItem value="api" label="Geyser API">
|
||||
The Geyser API provides a helper builder, called `VanillaBuilder` in `CustomWaypointStyle`, to implement custom
|
||||
waypoint icons that are similar to Java Edition's custom icons. The builder is similar to JSON-mappings in use
|
||||
and requires the same fields to be specified.
|
||||
|
||||
Custom waypoint styles are registered per-connection in the `SessionDefineCustomWaypointsEvent`,
|
||||
and as such you can check the `GeyserConnection` before registering a custom waypoint style. If a custom waypoint
|
||||
style is used across multiple connections, it can be useful to only create it once to save memory.
|
||||
|
||||
`VanillaBuilder` instances are created by using `CustomWaypointStyle#vanillaLike(int nearDistance, int farDistance)`.
|
||||
When not specifying a near- and far-distance, the Java defaults of 128 and 332 are used.
|
||||
|
||||
```java
|
||||
@Subscribe
|
||||
public void onSessionDefineCustomWaypoints(SessionDefineCustomWaypointsEvent event) {
|
||||
event.register(Identifier.of("geyser:my_first_waypoint"), CustomWaypointStyle.vanillaLike(10, 100)
|
||||
.withTexture(Identifier.of("geyser:custom_waypoint_0"))
|
||||
.withTexture(Identifier.of("geyser:custom_waypoint_1"))
|
||||
.build());
|
||||
|
||||
event.register(Identifier.of("geyser:my_second_waypoint"), CustomWaypointStyle.vanillaLike()
|
||||
.withTexture(Identifier.of("geyser:second_waypoint/texture_1"))
|
||||
.withTexture(Identifier.of("geyser:second_waypoint/texture_2"))
|
||||
.withTexture(Identifier.of("geyser:second_waypoint/texture_3"))
|
||||
.withTexture(Identifier.of("geyser:second_waypoint/texture_4"))
|
||||
.build());
|
||||
|
||||
event.register(Identifier.of("geyser:the_best_waypoint"), CustomWaypointStyle.vanillaLike(50, 332)
|
||||
.withTexture(Identifier.of("geyser:ultimate_waypoint/near"))
|
||||
.withTexture(Identifier.of("geyser:ultimate_waypoint/far"))
|
||||
.build());
|
||||
}
|
||||
```
|
||||
|
||||
As with JSON mappings, Geyser flattens the texture identifier into a string using the following format:
|
||||
|
||||
> `textures/ui/<namespace>/locator_bar_dot/<path>`
|
||||
|
||||
However, you can also pass a literal texture string to `withTexture`. This string must not be prefixed with
|
||||
`textures/` and must also not be suffixed with the texture extension (e.g. `.png`).
|
||||
|
||||
You can register the same custom waypoint style for multiple waypoint style identifiers. However, each
|
||||
waypoint style identifier may only have one custom waypoint style attached to it. If a duplicate is registered,
|
||||
a `CustomWaypointStyleRegisterException` will be thrown.
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
---
|
||||
|
||||
<details>
|
||||
<summary>Changing vanilla waypoint styles</summary>
|
||||
Creating custom waypoint styles for vanilla waypoint styles, like `minecraft:default`, is allowed, and can be done
|
||||
as follows:
|
||||
|
||||
<Tabs groupId="custom-waypoint-implementation">
|
||||
<TabItem value="json" label="JSON-mappings">
|
||||
```json
|
||||
{
|
||||
"format_version": 1,
|
||||
"waypoint_styles": {
|
||||
"minecraft:default": {
|
||||
"sprites": [
|
||||
"geyser:custom_vanilla_0",
|
||||
"geyser:custom_vanilla_1",
|
||||
"geyser:custom_vanilla_2",
|
||||
"geyser:custom_vanilla_3",
|
||||
"geyser:custom_vanilla_4"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="api" label="Geyser API">
|
||||
```java
|
||||
@Subscribe
|
||||
public void onSessionDefineCustomWaypoints(SessionDefineCustomWaypointsEvent event) {
|
||||
event.register(Identifier.of("minecraft:default"), CustomWaypointStyle.vanillaLike(128, 332)
|
||||
.withTexture(Identifier.of("geyser:custom_vanilla_0"))
|
||||
.withTexture(Identifier.of("geyser:custom_vanilla_1"))
|
||||
.withTexture(Identifier.of("geyser:custom_vanilla_2"))
|
||||
.withTexture(Identifier.of("geyser:custom_vanilla_3"))
|
||||
.withTexture(Identifier.of("geyser:custom_vanilla_4"))
|
||||
.build());
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
</details>
|
||||
|
||||
## Advanced icons
|
||||
|
||||
Geyser API users may write custom implementations of `CustomWaypointStyle`, to run custom checks for waypoint textures
|
||||
and waypoint icon sizes. Just like waypoint styles created using the `VanillaBuilder`, these can be registered for one
|
||||
or more custom waypoint style identifiers in the `SessionDefineCustomWaypointsEvent`. For example, the following
|
||||
implementation will always use the same texture and icon size, no matter the distance:
|
||||
|
||||
```java
|
||||
public final class MyCustomWaypointStyle implements CustomWaypointStyle {
|
||||
public static final CustomWaypointStyle INSTANCE = new MyCustomWaypointStyle();
|
||||
private static final Vector2f SIZE = Vector2f.from(0.5, 0.5);
|
||||
|
||||
private MyCustomWaypointStyle() {}
|
||||
|
||||
@Override
|
||||
public String texturePath(Identifier style, float distance) {
|
||||
return "ui/geyser/locator_bar_dot/my_icon";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2f textureSize(Identifier style, float distance) {
|
||||
return SIZE;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Implementations must always implement `texturePath(Identifier, float)` and `textureSize(Identifier, float)`. The first
|
||||
returns the texture path to use for that waypoint style and distance (not prefixed with `textures/`), and the second
|
||||
returns the size of the texture to use (where a size of `[1, 1]` is the size icons normally appear as when the waypoint
|
||||
is close to the player).
|
||||
|
||||
Implementations can then be registered through the `SessionDefineCustomWaypointsEvent` as follows:
|
||||
|
||||
```java
|
||||
@Subscribe
|
||||
public void onSessionDefineCustomWaypoints(SessionDefineCustomWaypointsEvent event) {
|
||||
event.register(Identifier.of("geyser:my_style", MyCustomWaypointStyle.INSTANCE));
|
||||
}
|
||||
```
|
||||
|
||||
Like with `VanillaBuilder`, should you use a custom waypoint style across multiple connections,
|
||||
it can be useful to only keep one instance of it, to save memory. Also, avoid running time-taking operations in your
|
||||
`texturePath` or `textureSize` implementations, since these methods are called frequently. For full implementation details,
|
||||
refer to the Javadocs of `CustomWaypointStyle`.
|
||||
@@ -81,7 +81,8 @@ However, many things that are possible with add-ons or behavior packs can be don
|
||||
or [custom blocks](/wiki/geyser/custom-blocks).
|
||||
|
||||
- **Does Geyser convert Java edition resource packs?** <br />
|
||||
Not currently. For now, you need to manually create a Bedrock edition resource pack equivalent.
|
||||
Not currently. For now, you need to manually create a Bedrock edition resource pack equivalent. You can however
|
||||
use automatic tools such as [Rainbow](/wiki/other/rainbow/) or [Thunder](/wiki/other/thunder) to make converting content simpler.
|
||||
|
||||
- **Can I allow players to choose resource packs themselves?** <br />
|
||||
On most Bedrock platforms (except consoles), players are able to download and install resource packs on the client.
|
||||
|
||||
Reference in new issue
Block a user