-
Notifications
You must be signed in to change notification settings - Fork 811
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split leftover platform specific code out of common, fix remaining wa…
…rnings
- Loading branch information
1 parent
83111dd
commit 6bb29b5
Showing
12 changed files
with
124 additions
and
80 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
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
8 changes: 3 additions & 5 deletions
8
...c/mods/sodium/mixin/core/WindowMixin.java → ...sodium/mixin/fabric/core/WindowMixin.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
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
21 changes: 21 additions & 0 deletions
21
.../java/net/caffeinemc/mods/sodium/neoforge/mixin/core/render/world/LevelRendererMixin.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,21 @@ | ||
package net.caffeinemc.mods.sodium.neoforge.mixin.core.render.world; | ||
|
||
import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer; | ||
import net.minecraft.client.renderer.LevelRenderer; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
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.CallbackInfo; | ||
|
||
import java.util.function.Consumer; | ||
|
||
@Mixin(LevelRenderer.class) | ||
public class LevelRendererMixin { | ||
@Inject(method = "iterateVisibleBlockEntities", at = @At("HEAD"), cancellable = true) | ||
public void replaceBlockEntityIteration(Consumer<BlockEntity> blockEntityConsumer, CallbackInfo ci) { | ||
ci.cancel(); | ||
|
||
SodiumWorldRenderer.instance().iterateVisibleBlockEntities(blockEntityConsumer); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...caffeinemc/mods/sodium/neoforge/mixin/features/gui/hooks/settings/OptionsScreenMixin.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,24 @@ | ||
package net.caffeinemc.mods.sodium.neoforge.mixin.features.gui.hooks.settings; | ||
|
||
import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.client.gui.screens.options.OptionsScreen; | ||
import net.minecraft.network.chat.Component; | ||
import org.spongepowered.asm.mixin.Dynamic; | ||
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; | ||
|
||
@Mixin(OptionsScreen.class) | ||
public class OptionsScreenMixin extends Screen { | ||
protected OptionsScreenMixin(Component title) { | ||
super(title); | ||
} | ||
|
||
@Dynamic | ||
@Inject(method = "lambda$init$2", at = @At("HEAD"), cancellable = true) | ||
private void open(CallbackInfoReturnable<Screen> ci) { | ||
ci.setReturnValue(SodiumOptionsGUI.createScreen(this)); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
.../mods/sodium/neoforge/mixin/features/options/render_layers/ItemBlockRenderTypesMixin.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,30 @@ | ||
package net.caffeinemc.mods.sodium.neoforge.mixin.features.options.render_layers; | ||
|
||
import net.caffeinemc.mods.sodium.client.SodiumClientMod; | ||
import net.minecraft.client.GraphicsStatus; | ||
import net.minecraft.client.renderer.ItemBlockRenderTypes; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ItemBlockRenderTypes.class) | ||
public class ItemBlockRenderTypesMixin { | ||
@Unique | ||
private static boolean leavesFancy; | ||
|
||
// getRenderLayers is a NeoForge only function required for the leaves to properly work. | ||
@Redirect( | ||
method = { "getRenderLayers" }, | ||
at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/ItemBlockRenderTypes;renderCutout:Z")) | ||
private static boolean redirectLeavesShouldBeFancy() { | ||
return leavesFancy; | ||
} | ||
|
||
@Inject(method = "setFancy", at = @At("RETURN")) | ||
private static void onSetFancyGraphicsOrBetter(boolean fancyGraphicsOrBetter, CallbackInfo ci) { | ||
leavesFancy = SodiumClientMod.options().quality.leavesQuality.isFancy(fancyGraphicsOrBetter ? GraphicsStatus.FANCY : GraphicsStatus.FAST); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...a/net/caffeinemc/mods/sodium/neoforge/mixin/workarounds/context_creation/WindowMixin.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,34 @@ | ||
package net.caffeinemc.mods.sodium.neoforge.mixin.workarounds.context_creation; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import com.mojang.blaze3d.platform.Window; | ||
import net.caffeinemc.mods.sodium.client.compatibility.workarounds.Workarounds; | ||
import net.caffeinemc.mods.sodium.client.compatibility.workarounds.nvidia.NvidiaWorkarounds; | ||
import net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
import java.util.function.IntSupplier; | ||
import java.util.function.LongSupplier; | ||
import java.util.function.Supplier; | ||
|
||
@Mixin(Window.class) | ||
public class WindowMixin { | ||
@WrapOperation(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/neoforged/fml/loading/ImmediateWindowHandler;setupMinecraftWindow(Ljava/util/function/IntSupplier;Ljava/util/function/IntSupplier;Ljava/util/function/Supplier;Ljava/util/function/LongSupplier;)J"), remap = false) | ||
private long wrapGlfwCreateWindowForge(final IntSupplier width, final IntSupplier height, final Supplier<String> title, final LongSupplier monitor, Operation<Long> op) { | ||
final boolean applyNvidiaWorkarounds = Workarounds.isWorkaroundEnabled(Workarounds.Reference.NVIDIA_THREADED_OPTIMIZATIONS); | ||
|
||
if (applyNvidiaWorkarounds && !PlatformRuntimeInformation.getInstance().platformHasEarlyLoadingScreen()) { | ||
NvidiaWorkarounds.install(); | ||
} | ||
|
||
try { | ||
return op.call(width, height, title, monitor); | ||
} finally { | ||
if (applyNvidiaWorkarounds) { | ||
NvidiaWorkarounds.uninstall(); | ||
} | ||
} | ||
} | ||
} |
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