Search in sources :

Example 1 with RegistryHolder

use of org.spongepowered.api.registry.RegistryHolder in project SpongeCommon by SpongePowered.

the class VolumeTransformationTest method fillVolume.

private static SpongeArchetypeVolume fillVolume(final Vector3i min, final Vector3i max, final Vector3i origin) {
    final Vector3i rawMin = min.min(max);
    final Vector3i rawMax = max.max(min);
    final Vector3i size = rawMax.sub(rawMin).add(Vector3i.ONE);
    final Vector3i relativeMin = rawMin.sub(origin);
    final RegistryHolder holder = Sponge.game();
    final SpongeArchetypeVolume volume = new SpongeArchetypeVolume(relativeMin, size, holder);
    final StubbedRegistry<BlockType> blockRegistry = (StubbedRegistry<BlockType>) RegistryTypes.BLOCK_TYPE.get();
    final Vector3i volMax = volume.max().add(Vector3i.ONE);
    IntStream.range(relativeMin.x(), volMax.x()).forEach(x -> IntStream.range(relativeMin.z(), volMax.z()).forEach(z -> IntStream.range(relativeMin.y(), volMax.y()).forEach(y -> {
        final BlockType block = blockRegistry.createEntry("minecraft", String.format("volumetest{%d, %d, %d}", x, y, z));
        final BlockState blockState = block.defaultState();
        volume.setBlock(x, y, z, blockState);
    })));
    return volume;
}
Also used : Game(org.spongepowered.api.Game) SpongeBuilderProvider(org.spongepowered.common.registry.SpongeBuilderProvider) Inject(com.google.inject.Inject) StubBlock(org.spongepowered.common.test.stub.block.StubBlock) AbstractReferentArchetypeVolume(org.spongepowered.common.world.volume.buffer.archetype.AbstractReferentArchetypeVolume) Biome(org.spongepowered.api.world.biome.Biome) PaletteReference(org.spongepowered.api.world.schematic.PaletteReference) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) BeforeAll(org.junit.jupiter.api.BeforeAll) Mirror(org.spongepowered.api.util.mirror.Mirror) SpongeFactoryProvider(org.spongepowered.common.registry.SpongeFactoryProvider) PaletteType(org.spongepowered.api.world.schematic.PaletteType) ArchetypeVolume(org.spongepowered.api.world.volume.archetype.ArchetypeVolume) StubMirror(org.spongepowered.common.test.stub.util.StubMirror) StubBlockStatePaletteType(org.spongepowered.common.test.stub.world.schematic.StubBlockStatePaletteType) MethodSource(org.junit.jupiter.params.provider.MethodSource) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) StubPaletteType(org.spongepowered.common.test.stub.world.schematic.StubPaletteType) Sponge(org.spongepowered.api.Sponge) StreamOptions(org.spongepowered.api.world.volume.stream.StreamOptions) Arguments(org.junit.jupiter.params.provider.Arguments) BlockState(org.spongepowered.api.block.BlockState) Transformation(org.spongepowered.api.util.transformation.Transformation) Rotations(org.spongepowered.api.util.rotation.Rotations) Stream(java.util.stream.Stream) StubModule(org.spongepowered.common.test.stub.StubModule) SpongeArchetypeVolume(org.spongepowered.common.world.volume.buffer.archetype.SpongeArchetypeVolume) BlockType(org.spongepowered.api.block.BlockType) StubRegistryHolder(org.spongepowered.common.test.stub.registry.StubRegistryHolder) Strictness(org.mockito.quality.Strictness) IntStream(java.util.stream.IntStream) MockitoSettings(org.mockito.junit.jupiter.MockitoSettings) RegistryHolder(org.spongepowered.api.registry.RegistryHolder) StubbedRegistry(org.spongepowered.common.test.stub.registry.StubbedRegistry) Rotation(org.spongepowered.api.util.rotation.Rotation) SpongeRegistryType(org.spongepowered.common.registry.SpongeRegistryType) StubRotations(org.spongepowered.common.test.stub.util.StubRotations) ResourceKey(org.spongepowered.api.ResourceKey) StubKey(org.spongepowered.common.test.stub.StubKey) RegistryKey(org.spongepowered.api.registry.RegistryKey) VolumePositionTranslators(org.spongepowered.api.world.volume.stream.VolumePositionTranslators) SpongePaletteReferenceFactory(org.spongepowered.common.world.schematic.SpongePaletteReferenceFactory) RegistryType(org.spongepowered.api.registry.RegistryType) RegistryTypes(org.spongepowered.api.registry.RegistryTypes) SpongeRegistryKey(org.spongepowered.common.registry.SpongeRegistryKey) Injector(com.google.inject.Injector) StubRegistryFactory(org.spongepowered.common.test.stub.registry.StubRegistryFactory) Mockito(org.mockito.Mockito) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) StubState(org.spongepowered.common.test.stub.block.StubState) SpongeStreamOptionsBuilder(org.spongepowered.common.world.volume.stream.SpongeStreamOptionsBuilder) Vector3d(org.spongepowered.math.vector.Vector3d) Assertions(org.junit.jupiter.api.Assertions) Guice(com.google.inject.Guice) StubGame(org.spongepowered.common.test.stub.StubGame) Vector3i(org.spongepowered.math.vector.Vector3i) BlockState(org.spongepowered.api.block.BlockState) SpongeArchetypeVolume(org.spongepowered.common.world.volume.buffer.archetype.SpongeArchetypeVolume) BlockType(org.spongepowered.api.block.BlockType) Vector3i(org.spongepowered.math.vector.Vector3i) StubbedRegistry(org.spongepowered.common.test.stub.registry.StubbedRegistry) StubRegistryHolder(org.spongepowered.common.test.stub.registry.StubRegistryHolder) RegistryHolder(org.spongepowered.api.registry.RegistryHolder)

Aggregations

Guice (com.google.inject.Guice)1 Inject (com.google.inject.Inject)1 Injector (com.google.inject.Injector)1 IntStream (java.util.stream.IntStream)1 Stream (java.util.stream.Stream)1 Assertions (org.junit.jupiter.api.Assertions)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 Arguments (org.junit.jupiter.params.provider.Arguments)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 Mockito (org.mockito.Mockito)1 MockitoExtension (org.mockito.junit.jupiter.MockitoExtension)1 MockitoSettings (org.mockito.junit.jupiter.MockitoSettings)1 Strictness (org.mockito.quality.Strictness)1 Game (org.spongepowered.api.Game)1 ResourceKey (org.spongepowered.api.ResourceKey)1 Sponge (org.spongepowered.api.Sponge)1 BlockState (org.spongepowered.api.block.BlockState)1 BlockType (org.spongepowered.api.block.BlockType)1