-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework GameRegistry system to be more registry-like
Signed-off-by: TheSilkMiner <thesilkminer@outlook.com>
- Loading branch information
1 parent
0c3b08f
commit c2ce273
Showing
15 changed files
with
269 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Common/src/main/java/com/blamejared/contenttweaker/core/api/registry/GameRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.blamejared.contenttweaker.core.api.registry; | ||
|
||
import com.blamejared.contenttweaker.core.api.ContentTweakerApi; | ||
import com.blamejared.contenttweaker.core.api.object.ObjectHolder; | ||
import com.blamejared.contenttweaker.core.api.object.ObjectType; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.Collection; | ||
import java.util.function.Supplier; | ||
import java.util.stream.Stream; | ||
|
||
public interface GameRegistry<T> { | ||
static <T> GameRegistry<T> findFromKey(final ObjectType<T> type, final ResourceKey<? extends Registry<T>> key) { | ||
return ContentTweakerApi.get().findRegistryFromKey(type, key); | ||
} | ||
|
||
ObjectType<T> type(); | ||
T get(final ResourceLocation name); | ||
ResourceLocation nameOf(final T object); | ||
Collection<T> all(); | ||
void enqueueRegistration(final ResourceLocation name, final Supplier<T> objectCreator); | ||
|
||
default void enqueueRegistration(final ObjectHolder<T> holder) { | ||
this.enqueueRegistration(holder.id(), holder); | ||
} | ||
|
||
default Stream<T> stream() { | ||
return this.all().stream(); | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
Common/src/main/java/com/blamejared/contenttweaker/core/registry/GameRegistry.java
This file was deleted.
Oops, something went wrong.
30 changes: 8 additions & 22 deletions
30
Common/src/main/java/com/blamejared/contenttweaker/core/registry/Winston.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
Common/src/main/java/com/blamejared/contenttweaker/core/service/PlatformService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
package com.blamejared.contenttweaker.core.service; | ||
|
||
import com.blamejared.contenttweaker.core.api.object.ObjectType; | ||
import com.blamejared.contenttweaker.core.api.registry.GameRegistry; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.resources.ResourceKey; | ||
|
||
import java.nio.file.Path; | ||
|
||
public interface PlatformService { | ||
Path gameDirectory(); | ||
Path locateResource(final String... components); | ||
<T> GameRegistry<T> findRegistryFromKey(final ObjectType<T> type, final ResourceKey<? extends Registry<T>> key); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Forge/src/main/java/com/blamejared/contenttweaker/forge/registry/BulletGameRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.blamejared.contenttweaker.forge.registry; | ||
|
||
import com.blamejared.contenttweaker.core.api.registry.GameRegistry; | ||
import net.minecraft.Util; | ||
|
||
import java.util.List; | ||
|
||
public interface BulletGameRegistry<T> extends GameRegistry<T> { | ||
List<Runnable> commands(); | ||
|
||
default void doRegistration() { | ||
Util.make(this.commands(), commands -> { | ||
commands.forEach(Runnable::run); | ||
commands.clear(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.