Lake fixes & water features

This commit is contained in:
paulevsGitch 2020-10-16 22:38:50 +03:00
parent 4dd1c55924
commit 6ebc796fb0
8 changed files with 173 additions and 39 deletions

View file

@ -0,0 +1,37 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.basis.BlockDoublePlant;
import ru.betterend.util.BlocksHelper;
public class UnderwaterPlantFeature extends UnderwaterPlantScatter {
private final Block plant;
public UnderwaterPlantFeature(Block plant, int radius) {
super(radius);
this.plant = plant;
}
@Override
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return plant.canPlaceAt(plant.getDefaultState(), world, blockPos);
}
@Override
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
if (plant instanceof BlockDoublePlant) {
int rot = random.nextInt(4);
BlockState state = plant.getDefaultState().with(BlockDoublePlant.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, blockPos, state);
BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(BlockDoublePlant.TOP, true));
}
else {
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
}
}
}