Implemented Replacement for fabrics ClientSpriteRegistryCallback
This commit is contained in:
parent
f881e0783f
commit
8b7c4bf9b1
6 changed files with 76 additions and 8 deletions
|
@ -4,6 +4,8 @@ import org.betterx.bclib.api.v2.ModIntegrationAPI;
|
||||||
import org.betterx.bclib.api.v2.PostInitAPI;
|
import org.betterx.bclib.api.v2.PostInitAPI;
|
||||||
import org.betterx.bclib.api.v2.dataexchange.DataExchangeAPI;
|
import org.betterx.bclib.api.v2.dataexchange.DataExchangeAPI;
|
||||||
import org.betterx.bclib.client.models.CustomModelBakery;
|
import org.betterx.bclib.client.models.CustomModelBakery;
|
||||||
|
import org.betterx.bclib.client.textures.AtlasSetManager;
|
||||||
|
import org.betterx.bclib.client.textures.SpriteLister;
|
||||||
import org.betterx.bclib.config.Configs;
|
import org.betterx.bclib.config.Configs;
|
||||||
import org.betterx.bclib.registry.BaseBlockEntityRenders;
|
import org.betterx.bclib.registry.BaseBlockEntityRenders;
|
||||||
import org.betterx.bclib.registry.PresetsRegistryClient;
|
import org.betterx.bclib.registry.PresetsRegistryClient;
|
||||||
|
@ -35,14 +37,9 @@ public class BCLibClient implements ClientModInitializer, ModelResourceProvider,
|
||||||
|
|
||||||
PresetsRegistryClient.onLoad();
|
PresetsRegistryClient.onLoad();
|
||||||
WorldsTogether.SURPRESS_EXPERIMENTAL_DIALOG = Configs.CLIENT_CONFIG.suppressExperimentalDialog();
|
WorldsTogether.SURPRESS_EXPERIMENTAL_DIALOG = Configs.CLIENT_CONFIG.suppressExperimentalDialog();
|
||||||
//dumpDatapack();
|
|
||||||
//TODO: 1.19.3 Find out how to load sprites from custom folders
|
AtlasSetManager.addSource(AtlasSetManager.VANILLA_BLOCKS, new SpriteLister("entity/chest"));
|
||||||
// ClientSpriteRegistryCallback
|
AtlasSetManager.addSource(AtlasSetManager.VANILLA_BLOCKS, new SpriteLister("blocks"));
|
||||||
// .event(TextureAtlas.LOCATION_BLOCKS)
|
|
||||||
// .register((resourceManager, sprites) -> {
|
|
||||||
// SpriteLoader.listSprites(resourceManager, "entity/chest", sprites::put);
|
|
||||||
// SpriteLoader.listSprites(resourceManager, "blocks", sprites::put);
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package org.betterx.bclib.client.textures;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.atlas.SpriteSource;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Environment(value = EnvType.CLIENT)
|
||||||
|
public class AtlasSetManager {
|
||||||
|
public static final ResourceLocation VANILLA_BLOCKS = new ResourceLocation("blocks");
|
||||||
|
private static Map<ResourceLocation, List<SpriteSource>> additionalSets = new HashMap<>();
|
||||||
|
|
||||||
|
public static void addSource(ResourceLocation type, SpriteSource source) {
|
||||||
|
additionalSets.computeIfAbsent(type, (t) -> new LinkedList<>()).add(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onLoadResources(ResourceLocation type, List<SpriteSource> sources) {
|
||||||
|
List<SpriteSource> additionalSources = additionalSets.get(type);
|
||||||
|
if (additionalSources != null) {
|
||||||
|
sources.addAll(additionalSources);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.betterx.bclib.client.textures;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.atlas.sources.DirectoryLister;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
|
@Environment(value = EnvType.CLIENT)
|
||||||
|
public class SpriteLister extends DirectoryLister {
|
||||||
|
public SpriteLister(String string) {
|
||||||
|
super(string, string + "/");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package org.betterx.bclib.mixin.client;
|
||||||
|
|
||||||
|
import org.betterx.bclib.client.textures.AtlasSetManager;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.atlas.SpriteResourceLoader;
|
||||||
|
import net.minecraft.client.renderer.texture.atlas.SpriteSource;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mixin(SpriteResourceLoader.class)
|
||||||
|
public class AtlasSetMixin {
|
||||||
|
@ModifyVariable(method = "load", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/atlas/SpriteResourceLoader;<init>(Ljava/util/List;)V"))
|
||||||
|
private static List<SpriteSource> bcl_load(
|
||||||
|
List<SpriteSource> list,
|
||||||
|
ResourceManager resourceManager,
|
||||||
|
ResourceLocation type
|
||||||
|
) {
|
||||||
|
AtlasSetManager.onLoadResources(type, list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ extendable class net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator
|
||||||
accessible class net/minecraft/core/registries/BuiltInRegistries$RegistryBootstrap
|
accessible class net/minecraft/core/registries/BuiltInRegistries$RegistryBootstrap
|
||||||
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
|
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
|
||||||
accessible class net/minecraft/server/dedicated/DedicatedServerProperties$WorldDimensionData
|
accessible class net/minecraft/server/dedicated/DedicatedServerProperties$WorldDimensionData
|
||||||
|
accessible class net/minecraft/client/resources/model/AtlasSet$AtlasEntry
|
||||||
|
|
||||||
#Methods
|
#Methods
|
||||||
accessible method net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent updateSettings (Lnet/minecraft/client/gui/screens/worldselection/WorldCreationContext$DimensionsUpdater;)V
|
accessible method net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent updateSettings (Lnet/minecraft/client/gui/screens/worldselection/WorldCreationContext$DimensionsUpdater;)V
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"client": [
|
"client": [
|
||||||
"AnvilScreenMixin",
|
"AnvilScreenMixin",
|
||||||
|
"AtlasSetMixin",
|
||||||
"BlockMixin",
|
"BlockMixin",
|
||||||
"ClientRecipeBookMixin",
|
"ClientRecipeBookMixin",
|
||||||
"FogRendererMixin",
|
"FogRendererMixin",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue