net.minecraft.world.gen.feature.DefaultFeatureConfig Java Examples

The following examples show how to use net.minecraft.world.gen.feature.DefaultFeatureConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpiderLairFeature.java    From the-hallow with MIT License 6 votes vote down vote up
@Override
public boolean generate(IWorld iWorld, ChunkGenerator<? extends ChunkGeneratorConfig> chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig defaultFeatureConfig) {
	if (iWorld.getBlockState(pos.down()).getBlock() == HallowedBlocks.DECEASED_GRASS_BLOCK) {
		setSpawner(iWorld, pos, EntityType.SPIDER);
		
		for (int i = 0; i < 64; ++i) {
			BlockPos pos_2 = pos.add(random.nextInt(6) - random.nextInt(6), random.nextInt(3) - random.nextInt(3), random.nextInt(6) - random.nextInt(6));
			if (iWorld.isAir(pos_2) || iWorld.getBlockState(pos_2).getBlock() == HallowedBlocks.DECEASED_GRASS_BLOCK) {
				iWorld.setBlockState(pos_2, Blocks.COBWEB.getDefaultState(), 2);
			}
		}
		
		BlockPos chestPos = pos.add(random.nextInt(4) - random.nextInt(4), 0, random.nextInt(4) - random.nextInt(4));
		iWorld.setBlockState(chestPos, StructurePiece.method_14916(iWorld, chestPos, Blocks.CHEST.getDefaultState()), 2);
		LootableContainerBlockEntity.setLootTable(iWorld, random, chestPos, TheHallow.id("chests/spider_lair"));
		
		return true;
	} else {
		return false;
	}
}
 
Example #2
Source File: HallowedCactusFeature.java    From the-hallow with MIT License 6 votes vote down vote up
@Override
public boolean generate(IWorld world, ChunkGenerator<? extends ChunkGeneratorConfig> generator, Random random, BlockPos pos, DefaultFeatureConfig config) {
	for (int i = 0; i < 10; i++) {
		BlockPos pos2 = pos.add(random.nextInt(8) - random.nextInt(8), random.nextInt(4) - random.nextInt(4), random.nextInt(8) - random.nextInt(8));
		if (world.isAir(pos2)) {
			int height = 1 + random.nextInt(random.nextInt(3) + 1);
			
			for (int j = 0; j < height; j++) {
				if (HallowedBlocks.RESTLESS_CACTUS.getDefaultState().canPlaceAt(world, pos2)) {
					world.setBlockState(pos2.up(j), HallowedBlocks.RESTLESS_CACTUS.getDefaultState(), 2);
				}
			}
		}
	}
	
	return true;
}
 
Example #3
Source File: RandomizedWildCropFeature.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public boolean generate(IWorld world, ChunkGenerator<? extends ChunkGeneratorConfig> chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig defaultFeatureConfig) {
	int numCrop = 0;

	for (int i = 0; i < 64; ++i) {
		BlockPos randomBlockPos = blockPos.add(random.nextInt(8) - random.nextInt(8), random.nextInt(4) - random.nextInt(4), random.nextInt(8) - random.nextInt(8));
		if (world.isAir(randomBlockPos) && world.getBlockState(randomBlockPos.down()).getBlock() == HallowedBlocks.DECEASED_GRASS_BLOCK) {
			world.setBlockState(randomBlockPos, this.choiceSelector.getSelection(random, randomBlockPos), 2);
			++numCrop;
		}
	}

	return numCrop > 0;
}
 
Example #4
Source File: CoralBlockMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
public void grow(ServerWorld worldIn, Random random, BlockPos pos, BlockState blockUnder)
{

    CoralFeature coral;
    int variant = random.nextInt(3);
    if (variant == 0)
        coral = new CoralClawFeature(DefaultFeatureConfig::deserialize);
    else if (variant == 1)
        coral = new CoralTreeFeature(DefaultFeatureConfig::deserialize);
    else
        coral = new CoralMushroomFeature(DefaultFeatureConfig::deserialize);

    MaterialColor color = blockUnder.getTopMaterialColor(worldIn, pos);
    BlockState proper_block = blockUnder;
    for (Block block: BlockTags.CORAL_BLOCKS.values())
    {
        proper_block = block.getDefaultState();
        if (proper_block.getTopMaterialColor(worldIn,pos) == color)
        {
            break;
        }
    }
    worldIn.setBlockState(pos, Blocks.WATER.getDefaultState(), 4);

    if (!((CoralFeatureInterface)coral).growSpecific(worldIn, random, pos, proper_block))
    {
        worldIn.setBlockState(pos, blockUnder, 3);
    }
    else
    {
        if (worldIn.random.nextInt(10)==0)
        {
            BlockPos randomPos = pos.add(worldIn.random.nextInt(16)-8,worldIn.random.nextInt(8),worldIn.random.nextInt(16)-8  );
            if (BlockTags.CORAL_BLOCKS.contains(worldIn.getBlockState(randomPos).getBlock()))
            {
                worldIn.setBlockState(randomPos, Blocks.WET_SPONGE.getDefaultState(), 3);
            }
        }
    }
}
 
