-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from dima-dencep/1.20.x/dev
4.0.7
- Loading branch information
Showing
18 changed files
with
235 additions
and
102 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
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
77 changes: 77 additions & 0 deletions
77
.../java/org/redlance/dima_dencep/mods/rrls/mixins/workaround/SimpleReloadInstanceMixin.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,77 @@ | ||
/* | ||
* Copyright 2023 - 2024 dima_dencep. | ||
* | ||
* Licensed under the Open Software License, Version 3.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* You may obtain a copy of the License at | ||
* https://spdx.org/licenses/OSL-3.0.txt | ||
*/ | ||
|
||
package org.redlance.dima_dencep.mods.rrls.mixins.workaround; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiSpriteManager; | ||
import net.minecraft.client.gui.font.FontManager; | ||
import net.minecraft.client.resources.SplashManager; | ||
import net.minecraft.client.resources.language.LanguageManager; | ||
import net.minecraft.server.packs.resources.PreparableReloadListener; | ||
import net.minecraft.util.Unit; | ||
import org.redlance.dima_dencep.mods.rrls.ConfigExpectPlatform; | ||
import org.redlance.dima_dencep.mods.rrls.Rrls; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CompletionStage; | ||
import java.util.function.BiFunction; | ||
|
||
@Mixin(targets = "net.minecraft.server.packs.resources.SimpleReloadInstance$1") | ||
public class SimpleReloadInstanceMixin { | ||
@Shadow | ||
@Final | ||
PreparableReloadListener val$listener; | ||
|
||
@WrapOperation( | ||
method = "wait", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Ljava/util/concurrent/CompletableFuture;thenCombine(Ljava/util/concurrent/CompletionStage;Ljava/util/function/BiFunction;)Ljava/util/concurrent/CompletableFuture;" | ||
) | ||
) | ||
public <U, V> CompletableFuture<V> rrls$async(CompletableFuture<Unit> instance, CompletionStage<? extends U> other, BiFunction<?, ? super U, ? extends V> fn, Operation<CompletableFuture<V>> original) { | ||
if (ConfigExpectPlatform.forceClose() && rrls$filterListener()) { | ||
Rrls.LOGGER.info("Skip wait for {}!", val$listener.getName()); | ||
|
||
return CompletableFuture.completedFuture(fn.apply(null, null)); | ||
} | ||
|
||
return original.call(instance, other, fn); | ||
} | ||
|
||
@Unique | ||
private boolean rrls$filterListener() { | ||
if (this.val$listener instanceof FontManager fontManager) { | ||
return !fontManager.fontSets.containsKey(Minecraft.DEFAULT_FONT); | ||
} | ||
|
||
if (this.val$listener instanceof LanguageManager languageManager) { | ||
return languageManager.getLanguages().size() == 1; | ||
} | ||
|
||
if (this.val$listener instanceof SplashManager splashManager) { | ||
return splashManager.splashes.isEmpty(); | ||
} | ||
|
||
if (this.val$listener instanceof GuiSpriteManager spriteManager) { | ||
return spriteManager.textureAtlas.texturesByName.isEmpty(); | ||
} | ||
|
||
return false; | ||
} | ||
} |
Oops, something went wrong.