@@ -87,20 +87,6 @@ public void generate(ChunkPos pos, World world, IChunkGenerator chunkGenerator,
8787
8888 }
8989
90- private static final Vec3i [] offsets = {
91- new Vec3i (-1 ,-1 ,-1 ),new Vec3i ( 0 ,-1 ,-1 ),new Vec3i ( 1 ,-1 ,-1 ),
92- new Vec3i (-1 , 0 ,-1 ),new Vec3i ( 0 , 0 ,-1 ),new Vec3i ( 1 , 0 ,-1 ),
93- new Vec3i (-1 , 1 ,-1 ),new Vec3i ( 0 , 1 ,-1 ),new Vec3i ( 1 , 1 ,-1 ),
94-
95- new Vec3i (-1 ,-1 , 0 ),new Vec3i ( 0 ,-1 , 0 ),new Vec3i ( 1 ,-1 , 0 ),
96- new Vec3i (-1 , 0 , 0 ),new Vec3i ( 0 , 0 , 0 ),new Vec3i ( 1 , 0 , 0 ),
97- new Vec3i (-1 , 1 , 0 ),new Vec3i ( 0 , 1 , 0 ),new Vec3i ( 1 , 1 , 0 ),
98-
99- new Vec3i (-1 ,-1 , 1 ),new Vec3i ( 0 ,-1 , 1 ),new Vec3i ( 1 ,-1 , 1 ),
100- new Vec3i (-1 , 0 , 1 ),new Vec3i ( 0 , 0 , 1 ),new Vec3i ( 1 , 0 , 1 ),
101- new Vec3i (-1 , 1 , 1 ),new Vec3i ( 0 , 1 , 1 ),new Vec3i ( 1 , 1 , 1 )
102- };
103-
10490 private static final Vec3i [] offsets_small = {
10591 new Vec3i ( 0 , 0 , 0 ),new Vec3i ( 1 , 0 , 0 ),
10692 new Vec3i ( 0 , 1 , 0 ),new Vec3i ( 1 , 1 , 0 ),
@@ -113,62 +99,72 @@ public void generate(ChunkPos pos, World world, IChunkGenerator chunkGenerator,
11399
114100 public static void spawnOre ( BlockPos blockPos , IBlockState oreBlock , int quantity , World world , Random prng , IBlockState replaceBlock ) {
115101 int count = quantity ;
116- if (quantity <= 8 ){
117- int [] scrambledLUT = new int [offsetIndexRef_small .length ];
118- System .arraycopy (offsetIndexRef_small , 0 , scrambledLUT , 0 , scrambledLUT .length );
102+ int lutType = quantity <= 8 ?offsetIndexRef_small .length :offsetIndexRef .length ;
103+ int [] lut = quantity <= 8 ?offsetIndexRef_small :offsetIndexRef ;
104+
105+ if ( quantity < 27 ) {
106+ int [] scrambledLUT = new int [lutType ];
107+ System .arraycopy (lut , 0 , scrambledLUT , 0 , scrambledLUT .length );
119108 scramble (scrambledLUT ,prng );
120109 while (count > 0 ){
121110 spawn (oreBlock ,world ,blockPos .add (offsets_small [scrambledLUT [--count ]]),world .provider .getDimension (),true ,replaceBlock );
122111 }
123112 return ;
124113 }
125- if (quantity < 27 ){
126- int [] scrambledLUT = new int [offsetIndexRef .length ];
127- System .arraycopy (offsetIndexRef , 0 , scrambledLUT , 0 , scrambledLUT .length );
128- scramble (scrambledLUT ,prng );
129- while (count > 0 ){
130- spawn (oreBlock ,world ,blockPos .add (offsets [scrambledLUT [--count ]]),world .provider .getDimension (),true ,replaceBlock );
131- }
132- return ;
133- }
114+
115+ doSpawnFill ( prng .nextBoolean (), world , blockPos , count , replaceBlock , oreBlock );
116+
117+ return ;
118+ }
119+
120+ private static void doSpawnFill (boolean nextBoolean , World world , BlockPos blockPos , int quantity , IBlockState replaceBlock , IBlockState oreBlock ) {
121+ int count = quantity ;
134122 double radius = Math .pow (quantity , 1.0 /3.0 ) * (3.0 / 4.0 / Math .PI ) + 2 ;
135123 int rSqr = (int )(radius * radius );
136- fill :{
137- if (prng .nextBoolean ()){ // switch-up the direction of fill to reduce predictability
138- // fill from north-east
139- for (int dy = (int )(-1 * radius ); dy < radius ; dy ++){
140- for (int dz = (int )(-1 * radius ); dz < radius ; dz ++){
141- for (int dx = (int )(-1 * radius ); dx < radius ; dx ++){
142- if ((dx *dx + dy *dy + dz *dz ) <= rSqr ){
143- spawn (oreBlock ,world ,blockPos .add (dx ,dy ,dz ),world .provider .getDimension (),true ,replaceBlock );
144- count --;
145- }
146- if (count <= 0 ) {
147- break fill ;
148- }
149- }
124+ if ( nextBoolean ) {
125+ spawnMungeNE ( world , blockPos , rSqr , radius , replaceBlock , count , oreBlock );
126+ } else {
127+ spawnMungeSW ( world , blockPos , rSqr , radius , replaceBlock , count , oreBlock );
128+ }
129+ }
130+
131+
132+ private static void spawnMungeSW (World world , BlockPos blockPos , int rSqr , double radius ,
133+ IBlockState replaceBlock , int count , IBlockState oreBlock ) {
134+ int quantity = count ;
135+ for (int dy = (int )(-1 * radius ); dy < radius ; dy ++){
136+ for (int dx = (int )(radius ); dx >= (int )(-1 * radius ); dx --){
137+ for (int dz = (int )(radius ); dz >= (int )(-1 * radius ); dz --){
138+ if ((dx *dx + dy *dy + dz *dz ) <= rSqr ){
139+ spawn (oreBlock ,world ,blockPos .add (dx ,dy ,dz ),world .provider .getDimension (),true ,replaceBlock );
140+ quantity --;
150141 }
151- }
152- } else {
153- // fill from south-west
154- for (int dy = (int )(-1 * radius ); dy < radius ; dy ++){
155- for (int dx = (int )(radius ); dx >= (int )(-1 * radius ); dx --){
156- for (int dz = (int )(radius ); dz >= (int )(-1 * radius ); dz --){
157- if ((dx *dx + dy *dy + dz *dz ) <= rSqr ){
158- spawn (oreBlock ,world ,blockPos .add (dx ,dy ,dz ),world .provider .getDimension (),true ,replaceBlock );
159- count --;
160- }
161- if (count <= 0 ) {
162- break fill ;
163- }
164- }
142+ if (quantity <= 0 ) {
143+ return ;
165144 }
166145 }
167146 }
168147 }
169- return ;
170148 }
171149
150+
151+ private static void spawnMungeNE (World world , BlockPos blockPos , int rSqr , double radius , IBlockState replaceBlock , int count , IBlockState oreBlock ) {
152+ int quantity = count ;
153+ for (int dy = (int )(-1 * radius ); dy < radius ; dy ++){
154+ for (int dz = (int )(-1 * radius ); dz < radius ; dz ++){
155+ for (int dx = (int )(-1 * radius ); dx < radius ; dx ++){
156+ if ((dx *dx + dy *dy + dz *dz ) <= rSqr ){
157+ spawn (oreBlock ,world ,blockPos .add (dx ,dy ,dz ),world .provider .getDimension (),true ,replaceBlock );
158+ quantity --;
159+ }
160+ if (quantity <= 0 ) {
161+ return ;
162+ }
163+ }
164+ }
165+ }
166+ }
167+
172168 private static void scramble (int [] target , Random prng ) {
173169 for (int i = target .length - 1 ; i > 0 ; i --){
174170 int n = prng .nextInt (i );
0 commit comments