Example #5
Source File: WitchWellFeature.java    From the-hallow with MIT License 5 votes vote down vote up
public WitchWellFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> configDeserializer) {
	super(configDeserializer);
	this.slab = HallowedBlocks.TAINTED_SANDSTONE_SLAB.getDefaultState();
	this.wall = HallowedBlocks.TAINTED_SANDSTONE.getDefaultState();
	this.fluid = HallowedBlocks.WITCH_WATER_BLOCK.getDefaultState();
	this.lantern = Blocks.LANTERN.getDefaultState().with(LanternBlock.HANGING, true);
}
 
Example #6
Source File: DeceasedWildCropFeature.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public boolean generate(IWorld world, ChunkGenerator<? extends ChunkGeneratorConfig> chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig defaultFeatureConfig) {
	int numCrop = 0;
	
	for (int i = 0; i < 64; ++i) {
		BlockPos randomBlockPos = blockPos.add(random.nextInt(8) - random.nextInt(8), random.nextInt(4) - random.nextInt(4), random.nextInt(8) - random.nextInt(8));
		if (world.isAir(randomBlockPos) && world.getBlockState(randomBlockPos.down()).getBlock() == HallowedBlocks.DECEASED_GRASS_BLOCK) {
			world.setBlockState(randomBlockPos, this.crop, 2);
			++numCrop;
		}
	}
	
	return numCrop > 0;
}
 
Example #7
Source File: DeaderBushFeature.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public boolean generate(IWorld world, ChunkGenerator<? extends ChunkGeneratorConfig> generator, Random random, BlockPos pos, DefaultFeatureConfig config) {
	for (BlockState state1 = world.getBlockState(pos); (state1.isAir() || state1.matches(BlockTags.LEAVES)) && pos.getY() > 0; state1 = world.getBlockState(pos)) {
		pos = pos.down();
	}
	
	for (int int_1 = 0; int_1 < 4; ++int_1) {
		BlockPos pos2 = pos.add(random.nextInt(8) - random.nextInt(8), random.nextInt(4) - random.nextInt(4), random.nextInt(8) - random.nextInt(8));
		if (world.isAir(pos2) && state.canPlaceAt(world, pos2)) {
			world.setBlockState(pos2, state, 2);
		}
	}
	
	return true;
}
 
Example #8
Source File: StoneCircleFeature.java    From the-hallow with MIT License 4 votes vote down vote up
public StoneCircleFeature() {
	super(DefaultFeatureConfig::deserialize);
}
 
Example #9
Source File: StoneCircleFeature.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public boolean generate(IWorld world, ChunkGenerator<? extends ChunkGeneratorConfig> chunkGenerator, Random rand, BlockPos pos, DefaultFeatureConfig config) {
	return this.generate(world, rand, pos);
}
 
Example #10
Source File: DeceasedWildCropFeature.java    From the-hallow with MIT License 4 votes vote down vote up
public DeceasedWildCropFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> featureConfig, BlockState blockState) {
	super(featureConfig);
	this.crop = blockState;
}
 
Example #11
Source File: RandomizedWildCropFeature.java    From the-hallow with MIT License 4 votes vote down vote up
public RandomizedWildCropFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> featureConfig, RandomBlockSelector choiceSelector) {
	super(featureConfig);
	this.choiceSelector = choiceSelector;
}
 
Example #12
Source File: SpiderLairFeature.java    From the-hallow with MIT License 4 votes vote down vote up
public SpiderLairFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> function) {
	super(function);
}
 
Example #13
Source File: DeaderBushFeature.java    From the-hallow with MIT License 4 votes vote down vote up
public DeaderBushFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> function_1, BlockState state) {
	super(function_1);
	this.state = state;
}
 
