Skip to content

Commit fd97b08

Browse files
committed
Progress
1 parent 4b8ed11 commit fd97b08

File tree

8 files changed

+107
-6
lines changed

8 files changed

+107
-6
lines changed

src/main/java/org/spongepowered/api/event/advancement/AdvancementTreeEvent.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import org.spongepowered.api.advancement.AdvancementTree;
2828
import org.spongepowered.api.event.Event;
29+
import org.spongepowered.api.registry.RegistryHolder;
2930

3031
/**
3132
* A base interface for all the {@link AdvancementTree} events.
@@ -47,5 +48,6 @@ public interface AdvancementTreeEvent extends Event {
4748
*/
4849
interface GenerateLayout extends AdvancementTreeEvent {
4950

51+
RegistryHolder registryHolder();
5052
}
5153
}

src/main/java/org/spongepowered/api/event/lifecycle/RegisterRegistryValueEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ default <T> void registry(RegistryType<T> registryType, Consumer<RegistryStep<T>
4747
<T> void registry(RegistryType<T> registryType, BiConsumer<RegistryHolder, RegistryStep<T>> consumer, final RegistryType<?>... dependencies);
4848

4949
default <T> void register(RegistryRegistrationSet<T> registrationSet) {
50-
this.registry(registrationSet.registryType(), r -> registrationSet.values().forEach(r::register));
50+
this.registry(registrationSet.registryType(), r -> registrationSet.values().forEach((k, v) -> r.register(k, v.get())));
5151
}
5252

5353
interface RegistryStep<T> {

src/main/java/org/spongepowered/api/registry/RegistryRegistrationSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ public interface RegistryRegistrationSet<T> {
3434

3535
RegistryType<T> registryType();
3636

37-
Map<ResourceKey, T> values();
37+
Map<ResourceKey, Supplier<T>> values();
3838

3939
static <T> Builder<T> builder(RegistryType<T> registryType, Supplier<RegistryHolder> defaultHolder) {
4040
return Sponge.game().factoryProvider().provide(Factory.class).builder(registryType, defaultHolder);
4141
}
4242

4343
interface Builder<T> extends org.spongepowered.api.util.Builder<RegistryRegistrationSet<T>, Builder<T>> {
4444

45-
DefaultedRegistryReference<T> register(ResourceKey key, T value);
45+
<V extends T> DefaultedRegistryReference<V> register(ResourceKey key, Supplier<V> value);
4646
}
4747

4848
interface Factory {

src/main/java/org/spongepowered/api/registry/RegistryTypes.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
import org.spongepowered.api.world.generation.structure.jigsaw.ProcessorList;
188188
import org.spongepowered.api.world.generation.structure.jigsaw.ProcessorType;
189189
import org.spongepowered.api.world.schematic.PaletteType;
190+
import org.spongepowered.api.world.server.WorldArchetypeType;
190191
import org.spongepowered.api.world.teleport.TeleportHelperFilter;
191192
import org.spongepowered.api.world.weather.WeatherType;
192193

@@ -520,6 +521,8 @@ public final class RegistryTypes {
520521

521522
// @formatter:on
522523

524+
public static final DefaultedRegistryType<WorldArchetypeType> WORLD_ARCHETYPE_TYPE = RegistryTypes.spongeKeyInGame("wire_attachment_type");
525+
523526
public static final DefaultedRegistryType<Recipe<?>> RECIPE = RegistryTypes.spongeKeyInGame("recipe");
524527

525528
public static final DefaultedRegistryType<Advancement> ADVAN = RegistryTypes.spongeKeyInGame("wire_attachment_type");

src/main/java/org/spongepowered/api/world/WorldType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626

2727
import org.spongepowered.api.data.Key;
2828
import org.spongepowered.api.data.value.Value;
29+
import org.spongepowered.api.datapack.DataPackSerializable;
2930
import org.spongepowered.api.registry.DefaultedRegistryValue;
3031
import org.spongepowered.api.service.context.ContextSource;
3132
import org.spongepowered.api.util.Builder;
3233
import org.spongepowered.api.util.CopyableBuilder;
3334
import org.spongepowered.api.util.annotation.CatalogedBy;
3435

3536
@CatalogedBy(WorldTypes.class)
36-
public interface WorldType extends DefaultedRegistryValue, ContextSource, WorldTypeDataFetcher {
37+
public interface WorldType extends DefaultedRegistryValue, ContextSource, WorldTypeDataFetcher, DataPackSerializable {
3738

3839
interface Builder extends org.spongepowered.api.util.Builder<WorldType, Builder>, CopyableBuilder<WorldType, Builder> {
3940

src/main/java/org/spongepowered/api/world/server/WorldArchetypeType.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,26 @@
2424
*/
2525
package org.spongepowered.api.world.server;
2626

27+
import org.spongepowered.api.Sponge;
28+
import org.spongepowered.api.datapack.DataPackSerializable;
29+
import org.spongepowered.api.registry.DefaultedRegistryValue;
30+
import org.spongepowered.api.util.annotation.CatalogedBy;
2731
import org.spongepowered.api.world.WorldType;
2832
import org.spongepowered.api.world.generation.ChunkGenerator;
2933

30-
public interface WorldArchetypeType {
34+
@CatalogedBy(WorldArchetypeTypes.class)
35+
public interface WorldArchetypeType extends DefaultedRegistryValue, DataPackSerializable {
36+
37+
static WorldArchetypeType.Builder builder() {
38+
return Sponge.game().builderProvider().provide(WorldArchetypeType.Builder.class);
39+
}
40+
41+
static WorldArchetypeType of(WorldType worldType, ChunkGenerator chunkGenerator) {
42+
return WorldArchetypeType.builder()
43+
.worldType(worldType)
44+
.chunkGenerator(chunkGenerator)
45+
.build();
46+
}
3147

3248
WorldType worldType();
3349

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/package org.spongepowered.api.world.server;
25+
26+
import org.spongepowered.api.ResourceKey;
27+
import org.spongepowered.api.Sponge;
28+
import org.spongepowered.api.registry.DefaultedRegistryReference;
29+
import org.spongepowered.api.registry.Registry;
30+
import org.spongepowered.api.registry.RegistryKey;
31+
import org.spongepowered.api.registry.RegistryScope;
32+
import org.spongepowered.api.registry.RegistryScopes;
33+
import org.spongepowered.api.registry.RegistryTypes;
34+
35+
/**
36+
* <!-- This file is automatically generated. Any manual changes will be overwritten. -->
37+
*/
38+
@SuppressWarnings("unused")
39+
@RegistryScopes(
40+
scopes = RegistryScope.ENGINE
41+
)
42+
public final class WorldArchetypeTypes {
43+
private WorldArchetypeTypes() {
44+
}
45+
46+
public static Registry<WorldArchetypeType> registry() {
47+
return Sponge.server().registry(RegistryTypes.WORLD_ARCHETYPE_TYPE);
48+
}
49+
50+
private static DefaultedRegistryReference<WorldArchetypeType> key(final ResourceKey location) {
51+
return RegistryKey.of(RegistryTypes.WORLD_ARCHETYPE_TYPE, location).asDefaultedReference(Sponge::server);
52+
}
53+
}

src/main/java/org/spongepowered/api/world/server/storage/ServerWorldProperties.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
import net.kyori.adventure.text.Component;
3030
import org.checkerframework.checker.nullness.qual.Nullable;
3131
import org.spongepowered.api.ResourceKeyed;
32+
import org.spongepowered.api.Sponge;
3233
import org.spongepowered.api.data.Keys;
3334
import org.spongepowered.api.entity.living.player.gamemode.GameMode;
3435
import org.spongepowered.api.entity.living.trader.WanderingTrader;
36+
import org.spongepowered.api.item.enchantment.Enchantment;
3537
import org.spongepowered.api.util.Identifiable;
3638
import org.spongepowered.api.util.MinecraftDayTime;
3739
import org.spongepowered.api.util.Nameable;
@@ -378,7 +380,31 @@ default Weather weather() {
378380

379381
interface LoadOptions {
380382

381-
FoundOptions foundOptions();
383+
static LoadOptions.Builder builder() {
384+
return Sponge.game().builderProvider().provide(LoadOptions.Builder.class);
385+
}
386+
387+
static LoadOptions load(Consumer<ServerWorldProperties> loadCallback) {
388+
return LoadOptions.builder()
389+
.load()
390+
.loadCallback(loadCallback)
391+
.build();
392+
}
393+
394+
static LoadOptions create(WorldArchetypeType worldArchetype) {
395+
return LoadOptions.builder()
396+
.create(worldArchetype)
397+
.build();
398+
}
399+
400+
static LoadOptions create(WorldArchetypeType worldArchetype, Consumer<ServerWorldProperties> initializeCallback) {
401+
return LoadOptions.builder()
402+
.create(worldArchetype)
403+
.initializeCallback(initializeCallback)
404+
.build();
405+
}
406+
407+
Optional<FoundOptions> foundOptions();
382408

383409
Optional<CreateOptions> createOptions();
384410

0 commit comments

Comments
 (0)