use of org.spongepowered.common.test.stub.registry.StubbedRegistry in project SpongeCommon by SpongePowered.
the class VolumeTransformationTest method setup.
@BeforeAll
static void setup() {
VolumeTransformationTest.guice.injectMembers(new DummyInjectable());
final StubGame game = (StubGame) Sponge.game();
final SpongeFactoryProvider factoryProvider = game.factoryProvider();
final SpongeBuilderProvider builderProvider = game.builderProvider();
// Set up Rotations
final StubbedRegistry<Rotation> rotation = new StubbedRegistry<>(() -> RegistryTypes.ROTATION, (k) -> Rotations.NONE.get());
// Set up Blocks and BlockState
final StubbedRegistry<BlockType> blocktypes = new StubbedRegistry<>(() -> RegistryTypes.BLOCK_TYPE, StubBlock::new);
// Set up biomes
final StubbedRegistry<Biome> biomes = new StubbedRegistry<>(() -> RegistryTypes.BIOME, (key) -> Mockito.mock(Biome.class));
// Set up palettes
final StubbedRegistry<PaletteType<?, ?>> paletteTypeRegistry = new StubbedRegistry<>(() -> RegistryTypes.PALETTE_TYPE, (key) -> new StubPaletteType<>());
factoryProvider.registerFactory(RegistryType.Factory.class, new SpongeRegistryType.FactoryImpl());
factoryProvider.registerFactory(RegistryKey.Factory.class, new SpongeRegistryKey.FactoryImpl());
factoryProvider.registerFactory(PaletteReference.Factory.class, new SpongePaletteReferenceFactory());
// and finally, set up the resourcekey stuff
factoryProvider.registerFactory(ResourceKey.Factory.class, new StubRegistryFactory());
game.register(rotation);
game.register(blocktypes);
game.register(biomes);
game.register(paletteTypeRegistry);
final StubbedRegistry<Mirror> mirror = new StubbedRegistry<>(() -> RegistryTypes.MIRROR, (k) -> Mockito.mock(Mirror.class));
StubMirror.registerDefaults(mirror);
game.register(mirror);
builderProvider.register(Transformation.Builder.class, SpongeTransformationBuilder::new);
builderProvider.register(StreamOptions.Builder.class, SpongeStreamOptionsBuilder::new);
StubRotations.registerDefaults(rotation);
paletteTypeRegistry.register(new StubKey("sponge", "block_state_palette"), new StubBlockStatePaletteType());
}
use of org.spongepowered.common.test.stub.registry.StubbedRegistry 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;
}
Aggregations