mirror of
https://github.com/FabricMC/fabric.git
synced 2025-03-13 16:53:35 -04:00
Fix ClientSpriteRegistryCallback not being called for some SpriteAtlases
fabric_localIds is no longer needed as all atlases have their own id now.
This commit is contained in:
parent
f3d8141bae
commit
264dbbc635
5 changed files with 6 additions and 79 deletions
|
@ -1,5 +1,5 @@
|
|||
archivesBaseName = "fabric-textures-v0"
|
||||
version = getSubprojectVersion(project, "1.0.0")
|
||||
version = getSubprojectVersion(project, "1.0.1")
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.impl.client.texture;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public interface SpriteAtlasTextureHooks {
|
||||
void onRegisteredAs(Identifier id);
|
||||
}
|
|
@ -44,11 +44,10 @@ import net.minecraft.util.crash.CrashReportSection;
|
|||
|
||||
import net.fabricmc.fabric.api.client.texture.DependentSprite;
|
||||
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
|
||||
import net.fabricmc.fabric.impl.client.texture.SpriteAtlasTextureHooks;
|
||||
import net.fabricmc.fabric.impl.client.texture.SpriteRegistryCallbackHolder;
|
||||
|
||||
@Mixin(SpriteAtlasTexture.class)
|
||||
public abstract class MixinSpriteAtlasTexture implements SpriteAtlasTextureHooks {
|
||||
public abstract class MixinSpriteAtlasTexture {
|
||||
@Unique
|
||||
private static Logger FABRIC_LOGGER = LogManager.getLogger();
|
||||
@Shadow
|
||||
|
@ -57,14 +56,8 @@ public abstract class MixinSpriteAtlasTexture implements SpriteAtlasTextureHooks
|
|||
@Shadow
|
||||
public abstract Sprite getSprite(Identifier id);
|
||||
|
||||
private final Set<Identifier> fabric_localIds = new HashSet<>();
|
||||
|
||||
// EVENT/HOOKS LOGIC
|
||||
|
||||
@Override
|
||||
public void onRegisteredAs(Identifier id) {
|
||||
fabric_localIds.add(id);
|
||||
}
|
||||
@Shadow
|
||||
public abstract Identifier method_24106();
|
||||
|
||||
// INJECTION LOGIC
|
||||
|
||||
|
@ -85,11 +78,7 @@ public abstract class MixinSpriteAtlasTexture implements SpriteAtlasTextureHooks
|
|||
fabric_injectedSprites = new HashMap<>();
|
||||
ClientSpriteRegistryCallback.Registry registry = new ClientSpriteRegistryCallback.Registry(fabric_injectedSprites, set::add);
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (Identifier id : fabric_localIds) {
|
||||
SpriteRegistryCallbackHolder.eventLocal(id).invoker().registerSprites((SpriteAtlasTexture) (Object) this, registry);
|
||||
}
|
||||
|
||||
SpriteRegistryCallbackHolder.eventLocal(method_24106()).invoker().registerSprites((SpriteAtlasTexture) (Object) this, registry);
|
||||
SpriteRegistryCallbackHolder.EVENT_GLOBAL.invoker().registerSprites((SpriteAtlasTexture) (Object) this, registry);
|
||||
|
||||
// TODO: Unoptimized.
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.client.texture;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.client.texture.AbstractTexture;
|
||||
import net.minecraft.client.texture.TextureManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.impl.client.texture.SpriteAtlasTextureHooks;
|
||||
|
||||
@Mixin(TextureManager.class)
|
||||
public class MixinTextureManager {
|
||||
@Inject(at = @At("RETURN"), method = "registerTexture")
|
||||
private void afterRegisterTexture(Identifier identifier, AbstractTexture texture, CallbackInfoReturnable<Boolean> info) {
|
||||
if (texture instanceof SpriteAtlasTextureHooks) {
|
||||
((SpriteAtlasTextureHooks) texture).onRegisteredAs(identifier);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,8 +3,7 @@
|
|||
"package": "net.fabricmc.fabric.mixin.client.texture",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"client": [
|
||||
"MixinSpriteAtlasTexture",
|
||||
"MixinTextureManager"
|
||||
"MixinSpriteAtlasTexture"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Reference in a new issue