Skip to content

Commit

Permalink
the ole' switcheroo
Browse files Browse the repository at this point in the history
  • Loading branch information
TropheusJ committed Oct 11, 2023
1 parent 10703a2 commit 7d1e720
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@

import com.google.common.collect.Multimap;

import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.resources.ResourceLocation;

public record EmissiveData(Multimap<ResourceLocation, ResourceLocation> map) {
public Collection<ResourceLocation> getEmissiveTexturesForModel(ResourceLocation id) {
if (id.toString().contains("energy_pellet"))
System.out.println(id);
if (id instanceof ModelResourceLocation modelId && modelId.getVariant().equals("inventory")) {
ResourceLocation sourceFormat = modelId.withPrefix("item/"); // also removes variant
if (id.toString().contains("energy_pellet"))
System.out.println(sourceFormat);
return map.get(sourceFormat);
}
return map.get(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public CompletableFuture<EmissiveData> load(ResourceManager manager, Executor ex
try {
Multimap<ResourceLocation, ResourceLocation> modelToTextures = HashMultimap.create();
GsonHelper.parse(resource.openAsReader()).asMap().forEach((model, element) -> {
ResourceLocation modelId = getModelId(model);
ResourceLocation modelId = getId(model);
List<ResourceLocation> textures = getTextures(element);
modelToTextures.putAll(modelId, textures);
});
Expand All @@ -56,13 +56,4 @@ private static ResourceLocation getId(String path) {
return PortalCubed.id(path);
}
}

private static ResourceLocation getModelId(String model) {
ResourceLocation id = getId(model);
if (id.getPath().startsWith("item/")) {
String path = id.getPath().substring(5);
return new ModelResourceLocation(id.getNamespace(), path, "inventory");
}
return id;
}
}

0 comments on commit 7d1e720

Please sign in to comment.