Skip to content

Commit

Permalink
Revert "Registered: Add key accessor"
Browse files Browse the repository at this point in the history
This reverts commit 4b802b7.
  • Loading branch information
Juuxel committed Oct 1, 2024
1 parent 4b0365a commit 2c895e7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package juuxel.adorn.lib.registry;

import net.minecraft.registry.RegistryKey;

import java.util.function.Supplier;

@FunctionalInterface
public interface Registered<T> extends Supplier<T> {
RegistryKey<? super T> key();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.function.Supplier;
import java.util.stream.Stream;

public final class RegisteredMap<K, V> implements Supplier<Map<K, V>> {
public final class RegisteredMap<K, V> implements Registered<Map<K, V>> {
private final Map<K, Registered<? extends V>> map;
private final Supplier<Map<K, V>> builtMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import juuxel.adorn.lib.registry.Registered;
import juuxel.adorn.lib.registry.Registrar;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;

import java.util.ArrayList;
import java.util.Iterator;
Expand All @@ -21,20 +20,9 @@ public RegistrarImpl(Registry<T> registry) {

@Override
public <U extends T> Registered<U> register(String id, Supplier<? extends U> provider) {
var key = RegistryKey.of(registry.getKey(), AdornCommon.id(id));
var registered = Registry.register(registry, key, provider.get());
var registered = Registry.register(registry, AdornCommon.id(id), provider.get());
objects.add(registered);
return new Registered<>() {
@Override
public U get() {
return registered;
}

@Override
public RegistryKey<? super U> key() {
return key;
}
};
return () -> registered;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.common.extensions.IHolderExtension;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;

Expand All @@ -32,17 +31,7 @@ public void hook(IEventBus modBus) {
public <U extends T> Registered<U> register(String id, Supplier<? extends U> provider) {
var registryObject = register.register(id, provider);
objects.add(registryObject);
return new Registered<>() {
@Override
public RegistryKey<? super U> key() {
return ((IHolderExtension<T>) registryObject).getKey();
}

@Override
public U get() {
return registryObject.get();
}
};
return registryObject::get;
}

@Override
Expand Down

0 comments on commit 2c895e7

Please sign in to comment.