pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package appeng.worldgen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.MutableBoundingBox;
|
||||
@@ -10,8 +12,6 @@ import net.minecraft.world.gen.feature.structure.ScatteredStructurePiece;
|
||||
import net.minecraft.world.gen.feature.structure.StructurePiece;
|
||||
import net.minecraft.world.gen.feature.template.TemplateManager;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class MeteoritePiece extends ScatteredStructurePiece {
|
||||
|
||||
public static IStructurePieceType TYPE = IStructurePieceType.register(MeteoritePiece::new, "AE2M");
|
||||
@@ -25,7 +25,8 @@ public class MeteoritePiece extends ScatteredStructurePiece {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean create(IWorld worldIn, ChunkGenerator<?> chunkGeneratorIn, Random randomIn, MutableBoundingBox mutableBoundingBoxIn, ChunkPos chunkPosIn) {
|
||||
public boolean create(IWorld worldIn, ChunkGenerator<?> chunkGeneratorIn, Random randomIn,
|
||||
MutableBoundingBox mutableBoundingBoxIn, ChunkPos chunkPosIn) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.worldgen;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -33,13 +32,14 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
@@ -49,375 +49,319 @@ import appeng.worldgen.meteorite.FalloutSand;
|
||||
import appeng.worldgen.meteorite.FalloutSnow;
|
||||
import appeng.worldgen.meteorite.IMeteoriteWorld;
|
||||
import appeng.worldgen.meteorite.MeteoriteBlockPutter;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
public final class MeteoritePlacer {
|
||||
private static final double PRESSES_SPAWN_CHANCE = 0.7;
|
||||
private static final int SKYSTONE_SPAWN_LIMIT = 12;
|
||||
private final IBlockDefinition skyChestDefinition;
|
||||
private final BlockState skyStone;
|
||||
private final Item skyStoneItem;
|
||||
private final MeteoriteBlockPutter putter = new MeteoriteBlockPutter();
|
||||
private final IWorld world;
|
||||
private final Fallout type;
|
||||
private final BlockPos pos;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
private final double meteoriteSize;
|
||||
private final double realCrater;
|
||||
private final double squaredMeteoriteSize;
|
||||
private final double crater;
|
||||
private final int skyMode;
|
||||
private final boolean lava;
|
||||
|
||||
public final class MeteoritePlacer
|
||||
{
|
||||
private static final double PRESSES_SPAWN_CHANCE = 0.7;
|
||||
private static final int SKYSTONE_SPAWN_LIMIT = 12;
|
||||
private final IBlockDefinition skyChestDefinition;
|
||||
private final BlockState skyStone;
|
||||
private final Item skyStoneItem;
|
||||
private final MeteoriteBlockPutter putter = new MeteoriteBlockPutter();
|
||||
private final IWorld world;
|
||||
private final Fallout type;
|
||||
private final BlockPos pos;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
private final double meteoriteSize;
|
||||
private final double realCrater;
|
||||
private final double squaredMeteoriteSize;
|
||||
private final double crater;
|
||||
private final int skyMode;
|
||||
private final boolean lava;
|
||||
public MeteoritePlacer(IWorld world, PlacedMeteoriteSettings settings) {
|
||||
this.world = world;
|
||||
this.pos = settings.getPos();
|
||||
this.x = settings.getPos().getX();
|
||||
this.y = settings.getPos().getY();
|
||||
this.z = settings.getPos().getZ();
|
||||
this.meteoriteSize = settings.getMeteoriteRadius();
|
||||
this.realCrater = settings.getCraterRadius();
|
||||
this.skyMode = settings.getSkyMode();
|
||||
this.lava = settings.isLava();
|
||||
this.squaredMeteoriteSize = this.meteoriteSize * this.meteoriteSize;
|
||||
this.crater = this.realCrater * this.realCrater;
|
||||
|
||||
public MeteoritePlacer(IWorld world, PlacedMeteoriteSettings settings)
|
||||
{
|
||||
this.world = world;
|
||||
this.pos = settings.getPos();
|
||||
this.x = settings.getPos().getX();
|
||||
this.y = settings.getPos().getY();
|
||||
this.z = settings.getPos().getZ();
|
||||
this.meteoriteSize = settings.getMeteoriteRadius();
|
||||
this.realCrater = settings.getCraterRadius();
|
||||
this.skyMode = settings.getSkyMode();
|
||||
this.lava = settings.isLava();
|
||||
this.squaredMeteoriteSize = this.meteoriteSize * this.meteoriteSize;
|
||||
this.crater = this.realCrater * this.realCrater;
|
||||
final IBlocks blocks = AEApi.instance().definitions().blocks();
|
||||
|
||||
final IBlocks blocks = AEApi.instance().definitions().blocks();
|
||||
this.skyChestDefinition = blocks.skyStoneChest();
|
||||
this.skyStone = blocks.skyStoneBlock().block().getDefaultState();
|
||||
this.skyStoneItem = blocks.skyStoneBlock().item();
|
||||
|
||||
this.skyChestDefinition = blocks.skyStoneChest();
|
||||
this.skyStone = blocks.skyStoneBlock().block().getDefaultState();
|
||||
this.skyStoneItem = blocks.skyStoneBlock().item();
|
||||
this.type = getFalloutFromBaseBlock(world, settings.getPos(), settings.getBlk());
|
||||
}
|
||||
|
||||
this.type = getFalloutFromBaseBlock(world, settings.getPos(), settings.getBlk());
|
||||
}
|
||||
public void place() {
|
||||
// creator
|
||||
if (skyMode > 10) {
|
||||
this.placeCrater();
|
||||
}
|
||||
|
||||
public void place() {
|
||||
// creator
|
||||
if( skyMode > 10 )
|
||||
{
|
||||
this.placeCrater();
|
||||
}
|
||||
this.placeMeteorite();
|
||||
|
||||
this.placeMeteorite();
|
||||
// collapse blocks...
|
||||
if (skyMode > 3) {
|
||||
this.decay();
|
||||
}
|
||||
}
|
||||
|
||||
// collapse blocks...
|
||||
if( skyMode > 3 )
|
||||
{
|
||||
this.decay();
|
||||
}
|
||||
}
|
||||
private int minX(int x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
private int minX(int x) {
|
||||
return x;
|
||||
}
|
||||
private int minZ(int x) {
|
||||
return x;
|
||||
}
|
||||
private int maxX(int x) {
|
||||
return x;
|
||||
}
|
||||
private int maxZ(int x) {
|
||||
return x;
|
||||
}
|
||||
private int minZ(int x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
private void placeCrater()
|
||||
{
|
||||
final int maxY = 255;
|
||||
final int minX = minX( x - 200 );
|
||||
final int maxX = maxX( x + 200 );
|
||||
final int minZ = minZ( z - 200 );
|
||||
final int maxZ = maxZ( z + 200 );
|
||||
private int maxX(int x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
BlockPos.Mutable blockPos = new BlockPos.Mutable();
|
||||
for( int j = y - 5; j < maxY; j++ )
|
||||
{
|
||||
blockPos.setY(j);
|
||||
boolean changed = false;
|
||||
private int maxZ(int x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
for( int i = minX; i < maxX; i++ )
|
||||
{
|
||||
blockPos.setX(i);
|
||||
for( int k = minZ; k < maxZ; k++ )
|
||||
{
|
||||
blockPos.setZ(k);
|
||||
final double dx = i - x;
|
||||
final double dz = k - z;
|
||||
final double h = y - this.meteoriteSize + 1 + this.type.adjustCrater();
|
||||
private void placeCrater() {
|
||||
final int maxY = 255;
|
||||
final int minX = minX(x - 200);
|
||||
final int maxX = maxX(x + 200);
|
||||
final int minZ = minZ(z - 200);
|
||||
final int maxZ = maxZ(z + 200);
|
||||
|
||||
final double distanceFrom = dx * dx + dz * dz;
|
||||
BlockPos.Mutable blockPos = new BlockPos.Mutable();
|
||||
for (int j = y - 5; j < maxY; j++) {
|
||||
blockPos.setY(j);
|
||||
boolean changed = false;
|
||||
|
||||
if( j > h + distanceFrom * 0.02 )
|
||||
{
|
||||
if( lava && j < y && world.getBlockState( blockPos ).getMaterial().isSolid() )
|
||||
{
|
||||
if( j > h + distanceFrom * 0.02 )
|
||||
{
|
||||
this.putter.put(world, blockPos, Blocks.LAVA.getDefaultState() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
changed = this.putter.put(world, blockPos, Platform.AIR_BLOCK.getDefaultState() ) || changed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = minX; i < maxX; i++) {
|
||||
blockPos.setX(i);
|
||||
for (int k = minZ; k < maxZ; k++) {
|
||||
blockPos.setZ(k);
|
||||
final double dx = i - x;
|
||||
final double dz = k - z;
|
||||
final double h = y - this.meteoriteSize + 1 + this.type.adjustCrater();
|
||||
|
||||
for( final Object o : world.getEntitiesWithinAABB( ItemEntity.class,
|
||||
new AxisAlignedBB( minX( x - 30 ), y - 5, minZ( z - 30 ), maxX( x + 30 ), y + 30, maxZ( z + 30 ) ) ) )
|
||||
{
|
||||
final Entity e = (Entity) o;
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
final double distanceFrom = dx * dx + dz * dz;
|
||||
|
||||
private void placeMeteorite()
|
||||
{
|
||||
// spawn meteor
|
||||
this.placeMeteoriteSkyStone();
|
||||
if (j > h + distanceFrom * 0.02) {
|
||||
if (lava && j < y && world.getBlockState(blockPos).getMaterial().isSolid()) {
|
||||
if (j > h + distanceFrom * 0.02) {
|
||||
this.putter.put(world, blockPos, Blocks.LAVA.getDefaultState());
|
||||
}
|
||||
} else {
|
||||
changed = this.putter.put(world, blockPos, Platform.AIR_BLOCK.getDefaultState()) || changed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
placeChest();
|
||||
}
|
||||
for (final Object o : world.getEntitiesWithinAABB(ItemEntity.class,
|
||||
new AxisAlignedBB(minX(x - 30), y - 5, minZ(z - 30), maxX(x + 30), y + 30, maxZ(z + 30)))) {
|
||||
final Entity e = (Entity) o;
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
|
||||
private void placeChest() {
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.SPAWN_PRESSES_IN_METEORITES ) )
|
||||
{
|
||||
this.putter.put(world, pos, this.skyChestDefinition.block().getDefaultState());
|
||||
private void placeMeteorite() {
|
||||
// spawn meteor
|
||||
this.placeMeteoriteSkyStone();
|
||||
|
||||
final TileEntity te = world.getTileEntity(pos); // FIXME: this is also probably a band-aid for another issue
|
||||
final InventoryAdaptor ap = InventoryAdaptor.getAdaptor( te, Direction.UP );
|
||||
if( ap != null && !ap.containsItems() ) // FIXME: band-aid for meteorites being generated multiple times
|
||||
{
|
||||
// TODO: loot tables would be better
|
||||
int primary = Math.max( 1, (int) ( Math.random() * 4 ) );
|
||||
placeChest();
|
||||
}
|
||||
|
||||
if( primary > 3 ) // in case math breaks...
|
||||
{
|
||||
primary = 3;
|
||||
}
|
||||
private void placeChest() {
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.SPAWN_PRESSES_IN_METEORITES)) {
|
||||
this.putter.put(world, pos, this.skyChestDefinition.block().getDefaultState());
|
||||
|
||||
for( int zz = 0; zz < primary; zz++ )
|
||||
{
|
||||
int r;
|
||||
boolean duplicate;
|
||||
final TileEntity te = world.getTileEntity(pos); // FIXME: this is also probably a band-aid for another issue
|
||||
final InventoryAdaptor ap = InventoryAdaptor.getAdaptor(te, Direction.UP);
|
||||
if (ap != null && !ap.containsItems()) // FIXME: band-aid for meteorites being generated multiple times
|
||||
{
|
||||
// TODO: loot tables would be better
|
||||
int primary = Math.max(1, (int) (Math.random() * 4));
|
||||
|
||||
do
|
||||
{
|
||||
duplicate = false;
|
||||
if (primary > 3) // in case math breaks...
|
||||
{
|
||||
primary = 3;
|
||||
}
|
||||
|
||||
if( Math.random() > PRESSES_SPAWN_CHANCE )
|
||||
{
|
||||
r = WorldData.instance().storageData().getNextOrderedValue( "presses", 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
r = (int) ( Math.random() * 1000 );
|
||||
}
|
||||
for (int zz = 0; zz < primary; zz++) {
|
||||
int r;
|
||||
boolean duplicate;
|
||||
|
||||
ItemStack toAdd = ItemStack.EMPTY;
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
do {
|
||||
duplicate = false;
|
||||
|
||||
switch( r % 4 )
|
||||
{
|
||||
case 0:
|
||||
toAdd = materials.calcProcessorPress().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
break;
|
||||
case 1:
|
||||
toAdd = materials.engProcessorPress().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
break;
|
||||
case 2:
|
||||
toAdd = materials.logicProcessorPress().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
break;
|
||||
case 3:
|
||||
toAdd = materials.siliconPress().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
break;
|
||||
default:
|
||||
}
|
||||
if (Math.random() > PRESSES_SPAWN_CHANCE) {
|
||||
r = WorldData.instance().storageData().getNextOrderedValue("presses", 0);
|
||||
} else {
|
||||
r = (int) (Math.random() * 1000);
|
||||
}
|
||||
|
||||
if( !toAdd.isEmpty() )
|
||||
{
|
||||
if( ap.simulateRemove( 1, toAdd, null ).isEmpty() )
|
||||
{
|
||||
ap.addItems( toAdd );
|
||||
}
|
||||
else
|
||||
{
|
||||
duplicate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
while( duplicate );
|
||||
}
|
||||
ItemStack toAdd = ItemStack.EMPTY;
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
final int secondary = Math.max( 1, (int) ( Math.random() * 3 ) );
|
||||
for( int zz = 0; zz < secondary; zz++ )
|
||||
{
|
||||
switch( (int) ( Math.random() * 1000 ) % 3 )
|
||||
{
|
||||
case 0:
|
||||
final int amount = (int) ( ( Math.random() * SKYSTONE_SPAWN_LIMIT ) + 1 );
|
||||
ap.addItems(new ItemStack(skyStoneItem, amount));
|
||||
break;
|
||||
case 1:
|
||||
final List<ItemStack> possibles = new ArrayList<>();
|
||||
possibles.add( new ItemStack( net.minecraft.item.Items.GOLD_NUGGET ) );
|
||||
switch (r % 4) {
|
||||
case 0:
|
||||
toAdd = materials.calcProcessorPress().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
break;
|
||||
case 1:
|
||||
toAdd = materials.engProcessorPress().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
break;
|
||||
case 2:
|
||||
toAdd = materials.logicProcessorPress().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
break;
|
||||
case 3:
|
||||
toAdd = materials.siliconPress().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
ItemStack nugget = Platform.pickRandom( possibles );
|
||||
if( nugget != null && !nugget.isEmpty() )
|
||||
{
|
||||
nugget = nugget.copy();
|
||||
nugget.setCount( (int) ( Math.random() * 12 ) + 1 );
|
||||
ap.addItems( nugget );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!toAdd.isEmpty()) {
|
||||
if (ap.simulateRemove(1, toAdd, null).isEmpty()) {
|
||||
ap.addItems(toAdd);
|
||||
} else {
|
||||
duplicate = true;
|
||||
}
|
||||
}
|
||||
} while (duplicate);
|
||||
}
|
||||
|
||||
private void placeMeteoriteSkyStone()
|
||||
{
|
||||
final int meteorXLength = minX( x - 8 );
|
||||
final int meteorXHeight = maxX( x + 8 );
|
||||
final int meteorZLength = minZ( z - 8 );
|
||||
final int meteorZHeight = maxZ( z + 8 );
|
||||
final int secondary = Math.max(1, (int) (Math.random() * 3));
|
||||
for (int zz = 0; zz < secondary; zz++) {
|
||||
switch ((int) (Math.random() * 1000) % 3) {
|
||||
case 0:
|
||||
final int amount = (int) ((Math.random() * SKYSTONE_SPAWN_LIMIT) + 1);
|
||||
ap.addItems(new ItemStack(skyStoneItem, amount));
|
||||
break;
|
||||
case 1:
|
||||
final List<ItemStack> possibles = new ArrayList<>();
|
||||
possibles.add(new ItemStack(net.minecraft.item.Items.GOLD_NUGGET));
|
||||
|
||||
BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||
for( int i = meteorXLength; i < meteorXHeight; i++ )
|
||||
{
|
||||
pos.setX(i);
|
||||
for( int j = y - 8; j < y + 8; j++ )
|
||||
{
|
||||
pos.setY(j);
|
||||
for( int k = meteorZLength; k < meteorZHeight; k++ )
|
||||
{
|
||||
pos.setZ(k);
|
||||
final double dx = i - x;
|
||||
final double dy = j - y;
|
||||
final double dz = k - z;
|
||||
ItemStack nugget = Platform.pickRandom(possibles);
|
||||
if (nugget != null && !nugget.isEmpty()) {
|
||||
nugget = nugget.copy();
|
||||
nugget.setCount((int) (Math.random() * 12) + 1);
|
||||
ap.addItems(nugget);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( dx * dx * 0.7 + dy * dy * ( j > y ? 1.4 : 0.8 ) + dz * dz * 0.7 < this.squaredMeteoriteSize )
|
||||
{
|
||||
this.putter.put(world, pos, skyStone );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void placeMeteoriteSkyStone() {
|
||||
final int meteorXLength = minX(x - 8);
|
||||
final int meteorXHeight = maxX(x + 8);
|
||||
final int meteorZLength = minZ(z - 8);
|
||||
final int meteorZHeight = maxZ(z + 8);
|
||||
|
||||
private void decay()
|
||||
{
|
||||
double randomShit = 0;
|
||||
BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||
for (int i = meteorXLength; i < meteorXHeight; i++) {
|
||||
pos.setX(i);
|
||||
for (int j = y - 8; j < y + 8; j++) {
|
||||
pos.setY(j);
|
||||
for (int k = meteorZLength; k < meteorZHeight; k++) {
|
||||
pos.setZ(k);
|
||||
final double dx = i - x;
|
||||
final double dy = j - y;
|
||||
final double dz = k - z;
|
||||
|
||||
final int meteorXLength = minX( x - 30 );
|
||||
final int meteorXHeight = maxX( x + 30 );
|
||||
final int meteorZLength = minZ( z - 30 );
|
||||
final int meteorZHeight = maxZ( z + 30 );
|
||||
if (dx * dx * 0.7 + dy * dy * (j > y ? 1.4 : 0.8) + dz * dz * 0.7 < this.squaredMeteoriteSize) {
|
||||
this.putter.put(world, pos, skyStone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlockPos.Mutable blockPos = new BlockPos.Mutable();
|
||||
BlockPos.Mutable blockPosUp = new BlockPos.Mutable();
|
||||
BlockPos.Mutable blockPosDown = new BlockPos.Mutable();
|
||||
for( int i = meteorXLength; i < meteorXHeight; i++ )
|
||||
{
|
||||
blockPos.setX(i);
|
||||
blockPosUp.setX(i);
|
||||
blockPosDown.setX(i);
|
||||
for( int k = meteorZLength; k < meteorZHeight; k++ )
|
||||
{
|
||||
blockPos.setZ(k);
|
||||
blockPosUp.setZ(k);
|
||||
blockPosDown.setZ(k);
|
||||
for( int j = y - 9; j < y + 30; j++ )
|
||||
{
|
||||
blockPos.setY(j);
|
||||
blockPosUp.setY(j + 1);
|
||||
blockPosDown.setY(j - 1);
|
||||
BlockState state = world.getBlockState( blockPos );
|
||||
Block blk = world.getBlockState( blockPos ).getBlock();
|
||||
if( blk == Blocks.LAVA )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
private void decay() {
|
||||
double randomShit = 0;
|
||||
|
||||
// TODO reconsider
|
||||
if( state.canBeReplacedByLogs( world, new BlockPos( blockPos ) ) )
|
||||
{
|
||||
blk = Platform.AIR_BLOCK;
|
||||
final Block blk_b = world.getBlockState( blockPosUp ).getBlock();
|
||||
final int meteorXLength = minX(x - 30);
|
||||
final int meteorXHeight = maxX(x + 30);
|
||||
final int meteorZLength = minZ(z - 30);
|
||||
final int meteorZHeight = maxZ(z + 30);
|
||||
|
||||
if( blk_b != blk )
|
||||
{
|
||||
final BlockState stateUp = world.getBlockState( blockPosUp );
|
||||
world.setBlockState( blockPos, stateUp, 3 );
|
||||
}
|
||||
else if( randomShit < 100 * this.crater )
|
||||
{
|
||||
final double dx = i - x;
|
||||
final double dy = j - y;
|
||||
final double dz = k - z;
|
||||
final double dist = dx * dx + dy * dy + dz * dz;
|
||||
BlockPos.Mutable blockPos = new BlockPos.Mutable();
|
||||
BlockPos.Mutable blockPosUp = new BlockPos.Mutable();
|
||||
BlockPos.Mutable blockPosDown = new BlockPos.Mutable();
|
||||
for (int i = meteorXLength; i < meteorXHeight; i++) {
|
||||
blockPos.setX(i);
|
||||
blockPosUp.setX(i);
|
||||
blockPosDown.setX(i);
|
||||
for (int k = meteorZLength; k < meteorZHeight; k++) {
|
||||
blockPos.setZ(k);
|
||||
blockPosUp.setZ(k);
|
||||
blockPosDown.setZ(k);
|
||||
for (int j = y - 9; j < y + 30; j++) {
|
||||
blockPos.setY(j);
|
||||
blockPosUp.setY(j + 1);
|
||||
blockPosDown.setY(j - 1);
|
||||
BlockState state = world.getBlockState(blockPos);
|
||||
Block blk = world.getBlockState(blockPos).getBlock();
|
||||
if (blk == Blocks.LAVA) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final BlockState xf = world.getBlockState( blockPosDown );
|
||||
if( !xf.canBeReplacedByLogs( world, blockPosDown ) )
|
||||
{
|
||||
final double extraRange = Math.random() * 0.6;
|
||||
final double height = this.crater * ( extraRange + 0.2 ) - Math.abs( dist - this.crater * 1.7 );
|
||||
// TODO reconsider
|
||||
if (state.canBeReplacedByLogs(world, new BlockPos(blockPos))) {
|
||||
blk = Platform.AIR_BLOCK;
|
||||
final Block blk_b = world.getBlockState(blockPosUp).getBlock();
|
||||
|
||||
if( xf.getBlock() != blk && height > 0 && Math.random() > 0.6 )
|
||||
{
|
||||
randomShit++;
|
||||
this.type.getRandomFall(world, blockPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// decay.
|
||||
if( world.isAirBlock(blockPosUp) )
|
||||
{
|
||||
if( Math.random() > 0.4 )
|
||||
{
|
||||
final double dx = i - x;
|
||||
final double dy = j - y;
|
||||
final double dz = k - z;
|
||||
if (blk_b != blk) {
|
||||
final BlockState stateUp = world.getBlockState(blockPosUp);
|
||||
world.setBlockState(blockPos, stateUp, 3);
|
||||
} else if (randomShit < 100 * this.crater) {
|
||||
final double dx = i - x;
|
||||
final double dy = j - y;
|
||||
final double dz = k - z;
|
||||
final double dist = dx * dx + dy * dy + dz * dz;
|
||||
|
||||
if( dx * dx + dy * dy + dz * dz < this.crater * 1.6 )
|
||||
{
|
||||
this.type.getRandomInset(world, blockPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final BlockState xf = world.getBlockState(blockPosDown);
|
||||
if (!xf.canBeReplacedByLogs(world, blockPosDown)) {
|
||||
final double extraRange = Math.random() * 0.6;
|
||||
final double height = this.crater * (extraRange + 0.2)
|
||||
- Math.abs(dist - this.crater * 1.7);
|
||||
|
||||
private Fallout getFalloutFromBaseBlock(IWorld w, BlockPos pos, ResourceLocation blk) {
|
||||
if( blk.equals(Blocks.SAND.getRegistryName()) )
|
||||
{
|
||||
return new FalloutSand( w, pos, this.putter, this.skyStone );
|
||||
}
|
||||
else if( blk.equals(Blocks.TERRACOTTA.getRegistryName()) )
|
||||
{
|
||||
return new FalloutCopy( w, pos, this.putter, this.skyStone );
|
||||
}
|
||||
else if( blk.equals(Blocks.ICE.getRegistryName()) || blk.equals(Blocks.SNOW.getRegistryName()) )
|
||||
{
|
||||
return new FalloutSnow( w, pos, this.putter, this.skyStone );
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Fallout( this.putter, this.skyStone );
|
||||
}
|
||||
}
|
||||
if (xf.getBlock() != blk && height > 0 && Math.random() > 0.6) {
|
||||
randomShit++;
|
||||
this.type.getRandomFall(world, blockPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// decay.
|
||||
if (world.isAirBlock(blockPosUp)) {
|
||||
if (Math.random() > 0.4) {
|
||||
final double dx = i - x;
|
||||
final double dy = j - y;
|
||||
final double dz = k - z;
|
||||
|
||||
if (dx * dx + dy * dy + dz * dz < this.crater * 1.6) {
|
||||
this.type.getRandomInset(world, blockPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Fallout getFalloutFromBaseBlock(IWorld w, BlockPos pos, ResourceLocation blk) {
|
||||
if (blk.equals(Blocks.SAND.getRegistryName())) {
|
||||
return new FalloutSand(w, pos, this.putter, this.skyStone);
|
||||
} else if (blk.equals(Blocks.TERRACOTTA.getRegistryName())) {
|
||||
return new FalloutCopy(w, pos, this.putter, this.skyStone);
|
||||
} else if (blk.equals(Blocks.ICE.getRegistryName()) || blk.equals(Blocks.SNOW.getRegistryName())) {
|
||||
return new FalloutSnow(w, pos, this.putter, this.skyStone);
|
||||
} else {
|
||||
return new Fallout(this.putter, this.skyStone);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package appeng.worldgen;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -10,10 +15,6 @@ import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* This is per-world data to track where Meteorites have been spawned.
|
||||
*/
|
||||
@@ -27,7 +28,7 @@ public final class MeteoriteSpawnData {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void setGenerated( int chunkX, int chunkZ ) {
|
||||
public void setGenerated(int chunkX, int chunkZ) {
|
||||
synchronized (data) {
|
||||
// edit.
|
||||
data.generated.putBoolean(chunkX + "," + chunkZ, true);
|
||||
@@ -35,10 +36,9 @@ public final class MeteoriteSpawnData {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasGenerated( int chunkX, int chunkZ ) {
|
||||
synchronized( data )
|
||||
{
|
||||
return data.generated.getBoolean( chunkX + "," + chunkZ );
|
||||
public boolean hasGenerated(int chunkX, int chunkZ) {
|
||||
synchronized (data) {
|
||||
return data.generated.getBoolean(chunkX + "," + chunkZ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,17 +61,17 @@ public final class MeteoriteSpawnData {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether another meteorite has spawned within the given block range of the given position.
|
||||
* Checks whether another meteorite has spawned within the given block range of
|
||||
* the given position.
|
||||
*/
|
||||
public boolean isMeteoriteSpawnInRange(BlockPos pos, int rangeSquared) {
|
||||
synchronized( data )
|
||||
{
|
||||
synchronized (data) {
|
||||
ChunkPos chunkPos = new ChunkPos(pos);
|
||||
CompoundNBT spawnData = getSpawnData(chunkPos.x, chunkPos.z, false);
|
||||
if (spawnData == null) {
|
||||
return false;
|
||||
}
|
||||
final int size = spawnData.getInt( "num" );
|
||||
final int size = spawnData.getInt("num");
|
||||
for (int i = 0; i < size; i++) {
|
||||
CompoundNBT existingSettingsNbt = spawnData.getCompound(String.valueOf(i));
|
||||
BlockPos existingPos = PlacedMeteoriteSettings.read(existingSettingsNbt).getPos();
|
||||
@@ -86,8 +86,7 @@ public final class MeteoriteSpawnData {
|
||||
}
|
||||
|
||||
public boolean tryAddSpawnedMeteorite(PlacedMeteoriteSettings settings, int minDistanceSquared) {
|
||||
synchronized( data )
|
||||
{
|
||||
synchronized (data) {
|
||||
if (isMeteoriteSpawnInRange(settings.getPos(), minDistanceSquared)) {
|
||||
return false;
|
||||
}
|
||||
@@ -98,13 +97,12 @@ public final class MeteoriteSpawnData {
|
||||
}
|
||||
|
||||
public void addSpawnedMeteorite(PlacedMeteoriteSettings settings) {
|
||||
synchronized( data )
|
||||
{
|
||||
synchronized (data) {
|
||||
ChunkPos chunkPos = new ChunkPos(settings.getPos());
|
||||
CompoundNBT spawnData = getSpawnData(chunkPos.x, chunkPos.z, true);
|
||||
final int size = spawnData.getInt( "num" );
|
||||
spawnData.put( String.valueOf( size ), settings.write(new CompoundNBT()) );
|
||||
spawnData.putInt( "num", size + 1 );
|
||||
final int size = spawnData.getInt("num");
|
||||
spawnData.put(String.valueOf(size), settings.write(new CompoundNBT()));
|
||||
spawnData.putInt("num", size + 1);
|
||||
data.markDirty();
|
||||
}
|
||||
}
|
||||
@@ -112,23 +110,18 @@ public final class MeteoriteSpawnData {
|
||||
public Collection<PlacedMeteoriteSettings> getNearByMeteorites(int chunkX, int chunkZ) {
|
||||
final Collection<PlacedMeteoriteSettings> ll = new ArrayList<>();
|
||||
|
||||
synchronized( data )
|
||||
{
|
||||
for( int x = -1; x <= 1; x++ )
|
||||
{
|
||||
for( int z = -1; z <= 1; z++ )
|
||||
{
|
||||
final int cx = x + ( chunkX >> 4 );
|
||||
final int cz = z + ( chunkZ >> 4 );
|
||||
synchronized (data) {
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
final int cx = x + (chunkX >> 4);
|
||||
final int cz = z + (chunkZ >> 4);
|
||||
|
||||
final CompoundNBT data = getSpawnData( cx << 4, cz << 4, false );
|
||||
final CompoundNBT data = getSpawnData(cx << 4, cz << 4, false);
|
||||
|
||||
if( data != null )
|
||||
{
|
||||
if (data != null) {
|
||||
// edit.
|
||||
final int size = data.getInt( "num" );
|
||||
for( int s = 0; s < size; s++ )
|
||||
{
|
||||
final int size = data.getInt("num");
|
||||
for (int s = 0; s < size; s++) {
|
||||
CompoundNBT settingsNbt = data.getCompound(String.valueOf(s));
|
||||
ll.add(PlacedMeteoriteSettings.read(settingsNbt));
|
||||
}
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
package appeng.worldgen;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.worldgen.meteorite.IMeteoriteWorld;
|
||||
import appeng.worldgen.meteorite.StandardWorld;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Makes decisions about spawning meteorites in the world.
|
||||
@@ -22,50 +24,47 @@ public class MeteoriteSpawner {
|
||||
private final Set<Block> validSpawn = new HashSet<>();
|
||||
private final Set<Block> invalidSpawn = new HashSet<>();
|
||||
|
||||
public MeteoriteSpawner()
|
||||
{
|
||||
public MeteoriteSpawner() {
|
||||
final IBlocks blocks = AEApi.instance().definitions().blocks();
|
||||
|
||||
this.validSpawn.add( Blocks.STONE );
|
||||
this.validSpawn.add( Blocks.COBBLESTONE );
|
||||
this.validSpawn.add( Blocks.GRASS );
|
||||
this.validSpawn.add( Blocks.SAND );
|
||||
this.validSpawn.add( Blocks.DIRT );
|
||||
this.validSpawn.add( Blocks.GRAVEL );
|
||||
this.validSpawn.add( Blocks.NETHERRACK );
|
||||
this.validSpawn.add( Blocks.IRON_ORE );
|
||||
this.validSpawn.add( Blocks.GOLD_ORE );
|
||||
this.validSpawn.add( Blocks.DIAMOND_ORE );
|
||||
this.validSpawn.add( Blocks.REDSTONE_ORE );
|
||||
this.validSpawn.add( Blocks.ICE );
|
||||
this.validSpawn.add( Blocks.SNOW );
|
||||
this.validSpawn.add(Blocks.STONE);
|
||||
this.validSpawn.add(Blocks.COBBLESTONE);
|
||||
this.validSpawn.add(Blocks.GRASS);
|
||||
this.validSpawn.add(Blocks.SAND);
|
||||
this.validSpawn.add(Blocks.DIRT);
|
||||
this.validSpawn.add(Blocks.GRAVEL);
|
||||
this.validSpawn.add(Blocks.NETHERRACK);
|
||||
this.validSpawn.add(Blocks.IRON_ORE);
|
||||
this.validSpawn.add(Blocks.GOLD_ORE);
|
||||
this.validSpawn.add(Blocks.DIAMOND_ORE);
|
||||
this.validSpawn.add(Blocks.REDSTONE_ORE);
|
||||
this.validSpawn.add(Blocks.ICE);
|
||||
this.validSpawn.add(Blocks.SNOW);
|
||||
|
||||
this.invalidSpawn.add( blocks.skyStoneBlock().block() );
|
||||
this.invalidSpawn.add( Blocks.IRON_DOOR );
|
||||
this.invalidSpawn.add( Blocks.IRON_BARS );
|
||||
this.invalidSpawn.add( Blocks.OAK_DOOR );
|
||||
this.invalidSpawn.add( Blocks.ACACIA_DOOR );
|
||||
this.invalidSpawn.add( Blocks.BIRCH_DOOR );
|
||||
this.invalidSpawn.add( Blocks.DARK_OAK_DOOR );
|
||||
this.invalidSpawn.add( Blocks.JUNGLE_DOOR );
|
||||
this.invalidSpawn.add( Blocks.SPRUCE_DOOR );
|
||||
this.invalidSpawn.add( Blocks.BRICKS );
|
||||
this.invalidSpawn.add( Blocks.CLAY );
|
||||
this.invalidSpawn.add( Blocks.WATER );
|
||||
this.invalidSpawn.add(blocks.skyStoneBlock().block());
|
||||
this.invalidSpawn.add(Blocks.IRON_DOOR);
|
||||
this.invalidSpawn.add(Blocks.IRON_BARS);
|
||||
this.invalidSpawn.add(Blocks.OAK_DOOR);
|
||||
this.invalidSpawn.add(Blocks.ACACIA_DOOR);
|
||||
this.invalidSpawn.add(Blocks.BIRCH_DOOR);
|
||||
this.invalidSpawn.add(Blocks.DARK_OAK_DOOR);
|
||||
this.invalidSpawn.add(Blocks.JUNGLE_DOOR);
|
||||
this.invalidSpawn.add(Blocks.SPRUCE_DOOR);
|
||||
this.invalidSpawn.add(Blocks.BRICKS);
|
||||
this.invalidSpawn.add(Blocks.CLAY);
|
||||
this.invalidSpawn.add(Blocks.WATER);
|
||||
}
|
||||
|
||||
public PlacedMeteoriteSettings trySpawnMeteoriteAtSuitableHeight(IWorldReader world, int x, int y, int z) {
|
||||
|
||||
for( int tries = 0; tries < 20; tries++ )
|
||||
{
|
||||
for (int tries = 0; tries < 20; tries++) {
|
||||
PlacedMeteoriteSettings spawned = trySpawnMeteorite(world, new BlockPos(x, y, z));
|
||||
if (spawned != null) {
|
||||
return spawned;
|
||||
}
|
||||
|
||||
y -= 15;
|
||||
if( y < 40 )
|
||||
{
|
||||
if (y < 40) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -74,15 +73,13 @@ public class MeteoriteSpawner {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PlacedMeteoriteSettings trySpawnMeteorite(IWorldReader world, BlockPos pos )
|
||||
{
|
||||
public PlacedMeteoriteSettings trySpawnMeteorite(IWorldReader world, BlockPos pos) {
|
||||
Block blk = world.getBlockState(pos).getBlock();
|
||||
if( !this.validSpawn.contains( blk ) )
|
||||
{
|
||||
if (!this.validSpawn.contains(blk)) {
|
||||
return null; // must spawn on a valid block..
|
||||
}
|
||||
|
||||
double meteoriteSize = ( Math.random() * 6.0 ) + 2;
|
||||
double meteoriteSize = (Math.random() * 6.0) + 2;
|
||||
double realCrater = meteoriteSize * 2 + 5;
|
||||
boolean lava = Math.random() > 0.9;
|
||||
|
||||
@@ -95,8 +92,7 @@ public class MeteoriteSpawner {
|
||||
|
||||
boolean solid = !isAirBelowSpawnPoint(world, pos);
|
||||
|
||||
if( !solid )
|
||||
{
|
||||
if (!solid) {
|
||||
skyMode = 0;
|
||||
}
|
||||
|
||||
@@ -105,11 +101,9 @@ public class MeteoriteSpawner {
|
||||
|
||||
private static boolean isAirBelowSpawnPoint(IWorldReader w, BlockPos pos) {
|
||||
BlockPos.Mutable testPos = new BlockPos.Mutable(pos);
|
||||
for( int j = pos.getY() - 15; j < pos.getY() - 1; j++ )
|
||||
{
|
||||
for (int j = pos.getY() - 15; j < pos.getY() - 1; j++) {
|
||||
testPos.setY(j);
|
||||
if( w.isAirBlock(testPos) )
|
||||
{
|
||||
if (w.isAirBlock(testPos)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -120,17 +114,13 @@ public class MeteoriteSpawner {
|
||||
int skyMode = 0;
|
||||
|
||||
BlockPos.Mutable testPos = new BlockPos.Mutable();
|
||||
for( int i = pos.getX() - 15; i < pos.getX() + 15; i++ )
|
||||
{
|
||||
for (int i = pos.getX() - 15; i < pos.getX() + 15; i++) {
|
||||
testPos.setX(i);
|
||||
for( int j = pos.getY() - 15; j < pos.getY() + 11; j++ )
|
||||
{
|
||||
for (int j = pos.getY() - 15; j < pos.getY() + 11; j++) {
|
||||
testPos.setY(j);
|
||||
for( int k = pos.getZ() - 15; k < pos.getZ() + 15; k++ )
|
||||
{
|
||||
for (int k = pos.getZ() - 15; k < pos.getZ() + 15; k++) {
|
||||
testPos.setZ(k);
|
||||
if( w.canBlockSeeSky( testPos ) )
|
||||
{
|
||||
if (w.canBlockSeeSky(testPos)) {
|
||||
skyMode++;
|
||||
}
|
||||
}
|
||||
@@ -143,18 +133,14 @@ public class MeteoriteSpawner {
|
||||
int realValidBlocks = 0;
|
||||
|
||||
BlockPos.Mutable testPos = new BlockPos.Mutable();
|
||||
for( int i = pos.getX() - 6; i < pos.getX() + 6; i++ )
|
||||
{
|
||||
for (int i = pos.getX() - 6; i < pos.getX() + 6; i++) {
|
||||
testPos.setX(i);
|
||||
for( int j = pos.getY() - 6; j < pos.getY() + 6; j++ )
|
||||
{
|
||||
for (int j = pos.getY() - 6; j < pos.getY() + 6; j++) {
|
||||
testPos.setY(j);
|
||||
for( int k = pos.getZ() - 6; k < pos.getZ() + 6; k++ )
|
||||
{
|
||||
for (int k = pos.getZ() - 6; k < pos.getZ() + 6; k++) {
|
||||
testPos.setZ(k);
|
||||
Block testBlk = w.getBlockState(testPos).getBlock();
|
||||
if( this.validSpawn.contains( testBlk ) )
|
||||
{
|
||||
if (this.validSpawn.contains(testBlk)) {
|
||||
realValidBlocks++;
|
||||
}
|
||||
}
|
||||
@@ -162,22 +148,17 @@ public class MeteoriteSpawner {
|
||||
}
|
||||
|
||||
int validBlocks = 0;
|
||||
for( int i = pos.getX() - 15; i < pos.getX() + 15; i++ )
|
||||
{
|
||||
for (int i = pos.getX() - 15; i < pos.getX() + 15; i++) {
|
||||
testPos.setX(i);
|
||||
for( int j = pos.getY() - 15; j < pos.getY() + 15; j++ )
|
||||
{
|
||||
for (int j = pos.getY() - 15; j < pos.getY() + 15; j++) {
|
||||
testPos.setY(j);
|
||||
for( int k = pos.getZ() - 15; k < pos.getZ() + 15; k++ )
|
||||
{
|
||||
for (int k = pos.getZ() - 15; k < pos.getZ() + 15; k++) {
|
||||
testPos.setZ(k);
|
||||
Block testBlk = w.getBlockState( testPos ).getBlock();
|
||||
if( this.invalidSpawn.contains( testBlk ) )
|
||||
{
|
||||
Block testBlk = w.getBlockState(testPos).getBlock();
|
||||
if (this.invalidSpawn.contains(testBlk)) {
|
||||
return false;
|
||||
}
|
||||
if( this.validSpawn.contains( testBlk ) )
|
||||
{
|
||||
if (this.validSpawn.contains(testBlk)) {
|
||||
validBlocks++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,10 @@
|
||||
|
||||
package appeng.worldgen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.features.IWorldGen.WorldGenType;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.registries.WorldGenRegistry;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
@@ -35,75 +31,76 @@ import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.NoFeatureConfig;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.Random;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.features.IWorldGen.WorldGenType;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.registries.WorldGenRegistry;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class MeteoriteWorldGen extends Feature<NoFeatureConfig> {
|
||||
|
||||
public final class MeteoriteWorldGen extends Feature<NoFeatureConfig>
|
||||
{
|
||||
public static final MeteoriteWorldGen INSTANCE = new MeteoriteWorldGen();
|
||||
|
||||
public static final MeteoriteWorldGen INSTANCE = new MeteoriteWorldGen();
|
||||
private MeteoriteWorldGen() {
|
||||
super(NoFeatureConfig::deserialize);
|
||||
setRegistryName(AppEng.MOD_ID, "meteorite");
|
||||
}
|
||||
|
||||
private MeteoriteWorldGen( )
|
||||
{
|
||||
super( NoFeatureConfig::deserialize );
|
||||
setRegistryName( AppEng.MOD_ID, "meteorite" );
|
||||
}
|
||||
private final MeteoriteSpawner spawner = new MeteoriteSpawner();
|
||||
|
||||
private final MeteoriteSpawner spawner = new MeteoriteSpawner();
|
||||
@ParametersAreNonnullByDefault
|
||||
@Override
|
||||
public boolean place(IWorld w, ChunkGenerator<? extends GenerationSettings> generator, Random r, BlockPos pos,
|
||||
NoFeatureConfig config) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.METEORITE_WORLD_GEN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
@Override
|
||||
public boolean place( IWorld w, ChunkGenerator<? extends GenerationSettings> generator, Random r, BlockPos pos, NoFeatureConfig config )
|
||||
{
|
||||
if(!AEConfig.instance().isFeatureEnabled( AEFeature.METEORITE_WORLD_GEN )) {
|
||||
return false;
|
||||
}
|
||||
ChunkPos chunkPos = new ChunkPos(pos);
|
||||
if (!WorldGenRegistry.INSTANCE.isWorldGenEnabled(WorldGenType.METEORITES, w.getWorld())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ChunkPos chunkPos = new ChunkPos( pos );
|
||||
if (!WorldGenRegistry.INSTANCE.isWorldGenEnabled(WorldGenType.METEORITES, w.getWorld())) {
|
||||
return false;
|
||||
}
|
||||
double minSqDist = Double.MAX_VALUE;
|
||||
|
||||
double minSqDist = Double.MAX_VALUE;
|
||||
MeteoriteSpawnData spawnData = MeteoriteSpawnData.get(w);
|
||||
|
||||
MeteoriteSpawnData spawnData = MeteoriteSpawnData.get(w);
|
||||
// near by meteorites!
|
||||
for (final PlacedMeteoriteSettings data : spawnData.getNearByMeteorites(chunkPos.x, chunkPos.z)) {
|
||||
minSqDist = Math.min(minSqDist, getSqDistance(data, pos));
|
||||
}
|
||||
|
||||
// near by meteorites!
|
||||
for( final PlacedMeteoriteSettings data : spawnData.getNearByMeteorites(chunkPos.x, chunkPos.z) )
|
||||
{
|
||||
minSqDist = Math.min( minSqDist, getSqDistance( data, pos ) );
|
||||
}
|
||||
final boolean isCluster = (minSqDist < 30 * 30)
|
||||
&& Platform.getRandomFloat() < AEConfig.instance().getMeteoriteClusterChance();
|
||||
|
||||
final boolean isCluster = ( minSqDist < 30 * 30 ) && Platform.getRandomFloat() < AEConfig.instance().getMeteoriteClusterChance();
|
||||
if (minSqDist > AEConfig.instance().getMinMeteoriteDistanceSq() || isCluster) {
|
||||
final int x = r.nextInt(16) + (chunkPos.x << 4);
|
||||
final int y = AEConfig.instance().getMeteoriteMaximumSpawnHeight() + r.nextInt(20);
|
||||
final int z = r.nextInt(16) + (chunkPos.z << 4);
|
||||
|
||||
if( minSqDist > AEConfig.instance().getMinMeteoriteDistanceSq() || isCluster )
|
||||
{
|
||||
final int x = r.nextInt( 16 ) + ( chunkPos.x << 4 );
|
||||
final int y = AEConfig.instance().getMeteoriteMaximumSpawnHeight() + r.nextInt( 20 );
|
||||
final int z = r.nextInt( 16 ) + ( chunkPos.z << 4 );
|
||||
PlacedMeteoriteSettings settings = spawner.trySpawnMeteoriteAtSuitableHeight(w, x, y, z);
|
||||
if (settings != null) {
|
||||
// Double check that no other chunk generated a meteorite within range while we
|
||||
// were working
|
||||
int checkRange = isCluster ? (30 * 30) : AEConfig.instance().getMinMeteoriteDistanceSq();
|
||||
if (spawnData.tryAddSpawnedMeteorite(settings, checkRange)) {
|
||||
MeteoritePlacer placer = new MeteoritePlacer(w, settings);
|
||||
placer.place();
|
||||
WorldData.instance().compassData().service().updateArea(w, chunkPos.x, chunkPos.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlacedMeteoriteSettings settings = spawner.trySpawnMeteoriteAtSuitableHeight(w, x, y, z);
|
||||
if (settings != null) {
|
||||
// Double check that no other chunk generated a meteorite within range while we were working
|
||||
int checkRange = isCluster ? (30*30) : AEConfig.instance().getMinMeteoriteDistanceSq();
|
||||
if (spawnData.tryAddSpawnedMeteorite(settings, checkRange)) {
|
||||
MeteoritePlacer placer = new MeteoritePlacer(w, settings);
|
||||
placer.place();
|
||||
WorldData.instance().compassData().service().updateArea( w, chunkPos.x, chunkPos.z );
|
||||
}
|
||||
}
|
||||
}
|
||||
spawnData.setGenerated(chunkPos.x, chunkPos.z);
|
||||
return true;
|
||||
}
|
||||
|
||||
spawnData.setGenerated( chunkPos.x, chunkPos.z );
|
||||
return true;
|
||||
}
|
||||
|
||||
private static double getSqDistance( PlacedMeteoriteSettings placed, BlockPos pos )
|
||||
{
|
||||
final int chunkX = placed.getPos().getX() - pos.getX();
|
||||
final int chunkZ = placed.getPos().getZ() - pos.getZ();
|
||||
return chunkX * chunkX + chunkZ * chunkZ;
|
||||
}
|
||||
private static double getSqDistance(PlacedMeteoriteSettings placed, BlockPos pos) {
|
||||
final int chunkX = placed.getPos().getX() - pos.getX();
|
||||
final int chunkZ = placed.getPos().getZ() - pos.getZ();
|
||||
return chunkX * chunkX + chunkZ * chunkZ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package appeng.worldgen;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public final class PlacedMeteoriteSettings {
|
||||
|
||||
private final BlockPos pos;
|
||||
@@ -17,7 +17,8 @@ public final class PlacedMeteoriteSettings {
|
||||
private final double meteoriteRadius;
|
||||
private final double craterRadius;
|
||||
|
||||
public PlacedMeteoriteSettings(BlockPos pos, ResourceLocation blk, boolean lava, int skyMode, double meteoriteRadius, double craterRadius) {
|
||||
public PlacedMeteoriteSettings(BlockPos pos, ResourceLocation blk, boolean lava, int skyMode,
|
||||
double meteoriteRadius, double craterRadius) {
|
||||
this.pos = pos;
|
||||
this.blk = blk;
|
||||
this.lava = lava;
|
||||
@@ -54,13 +55,13 @@ public final class PlacedMeteoriteSettings {
|
||||
tag.putInt("x", pos.getX());
|
||||
tag.putInt("y", pos.getY());
|
||||
tag.putInt("z", pos.getZ());
|
||||
tag.putString( "blk", blk.toString() );
|
||||
tag.putString("blk", blk.toString());
|
||||
|
||||
tag.putDouble( "meteoriteRadius", meteoriteRadius );
|
||||
tag.putDouble( "craterRadius", craterRadius );
|
||||
tag.putDouble("meteoriteRadius", meteoriteRadius);
|
||||
tag.putDouble("craterRadius", craterRadius);
|
||||
|
||||
tag.putBoolean( "lava", lava );
|
||||
tag.putInt( "skyMode", skyMode );
|
||||
tag.putBoolean("lava", lava);
|
||||
tag.putInt("skyMode", skyMode);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,11 @@
|
||||
|
||||
package appeng.worldgen;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.features.IWorldGen.WorldGenType;
|
||||
import appeng.core.features.registries.WorldGenRegistry;
|
||||
import com.mojang.datafixers.Dynamic;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
@@ -33,83 +31,73 @@ import net.minecraft.world.gen.GenerationSettings;
|
||||
import net.minecraft.world.gen.feature.ReplaceBlockConfig;
|
||||
import net.minecraft.world.gen.feature.ReplaceBlockFeature;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.features.IWorldGen.WorldGenType;
|
||||
import appeng.core.features.registries.WorldGenRegistry;
|
||||
|
||||
public final class QuartzWorldGen extends ReplaceBlockFeature {
|
||||
/*
|
||||
* private final WorldGenMinable oreNormal; private final WorldGenMinable
|
||||
* oreCharged;
|
||||
*/
|
||||
|
||||
public final class QuartzWorldGen extends ReplaceBlockFeature
|
||||
{
|
||||
/*
|
||||
private final WorldGenMinable oreNormal;
|
||||
private final WorldGenMinable oreCharged;
|
||||
*/
|
||||
public QuartzWorldGen(Function<Dynamic<?>, ? extends ReplaceBlockConfig> serializer) {
|
||||
super(serializer);
|
||||
final IBlocks blocks = AEApi.instance().definitions().blocks();
|
||||
final IBlockDefinition oreDefinition = blocks.quartzOre();
|
||||
final IBlockDefinition chargedDefinition = blocks.quartzOreCharged();
|
||||
|
||||
public QuartzWorldGen( Function<Dynamic<?>, ? extends ReplaceBlockConfig> serializer )
|
||||
{
|
||||
super(serializer);
|
||||
final IBlocks blocks = AEApi.instance().definitions().blocks();
|
||||
final IBlockDefinition oreDefinition = blocks.quartzOre();
|
||||
final IBlockDefinition chargedDefinition = blocks.quartzOreCharged();
|
||||
/*
|
||||
* this.oreNormal = oreDefinition.maybeBlock() .map( b -> new WorldGenMinable(
|
||||
* b.getDefaultState(), AEConfig.instance().getQuartzOresPerCluster() ) )
|
||||
* .orElse( null ); this.oreCharged = chargedDefinition.maybeBlock() .map( b ->
|
||||
* new WorldGenMinable( b.getDefaultState(),
|
||||
* AEConfig.instance().getQuartzOresPerCluster() ) ) .orElse( null );
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
this.oreNormal = oreDefinition.maybeBlock()
|
||||
.map( b -> new WorldGenMinable( b.getDefaultState(), AEConfig.instance().getQuartzOresPerCluster() ) )
|
||||
.orElse( null );
|
||||
this.oreCharged = chargedDefinition.maybeBlock()
|
||||
.map( b -> new WorldGenMinable( b.getDefaultState(), AEConfig.instance().getQuartzOresPerCluster() ) )
|
||||
.orElse( null );
|
||||
*/
|
||||
}
|
||||
private static boolean shouldGenerate(final boolean isCharged, final World w) {
|
||||
return WorldGenRegistry.INSTANCE
|
||||
.isWorldGenEnabled(isCharged ? WorldGenType.CHARGED_CERTUS_QUARTZ : WorldGenType.CERTUS_QUARTZ, w);
|
||||
}
|
||||
|
||||
private static boolean shouldGenerate( final boolean isCharged, final World w )
|
||||
{
|
||||
return WorldGenRegistry.INSTANCE.isWorldGenEnabled( isCharged ? WorldGenType.CHARGED_CERTUS_QUARTZ : WorldGenType.CERTUS_QUARTZ, w );
|
||||
}
|
||||
|
||||
@Override public boolean place( IWorld worldIn, ChunkGenerator<? extends GenerationSettings> generator, Random r, BlockPos pos, ReplaceBlockConfig config )
|
||||
{
|
||||
/*
|
||||
if( this.oreNormal == null && this.oreCharged == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
World w = worldIn.getWorld();
|
||||
|
||||
int seaLevel = w.getSeaLevel();
|
||||
|
||||
ChunkPos chunkPos = new ChunkPos( pos );
|
||||
|
||||
if( seaLevel < 20 )
|
||||
{
|
||||
final int x = ( chunkPos.x << 4 ) + 8;
|
||||
final int z = ( chunkPos.z << 4 ) + 8;
|
||||
seaLevel = w.getHeight( Heightmap.Type.WORLD_SURFACE, x, z );
|
||||
}
|
||||
|
||||
final int oreDepthMultiplier = AEConfig.instance().getQuartzOresClusterAmount() * seaLevel / 64;
|
||||
final int scale = (int) Math.round( r.nextGaussian() * Math.sqrt( oreDepthMultiplier ) + oreDepthMultiplier );
|
||||
|
||||
for( int cnt = 0; cnt < ( r.nextBoolean() ? scale * 2 : scale ) / 2; ++cnt )
|
||||
{
|
||||
boolean isCharged = false;
|
||||
|
||||
if( this.oreCharged != null )
|
||||
{
|
||||
isCharged = r.nextFloat() > AEConfig.instance().getSpawnChargedChance();
|
||||
}
|
||||
|
||||
final WorldGenMinable whichOre = isCharged ? this.oreCharged : this.oreNormal;
|
||||
if( whichOre != null && shouldGenerate( isCharged, w ) )
|
||||
{
|
||||
final int cx = chunkPos.x * 16 + r.nextInt( 16 );
|
||||
final int cy = r.nextInt( 40 * seaLevel / 64 ) + r.nextInt( 22 * seaLevel / 64 ) + 12 * seaLevel / 64;
|
||||
final int cz = chunkPos.z * 16 + r.nextInt( 16 );
|
||||
whichOre.generate( w, r, new BlockPos( cx, cy, cz ) );
|
||||
}
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean place(IWorld worldIn, ChunkGenerator<? extends GenerationSettings> generator, Random r, BlockPos pos,
|
||||
ReplaceBlockConfig config) {
|
||||
/*
|
||||
* if( this.oreNormal == null && this.oreCharged == null ) { return false; }
|
||||
*
|
||||
* World w = worldIn.getWorld();
|
||||
*
|
||||
* int seaLevel = w.getSeaLevel();
|
||||
*
|
||||
* ChunkPos chunkPos = new ChunkPos( pos );
|
||||
*
|
||||
* if( seaLevel < 20 ) { final int x = ( chunkPos.x << 4 ) + 8; final int z = (
|
||||
* chunkPos.z << 4 ) + 8; seaLevel = w.getHeight( Heightmap.Type.WORLD_SURFACE,
|
||||
* x, z ); }
|
||||
*
|
||||
* final int oreDepthMultiplier =
|
||||
* AEConfig.instance().getQuartzOresClusterAmount() * seaLevel / 64; final int
|
||||
* scale = (int) Math.round( r.nextGaussian() * Math.sqrt( oreDepthMultiplier )
|
||||
* + oreDepthMultiplier );
|
||||
*
|
||||
* for( int cnt = 0; cnt < ( r.nextBoolean() ? scale * 2 : scale ) / 2; ++cnt )
|
||||
* { boolean isCharged = false;
|
||||
*
|
||||
* if( this.oreCharged != null ) { isCharged = r.nextFloat() >
|
||||
* AEConfig.instance().getSpawnChargedChance(); }
|
||||
*
|
||||
* final WorldGenMinable whichOre = isCharged ? this.oreCharged :
|
||||
* this.oreNormal; if( whichOre != null && shouldGenerate( isCharged, w ) ) {
|
||||
* final int cx = chunkPos.x * 16 + r.nextInt( 16 ); final int cy = r.nextInt(
|
||||
* 40 * seaLevel / 64 ) + r.nextInt( 22 * seaLevel / 64 ) + 12 * seaLevel / 64;
|
||||
* final int cz = chunkPos.z * 16 + r.nextInt( 16 ); whichOre.generate( w, r,
|
||||
* new BlockPos( cx, cy, cz ) ); } }
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,56 +18,48 @@
|
||||
|
||||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ChunkOnly extends StandardWorld
|
||||
{
|
||||
public class ChunkOnly extends StandardWorld {
|
||||
|
||||
private final IChunk target;
|
||||
private final int cx;
|
||||
private final int cz;
|
||||
private final IChunk target;
|
||||
private final int cx;
|
||||
private final int cz;
|
||||
|
||||
public ChunkOnly(final IWorld w, final int cx, final int cz )
|
||||
{
|
||||
super( w );
|
||||
this.target = w.getChunk( cx, cz );
|
||||
this.cx = cx;
|
||||
this.cz = cz;
|
||||
}
|
||||
public ChunkOnly(final IWorld w, final int cx, final int cz) {
|
||||
super(w);
|
||||
this.target = w.getChunk(cx, cz);
|
||||
this.cx = cx;
|
||||
this.cz = cz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minX( final int in )
|
||||
{
|
||||
return Math.max( in, this.cx << 4 );
|
||||
}
|
||||
@Override
|
||||
public int minX(final int in) {
|
||||
return Math.max(in, this.cx << 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minZ( final int in )
|
||||
{
|
||||
return Math.max( in, this.cz << 4 );
|
||||
}
|
||||
@Override
|
||||
public int minZ(final int in) {
|
||||
return Math.max(in, this.cz << 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxX( final int in )
|
||||
{
|
||||
return Math.min( in, ( this.cx + 1 ) << 4 );
|
||||
}
|
||||
@Override
|
||||
public int maxX(final int in) {
|
||||
return Math.min(in, (this.cx + 1) << 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxZ( final int in )
|
||||
{
|
||||
return Math.min( in, ( this.cz + 1 ) << 4 );
|
||||
}
|
||||
@Override
|
||||
public int maxZ(final int in) {
|
||||
return Math.min(in, (this.cz + 1) << 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(BlockPos pos) {
|
||||
@@ -75,36 +67,29 @@ public class ChunkOnly extends StandardWorld
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock( BlockPos pos )
|
||||
{
|
||||
if( this.range( pos ) )
|
||||
{
|
||||
return this.target.getBlockState( new BlockPos(pos) ).getBlock();
|
||||
}
|
||||
return Platform.AIR_BLOCK;
|
||||
}
|
||||
public Block getBlock(BlockPos pos) {
|
||||
if (this.range(pos)) {
|
||||
return this.target.getBlockState(new BlockPos(pos)).getBlock();
|
||||
}
|
||||
return Platform.AIR_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock( BlockPos pos, final BlockState blk )
|
||||
{
|
||||
if( this.range( pos ) )
|
||||
{
|
||||
target.setBlockState(new BlockPos( pos ), blk, false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setBlock(BlockPos pos, final BlockState blk) {
|
||||
if (this.range(pos)) {
|
||||
target.setBlockState(new BlockPos(pos), blk, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock( BlockPos pos, final BlockState state, final int flags )
|
||||
{
|
||||
if( this.range( pos ) )
|
||||
{
|
||||
this.getWorld().setBlockState( new BlockPos( pos ), state, flags & ( ~2 ) );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setBlock(BlockPos pos, final BlockState state, final int flags) {
|
||||
if (this.range(pos)) {
|
||||
this.getWorld().setBlockState(new BlockPos(pos), state, flags & (~2));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean range( BlockPos pos )
|
||||
{
|
||||
return this.cx == ( pos.getX() >> 4 ) && this.cz == ( pos.getZ() >> 4 );
|
||||
}
|
||||
@Override
|
||||
public boolean range(BlockPos pos) {
|
||||
return this.cx == (pos.getX() >> 4) && this.cz == (pos.getZ() >> 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,78 +18,53 @@
|
||||
|
||||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class Fallout
|
||||
{
|
||||
private final MeteoriteBlockPutter putter;
|
||||
private final BlockState skyStone;
|
||||
public class Fallout {
|
||||
private final MeteoriteBlockPutter putter;
|
||||
private final BlockState skyStone;
|
||||
|
||||
public Fallout( final MeteoriteBlockPutter putter, final BlockState skyStone )
|
||||
{
|
||||
this.putter = putter;
|
||||
this.skyStone = skyStone;
|
||||
}
|
||||
public Fallout(final MeteoriteBlockPutter putter, final BlockState skyStone) {
|
||||
this.putter = putter;
|
||||
this.skyStone = skyStone;
|
||||
}
|
||||
|
||||
public int adjustCrater()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
public int adjustCrater() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void getRandomFall(final IWorld w, BlockPos pos )
|
||||
{
|
||||
final double a = Math.random();
|
||||
if( a > 0.9 )
|
||||
{
|
||||
this.putter.put( w, pos, Blocks.STONE.getDefaultState() );
|
||||
}
|
||||
else if( a > 0.8 )
|
||||
{
|
||||
this.putter.put( w, pos, Blocks.COBBLESTONE.getDefaultState() );
|
||||
}
|
||||
else if( a > 0.7 )
|
||||
{
|
||||
this.putter.put( w, pos, Blocks.DIRT.getDefaultState() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.putter.put( w, pos, Blocks.GRAVEL.getDefaultState() );
|
||||
}
|
||||
}
|
||||
public void getRandomFall(final IWorld w, BlockPos pos) {
|
||||
final double a = Math.random();
|
||||
if (a > 0.9) {
|
||||
this.putter.put(w, pos, Blocks.STONE.getDefaultState());
|
||||
} else if (a > 0.8) {
|
||||
this.putter.put(w, pos, Blocks.COBBLESTONE.getDefaultState());
|
||||
} else if (a > 0.7) {
|
||||
this.putter.put(w, pos, Blocks.DIRT.getDefaultState());
|
||||
} else {
|
||||
this.putter.put(w, pos, Blocks.GRAVEL.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
||||
public void getRandomInset( final IWorld w, BlockPos pos )
|
||||
{
|
||||
final double a = Math.random();
|
||||
if( a > 0.9 )
|
||||
{
|
||||
this.putter.put( w, pos, Blocks.COBBLESTONE.getDefaultState() );
|
||||
}
|
||||
else if( a > 0.8 )
|
||||
{
|
||||
this.putter.put( w, pos, Blocks.STONE.getDefaultState() );
|
||||
}
|
||||
else if( a > 0.7 )
|
||||
{
|
||||
this.putter.put( w, pos, Blocks.GRASS_BLOCK.getDefaultState() );
|
||||
}
|
||||
else if( a > 0.6 )
|
||||
{
|
||||
this.putter.put( w, pos, this.skyStone );
|
||||
}
|
||||
else if( a > 0.5 )
|
||||
{
|
||||
this.putter.put( w, pos, Blocks.GRAVEL.getDefaultState() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.putter.put( w, pos, Platform.AIR_BLOCK.getDefaultState() );
|
||||
}
|
||||
}
|
||||
public void getRandomInset(final IWorld w, BlockPos pos) {
|
||||
final double a = Math.random();
|
||||
if (a > 0.9) {
|
||||
this.putter.put(w, pos, Blocks.COBBLESTONE.getDefaultState());
|
||||
} else if (a > 0.8) {
|
||||
this.putter.put(w, pos, Blocks.STONE.getDefaultState());
|
||||
} else if (a > 0.7) {
|
||||
this.putter.put(w, pos, Blocks.GRASS_BLOCK.getDefaultState());
|
||||
} else if (a > 0.6) {
|
||||
this.putter.put(w, pos, this.skyStone);
|
||||
} else if (a > 0.5) {
|
||||
this.putter.put(w, pos, Blocks.GRAVEL.getDefaultState());
|
||||
} else {
|
||||
this.putter.put(w, pos, Platform.AIR_BLOCK.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,67 +18,52 @@
|
||||
|
||||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class FalloutCopy extends Fallout
|
||||
{
|
||||
private static final double SPECIFIED_BLOCK_THRESHOLD = 0.9;
|
||||
private static final double AIR_BLOCK_THRESHOLD = 0.8;
|
||||
private static final double BLOCK_THRESHOLD_STEP = 0.1;
|
||||
public class FalloutCopy extends Fallout {
|
||||
private static final double SPECIFIED_BLOCK_THRESHOLD = 0.9;
|
||||
private static final double AIR_BLOCK_THRESHOLD = 0.8;
|
||||
private static final double BLOCK_THRESHOLD_STEP = 0.1;
|
||||
|
||||
private final BlockState block;
|
||||
private final MeteoriteBlockPutter putter;
|
||||
private final BlockState block;
|
||||
private final MeteoriteBlockPutter putter;
|
||||
|
||||
public FalloutCopy(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone )
|
||||
{
|
||||
super( putter, skyStone );
|
||||
this.putter = putter;
|
||||
this.block = w.getBlockState( pos );
|
||||
}
|
||||
public FalloutCopy(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone) {
|
||||
super(putter, skyStone);
|
||||
this.putter = putter;
|
||||
this.block = w.getBlockState(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRandomFall( final IWorld w, BlockPos pos )
|
||||
{
|
||||
final double a = Math.random();
|
||||
if( a > SPECIFIED_BLOCK_THRESHOLD )
|
||||
{
|
||||
this.putter.put( w, pos, this.block );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getOther( w, pos, a );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void getRandomFall(final IWorld w, BlockPos pos) {
|
||||
final double a = Math.random();
|
||||
if (a > SPECIFIED_BLOCK_THRESHOLD) {
|
||||
this.putter.put(w, pos, this.block);
|
||||
} else {
|
||||
this.getOther(w, pos, a);
|
||||
}
|
||||
}
|
||||
|
||||
public void getOther( final IWorld w, BlockPos pos, final double a )
|
||||
{
|
||||
public void getOther(final IWorld w, BlockPos pos, final double a) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRandomInset( final IWorld w, BlockPos pos )
|
||||
{
|
||||
final double a = Math.random();
|
||||
if( a > SPECIFIED_BLOCK_THRESHOLD )
|
||||
{
|
||||
this.putter.put( w, pos, this.block );
|
||||
}
|
||||
else if( a > AIR_BLOCK_THRESHOLD )
|
||||
{
|
||||
this.putter.put( w, pos, Blocks.AIR.getDefaultState() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getOther( w, pos, a - BLOCK_THRESHOLD_STEP );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void getRandomInset(final IWorld w, BlockPos pos) {
|
||||
final double a = Math.random();
|
||||
if (a > SPECIFIED_BLOCK_THRESHOLD) {
|
||||
this.putter.put(w, pos, this.block);
|
||||
} else if (a > AIR_BLOCK_THRESHOLD) {
|
||||
this.putter.put(w, pos, Blocks.AIR.getDefaultState());
|
||||
} else {
|
||||
this.getOther(w, pos, a - BLOCK_THRESHOLD_STEP);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,38 +18,31 @@
|
||||
|
||||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
|
||||
public class FalloutSand extends FalloutCopy
|
||||
{
|
||||
private static final double GLASS_THRESHOLD = 0.66;
|
||||
private final MeteoriteBlockPutter putter;
|
||||
public class FalloutSand extends FalloutCopy {
|
||||
private static final double GLASS_THRESHOLD = 0.66;
|
||||
private final MeteoriteBlockPutter putter;
|
||||
|
||||
public FalloutSand(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone )
|
||||
{
|
||||
super( w, pos, putter, skyStone );
|
||||
this.putter = putter;
|
||||
}
|
||||
public FalloutSand(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone) {
|
||||
super(w, pos, putter, skyStone);
|
||||
this.putter = putter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int adjustCrater()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
@Override
|
||||
public int adjustCrater() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOther( final IWorld w, BlockPos pos, final double a )
|
||||
{
|
||||
if( a > GLASS_THRESHOLD )
|
||||
{
|
||||
this.putter.put( w, pos, Blocks.GLASS.getDefaultState() );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void getOther(final IWorld w, BlockPos pos, final double a) {
|
||||
if (a > GLASS_THRESHOLD) {
|
||||
this.putter.put(w, pos, Blocks.GLASS.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,43 +18,34 @@
|
||||
|
||||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
|
||||
public class FalloutSnow extends FalloutCopy
|
||||
{
|
||||
private static final double SNOW_THRESHOLD = 0.7;
|
||||
private static final double ICE_THRESHOLD = 0.5;
|
||||
private final MeteoriteBlockPutter putter;
|
||||
public class FalloutSnow extends FalloutCopy {
|
||||
private static final double SNOW_THRESHOLD = 0.7;
|
||||
private static final double ICE_THRESHOLD = 0.5;
|
||||
private final MeteoriteBlockPutter putter;
|
||||
|
||||
public FalloutSnow(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone)
|
||||
{
|
||||
super( w, pos, putter, skyStone );
|
||||
this.putter = putter;
|
||||
}
|
||||
public FalloutSnow(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone) {
|
||||
super(w, pos, putter, skyStone);
|
||||
this.putter = putter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int adjustCrater()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
@Override
|
||||
public int adjustCrater() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOther( final IWorld w, BlockPos pos, final double a )
|
||||
{
|
||||
if( a > SNOW_THRESHOLD )
|
||||
{
|
||||
this.putter.put( w, pos, Blocks.SNOW.getDefaultState() );
|
||||
}
|
||||
else if( a > ICE_THRESHOLD )
|
||||
{
|
||||
this.putter.put( w, pos, Blocks.ICE.getDefaultState() );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void getOther(final IWorld w, BlockPos pos, final double a) {
|
||||
if (a > SNOW_THRESHOLD) {
|
||||
this.putter.put(w, pos, Blocks.SNOW.getDefaultState());
|
||||
} else if (a > ICE_THRESHOLD) {
|
||||
this.putter.put(w, pos, Blocks.ICE.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -26,30 +25,28 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IMeteoriteWorld {
|
||||
int minX(int in);
|
||||
|
||||
public interface IMeteoriteWorld
|
||||
{
|
||||
int minX( int in );
|
||||
int minZ(int in);
|
||||
|
||||
int minZ( int in );
|
||||
int maxX(int in);
|
||||
|
||||
int maxX( int in );
|
||||
int maxZ(int in);
|
||||
|
||||
int maxZ( int in );
|
||||
boolean contains(BlockPos pos);
|
||||
|
||||
boolean contains( BlockPos pos );
|
||||
Block getBlock(BlockPos pos);
|
||||
|
||||
Block getBlock( BlockPos pos );
|
||||
boolean canBlockSeeTheSky(BlockPos pos);
|
||||
|
||||
boolean canBlockSeeTheSky( BlockPos pos );
|
||||
TileEntity getTileEntity(BlockPos pos);
|
||||
|
||||
TileEntity getTileEntity( BlockPos pos );
|
||||
IWorld getWorld();
|
||||
|
||||
IWorld getWorld();
|
||||
void setBlock(BlockPos pos, final BlockState state, final int flags);
|
||||
|
||||
void setBlock( BlockPos pos, final BlockState state, final int flags );
|
||||
void setBlock(BlockPos pos, BlockState blk);
|
||||
|
||||
void setBlock( BlockPos pos, BlockState blk );
|
||||
|
||||
BlockState getBlockState( BlockPos pos );
|
||||
BlockState getBlockState(BlockPos pos);
|
||||
}
|
||||
@@ -18,27 +18,22 @@
|
||||
|
||||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
public class MeteoriteBlockPutter {
|
||||
public boolean put(final IWorld w, BlockPos pos, final BlockState blk) {
|
||||
final BlockState original = w.getBlockState(pos);
|
||||
|
||||
public class MeteoriteBlockPutter
|
||||
{
|
||||
public boolean put(final IWorld w, BlockPos pos, final BlockState blk )
|
||||
{
|
||||
final BlockState original = w.getBlockState( pos );
|
||||
if (original.getBlock() == Blocks.BEDROCK || original == blk) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( original.getBlock() == Blocks.BEDROCK || original == blk )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
w.setBlockState(pos, blk, 0);
|
||||
return true;
|
||||
}
|
||||
w.setBlockState(pos, blk, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -29,113 +28,92 @@ import net.minecraft.world.World;
|
||||
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class StandardWorld implements IMeteoriteWorld {
|
||||
|
||||
public class StandardWorld implements IMeteoriteWorld
|
||||
{
|
||||
private final IWorld w;
|
||||
|
||||
private final IWorld w;
|
||||
public StandardWorld(final IWorld w) {
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
public StandardWorld( final IWorld w )
|
||||
{
|
||||
this.w = w;
|
||||
}
|
||||
@Override
|
||||
public int minX(final int in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minX( final int in )
|
||||
{
|
||||
return in;
|
||||
}
|
||||
@Override
|
||||
public int minZ(final int in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minZ( final int in )
|
||||
{
|
||||
return in;
|
||||
}
|
||||
@Override
|
||||
public int maxX(final int in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxX( final int in )
|
||||
{
|
||||
return in;
|
||||
}
|
||||
@Override
|
||||
public int maxZ(final int in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxZ( final int in )
|
||||
{
|
||||
return in;
|
||||
}
|
||||
@Override
|
||||
public boolean contains(BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public Block getBlock(BlockPos pos) {
|
||||
if (this.range(pos)) {
|
||||
return this.getWorld().getBlockState(new BlockPos(pos)).getBlock();
|
||||
}
|
||||
return Platform.AIR_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock( BlockPos pos )
|
||||
{
|
||||
if( this.range( pos ) )
|
||||
{
|
||||
return this.getWorld().getBlockState( new BlockPos( pos ) ).getBlock();
|
||||
}
|
||||
return Platform.AIR_BLOCK;
|
||||
}
|
||||
@Override
|
||||
public boolean canBlockSeeTheSky(BlockPos pos) {
|
||||
if (this.range(pos)) {
|
||||
return this.getWorld().canBlockSeeSky(new BlockPos(pos));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlockSeeTheSky( BlockPos pos )
|
||||
{
|
||||
if( this.range( pos ) )
|
||||
{
|
||||
return this.getWorld().canBlockSeeSky( new BlockPos( pos ) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public TileEntity getTileEntity(BlockPos pos) {
|
||||
if (this.range(pos)) {
|
||||
return this.getWorld().getTileEntity(new BlockPos(pos));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity( BlockPos pos )
|
||||
{
|
||||
if( this.range( pos ) )
|
||||
{
|
||||
return this.getWorld().getTileEntity( new BlockPos( pos ) );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public IWorld getWorld() {
|
||||
return this.w;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorld getWorld()
|
||||
{
|
||||
return this.w;
|
||||
}
|
||||
@Override
|
||||
public void setBlock(BlockPos pos, final BlockState blk) {
|
||||
if (this.range(pos)) {
|
||||
// FIXME: Attempt at reducing impact of placing meteors by passing 16|32 here
|
||||
this.getWorld().setBlockState(new BlockPos(pos), blk, 16 | 32);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock( BlockPos pos, final BlockState blk )
|
||||
{
|
||||
if( this.range( pos ) )
|
||||
{
|
||||
// FIXME: Attempt at reducing impact of placing meteors by passing 16|32 here
|
||||
this.getWorld().setBlockState( new BlockPos( pos ), blk, 16|32 );
|
||||
}
|
||||
}
|
||||
public boolean range(BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean range( BlockPos pos )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void setBlock(BlockPos pos, final BlockState state, final int l) {
|
||||
if (this.range(pos)) {
|
||||
this.w.setBlockState(new BlockPos(pos), state, l);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock( BlockPos pos, final BlockState state, final int l )
|
||||
{
|
||||
if( this.range( pos ) )
|
||||
{
|
||||
this.w.setBlockState( new BlockPos( pos ), state, l );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState( BlockPos pos )
|
||||
{
|
||||
if( this.range( pos ) )
|
||||
{
|
||||
return this.w.getBlockState( new BlockPos( pos ) );
|
||||
}
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
if (this.range(pos)) {
|
||||
return this.w.getBlockState(new BlockPos(pos));
|
||||
}
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user