@@ -44,9 +44,13 @@ public void generate(ChunkPos pos, World world, IChunkGenerator chunkGenerator,
4444 int chunkZ = pos .z ;
4545 Vec3i chunkCoord = new Vec3i (chunkX , chunkZ , world .provider .getDimension ());
4646 Map <BlockPos ,IBlockState > cache = retrieveCache (chunkCoord );
47- for (Entry <BlockPos ,IBlockState > ent : cache .entrySet ()){
48- spawn (cache .get (ent .getKey ()),world ,ent .getKey (),world .provider .getDimension (),false ,replaceBlock );
47+
48+ if ( !cache .isEmpty () ) { // if there is something in the cache, try to spawn it
49+ for (Entry <BlockPos ,IBlockState > ent : cache .entrySet ()){
50+ spawn (cache .get (ent .getKey ()),world ,ent .getKey (),world .provider .getDimension (),false ,replaceBlock );
51+ }
4952 }
53+
5054 // now to ore spawn
5155
5256 int blockX = chunkX * 16 + 8 ;
@@ -94,20 +98,38 @@ public void generate(ChunkPos pos, World world, IChunkGenerator chunkGenerator,
9498 new Vec3i ( 0 , 0 , 1 ),new Vec3i ( 1 , 0 , 1 ),
9599 new Vec3i ( 0 , 1 , 1 ),new Vec3i ( 1 , 1 , 1 )
96100 };
101+
102+ private static final Vec3i [] offsets = {
103+ new Vec3i (-1 ,-1 ,-1 ),new Vec3i ( 0 ,-1 ,-1 ),new Vec3i ( 1 ,-1 ,-1 ),
104+ new Vec3i (-1 , 0 ,-1 ),new Vec3i ( 0 , 0 ,-1 ),new Vec3i ( 1 , 0 ,-1 ),
105+ new Vec3i (-1 , 1 ,-1 ),new Vec3i ( 0 , 1 ,-1 ),new Vec3i ( 1 , 1 ,-1 ),
106+
107+ new Vec3i (-1 ,-1 , 0 ),new Vec3i ( 0 ,-1 , 0 ),new Vec3i ( 1 ,-1 , 0 ),
108+ new Vec3i (-1 , 0 , 0 ),new Vec3i ( 0 , 0 , 0 ),new Vec3i ( 1 , 0 , 0 ),
109+ new Vec3i (-1 , 1 , 0 ),new Vec3i ( 0 , 1 , 0 ),new Vec3i ( 1 , 1 , 0 ),
110+
111+ new Vec3i (-1 ,-1 , 1 ),new Vec3i ( 0 ,-1 , 1 ),new Vec3i ( 1 ,-1 , 1 ),
112+ new Vec3i (-1 , 0 , 1 ),new Vec3i ( 0 , 0 , 1 ),new Vec3i ( 1 , 0 , 1 ),
113+ new Vec3i (-1 , 1 , 1 ),new Vec3i ( 0 , 1 , 1 ),new Vec3i ( 1 , 1 , 1 )
114+ };
115+
97116 private static final int [] offsetIndexRef = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,24 ,25 ,26 };
98117 private static final int [] offsetIndexRef_small = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 };
99118
100119 public static void spawnOre ( BlockPos blockPos , IBlockState oreBlock , int quantity , World world , Random prng , IBlockState replaceBlock ) {
101120 int count = quantity ;
102- int lutType = quantity <= 8 ?offsetIndexRef_small .length :offsetIndexRef .length ;
103- int [] lut = quantity <= 8 ?offsetIndexRef_small :offsetIndexRef ;
121+ int lutType = (quantity < 8 )?offsetIndexRef_small .length :offsetIndexRef .length ;
122+ int [] lut = (quantity < 8 )?offsetIndexRef_small :offsetIndexRef ;
123+ Vec3i [] offs = new Vec3i [lutType ];
124+
125+ System .arraycopy ((quantity < 8 )?offsets_small :offsets , 0 , offs , 0 , lutType );
104126
105127 if ( quantity < 27 ) {
106128 int [] scrambledLUT = new int [lutType ];
107129 System .arraycopy (lut , 0 , scrambledLUT , 0 , scrambledLUT .length );
108130 scramble (scrambledLUT ,prng );
109131 while (count > 0 ){
110- spawn (oreBlock ,world ,blockPos .add (offsets_small [scrambledLUT [--count ]]),world .provider .getDimension (),true ,replaceBlock );
132+ spawn (oreBlock ,world ,blockPos .add (offs [scrambledLUT [--count ]]),world .provider .getDimension (),true ,replaceBlock );
111133 }
112134 return ;
113135 }
0 commit comments