Files
Documentation/content/reference/buildertools/scripted-brushes.fr.md
2026-01-20 20:33:59 +01:00

388 lines
5.7 KiB
Markdown

---
title: Brosses Scriptees
type: docs
weight: 1
---
Les brosses scriptees permettent de creer des operations de brosse complexes et programmables via definitions d'assets JSON.
**Package:** `com.hypixel.hytale.builtin.buildertools.scriptedbrushes`
## Architecture
```
Brosses Scriptees
├── Assets
│ └── ScriptedBrushAsset - Definitions de brosses
├── Operations
│ ├── BrushOperation - Classe operation de base
│ ├── SequenceBrushOperation - Operations sequentielles
│ └── GlobalBrushOperation - Modificateurs globaux
├── Categories
│ ├── Operations Forme - Set, fill, shape
│ ├── Operations Masque - Mask, history mask
│ ├── Controle Flux - Boucles, sauts, conditions
│ ├── Operations Materiau - Pattern, replace
│ └── Operations Transform - Offset, dimensions
├── Config
│ ├── BrushConfig - Configuration runtime
│ └── BrushConfigEditStore - Etat edition
└── Commandes
└── BrushConfigCommand - /brushconfig
```
## ScriptedBrushAsset
Definitions de brosses chargees depuis JSON:
**Emplacement Asset:** `BuilderTools/Brushes/`
```yaml
# BuilderTools/Brushes/terrain_sphere.json
{
"Id": "terrain_sphere",
"Operations": [
{
"Type": "Shape",
"Shape": "Sphere"
},
{
"Type": "Dimensions",
"Width": 5,
"Height": 5,
"Depth": 5
},
{
"Type": "Material",
"Pattern": "[Rock_Stone]"
},
{
"Type": "Set"
}
]
}
```
### Acces Asset
```java
// Obtenir asset brosse
ScriptedBrushAsset brush = ScriptedBrushAsset.get("terrain_sphere");
// Obtenir operations
List<BrushOperation> operations = brush.getOperations();
// Charger dans executeur
brush.loadIntoExecutor(executor);
```
## Types d'Operations
### Operations de Forme
| Operation | Description |
|-----------|-------------|
| `Set` | Appliquer blocs aux positions |
| `Shape` | Definir forme brosse (Sphere, Cube, Cylinder) |
| `Delete` | Supprimer blocs |
| `Smooth` | Lisser terrain |
| `Erode` | Eroder terrain |
| `Lift` | Elever terrain |
| `Melt` | Fondre terrain |
```yaml
{
"Type": "Shape",
"Shape": "Sphere" // Sphere, Cube, Cylinder
}
```
### Operations de Dimension
```yaml
{
"Type": "Dimensions",
"Width": 10,
"Height": 5,
"Depth": 10
}
```
```yaml
{
"Type": "RandomizeDimensions",
"MinWidth": 3,
"MaxWidth": 7,
"MinHeight": 3,
"MaxHeight": 7
}
```
### Operations de Materiau
```yaml
{
"Type": "Material",
"Pattern": "[50%Rock_Stone, 50%Rock_Shale]"
}
```
```yaml
{
"Type": "BlockPattern",
"Pattern": "[Rock_Stone]"
}
```
```yaml
{
"Type": "Replace",
"From": "[Grass]",
"To": "[Dirt]"
}
```
### Operations de Masque
```yaml
{
"Type": "Mask",
"Mask": "[!Air]"
}
```
```yaml
{
"Type": "AppendMask",
"Mask": "[!Water]"
}
```
```yaml
{
"Type": "HistoryMask"
// Affecter uniquement blocs precedemment modifies
}
```
```yaml
{
"Type": "UseBrushMask"
// Utiliser masque des arguments outil
}
```
### Operations de Decalage
```yaml
{
"Type": "Offset",
"X": 0,
"Y": 5,
"Z": 0
}
```
```yaml
{
"Type": "RandomOffset",
"MinX": -2,
"MaxX": 2,
"MinY": 0,
"MaxY": 5,
"MinZ": -2,
"MaxZ": 2
}
```
### Controle de Flux
#### Boucles
```yaml
{
"Type": "Loop",
"Count": 5,
"StartIndex": 2,
"EndIndex": 6
}
```
```yaml
{
"Type": "LoopRandom",
"MinCount": 3,
"MaxCount": 8
}
```
```yaml
{
"Type": "CircleOffsetAndLoop",
"Radius": 5,
"Count": 8
}
```
#### Conditionnels
```yaml
{
"Type": "JumpIfBlockType",
"BlockType": "Air",
"Index": 10,
"ElseIndex": 5
}
```
```yaml
{
"Type": "JumpIfClickType",
"ClickType": "Primary",
"Index": 3
}
```
```yaml
{
"Type": "JumpIfCompare",
"Variable": "height",
"Operator": ">",
"Value": 5,
"Index": 8
}
```
```yaml
{
"Type": "JumpToIndex",
"Index": 0
}
```
```yaml
{
"Type": "Exit"
// Arreter execution brosse
}
```
### Operations Speciales
```yaml
{
"Type": "Echo",
"Message": "Brosse appliquee!"
}
```
```yaml
{
"Type": "RunCommand",
"Command": "/fill [Stone]"
}
```
```yaml
{
"Type": "PastePrefab",
"PrefabId": "tree_oak"
}
```
```yaml
{
"Type": "HeightmapLayer",
"Layer": 0
}
```
### Operations Sauvegarde/Chargement
```yaml
{
"Type": "LoadOperationsFromAsset",
"AssetId": "common_setup"
}
```
```yaml
{
"Type": "SaveBrushConfig",
"Key": "my_config"
}
```
```yaml
{
"Type": "LoadBrushConfig",
"Key": "my_config"
}
```
## Operations Globales
Operations qui affectent toute la brosse:
```yaml
{
"Type": "Debug",
"Enabled": true
}
```
```yaml
{
"Type": "DisableHoldInteraction"
// Declencher uniquement au clic, pas au maintien
}
```
```yaml
{
"Type": "IgnoreExistingBrushData"
}
```
## Commande Config Brosse
Gerer les configurations de brosse via commande:
| Commande | Description |
|----------|-------------|
| `/brushconfig` | Commande config brosse de base |
| `/brushconfig load <id>` | Charger config brosse |
| `/brushconfig list` | Lister brosses disponibles |
| `/brushconfig clear` | Effacer config actuelle |
| `/brushconfig exit` | Quitter mode brosse |
| `/brushconfig debugstep` | Executer pas a pas |
## Utilisation de l'API
### Charger une Brosse
```java
ScriptedBrushAsset brush = ScriptedBrushAsset.get("terrain_sphere");
```
### Executer une Brosse
```java
BrushConfigCommandExecutor executor = new BrushConfigCommandExecutor();
brush.loadIntoExecutor(executor);
// Executer operations sequentiellement
```
### Acceder aux Operations
```java
List<BrushOperation> operations = brush.getOperations();
for (BrushOperation op : operations) {
if (op instanceof SequenceBrushOperation) {
// Operation sequentielle
} else if (op instanceof GlobalBrushOperation) {
// Modificateur global
}
}
```