28 lines
918 B
Java
28 lines
918 B
Java
package net.minecraft.world.level.levelgen.placement;
|
|
|
|
import com.mojang.serialization.MapCodec;
|
|
import java.util.function.Supplier;
|
|
import java.util.stream.Stream;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.util.RandomSource;
|
|
|
|
public class InSquarePlacement extends PlacementModifier {
|
|
private static final InSquarePlacement INSTANCE = new InSquarePlacement();
|
|
public static final MapCodec<InSquarePlacement> CODEC = MapCodec.unit((Supplier<InSquarePlacement>)(() -> INSTANCE));
|
|
|
|
public static InSquarePlacement spread() {
|
|
return INSTANCE;
|
|
}
|
|
|
|
@Override
|
|
public Stream<BlockPos> getPositions(PlacementContext context, RandomSource random, BlockPos pos) {
|
|
int i = random.nextInt(16) + pos.getX();
|
|
int j = random.nextInt(16) + pos.getZ();
|
|
return Stream.of(new BlockPos(i, pos.getY(), j));
|
|
}
|
|
|
|
@Override
|
|
public PlacementModifierType<?> type() {
|
|
return PlacementModifierType.IN_SQUARE;
|
|
}
|
|
}
|