use of net.minecraft.world.biome.Biome in project RecurrentComplex by Ivorforce.
the class TransformerNatural method transformBlock.
@Override
public void transformBlock(InstanceData instanceData, Phase phase, StructureSpawnContext context, BlockPos sourcePos, BlockPos pos, IBlockState sourceState, double density) {
World world = context.environment.world;
Biome biome = context.environment.biome;
IBlockState topBlock = biome.topBlock != null ? biome.topBlock : Blocks.AIR.getDefaultState();
IBlockState fillerBlock = biome.fillerBlock != null ? biome.fillerBlock : Blocks.AIR.getDefaultState();
IBlockState mainBlock = Blocks.STONE.getDefaultState();
boolean useStoneBlock = pos.getY() < world.getSeaLevel();
IBlockState setBlock = useStoneBlock ? mainBlock : (instanceData.cloud.containsKey(sourcePos.up()) ? fillerBlock : topBlock);
if (world.provider.getDimension() == -1)
setBlock = Blocks.NETHERRACK.getDefaultState();
else if (world.provider.getDimension() == 1)
setBlock = Blocks.END_STONE.getDefaultState();
context.setBlock(pos, setBlock, 2);
}
use of net.minecraft.world.biome.Biome in project RecurrentComplex by Ivorforce.
the class WorldGenStructures method planStructuresInChunk.
public static void planStructuresInChunk(Random random, ChunkPos chunkPos, WorldServer world, Biome biomeGen, @Nullable Predicate<Structure> structurePredicate) {
MixingStructureSelector<NaturalGeneration, NaturalStructureSelector.Category> structureSelector = StructureRegistry.INSTANCE.naturalStructureSelectors().get(biomeGen, world.provider);
float distanceToSpawn = distance(new ChunkPos(world.getSpawnPoint()), chunkPos);
// TODO Use STRUCTURE_TRIES
List<Pair<Structure<?>, NaturalGeneration>> generated = structureSelector.generatedStructures(random, world.getBiome(chunkPos.getBlock(0, 0, 0)), world.provider, distanceToSpawn);
generated.stream().filter(pair -> structurePredicate == null || structurePredicate.test(pair.getLeft())).forEach(pair -> planStructureInChunk(chunkPos, world, pair.getLeft(), pair.getRight(), random.nextLong()));
}
use of net.minecraft.world.biome.Biome in project RecurrentComplex by Ivorforce.
the class RCBiomeDecorator method doDecorate.
protected static int doDecorate(WorldServer worldIn, Random random, BlockPos blockPos, DecorationType type, int amount, boolean lowChance) {
ChunkPos chunkPos = new ChunkPos(blockPos);
double baseWeight = RCConfig.baseDecorationWeights.get(type);
if (baseWeight <= 0)
return amount;
Biome biomeIn = worldIn.getBiome(chunkPos.getBlock(16, 0, 16));
StructureSelector<VanillaDecorationGeneration, DecorationType> selector = StructureRegistry.INSTANCE.decorationSelectors().get(biomeIn, worldIn.provider);
double totalWeight = selector.totalWeight(type);
if (totalWeight <= 0)
return amount;
return trySurface(worldIn, random, chunkPos, selector, type, totalWeight, baseWeight, amount, lowChance);
}
use of net.minecraft.world.biome.Biome in project RecurrentComplex by Ivorforce.
the class RCBiomeDecorator method doDecorate.
protected static Event.Result doDecorate(WorldServer worldIn, Random random, BlockPos chunkPos, DecorationType type) {
Biome biomeIn = worldIn.getBiome(chunkPos.add(16, 0, 16));
BiomeDecorator decorator = biomeIn.decorator;
Adapter adapter = adapter(worldIn, chunkPos, type, biomeIn, decorator);
int origAmount = adapter.amount(worldIn, random, biomeIn, decorator, chunkPos, type);
// Don't interfere
if (origAmount < 0)
return null;
int vanillaAmount = doDecorate(worldIn, random, chunkPos, type, origAmount, adapter.mayGiveUp(worldIn, random, biomeIn, decorator, chunkPos, type));
// Replaced none, might as well give back
if (vanillaAmount == origAmount)
return null;
for (int i = 0; i < vanillaAmount; ++i) adapter.generate(worldIn, random, biomeIn, decorator, chunkPos, type);
// if < 0 we let vanilla do its thing
return vanillaAmount >= 0 ? Event.Result.DENY : null;
}
use of net.minecraft.world.biome.Biome in project BetterWithAddons by DaedalusGame.
the class BlockWorldScaleOre method exposedToElements.
public boolean exposedToElements(World world, BlockPos pos) {
Biome biome = world.getBiome(pos);
boolean isHot = biome.getTempCategory() == Biome.TempCategory.WARM;
boolean isRaining = world.isRainingAt(pos);
boolean isCold = biome.isSnowyBiome();
boolean isHumid = biome.canRain();
boolean isDaytime = world.isDaytime();
boolean isWaterAbove = world.getBlockState(pos.up()).getMaterial() == Material.WATER;
if (// TODO: Switch this out for a lens check maybe. That would push it back in the tech tree :/
isHot && !isHumid && isDaytime)
return true;
if (isCold && isRaining)
return true;
if (isWaterAbove)
return true;
return false;
}
Aggregations