Skip to content

Commit

Permalink
Merge branch '1.19.4' into 1.20.1
Browse files Browse the repository at this point in the history
* 1.19.4:
  3.0.4
  • Loading branch information
Faboslav committed Sep 30, 2024
2 parents 51cc9a0 + ce6b10b commit f7a0bb2
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 419 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.0.4

- Improved internal registries logic (Might fix some crashes)

## 3.0.3

- Fixed crash related to catalogue
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* @author ThatGravyBoat
* <a href="https://github.com/Team-Resourceful/ResourcefulLib">https://github.com/Team-Resourceful/ResourcefulLib</a>
*/
public final class RegistryEntries<T>
public class RegistryEntries<T>
{
private final List<RegistryEntry<T>> entries = new ArrayList<>();

public <I extends T> RegistryEntry<I> add(RegistryEntry<I> entry) {
public <I extends T, E extends RegistryEntry<I>> E add(E entry) {
//noinspection unchecked
entries.add((RegistryEntry<T>) entry);
return entry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.commons.lang3.tuple.Pair;

import java.util.function.Supplier;

/**
* Event/registry related is code based on The Bumblezone/Resourceful Lib mods with permissions from the authors
Expand All @@ -16,7 +12,7 @@
* @author ThatGravyBoat
* <a href="https://github.com/Team-Resourceful/ResourcefulLib">https://github.com/Team-Resourceful/ResourcefulLib</a>
*/
public final class ResourcefulRegistries
public class ResourcefulRegistries
{
public static <T> ResourcefulRegistry<T> create(ResourcefulRegistry<T> parent) {
return new ResourcefulRegistryChild<>(parent);
Expand All @@ -28,13 +24,7 @@ public static <T> ResourcefulRegistry<T> create(Registry<T> registry, String id)
}

@ExpectPlatform
public static <T, R extends T, K extends Registry<T>> Pair<Supplier<CustomRegistryLookup<T, R>>, ResourcefulRegistry<T>> createCustomRegistryInternal(
String modId,
RegistryKey<K> key,
boolean save,
boolean sync,
boolean allowModification
) {
public static <D, T extends ResourcefulRegistry<D>> T create(ResourcefulRegistryType<D, T> type, String id) {
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
import java.util.function.Supplier;
import java.util.stream.Stream;

/**
* Event/registry related is code based on The Bumblezone/Resourceful Lib mods with permissions from the authors
*
* @author TelepathicGrunt
* <a href="https://github.com/TelepathicGrunt/Bumblezone">https://github.com/TelepathicGrunt/Bumblezone</a>
* @author ThatGravyBoat
* <a href="https://github.com/Team-Resourceful/ResourcefulLib">https://github.com/Team-Resourceful/ResourcefulLib</a>
*/
public interface ResourcefulRegistry<T>
{
<I extends T> RegistryEntry<I> register(String id, Supplier<I> supplier);
Expand All @@ -22,5 +14,9 @@ default Stream<RegistryEntry<T>> stream() {
return getEntries().stream();
}

default Stream<T> boundStream() {
return stream().map(RegistryEntry::get);
}

void init();
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package com.faboslav.friendsandfoes.common.init.registry;

import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;

/**
* Event/registry related is code based on The Bumblezone/Resourceful Lib mods with permissions from the authors
*
Expand All @@ -13,19 +8,16 @@
* @author ThatGravyBoat
* <a href="https://github.com/Team-Resourceful/ResourcefulLib">https://github.com/Team-Resourceful/ResourcefulLib</a>
*/
public interface CustomRegistryLookup<T, K extends T> extends Iterable<T>
public final class ResourcefulRegistryType<D, T extends ResourcefulRegistry<D>>
{
boolean containsKey(Identifier id);

boolean containsValue(T value);

@Nullable
T get(Identifier id);

@Nullable
Identifier getKey(T value);
private final Class<T> type;

Collection<T> getValues();
private ResourcefulRegistryType(Class<T> type) {
this.type = type;
}

Collection<Identifier> getKeys();
}
@Override
public String toString() {
return "ResourcefulRegistryType{type=" + type + "}";
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.faboslav.friendsandfoes.common.init.registry.fabric;

import com.faboslav.friendsandfoes.common.init.registry.RegistryEntry;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import java.util.function.Supplier;

/**
* Event/registry related is code based on The Bumblezone/Resourceful Lib mods with permissions from the authors
*
* @author TelepathicGrunt
* <a href="https://github.com/TelepathicGrunt/Bumblezone">https://github.com/TelepathicGrunt/Bumblezone</a>
* @author ThatGravyBoat
* <a href="https://github.com/Team-Resourceful/ResourcefulLib">https://github.com/Team-Resourceful/ResourcefulLib</a>
*/
public class FabricRegistryEntry<T> implements RegistryEntry<T>
{
private final Identifier id;
private final T value;

private FabricRegistryEntry(Identifier id, T value) {
this.id = id;
this.value = value;
}

public static <T, I extends T> FabricRegistryEntry<I> of(
Registry<T> registry,
Identifier id,
Supplier<I> supplier
) {
return new FabricRegistryEntry<>(id, Registry.register(registry, id, supplier.get()));
}

@Override
public T get() {
return this.value;
}

@Override
public Identifier getId() {
return this.id;
}
}
Loading

0 comments on commit f7a0bb2

Please sign in to comment.