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

The following examples show how to use net.minecraft.world.gen.feature.StructureFeature. 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: FeatureGenerator.java    From fabric-carpet with MIT License 6 votes vote down vote up
public static StructureStart shouldStructureStartAt(ServerWorld world, BlockPos pos, StructureFeature<?> structure, boolean computeBox)
{
    ChunkGenerator<?> generator = world.getChunkManager().getChunkGenerator();
    if (!generator.getBiomeSource().hasStructureFeature(structure))
        return null;
    BiomeAccess biomeAccess = world.getBiomeAccess().withSource(generator.getBiomeSource());
    ChunkRandom chunkRandom = new ChunkRandom();
    ChunkPos chunkPos = new ChunkPos(pos);
    Biome biome = biomeAccess.getBiome(new BlockPos(chunkPos.getStartX() + 9, 0, chunkPos.getStartZ() + 9));
    if (structure.shouldStartAt(biomeAccess, generator, chunkRandom, chunkPos.x, chunkPos.z, biome))
    {
        if (!computeBox) return StructureStart.DEFAULT;
        StructureManager manager = world.getSaveHandler().getStructureManager();
        StructureStart structureStart3 = structure.getStructureStartFactory().create(structure, chunkPos.x, chunkPos.z, BlockBox.empty(), 0, generator.getSeed());
        structureStart3.initialize(generator, manager, chunkPos.x, chunkPos.z, biome);
        if (!structureStart3.hasChildren()) return null;
        return structureStart3;
    }
    return null;
}
 
Example #2
Source File: MoonChunkGenerator.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
public List<Biome.SpawnEntry> getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos) {
    if (group == SpawnGroup.MONSTER) {
        if (accessor.method_28388(pos, false, StructureFeature.PILLAGER_OUTPOST).hasChildren()) {
            return StructureFeature.PILLAGER_OUTPOST.getMonsterSpawns();
        }
    }

    return super.getEntitySpawnList(biome, accessor, group, pos);
}
 
Example #3
Source File: FeatureGenerator.java    From fabric-carpet with MIT License 5 votes vote down vote up
private static Thing setupCustomStructure(StructureFeature structure, FeatureConfig conf, Biome biome, boolean wireOnly)
    {
    //if (1+2==3)
    //    throw new RuntimeException("rebuild me");
    return (w, p) -> {
        ChunkGenerator chunkgen = new OverworldChunkGenerator(w, w.getChunkManager().getChunkGenerator().getBiomeSource(), new OverworldChunkGeneratorConfig()) //  BiomeSourceType.VANILLA_LAYERED.applyConfig((BiomeSourceType.VANILLA_LAYERED.getConfig())), ChunkGeneratorType.SURFACE.createSettings())
        {
            @Override
            public <C extends FeatureConfig> C getStructureConfig(Biome biome_1, StructureFeature<C> structureFeature_1)
            {
                return (C)conf;
            }

            @Override
            public BiomeSource getBiomeSource()
            {
                return new VanillaLayeredBiomeSource(new VanillaLayeredBiomeSourceConfig(w.getLevelProperties()))
                {
                    @Override
                    public Biome getBiomeForNoiseGen(int i, int j, int k)
                    {
                        return biome;
                    }

                    @Override
                    public Set<Biome> getBiomesInArea(int int_1, int int_2, int int_3, int int_4)
                    {
                        return Sets.newHashSet(biome);
                    }
                };
            }
        };


        return ((StructureFeatureInterface)structure).plopAnywhere(w, p, chunkgen, wireOnly);
    };
}
 
Example #4
Source File: ChunkGeneratorMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "hasStructure", at = @At("HEAD"), cancellable = true)
private void skipGenerationBiomeChecks(Biome biome_1, StructureFeature<? extends FeatureConfig> structureFeature_1, CallbackInfoReturnable<Boolean> cir)
{
    if (CarpetSettings.skipGenerationChecks)
    {
        cir.setReturnValue(true);
        cir.cancel();
    }
}
 
Example #5
Source File: StructureFeatureMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
private StructureStart forceStructureStart(IWorld worldIn, ChunkGenerator <? extends ChunkGeneratorConfig > generator, Random rand, long packedChunkPos)
{
    ChunkPos chunkpos = new ChunkPos(packedChunkPos);
    StructureStart structurestart;

    Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS, false);

    if (ichunk != null)
    {
        structurestart = ichunk.getStructureStart(this.getName());

        if (structurestart != null && structurestart != StructureStart.DEFAULT)
        {
            return structurestart;
        }
    }
    Biome biome_1 = generator.getBiomeSource().getBiomeForNoiseGen((chunkpos.getStartX() + 9) >> 2, 0, (chunkpos.getStartZ() + 9) >> 2 );
    StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, BlockBox.empty(),0,generator.getSeed());
    structurestart1.initialize(generator, ((ServerWorld)worldIn).getStructureManager() , chunkpos.x, chunkpos.z, biome_1);
    structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT;

    if (structurestart.hasChildren())
    {
        worldIn.getChunk(chunkpos.x, chunkpos.z).setStructureStart(this.getName(), structurestart);
    }

    //long2objectmap.put(packedChunkPos, structurestart);
    return structurestart;
}
 
Example #6
Source File: MoonVillageStart.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
public MoonVillageStart(StructureFeature<StructurePoolFeatureConfig> structureFeature, int chunkX, int chunkZ, BlockBox blockBox, int i, long l) {
    super(structureFeature, chunkX, chunkZ, blockBox, i, l);
}
 
Example #7
Source File: MoonVillageFeature.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Override
public StructureFeature.StructureStartFactory<StructurePoolFeatureConfig> getStructureStartFactory() {
    return MoonVillageStart::new;
}
 
Example #8
Source File: FeatureGenerator.java    From fabric-carpet with MIT License 4 votes vote down vote up
private static Thing spawnCustomStructure(StructureFeature structure, FeatureConfig conf, Biome biome)
{
    return setupCustomStructure(structure, conf, biome, false);
}
 
Example #9
Source File: FeatureGenerator.java    From fabric-carpet with MIT License 4 votes vote down vote up
private static Thing gridCustomStructure(StructureFeature structure, FeatureConfig conf, Biome biome)
{
    return setupCustomStructure(structure, conf, biome, true);
}
 
Example #10
Source File: StructureFeatureMixin.java    From fabric-carpet with MIT License votes vote down vote up
@Shadow public abstract StructureFeature.StructureStartFactory getStructureStartFactory();