mirror of
https://github.com/architectury/architectury-api.git
synced 2026-04-01 21:17:45 -05:00
Update to 1.19.3
This commit is contained in:
@@ -207,7 +207,7 @@ public class EventHandlerImplClient {
|
||||
colorContext.setBackgroundColor(event.getBackgroundStart());
|
||||
colorContext.setOutlineGradientTopColor(event.getBorderStart());
|
||||
colorContext.setOutlineGradientBottomColor(event.getBorderEnd());
|
||||
ClientTooltipEvent.RENDER_MODIFY_COLOR.invoker().renderTooltip(stack, event.getX(), event.getY(), colorContext);
|
||||
// ClientTooltipEvent.RENDER_MODIFY_COLOR.invoker().renderTooltip(stack, event.getX(), event.getY(), colorContext);
|
||||
event.setBackground(colorContext.getBackgroundColor());
|
||||
event.setBorderEnd(colorContext.getOutlineGradientBottomColor());
|
||||
event.setBorderStart(colorContext.getOutlineGradientTopColor());
|
||||
@@ -326,14 +326,9 @@ public class EventHandlerImplClient {
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class ModBasedEventHandler {
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventTextureStitchEvent(TextureStitchEvent.Pre event) {
|
||||
ClientTextureStitchEvent.PRE.invoker().stitch(event.getAtlas(), event::addSprite);
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventTextureStitchEvent(TextureStitchEvent.Post event) {
|
||||
ClientTextureStitchEvent.POST.invoker().stitch(event.getAtlas());
|
||||
// ClientTextureStitchEvent.POST.invoker().stitch(event.getAtlas());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
@@ -343,7 +338,7 @@ public class EventHandlerImplClient {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void event(RegisterShadersEvent event) {
|
||||
ClientReloadShadersEvent.EVENT.invoker().reload(event.getResourceManager(), event::registerShader);
|
||||
ClientReloadShadersEvent.EVENT.invoker().reload(event.getResourceProvider(), event::registerShader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class EventHandlerImplCommon {
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void event(ServerChatEvent.Preview event) {
|
||||
public static void event(ServerChatEvent event) {
|
||||
class ChatComponentImpl implements ChatEvent.ChatComponent {
|
||||
@Override
|
||||
public Component get() {
|
||||
@@ -155,8 +155,8 @@ public class EventHandlerImplCommon {
|
||||
ChatEvent.DECORATE.invoker().decorate(event.getPlayer(), new ChatComponentImpl());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void event(ServerChatEvent.Submitted event) {
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public static void eventAfter(ServerChatEvent event) {
|
||||
EventResult process = ChatEvent.RECEIVED.invoker().received(event.getPlayer(), event.getMessage());
|
||||
if (process.isFalse())
|
||||
event.setCanceled(true);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package dev.architectury.hooks.client.screen.forge;
|
||||
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
@@ -34,11 +34,11 @@ public class ScreenHooksImpl {
|
||||
return screen.narratables;
|
||||
}
|
||||
|
||||
public static List<Widget> getRenderables(Screen screen) {
|
||||
public static List<Renderable> getRenderables(Screen screen) {
|
||||
return screen.renderables;
|
||||
}
|
||||
|
||||
public static <T extends AbstractWidget & Widget & NarratableEntry> T addRenderableWidget(Screen screen, T widget) {
|
||||
public static <T extends AbstractWidget & Renderable & NarratableEntry> T addRenderableWidget(Screen screen, T widget) {
|
||||
try {
|
||||
return (T) ObfuscationReflectionHelper.findMethod(Screen.class, "m_142416_", GuiEventListener.class).invoke(screen, widget);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
@@ -46,9 +46,9 @@ public class ScreenHooksImpl {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T extends Widget> T addRenderableOnly(Screen screen, T listener) {
|
||||
public static <T extends Renderable> T addRenderableOnly(Screen screen, T listener) {
|
||||
try {
|
||||
return (T) ObfuscationReflectionHelper.findMethod(Screen.class, "m_169394_", Widget.class).invoke(screen, listener);
|
||||
return (T) ObfuscationReflectionHelper.findMethod(Screen.class, "m_169394_", Renderable.class).invoke(screen, listener);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import dev.architectury.utils.Env;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -181,7 +182,7 @@ public class NetworkManagerImpl {
|
||||
}
|
||||
|
||||
public static Packet<ClientGamePacketListener> createAddEntityPacket(Entity entity) {
|
||||
return NetworkHooks.getEntitySpawningPacket(entity);
|
||||
return (Packet<ClientGamePacketListener>) NetworkHooks.getEntitySpawningPacket(entity);
|
||||
}
|
||||
|
||||
static FriendlyByteBuf sendSyncPacket(Map<ResourceLocation, NetworkReceiver> map) {
|
||||
|
||||
@@ -19,21 +19,220 @@
|
||||
|
||||
package dev.architectury.registry.forge;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import dev.architectury.forge.ArchitecturyForge;
|
||||
import dev.architectury.registry.CreativeTabOutput;
|
||||
import dev.architectury.registry.CreativeTabRegistry;
|
||||
import dev.architectury.registry.CreativeTabRegistry.TabSupplier;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.CreativeModeTabRegistry;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = ArchitecturyForge.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public class CreativeTabRegistryImpl {
|
||||
public static CreativeModeTab create(ResourceLocation resourceLocation, Supplier<ItemStack> supplier) {
|
||||
return new CreativeModeTab(String.format("%s.%s", resourceLocation.getNamespace(), resourceLocation.getPath())) {
|
||||
private static final Logger LOGGER = LogManager.getLogger(CreativeTabRegistryImpl.class);
|
||||
|
||||
@Nullable
|
||||
private static List<Consumer<CreativeModeTabEvent.Register>> registerListeners = new ArrayList<>();
|
||||
private static final List<Consumer<CreativeModeTabEvent.BuildContents>> BUILD_CONTENTS_LISTENERS = new ArrayList<>();
|
||||
private static final Multimap<TabKey, Supplier<ItemStack>> APPENDS = MultimapBuilder.hashKeys().arrayListValues().build();
|
||||
|
||||
static {
|
||||
BUILD_CONTENTS_LISTENERS.add(event -> {
|
||||
for (Map.Entry<TabKey, Collection<Supplier<ItemStack>>> keyEntry : APPENDS.asMap().entrySet()) {
|
||||
Supplier<List<ItemStack>> stacks = Suppliers.memoize(() -> keyEntry.getValue().stream()
|
||||
.map(Supplier::get)
|
||||
.toList());
|
||||
if (keyEntry.getKey() instanceof TabKey.SupplierTabKey supplierTabKey) {
|
||||
event.register(supplierTabKey.supplier.getName(), (arg, populator, bl) -> {
|
||||
populator.acceptAll(stacks.get());
|
||||
});
|
||||
} else if (keyEntry.getKey() instanceof TabKey.DirectTabKey directTabKey) {
|
||||
event.register(directTabKey.tab, (arg, populator, bl) -> {
|
||||
populator.acceptAll(stacks.get());
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void event(CreativeModeTabEvent.Register event) {
|
||||
if (registerListeners != null) {
|
||||
for (Consumer<CreativeModeTabEvent.Register> listener : registerListeners) {
|
||||
listener.accept(event);
|
||||
}
|
||||
registerListeners = null;
|
||||
} else {
|
||||
LOGGER.warn("Creative tab listeners were already registered!");
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void event(CreativeModeTabEvent.BuildContents event) {
|
||||
for (Consumer<CreativeModeTabEvent.BuildContents> listener : BUILD_CONTENTS_LISTENERS) {
|
||||
listener.accept(event);
|
||||
}
|
||||
}
|
||||
|
||||
public static TabSupplier create(ResourceLocation name, Consumer<CreativeModeTab.Builder> callback) {
|
||||
if (registerListeners == null) {
|
||||
throw new IllegalStateException("Creative tab listeners were already registered!");
|
||||
}
|
||||
CreativeModeTab[] tab = new CreativeModeTab[1];
|
||||
registerListeners.add(register -> {
|
||||
tab[0] = register.registerCreativeModeTab(name, builder -> {
|
||||
builder.title(Component.translatable("itemGroup.%s.%s".formatted(name.getNamespace(), name.getPath())));
|
||||
callback.accept(builder);
|
||||
});
|
||||
});
|
||||
return new TabSupplier() {
|
||||
@Override
|
||||
@NotNull
|
||||
public ItemStack makeIcon() {
|
||||
return supplier.get();
|
||||
public ResourceLocation getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreativeModeTab get() {
|
||||
if (tab[0] == null) {
|
||||
throw new IllegalStateException("Creative tab %s was not registered yet!".formatted(name));
|
||||
}
|
||||
|
||||
return tab[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPresent() {
|
||||
return tab[0] != null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static TabSupplier of(CreativeModeTab tab) {
|
||||
ResourceLocation location = CreativeModeTabRegistry.getName(tab);
|
||||
if (location == null) {
|
||||
throw new IllegalArgumentException("Tab %s is not registered!".formatted(tab));
|
||||
}
|
||||
return new TabSupplier() {
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPresent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreativeModeTab get() {
|
||||
return tab;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static TabSupplier defer(ResourceLocation name) {
|
||||
return new TabSupplier() {
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPresent() {
|
||||
return CreativeModeTabRegistry.getTab(name) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreativeModeTab get() {
|
||||
CreativeModeTab tab = CreativeModeTabRegistry.getTab(name);
|
||||
if (tab == null) {
|
||||
throw new IllegalStateException("Creative tab %s was not registered yet!".formatted(name));
|
||||
} else {
|
||||
return tab;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void modify(TabSupplier tab, CreativeTabRegistry.ModifyTabCallback filler) {
|
||||
BUILD_CONTENTS_LISTENERS.add(event -> {
|
||||
if (tab.isPresent()) {
|
||||
event.register(tab.get(), (flags, populator, canUseGameMasterBlocks) -> {
|
||||
filler.accept(flags, wrapTabOutput(populator), canUseGameMasterBlocks);
|
||||
});
|
||||
} else {
|
||||
event.register(tab.getName(), (flags, populator, canUseGameMasterBlocks) -> {
|
||||
filler.accept(flags, wrapTabOutput(populator), canUseGameMasterBlocks);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static CreativeTabOutput wrapTabOutput(CreativeModeTabEvent.CreativeModeTabPopulator populator) {
|
||||
return new CreativeTabOutput() {
|
||||
@Override
|
||||
public void acceptAfter(ItemStack after, ItemStack stack, CreativeModeTab.TabVisibility visibility) {
|
||||
populator.accept(stack, visibility, ItemStack.EMPTY, after);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptBefore(ItemStack before, ItemStack stack, CreativeModeTab.TabVisibility visibility) {
|
||||
populator.accept(stack, visibility, before, ItemStack.EMPTY);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(TabSupplier tab, Supplier<ItemStack> item) {
|
||||
APPENDS.put(new TabKey.SupplierTabKey(tab), item);
|
||||
}
|
||||
|
||||
private interface TabKey {
|
||||
record SupplierTabKey(TabSupplier supplier) implements TabKey {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof SupplierTabKey that)) return false;
|
||||
return Objects.equals(supplier.getName(), that.supplier.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(supplier.getName());
|
||||
}
|
||||
}
|
||||
|
||||
record DirectTabKey(CreativeModeTab tab) implements TabKey {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof DirectTabKey that)) return false;
|
||||
return tab == that.tab;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return System.identityHashCode(tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import dev.architectury.registry.level.biome.BiomeModifications.BiomeContext;
|
||||
import dev.architectury.utils.GameInstance;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -69,10 +70,6 @@ public class BiomeModificationsImpl {
|
||||
registry.register(new ResourceLocation(ArchitecturyForge.MOD_ID, "none_biome_mod_codec"),
|
||||
noneBiomeModCodec = Codec.unit(BiomeModifierImpl.INSTANCE));
|
||||
});
|
||||
event.register(ForgeRegistries.Keys.BIOME_MODIFIERS, registry -> {
|
||||
registry.register(new ResourceLocation(ArchitecturyForge.MOD_ID, "impl"),
|
||||
BiomeModifierImpl.INSTANCE);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -145,9 +142,9 @@ public class BiomeModificationsImpl {
|
||||
public boolean hasTag(TagKey<Biome> tag) {
|
||||
MinecraftServer server = GameInstance.getServer();
|
||||
if (server != null) {
|
||||
Optional<? extends Registry<Biome>> registry = server.registryAccess().registry(Registry.BIOME_REGISTRY);
|
||||
Optional<? extends Registry<Biome>> registry = server.registryAccess().registry(Registries.BIOME);
|
||||
if (registry.isPresent()) {
|
||||
Optional<Holder<Biome>> holder = registry.get().getHolder(biomeResourceKey.get());
|
||||
Optional<Holder.Reference<Biome>> holder = registry.get().getHolder(biomeResourceKey.get());
|
||||
if (holder.isPresent()) {
|
||||
return holder.get().is(tag);
|
||||
}
|
||||
@@ -168,7 +165,7 @@ public class BiomeModificationsImpl {
|
||||
public BiomeWrapped(ModifiableBiomeInfo.BiomeInfo.Builder event) {
|
||||
this(event,
|
||||
new MutableClimatePropertiesWrapped(event.getClimateSettings()),
|
||||
new MutableEffectsPropertiesWrapped(event.getEffects()),
|
||||
new MutableEffectsPropertiesWrapped(event.getSpecialEffects()),
|
||||
new GenerationSettingsBuilderWrapped(event.getGenerationSettings()),
|
||||
new SpawnSettingsBuilderWrapped(event.getMobSpawnSettings())
|
||||
);
|
||||
@@ -253,7 +250,7 @@ public class BiomeModificationsImpl {
|
||||
public MutableBiomeWrapped(ModifiableBiomeInfo.BiomeInfo.Builder event) {
|
||||
super(event,
|
||||
new MutableClimatePropertiesWrapped(event.getClimateSettings()),
|
||||
new MutableEffectsPropertiesWrapped(event.getEffects()),
|
||||
new MutableEffectsPropertiesWrapped(event.getSpecialEffects()),
|
||||
new MutableGenerationSettingsBuilderWrapped(event.getGenerationSettings()),
|
||||
new MutableSpawnSettingsBuilderWrapped(event.getMobSpawnSettings())
|
||||
);
|
||||
@@ -385,7 +382,7 @@ public class BiomeModificationsImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SoundEvent> getAmbientLoopSound() {
|
||||
public Optional<Holder<SoundEvent>> getAmbientLoopSound() {
|
||||
return builder.ambientLoopSoundEvent;
|
||||
}
|
||||
|
||||
@@ -453,7 +450,7 @@ public class BiomeModificationsImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutable setAmbientLoopSound(@Nullable SoundEvent sound) {
|
||||
public Mutable setAmbientLoopSound(@Nullable Holder<SoundEvent> sound) {
|
||||
builder.ambientLoopSoundEvent = Optional.ofNullable(sound);
|
||||
return this;
|
||||
}
|
||||
@@ -488,12 +485,46 @@ public class BiomeModificationsImpl {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutable addFeature(GenerationStep.Decoration decoration, ResourceKey<PlacedFeature> feature) {
|
||||
MinecraftServer server = GameInstance.getServer();
|
||||
if (server != null) {
|
||||
Optional<? extends Registry<PlacedFeature>> registry = server.registryAccess().registry(Registries.PLACED_FEATURE);
|
||||
if (registry.isPresent()) {
|
||||
Optional<Holder.Reference<PlacedFeature>> holder = registry.get().getHolder(feature);
|
||||
if (holder.isPresent()) {
|
||||
return addFeature(decoration, holder.get());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown feature: " + feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutable addCarver(GenerationStep.Carving carving, Holder<ConfiguredWorldCarver<?>> feature) {
|
||||
generation.addCarver(carving, feature);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutable addCarver(GenerationStep.Carving carving, ResourceKey<ConfiguredWorldCarver<?>> feature) {
|
||||
MinecraftServer server = GameInstance.getServer();
|
||||
if (server != null) {
|
||||
Optional<? extends Registry<ConfiguredWorldCarver<?>>> registry = server.registryAccess().registry(Registries.CONFIGURED_CARVER);
|
||||
if (registry.isPresent()) {
|
||||
Optional<Holder.Reference<ConfiguredWorldCarver<?>>> holder = registry.get().getHolder(feature);
|
||||
if (holder.isPresent()) {
|
||||
return addCarver(carving, holder.get());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown carver: " + feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutable removeFeature(GenerationStep.Decoration decoration, ResourceKey<PlacedFeature> feature) {
|
||||
generation.getFeatures(decoration).removeIf(supplier -> supplier.is(feature));
|
||||
|
||||
@@ -26,12 +26,12 @@ import com.google.common.collect.Multimap;
|
||||
import dev.architectury.platform.forge.EventBuses;
|
||||
import dev.architectury.registry.registries.Registrar;
|
||||
import dev.architectury.registry.registries.RegistrarBuilder;
|
||||
import dev.architectury.registry.registries.Registries;
|
||||
import dev.architectury.registry.registries.RegistrarManager;
|
||||
import dev.architectury.registry.registries.RegistrySupplier;
|
||||
import dev.architectury.registry.registries.options.RegistrarOption;
|
||||
import dev.architectury.registry.registries.options.StandardRegistrarOption;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
@@ -47,15 +47,15 @@ import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class RegistriesImpl {
|
||||
private static final Logger LOGGER = LogManager.getLogger(RegistriesImpl.class);
|
||||
public class RegistrarManagerImpl {
|
||||
private static final Logger LOGGER = LogManager.getLogger(RegistrarManagerImpl.class);
|
||||
private static final Multimap<RegistryEntryId<?>, Consumer<?>> LISTENERS = HashMultimap.create();
|
||||
|
||||
private static void listen(ResourceKey<?> resourceKey, ResourceLocation id, Consumer<?> listener, boolean vanilla) {
|
||||
LISTENERS.put(new RegistryEntryId<>(resourceKey, id), listener);
|
||||
}
|
||||
|
||||
public static Registries.RegistryProvider _get(String modId) {
|
||||
public static RegistrarManager.RegistryProvider _get(String modId) {
|
||||
return new RegistryProviderImpl(modId);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class RegistriesImpl {
|
||||
}
|
||||
}
|
||||
|
||||
public static class RegistryProviderImpl implements Registries.RegistryProvider {
|
||||
public static class RegistryProviderImpl implements RegistrarManager.RegistryProvider {
|
||||
private static final Map<ResourceKey<Registry<?>>, Registrar<?>> CUSTOM_REGS = new HashMap<>();
|
||||
private final String modId;
|
||||
private final Supplier<IEventBus> eventBus;
|
||||
@@ -141,8 +141,7 @@ public class RegistriesImpl {
|
||||
updateEventBus();
|
||||
ForgeRegistry<T> registry = RegistryManager.ACTIVE.getRegistry(registryKey.location());
|
||||
if (registry == null) {
|
||||
Registry<T> ts = (Registry<T>) Registry.REGISTRY.get(registryKey.location());
|
||||
if (ts == null) ts = (Registry<T>) BuiltinRegistries.REGISTRY.get(registryKey.location());
|
||||
Registry<T> ts = (Registry<T>) BuiltInRegistries.REGISTRY.get(registryKey.location());
|
||||
if (ts != null) {
|
||||
return get(ts);
|
||||
}
|
||||
@@ -328,8 +327,8 @@ public class RegistriesImpl {
|
||||
Registrar<T> registrar = this;
|
||||
return new RegistrySupplier<>() {
|
||||
@Override
|
||||
public Registries getRegistries() {
|
||||
return Registries.get(modId);
|
||||
public RegistrarManager getRegistrarManager() {
|
||||
return RegistrarManager.get(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -446,7 +445,7 @@ public class RegistriesImpl {
|
||||
if (contains(id)) {
|
||||
callback.accept(get(id));
|
||||
} else {
|
||||
RegistriesImpl.listen(key(), id, callback, true);
|
||||
RegistrarManagerImpl.listen(key(), id, callback, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -468,8 +467,8 @@ public class RegistriesImpl {
|
||||
Registrar<T> registrar = this;
|
||||
return new RegistrySupplier<>() {
|
||||
@Override
|
||||
public Registries getRegistries() {
|
||||
return Registries.get(modId);
|
||||
public RegistrarManager getRegistrarManager() {
|
||||
return RegistrarManager.get(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -525,8 +524,8 @@ public class RegistriesImpl {
|
||||
Registrar<T> registrar = this;
|
||||
return new RegistrySupplier<>() {
|
||||
@Override
|
||||
public Registries getRegistries() {
|
||||
return Registries.get(modId);
|
||||
public RegistrarManager getRegistrarManager() {
|
||||
return RegistrarManager.get(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -639,7 +638,7 @@ public class RegistriesImpl {
|
||||
if (contains(id)) {
|
||||
callback.accept(get(id));
|
||||
} else {
|
||||
RegistriesImpl.listen(key(), id, callback, false);
|
||||
RegistrarManagerImpl.listen(key(), id, callback, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -674,8 +673,8 @@ public class RegistriesImpl {
|
||||
if (isReady()) return delegate.get().delegate(id);
|
||||
return new RegistrySupplier<>() {
|
||||
@Override
|
||||
public Registries getRegistries() {
|
||||
return Registries.get(modId);
|
||||
public RegistrarManager getRegistrarManager() {
|
||||
return RegistrarManager.get(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,5 +1,5 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[43,)"
|
||||
loaderVersion = "[44,)"
|
||||
issueTrackerURL = "https://github.com/shedaniel/architectury/issues"
|
||||
license = "GNU LGPLv3"
|
||||
|
||||
@@ -17,13 +17,13 @@ license = "LGPL-3"
|
||||
[[dependencies.architectury]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.19.2,)"
|
||||
versionRange = "[1.19.3,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.architectury]]
|
||||
modId = "forge"
|
||||
mandatory = true
|
||||
versionRange = "[43.2.0,)"
|
||||
versionRange = "[44.0.0,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type" : "architectury:none_biome_mod_codec"
|
||||
}
|
||||
Reference in New Issue
Block a user