Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Jun 15, 2024
1 parent 69aec12 commit 880ee28
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 87 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import me.modmuss50.mpp.ReleaseType
import org.groovymc.modsdotgroovy.core.Platform
import org.groovymc.modsdotgroovy.types.core.Platform

plugins {
id 'maven-publish'
Expand Down
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[versions]
minecraft = "1.20.6"
minecraft = "1.21"
parchment = "2024.04.14"

neoforge = "20.6.1-beta"
neoforge = "21.0.6-beta"

fabric_loader = "0.15.10"
fabric_api = "0.97.8+1.20.6"
fabric_loader = "0.15.11"
fabric_api = "0.100.1+1.21"

fabric_mixin = "0.13.3+mixin.0.8.5"

modsdotgroovy = "2.0.0-beta.22"
modsdotgroovy = "2.0.0-beta.28"

modpublish = "0.5.1"

owolib = "0.12.6+1.20.3"
owolib = "0.12.9+1.20.5"

managedversioning = "1.2.17"
managedversioning = "1.2.19"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pluginManagement {
}

plugins {
id 'dev.lukebemish.conventions' version '0.1.9'
id 'dev.lukebemish.multisource' version '0.1.7'
id 'dev.lukebemish.conventions' version '0.1.10'
id 'dev.lukebemish.multisource' version '0.1.8'
}

rootProject.name = 'dynamicassetgenerator'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import dev.lukebemish.dynamicassetgenerator.impl.client.platform.PlatformClient;
import dev.lukebemish.dynamicassetgenerator.impl.mixin.SpriteSourcesAccessor;
import net.minecraft.client.renderer.texture.atlas.SpriteSource;
import net.minecraft.client.renderer.texture.atlas.SpriteSourceType;
import net.minecraft.resources.ResourceLocation;

@AutoService(PlatformClient.class)
public class PlatformClientImpl implements PlatformClient {
@Override
public void addSpriteSource(ResourceLocation location, MapCodec<? extends SpriteSource> codec) {
SpriteSourcesAccessor.dynamic_asset_generator$invokeRegister(location.toString(), codec);
SpriteSourcesAccessor.dynamic_asset_generator$getTypes().put(location, new SpriteSourceType(codec));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void checkMap() {
DynamicAssetGenerator.LOGGER.error("Error encoding tag file from OwoLib entries: " + e.getMessage());
return;
}
tagMap.put(new ResourceLocation(key.tagId().getNamespace(), "tags/" + key.type() + "/" + key.tagId().getPath() + ".json"),
tagMap.put(ResourceLocation.fromNamespaceAndPath(key.tagId().getNamespace(), "tags/" + key.type() + "/" + key.tagId().getPath() + ".json"),
DynamicAssetGenerator.GSON.toJson(encoded));
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static TrackingResourceSource of(ResourceGenerationContext.ResourceSource

private void addLocation(ResourceLocation location) {
if (location.getPath().startsWith(prefix) && location.getPath().endsWith(suffix)) {
unsafeAddLocation(new ResourceLocation(location.getNamespace(), location.getPath().substring(prefix.length(), location.getPath().length() - suffix.length())));
unsafeAddLocation(ResourceLocation.fromNamespaceAndPath(location.getNamespace(), location.getPath().substring(prefix.length(), location.getPath().length() - suffix.length())));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class AssetResourceCache extends ResourceCache {
* The location of an empty texture, which consists of a single transparent pixel.
*/
@SuppressWarnings("unused")
public static final ResourceLocation EMPTY_TEXTURE = new ResourceLocation(DynamicAssetGenerator.MOD_ID, "empty");
public static final ResourceLocation EMPTY_TEXTURE = ResourceLocation.fromNamespaceAndPath(DynamicAssetGenerator.MOD_ID, "empty");

/**
* @param name a unique identifier for this cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public ResourceSource getResourceSource() {
ResourceGenerationContext trackingContext = context.withResourceSource(trackingSource);
var dataHolder = new TexSourceDataHolder();
IoSupplier<NativeImage> imageSupplier = ResourceUtils.wrapSafeData(
new ResourceLocation(rl.getNamespace(), "textures/"+rl.getPath()+".png"),
ResourceLocation.fromNamespaceAndPath(rl.getNamespace(), "textures/"+rl.getPath()+".png"),
(r, c) -> texSource.getCachedSupplier(dataHolder, c),
trackingContext,
im -> {
Expand Down Expand Up @@ -173,7 +173,7 @@ public ResourceSource getResourceSource() {
TextureMetaGenerator.AnimationGenerator generator = new TextureMetaGenerator.AnimationGenerator.Builder().build();
List<Pair<ResourceLocation, JsonObject>> animations = new ArrayList<>();
for (ResourceLocation touchedTexture : trackingSource.getTouchedTextures()) {
var resource = context.getResourceSource().getResource(new ResourceLocation(touchedTexture.getNamespace(), "textures/"+touchedTexture.getPath()+".png.mcmeta"));
var resource = context.getResourceSource().getResource(ResourceLocation.fromNamespaceAndPath(touchedTexture.getNamespace(), "textures/"+touchedTexture.getPath()+".png.mcmeta"));
if (resource == null) {
animations.add(new Pair<>(touchedTexture, null));
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public IoSupplier<InputStream> get(ResourceLocation outRl, ResourceGenerationCon
}

private ResourceLocation getOutputLocation() {
return new ResourceLocation(this.outputLocation.getNamespace(), "textures/"+this.outputLocation.getPath()+".png");
return ResourceLocation.fromNamespaceAndPath(this.outputLocation.getNamespace(), "textures/"+this.outputLocation.getPath()+".png");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public List<ResourceLocation> getSources() {
public @NonNull <T> DataResult<T> persistentCacheData(DynamicOps<T> ops, ResourceLocation location, ResourceGenerationContext context) {
var builder = ops.listBuilder();
for (var s : sources) {
ResourceLocation metaLocation = new ResourceLocation(s.getNamespace(), "textures/" + s.getPath() + ".png.mcmeta");
ResourceLocation metaLocation = ResourceLocation.fromNamespaceAndPath(s.getNamespace(), "textures/" + s.getPath() + ".png.mcmeta");
var supplier = context.getResourceSource().getResource(metaLocation);
if (supplier == null) {
builder.add(ops.empty());
Expand All @@ -112,7 +112,7 @@ public List<ResourceLocation> getSources() {

return () -> {
List<Pair<ResourceLocation, JsonObject>> originals = sources.stream().<Pair<ResourceLocation, JsonObject>>map(s -> {
ResourceLocation metaLocation = new ResourceLocation(s.getNamespace(), "textures/" + s.getPath() + ".png.mcmeta");
ResourceLocation metaLocation = ResourceLocation.fromNamespaceAndPath(s.getNamespace(), "textures/" + s.getPath() + ".png.mcmeta");
try {
var resource = context.getResourceSource().getResource(metaLocation);
if (resource == null) {
Expand Down Expand Up @@ -150,7 +150,7 @@ public List<ResourceLocation> getSources() {

@Override
public @NonNull Set<ResourceLocation> getLocations(ResourceGenerationContext context) {
return Set.of(new ResourceLocation(outputLocation.getNamespace(),"textures/"+ outputLocation.getPath()+".png.mcmeta"));
return Set.of(ResourceLocation.fromNamespaceAndPath(outputLocation.getNamespace(),"textures/"+ outputLocation.getPath()+".png.mcmeta"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private TextureReaderSource(ResourceLocation path) {

@Override
public IoSupplier<NativeImage> getSupplier(TexSourceDataHolder data, ResourceGenerationContext context) {
ResourceLocation outRl = new ResourceLocation(this.getPath().getNamespace(), "textures/" + this.getPath().getPath() + ".png");
ResourceLocation outRl = ResourceLocation.fromNamespaceAndPath(this.getPath().getNamespace(), "textures/" + this.getPath().getPath() + ".png");
return () -> {
try {
var in = context.getResourceSource().getResource(outRl);
Expand All @@ -56,7 +56,7 @@ public IoSupplier<NativeImage> getSupplier(TexSourceDataHolder data, ResourceGen

@Override
public @NonNull <T> DataResult<T> persistentCacheData(DynamicOps<T> ops, ResourceGenerationContext context) {
ResourceLocation outRl = new ResourceLocation(this.getPath().getNamespace(), "textures/" + this.getPath().getPath() + ".png");
ResourceLocation outRl = ResourceLocation.fromNamespaceAndPath(this.getPath().getNamespace(), "textures/" + this.getPath().getPath() + ".png");
var supplier = context.getResourceSource().getResource(outRl);
if (supplier != null) {
try (var is = supplier.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ public void queue(Map<ResourceLocation, Set<ResourceLocation>> tags) {
}

@Override
public IoSupplier<InputStream> get(ResourceLocation outRl, ResourceGenerationContext context) {
public @Nullable IoSupplier<InputStream> get(ResourceLocation outRl, ResourceGenerationContext context) {
if (!outRl.getPath().startsWith("tags/") || !outRl.getPath().endsWith(".json")) {
return null;
}
return () -> {
checkTags(context);
ResourceLocation tagRl = new ResourceLocation(outRl.getNamespace(), outRl.getPath().substring(5, outRl.getPath().length() - 5));
ResourceLocation tagRl = ResourceLocation.fromNamespaceAndPath(outRl.getNamespace(), outRl.getPath().substring(5, outRl.getPath().length() - 5));
return build(bakedTags.get(tagRl));
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static Pair<String, ResourceLocation> separatePrefix(ResourceLocation loc
String[] parts = location.getPath().split("/", 2);
if (parts.length == 1)
return Pair.of("", location);
return new Pair<>(parts[0], new ResourceLocation(location.getNamespace(), parts[1]));
return new Pair<>(parts[0], ResourceLocation.fromNamespaceAndPath(location.getNamespace(), parts[1]));
}

/**
Expand All @@ -31,6 +31,6 @@ public static Pair<String, ResourceLocation> separateSuffix(ResourceLocation loc
int index = location.getPath().lastIndexOf('.');
if (index == -1)
return Pair.of("", location);
return new Pair<>(location.getPath().substring(index + 1), new ResourceLocation(location.getNamespace(), location.getPath().substring(0, index)));
return new Pair<>(location.getPath().substring(index + 1), ResourceLocation.fromNamespaceAndPath(location.getNamespace(), location.getPath().substring(0, index)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static ModConfig getConfig() {
public static final boolean TIME_RESOURCES = "true".equals(System.getProperty("dynamicassetgenerator.time_resources")) || getConfig().timeResources();

public static void init() {
ResourceGenerator.register(new ResourceLocation(MOD_ID,"dummy"), DummyGenerator.CODEC);
ResourceGenerator.register(ResourceLocation.fromNamespaceAndPath(MOD_ID,"dummy"), DummyGenerator.CODEC);
if (TIME_RESOURCES) {
LOGGER.info("Dynamic Asset Generator will time resource generation during this run!");
try {
Expand All @@ -58,7 +58,7 @@ public static void init() {
LOGGER.error("Issue deleting times.log; you might be able to ignore this", e);
}
}
ResourceCache.register(new BuiltinDataResourceCache(new ResourceLocation(MOD_ID, "builtin_data")), Pack.Position.TOP);
ResourceCache.register(new BuiltinDataResourceCache(ResourceLocation.fromNamespaceAndPath(MOD_ID, "builtin_data")), Pack.Position.TOP);
}

public static Path cache(ResourceLocation cacheKey, boolean keyed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.Optional;

public record BuiltinSpriteProvider(Map<ResourceLocation, TexSource> sources, @Nullable ResourceLocation location) implements SpriteProvider<BuiltinSpriteProvider> {
public static final ResourceLocation LOCATION = new ResourceLocation(DynamicAssetGenerator.MOD_ID, "tex_sources");
public static final ResourceLocation LOCATION = ResourceLocation.fromNamespaceAndPath(DynamicAssetGenerator.MOD_ID, "tex_sources");
public static final MapCodec<BuiltinSpriteProvider> CODEC = RecordCodecBuilder.mapCodec(i -> i.group(
Codec.unboundedMap(ResourceLocation.CODEC, TexSource.CODEC).fieldOf("sources").forGetter(BuiltinSpriteProvider::sources),
ResourceLocation.CODEC.optionalFieldOf("location").forGetter(s -> Optional.ofNullable(s.location()))
Expand Down
Loading

0 comments on commit 880ee28

Please sign in to comment.