282 lines
5.4 KiB
Markdown
282 lines
5.4 KiB
Markdown
---
|
|
title: Placement de Props
|
|
type: docs
|
|
weight: 10
|
|
---
|
|
|
|
Le placement de props gère la génération de végétation, de décorations et de petits objets sur les surfaces du terrain.
|
|
|
|
**Package:** `com.hypixel.hytale.builtin.hytalegenerator.props`
|
|
|
|
## Système de Props
|
|
|
|
Les props sont de petites caractéristiques placées après la génération du terrain :
|
|
|
|
```java
|
|
public interface PropPlacer {
|
|
// Placer des props dans un chunk
|
|
void place(GenerationContainer container, int chunkX, int chunkZ);
|
|
}
|
|
|
|
public class PropContext {
|
|
private int x, y, z;
|
|
private Biome biome;
|
|
private BlockType surfaceBlock;
|
|
private float slope;
|
|
private boolean nearWater;
|
|
}
|
|
```
|
|
|
|
## Définition de Prop
|
|
|
|
```yaml
|
|
# props/oak_tree.yaml
|
|
Type: Prop
|
|
Id: oak_tree
|
|
Prefab: prefabs/trees/oak_medium
|
|
Density: 0.02
|
|
Placement:
|
|
SurfaceTypes: [grass_block, dirt]
|
|
MinSlope: 0
|
|
MaxSlope: 30
|
|
MinSpacing: 3
|
|
Requirements:
|
|
ClearanceAbove: 10
|
|
ClearanceRadius: 2
|
|
Variants:
|
|
- prefabs/trees/oak_small
|
|
- prefabs/trees/oak_medium
|
|
- prefabs/trees/oak_large
|
|
VariantWeights: [0.3, 0.5, 0.2]
|
|
```
|
|
|
|
## Fournisseurs de Position
|
|
|
|
Déterminent où les props peuvent être placés :
|
|
|
|
### RandomPositionProvider
|
|
|
|
Positions de surface aléatoires :
|
|
|
|
```yaml
|
|
Type: RandomPosition
|
|
Density: 0.1
|
|
GridSize: 4 # Une tentative par zone 4x4
|
|
```
|
|
|
|
### GridPositionProvider
|
|
|
|
Grille régulière avec gigue :
|
|
|
|
```yaml
|
|
Type: GridPosition
|
|
Spacing: 8
|
|
Jitter: 3
|
|
```
|
|
|
|
### NoisePositionProvider
|
|
|
|
Regroupement basé sur le bruit :
|
|
|
|
```yaml
|
|
Type: NoisePosition
|
|
NoiseScale: 0.05
|
|
Threshold: 0.3
|
|
Density: 0.5
|
|
```
|
|
|
|
## Règles de Placement
|
|
|
|
```java
|
|
public class PlacementRules {
|
|
private Set<BlockType> validSurfaces;
|
|
private float minSlope;
|
|
private float maxSlope;
|
|
private int minSpacing;
|
|
private int clearanceAbove;
|
|
|
|
public boolean canPlace(PropContext ctx) {
|
|
// Vérifier le type de surface
|
|
if (!validSurfaces.contains(ctx.surfaceBlock)) {
|
|
return false;
|
|
}
|
|
|
|
// Vérifier la pente
|
|
if (ctx.slope < minSlope || ctx.slope > maxSlope) {
|
|
return false;
|
|
}
|
|
|
|
// Vérifier l'espacement des autres props
|
|
if (!hasMinSpacing(ctx)) {
|
|
return false;
|
|
}
|
|
|
|
// Vérifier le dégagement
|
|
if (!hasClearance(ctx)) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
```
|
|
|
|
## Props de Végétation
|
|
|
|
### TreePlacer
|
|
|
|
Place des arbres avec variation par biome :
|
|
|
|
```yaml
|
|
Type: TreePlacer
|
|
Biomes:
|
|
forest:
|
|
Density: 0.3
|
|
Types: [oak, birch, maple]
|
|
plains:
|
|
Density: 0.02
|
|
Types: [oak]
|
|
jungle:
|
|
Density: 0.5
|
|
Types: [jungle_tree, palm]
|
|
```
|
|
|
|
### GrassPlacer
|
|
|
|
Place de l'herbe et des fleurs :
|
|
|
|
```yaml
|
|
Type: GrassPlacer
|
|
Density: 0.8
|
|
Variants:
|
|
- Block: tall_grass
|
|
Weight: 0.7
|
|
- Block: fern
|
|
Weight: 0.2
|
|
- Block: flower_red
|
|
Weight: 0.05
|
|
- Block: flower_yellow
|
|
Weight: 0.05
|
|
```
|
|
|
|
### BushPlacer
|
|
|
|
Place des buissons et arbustes :
|
|
|
|
```yaml
|
|
Type: BushPlacer
|
|
Density: 0.1
|
|
Prefabs: [bush_small, bush_medium]
|
|
NearTreesOnly: true
|
|
TreeDistance: 5
|
|
```
|
|
|
|
## Props d'Objets
|
|
|
|
### RockPlacer
|
|
|
|
Place des rochers et blocs :
|
|
|
|
```yaml
|
|
Type: RockPlacer
|
|
Density: 0.05
|
|
Sizes:
|
|
- Prefab: rock_small
|
|
Weight: 0.6
|
|
- Prefab: rock_medium
|
|
Weight: 0.3
|
|
- Prefab: rock_large
|
|
Weight: 0.1
|
|
BiomeModifiers:
|
|
mountains: 2.0
|
|
plains: 0.5
|
|
```
|
|
|
|
### DebrisPlacer
|
|
|
|
Place des troncs tombés, branches :
|
|
|
|
```yaml
|
|
Type: DebrisPlacer
|
|
Density: 0.03
|
|
Items:
|
|
- fallen_log
|
|
- branch
|
|
- leaf_pile
|
|
ForestOnly: true
|
|
```
|
|
|
|
## Intégration des Biomes
|
|
|
|
```java
|
|
public class BiomePropPlacer implements PropPlacer {
|
|
private Map<String, List<PropConfig>> biomeProps;
|
|
|
|
public void place(GenerationContainer container, int chunkX, int chunkZ) {
|
|
for (int x = 0; x < 16; x++) {
|
|
for (int z = 0; z < 16; z++) {
|
|
int worldX = chunkX * 16 + x;
|
|
int worldZ = chunkZ * 16 + z;
|
|
|
|
Biome biome = container.getBiome(worldX, worldZ);
|
|
List<PropConfig> props = biomeProps.get(biome.getId());
|
|
|
|
for (PropConfig prop : props) {
|
|
if (shouldPlace(prop, worldX, worldZ)) {
|
|
placeProp(container, prop, worldX, worldZ);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## Configuration
|
|
|
|
```yaml
|
|
# props/config.yaml
|
|
PropPlacement:
|
|
Enabled: true
|
|
DensityMultiplier: 1.0
|
|
Props:
|
|
- Type: TreePlacer
|
|
Priority: 1
|
|
- Type: BushPlacer
|
|
Priority: 2
|
|
- Type: GrassPlacer
|
|
Priority: 3
|
|
- Type: RockPlacer
|
|
Priority: 4
|
|
```
|
|
|
|
## Prop Placer Personnalisé
|
|
|
|
```java
|
|
public class MyPropPlacer implements PropPlacer {
|
|
@Override
|
|
public void place(GenerationContainer container, int chunkX, int chunkZ) {
|
|
for (int x = 0; x < 16; x++) {
|
|
for (int z = 0; z < 16; z++) {
|
|
if (random.nextFloat() < 0.1f) {
|
|
int surfaceY = container.getHeight(x, z);
|
|
// Placer un prop personnalisé
|
|
placeMyProp(container, x, surfaceY + 1, z);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## Bonnes Pratiques
|
|
|
|
{{< callout type="info" >}}
|
|
**Directives de Placement de Props :**
|
|
- Utilisez une densité appropriée pour l'ambiance du biome
|
|
- Assurez-vous que les props ne se chevauchent pas
|
|
- Ajoutez de la variété avec plusieurs variantes
|
|
- Considérez les performances avec une haute densité
|
|
- Testez la distribution visuelle sur le terrain
|
|
{{< /callout >}}
|