230 lines
4.7 KiB
Markdown
230 lines
4.7 KiB
Markdown
---
|
|
title: Editeur Prefab
|
|
type: docs
|
|
weight: 3
|
|
---
|
|
|
|
L'editeur de prefabs permet de creer, editer et gerer des structures prefabriquees qui peuvent etre placees dans le monde.
|
|
|
|
**Package:** `com.hypixel.hytale.builtin.buildertools.prefabeditor`
|
|
|
|
## Architecture
|
|
|
|
```
|
|
Editeur Prefab
|
|
├── Gestion Sessions
|
|
│ ├── PrefabEditSession - Session d'edition active
|
|
│ └── PrefabEditSessionManager - Coordinateur sessions
|
|
├── Composants
|
|
│ ├── PrefabAnchor - Definitions points d'ancrage
|
|
│ └── PrefabEditorCreationSettings
|
|
├── Interactions
|
|
│ ├── PrefabSelectionInteraction
|
|
│ └── PrefabSetAnchorInteraction
|
|
├── Systemes
|
|
│ ├── PrefabDirtySystems - Suivi changements
|
|
│ └── PrefabMarkerProvider - Marqueurs d'ancrage
|
|
└── Commandes
|
|
└── PrefabEditCommand
|
|
```
|
|
|
|
## Session Edition Prefab
|
|
|
|
### Demarrer une Session
|
|
|
|
```
|
|
/prefabedit <prefab_id>
|
|
```
|
|
|
|
Cela entre en mode edition prefab ou:
|
|
- Les outils de selection fonctionnent dans les limites du prefab
|
|
- Les changements sont suivis separement
|
|
- Les ancres peuvent etre definies
|
|
|
|
### PrefabEditSession
|
|
|
|
```java
|
|
public class PrefabEditSession {
|
|
// Session d'edition active pour un prefab
|
|
// Suit modifications et ancres
|
|
}
|
|
```
|
|
|
|
### Gestionnaire de Sessions
|
|
|
|
```java
|
|
PrefabEditSessionManager manager = BuilderToolsPlugin.get().getPrefabEditSessionManager();
|
|
|
|
// Verifier si joueur edite
|
|
boolean isEditing = manager.isEditing(player);
|
|
|
|
// Obtenir session active
|
|
PrefabEditSession session = manager.getSession(player);
|
|
```
|
|
|
|
## Ancres Prefab
|
|
|
|
Les ancres definissent des points speciaux dans un prefab:
|
|
|
|
### PrefabAnchor
|
|
|
|
```java
|
|
public class PrefabAnchor {
|
|
// Position relative a l'origine prefab
|
|
// Identifiant nom
|
|
// Type d'ancre
|
|
}
|
|
```
|
|
|
|
### Definir des Ancres
|
|
|
|
Utiliser l'interaction d'ancrage ou commande:
|
|
|
|
```
|
|
/prefab anchor set <nom> [x y z]
|
|
/prefab anchor remove <nom>
|
|
/prefab anchor list
|
|
```
|
|
|
|
### Types d'Ancres
|
|
|
|
| Type | Description |
|
|
|------|-------------|
|
|
| `origin` | Origine placement prefab |
|
|
| `spawn` | Point de spawn entite |
|
|
| `connection` | Connexion vers autres prefabs |
|
|
| `custom` | Ancre definie par utilisateur |
|
|
|
|
## Commandes Prefab
|
|
|
|
### /prefab
|
|
|
|
Commande principale gestion prefabs:
|
|
|
|
```
|
|
/prefab save <nom> Sauver selection comme prefab
|
|
/prefab load <nom> Charger prefab vers presse-papiers
|
|
/prefab list Lister prefabs disponibles
|
|
/prefab delete <nom> Supprimer un prefab
|
|
/prefab info <nom> Afficher informations prefab
|
|
```
|
|
|
|
### /prefabedit
|
|
|
|
Entrer en mode edition prefab:
|
|
|
|
```
|
|
/prefabedit <prefab_id> Editer prefab existant
|
|
/prefabedit exit Quitter mode edition
|
|
/prefabedit save Sauvegarder changements
|
|
/prefabedit discard Abandonner changements
|
|
```
|
|
|
|
## Interactions
|
|
|
|
### PrefabSelectionInteraction
|
|
|
|
Selectionner prefabs dans le monde:
|
|
|
|
```java
|
|
// Type d'interaction enregistre
|
|
getCodecRegistry(Interaction.CODEC).register(
|
|
"PrefabSelection",
|
|
PrefabSelectionInteraction.class,
|
|
PrefabSelectionInteraction.CODEC
|
|
);
|
|
```
|
|
|
|
### PrefabSetAnchorInteraction
|
|
|
|
Definir ancres via interaction:
|
|
|
|
```java
|
|
// Permet de cliquer pour placer ancres
|
|
getCodecRegistry(Interaction.CODEC).register(
|
|
"PrefabSetAnchor",
|
|
PrefabSetAnchorInteraction.class,
|
|
PrefabSetAnchorInteraction.CODEC
|
|
);
|
|
```
|
|
|
|
## Parametres de Creation
|
|
|
|
### PrefabEditorCreationSettings
|
|
|
|
Configuration pour creer nouveaux prefabs:
|
|
|
|
```java
|
|
public class PrefabEditorCreationSettings {
|
|
// Parametres pour creation prefab
|
|
// Flag inclure entites
|
|
// Parametres compression
|
|
}
|
|
```
|
|
|
|
## Systemes
|
|
|
|
### PrefabDirtySystems
|
|
|
|
Suit les modifications aux prefabs:
|
|
|
|
```java
|
|
// Marque prefab comme modifie quand changements surviennent
|
|
// Demande sauvegarde a la sortie
|
|
```
|
|
|
|
### PrefabMarkerProvider
|
|
|
|
Fournit marqueurs visuels pour ancres:
|
|
|
|
```java
|
|
// Affiche positions d'ancrage en mode creatif
|
|
// Montre points de connexion
|
|
```
|
|
|
|
## Utilisation de l'API
|
|
|
|
### Sauver Selection comme Prefab
|
|
|
|
```java
|
|
BuilderToolsPlugin tools = BuilderToolsPlugin.get();
|
|
// La selection doit etre definie d'abord
|
|
// Utiliser commande /prefab save ou API
|
|
```
|
|
|
|
### Charger et Placer Prefab
|
|
|
|
```java
|
|
// Charger vers presse-papiers
|
|
// /prefab load <nom>
|
|
|
|
// Coller a l'emplacement
|
|
// /paste
|
|
```
|
|
|
|
### Verifier Mode Edition
|
|
|
|
```java
|
|
PrefabEditSessionManager manager =
|
|
BuilderToolsPlugin.get().getPrefabEditSessionManager();
|
|
|
|
if (manager.isEditing(player)) {
|
|
PrefabEditSession session = manager.getSession(player);
|
|
// Travailler avec session
|
|
}
|
|
```
|
|
|
|
## Stockage Prefab
|
|
|
|
Les prefabs sont stockes dans les donnees du monde:
|
|
|
|
```
|
|
worlds/<monde>/prefabs/<nom>.prefab
|
|
```
|
|
|
|
La structure inclut:
|
|
- Donnees de blocs
|
|
- Donnees d'entites (si incluses)
|
|
- Definitions d'ancres
|
|
- Metadonnees
|