11package com .mcmoddev .orespawn .api ;
22
3- import java .util .Collections ;
4- import java .util .Deque ;
5- import java .util .HashMap ;
6- import java .util .LinkedList ;
7- import java .util .List ;
8- import java .util .Map ;
9- import java .util .Random ;
10- import java .util .Map .Entry ;
11-
123import com .google .common .collect .ImmutableSet ;
134import com .google .gson .JsonObject ;
145import com .mcmoddev .orespawn .OreSpawn ;
15-
166import com .mcmoddev .orespawn .impl .location .BiomeLocationComposition ;
177import net .minecraft .block .state .IBlockState ;
188import net .minecraft .init .Blocks ;
199import net .minecraft .util .math .BlockPos ;
2010import net .minecraft .util .math .Vec3i ;
2111import net .minecraft .world .World ;
2212import net .minecraft .world .biome .Biome ;
23- import net .minecraftforge .fml .common .registry .ForgeRegistries ;
13+
14+ import java .util .*;
15+ import java .util .Map .Entry ;
2416
2517public class FeatureBase {
2618 private static final int MAX_CACHE_SIZE = 2048 ;
2719 /** overflow cache so that ores that spawn at edge of chunk can
2820 * appear in the neighboring chunk without triggering a chunk-load */
29- protected static final Map <Vec3i ,Map <BlockPos ,IBlockState >> overflowCache = new HashMap <>(MAX_CACHE_SIZE );
30- protected static final Deque <Vec3i > cacheOrder = new LinkedList <>();
21+ private static final Map <Vec3i ,Map <BlockPos ,IBlockState >> overflowCache = new HashMap <>(MAX_CACHE_SIZE );
22+ private static final Deque <Vec3i > cacheOrder = new LinkedList <>();
3123 protected Random random ;
3224
3325 public FeatureBase ( Random rand ) {
@@ -44,7 +36,7 @@ private boolean fullMatch( ImmutableSet<BiomeLocation> locs, Biome biome ) {
4436 return false ;
4537 }
4638
47- protected boolean biomeMatch ( Biome chunkBiome , BiomeLocation inp ) {
39+ private boolean biomeMatch ( Biome chunkBiome , BiomeLocation inp ) {
4840 if ( inp .getBiomes ().isEmpty () ) {
4941 return false ;
5042 }
@@ -69,7 +61,7 @@ protected void runCache(int chunkX, int chunkZ, World world, List<IBlockState> b
6961
7062 if ( !cache .isEmpty () ) { // if there is something in the cache, try to spawn it
7163 for (Entry <BlockPos ,IBlockState > ent : cache .entrySet ()){
72- spawnNoCheck ( cache .get (ent .getKey ()), world , ent .getKey (), world .provider .getDimension (), false , blockReplace );
64+ spawnNoCheck ( cache .get (ent .getKey ()), world , ent .getKey (), world .provider .getDimension (), blockReplace );
7365 }
7466 }
7567 }
@@ -116,27 +108,28 @@ private boolean spawnOrCache ( World world, BlockPos coord, List<IBlockState> bl
116108 cacheOverflowBlock (oreBlock ,coord ,dimension );
117109 return true ;
118110 }
111+
119112 return false ;
120113 }
121114
122- protected boolean spawnNoCheck ( IBlockState oreBlock , World world , BlockPos coord , int dimension , boolean cacheOverflow ,
123- List <IBlockState > blockReplace ) {
115+ private void spawnNoCheck ( IBlockState oreBlock , World world , BlockPos coord , int dimension ,
116+ List <IBlockState > blockReplace ) {
124117 if ( oreBlock == null ) {
125118 OreSpawn .LOGGER .fatal ("FeatureBase.spawn() called with a null ore!" );
126- return false ;
119+ return ;
127120 }
128121
129122 BlockPos np = mungeFixYcoord (coord );
130123
131124 if ( coord .getY () >= world .getHeight ()) {
132125 OreSpawn .LOGGER .warn ("Asked to spawn %s above build limit at %s" , oreBlock , coord );
133- return false ;
126+ return ;
134127 }
135128
136- return spawnOrCache (world ,np ,blockReplace ,oreBlock ,cacheOverflow ,dimension );
129+ spawnOrCache (world ,np ,blockReplace ,oreBlock ,false ,dimension );
137130 }
138131
139- protected void cacheOverflowBlock ( IBlockState bs , BlockPos coord , int dimension ){
132+ private void cacheOverflowBlock ( IBlockState bs , BlockPos coord , int dimension ){
140133 Vec3i chunkCoord = new Vec3i (coord .getX () >> 4 , coord .getY () >> 4 , dimension );
141134 if (overflowCache .containsKey (chunkCoord )){
142135 cacheOrder .addLast (chunkCoord );
@@ -145,20 +138,20 @@ protected void cacheOverflowBlock(IBlockState bs, BlockPos coord, int dimension)
145138 overflowCache .get (drop ).clear ();
146139 overflowCache .remove (drop );
147140 }
148- overflowCache .put (chunkCoord , new HashMap <BlockPos , IBlockState >());
141+ overflowCache .put (chunkCoord , new HashMap <>());
149142 }
150143 Map <BlockPos ,IBlockState > cache = overflowCache .getOrDefault (chunkCoord , new HashMap <>());
151144 cache .put (coord , bs );
152145 }
153146
154- protected Map <BlockPos ,IBlockState > retrieveCache ( Vec3i chunkCoord ){
147+ private Map <BlockPos ,IBlockState > retrieveCache ( Vec3i chunkCoord ){
155148 if (overflowCache .containsKey (chunkCoord )){
156149 Map <BlockPos ,IBlockState > cache =overflowCache .get (chunkCoord );
157150 cacheOrder .remove (chunkCoord );
158151 overflowCache .remove (chunkCoord );
159152 return cache ;
160153 } else {
161- return Collections .< BlockPos , IBlockState > emptyMap ();
154+ return Collections .emptyMap ();
162155 }
163156 }
164157
@@ -171,12 +164,8 @@ protected void scramble(int[] target, Random prng) {
171164 }
172165 }
173166
174- protected boolean canReplace (IBlockState target , List <IBlockState > blockToReplace ) {
175- if ( target .getBlock ().equals (Blocks .AIR ) ) {
176- return false ;
177- } else {
178- return blockToReplace .contains (target );
179- }
167+ private boolean canReplace ( IBlockState target , List <IBlockState > blockToReplace ) {
168+ return !target .getBlock ().equals ( Blocks .AIR ) && blockToReplace .contains ( target );
180169 }
181170
182171 protected static final Vec3i [] offsets_small = {
@@ -211,7 +200,7 @@ protected static void mergeDefaults(JsonObject parameters, JsonObject defaultPar
211200 });
212201 }
213202
214- protected double triangularDistribution ( double a , double b , double c ) {
203+ private double triangularDistribution ( double a , double b , double c ) {
215204 double base = (c - a ) / (b - a );
216205 double rand = this .random .nextDouble ();
217206 if (rand < base ) {
0 commit comments