Tags, surface builders, biome API (WIP), processors, features

This commit is contained in:
paulevsGitch 2021-05-23 08:32:45 +03:00
parent 6b0bf593ad
commit 979e2ab92a
15 changed files with 1513 additions and 51 deletions

View file

@ -0,0 +1,31 @@
package ru.bclib.world.processors;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
public class DestructionStructureProcessor extends StructureProcessor {
private int chance = 4;
public void setChance(int chance) {
this.chance = chance;
}
@Override
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlacementData) {
if (!BlocksHelper.isInvulnerable(structureBlockInfo2.state, worldView, structureBlockInfo2.pos) && MHelper.RANDOM.nextInt(chance) == 0) {
return null;
}
return structureBlockInfo2;
}
@Override
protected StructureProcessorType<?> getType() {
return StructureProcessorType.RULE;
}
}

View file

@ -0,0 +1,27 @@
package ru.bclib.world.processors;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
public class TerrainStructureProcessor extends StructureProcessor {
@Override
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlacementData) {
BlockPos bpos = structureBlockInfo2.pos;
if (structureBlockInfo2.state.is(Blocks.END_STONE) && worldView.isEmptyBlock(bpos.above())) {
BlockState top = worldView.getBiome(structureBlockInfo2.pos).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
return new StructureBlockInfo(bpos, top, structureBlockInfo2.nbt);
}
return structureBlockInfo2;
}
@Override
protected StructureProcessorType<?> getType() {
return StructureProcessorType.RULE;
}
}