-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix various issues with the atlas texture cache (#7)
* refactor: Invalidate the atlas texture cache when reloading resources * fix: Fix cache recreation when reloading resources * fix: Fix mipmapping issues and crashes Also moved some Mixin classes into packages and removed unused code. * fix: Fix cache directory not being deleted recursively when it's out of date * perf: Write cache data to the cache file asynchronously * fix: Fix native crash when writing files Also improved logging and rolled back the `NativeImageAdapter`, because saving the images in JSON is faster than creating hundreds of PNG files. * fix: Fix crash when a JSON element is an instance of `JsonNull` or when an exception occurs * feat: Use enabled resource packs for the atlas texture cache hash * refactor: Change hash name prefix filter to a substring filter * fix: Add missing Mod Menu `modCompilyOnly` * Revert "fix: Add missing Mod Menu `modCompilyOnly`" This reverts commit b748bb7. * fix: Fix crash when getting enabled resource pack names * fix: Fix `ConcurrentModificationException` crash when getting enabled resource pack names
- Loading branch information
1 parent
7460f26
commit f54ca1a
Showing
14 changed files
with
212 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
common/src/main/java/io/github/steveplays28/blinkload/mixin/client/MinecraftClientMixin.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...thub/steveplays28/blinkload/mixin/client/resource/ReloadableResourceManagerImplMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.github.steveplays28.blinkload.mixin.client.resource; | ||
|
||
import io.github.steveplays28.blinkload.client.event.ClientLifecycleEvent; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.resource.ReloadableResourceManagerImpl; | ||
import net.minecraft.resource.ResourcePack; | ||
import net.minecraft.resource.ResourceReload; | ||
import net.minecraft.util.Unit; | ||
import org.jetbrains.annotations.NotNull; | ||
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 java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.Executor; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Mixin(ReloadableResourceManagerImpl.class) | ||
public class ReloadableResourceManagerImplMixin { | ||
@Inject(method = "reload", at = @At(value = "HEAD")) | ||
private void blinkload$invokeBeforeResourceReloadEvent(Executor prepareExecutor, Executor applyExecutor, CompletableFuture<Unit> initialStage, List<ResourcePack> packs, CallbackInfoReturnable<ResourceReload> cir) { | ||
ClientLifecycleEvent.CLIENT_RESOURCE_RELOAD_STARTING.invoker().onClientResourceReloadStarting(); | ||
} | ||
|
||
@Inject(method = "reload", at = @At(value = "RETURN")) | ||
private void blinkload$invokeAfterResourceReloadEvent(Executor prepareExecutor, Executor applyExecutor, CompletableFuture<Unit> initialStage, List<ResourcePack> packs, @NotNull CallbackInfoReturnable<ResourceReload> cir) { | ||
cir.getReturnValue().whenComplete().whenComplete( | ||
(unused, throwable) -> ClientLifecycleEvent.CLIENT_RESOURCE_RELOAD_FINISHED.invoker().onClientResourceReloadFinished()); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...src/main/java/io/github/steveplays28/blinkload/mixin/client/texture/NativeImageMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.github.steveplays28.blinkload.mixin.client.texture; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.texture.NativeImage; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.nio.channels.WritableByteChannel; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Mixin(NativeImage.class) | ||
public abstract class NativeImageMixin { | ||
@Shadow | ||
private long pointer; | ||
|
||
@Inject(method = "write", at = @At(value = "HEAD"), cancellable = true) | ||
private void blinkload$checkIfPointerIsAllocated(WritableByteChannel channel, @NotNull CallbackInfoReturnable<Boolean> cir) { | ||
if (this.pointer == 0L) { | ||
cir.setReturnValue(true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.