use of net.minecraft.world.biome.Biome in project Almura by AlmuraDev.
the class Grass method getOrLoadAmountRequiredRangeForBiome.
@Nullable
public IntRange getOrLoadAmountRequiredRangeForBiome(final Biome biome) {
@Nullable IntRange found = this.biomeAmountRanges.get(biome);
if (found == null) {
for (final Map.Entry<FunctionPredicate<Biome, ResourceLocation>, IntRange> entry : this.biomeAmountPredicates.entrySet()) {
final FunctionPredicate<Biome, ResourceLocation> predicate = entry.getKey();
if (predicate.test(biome)) {
final IntRange range = entry.getValue();
this.biomeAmountRanges.put(biome, range);
found = range;
break;
}
}
}
if (found == null && this.globalAmountRange != null) {
this.biomeAmountRanges.put(biome, this.globalAmountRange);
found = this.globalAmountRange;
}
return found;
}
use of net.minecraft.world.biome.Biome in project Almura by AlmuraDev.
the class TreeFeature method generate.
@Override
public boolean generate(final World world, final Random random, final BlockPos origin, final List<LazyBlockState> requires) {
final Biome biome = world.getBiome(origin);
final int height = AbstractTreeFeature.height(this.height, biome, random);
boolean canPlace = true;
if (origin.getY() < 1 || origin.getY() + height + 1 > world.getHeight()) {
return false;
}
for (int y = origin.getY(); y <= origin.getY() + 1 + height; y++) {
int k = 1;
if (y == origin.getY()) {
k = 0;
}
if (y >= origin.getY() + 1 + height - 2) {
k = 2;
}
final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
for (int x = origin.getX() - k; x <= origin.getX() + k && canPlace; x++) {
for (int z = origin.getZ() - k; z <= origin.getZ() + k && canPlace; z++) {
if (y >= 0 && y < world.getHeight()) {
if (!this.replaceable(world, pos.setPos(x, y, z))) {
canPlace = false;
}
} else {
canPlace = false;
}
}
}
}
if (!canPlace) {
return false;
}
final BlockPos belowOrigin = origin.down();
IBlockState state = world.getBlockState(belowOrigin);
if (AbstractTreeFeature.canSustainPlant(state, world, belowOrigin, EnumFacing.UP, (BlockSapling) Blocks.SAPLING, requires) && origin.getY() < world.getHeight() - height - 1) {
state.getBlock().onPlantGrow(state, world, belowOrigin, origin);
for (int y = origin.getY() - 3 + height; y <= origin.getY() + height; y++) {
final int yd = y - (origin.getY() + height);
final int os = 1 - yd / 2;
for (int x = origin.getX() - os; x <= origin.getX() + os; x++) {
final int ox = x - origin.getX();
for (int z = origin.getZ() - os; z <= origin.getZ() + os; z++) {
final int oz = z - origin.getZ();
if (Math.abs(ox) != os || Math.abs(oz) != os || random.nextInt(2) != 0 && yd != 0) {
final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(x, y, z);
state = world.getBlockState(pos);
if (state.getBlock().isAir(state, world, pos) || state.getBlock().isLeaves(state, world, pos) || state.getMaterial() == Material.VINE) {
final IBlockState leavesOrFruitState = AbstractTreeFeature.leavesOrFruitBlock(this.leaves, this.fruit, biome, random);
this.setBlockAndNotifyAdequately(world, pos, leavesOrFruitState);
state = world.getBlockState(pos);
// Enforce hanging only hanging from a leaves or fruit
if (state.equals(leavesOrFruitState) && AbstractTreeFeature.shouldPlaceHanging(this.hanging, biome, random)) {
pos.setPos(x, y - 1, z);
final IBlockState underLeafOrFruitState = world.getBlockState(pos);
if (underLeafOrFruitState.getBlock().isAir(underLeafOrFruitState, world, pos)) {
this.setBlockAndNotifyAdequately(world, pos, AbstractTreeFeature.hangingBlock(this.hanging));
}
}
}
}
}
}
}
final BlockPos.MutableBlockPos mutPos = new BlockPos.MutableBlockPos(origin);
for (int i = 0; i < height; i++) {
final BlockPos pos = mutPos.setPos(mutPos.getX(), origin.getY() + i, mutPos.getZ());
state = world.getBlockState(pos);
if (state.getBlock().isAir(state, world, pos) || state.getBlock().isLeaves(state, world, pos) || AbstractTreeFeature.hangingBlock(this.hanging).equals(state) || state.getMaterial() == Material.VINE) {
this.setBlockAndNotifyAdequately(world, pos, this.log.get());
}
}
return true;
}
return false;
}
use of net.minecraft.world.biome.Biome in project Almura by AlmuraDev.
the class BiomeServerFeature method getBiomeConfigs.
private Map<Integer, BiomeConfig> getBiomeConfigs() {
final ForgeRegistry<Biome> registry = (ForgeRegistry<Biome>) ForgeRegistries.BIOMES;
final List<Biome> values = registry.getValues();
final Map<Integer, BiomeConfig> biomes = new HashMap<>(values.size());
for (Biome biome : values) {
biomes.put(registry.getID(biome), BiomeConfig.of(biome));
}
return biomes;
}
use of net.minecraft.world.biome.Biome in project Almura by AlmuraDev.
the class MixinWorld method redirectCanSnowAt.
@Redirect(method = "isRainingAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;canSnowAt(Lnet/minecraft/util/math/BlockPos;Z)Z"))
private boolean redirectCanSnowAt(World world, BlockPos pos, boolean checkLight) {
final BiomeChunk biomeChunk = BiomeUtil.getChunk(pos);
if (biomeChunk == null) {
return world.canSnowAt(pos, checkLight);
}
final Biome biome = world.getBiome(pos);
final float temperature = biomeChunk.getTemperature(pos, biome);
return temperature < 0.15f;
}
use of net.minecraft.world.biome.Biome in project Almura by AlmuraDev.
the class MixinBiomeColorHelper method getColorAtPos.
/**
* @author Zidane - Chris Sanders
* @reason Have water respect our config
*/
@Overwrite
private static int getColorAtPos(IBlockAccess blockAccess, BlockPos pos, BiomeColorHelper.ColorResolver colorResolver) {
int i = 0;
int j = 0;
int k = 0;
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(pos.add(-1, 0, -1), pos.add(1, 0, 1))) {
final Biome biome = blockAccess.getBiome(blockpos$mutableblockpos);
int l;
if (colorResolver == BiomeColorHelper.WATER_COLOR) {
final BiomeChunk biomeChunk = BiomeUtil.getChunk(blockpos$mutableblockpos);
if (biomeChunk == null) {
l = colorResolver.getColorAtPos(biome, blockpos$mutableblockpos);
} else {
l = biomeChunk.getWaterColor(pos, biome);
}
} else {
l = colorResolver.getColorAtPos(biome, blockpos$mutableblockpos);
}
i += (l & 16711680) >> 16;
j += (l & 65280) >> 8;
k += l & 255;
}
return (i / 9 & 255) << 16 | (j / 9 & 255) << 8 | k / 9 & 255;
}
Aggregations