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 TileEntityLureTree method attractAnimals.
public boolean attractAnimals(int amt) {
Random random = world.rand;
Biome biome = world.getBiome(pos);
int spawned = 0;
if (biome != null) {
List<Biome.SpawnListEntry> spawnable = biome.getSpawnableList(EnumCreatureType.CREATURE);
if (!spawnable.isEmpty())
for (int i = 0; i < amt; i++) {
Biome.SpawnListEntry entry = WeightedRandom.getRandomItem(random, spawnable);
int x = pos.getX() + random.nextInt(InteractionBWA.RADIUS * 2 + 1) - InteractionBWA.RADIUS;
int z = pos.getZ() + random.nextInt(InteractionBWA.RADIUS * 2 + 1) - InteractionBWA.RADIUS;
if (!BLACKLIST.contains(entry.entityClass)) {
for (int y = pos.getY(); y > pos.getY() - 4; y--) {
BlockPos pos = new BlockPos(x, y, z);
if (world.isAirBlock(pos) && WorldEntitySpawner.canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType.ON_GROUND, world, pos)) {
EntityLiving entityliving;
try {
entityliving = entry.entityClass.getConstructor(new Class[] { World.class }).newInstance(new Object[] { world });
} catch (Exception exception) {
exception.printStackTrace();
continue;
}
entityliving.setLocationAndAngles(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, random.nextFloat() * 360.0F, 0.0F);
world.spawnEntity(entityliving);
if (entityliving != null) {
entityliving.spawnExplosionParticle();
spawned++;
}
break;
} else if (world.isSideSolid(pos, EnumFacing.UP)) {
break;
}
}
}
}
}
return spawned > 0;
}
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