Skip to content

Commit

Permalink
重命名 registrar 为 registrator
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Aug 31, 2024
1 parent 0a1840d commit 5c21fe3
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package dev.anvilcraft.lib.registrar;
package dev.anvilcraft.lib.registrator;

import dev.anvilcraft.lib.data.DataProviderType;
import dev.anvilcraft.lib.registrar.builder.EntryBuilder;
import dev.anvilcraft.lib.registrar.builder.ItemBuilder;
import dev.anvilcraft.lib.registrar.builder.BlockBuilder;
import dev.anvilcraft.lib.registrar.entry.TagKeyEntry;
import dev.anvilcraft.lib.registrator.builder.EntryBuilder;
import dev.anvilcraft.lib.registrator.builder.ItemBuilder;
import dev.anvilcraft.lib.registrator.builder.BlockBuilder;
import dev.anvilcraft.lib.registrator.entry.TagKeyEntry;
import net.minecraft.core.Registry;
import net.minecraft.data.DataProvider;
import net.minecraft.resources.ResourceKey;
Expand All @@ -22,12 +22,12 @@
import java.util.function.Function;

@SuppressWarnings("unused")
public abstract class AbstractRegistrar {
public abstract class AbstractRegistrator {
protected final BuilderManager manager = new BuilderManager();
protected final Map<DataProviderType<?>, Consumer<DataProvider>> dataProviders = Collections.synchronizedMap(new HashMap<>());
private final String modid;

protected AbstractRegistrar(String modid) {
protected AbstractRegistrator(String modid) {
this.modid = modid;
}

Expand Down Expand Up @@ -66,13 +66,13 @@ public void init() {
}

@SuppressWarnings("UnusedReturnValue")
public <T extends DataProvider> AbstractRegistrar initDatagen(DataProviderType<T> type, Consumer<DataProvider> consumer) {
public <T extends DataProvider> AbstractRegistrator initDatagen(DataProviderType<T> type, Consumer<DataProvider> consumer) {
this.dataProviders.put(type, consumer);
return this;
}

@SuppressWarnings("UnusedReturnValue")
public <T> AbstractRegistrar addBuilder(Registry<T> registry, EntryBuilder<? extends T> builder) {
public <T> AbstractRegistrator addBuilder(Registry<T> registry, EntryBuilder<? extends T> builder) {
this.manager.addBuilder(registry, builder);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.anvilcraft.lib.registrar;
package dev.anvilcraft.lib.registrator;

import dev.anvilcraft.lib.registrar.builder.EntryBuilder;
import dev.anvilcraft.lib.registrator.builder.EntryBuilder;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package dev.anvilcraft.lib.registrar;
package dev.anvilcraft.lib.registrator;

import dev.architectury.injectables.annotations.ExpectPlatform;
import org.jetbrains.annotations.NotNull;

@SuppressWarnings("unused")
public abstract class Registrar extends AbstractRegistrar {
protected Registrar(String modid) {
public abstract class Registrator extends AbstractRegistrator {
protected Registrator(String modid) {
super(modid);
}

@ExpectPlatform
public static @NotNull Registrar create(String modid) {
public static @NotNull Registrator create(String modid) {
throw new AssertionError();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.anvilcraft.lib.registrar;
package dev.anvilcraft.lib.registrator;

import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.resources.ResourceLocation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dev.anvilcraft.lib.registrar.builder;
package dev.anvilcraft.lib.registrator.builder;

import dev.anvilcraft.lib.data.AnvilLibBlockModelProvider;
import dev.anvilcraft.lib.data.DataProviderType;
import dev.anvilcraft.lib.registrar.AbstractRegistrar;
import dev.anvilcraft.lib.registrar.entry.BlockEntry;
import dev.anvilcraft.lib.registrator.AbstractRegistrator;
import dev.anvilcraft.lib.registrator.entry.BlockEntry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
Expand All @@ -16,7 +16,7 @@ public class BlockBuilder<T extends Block> extends EntryBuilder<T> {
private final Function<BlockBehaviour.Properties, T> factory;
private final BlockBehaviour.Properties properties = BlockBehaviour.Properties.of();

public BlockBuilder(AbstractRegistrar registrar, String id, Function<BlockBehaviour.Properties, T> factory) {
public BlockBuilder(AbstractRegistrator registrar, String id, Function<BlockBehaviour.Properties, T> factory) {
super(registrar, id);
this.factory = factory;
this.entry = new BlockEntry<>(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.anvilcraft.lib.registrar.builder;
package dev.anvilcraft.lib.registrator.builder;

import dev.anvilcraft.lib.registrar.AbstractRegistrar;
import dev.anvilcraft.lib.registrator.AbstractRegistrator;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
Expand All @@ -10,7 +10,7 @@
public class BlockItemBuilder<T extends BlockItem, B extends Block> extends ItemBuilder<T> {
protected final BlockBuilder<B> blockBuilder;

public BlockItemBuilder(AbstractRegistrar registrar, BlockBuilder<B> builder, String id, Function<Item.Properties, T> factory) {
public BlockItemBuilder(AbstractRegistrator registrar, BlockBuilder<B> builder, String id, Function<Item.Properties, T> factory) {
super(registrar, id, factory);
this.blockBuilder = builder;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package dev.anvilcraft.lib.registrar.builder;
package dev.anvilcraft.lib.registrator.builder;

import dev.anvilcraft.lib.registrar.AbstractRegistrar;
import dev.anvilcraft.lib.registrar.entry.RegistryEntry;
import dev.anvilcraft.lib.registrator.AbstractRegistrator;
import dev.anvilcraft.lib.registrator.entry.RegistryEntry;
import net.minecraft.resources.ResourceLocation;

public abstract class EntryBuilder<T> {
protected final AbstractRegistrar registrar;
protected final AbstractRegistrator registrar;
protected final String id;

protected EntryBuilder(AbstractRegistrar registrar, String id) {
protected EntryBuilder(AbstractRegistrator registrar, String id) {
this.registrar = registrar;
this.id = id;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package dev.anvilcraft.lib.registrar.builder;
package dev.anvilcraft.lib.registrator.builder;

import dev.anvilcraft.lib.data.AnvilLibItemModelProvider;
import dev.anvilcraft.lib.data.DataProviderType;
import dev.anvilcraft.lib.mixin.ItemPropertiesAccessor;
import dev.anvilcraft.lib.registrar.AbstractRegistrar;
import dev.anvilcraft.lib.registrar.entry.ItemEntry;
import dev.anvilcraft.lib.registrator.AbstractRegistrator;
import dev.anvilcraft.lib.registrator.entry.ItemEntry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.tags.TagKey;
Expand All @@ -22,7 +22,7 @@ public class ItemBuilder<T extends Item> extends EntryBuilder<T> {
private final Item.Properties properties = new Item.Properties();
private final Function<Item.Properties, T> factory;

public ItemBuilder(AbstractRegistrar registrar, String id, Function<Item.Properties, T> factory) {
public ItemBuilder(AbstractRegistrator registrar, String id, Function<Item.Properties, T> factory) {
super(registrar, id);
this.factory = factory;
this.entry = new ItemEntry<>(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.anvilcraft.lib.registrar.entry;
package dev.anvilcraft.lib.registrator.entry;

import dev.anvilcraft.lib.registrar.builder.BlockBuilder;
import dev.anvilcraft.lib.registrator.builder.BlockBuilder;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.anvilcraft.lib.registrar.entry;
package dev.anvilcraft.lib.registrator.entry;

import dev.anvilcraft.lib.registrar.builder.ItemBuilder;
import dev.anvilcraft.lib.registrator.builder.ItemBuilder;
import lombok.Getter;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.anvilcraft.lib.registrar.entry;
package dev.anvilcraft.lib.registrator.entry;

import java.util.function.Supplier;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.anvilcraft.lib.registrar.entry;
package dev.anvilcraft.lib.registrator.entry;

import dev.anvilcraft.lib.AnvilLib;
import dev.anvilcraft.lib.registrar.AbstractRegistrar;
import dev.anvilcraft.lib.registrator.AbstractRegistrator;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -10,21 +10,21 @@

public final class TagKeyEntry<T> extends RegistryEntry<TagKey<T>> {
private TagKey<T> self = null;
private final AbstractRegistrar registrar;
private final AbstractRegistrator registrar;
private final ResourceKey<? extends Registry<T>> registry;
@NotNull
private final String defaultPath;
private final String forgePath;

private TagKeyEntry(AbstractRegistrar registrar, ResourceKey<? extends Registry<T>> registry, @NotNull String defaultPath, String forgePath) {
private TagKeyEntry(AbstractRegistrator registrar, ResourceKey<? extends Registry<T>> registry, @NotNull String defaultPath, String forgePath) {
this.registrar = registrar;
this.registry = registry;
this.defaultPath = defaultPath;
this.forgePath = forgePath;
}

@NotNull
public static <T> TagKeyEntry<T> create(AbstractRegistrar registrar, ResourceKey<? extends Registry<T>> registry, @NotNull String fabricPath, String forgePath) {
public static <T> TagKeyEntry<T> create(AbstractRegistrator registrar, ResourceKey<? extends Registry<T>> registry, @NotNull String fabricPath, String forgePath) {
return new TagKeyEntry<>(registrar, registry, fabricPath, forgePath);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package dev.anvilcraft.lib.registrar.fabric;
package dev.anvilcraft.lib.registrator.fabric;

import dev.anvilcraft.lib.AnvilLib;
import dev.anvilcraft.lib.registrar.Registrar;
import dev.anvilcraft.lib.registrar.builder.EntryBuilder;
import dev.anvilcraft.lib.registrator.Registrator;
import dev.anvilcraft.lib.registrator.builder.EntryBuilder;
import net.minecraft.core.Registry;
import org.jetbrains.annotations.NotNull;

public class RegistrarImpl extends Registrar {
private RegistrarImpl(String modid) {
public class RegistratorImpl extends Registrator {
private RegistratorImpl(String modid) {
super(modid);
}

@NotNull
public static Registrar create(String modid) {
return new RegistrarImpl(modid);
public static Registrator create(String modid) {
return new RegistratorImpl(modid);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.anvilcraft.lib.registrar.fabric;
package dev.anvilcraft.lib.registrator.fabric;

import dev.anvilcraft.lib.registrar.ResourcePacksHelper;
import dev.anvilcraft.lib.registrator.ResourcePacksHelper;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
import net.fabricmc.loader.api.FabricLoader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package dev.anvilcraft.lib.registrar.forge;
package dev.anvilcraft.lib.registrator.forge;

import dev.anvilcraft.lib.AnvilLib;
import dev.anvilcraft.lib.registrar.Registrar;
import dev.anvilcraft.lib.registrar.builder.EntryBuilder;
import dev.anvilcraft.lib.registrator.Registrator;
import dev.anvilcraft.lib.registrator.builder.EntryBuilder;
import net.minecraft.core.Registry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.registries.RegisterEvent;
import org.jetbrains.annotations.NotNull;

public class RegistrarImpl extends Registrar {
private RegistrarImpl(String modid) {
public class RegistratorImpl extends Registrator {
private RegistratorImpl(String modid) {
super(modid);
}

Expand All @@ -36,7 +36,7 @@ private <T> void init(RegisterEvent event, Registry<T> registry) {
}

@NotNull
public static Registrar create(String modid) {
return new RegistrarImpl(modid);
public static Registrator create(String modid) {
return new RegistratorImpl(modid);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package dev.anvilcraft.lib.registrar.forge;
package dev.anvilcraft.lib.registrator.forge;

import dev.anvilcraft.lib.registrar.ResourcePacksHelper;
import dev.anvilcraft.lib.registrator.ResourcePacksHelper;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackSource;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.AddPackFindersEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package dev.anvilcraft.lib.registrar.forge;
package dev.anvilcraft.lib.registrator.forge;

import dev.anvilcraft.lib.AnvilLib;
import dev.anvilcraft.lib.registrar.Registrar;
import dev.anvilcraft.lib.registrar.builder.EntryBuilder;
import dev.anvilcraft.lib.registrator.Registrator;
import dev.anvilcraft.lib.registrator.builder.EntryBuilder;
import net.minecraft.core.Registry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.registries.RegisterEvent;
import org.jetbrains.annotations.NotNull;

public class RegistrarImpl extends Registrar {
private RegistrarImpl(String modid) {
public class RegistratorImpl extends Registrator {
private RegistratorImpl(String modid) {
super(modid);
}

Expand All @@ -36,7 +36,7 @@ private <T> void init(RegisterEvent event, Registry<T> registry) {
}

@NotNull
public static Registrar create(String modid) {
return new RegistrarImpl(modid);
public static Registrator create(String modid) {
return new RegistratorImpl(modid);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package dev.anvilcraft.lib.registrar.forge;
package dev.anvilcraft.lib.registrator.forge;

import dev.anvilcraft.lib.registrar.ResourcePacksHelper;
import dev.anvilcraft.lib.registrator.ResourcePacksHelper;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackSource;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.AddPackFindersEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModList;
Expand Down

0 comments on commit 5c21fe3

Please sign in to comment.