Example #14
Source File: WitchWellFeature.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public boolean generate(IWorld world, ChunkGenerator<? extends ChunkGeneratorConfig> gen, Random random, BlockPos pos, DefaultFeatureConfig config) {
	pos = pos.up();
	while (world.isAir(pos) && pos.getY() > 2) {
		pos = pos.down();
	}
	
	if (!CAN_GENERATE.test(world.getBlockState(pos))) {
		return false;
	}
	
	// Check for solid ground
	for (int x = -2; x <= 2; ++x) {
		for (int z = -2; z <= 2; ++z) {
			if (world.isAir(pos.add(x, -1, z)) && world.isAir(pos.add(x, -2, z))) {
				return false;
			}
		}
	}
	
	//System.out.println("Generating at " + pos);
	
	// Below-ground layer
	for (int y = -1; y <= 0; ++y) {
		for (int x = -2; x <= 2; ++x) {
			for (int z = -2; z <= 2; ++z) {
				world.setBlockState(pos.add(x, y, z), this.wall, 2);
			}
		}
	}
	
	// Fluid
	world.setBlockState(pos, this.fluid, 2);
	for (Direction direction : Direction.Type.HORIZONTAL) {
		world.setBlockState(pos.offset(direction), this.fluid, 2);
	}
	
	// Above-ground layer
	for (int x = -2; x <= 2; ++x) {
		for (int z = -2; z <= 2; ++z) {
			if (x == -2 || x == 2 || z == -2 || z == 2) {
				world.setBlockState(pos.add(x, 1, z), this.wall, 2);
			}
		}
	}
	
	// Slabs in the above-ground layer
	world.setBlockState(pos.add(2, 1, 0), this.slab, 2);
	world.setBlockState(pos.add(-2, 1, 0), this.slab, 2);
	world.setBlockState(pos.add(0, 1, 2), this.slab, 2);
	world.setBlockState(pos.add(0, 1, -2), this.slab, 2);
	
	// Witched pumpkin
	int pumpkinX = random.nextBoolean() ? -2 : 2;
	int pumpkinZ = random.nextBoolean() ? -2 : 2;
	Direction pumpkinFacing = Direction.fromHorizontal(random.nextInt(4));
	world.setBlockState(pos.add(pumpkinX, 2, pumpkinZ), getPumpkin(pumpkinFacing), 2);
	world.setBlockState(pos.add(0, 3, 0), this.lantern, 2);
	
	// Roof
	for (int x = -1; x <= 1; ++x) {
		for (int z = -1; z <= 1; ++z) {
			if (x == 0 && z == 0) {
				world.setBlockState(pos.add(x, 4, z), this.wall, 2);
			} else {
				world.setBlockState(pos.add(x, 4, z), this.slab, 2);
			}
		}
	}
	
	// Pillars
	for (int y = 1; y <= 3; ++y) {
		world.setBlockState(pos.add(-1, y, -1), this.wall, 2);
		world.setBlockState(pos.add(-1, y, 1), this.wall, 2);
		world.setBlockState(pos.add(1, y, -1), this.wall, 2);
		world.setBlockState(pos.add(1, y, 1), this.wall, 2);
	}
	
	return true;
}
 
Example #15
Source File: BarrowFeature.java    From the-hallow with MIT License 4 votes vote down vote up
public BarrowFeature() {
	super(DefaultFeatureConfig::deserialize);
}
 
Example #16
Source File: BarrowFeature.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public boolean generate(IWorld world, ChunkGenerator<? extends ChunkGeneratorConfig> chunkGenerator, Random rand, BlockPos pos, DefaultFeatureConfig config) {
	//final BiomeSource source = chunkGenerator.getBiomeSource();
	
	return this.generate(world, rand, pos, (blockpos) -> world.getBiome(blockpos).getSurfaceConfig());
}
 
Example #17
Source File: JungleTempleFeature_creeperMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 4 votes vote down vote up
public JungleTempleFeature_creeperMixin(Function<Dynamic<?>, ? extends DefaultFeatureConfig> configFactory)
{
    super(configFactory);
}
 
Example #18
Source File: IglooFeatureMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 4 votes vote down vote up
public IglooFeatureMixin(Function<Dynamic<?>, ? extends DefaultFeatureConfig> configFactory)
{
    super(configFactory);
}
 
Example #19
Source File: FeatureGenerator.java    From fabric-carpet with MIT License 4 votes vote down vote up
private static Thing simplePlop(Feature<DefaultFeatureConfig> feature)
{
    return simplePlop(feature.configure(FeatureConfig.DEFAULT));
}
 
Example #20
Source File: HallowedCactusFeature.java    From the-hallow with MIT License 4 votes vote down vote up
public HallowedCactusFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> function) {
	super(function);
}
 
Example #21
Source File: EndCityFeatureMixin.java    From fabric-carpet with MIT License 4 votes vote down vote up
public EndCityFeatureMixin(Function<Dynamic<?>, ? extends DefaultFeatureConfig> function_1)
{
    super(function_1);
}
 
Example #22
Source File: DesertPyramidFeatureMixin.java    From fabric-carpet with MIT License 4 votes vote down vote up
public DesertPyramidFeatureMixin(Function<Dynamic<?>, ? extends DefaultFeatureConfig> function_1)
{
    super(function_1);
}