Applied-Energistics-2-tiler.../hooks/MeteoriteWorldGen.java
AlgorithmX2 d4ff8e731d Added Meteorite Spawn Distance Setting.
Added Charged Quartz Spawn Chance.
All GUI's Parts/Tiles support Custom Localization. ( Fixes #0190 )
Added Crafting Recipe for copying Press Plates.
Fixed Bug: #0189 - Particles don't turn off when set to minimal
Fixed Bug: #0176 - Weird Colorization While Mining Parts.
Fixed Bug: #0152 - TPane drops parts as items and does not insert into system.
Fixed Bug: #0140 - Spatial pylon facade renders oddly (Clear)
2014-03-15 01:58:21 -05:00

81 lines
1.7 KiB
Java

package appeng.hooks;
import java.util.Random;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import appeng.api.util.DimensionalCoord;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.WorldSettings;
import appeng.helpers.MeteoritePlacer;
import appeng.services.helpers.ICompassCallback;
import cpw.mods.fml.common.IWorldGenerator;
final public class MeteoriteWorldGen implements IWorldGenerator
{
class myGen implements ICompassCallback
{
double distance = 0;
@Override
public void calculatedDirection(boolean hasResult, boolean spin, double radians, double dist)
{
if ( hasResult )
distance = dist;
else
distance = Double.MAX_VALUE;
}
};
@Override
public void generate(Random r, int chunkX, int chunkZ, World w, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
if ( r.nextFloat() > 0.9 )
{
int x = r.nextInt( 16 ) + (chunkX << 4);
int z = r.nextInt( 16 ) + (chunkZ << 4);
myGen obj = new myGen();
Future<?> future = WorldSettings.getInstance().getCompass().getCompassDirection( new DimensionalCoord( w, x, 128, z ), 70, obj );
try
{
future.get();
if ( obj.distance > AEConfig.instance.minMeteoriteDistanceSq )
{
int depth = 180 + r.nextInt( 20 );
for (int trys = 0; trys < 20; trys++)
{
MeteoritePlacer mp = new MeteoritePlacer();
if ( mp.spawnMeteorite( w, x, depth, z ) )
return;
depth -= 15;
if ( depth < 40 )
return;
}
}
}
catch (InterruptedException e)
{
AELog.error( e );
}
catch (ExecutionException e)
{
AELog.error( e );
}
}
}
}