@@ -21,12 +21,38 @@ public class OreGen implements Resource {
2121 private final Extent extent ;
2222 private final Mask mask ;
2323 private final MutableBlockVector3 mutable = new MutableBlockVector3 ();
24+ private final boolean triangular ;
2425
2526 private final double ONE_2 = 1 / 2F ;
2627 private final double ONE_8 = 1 / 8F ;
2728 private final double ONE_16 = 1 / 16F ;
2829
2930 public OreGen (Extent extent , Mask mask , Pattern pattern , int size , int minY , int maxY ) {
31+ this (extent , mask , pattern , size , minY , maxY , false );
32+ }
33+
34+ /**
35+ * Generate ore-like deposits with the given pattern and settings
36+ *
37+ * @param extent Extent to write to
38+ * @param mask mask of where to place
39+ * @param pattern pattern to place
40+ * @param size maximum size of deposits
41+ * @param minY min Y to consider generation from (important for triangular generation)
42+ * @param maxY max Y to consider generation from (important for triangular generation)
43+ * @param triangular if a triangular distribution of ores should be used (rather than
44+ * @throws WorldEditException on error
45+ * @since TODO
46+ */
47+ public OreGen (
48+ Extent extent ,
49+ Mask mask ,
50+ Pattern pattern ,
51+ int size ,
52+ int minY ,
53+ int maxY ,
54+ boolean triangular
55+ ) {
3056 this .maxSize = size ;
3157 this .maxSizeO8 = size * ONE_8 ;
3258 this .maxSizeO16 = size * ONE_16 ;
@@ -36,11 +62,20 @@ public OreGen(Extent extent, Mask mask, Pattern pattern, int size, int minY, int
3662 this .mask = mask ;
3763 this .pattern = pattern ;
3864 this .extent = extent ;
65+ this .triangular = triangular ;
3966 }
4067
4168 @ Override
4269 public boolean spawn (Random rand , int x , int z ) throws WorldEditException {
43- int y = rand .nextInt (maxY - minY ) + minY ;
70+ int y ;
71+ if (this .triangular ) {
72+ int range = maxY - minY ;
73+ int mid = range / 2 ;
74+ int upperMid = range - mid ;
75+ y = minY + rand .nextInt (mid ) + rand .nextInt (upperMid );
76+ } else {
77+ y = rand .nextInt (maxY - minY ) + minY ;
78+ }
4479 if (!mask .test (mutable .setComponents (x , y , z ))) {
4580 return false ;
4681 }
0 commit comments