Skip to content

Commit

Permalink
Leverage game-provided pack version
Browse files Browse the repository at this point in the history
Signed-off-by: TheSilkMiner <thesilkminer@outlook.com>
  • Loading branch information
TheSilkMiner committed May 18, 2022
1 parent 83bd675 commit 8fa40f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.blamejared.contenttweaker.core.ContentTweakerCore;
import com.blamejared.contenttweaker.core.api.ContentTweakerConstants;
import com.google.gson.JsonObject;
import net.minecraft.SharedConstants;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.packs.PackResources;
Expand Down Expand Up @@ -38,7 +39,7 @@ public void loadPacks(final Consumer<Pack> consumer, final Pack.PackConstructor

private Pack pack(final PackType type, final String id, final RuntimeFragment fragment, final Pack.PackConstructor constructor) {
final String packId = ContentTweakerConstants.rl("runtime/" + fragment.fsId().replace(':', '/')).toString();
final Pack pack = Pack.create(id, true, () -> this.createPack(type, id, packId, fragment), constructor, Pack.Position.TOP, this::decorateSource);
final Pack pack = Pack.create(packId, true, () -> this.createPack(type, id, packId, fragment), constructor, Pack.Position.TOP, this::decorateSource);
if (pack == null) {
throw new IllegalStateException("An error occurred while generating runtime " + ContentTweakerConstants.MOD_NAME + " pack '" + packId + "'");
}
Expand Down Expand Up @@ -67,10 +68,7 @@ private JsonObject makeMetadata(final PackType type, final String packId, final
}

private int makeFormat(final PackType type) {
return switch (type) {
case CLIENT_RESOURCES -> CLIENT_FORMAT;
case SERVER_DATA -> SERVER_FORMAT;
};
return type.getVersion(SharedConstants.getCurrentVersion());
}

private Component decorateSource(final Component originalName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

public class RuntimeResourceManager implements ResourceManager {
public final class RuntimeResourceManager implements ResourceManager {
private record Cleaner(Supplier<? extends Collection<? extends AutoCloseable>> closeables) implements Runnable {
@Override
public void run() {
Expand Down

0 comments on commit 8fa40f8

Please sign in to comment.