Skip to content

Commit

Permalink
fixed build error
Browse files Browse the repository at this point in the history
  • Loading branch information
LudoCrypt committed Dec 9, 2023
1 parent 9097025 commit 46c3051
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;

public interface TagGroupLoaderAccess {
public interface TagGroupLoaderAccess<O> {

public Optional<RegistryKey<? extends Registry<?>>> getRegistryKey();
public Optional<RegistryKey<? extends Registry<O>>> getRegistryKey();

public void setRegistryKey(@Nullable RegistryKey<? extends Registry<?>> key);
public void setRegistryKey(@Nullable RegistryKey<? extends Registry<O>> key);

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,26 @@
import net.minecraft.util.Identifier;

@Mixin(TagGroupLoader.class)
public class TagGroupLoaderMixin<T> implements TagGroupLoaderAccess {
public class TagGroupLoaderMixin<T, O> implements TagGroupLoaderAccess<O> {

@Shadow
@Final
Function<Identifier, Optional<? extends T>> registryGetter;

@Unique
Optional<RegistryKey<? extends Registry<?>>> associatedRegistryKey = Optional.empty();
Optional<RegistryKey<? extends Registry<O>>> associatedRegistryKey = Optional.empty();

@SuppressWarnings("unchecked")
@Inject(method = "Lnet/minecraft/registry/tag/TagGroupLoader;loadTags(Lnet/minecraft/resource/ResourceManager;)Ljava/util/Map;", at = @At(value = "INVOKE", target = "Ljava/util/Map;computeIfAbsent(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;", shift = Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD)
private <O> void limlib$loadTags(ResourceManager manager,
private void limlib$loadTags(ResourceManager manager,
CallbackInfoReturnable<Map<Identifier, List<TagGroupLoader.EntryWithSource>>> ci,
Map<Identifier, List<TagGroupLoader.EntryWithSource>> map, ResourceFileNamespace resourceFileNamespace,
Iterator<Map.Entry<Identifier, List<Resource>>> itr, Map.Entry<Identifier, List<Resource>> entry,
Identifier identifier, Identifier identifier2, Iterator<Resource> ritr, Resource resource, Reader reader,
JsonElement jsonElement) {

if (this.getRegistryKey().isPresent()) {
TagKey<O> key = (TagKey<O>) TagKey.of(this.getRegistryKey().get(), identifier2);
TagKey<O> key = TagKey.of(this.getRegistryKey().get(), identifier2);
LimlibRegistryHooks.TAG_JSON_HOOKS
.getOrDefault(key, Sets.newHashSet())
.forEach((hook) -> ((LimlibJsonTagHook<O>) hook).register(manager, key, jsonElement));
Expand All @@ -62,12 +62,12 @@ public class TagGroupLoaderMixin<T> implements TagGroupLoaderAccess {
}

@Override
public Optional<RegistryKey<? extends Registry<?>>> getRegistryKey() {
public Optional<RegistryKey<? extends Registry<O>>> getRegistryKey() {
return this.associatedRegistryKey;
}

@Override
public void setRegistryKey(@Nullable RegistryKey<? extends Registry<?>> key) {
public void setRegistryKey(@Nullable RegistryKey<? extends Registry<O>> key) {
this.associatedRegistryKey = Optional.ofNullable(key);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
@Mixin(TagManagerLoader.class)
public class TagManagerLoaderMixin {

@SuppressWarnings("unchecked")
@Inject(method = "Lnet/minecraft/registry/tag/TagManagerLoader;buildGroup(Lnet/minecraft/resource/ResourceManager;Ljava/util/concurrent/Executor;Lnet/minecraft/registry/DynamicRegistryManager$RegistryEntry;)Ljava/util/concurrent/CompletableFuture;", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
private <T> void limlib$buildGroup(ResourceManager resourceManager, Executor prepareExecutor,
DynamicRegistryManager.RegistryEntry<T> registryEntry,
CallbackInfoReturnable<CompletableFuture<TagManagerLoader.LoadResult<T>>> ci,
RegistryKey<? extends Registry<T>> registryKey, Registry<T> registry, TagGroupLoader<Holder<T>> tagGroupLoader) {
((TagGroupLoaderAccess) tagGroupLoader).setRegistryKey(registryKey);
((TagGroupLoaderAccess<T>) tagGroupLoader).setRegistryKey(registryKey);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
@Mixin(WorldSaveStorage.class)
public class WorldSaveStorageMixin {

@ModifyVariable(method = "Lnet/minecraft/world/storage/WorldSaveStorage;method_54523(Lcom/mojang/serialization/Dynamic;Lnet/minecraft/server/world/FeatureAndDataSettings;Lnet/minecraft/registry/Registry;Lnet/minecraft/registry/DynamicRegistryManager$Frozen;)Lnet/minecraft/unmapped/C_qhzfxdhh;", at = @At(value = "STORE"), ordinal = 1)
@ModifyVariable(method = "Lnet/minecraft/world/storage/WorldSaveStorage;method_54523(Lcom/mojang/serialization/Dynamic;Lnet/minecraft/server/world/FeatureAndDataSettings;Lnet/minecraft/registry/Registry;Lnet/minecraft/registry/DynamicRegistryManager$Frozen;)Lnet/minecraft/unmapped/C_qhzfxdhh;", at = @At(value = "STORE"), ordinal = 2)
private static <T> Dynamic<T> limlib$readGeneratorProperties$datafix(Dynamic<T> in, Dynamic<?> levelData,
FeatureAndDataSettings featureAndDataSettings, Registry<DimensionOptions> registry,
DynamicRegistryManager.Frozen frozen) {
Dynamic<T> dynamic = in;

// for (Entry<RegistryKey<LimlibWorld>, LimlibWorld> entry : LimlibWorld.LIMLIB_WORLD.getEntries()) {
// dynamic = limlib$addDimension(entry.getKey(), entry.getValue(), dynamic, frozen);
// }
for (Entry<RegistryKey<LimlibWorld>, LimlibWorld> entry : LimlibWorld.LIMLIB_WORLD.getEntries()) {
dynamic = limlib$addDimension(entry.getKey(), entry.getValue(), dynamic, frozen);
}

return dynamic;
}
Expand Down Expand Up @@ -63,7 +63,7 @@ public <Q> HolderProvider<Q> get(RegistryKey<Registry<Q>> key) {
}))
.result()
.get()));
in = in.set("dimensions", in.createMap(dimensionsMap));
return in.set("dimensions", in.createMap(dimensionsMap));
}

return in;
Expand Down

0 comments on commit 46c3051

Please sign in to comment.