use of net.minecraft.world.level.block.GrassBlock in project EdenRing by paulevsGitch.
the class BalloonMushroomTreeFeature method place.
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featurePlaceContext) {
WorldGenLevel level = featurePlaceContext.level();
BlockPos center = featurePlaceContext.origin();
Random random = featurePlaceContext.random();
Block below = level.getBlockState(center.below()).getBlock();
if (!(below instanceof GrassBlock) && below != Blocks.DIRT) {
return false;
}
MutableBlockPos pos = center.mutable();
int h = MHelper.randRange(5, 9, random);
for (int i = 1; i <= h; i++) {
pos.setY(center.getY() + i);
if (!level.getBlockState(pos).isAir()) {
h = i - 1;
}
}
if (h < 5) {
h = random.nextInt(4);
pos.setY(center.getY());
BlockState tall = EdenBlocks.TALL_BALLOON_MUSHROOM.defaultBlockState();
for (byte i = 0; i <= h; i++) {
BlockState state = tall.setValue(EdenBlockProperties.TEXTURE_4, (int) i);
if (i == h)
state = state.setValue(EdenBlockProperties.TEXTURE_4, 3);
if (level.getBlockState(pos.above()).isAir()) {
BlocksHelper.setWithoutUpdate(level, pos, state);
pos.setY(pos.getY() + 1);
} else {
state = state.setValue(EdenBlockProperties.TEXTURE_4, 3);
BlocksHelper.setWithoutUpdate(level, pos, state);
return true;
}
}
return true;
}
BlockState stem = EdenBlocks.BALLOON_MUSHROOM_STEM.defaultBlockState();
if (h > 5 && random.nextInt(6) == 0) {
for (int i = 0; i < h; i++) {
pos.setY(center.getY() + i);
BlocksHelper.setWithoutUpdate(level, pos, stem);
}
BlockState head = EdenBlocks.BALLOON_MUSHROOM_BLOCK.defaultBlockState();
BlockState fur = stem.setValue(EdenBlockProperties.BALLOON_MUSHROOM_STEM, BalloonMushroomStemState.FUR);
for (int x = -1; x < 2; x++) {
pos.setX(center.getX() + x);
for (int z = -1; z < 2; z++) {
pos.setZ(center.getZ() + z);
pos.setY(center.getY() + h - 1);
if (level.getBlockState(pos).isAir()) {
BlocksHelper.setWithoutUpdate(level, pos, fur);
}
for (int y = 0; y < 3; y++) {
pos.setY(center.getY() + h + y);
if (level.getBlockState(pos).isAir()) {
BlocksHelper.setWithoutUpdate(level, pos, head);
}
}
}
}
} else {
BlockState thin = stem.setValue(EdenBlockProperties.BALLOON_MUSHROOM_STEM, BalloonMushroomStemState.THIN);
BlockState thin_up = stem.setValue(EdenBlockProperties.BALLOON_MUSHROOM_STEM, BalloonMushroomStemState.THIN_TOP);
int hMax = h - 1;
for (int i = 0; i < h; i++) {
pos.setY(center.getY() + i);
BlocksHelper.setWithoutUpdate(level, pos, i == hMax ? thin_up : thin);
}
pos.setY(center.getY() + h);
BlocksHelper.setWithoutUpdate(level, pos, EdenBlocks.BALLOON_MUSHROOM_BLOCK);
}
return true;
}
use of net.minecraft.world.level.block.GrassBlock in project EdenRing by paulevsGitch.
the class EdenBlocks method init.
public static void init() {
BlockRegistry.getModBlocks(EdenRing.MOD_ID).forEach(block -> {
Properties properties = ((AbstractBlockAccessor) block).getSettings();
Material material = ((AbstractBlockSettingsAccessor) properties).getMaterial();
if (block instanceof BaseLeavesBlock) {
TagAPI.addBlockTag(NamedMineableTags.HOE, block);
TagAPI.addBlockTag(NamedBlockTags.LEAVES, block);
TagAPI.addItemTag(NamedItemTags.LEAVES, block);
ComposterAPI.allowCompost(0.3F, block);
} else if (block instanceof GrassBlock) {
TagAPI.addBlockTag(NamedMineableTags.SHOVEL, block);
ShovelAPI.addShovelBehaviour(block, Blocks.DIRT_PATH.defaultBlockState());
TillableBlockRegistry.register(block, HoeItem::onlyIfAirAbove, Blocks.FARMLAND.defaultBlockState());
} else if (material == Material.PLANT || material == Material.REPLACEABLE_PLANT) {
TagAPI.addBlockTag(NamedMineableTags.HOE, block);
if (block.asItem() != Items.AIR) {
ComposterAPI.allowCompost(0.1F, block);
}
} else if (material == Material.STONE || material == Material.METAL || material == Material.HEAVY_METAL || material == Material.AMETHYST) {
TagAPI.addBlockTag(NamedMineableTags.PICKAXE, block);
}
if (block instanceof BaseVineBlock) {
TagAPI.addBlockTag(NamedBlockTags.CLIMBABLE, block);
}
});
BonemealAPI.addLandGrass(MYCOTIC_GRASS, EDEN_MYCELIUM);
BonemealAPI.addLandGrass(EdenBiomes.GOLDEN_FOREST.getID(), GOLDEN_GRASS, EDEN_GRASS_BLOCK);
BonemealAPI.addLandGrass(EdenBiomes.GOLDEN_FOREST.getID(), Blocks.GRASS, EDEN_GRASS_BLOCK);
BonemealAPI.addSpreadableBlock(MOSSY_STONE, Blocks.STONE);
}
Aggregations