BlockIgnoreProcessor .java

net.minecraft.world.level.levelgen.structure.templatesystem.BlockIgnoreProcessor (class): members: WEIRD_BLOCK_STATE_CODEC, STRUCTURE_AND_AIR, toIgnore.

net.minecraft.world.level.levelgen.structure.templatesystemclass47 linescommon2.1 KB

Implements

API Surface (1)

MapCodec<BlockIgnoreProcessor> codec()

Fields & Constants (11)

WEIRD_BLOCK_STATE_CODEC
MAP_CODEC
STRUCTURE_BLOCK
AIR
STRUCTURE_AND_AIR
toIgnore
level
targetPosition
referencePos
templateRelativePos
processedBlockInfo

String literals (1)

"blocks"

Full Source

BlockIgnoreProcessor.java47 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.structure.templatesystem;
2
3
import com.google.common.collect.ImmutableList;
4
import com.mojang.serialization.Codec;
5
import com.mojang.serialization.MapCodec;
6
import com.mojang.serialization.codecs.RecordCodecBuilder;
7
import java.util.List;
8
import net.minecraft.core.BlockPos;
9
import net.minecraft.world.level.LevelReader;
10
import net.minecraft.world.level.block.Block;
11
import net.minecraft.world.level.block.Blocks;
12
import net.minecraft.world.level.block.state.BlockBehaviour;
13
import net.minecraft.world.level.block.state.BlockState;
14
import org.jspecify.annotations.Nullable;
15
16
public class BlockIgnoreProcessor implements StructureProcessor {
17
	private static final Codec<Block> WEIRD_BLOCK_STATE_CODEC = BlockState.CODEC.xmap(BlockBehaviour.BlockStateBase::getBlock, Block::defaultBlockState);
18
	public static final MapCodec<BlockIgnoreProcessor> MAP_CODEC = RecordCodecBuilder.mapCodec(
19
		i -> i.group(WEIRD_BLOCK_STATE_CODEC.listOf().fieldOf("blocks").forGetter(o -> o.toIgnore)).apply(i, BlockIgnoreProcessor::new)
20
	);
21
	public static final BlockIgnoreProcessor STRUCTURE_BLOCK = new BlockIgnoreProcessor(ImmutableList.of(Blocks.STRUCTURE_BLOCK));
22
	public static final BlockIgnoreProcessor AIR = new BlockIgnoreProcessor(ImmutableList.of(Blocks.AIR));
23
	public static final BlockIgnoreProcessor STRUCTURE_AND_AIR = new BlockIgnoreProcessor(ImmutableList.of(Blocks.AIR, Blocks.STRUCTURE_BLOCK));
24
	private final ImmutableList<Block> toIgnore;
25
26
	public BlockIgnoreProcessor(final List<Block> toIgnore) {
27
		this.toIgnore = ImmutableList.copyOf(toIgnore);
28
	}
29
30
	@Override
31
	public StructureTemplate.@Nullable StructureBlockInfo processBlock(
32
		final LevelReader level,
33
		final BlockPos targetPosition,
34
		final BlockPos referencePos,
35
		final BlockPos templateRelativePos,
36
		final StructureTemplate.StructureBlockInfo processedBlockInfo,
37
		final StructurePlaceSettings settings
38
	) {
39
		return this.toIgnore.contains(processedBlockInfo.state().getBlock()) ? null : processedBlockInfo;
40
	}
41
42
	@Override
43
	public MapCodec<BlockIgnoreProcessor> codec() {
44
		return MAP_CODEC;
45
	}
46
}
47

Decompiled Minecraft 26.3 source of BlockIgnoreProcessor (net/minecraft/world/level/levelgen/structure/templatesystem/BlockIgnoreProcessor.java) with Mojang official mappings, stored verbatim on the site.