diff --git a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/OneConfigMixinInit.java b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/OneConfigMixinInit.java index ffa494cb6..1eeaec20e 100644 --- a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/OneConfigMixinInit.java +++ b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/OneConfigMixinInit.java @@ -72,12 +72,6 @@ public List getMixins() { //? if = 1.8.9 //mixins.add("command.Mixin_LegacyChatCompletion"); - //? if = 1.8.9 { - /*mixins.add("legacy.Mixin_PathResourcePack"); - mixins.add("legacy.Mixin_Resource"); - mixins.add("legacy.Mixin_ResourcePackSummaryEntry"); - *///?} - //? moul_compat { RelocatedMixins.INSTANCE.register(e -> { mixins.add(e); diff --git a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/legacy/ornithe/DeferredInputStream.java b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/legacy/ornithe/DeferredInputStream.java deleted file mode 100644 index a4b34f643..000000000 --- a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/legacy/ornithe/DeferredInputStream.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Original file can be found at - * https://github.com/FabricMC/fabric-api/blob/1.14/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/DeferredInputStream.java - * - * Modifications by OrnitheMC: - * - remove unused constructor and method - * - replace Minecraft class reference with OSL equivalent - * - update formatting to match the rest of the project - */ -/* - * 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 org.polyfrost.oneconfig.internal.legacy.ornithe; - -//? if = 1.8.9 { -/*import java.io.IOException; -import java.io.InputStream; - -import net.ornithemc.osl.core.api.util.Unit; - -/^* - * InputStream deferring to a separate I/O thread to work around - * Thread.interrupt()-related issues in NIO. - ^/ -class DeferredInputStream extends InputStream { - - private final InputStream stream; - - DeferredInputStream(InputStream stream) throws IOException { - if (stream == null) { - throw new IOException("Something happened while trying to create an InputStream!"); - } - - this.stream = stream; - } - - @Override - public int available() throws IOException { - return DeferredNioExecutionHandler.submit(this.stream::available); - } - - @Override - public boolean markSupported() { - return this.stream.markSupported(); - } - - @Override - public void mark(int readLimit) { - this.stream.mark(readLimit); - } - - @Override - public void reset() throws IOException { - DeferredNioExecutionHandler.submit(() -> { - this.stream.reset(); - return Unit.INSTANCE; - }); - } - - @Override - public long skip(long n) throws IOException { - return DeferredNioExecutionHandler.submit(() -> this.stream.skip(n)); - } - - @Override - public int read() throws IOException { - return DeferredNioExecutionHandler.submit(this.stream::read); - } - - @Override - public int read(byte[] b) throws IOException { - return DeferredNioExecutionHandler.submit(() -> this.stream.read(b)); - } - - @Override - public int read(byte[] b, int offset, int length) throws IOException { - return DeferredNioExecutionHandler.submit(() -> this.stream.read(b, offset, length)); - } - - @Override - public void close() throws IOException { - DeferredNioExecutionHandler.submit(() -> { - this.stream.close(); - return Unit.INSTANCE; - }); - } -} -*///?} diff --git a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/legacy/ornithe/DeferredNioExecutionHandler.java b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/legacy/ornithe/DeferredNioExecutionHandler.java deleted file mode 100644 index b425d5131..000000000 --- a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/legacy/ornithe/DeferredNioExecutionHandler.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Original file can be found at - * https://github.com/FabricMC/fabric-api/blob/1.14/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/DeferredInputStream.java - * - * Modifications by OrnitheMC: - * - remove unused field and methods - * - update formatting to match the rest of the project - */ -/* - * 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 org.polyfrost.oneconfig.internal.legacy.ornithe; - -//? if = 1.8.9 { -/*import java.io.IOException; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import com.google.common.util.concurrent.ThreadFactoryBuilder; - -class DeferredNioExecutionHandler { - - private static final ThreadLocal DEFERRED_REQUIRED = new ThreadLocal<>(); - private static ExecutorService EXECUTOR_SERVICE; - - public static boolean shouldDefer() { - Boolean deferRequired = DEFERRED_REQUIRED.get(); - - if (deferRequired == null) { - deferRequired = false; - - StackTraceElement[] elements = Thread.currentThread().getStackTrace(); - - for (StackTraceElement element : elements) { - if (element.getClassName().startsWith("paulscode.sound.")) { - deferRequired = true; - break; - } - } - - DEFERRED_REQUIRED.set(deferRequired); - } - - return deferRequired; - } - - public static V submit(Callable callable) throws IOException { - if (EXECUTOR_SERVICE == null) { - EXECUTOR_SERVICE = Executors.newSingleThreadExecutor( - new ThreadFactoryBuilder() - .setNameFormat("OSL Deferred I/O Thread") - .build() - ); - } - - Future future = EXECUTOR_SERVICE.submit(callable); - return getSubmittedFuture(future); - } - - private static V getSubmittedFuture(Future future) throws IOException { - while (true) { - try { - return future.get(); - } catch (ExecutionException e) { - Throwable t = e.getCause(); - - if (t instanceof IOException) { - throw (IOException) t; - } else { - throw new RuntimeException("ExecutionException which should not happen!", t); - } - } catch (InterruptedException e) { - // keep calm, carry on... - } - } - } -} -*///?} diff --git a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/legacy/ornithe/DeferredResource.java b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/legacy/ornithe/DeferredResource.java deleted file mode 100644 index 2f80616a0..000000000 --- a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/legacy/ornithe/DeferredResource.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.polyfrost.oneconfig.internal.legacy.ornithe; - -//? if = 1.8.9 { -/*import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; - -import net.ornithemc.osl.core.api.util.function.IOSupplier; - -/^* Copied from OSL commit adbaa78fadd5092c13db1ec52e48d79f1f9a5ec7's LazyResource. ^/ -public final class DeferredResource { - private DeferredResource() { - } - - public static IOSupplier inputStreamSupplier(Path path) { - return () -> fileInputStream(path); - } - - public static InputStream fileInputStream(Path path) throws IOException { - if (DeferredNioExecutionHandler.shouldDefer()) { - return DeferredNioExecutionHandler.submit(() -> new DeferredInputStream(Files.newInputStream(path))); - } else { - return Files.newInputStream(path); - } - } -} -*///?} diff --git a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/command/Mixin_LegacyChatCompletion.java b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/command/Mixin_LegacyChatCompletion.java index 135d659bc..d5ed42fb9 100644 --- a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/command/Mixin_LegacyChatCompletion.java +++ b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/command/Mixin_LegacyChatCompletion.java @@ -47,7 +47,7 @@ public abstract class Mixin_LegacyChatCompletion { method = "goThroughHistory(Ljava/lang/String;Ljava/lang/String;)V", at = @At( value = "FIELD", - target = "Lnet/minecraft/client/gui/screen/ChatScreen;completed:Z", + target = "Lnet/minecraft/client/gui/screen/game/ChatScreen;completed:Z", opcode = Opcodes.PUTFIELD ) ) diff --git a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/legacy/Mixin_PathResourcePack.java b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/legacy/Mixin_PathResourcePack.java deleted file mode 100644 index ad3cc6be8..000000000 --- a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/legacy/Mixin_PathResourcePack.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.polyfrost.oneconfig.internal.mixin.legacy; - -//? if = 1.8.9 { -/*import java.io.IOException; -import java.io.InputStream; -import java.nio.file.OpenOption; -import java.nio.file.Path; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import net.ornithemc.osl.resource.loader.impl.resource.pack.PathResourcePack; -import org.polyfrost.oneconfig.internal.legacy.ornithe.DeferredResource; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(value = PathResourcePack.class, remap = false) -public abstract class Mixin_PathResourcePack { - @WrapOperation( - method = "getResource(Ljava/lang/String;)Ljava/io/InputStream;", - at = @At( - value = "INVOKE", - target = "Ljava/nio/file/Files;newInputStream(Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/InputStream;" - ) - ) - private InputStream oneconfig$deferInputStream(Path path, OpenOption[] options, Operation original) throws IOException { - return DeferredResource.fileInputStream(path); - } -} -*///?} diff --git a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/legacy/Mixin_Resource.java b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/legacy/Mixin_Resource.java deleted file mode 100644 index 375e7267b..000000000 --- a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/legacy/Mixin_Resource.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.polyfrost.oneconfig.internal.mixin.legacy; - -//? if = 1.8.9 { -/*import java.io.IOException; -import java.io.InputStream; -import java.nio.file.OpenOption; -import java.nio.file.Path; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import net.ornithemc.osl.resource.loader.api.resource.Resource; -import org.polyfrost.oneconfig.internal.legacy.ornithe.DeferredResource; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(value = Resource.class, remap = false) -public interface Mixin_Resource { - @WrapOperation( - method = "lambda$supplier$0", - at = @At( - value = "INVOKE", - target = "Ljava/nio/file/Files;newInputStream(Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/InputStream;" - ) - ) - private static InputStream oneconfig$deferInputStream(Path path, OpenOption[] options, Operation original) throws IOException { - return DeferredResource.fileInputStream(path); - } -} -*///?} diff --git a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/legacy/Mixin_ResourcePackSummaryEntry.java b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/legacy/Mixin_ResourcePackSummaryEntry.java deleted file mode 100644 index f69837ca8..000000000 --- a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/mixin/legacy/Mixin_ResourcePackSummaryEntry.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.polyfrost.oneconfig.internal.mixin.legacy; - -//? if = 1.8.9 { -/*import java.io.IOException; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import net.minecraft.client.Minecraft; -import net.minecraft.client.render.texture.DynamicTexture; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(targets = "net.ornithemc.osl.resource.loader.impl.adapter.ResourcePackSummaryEntry", remap = false) -public class Mixin_ResourcePackSummaryEntry { - @ModifyExpressionValue( - method = "", - at = @At( - value = "FIELD", - target = "Lnet/minecraft/client/render/texture/TextureUtil;MISSING_TEXTURE:Lnet/minecraft/client/render/texture/DynamicTexture;", - remap = true - ), - remap = false - ) - private DynamicTexture oneconfig$useDefaultPackIcon(DynamicTexture missingTexture) { - try { - return new DynamicTexture(Minecraft.getInstance().getResourcePacks().defaultPack.getIcon()); - } catch (IOException e) { - throw new IllegalStateException("Unable to load the default resource pack icon", e); - } - } -} -*///?}