Init
This commit is contained in:
255
content/world/interactions/_index.en.md
Normal file
255
content/world/interactions/_index.en.md
Normal file
@@ -0,0 +1,255 @@
|
||||
---
|
||||
title: Interaction System
|
||||
type: docs
|
||||
weight: 8
|
||||
---
|
||||
|
||||
The Interaction system is Hytale's powerful data-driven behavior framework. It defines how items, blocks, and entities behave when used or activated.
|
||||
|
||||
## Overview
|
||||
|
||||
Interactions are primarily configured through asset files rather than Java code. They form chains of operations that execute when a player performs actions like clicking, attacking, or using items.
|
||||
|
||||
{{< cards cols="2" >}}
|
||||
{{< card link="interaction-types" title="Interaction Types" subtitle="100+ built-in interaction types" icon="lightning-bolt" >}}
|
||||
{{< card link="selectors" title="Selectors" subtitle="Target entities and blocks" icon="cursor-click" >}}
|
||||
{{< card link="combat" title="Combat" subtitle="Damage calculation and knockback" icon="fire" >}}
|
||||
{{< /cards >}}
|
||||
|
||||
## Key Concepts
|
||||
|
||||
### Interaction Assets
|
||||
|
||||
Interactions are assets loaded from data packs. Assets are stored in an indexed map - you first get the index, then retrieve the asset:
|
||||
|
||||
```java
|
||||
import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Interaction;
|
||||
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
|
||||
|
||||
// Get the asset map
|
||||
IndexedLookupTableAssetMap<String, Interaction> assetMap = Interaction.getAssetMap();
|
||||
|
||||
// Get index from string ID
|
||||
int index = assetMap.getIndex("my_interaction");
|
||||
|
||||
// Get interaction by index
|
||||
Interaction interaction = assetMap.getAsset(index);
|
||||
|
||||
// Or combined (but check for null!)
|
||||
if (index != Integer.MIN_VALUE) {
|
||||
Interaction myInteraction = assetMap.getAsset(index);
|
||||
}
|
||||
```
|
||||
|
||||
{{< callout type="warning" >}}
|
||||
**Important:** `getAsset()` takes an `int` index, not a String. Use `getIndex()` first to convert the string ID to an index. Returns `Integer.MIN_VALUE` if not found.
|
||||
{{< /callout >}}
|
||||
|
||||
### Interaction Context
|
||||
|
||||
When interactions run, they receive an `InteractionContext` with:
|
||||
|
||||
- **Entity reference** - The entity performing the interaction
|
||||
- **Held item** - The item being used
|
||||
- **Target block/entity** - What's being targeted
|
||||
- **State tracking** - Progress and timing information
|
||||
|
||||
### Interaction States
|
||||
|
||||
**Package:** `com.hypixel.hytale.protocol`
|
||||
|
||||
```java
|
||||
public enum InteractionState {
|
||||
Finished(0), // Completed successfully
|
||||
Skip(1), // Skipped by user
|
||||
ItemChanged(2), // Cancelled due to item change
|
||||
Failed(3), // Failed to execute
|
||||
NotFinished(4); // Still running
|
||||
}
|
||||
```
|
||||
|
||||
| State | Value | Description |
|
||||
|-------|-------|-------------|
|
||||
| `Finished` | 0 | Interaction completed successfully |
|
||||
| `Skip` | 1 | User requested to skip |
|
||||
| `ItemChanged` | 2 | Cancelled because held item changed |
|
||||
| `Failed` | 3 | Interaction failed to execute |
|
||||
| `NotFinished` | 4 | Still running, not yet complete |
|
||||
|
||||
## Interaction Categories
|
||||
|
||||
### Block Interactions
|
||||
|
||||
Operations on blocks:
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `PlaceBlockInteraction` | Place a block |
|
||||
| `BreakBlockInteraction` | Break a block |
|
||||
| `DestroyBlockInteraction` | Destroy without drops |
|
||||
| `ChangeBlockInteraction` | Change block type |
|
||||
| `UseBlockInteraction` | Interact with block |
|
||||
| `PlaceFluidInteraction` | Place fluid |
|
||||
|
||||
### Item Interactions
|
||||
|
||||
Operations with items:
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `AddItemInteraction` | Add item to inventory |
|
||||
| `EquipItemInteraction` | Equip an item |
|
||||
| `ModifyInventoryInteraction` | Modify inventory contents |
|
||||
|
||||
### Entity Interactions
|
||||
|
||||
Operations on entities:
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `UseEntityInteraction` | Interact with entity |
|
||||
| `RemoveEntityInteraction` | Remove an entity |
|
||||
| `ApplyEffectInteraction` | Apply status effect |
|
||||
| `ClearEntityEffectInteraction` | Remove effects |
|
||||
|
||||
### Combat Interactions
|
||||
|
||||
Damage and combat:
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `DamageCalculator` | Calculate damage |
|
||||
| `DamageEffects` | Apply damage effects |
|
||||
| `Knockback` | Apply knockback |
|
||||
| `DirectionalKnockback` | Directional knockback |
|
||||
| `ForceKnockback` | Force-based knockback |
|
||||
|
||||
### UI Interactions
|
||||
|
||||
User interface:
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `OpenContainerInteraction` | Open container UI |
|
||||
| `OpenPageInteraction` | Open a page |
|
||||
| `OpenCustomUIInteraction` | Open custom UI |
|
||||
| `SendMessageInteraction` | Send message to player |
|
||||
|
||||
### Structure Interactions
|
||||
|
||||
World modification:
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `SpawnPrefabInteraction` | Spawn a prefab/structure |
|
||||
| `LaunchProjectileInteraction` | Launch projectile |
|
||||
|
||||
### Control Flow
|
||||
|
||||
Chain and condition interactions:
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `SerialInteraction` | Run interactions in sequence |
|
||||
| `ParallelInteraction` | Run interactions simultaneously |
|
||||
| `SelectInteraction` | Choose between interactions |
|
||||
| `ConditionInteraction` | Conditional execution |
|
||||
| `RepeatInteraction` | Repeat an interaction |
|
||||
| `CancelChainInteraction` | Cancel the chain |
|
||||
|
||||
### Stat Interactions
|
||||
|
||||
Entity statistics:
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `ChangeStatInteraction` | Modify a stat |
|
||||
| `StatsConditionInteraction` | Check stat conditions |
|
||||
|
||||
## Interaction Properties
|
||||
|
||||
Common properties on all interactions:
|
||||
|
||||
```yaml
|
||||
# Example interaction configuration
|
||||
MyInteraction:
|
||||
Type: PlaceBlock
|
||||
RunTime: 0.5 # Duration in seconds
|
||||
ViewDistance: 96.0 # Visibility distance
|
||||
HorizontalSpeedMultiplier: 1.0
|
||||
CancelOnItemChange: true
|
||||
Effects:
|
||||
WaitForAnimationToFinish: true
|
||||
ItemAnimationId: "swing"
|
||||
Rules:
|
||||
# Activation rules
|
||||
```
|
||||
|
||||
### InteractionEffects
|
||||
|
||||
Visual and audio effects:
|
||||
|
||||
- `ItemAnimationId` - Animation to play
|
||||
- `WaitForAnimationToFinish` - Wait for animation
|
||||
- Sound effects
|
||||
- Particle effects
|
||||
|
||||
### InteractionRules
|
||||
|
||||
Control when interactions can run:
|
||||
|
||||
- Game mode restrictions
|
||||
- State requirements
|
||||
- Cooldown checks
|
||||
|
||||
## Selectors
|
||||
|
||||
Selectors determine what entities or blocks are targeted:
|
||||
|
||||
| Selector | Description |
|
||||
|----------|-------------|
|
||||
| `RaycastSelector` | Cast ray from camera |
|
||||
| `AOECircleSelector` | Area of effect circle |
|
||||
| `AOECylinderSelector` | Area of effect cylinder |
|
||||
| `StabSelector` | Close-range stab |
|
||||
| `HorizontalSelector` | Horizontal sweep |
|
||||
|
||||
## Accessing Interactions
|
||||
|
||||
### From Items
|
||||
|
||||
Items define their interactions in asset files. At runtime:
|
||||
|
||||
```java
|
||||
ItemStack item = player.getInventory().getActiveItem();
|
||||
Item itemAsset = item.getItem();
|
||||
// Item defines its primary/secondary interactions
|
||||
```
|
||||
|
||||
### From Blocks
|
||||
|
||||
Blocks define use interactions:
|
||||
|
||||
```java
|
||||
BlockType blockType = world.getBlockType(position);
|
||||
// Block defines its use interaction
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
{{< callout type="info" >}}
|
||||
**Interaction Guidelines:**
|
||||
- Interactions are primarily data-driven through assets
|
||||
- Use existing interaction types when possible
|
||||
- Chain interactions for complex behaviors
|
||||
- Use selectors to target appropriately
|
||||
- Consider game mode in rules
|
||||
{{< /callout >}}
|
||||
|
||||
{{< callout type="warning" >}}
|
||||
**Performance Note:** Complex interaction chains with many parallel operations can impact performance. Keep chains efficient.
|
||||
{{< /callout >}}
|
||||
|
||||
## Further Reading
|
||||
|
||||
For detailed information on specific interaction types, see the subpages.
|
||||
255
content/world/interactions/_index.fr.md
Normal file
255
content/world/interactions/_index.fr.md
Normal file
@@ -0,0 +1,255 @@
|
||||
---
|
||||
title: Système d'Interactions
|
||||
type: docs
|
||||
weight: 8
|
||||
---
|
||||
|
||||
Le système d'Interactions est le puissant framework de comportements piloté par les données de Hytale. Il définit comment les objets, blocs et entités se comportent lorsqu'ils sont utilisés ou activés.
|
||||
|
||||
## Vue d'Ensemble
|
||||
|
||||
Les interactions sont principalement configurées via des fichiers d'assets plutôt que du code Java. Elles forment des chaînes d'opérations qui s'exécutent lorsqu'un joueur effectue des actions comme cliquer, attaquer ou utiliser des objets.
|
||||
|
||||
{{< cards cols="2" >}}
|
||||
{{< card link="interaction-types" title="Types d'Interactions" subtitle="100+ types d'interactions intégrés" icon="lightning-bolt" >}}
|
||||
{{< card link="selectors" title="Sélecteurs" subtitle="Cibler entités et blocs" icon="cursor-click" >}}
|
||||
{{< card link="combat" title="Combat" subtitle="Calcul de dégâts et knockback" icon="fire" >}}
|
||||
{{< /cards >}}
|
||||
|
||||
## Concepts Clés
|
||||
|
||||
### Assets d'Interaction
|
||||
|
||||
Les interactions sont des assets chargés depuis les data packs. Les assets sont stockés dans une map indexée - vous devez d'abord obtenir l'index, puis récupérer l'asset :
|
||||
|
||||
```java
|
||||
import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Interaction;
|
||||
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
|
||||
|
||||
// Obtenir la map d'assets
|
||||
IndexedLookupTableAssetMap<String, Interaction> assetMap = Interaction.getAssetMap();
|
||||
|
||||
// Obtenir l'index depuis l'ID string
|
||||
int index = assetMap.getIndex("my_interaction");
|
||||
|
||||
// Obtenir l'interaction par index
|
||||
Interaction interaction = assetMap.getAsset(index);
|
||||
|
||||
// Ou combiné (mais vérifiez null !)
|
||||
if (index != Integer.MIN_VALUE) {
|
||||
Interaction myInteraction = assetMap.getAsset(index);
|
||||
}
|
||||
```
|
||||
|
||||
{{< callout type="warning" >}}
|
||||
**Important :** `getAsset()` prend un `int` index, pas un String. Utilisez `getIndex()` d'abord pour convertir l'ID string en index. Retourne `Integer.MIN_VALUE` si non trouvé.
|
||||
{{< /callout >}}
|
||||
|
||||
### Contexte d'Interaction
|
||||
|
||||
Quand les interactions s'exécutent, elles reçoivent un `InteractionContext` avec :
|
||||
|
||||
- **Référence d'entité** - L'entité effectuant l'interaction
|
||||
- **Objet tenu** - L'objet utilisé
|
||||
- **Bloc/entité cible** - Ce qui est ciblé
|
||||
- **Suivi d'état** - Informations de progression et timing
|
||||
|
||||
### États d'Interaction
|
||||
|
||||
**Package :** `com.hypixel.hytale.protocol`
|
||||
|
||||
```java
|
||||
public enum InteractionState {
|
||||
Finished(0), // Terminé avec succès
|
||||
Skip(1), // Ignoré par l'utilisateur
|
||||
ItemChanged(2), // Annulé suite à changement d'objet
|
||||
Failed(3), // Échec d'exécution
|
||||
NotFinished(4); // Toujours en cours
|
||||
}
|
||||
```
|
||||
|
||||
| État | Valeur | Description |
|
||||
|------|--------|-------------|
|
||||
| `Finished` | 0 | Interaction terminée avec succès |
|
||||
| `Skip` | 1 | L'utilisateur a demandé d'ignorer |
|
||||
| `ItemChanged` | 2 | Annulé car l'objet tenu a changé |
|
||||
| `Failed` | 3 | L'interaction a échoué |
|
||||
| `NotFinished` | 4 | Toujours en cours, pas encore terminé |
|
||||
|
||||
## Catégories d'Interactions
|
||||
|
||||
### Interactions de Blocs
|
||||
|
||||
Opérations sur les blocs :
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `PlaceBlockInteraction` | Placer un bloc |
|
||||
| `BreakBlockInteraction` | Casser un bloc |
|
||||
| `DestroyBlockInteraction` | Détruire sans drops |
|
||||
| `ChangeBlockInteraction` | Changer le type de bloc |
|
||||
| `UseBlockInteraction` | Interagir avec un bloc |
|
||||
| `PlaceFluidInteraction` | Placer un fluide |
|
||||
|
||||
### Interactions d'Objets
|
||||
|
||||
Opérations avec les objets :
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `AddItemInteraction` | Ajouter un objet à l'inventaire |
|
||||
| `EquipItemInteraction` | Équiper un objet |
|
||||
| `ModifyInventoryInteraction` | Modifier le contenu de l'inventaire |
|
||||
|
||||
### Interactions d'Entités
|
||||
|
||||
Opérations sur les entités :
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `UseEntityInteraction` | Interagir avec une entité |
|
||||
| `RemoveEntityInteraction` | Supprimer une entité |
|
||||
| `ApplyEffectInteraction` | Appliquer un effet de statut |
|
||||
| `ClearEntityEffectInteraction` | Supprimer les effets |
|
||||
|
||||
### Interactions de Combat
|
||||
|
||||
Dégâts et combat :
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `DamageCalculator` | Calculer les dégâts |
|
||||
| `DamageEffects` | Appliquer les effets de dégâts |
|
||||
| `Knockback` | Appliquer le knockback |
|
||||
| `DirectionalKnockback` | Knockback directionnel |
|
||||
| `ForceKnockback` | Knockback basé sur la force |
|
||||
|
||||
### Interactions UI
|
||||
|
||||
Interface utilisateur :
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `OpenContainerInteraction` | Ouvrir l'UI de conteneur |
|
||||
| `OpenPageInteraction` | Ouvrir une page |
|
||||
| `OpenCustomUIInteraction` | Ouvrir une UI personnalisée |
|
||||
| `SendMessageInteraction` | Envoyer un message au joueur |
|
||||
|
||||
### Interactions de Structures
|
||||
|
||||
Modification du monde :
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `SpawnPrefabInteraction` | Faire apparaître un prefab/structure |
|
||||
| `LaunchProjectileInteraction` | Lancer un projectile |
|
||||
|
||||
### Flux de Contrôle
|
||||
|
||||
Interactions de chaînage et conditions :
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `SerialInteraction` | Exécuter les interactions en séquence |
|
||||
| `ParallelInteraction` | Exécuter les interactions simultanément |
|
||||
| `SelectInteraction` | Choisir entre les interactions |
|
||||
| `ConditionInteraction` | Exécution conditionnelle |
|
||||
| `RepeatInteraction` | Répéter une interaction |
|
||||
| `CancelChainInteraction` | Annuler la chaîne |
|
||||
|
||||
### Interactions de Stats
|
||||
|
||||
Statistiques d'entités :
|
||||
|
||||
| Interaction | Description |
|
||||
|-------------|-------------|
|
||||
| `ChangeStatInteraction` | Modifier une stat |
|
||||
| `StatsConditionInteraction` | Vérifier les conditions de stats |
|
||||
|
||||
## Propriétés d'Interaction
|
||||
|
||||
Propriétés communes à toutes les interactions :
|
||||
|
||||
```yaml
|
||||
# Exemple de configuration d'interaction
|
||||
MyInteraction:
|
||||
Type: PlaceBlock
|
||||
RunTime: 0.5 # Durée en secondes
|
||||
ViewDistance: 96.0 # Distance de visibilité
|
||||
HorizontalSpeedMultiplier: 1.0
|
||||
CancelOnItemChange: true
|
||||
Effects:
|
||||
WaitForAnimationToFinish: true
|
||||
ItemAnimationId: "swing"
|
||||
Rules:
|
||||
# Règles d'activation
|
||||
```
|
||||
|
||||
### InteractionEffects
|
||||
|
||||
Effets visuels et audio :
|
||||
|
||||
- `ItemAnimationId` - Animation à jouer
|
||||
- `WaitForAnimationToFinish` - Attendre l'animation
|
||||
- Effets sonores
|
||||
- Effets de particules
|
||||
|
||||
### InteractionRules
|
||||
|
||||
Contrôle quand les interactions peuvent s'exécuter :
|
||||
|
||||
- Restrictions de mode de jeu
|
||||
- Exigences d'état
|
||||
- Vérifications de cooldown
|
||||
|
||||
## Sélecteurs
|
||||
|
||||
Les sélecteurs déterminent quelles entités ou blocs sont ciblés :
|
||||
|
||||
| Sélecteur | Description |
|
||||
|-----------|-------------|
|
||||
| `RaycastSelector` | Lancer un rayon depuis la caméra |
|
||||
| `AOECircleSelector` | Zone d'effet circulaire |
|
||||
| `AOECylinderSelector` | Zone d'effet cylindrique |
|
||||
| `StabSelector` | Estoc à courte portée |
|
||||
| `HorizontalSelector` | Balayage horizontal |
|
||||
|
||||
## Accéder aux Interactions
|
||||
|
||||
### Depuis les Objets
|
||||
|
||||
Les objets définissent leurs interactions dans les fichiers d'assets. À l'exécution :
|
||||
|
||||
```java
|
||||
ItemStack item = player.getInventory().getActiveItem();
|
||||
Item itemAsset = item.getItem();
|
||||
// L'objet définit ses interactions primaires/secondaires
|
||||
```
|
||||
|
||||
### Depuis les Blocs
|
||||
|
||||
Les blocs définissent les interactions d'utilisation :
|
||||
|
||||
```java
|
||||
BlockType blockType = world.getBlockType(position);
|
||||
// Le bloc définit son interaction d'utilisation
|
||||
```
|
||||
|
||||
## Bonnes Pratiques
|
||||
|
||||
{{< callout type="info" >}}
|
||||
**Directives d'Interaction :**
|
||||
- Les interactions sont principalement pilotées par les données via les assets
|
||||
- Utilisez les types d'interaction existants quand possible
|
||||
- Chaînez les interactions pour des comportements complexes
|
||||
- Utilisez les sélecteurs pour cibler de manière appropriée
|
||||
- Considérez le mode de jeu dans les règles
|
||||
{{< /callout >}}
|
||||
|
||||
{{< callout type="warning" >}}
|
||||
**Note de Performance :** Les chaînes d'interaction complexes avec de nombreuses opérations parallèles peuvent impacter les performances. Gardez les chaînes efficaces.
|
||||
{{< /callout >}}
|
||||
|
||||
## Lectures Complémentaires
|
||||
|
||||
Pour des informations détaillées sur les types d'interaction spécifiques, consultez les sous-pages.
|
||||
270
content/world/interactions/selectors.en.md
Normal file
270
content/world/interactions/selectors.en.md
Normal file
@@ -0,0 +1,270 @@
|
||||
---
|
||||
title: Selectors
|
||||
type: docs
|
||||
weight: 2
|
||||
---
|
||||
|
||||
Selectors determine which entities or blocks are targeted by an interaction.
|
||||
|
||||
**Package:** `com.hypixel.hytale.server.core.modules.interaction.interaction.config.selector`
|
||||
|
||||
## Selector Types
|
||||
|
||||
### RaycastSelector
|
||||
|
||||
Casts a ray from the player's view to find targets:
|
||||
|
||||
```yaml
|
||||
Selector:
|
||||
Type: Raycast
|
||||
Range: 5.0
|
||||
BlockCollision: true
|
||||
EntityCollision: true
|
||||
```
|
||||
|
||||
Properties:
|
||||
- `Range` - Maximum distance
|
||||
- `BlockCollision` - Stop at blocks
|
||||
- `EntityCollision` - Detect entities
|
||||
|
||||
### AOECircleSelector
|
||||
|
||||
Selects all targets in a circular area:
|
||||
|
||||
```yaml
|
||||
Selector:
|
||||
Type: AOECircle
|
||||
Radius: 3.0
|
||||
Height: 2.0
|
||||
```
|
||||
|
||||
Properties:
|
||||
- `Radius` - Circle radius
|
||||
- `Height` - Vertical extent
|
||||
|
||||
### AOECylinderSelector
|
||||
|
||||
Selects targets in a cylindrical area:
|
||||
|
||||
```yaml
|
||||
Selector:
|
||||
Type: AOECylinder
|
||||
Radius: 4.0
|
||||
Height: 3.0
|
||||
HeightOffset: 0.0
|
||||
```
|
||||
|
||||
### StabSelector
|
||||
|
||||
Close-range forward attack:
|
||||
|
||||
```yaml
|
||||
Selector:
|
||||
Type: Stab
|
||||
Range: 2.0
|
||||
Width: 1.5
|
||||
```
|
||||
|
||||
### HorizontalSelector
|
||||
|
||||
Horizontal sweep attack:
|
||||
|
||||
```yaml
|
||||
Selector:
|
||||
Type: Horizontal
|
||||
Range: 3.0
|
||||
Angle: 90.0
|
||||
```
|
||||
|
||||
## Selector Interface
|
||||
|
||||
The `Selector` interface provides methods for targeting:
|
||||
|
||||
```java
|
||||
import com.hypixel.hytale.component.CommandBuffer;
|
||||
import com.hypixel.hytale.component.Ref;
|
||||
import com.hypixel.hytale.function.consumer.TriIntConsumer;
|
||||
import com.hypixel.hytale.math.vector.Vector4d;
|
||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public interface Selector {
|
||||
// Select target entities - consumer receives entity ref AND hit location
|
||||
void selectTargetEntities(
|
||||
CommandBuffer<EntityStore> buffer,
|
||||
Ref<EntityStore> attacker,
|
||||
BiConsumer<Ref<EntityStore>, Vector4d> consumer,
|
||||
Predicate<Ref<EntityStore>> filter
|
||||
);
|
||||
|
||||
// Select target blocks
|
||||
void selectTargetBlocks(
|
||||
CommandBuffer<EntityStore> buffer,
|
||||
Ref<EntityStore> attacker,
|
||||
TriIntConsumer consumer
|
||||
);
|
||||
|
||||
// Update selector state each tick
|
||||
void tick(
|
||||
CommandBuffer<EntityStore> buffer,
|
||||
Ref<EntityStore> entity,
|
||||
float startTime,
|
||||
float currentTime
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
{{< callout type="info" >}}
|
||||
**Note:** The instance method `selectTargetEntities()` provides hit location via `Vector4d`, while the static `selectNearbyEntities()` only provides entity references.
|
||||
{{< /callout >}}
|
||||
|
||||
## Entity Matchers
|
||||
|
||||
Filter which entities can be selected:
|
||||
|
||||
### VulnerableMatcher
|
||||
|
||||
Only select entities that can take damage:
|
||||
|
||||
```yaml
|
||||
Matcher:
|
||||
Type: Vulnerable
|
||||
```
|
||||
|
||||
### PlayerMatcher
|
||||
|
||||
Only select players:
|
||||
|
||||
```yaml
|
||||
Matcher:
|
||||
Type: Player
|
||||
```
|
||||
|
||||
## Static Selection Utilities
|
||||
|
||||
The `Selector` interface provides static methods for common operations:
|
||||
|
||||
### Select Nearby Blocks
|
||||
|
||||
```java
|
||||
Selector.selectNearbyBlocks(
|
||||
commandBuffer,
|
||||
attackerRef,
|
||||
range,
|
||||
(x, y, z) -> {
|
||||
// Process each block position
|
||||
}
|
||||
);
|
||||
|
||||
// Or from a position
|
||||
Selector.selectNearbyBlocks(
|
||||
position,
|
||||
range,
|
||||
(x, y, z) -> {
|
||||
// Process each block position
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
### Select Nearby Entities
|
||||
|
||||
```java
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
Selector.selectNearbyEntities(
|
||||
commandBuffer,
|
||||
attackerRef,
|
||||
range,
|
||||
(Consumer<Ref<EntityStore>>) entityRef -> {
|
||||
// Process each entity
|
||||
},
|
||||
(Predicate<Ref<EntityStore>>) entityRef -> {
|
||||
// Filter predicate - return true to include
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
// Or from a position with ComponentAccessor
|
||||
Selector.selectNearbyEntities(
|
||||
componentAccessor,
|
||||
position,
|
||||
range,
|
||||
entityRef -> {
|
||||
// Process each entity
|
||||
},
|
||||
entityRef -> true // Filter or null
|
||||
);
|
||||
```
|
||||
|
||||
{{< callout type="info" >}}
|
||||
**Note:** The consumer receives `Ref<EntityStore>` only. For entity hit positions (like `Vector4d`), use `selectTargetEntities()` from a Selector instance instead.
|
||||
{{< /callout >}}
|
||||
|
||||
## Practical Examples
|
||||
|
||||
### Sword Slash
|
||||
|
||||
```yaml
|
||||
SwordSlash:
|
||||
Type: DamageCalculator
|
||||
Selector:
|
||||
Type: Horizontal
|
||||
Range: 2.5
|
||||
Angle: 120.0
|
||||
Matcher:
|
||||
Type: Vulnerable
|
||||
Damage:
|
||||
Base: 10.0
|
||||
Type: Physical
|
||||
```
|
||||
|
||||
### Healing Aura
|
||||
|
||||
```yaml
|
||||
HealingAura:
|
||||
Type: ChangeStatInteraction
|
||||
Selector:
|
||||
Type: AOECircle
|
||||
Radius: 5.0
|
||||
Height: 3.0
|
||||
Matcher:
|
||||
Type: Player
|
||||
Stat: Health
|
||||
Amount: 5.0
|
||||
```
|
||||
|
||||
### Mining
|
||||
|
||||
```yaml
|
||||
Mining:
|
||||
Type: BreakBlock
|
||||
Selector:
|
||||
Type: Raycast
|
||||
Range: 4.0
|
||||
BlockCollision: true
|
||||
EntityCollision: false
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
{{< callout type="info" >}}
|
||||
**Selector Guidelines:**
|
||||
- Use appropriate range for the interaction type
|
||||
- Apply filters to avoid unintended targets
|
||||
- Consider performance with large AOE selectors
|
||||
- Use raycast for precision attacks
|
||||
- Always check `entity.isValid()` before accessing entity components
|
||||
{{< /callout >}}
|
||||
|
||||
{{< callout type="warning" >}}
|
||||
**Entity Validity:** Before interacting with an entity, verify it is still valid to prevent null pointer exceptions:
|
||||
```java
|
||||
if (entityRef.isValid()) {
|
||||
// Safe to access entity components
|
||||
// ... perform operations
|
||||
}
|
||||
```
|
||||
The server validates entity references internally, but custom code should always check validity with `Ref.isValid()`.
|
||||
{{< /callout >}}
|
||||
270
content/world/interactions/selectors.fr.md
Normal file
270
content/world/interactions/selectors.fr.md
Normal file
@@ -0,0 +1,270 @@
|
||||
---
|
||||
title: Sélecteurs
|
||||
type: docs
|
||||
weight: 2
|
||||
---
|
||||
|
||||
Les sélecteurs déterminent quelles entités ou blocs sont ciblés par une interaction.
|
||||
|
||||
**Package:** `com.hypixel.hytale.server.core.modules.interaction.interaction.config.selector`
|
||||
|
||||
## Types de Sélecteurs
|
||||
|
||||
### RaycastSelector
|
||||
|
||||
Lance un rayon depuis la vue du joueur pour trouver des cibles :
|
||||
|
||||
```yaml
|
||||
Selector:
|
||||
Type: Raycast
|
||||
Range: 5.0
|
||||
BlockCollision: true
|
||||
EntityCollision: true
|
||||
```
|
||||
|
||||
Propriétés :
|
||||
- `Range` - Distance maximale
|
||||
- `BlockCollision` - S'arrêter aux blocs
|
||||
- `EntityCollision` - Détecter les entités
|
||||
|
||||
### AOECircleSelector
|
||||
|
||||
Sélectionne toutes les cibles dans une zone circulaire :
|
||||
|
||||
```yaml
|
||||
Selector:
|
||||
Type: AOECircle
|
||||
Radius: 3.0
|
||||
Height: 2.0
|
||||
```
|
||||
|
||||
Propriétés :
|
||||
- `Radius` - Rayon du cercle
|
||||
- `Height` - Étendue verticale
|
||||
|
||||
### AOECylinderSelector
|
||||
|
||||
Sélectionne les cibles dans une zone cylindrique :
|
||||
|
||||
```yaml
|
||||
Selector:
|
||||
Type: AOECylinder
|
||||
Radius: 4.0
|
||||
Height: 3.0
|
||||
HeightOffset: 0.0
|
||||
```
|
||||
|
||||
### StabSelector
|
||||
|
||||
Attaque vers l'avant à courte portée :
|
||||
|
||||
```yaml
|
||||
Selector:
|
||||
Type: Stab
|
||||
Range: 2.0
|
||||
Width: 1.5
|
||||
```
|
||||
|
||||
### HorizontalSelector
|
||||
|
||||
Attaque en balayage horizontal :
|
||||
|
||||
```yaml
|
||||
Selector:
|
||||
Type: Horizontal
|
||||
Range: 3.0
|
||||
Angle: 90.0
|
||||
```
|
||||
|
||||
## Interface Selector
|
||||
|
||||
L'interface `Selector` fournit des méthodes pour le ciblage :
|
||||
|
||||
```java
|
||||
import com.hypixel.hytale.component.CommandBuffer;
|
||||
import com.hypixel.hytale.component.Ref;
|
||||
import com.hypixel.hytale.function.consumer.TriIntConsumer;
|
||||
import com.hypixel.hytale.math.vector.Vector4d;
|
||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public interface Selector {
|
||||
// Sélectionner les entités cibles - le consumer reçoit la ref ET la position de frappe
|
||||
void selectTargetEntities(
|
||||
CommandBuffer<EntityStore> buffer,
|
||||
Ref<EntityStore> attacker,
|
||||
BiConsumer<Ref<EntityStore>, Vector4d> consumer,
|
||||
Predicate<Ref<EntityStore>> filter
|
||||
);
|
||||
|
||||
// Sélectionner les blocs cibles
|
||||
void selectTargetBlocks(
|
||||
CommandBuffer<EntityStore> buffer,
|
||||
Ref<EntityStore> attacker,
|
||||
TriIntConsumer consumer
|
||||
);
|
||||
|
||||
// Mettre à jour l'état du sélecteur à chaque tick
|
||||
void tick(
|
||||
CommandBuffer<EntityStore> buffer,
|
||||
Ref<EntityStore> entity,
|
||||
float startTime,
|
||||
float currentTime
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
{{< callout type="info" >}}
|
||||
**Note :** La méthode d'instance `selectTargetEntities()` fournit la position de frappe via `Vector4d`, tandis que la méthode statique `selectNearbyEntities()` fournit uniquement les références d'entités.
|
||||
{{< /callout >}}
|
||||
|
||||
## Filtres d'Entités
|
||||
|
||||
Filtrer quelles entités peuvent être sélectionnées :
|
||||
|
||||
### VulnerableMatcher
|
||||
|
||||
Sélectionner uniquement les entités pouvant subir des dégâts :
|
||||
|
||||
```yaml
|
||||
Matcher:
|
||||
Type: Vulnerable
|
||||
```
|
||||
|
||||
### PlayerMatcher
|
||||
|
||||
Sélectionner uniquement les joueurs :
|
||||
|
||||
```yaml
|
||||
Matcher:
|
||||
Type: Player
|
||||
```
|
||||
|
||||
## Utilitaires de Sélection Statique
|
||||
|
||||
L'interface `Selector` fournit des méthodes statiques pour les opérations courantes :
|
||||
|
||||
### Sélectionner les Blocs Proches
|
||||
|
||||
```java
|
||||
Selector.selectNearbyBlocks(
|
||||
commandBuffer,
|
||||
attackerRef,
|
||||
range,
|
||||
(x, y, z) -> {
|
||||
// Traiter chaque position de bloc
|
||||
}
|
||||
);
|
||||
|
||||
// Ou depuis une position
|
||||
Selector.selectNearbyBlocks(
|
||||
position,
|
||||
range,
|
||||
(x, y, z) -> {
|
||||
// Traiter chaque position de bloc
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
### Sélectionner les Entités Proches
|
||||
|
||||
```java
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
Selector.selectNearbyEntities(
|
||||
commandBuffer,
|
||||
attackerRef,
|
||||
range,
|
||||
(Consumer<Ref<EntityStore>>) entityRef -> {
|
||||
// Traiter chaque entité
|
||||
},
|
||||
(Predicate<Ref<EntityStore>>) entityRef -> {
|
||||
// Prédicat de filtre - retourner true pour inclure
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
// Ou depuis une position avec ComponentAccessor
|
||||
Selector.selectNearbyEntities(
|
||||
componentAccessor,
|
||||
position,
|
||||
range,
|
||||
entityRef -> {
|
||||
// Traiter chaque entité
|
||||
},
|
||||
entityRef -> true // Filtre ou null
|
||||
);
|
||||
```
|
||||
|
||||
{{< callout type="info" >}}
|
||||
**Note :** Le consumer reçoit uniquement `Ref<EntityStore>`. Pour les positions de frappe d'entité (comme `Vector4d`), utilisez plutôt `selectTargetEntities()` d'une instance de Selector.
|
||||
{{< /callout >}}
|
||||
|
||||
## Exemples Pratiques
|
||||
|
||||
### Tranchant d'Épée
|
||||
|
||||
```yaml
|
||||
SwordSlash:
|
||||
Type: DamageCalculator
|
||||
Selector:
|
||||
Type: Horizontal
|
||||
Range: 2.5
|
||||
Angle: 120.0
|
||||
Matcher:
|
||||
Type: Vulnerable
|
||||
Damage:
|
||||
Base: 10.0
|
||||
Type: Physical
|
||||
```
|
||||
|
||||
### Aura de Soin
|
||||
|
||||
```yaml
|
||||
HealingAura:
|
||||
Type: ChangeStatInteraction
|
||||
Selector:
|
||||
Type: AOECircle
|
||||
Radius: 5.0
|
||||
Height: 3.0
|
||||
Matcher:
|
||||
Type: Player
|
||||
Stat: Health
|
||||
Amount: 5.0
|
||||
```
|
||||
|
||||
### Minage
|
||||
|
||||
```yaml
|
||||
Mining:
|
||||
Type: BreakBlock
|
||||
Selector:
|
||||
Type: Raycast
|
||||
Range: 4.0
|
||||
BlockCollision: true
|
||||
EntityCollision: false
|
||||
```
|
||||
|
||||
## Bonnes Pratiques
|
||||
|
||||
{{< callout type="info" >}}
|
||||
**Directives des Sélecteurs :**
|
||||
- Utilisez une portée appropriée pour le type d'interaction
|
||||
- Appliquez des filtres pour éviter les cibles non voulues
|
||||
- Considérez les performances avec les grands sélecteurs AOE
|
||||
- Utilisez le raycast pour les attaques de précision
|
||||
- Vérifiez toujours `entity.isValid()` avant d'accéder aux composants d'entité
|
||||
{{< /callout >}}
|
||||
|
||||
{{< callout type="warning" >}}
|
||||
**Validité des Entités :** Avant d'interagir avec une entité, vérifiez qu'elle est toujours valide pour éviter les exceptions de pointeur null :
|
||||
```java
|
||||
if (entityRef.isValid()) {
|
||||
// Accès sécurisé aux composants de l'entité
|
||||
// ... effectuer les opérations
|
||||
}
|
||||
```
|
||||
Le serveur valide les références d'entité en interne, mais le code personnalisé doit toujours vérifier la validité avec `Ref.isValid()`.
|
||||
{{< /callout >}}
|
||||
Reference in New Issue
Block a user