diff --git a/build.gradle b/build.gradle index 2039766c0..5eff10c1d 100644 --- a/build.gradle +++ b/build.gradle @@ -12,9 +12,8 @@ buildscript { plugins { id 'signing' - id 'fabric-loom' version '1.6-SNAPSHOT' + id 'fabric-loom' version '1.7-SNAPSHOT' id 'maven-publish' - id 'io.github.juuxel.loom-quiltflower' version '1.10.0' } apply plugin: 'de.guntram.mcmod.crowdin-translate' @@ -55,7 +54,7 @@ repositories { dependencies { //to change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + mappings loom.officialMojangMappings() modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" //modImplementation "me.jellysquid.mods:sodium:0.5.9-snapshot+mc1.21-pre3-build.9" diff --git a/gradle.properties b/gradle.properties index 6443f4085..7feaa3ced 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://modmuss50.me/fabric.html minecraft_version=1.21 yarn_mappings=1.21+build.1 - loader_version=0.15.11 + loader_version=0.16.0 # Mod Properties mod_version=0.5.7 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23a4..09523c0e5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/client/ClientTickHandler.java b/src/main/java/me/flashyreese/mods/sodiumextra/client/ClientTickHandler.java index fb747d113..770454c9b 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/client/ClientTickHandler.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/client/ClientTickHandler.java @@ -13,7 +13,7 @@ public class ClientTickHandler { public void onClientInitialize() { ClientTickEvents.START_CLIENT_TICK.register(minecraftClient -> { - int currentFPS = MinecraftClientAccessor.getCurrentFPS(); + int currentFPS = MinecraftClientAccessor.getFPS(); this.fpsQueue.add(currentFPS); this.averageFps = (int) this.fpsQueue.stream().mapToInt(Integer::intValue).average().orElse(0); this.lowestFps = this.fpsQueue.stream().min(Comparator.comparingInt(e -> e)).orElse(0); diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/SodiumExtraGameOptionPages.java b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/SodiumExtraGameOptionPages.java index a9ba70988..22c62b13c 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/SodiumExtraGameOptionPages.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/SodiumExtraGameOptionPages.java @@ -11,12 +11,12 @@ import me.jellysquid.mods.sodium.client.gui.options.control.SliderControl; import me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl; import me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage; -import net.minecraft.client.MinecraftClient; -import net.minecraft.registry.Registries; -import net.minecraft.text.Text; -import net.minecraft.text.Texts; -import net.minecraft.util.Identifier; -import net.minecraft.world.dimension.DimensionOptionsRegistryHolder; +import net.minecraft.client.Minecraft; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.ComponentUtils; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.levelgen.WorldDimensions; import java.util.*; import java.util.stream.Collectors; @@ -26,8 +26,8 @@ public class SodiumExtraGameOptionPages { public static final SodiumExtraOptionsStorage sodiumExtraOpts = new SodiumExtraOptionsStorage(); public static final MinecraftOptionsStorage vanillaOpts = new MinecraftOptionsStorage(); - private static Text parseVanillaString(String key) { - return Text.literal((Text.translatable(key).getString()).replaceAll("§.", "")); + private static Component parseVanillaString(String key) { + return Component.literal((Component.translatable(key).getString()).replaceAll("§.", "")); } public static OptionPage animation() { @@ -36,7 +36,7 @@ public static OptionPage animation() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.animation").isEnabled()) .setName(parseVanillaString("gui.socialInteractions.tab_all")) - .setTooltip(Text.translatable("sodium-extra.option.animations_all.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.animations_all.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.animationSettings.animation = value, opts -> opts.animationSettings.animation) .setFlags(OptionFlag.REQUIRES_ASSET_RELOAD) @@ -48,7 +48,7 @@ public static OptionPage animation() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.animation").isEnabled()) .setName(parseVanillaString("block.minecraft.water")) - .setTooltip(Text.translatable("sodium-extra.option.animate_water.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.animate_water.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.animationSettings.water = value, opts -> opts.animationSettings.water) .setFlags(OptionFlag.REQUIRES_ASSET_RELOAD) @@ -57,7 +57,7 @@ public static OptionPage animation() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.animation").isEnabled()) .setName(parseVanillaString("block.minecraft.lava")) - .setTooltip(Text.translatable("sodium-extra.option.animate_lava.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.animate_lava.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.animationSettings.lava = value, opts -> opts.animationSettings.lava) .setFlags(OptionFlag.REQUIRES_ASSET_RELOAD) @@ -66,7 +66,7 @@ public static OptionPage animation() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.animation").isEnabled()) .setName(parseVanillaString("block.minecraft.fire")) - .setTooltip(Text.translatable("sodium-extra.option.animate_fire.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.animate_fire.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.animationSettings.fire = value, opts -> opts.animationSettings.fire) .setFlags(OptionFlag.REQUIRES_ASSET_RELOAD) @@ -75,7 +75,7 @@ public static OptionPage animation() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.animation").isEnabled()) .setName(parseVanillaString("block.minecraft.nether_portal")) - .setTooltip(Text.translatable("sodium-extra.option.animate_portal.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.animate_portal.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.animationSettings.portal = value, opts -> opts.animationSettings.portal) .setFlags(OptionFlag.REQUIRES_ASSET_RELOAD) @@ -83,8 +83,8 @@ public static OptionPage animation() { ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.animation").isEnabled()) - .setName(Text.translatable("sodium-extra.option.block_animations")) - .setTooltip(Text.translatable("sodium-extra.option.block_animations.tooltip")) + .setName(Component.translatable("sodium-extra.option.block_animations")) + .setTooltip(Component.translatable("sodium-extra.option.block_animations.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.animationSettings.blockAnimations = value, options -> options.animationSettings.blockAnimations) .setFlags(OptionFlag.REQUIRES_ASSET_RELOAD) @@ -93,14 +93,14 @@ public static OptionPage animation() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.animation").isEnabled()) .setName(parseVanillaString("block.minecraft.sculk_sensor")) - .setTooltip(Text.translatable("sodium-extra.option.animate_sculk_sensor.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.animate_sculk_sensor.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.animationSettings.sculkSensor = value, options -> options.animationSettings.sculkSensor) .setFlags(OptionFlag.REQUIRES_ASSET_RELOAD) .build() ) .build()); - return new OptionPage(Text.translatable("sodium-extra.option.animations"), ImmutableList.copyOf(groups)); + return new OptionPage(Component.translatable("sodium-extra.option.animations"), ImmutableList.copyOf(groups)); } public static OptionPage particle() { @@ -109,7 +109,7 @@ public static OptionPage particle() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.particle").isEnabled()) .setName(parseVanillaString("gui.socialInteractions.tab_all")) - .setTooltip(Text.translatable("sodium-extra.option.particles_all.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.particles_all.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.particleSettings.particles = value, opts -> opts.particleSettings.particles) .build() @@ -120,7 +120,7 @@ public static OptionPage particle() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.particle").isEnabled()) .setName(parseVanillaString("subtitles.entity.generic.splash")) - .setTooltip(Text.translatable("sodium-extra.option.rain_splash.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.rain_splash.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.particleSettings.rainSplash = value, opts -> opts.particleSettings.rainSplash) .build() @@ -128,7 +128,7 @@ public static OptionPage particle() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.particle").isEnabled()) .setName(parseVanillaString("subtitles.block.generic.break")) - .setTooltip(Text.translatable("sodium-extra.option.block_break.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.block_break.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.particleSettings.blockBreak = value, opts -> opts.particleSettings.blockBreak) .build() @@ -136,15 +136,15 @@ public static OptionPage particle() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.particle").isEnabled()) .setName(parseVanillaString("subtitles.block.generic.hit")) - .setTooltip(Text.translatable("sodium-extra.option.block_breaking.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.block_breaking.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.particleSettings.blockBreaking = value, opts -> opts.particleSettings.blockBreaking) .build() ) .build()); - Map> otherParticles = Registries.PARTICLE_TYPE.getIds().stream() - .collect(Collectors.groupingBy(Identifier::getNamespace)); + Map> otherParticles = BuiltInRegistries.PARTICLE_TYPE.keySet().stream() + .collect(Collectors.groupingBy(ResourceLocation::getNamespace)); otherParticles.forEach((namespace, identifiers) -> groups.add(identifiers.stream() .map(identifier -> OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.particle").isEnabled()) @@ -171,24 +171,24 @@ public static OptionPage detail() { groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.sky").isEnabled()) - .setName(Text.translatable("sodium-extra.option.sky")) - .setTooltip(Text.translatable("sodium-extra.option.sky.tooltip")) + .setName(Component.translatable("sodium-extra.option.sky")) + .setTooltip(Component.translatable("sodium-extra.option.sky.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.detailSettings.sky = value, opts -> opts.detailSettings.sky) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.stars").isEnabled()) - .setName(Text.translatable("sodium-extra.option.stars")) - .setTooltip(Text.translatable("sodium-extra.option.stars.tooltip")) + .setName(Component.translatable("sodium-extra.option.stars")) + .setTooltip(Component.translatable("sodium-extra.option.stars.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.detailSettings.stars = value, opts -> opts.detailSettings.stars) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.sun_moon").isEnabled()) - .setName(Text.translatable("sodium-extra.option.sun_moon")) - .setTooltip(Text.translatable("sodium-extra.option.sun_moon.tooltip")) + .setName(Component.translatable("sodium-extra.option.sun_moon")) + .setTooltip(Component.translatable("sodium-extra.option.sun_moon.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.detailSettings.sunMoon = value, opts -> opts.detailSettings.sunMoon) .setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD) @@ -197,15 +197,15 @@ public static OptionPage detail() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.particle").isEnabled()) .setName(parseVanillaString("soundCategory.weather")) - .setTooltip(Text.translatable("sodium-extra.option.rain_snow.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.rain_snow.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.detailSettings.rainSnow = value, opts -> opts.detailSettings.rainSnow) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.biome_colors").isEnabled()) - .setName(Text.translatable("sodium-extra.option.biome_colors")) - .setTooltip(Text.translatable("sodium-extra.option.biome_colors.tooltip")) + .setName(Component.translatable("sodium-extra.option.biome_colors")) + .setTooltip(Component.translatable("sodium-extra.option.biome_colors.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.detailSettings.biomeColors = value, options -> options.detailSettings.biomeColors) .setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD) @@ -213,15 +213,15 @@ public static OptionPage detail() { ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.sky_colors").isEnabled()) - .setName(Text.translatable("sodium-extra.option.sky_colors")) - .setTooltip(Text.translatable("sodium-extra.option.sky_colors.tooltip")) + .setName(Component.translatable("sodium-extra.option.sky_colors")) + .setTooltip(Component.translatable("sodium-extra.option.sky_colors.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.detailSettings.skyColors = value, options -> options.detailSettings.skyColors) .setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD) .build() ) .build()); - return new OptionPage(Text.translatable("sodium-extra.option.details"), ImmutableList.copyOf(groups)); + return new OptionPage(Component.translatable("sodium-extra.option.details"), ImmutableList.copyOf(groups)); } public static OptionPage render() { @@ -230,16 +230,16 @@ public static OptionPage render() { groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.fog").isEnabled()) - .setName(Text.translatable("sodium-extra.option.multi_dimension_fog")) - .setTooltip(Text.translatable("sodium-extra.option.multi_dimension_fog.tooltip")) + .setName(Component.translatable("sodium-extra.option.multi_dimension_fog")) + .setTooltip(Component.translatable("sodium-extra.option.multi_dimension_fog.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.renderSettings.multiDimensionFogControl = value, options -> options.renderSettings.multiDimensionFogControl) .build() ) .add(OptionImpl.createBuilder(int.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.fog_falloff").isEnabled()) - .setName(Text.translatable("sodium-extra.option.fog_start")) - .setTooltip(Text.translatable("sodium-extra.option.fog_start.tooltip")) + .setName(Component.translatable("sodium-extra.option.fog_start")) + .setTooltip(Component.translatable("sodium-extra.option.fog_start.tooltip")) .setControl(option -> new SliderControlExtended(option, 20, 100, 1, ControlValueFormatter.percentage(), false)) .setBinding((options, value) -> options.renderSettings.fogStart = value, options -> options.renderSettings.fogStart) .build() @@ -247,15 +247,15 @@ public static OptionPage render() { .build()); if (SodiumExtraClientMod.options().renderSettings.multiDimensionFogControl) { - DimensionOptionsRegistryHolder - .streamAll(Stream.empty()) - .filter(dim -> !SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.containsKey(dim.getValue())) - .forEach(dim -> SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.put(dim.getValue(), 0)); + WorldDimensions + .keysInOrder(Stream.empty()) + .filter(dim -> !SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.containsKey(dim.location())) + .forEach(dim -> SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.put(dim.location(), 0)); groups.add(SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.keySet().stream() .map(identifier -> OptionImpl.createBuilder(int.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.fog").isEnabled()) - .setName(Text.translatable("sodium-extra.option.fog", translatableName(identifier, "dimensions").getString())) - .setTooltip(Text.translatable("sodium-extra.option.fog.tooltip")) + .setName(Component.translatable("sodium-extra.option.fog", translatableName(identifier, "dimensions").getString())) + .setTooltip(Component.translatable("sodium-extra.option.fog.tooltip")) .setControl(option -> new SliderControlExtended(option, 0, 33, 1, ControlValueFormatterExtended.fogDistance(), false)) .setBinding((opts, val) -> opts.renderSettings.dimensionFogDistanceMap.put(identifier, val), opts -> opts.renderSettings.dimensionFogDistanceMap.getOrDefault(identifier, 0)) @@ -271,8 +271,8 @@ public static OptionPage render() { groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(int.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.fog").isEnabled()) - .setName(Text.translatable("sodium-extra.option.single_fog")) - .setTooltip(Text.translatable("sodium-extra.option.single_fog.tooltip")) + .setName(Component.translatable("sodium-extra.option.single_fog")) + .setTooltip(Component.translatable("sodium-extra.option.single_fog.tooltip")) .setControl(option -> new SliderControlExtended(option, 0, 33, 1, ControlValueFormatterExtended.fogDistance(), false)) .setBinding((options, value) -> options.renderSettings.fogDistance = value, options -> options.renderSettings.fogDistance) .build() @@ -283,8 +283,8 @@ public static OptionPage render() { groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.light_updates").isEnabled()) - .setName(Text.translatable("sodium-extra.option.light_updates")) - .setTooltip(Text.translatable("sodium-extra.option.light_updates.tooltip")) + .setName(Component.translatable("sodium-extra.option.light_updates")) + .setTooltip(Component.translatable("sodium-extra.option.light_updates.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.renderSettings.lightUpdates = value, options -> options.renderSettings.lightUpdates) .build() @@ -294,7 +294,7 @@ public static OptionPage render() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.render.entity").isEnabled()) .setName(parseVanillaString("entity.minecraft.item_frame")) - .setTooltip(Text.translatable("sodium-extra.option.item_frames.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.item_frames.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.renderSettings.itemFrame = value, opts -> opts.renderSettings.itemFrame) .build() @@ -302,7 +302,7 @@ public static OptionPage render() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.render.entity").isEnabled()) .setName(parseVanillaString("entity.minecraft.armor_stand")) - .setTooltip(Text.translatable("sodium-extra.option.armor_stands.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.armor_stands.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.renderSettings.armorStand = value, options -> options.renderSettings.armorStand) .build() @@ -310,7 +310,7 @@ public static OptionPage render() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.render.entity").isEnabled()) .setName(parseVanillaString("entity.minecraft.painting")) - .setTooltip(Text.translatable("sodium-extra.option.paintings.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.paintings.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.renderSettings.painting = value, options -> options.renderSettings.painting) .setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD) @@ -320,24 +320,24 @@ public static OptionPage render() { groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.render.block.entity").isEnabled()) - .setName(Text.translatable("sodium-extra.option.beacon_beam")) - .setTooltip(Text.translatable("sodium-extra.option.beacon_beam.tooltip")) + .setName(Component.translatable("sodium-extra.option.beacon_beam")) + .setTooltip(Component.translatable("sodium-extra.option.beacon_beam.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.renderSettings.beaconBeam = value, opts -> opts.renderSettings.beaconBeam) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.render.block.entity").isEnabled()) - .setName(Text.translatable("sodium-extra.option.limit_beacon_beam_height")) - .setTooltip(Text.translatable("sodium-extra.option.limit_beacon_beam_height.tooltip")) + .setName(Component.translatable("sodium-extra.option.limit_beacon_beam_height")) + .setTooltip(Component.translatable("sodium-extra.option.limit_beacon_beam_height.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.renderSettings.limitBeaconBeamHeight = value, opts -> opts.renderSettings.limitBeaconBeamHeight) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.render.block.entity").isEnabled()) - .setName(Text.translatable("sodium-extra.option.enchanting_table_book")) - .setTooltip(Text.translatable("sodium-extra.option.enchanting_table_book.tooltip")) + .setName(Component.translatable("sodium-extra.option.enchanting_table_book")) + .setTooltip(Component.translatable("sodium-extra.option.enchanting_table_book.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.renderSettings.enchantingTableBook = value, opts -> opts.renderSettings.enchantingTableBook) .build() @@ -345,7 +345,7 @@ public static OptionPage render() { .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.render.block.entity").isEnabled()) .setName(parseVanillaString("block.minecraft.piston")) - .setTooltip(Text.translatable("sodium-extra.option.piston.tooltip")) + .setTooltip(Component.translatable("sodium-extra.option.piston.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.renderSettings.piston = value, options -> options.renderSettings.piston) .build() @@ -354,32 +354,32 @@ public static OptionPage render() { groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.render.entity").isEnabled()) - .setName(Text.translatable("sodium-extra.option.item_frame_name_tag")) - .setTooltip(Text.translatable("sodium-extra.option.item_frame_name_tag.tooltip")) + .setName(Component.translatable("sodium-extra.option.item_frame_name_tag")) + .setTooltip(Component.translatable("sodium-extra.option.item_frame_name_tag.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.renderSettings.itemFrameNameTag = value, opts -> opts.renderSettings.itemFrameNameTag) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.render.entity").isEnabled()) - .setName(Text.translatable("sodium-extra.option.player_name_tag")) - .setTooltip(Text.translatable("sodium-extra.option.player_name_tag.tooltip")) + .setName(Component.translatable("sodium-extra.option.player_name_tag")) + .setTooltip(Component.translatable("sodium-extra.option.player_name_tag.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.renderSettings.playerNameTag = value, options -> options.renderSettings.playerNameTag) .build() ) .build()); - return new OptionPage(Text.translatable("sodium-extra.option.render"), ImmutableList.copyOf(groups)); + return new OptionPage(Component.translatable("sodium-extra.option.render"), ImmutableList.copyOf(groups)); } public static OptionPage extra() { List groups = new ArrayList<>(); groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) - .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.reduce_resolution_on_mac").isEnabled() && MinecraftClient.IS_SYSTEM_MAC) - .setName(Text.translatable("sodium-extra.option.reduce_resolution_on_mac")) - .setTooltip(Text.translatable("sodium-extra.option.reduce_resolution_on_mac.tooltip")) - .setEnabled(MinecraftClient.IS_SYSTEM_MAC) + .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.reduce_resolution_on_mac").isEnabled() && Minecraft.ON_OSX) + .setName(Component.translatable("sodium-extra.option.reduce_resolution_on_mac")) + .setTooltip(Component.translatable("sodium-extra.option.reduce_resolution_on_mac.tooltip")) + .setEnabled(Minecraft.ON_OSX) .setImpact(OptionImpact.HIGH) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.extraSettings.reduceResolutionOnMac = value, opts -> opts.extraSettings.reduceResolutionOnMac) @@ -387,52 +387,52 @@ public static OptionPage extra() { ).build()); groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(SodiumExtraGameOptions.OverlayCorner.class, sodiumExtraOpts) - .setName(Text.translatable("sodium-extra.option.overlay_corner")) - .setTooltip(Text.translatable("sodium-extra.option.overlay_corner.tooltip")) + .setName(Component.translatable("sodium-extra.option.overlay_corner")) + .setTooltip(Component.translatable("sodium-extra.option.overlay_corner.tooltip")) .setControl(option -> new CyclingControl<>(option, SodiumExtraGameOptions.OverlayCorner.class)) .setBinding((opts, value) -> opts.extraSettings.overlayCorner = value, opts -> opts.extraSettings.overlayCorner) .build() ) .add(OptionImpl.createBuilder(SodiumExtraGameOptions.TextContrast.class, sodiumExtraOpts) - .setName(Text.translatable("sodium-extra.option.text_contrast")) - .setTooltip(Text.translatable("sodium-extra.option.text_contrast.tooltip")) + .setName(Component.translatable("sodium-extra.option.text_contrast")) + .setTooltip(Component.translatable("sodium-extra.option.text_contrast.tooltip")) .setControl(option -> new CyclingControl<>(option, SodiumExtraGameOptions.TextContrast.class)) .setBinding((opts, value) -> opts.extraSettings.textContrast = value, opts -> opts.extraSettings.textContrast) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) - .setName(Text.translatable("sodium-extra.option.show_fps")) - .setTooltip(Text.translatable("sodium-extra.option.show_fps.tooltip")) + .setName(Component.translatable("sodium-extra.option.show_fps")) + .setTooltip(Component.translatable("sodium-extra.option.show_fps.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.extraSettings.showFps = value, opts -> opts.extraSettings.showFps) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) - .setName(Text.translatable("sodium-extra.option.show_fps_extended")) - .setTooltip(Text.translatable("sodium-extra.option.show_fps_extended.tooltip")) + .setName(Component.translatable("sodium-extra.option.show_fps_extended")) + .setTooltip(Component.translatable("sodium-extra.option.show_fps_extended.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.extraSettings.showFPSExtended = value, opts -> opts.extraSettings.showFPSExtended) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) - .setName(Text.translatable("sodium-extra.option.show_coordinates")) - .setTooltip(Text.translatable("sodium-extra.option.show_coordinates.tooltip")) + .setName(Component.translatable("sodium-extra.option.show_coordinates")) + .setTooltip(Component.translatable("sodium-extra.option.show_coordinates.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.extraSettings.showCoords = value, opts -> opts.extraSettings.showCoords) .build() ) .add(OptionImpl.createBuilder(int.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.cloud").isEnabled()) - .setName(Text.translatable("sodium-extra.option.cloud_height")) - .setTooltip(Text.translatable("sodium-extra.option.cloud_height.tooltip")) + .setName(Component.translatable("sodium-extra.option.cloud_height")) + .setTooltip(Component.translatable("sodium-extra.option.cloud_height.tooltip")) .setControl(option -> new SliderControl(option, -64, 319, 1, ControlValueFormatter.number())) .setBinding((options, value) -> options.extraSettings.cloudHeight = value, options -> options.extraSettings.cloudHeight) .build() ) .add(OptionImpl.createBuilder(int.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.sodium.cloud").isEnabled()) - .setName(Text.translatable("sodium-extra.option.cloud_distance")) - .setTooltip(Text.translatable("sodium-extra.option.cloud_distance.tooltip")) + .setName(Component.translatable("sodium-extra.option.cloud_distance")) + .setTooltip(Component.translatable("sodium-extra.option.cloud_distance.tooltip")) .setControl(option -> new SliderControl(option, 100, 300, 10, ControlValueFormatter.percentage())) .setBinding((options, value) -> options.extraSettings.cloudDistance = value, options -> options.extraSettings.cloudDistance) .build() @@ -440,8 +440,8 @@ public static OptionPage extra() { .build()); groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, vanillaOpts) - .setName(Text.translatable("sodium-extra.option.advanced_item_tooltips")) - .setTooltip(Text.translatable("sodium-extra.option.advanced_item_tooltips.tooltip")) + .setName(Component.translatable("sodium-extra.option.advanced_item_tooltips")) + .setTooltip(Component.translatable("sodium-extra.option.advanced_item_tooltips.tooltip")) .setControl(TickBoxControl::new) .setBinding((opts, value) -> opts.advancedItemTooltips = value, opts -> opts.advancedItemTooltips) .build() @@ -450,39 +450,39 @@ public static OptionPage extra() { groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.toasts").isEnabled()) - .setName(Text.translatable("sodium-extra.option.toasts")) - .setTooltip(Text.translatable("sodium-extra.option.toasts.tooltip")) + .setName(Component.translatable("sodium-extra.option.toasts")) + .setTooltip(Component.translatable("sodium-extra.option.toasts.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.extraSettings.toasts = value, options -> options.extraSettings.toasts) .build()) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.toasts").isEnabled()) - .setName(Text.translatable("sodium-extra.option.advancement_toast")) - .setTooltip(Text.translatable("sodium-extra.option.advancement_toast.tooltip")) + .setName(Component.translatable("sodium-extra.option.advancement_toast")) + .setTooltip(Component.translatable("sodium-extra.option.advancement_toast.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.extraSettings.advancementToast = value, options -> options.extraSettings.advancementToast) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.toasts").isEnabled()) - .setName(Text.translatable("sodium-extra.option.recipe_toast")) - .setTooltip(Text.translatable("sodium-extra.option.recipe_toast.tooltip")) + .setName(Component.translatable("sodium-extra.option.recipe_toast")) + .setTooltip(Component.translatable("sodium-extra.option.recipe_toast.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.extraSettings.recipeToast = value, options -> options.extraSettings.recipeToast) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.toasts").isEnabled()) - .setName(Text.translatable("sodium-extra.option.system_toast")) - .setTooltip(Text.translatable("sodium-extra.option.system_toast.tooltip")) + .setName(Component.translatable("sodium-extra.option.system_toast")) + .setTooltip(Component.translatable("sodium-extra.option.system_toast.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.extraSettings.systemToast = value, options -> options.extraSettings.systemToast) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.toasts").isEnabled()) - .setName(Text.translatable("sodium-extra.option.tutorial_toast")) - .setTooltip(Text.translatable("sodium-extra.option.tutorial_toast.tooltip")) + .setName(Component.translatable("sodium-extra.option.tutorial_toast")) + .setTooltip(Component.translatable("sodium-extra.option.tutorial_toast.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.extraSettings.tutorialToast = value, options -> options.extraSettings.tutorialToast) .build() @@ -491,16 +491,16 @@ public static OptionPage extra() { groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.instant_sneak").isEnabled()) - .setName(Text.translatable("sodium-extra.option.instant_sneak")) - .setTooltip(Text.translatable("sodium-extra.option.instant_sneak.tooltip")) + .setName(Component.translatable("sodium-extra.option.instant_sneak")) + .setTooltip(Component.translatable("sodium-extra.option.instant_sneak.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.extraSettings.instantSneak = value, options -> options.extraSettings.instantSneak) .build() ) .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.prevent_shaders").isEnabled()) - .setName(Text.translatable("sodium-extra.option.prevent_shaders")) - .setTooltip(Text.translatable("sodium-extra.option.prevent_shaders.tooltip")) + .setName(Component.translatable("sodium-extra.option.prevent_shaders")) + .setTooltip(Component.translatable("sodium-extra.option.prevent_shaders.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.extraSettings.preventShaders = value, options -> options.extraSettings.preventShaders) .setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD) @@ -510,31 +510,31 @@ public static OptionPage extra() { groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.steady_debug_hud").isEnabled()) - .setName(Text.translatable("sodium-extra.option.steady_debug_hud")) - .setTooltip(Text.translatable("sodium-extra.option.steady_debug_hud.tooltip")) + .setName(Component.translatable("sodium-extra.option.steady_debug_hud")) + .setTooltip(Component.translatable("sodium-extra.option.steady_debug_hud.tooltip")) .setControl(TickBoxControl::new) .setBinding((options, value) -> options.extraSettings.steadyDebugHud = value, options -> options.extraSettings.steadyDebugHud) .build() ) .add(OptionImpl.createBuilder(int.class, sodiumExtraOpts) .setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.steady_debug_hud").isEnabled()) - .setName(Text.translatable("sodium-extra.option.steady_debug_hud_refresh_interval")) - .setTooltip(Text.translatable("sodium-extra.option.steady_debug_hud_refresh_interval.tooltip")) + .setName(Component.translatable("sodium-extra.option.steady_debug_hud_refresh_interval")) + .setTooltip(Component.translatable("sodium-extra.option.steady_debug_hud_refresh_interval.tooltip")) .setControl(option -> new SliderControlExtended(option, 1, 20, 1, ControlValueFormatterExtended.ticks(), false)) .setBinding((options, value) -> options.extraSettings.steadyDebugHudRefreshInterval = value, options -> options.extraSettings.steadyDebugHudRefreshInterval) .build() ) .build()); - return new OptionPage(Text.translatable("sodium-extra.option.extras"), ImmutableList.copyOf(groups)); + return new OptionPage(Component.translatable("sodium-extra.option.extras"), ImmutableList.copyOf(groups)); } - private static Text translatableName(Identifier identifier, String category) { - String key = identifier.toTranslationKey("options.".concat(category)); + private static Component translatableName(ResourceLocation identifier, String category) { + String key = identifier.toLanguageKey("options.".concat(category)); - Text translatable = Text.translatable(key); - if (!Texts.hasTranslation(translatable)) { - translatable = Text.literal( + Component translatable = Component.translatable(key); + if (!ComponentUtils.isTranslationResolvable(translatable)) { + translatable = Component.literal( Arrays.stream(key.substring(key.lastIndexOf('.') + 1).split("_")) .map(s -> s.substring(0, 1).toUpperCase() + s.substring(1)) .collect(Collectors.joining(" ")) @@ -543,12 +543,12 @@ private static Text translatableName(Identifier identifier, String category) { return translatable; } - private static Text translatableTooltip(Identifier identifier, String category) { - String key = identifier.toTranslationKey("options.".concat(category)).concat(".tooltip"); + private static Component translatableTooltip(ResourceLocation identifier, String category) { + String key = identifier.toLanguageKey("options.".concat(category)).concat(".tooltip"); - Text translatable = Text.translatable(key); - if (!Texts.hasTranslation(translatable)) { - translatable = Text.translatable( + Component translatable = Component.translatable(key); + if (!ComponentUtils.isTranslationResolvable(translatable)) { + translatable = Component.translatable( "sodium-extra.option.".concat(category).concat(".tooltips"), translatableName(identifier, category) ); diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/SodiumExtraGameOptions.java b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/SodiumExtraGameOptions.java index 58494de7a..9541fa10a 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/SodiumExtraGameOptions.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/SodiumExtraGameOptions.java @@ -8,8 +8,8 @@ import it.unimi.dsi.fastutil.objects.Object2IntArrayMap; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; import me.jellysquid.mods.sodium.client.gui.options.TextProvider; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import org.lwjgl.glfw.GLFW; import java.io.File; @@ -22,7 +22,7 @@ public class SodiumExtraGameOptions { private static final Gson gson = new GsonBuilder() - .registerTypeAdapter(Identifier.class, new Identifier.Serializer()) + .registerTypeAdapter(ResourceLocation.class, new ResourceLocation.Serializer()) .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .setPrettyPrinting() .excludeFieldsWithModifiers(Modifier.PRIVATE) @@ -78,14 +78,14 @@ public enum OverlayCorner implements TextProvider { BOTTOM_LEFT("sodium-extra.option.overlay_corner.bottom_left"), BOTTOM_RIGHT("sodium-extra.option.overlay_corner.bottom_right"); - private final Text text; + private final Component text; OverlayCorner(String text) { - this.text = Text.translatable(text); + this.text = Component.translatable(text); } @Override - public Text getLocalizedName() { + public Component getLocalizedName() { return this.text; } } @@ -95,14 +95,14 @@ public enum TextContrast implements TextProvider { BACKGROUND("sodium-extra.option.text_contrast.background"), SHADOW("sodium-extra.option.text_contrast.shadow"); - private final Text text; + private final Component text; TextContrast(String text) { - this.text = Text.translatable(text); + this.text = Component.translatable(text); } @Override - public Text getLocalizedName() { + public Component getLocalizedName() { return this.text; } } @@ -112,7 +112,7 @@ public enum VerticalSyncOption implements TextProvider { ON("options.on"), ADAPTIVE("sodium-extra.option.use_adaptive_sync.name", GLFW.glfwExtensionSupported("GLX_EXT_swap_control_tear") || GLFW.glfwExtensionSupported("WGL_EXT_swap_control_tear")); - private final Text name; + private final Component name; private final boolean supported; VerticalSyncOption(String name) { @@ -120,7 +120,7 @@ public enum VerticalSyncOption implements TextProvider { } VerticalSyncOption(String name, boolean supported) { - this.name = Text.translatable(name); + this.name = Component.translatable(name); this.supported = supported; } @@ -129,7 +129,7 @@ public static VerticalSyncOption[] getAvailableOptions() { } @Override - public Text getLocalizedName() { + public Component getLocalizedName() { return this.name; } } @@ -160,7 +160,7 @@ public static class ParticleSettings { public boolean blockBreak; public boolean blockBreaking; @SerializedName("other") - public Map otherMap; + public Map otherMap; public ParticleSettings() { this.particles = true; @@ -194,7 +194,7 @@ public static class RenderSettings { public int fogStart; public boolean multiDimensionFogControl; @SerializedName("dimensionFogDistance") - public Map dimensionFogDistanceMap; + public Map dimensionFogDistanceMap; public boolean lightUpdates; public boolean itemFrame; public boolean armorStand; diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/SodiumExtraHud.java b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/SodiumExtraHud.java index bd69f0870..4d2ef5466 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/SodiumExtraHud.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/SodiumExtraHud.java @@ -5,81 +5,81 @@ import me.flashyreese.mods.sodiumextra.mixin.gui.MinecraftClientAccessor; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.RenderTickCounter; -import net.minecraft.text.Text; -import net.minecraft.util.math.Vec3d; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.world.phys.Vec3; import java.util.List; public class SodiumExtraHud implements HudRenderCallback, ClientTickEvents.StartTick { - private final List textList = new ObjectArrayList<>(); + private final List textList = new ObjectArrayList<>(); - private final MinecraftClient client = MinecraftClient.getInstance(); + private final Minecraft client = Minecraft.getInstance(); @Override - public void onStartTick(MinecraftClient client) { + public void onStartTick(Minecraft client) { // Clear the textList to start fresh (this might not be ideal but hey it's still better than whatever the fuck debug hud is doing) this.textList.clear(); if (SodiumExtraClientMod.options().extraSettings.showFps) { - int currentFPS = MinecraftClientAccessor.getCurrentFPS(); + int currentFPS = MinecraftClientAccessor.getFPS(); - Text text = Text.translatable("sodium-extra.overlay.fps", currentFPS); + Component text = Component.translatable("sodium-extra.overlay.fps", currentFPS); if (SodiumExtraClientMod.options().extraSettings.showFPSExtended) - text = Text.literal(String.format("%s %s", text.getString(), Text.translatable("sodium-extra.overlay.fps_extended", SodiumExtraClientMod.getClientTickHandler().getHighestFps(), SodiumExtraClientMod.getClientTickHandler().getAverageFps(), + text = Component.literal(String.format("%s %s", text.getString(), Component.translatable("sodium-extra.overlay.fps_extended", SodiumExtraClientMod.getClientTickHandler().getHighestFps(), SodiumExtraClientMod.getClientTickHandler().getAverageFps(), SodiumExtraClientMod.getClientTickHandler().getLowestFps()).getString())); this.textList.add(text); } - if (SodiumExtraClientMod.options().extraSettings.showCoords && !this.client.hasReducedDebugInfo() && this.client.player != null) { - Vec3d pos = this.client.player.getPos(); + if (SodiumExtraClientMod.options().extraSettings.showCoords && !this.client.showOnlyReducedInfo() && this.client.player != null) { + Vec3 pos = this.client.player.position(); - Text text = Text.translatable("sodium-extra.overlay.coordinates", String.format("%.2f", pos.x), String.format("%.2f", pos.y), String.format("%.2f", pos.z)); + Component text = Component.translatable("sodium-extra.overlay.coordinates", String.format("%.2f", pos.x), String.format("%.2f", pos.y), String.format("%.2f", pos.z)); this.textList.add(text); } if (!SodiumExtraClientMod.options().renderSettings.lightUpdates) { - Text text = Text.translatable("sodium-extra.overlay.light_updates"); + Component text = Component.translatable("sodium-extra.overlay.light_updates"); this.textList.add(text); } } @Override - public void onHudRender(DrawContext drawContext, RenderTickCounter renderTickCounter) { - if (!this.client.getDebugHud().shouldShowDebugHud() && !this.client.options.hudHidden) { + public void onHudRender(GuiGraphics guiGraphics, DeltaTracker deltaTracker) { + if (!this.client.getDebugOverlay().showDebugScreen() && !this.client.options.hideGui) { SodiumExtraGameOptions.OverlayCorner overlayCorner = SodiumExtraClientMod.options().extraSettings.overlayCorner; // Calculate starting position based on the overlay corner int x; int y = overlayCorner == SodiumExtraGameOptions.OverlayCorner.BOTTOM_LEFT || overlayCorner == SodiumExtraGameOptions.OverlayCorner.BOTTOM_RIGHT ? - this.client.getWindow().getScaledHeight() - this.client.textRenderer.fontHeight - 2 : 2; + this.client.getWindow().getGuiScaledHeight() - this.client.font.lineHeight - 2 : 2; // Render each text in the list - for (Text text : this.textList) { + for (Component text : this.textList) { if (overlayCorner == SodiumExtraGameOptions.OverlayCorner.TOP_RIGHT || overlayCorner == SodiumExtraGameOptions.OverlayCorner.BOTTOM_RIGHT) { - x = this.client.getWindow().getScaledWidth() - this.client.textRenderer.getWidth(text) - 2; + x = this.client.getWindow().getGuiScaledWidth() - this.client.font.width(text) - 2; } else { x = 2; } - this.drawString(drawContext, text, x, y); + this.drawString(guiGraphics, text, x, y); if (overlayCorner == SodiumExtraGameOptions.OverlayCorner.BOTTOM_LEFT || overlayCorner == SodiumExtraGameOptions.OverlayCorner.BOTTOM_RIGHT) { - y -= client.textRenderer.fontHeight + 2; + y -= client.font.lineHeight + 2; } else { - y += client.textRenderer.fontHeight + 2; // Increase the y-position for the next text + y += client.font.lineHeight + 2; // Increase the y-position for the next text } } } } - private void drawString(DrawContext drawContext, Text text, int x, int y) { + private void drawString(GuiGraphics guiGraphics, Component text, int x, int y) { int textColor = 0xffffffff; // Default text color if (SodiumExtraClientMod.options().extraSettings.textContrast == SodiumExtraGameOptions.TextContrast.BACKGROUND) { - drawContext.fill(x - 1, y - 1, x + this.client.textRenderer.getWidth(text) + 1, y + this.client.textRenderer.fontHeight + 1, -1873784752); + guiGraphics.fill(x - 1, y - 1, x + this.client.font.width(text) + 1, y + this.client.font.lineHeight + 1, -1873784752); } - drawContext.drawText(this.client.textRenderer, text, x, y, textColor, SodiumExtraClientMod.options().extraSettings.textContrast == SodiumExtraGameOptions.TextContrast.SHADOW); + guiGraphics.drawString(this.client.font, text, x, y, textColor, SodiumExtraClientMod.options().extraSettings.textContrast == SodiumExtraGameOptions.TextContrast.SHADOW); } } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/options/control/SliderControlExtended.java b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/options/control/SliderControlExtended.java index 65f185dbb..584d2034a 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/options/control/SliderControlExtended.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/options/control/SliderControlExtended.java @@ -5,9 +5,9 @@ import me.jellysquid.mods.sodium.client.gui.options.control.ControlElement; import me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter; import me.jellysquid.mods.sodium.client.util.Dim2i; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.util.Mth; import org.apache.commons.lang3.Validate; public class SliderControlExtended implements Control { @@ -76,29 +76,29 @@ public Dim2i getSliderBounds() { } @Override - public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) { - super.render(drawContext, mouseX, mouseY, delta); + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { + super.render(guiGraphics, mouseX, mouseY, delta); if (this.option.isAvailable() && this.hovered) { - this.renderSlider(drawContext); + this.renderSlider(guiGraphics); } else { - this.renderStandaloneValue(drawContext); + this.renderStandaloneValue(guiGraphics); } } - private void renderStandaloneValue(DrawContext drawContext) { + private void renderStandaloneValue(GuiGraphics guiGraphics) { int sliderX = this.getSliderBounds().x(); int sliderY = this.getSliderBounds().y(); int sliderWidth = this.getSliderBounds().width(); int sliderHeight = this.getSliderBounds().height(); - Text label = this.formatter.format(this.option.getValue()); - int labelWidth = this.font.getWidth(label); + Component label = this.formatter.format(this.option.getValue()); + int labelWidth = this.font.width(label); - this.drawString(drawContext, label, sliderX + sliderWidth - labelWidth, sliderY + (sliderHeight / 2) - 4, 0xFFFFFFFF); + this.drawString(guiGraphics, label, sliderX + sliderWidth - labelWidth, sliderY + (sliderHeight / 2) - 4, 0xFFFFFFFF); } - private void renderSlider(DrawContext drawContext) { + private void renderSlider(GuiGraphics guiGraphics) { int sliderX = this.getSliderBounds().x(); int sliderY = this.getSliderBounds().y(); int sliderWidth = this.getSliderBounds().width(); @@ -106,19 +106,19 @@ private void renderSlider(DrawContext drawContext) { this.thumbPosition = this.getThumbPositionForValue(option.getValue()); - double thumbOffset = MathHelper.clamp((double) (this.getIntValue() - this.min) / this.range * sliderWidth, 0, sliderWidth); + double thumbOffset = Mth.clamp((double) (this.getIntValue() - this.min) / this.range * sliderWidth, 0, sliderWidth); double thumbX = sliderX + thumbOffset - THUMB_WIDTH; double trackY = sliderY + (sliderHeight / 2) - ((double) TRACK_HEIGHT / 2); - this.drawRect(drawContext, (int) thumbX, sliderY, (int) (thumbX + (THUMB_WIDTH * 2)), sliderY + sliderHeight, 0xFFFFFFFF); - this.drawRect(drawContext, sliderX, (int) trackY, sliderX + sliderWidth, (int) (trackY + TRACK_HEIGHT), 0xFFFFFFFF); + this.drawRect(guiGraphics, (int) thumbX, sliderY, (int) (thumbX + (THUMB_WIDTH * 2)), sliderY + sliderHeight, 0xFFFFFFFF); + this.drawRect(guiGraphics, sliderX, (int) trackY, sliderX + sliderWidth, (int) (trackY + TRACK_HEIGHT), 0xFFFFFFFF); - Text label = this.displayIntValueWhileSliding ? Text.of(String.valueOf(this.getIntValue())) : this.formatter.format(this.option.getValue()); + Component label = this.displayIntValueWhileSliding ? Component.literal(String.valueOf(this.getIntValue())) : this.formatter.format(this.option.getValue()); - int labelWidth = this.font.getWidth(label); + int labelWidth = this.font.width(label); - this.drawString(drawContext, label, sliderX - labelWidth - 6, sliderY + (sliderHeight / 2) - 4, 0xFFFFFFFF); + this.drawString(guiGraphics, label, sliderX - labelWidth - 6, sliderY + (sliderHeight / 2) - 4, 0xFFFFFFFF); } public int getIntValue() { @@ -149,7 +149,7 @@ private void setValueFromMouse(double d) { } private void setValue(double d) { - this.thumbPosition = MathHelper.clamp(d, 0.0D, 1.0D); + this.thumbPosition = Mth.clamp(d, 0.0D, 1.0D); int value = this.getIntValue(); diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/AbstractFrame.java b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/AbstractFrame.java index 91ab9c6aa..e1186e8e0 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/AbstractFrame.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/AbstractFrame.java @@ -4,21 +4,25 @@ import me.jellysquid.mods.sodium.client.gui.options.control.ControlElement; import me.jellysquid.mods.sodium.client.gui.widgets.AbstractWidget; import me.jellysquid.mods.sodium.client.util.Dim2i; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.*; -import net.minecraft.client.gui.navigation.GuiNavigation; -import net.minecraft.client.gui.navigation.GuiNavigationPath; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ComponentPath; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.Renderable; +import net.minecraft.client.gui.components.events.ContainerEventHandler; +import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.client.gui.navigation.FocusNavigationEvent; +import net.minecraft.client.gui.navigation.ScreenRectangle; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; -public abstract class AbstractFrame extends AbstractWidget implements ParentElement { +public abstract class AbstractFrame extends AbstractWidget implements ContainerEventHandler { protected final Dim2i dim; protected final List children = new ArrayList<>(); - protected final List drawable = new ArrayList<>(); + protected final List renderable = new ArrayList<>(); protected final List> controlElements = new ArrayList<>(); - private Element focused; + private GuiEventListener focused; private boolean dragging; public AbstractFrame(Dim2i dim) { @@ -26,29 +30,29 @@ public AbstractFrame(Dim2i dim) { } public void buildFrame() { - for (Element element : this.children) { + for (GuiEventListener element : this.children) { if (element instanceof AbstractFrame) { this.controlElements.addAll(((AbstractFrame) element).controlElements); } if (element instanceof ControlElement) { this.controlElements.add((ControlElement) element); } - if (element instanceof Drawable) { - this.drawable.add((Drawable) element); + if (element instanceof Renderable) { + this.renderable.add((Renderable) element); } } } @Override - public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) { - for (Drawable drawable : this.drawable) { - drawable.render(drawContext, mouseX, mouseY, delta); + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { + for (Renderable renderable : this.renderable) { + renderable.render(guiGraphics, mouseX, mouseY, delta); } } public void applyScissor(int x, int y, int width, int height, Runnable action) { - double scale = MinecraftClient.getInstance().getWindow().getScaleFactor(); - RenderSystem.enableScissor((int) (x * scale), (int) (MinecraftClient.getInstance().getWindow().getFramebufferHeight() - (y + height) * scale), + double scale = Minecraft.getInstance().getWindow().getGuiScale(); + RenderSystem.enableScissor((int) (x * scale), (int) (Minecraft.getInstance().getWindow().getHeight() - (y + height) * scale), (int) (width * scale), (int) (height * scale)); action.run(); RenderSystem.disableScissor(); @@ -66,17 +70,17 @@ public void setDragging(boolean dragging) { @Nullable @Override - public Element getFocused() { + public GuiEventListener getFocused() { return this.focused; } @Override - public void setFocused(@Nullable Element focused) { + public void setFocused(@Nullable GuiEventListener focused) { this.focused = focused; } @Override - public List children() { + public List children() { return this.children; } @@ -86,12 +90,12 @@ public boolean isMouseOver(double mouseX, double mouseY) { } @Override - public @Nullable GuiNavigationPath getNavigationPath(GuiNavigation navigation) { - return ParentElement.super.getNavigationPath(navigation); + public @Nullable ComponentPath nextFocusPath(FocusNavigationEvent navigation) { + return ContainerEventHandler.super.nextFocusPath(navigation); } @Override - public ScreenRect getNavigationFocus() { - return new ScreenRect(this.dim.x(), this.dim.y(), this.dim.width(), this.dim.height()); + public ScreenRectangle getRectangle() { + return new ScreenRectangle(this.dim.x(), this.dim.y(), this.dim.width(), this.dim.height()); } } \ No newline at end of file diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/OptionPageScrollFrame.java b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/OptionPageScrollFrame.java index 01ba25436..8a827d15a 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/OptionPageScrollFrame.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/OptionPageScrollFrame.java @@ -7,12 +7,12 @@ import me.jellysquid.mods.sodium.client.gui.options.control.Control; import me.jellysquid.mods.sodium.client.gui.options.control.ControlElement; import me.jellysquid.mods.sodium.client.util.Dim2i; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.OrderedText; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.util.Language; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.locale.Language; +import net.minecraft.network.chat.Component; +import net.minecraft.util.FormattedCharSequence; import java.util.ArrayList; import java.util.List; @@ -31,7 +31,7 @@ public OptionPageScrollFrame(Dim2i dim, OptionPage page) { public void setupFrame() { this.children.clear(); - this.drawable.clear(); + this.renderable.clear(); this.controlElements.clear(); int y = 0; @@ -57,7 +57,7 @@ public void buildFrame() { if (this.page == null) return; this.children.clear(); - this.drawable.clear(); + this.renderable.clear(); this.controlElements.clear(); int y = 0; @@ -84,7 +84,7 @@ public void buildFrame() { } @Override - public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { ControlElement hoveredElement = this.controlElements.stream() .filter(ControlElement::isHovered) .findFirst() @@ -92,16 +92,16 @@ public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) .filter(ControlElement::isFocused) .findFirst() .orElse(null)); - this.applyScissor(this.dim.x(), this.dim.y(), this.dim.width(), this.dim.height(), () -> super.render(drawContext, mouseX, mouseY, delta)); + this.applyScissor(this.dim.x(), this.dim.y(), this.dim.width(), this.dim.height(), () -> super.render(guiGraphics, mouseX, mouseY, delta)); if (this.canScroll) { - this.scrollBar.render(drawContext, mouseX, mouseY, delta); + this.scrollBar.render(guiGraphics, mouseX, mouseY, delta); } if (this.dim.containsCursor(mouseX, mouseY) && hoveredElement != null) { - this.renderOptionTooltip(drawContext, hoveredElement); + this.renderOptionTooltip(guiGraphics, hoveredElement); } } - private void renderOptionTooltip(DrawContext drawContext, ControlElement element) { + private void renderOptionTooltip(GuiGraphics guiGraphics, ControlElement element) { Dim2i dim = element.getDimensions(); int textPadding = 3; @@ -113,12 +113,12 @@ private void renderOptionTooltip(DrawContext drawContext, ControlElement elem int boxX = this.dim.getLimitX() + boxPadding; Option option = element.getOption(); - List tooltip = new ArrayList<>(MinecraftClient.getInstance().textRenderer.wrapLines(option.getTooltip(), boxWidth - (textPadding * 2))); + List tooltip = new ArrayList<>(Minecraft.getInstance().font.split(option.getTooltip(), boxWidth - (textPadding * 2))); OptionImpact impact = option.getImpact(); if (impact != null) { - tooltip.add(Language.getInstance().reorder(Text.translatable("sodium.options.performance_impact_string", impact.getLocalizedName()).formatted(Formatting.GRAY))); + tooltip.add(Language.getInstance().getVisualOrder(Component.translatable("sodium.options.performance_impact_string", impact.getLocalizedName()).withStyle(ChatFormatting.GRAY))); } /*if (option.getFlags().contains(OptionFlag.REQUIRES_GAME_RESTART)) { @@ -134,10 +134,10 @@ private void renderOptionTooltip(DrawContext drawContext, ControlElement elem boxY -= boxYLimit - boxYCutoff; } - this.drawRect(drawContext, boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0xE0000000); + this.drawRect(guiGraphics, boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0xE0000000); for (int i = 0; i < tooltip.size(); i++) { - drawContext.drawText(MinecraftClient.getInstance().textRenderer, tooltip.get(i), boxX + textPadding, boxY + textPadding + (i * 12), 0xFFFFFFFF, false); + guiGraphics.drawString(Minecraft.getInstance().font, tooltip.get(i), boxX + textPadding, boxY + textPadding + (i * 12), 0xFFFFFFFF, false); } } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/ScrollBarComponent.java b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/ScrollBarComponent.java index f83856c6b..f3614e9c6 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/ScrollBarComponent.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/ScrollBarComponent.java @@ -2,8 +2,8 @@ import me.jellysquid.mods.sodium.client.gui.widgets.AbstractWidget; import me.jellysquid.mods.sodium.client.util.Dim2i; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.util.Mth; public class ScrollBarComponent extends AbstractWidget { @@ -42,9 +42,9 @@ public void updateThumbPosition() { } @Override - public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) { - this.drawBorder(drawContext, this.dim.x(), this.dim.y(), this.dim.getLimitX(), this.dim.getLimitY(), 0xFFAAAAAA); - this.drawRect(drawContext, this.scrollThumb.x(), this.scrollThumb.y(), this.scrollThumb.getLimitX(), this.scrollThumb.getLimitY(), 0xFFAAAAAA); + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { + this.drawBorder(guiGraphics, this.dim.x(), this.dim.y(), this.dim.getLimitX(), this.dim.getLimitY(), 0xFFAAAAAA); + this.drawRect(guiGraphics, this.scrollThumb.x(), this.scrollThumb.y(), this.scrollThumb.getLimitX(), this.scrollThumb.getLimitY(), 0xFFAAAAAA); } @Override @@ -91,7 +91,7 @@ public int getOffset() { } private void setOffset(int value) { - this.offset = MathHelper.clamp(value, 0, this.maxScrollBarOffset); + this.offset = Mth.clamp(value, 0, this.maxScrollBarOffset); this.updateThumbPosition(); this.onSetOffset.run(); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/client/render/vertex/formats/TextureColorVertex.java b/src/main/java/me/flashyreese/mods/sodiumextra/client/render/vertex/formats/TextureColorVertex.java index e77a775a7..5905cfd72 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/client/render/vertex/formats/TextureColorVertex.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/client/render/vertex/formats/TextureColorVertex.java @@ -1,14 +1,14 @@ package me.flashyreese.mods.sodiumextra.client.render.vertex.formats; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; import net.caffeinemc.mods.sodium.api.math.MatrixHelper; import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription; import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatRegistry; -import net.minecraft.client.render.VertexFormats; import org.joml.Matrix4f; import org.lwjgl.system.MemoryUtil; public class TextureColorVertex { - public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance().get(VertexFormats.POSITION_TEXTURE_COLOR); + public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance().get(DefaultVertexFormat.POSITION_TEX_COLOR); public static final int STRIDE = 24; diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/client/render/vertex/formats/TextureVertex.java b/src/main/java/me/flashyreese/mods/sodiumextra/client/render/vertex/formats/TextureVertex.java index 9f3729712..d2825f1cf 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/client/render/vertex/formats/TextureVertex.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/client/render/vertex/formats/TextureVertex.java @@ -1,14 +1,14 @@ package me.flashyreese.mods.sodiumextra.client.render.vertex.formats; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; import net.caffeinemc.mods.sodium.api.math.MatrixHelper; import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription; import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatRegistry; -import net.minecraft.client.render.VertexFormats; import org.joml.Matrix4f; import org.lwjgl.system.MemoryUtil; public class TextureVertex { - public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance().get(VertexFormats.POSITION_TEXTURE); + public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance().get(DefaultVertexFormat.POSITION_TEX); public static final int STRIDE = 20; diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/client/render/vertex/formats/WeatherVertex.java b/src/main/java/me/flashyreese/mods/sodiumextra/client/render/vertex/formats/WeatherVertex.java index f9975d824..d9bf8ecfd 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/client/render/vertex/formats/WeatherVertex.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/client/render/vertex/formats/WeatherVertex.java @@ -1,16 +1,16 @@ package me.flashyreese.mods.sodiumextra.client.render.vertex.formats; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; import net.caffeinemc.mods.sodium.api.vertex.attributes.common.ColorAttribute; import net.caffeinemc.mods.sodium.api.vertex.attributes.common.LightAttribute; import net.caffeinemc.mods.sodium.api.vertex.attributes.common.PositionAttribute; import net.caffeinemc.mods.sodium.api.vertex.attributes.common.TextureAttribute; import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription; import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatRegistry; -import net.minecraft.client.render.VertexFormats; import org.lwjgl.system.MemoryUtil; public final class WeatherVertex { - public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance().get(VertexFormats.POSITION_TEXTURE_COLOR_LIGHT); + public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance().get(DefaultVertexFormat.PARTICLE); public static final int STRIDE = 28; private static final int OFFSET_POSITION = 0; private static final int OFFSET_TEXTURE = 12; diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/common/util/ControlValueFormatterExtended.java b/src/main/java/me/flashyreese/mods/sodiumextra/common/util/ControlValueFormatterExtended.java index 4b22047a0..8d48dfeab 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/common/util/ControlValueFormatterExtended.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/common/util/ControlValueFormatterExtended.java @@ -1,18 +1,18 @@ package me.flashyreese.mods.sodiumextra.common.util; +import com.mojang.blaze3d.platform.Monitor; import me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.Monitor; -import net.minecraft.text.Text; +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; public interface ControlValueFormatterExtended extends ControlValueFormatter { static ControlValueFormatter resolution() { - Monitor monitor = MinecraftClient.getInstance().getWindow().getMonitor(); + Monitor monitor = Minecraft.getInstance().getWindow().findBestMonitor(); return (v) -> { if (monitor == null) { - return Text.translatable("options.fullscreen.unavailable"); + return Component.translatable("options.fullscreen.unavailable"); } else { - return v == 0 ? Text.translatable("options.fullscreen.current") : Text.literal(monitor.getVideoMode(v - 1).toString()); + return v == 0 ? Component.translatable("options.fullscreen.current") : Component.literal(monitor.getMode(v - 1).toString()); } }; } @@ -20,16 +20,16 @@ static ControlValueFormatter resolution() { static ControlValueFormatter fogDistance() { return (v) -> { if (v == 0) { - return Text.translatable("options.gamma.default"); + return Component.translatable("options.gamma.default"); } else if (v == 33) { - return Text.translatable("options.off"); + return Component.translatable("options.off"); } else { - return Text.translatable("options.chunks", v); + return Component.translatable("options.chunks", v); } }; } static ControlValueFormatter ticks() { - return (v) -> Text.translatable("sodium-extra.units.ticks", v); + return (v) -> Component.translatable("sodium-extra.units.ticks", v); } } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/compat/IrisCompat.java b/src/main/java/me/flashyreese/mods/sodiumextra/compat/IrisCompat.java index 00b24ab99..1f4fbd80b 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/compat/IrisCompat.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/compat/IrisCompat.java @@ -1,6 +1,6 @@ package me.flashyreese.mods.sodiumextra.compat; -import net.minecraft.client.render.VertexFormat; +import com.mojang.blaze3d.vertex.VertexFormat; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/compat/ModelVertexToTerrainSerializer.java b/src/main/java/me/flashyreese/mods/sodiumextra/compat/ModelVertexToTerrainSerializer.java index a6a21ece0..0988e0c7b 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/compat/ModelVertexToTerrainSerializer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/compat/ModelVertexToTerrainSerializer.java @@ -13,7 +13,7 @@ public void serialize(long src, long dst, int vertexCount) { MemoryUtil.memCopy(src + 28L, dst + 24L, 8); // Copies light and normal src += ModelVertex.STRIDE; - dst += IrisCompat.getTerrainFormat().getVertexSizeByte(); + dst += IrisCompat.getTerrainFormat().getVertexSize(); } } } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/adaptive_sync/MixinWindow.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/adaptive_sync/MixinWindow.java index 9e3da5848..285d9ec00 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/adaptive_sync/MixinWindow.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/adaptive_sync/MixinWindow.java @@ -1,7 +1,7 @@ package me.flashyreese.mods.sodiumextra.mixin.adaptive_sync; +import com.mojang.blaze3d.platform.Window; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.util.Window; import org.lwjgl.glfw.GLFW; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -9,7 +9,7 @@ @Mixin(Window.class) public class MixinWindow { - @Redirect(method = "setVsync", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwSwapInterval(I)V", remap = false)) + @Redirect(method = "updateVsync", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwSwapInterval(I)V", remap = false)) private void setSwapInterval(int interval) { if (SodiumExtraClientMod.options().extraSettings.useAdaptiveSync) { if (GLFW.glfwExtensionSupported("GLX_EXT_swap_control_tear") || GLFW.glfwExtensionSupported("WGL_EXT_swap_control_tear")) { diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/animation/MixinSpriteAtlasTexture.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/animation/MixinSpriteAtlasTexture.java index ae2994ea4..b6bfc88da 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/animation/MixinSpriteAtlasTexture.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/animation/MixinSpriteAtlasTexture.java @@ -1,10 +1,10 @@ package me.flashyreese.mods.sodiumextra.mixin.animation; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.texture.AbstractTexture; -import net.minecraft.client.texture.Sprite; -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.util.Identifier; +import net.minecraft.client.renderer.texture.AbstractTexture; +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.resources.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -14,76 +14,76 @@ import java.util.Map; import java.util.function.Supplier; -@Mixin(SpriteAtlasTexture.class) +@Mixin(TextureAtlas.class) public abstract class MixinSpriteAtlasTexture extends AbstractTexture { @Unique - private final Map, List> animatedSprites = Map.of( + private final Map, List> animatedSprites = Map.of( () -> SodiumExtraClientMod.options().animationSettings.water, List.of( - Identifier.of("minecraft", "block/water_still"), - Identifier.of("minecraft", "block/water_flow") + ResourceLocation.fromNamespaceAndPath("minecraft", "block/water_still"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/water_flow") ), () -> SodiumExtraClientMod.options().animationSettings.lava, List.of( - Identifier.of("minecraft", "block/lava_still"), - Identifier.of("minecraft", "block/lava_flow") + ResourceLocation.fromNamespaceAndPath("minecraft", "block/lava_still"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/lava_flow") ), () -> SodiumExtraClientMod.options().animationSettings.portal, List.of( - Identifier.of("minecraft", "block/nether_portal") + ResourceLocation.fromNamespaceAndPath("minecraft", "block/nether_portal") ), () -> SodiumExtraClientMod.options().animationSettings.fire, List.of( - Identifier.of("minecraft", "block/fire_0"), - Identifier.of("minecraft", "block/fire_1"), - Identifier.of("minecraft", "block/soul_fire_0"), - Identifier.of("minecraft", "block/soul_fire_1"), - Identifier.of("minecraft", "block/campfire_fire"), - Identifier.of("minecraft", "block/campfire_log_lit"), - Identifier.of("minecraft", "block/soul_campfire_fire"), - Identifier.of("minecraft", "block/soul_campfire_log_lit") + ResourceLocation.fromNamespaceAndPath("minecraft", "block/fire_0"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/fire_1"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/soul_fire_0"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/soul_fire_1"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/campfire_fire"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/campfire_log_lit"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/soul_campfire_fire"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/soul_campfire_log_lit") ), () -> SodiumExtraClientMod.options().animationSettings.blockAnimations, List.of( - Identifier.of("minecraft", "block/magma"), - Identifier.of("minecraft", "block/lantern"), - Identifier.of("minecraft", "block/sea_lantern"), - Identifier.of("minecraft", "block/soul_lantern"), - Identifier.of("minecraft", "block/kelp"), - Identifier.of("minecraft", "block/kelp_plant"), - Identifier.of("minecraft", "block/seagrass"), - Identifier.of("minecraft", "block/tall_seagrass_top"), - Identifier.of("minecraft", "block/tall_seagrass_bottom"), - Identifier.of("minecraft", "block/warped_stem"), - Identifier.of("minecraft", "block/crimson_stem"), - Identifier.of("minecraft", "block/blast_furnace_front_on"), - Identifier.of("minecraft", "block/smoker_front_on"), - Identifier.of("minecraft", "block/stonecutter_saw"), - Identifier.of("minecraft", "block/prismarine"), - Identifier.of("minecraft", "block/respawn_anchor_top"), - Identifier.of("minecraft", "entity/conduit/wind"), - Identifier.of("minecraft", "entity/conduit/wind_vertical") + ResourceLocation.fromNamespaceAndPath("minecraft", "block/magma"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/lantern"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/sea_lantern"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/soul_lantern"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/kelp"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/kelp_plant"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/seagrass"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/tall_seagrass_top"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/tall_seagrass_bottom"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/warped_stem"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/crimson_stem"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/blast_furnace_front_on"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/smoker_front_on"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/stonecutter_saw"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/prismarine"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/respawn_anchor_top"), + ResourceLocation.fromNamespaceAndPath("minecraft", "entity/conduit/wind"), + ResourceLocation.fromNamespaceAndPath("minecraft", "entity/conduit/wind_vertical") ), () -> SodiumExtraClientMod.options().animationSettings.sculkSensor, List.of( - Identifier.of("minecraft", "block/sculk"), - Identifier.of("minecraft", "block/sculk_catalyst_top_bloom"), - Identifier.of("minecraft", "block/sculk_catalyst_side_bloom"), - Identifier.of("minecraft", "block/sculk_shrieker_inner_top"), - Identifier.of("minecraft", "block/sculk_vein"), - Identifier.of("minecraft", "block/sculk_shrieker_can_summon_inner_top"), - Identifier.of("minecraft", "block/sculk_sensor_tendril_inactive"), - Identifier.of("minecraft", "block/sculk_sensor_tendril_active"), - Identifier.of("minecraft", "vibration") + ResourceLocation.fromNamespaceAndPath("minecraft", "block/sculk"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/sculk_catalyst_top_bloom"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/sculk_catalyst_side_bloom"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/sculk_shrieker_inner_top"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/sculk_vein"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/sculk_shrieker_can_summon_inner_top"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/sculk_sensor_tendril_inactive"), + ResourceLocation.fromNamespaceAndPath("minecraft", "block/sculk_sensor_tendril_active"), + ResourceLocation.fromNamespaceAndPath("minecraft", "vibration") ) ); - @Redirect(method = "upload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/Sprite;createAnimation()Lnet/minecraft/client/texture/Sprite$TickableAnimation;")) - public Sprite.TickableAnimation sodiumExtra$tickAnimatedSprites(Sprite instance) { - Sprite.TickableAnimation tickableAnimation = instance.createAnimation(); - if (tickableAnimation != null && SodiumExtraClientMod.options().animationSettings.animation && this.shouldAnimate(instance.getContents().getId())) + @Redirect(method = "upload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;createTicker()Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$Ticker;")) + public TextureAtlasSprite.Ticker sodiumExtra$tickAnimatedSprites(TextureAtlasSprite instance) { + TextureAtlasSprite.Ticker tickableAnimation = instance.createTicker(); + if (tickableAnimation != null && SodiumExtraClientMod.options().animationSettings.animation && this.shouldAnimate(instance.contents().name())) return tickableAnimation; return null; } @Unique - private boolean shouldAnimate(Identifier identifier) { + private boolean shouldAnimate(ResourceLocation identifier) { if (identifier != null) { - for (Map.Entry, List> supplierListEntry : this.animatedSprites.entrySet()) { + for (Map.Entry, List> supplierListEntry : this.animatedSprites.entrySet()) { if (supplierListEntry.getValue().contains(identifier)) { return supplierListEntry.getKey().get(); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/biome_colors/MixinBiomeColors.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/biome_colors/MixinBiomeColors.java index eeeb30d32..0bc3468d2 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/biome_colors/MixinBiomeColors.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/biome_colors/MixinBiomeColors.java @@ -1,7 +1,7 @@ package me.flashyreese.mods.sodiumextra.mixin.biome_colors; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.color.world.BiomeColors; +import net.minecraft.client.renderer.BiomeColors; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -9,21 +9,21 @@ @Mixin(BiomeColors.class) public class MixinBiomeColors { - @Inject(method = "getGrassColor", at = @At("RETURN"), cancellable = true) + @Inject(method = "getAverageGrassColor", at = @At("RETURN"), cancellable = true) private static void grassColor(CallbackInfoReturnable cir) { if (!SodiumExtraClientMod.options().detailSettings.biomeColors) { cir.setReturnValue(9551193); // 9551193 5877296 } } - @Inject(method = "getWaterColor", at = @At("RETURN"), cancellable = true) + @Inject(method = "getAverageWaterColor", at = @At("RETURN"), cancellable = true) private static void waterColor(CallbackInfoReturnable cir) { if (!SodiumExtraClientMod.options().detailSettings.biomeColors) { cir.setReturnValue(4159204); } } - @Inject(method = "getFoliageColor", at = @At("RETURN"), cancellable = true) + @Inject(method = "getAverageFoliageColor", at = @At("RETURN"), cancellable = true) private static void foliageColor(CallbackInfoReturnable cir) { if (!SodiumExtraClientMod.options().detailSettings.biomeColors) { cir.setReturnValue(5877296); diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/cloud/MixinDimensionEffectsOverworld.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/cloud/MixinDimensionEffectsOverworld.java index 14725db17..87efabe0d 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/cloud/MixinDimensionEffectsOverworld.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/cloud/MixinDimensionEffectsOverworld.java @@ -1,17 +1,17 @@ package me.flashyreese.mods.sodiumextra.mixin.cloud; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.render.DimensionEffects; +import net.minecraft.client.renderer.DimensionSpecialEffects; import org.spongepowered.asm.mixin.Mixin; -@Mixin(DimensionEffects.Overworld.class) -public abstract class MixinDimensionEffectsOverworld extends DimensionEffects { +@Mixin(DimensionSpecialEffects.OverworldEffects.class) +public abstract class MixinDimensionEffectsOverworld extends DimensionSpecialEffects { public MixinDimensionEffectsOverworld(float cloudsHeight, boolean alternateSkyColor, SkyType skyType, boolean brightenLighting, boolean darkened) { super(cloudsHeight, alternateSkyColor, skyType, brightenLighting, darkened); } @Override - public float getCloudsHeight() { + public float getCloudHeight() { return SodiumExtraClientMod.options().extraSettings.cloudHeight; } } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog/MixinBackgroundRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog/MixinFogRenderer.java similarity index 51% rename from src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog/MixinBackgroundRenderer.java rename to src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog/MixinFogRenderer.java index 7e79ceefa..df70b50ba 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog/MixinBackgroundRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog/MixinFogRenderer.java @@ -2,10 +2,10 @@ import com.mojang.blaze3d.systems.RenderSystem; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.block.enums.CameraSubmersionType; -import net.minecraft.client.render.BackgroundRenderer; -import net.minecraft.client.render.Camera; -import net.minecraft.entity.Entity; +import net.minecraft.client.Camera; +import net.minecraft.client.renderer.FogRenderer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.material.FogType; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -13,24 +13,24 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(BackgroundRenderer.class) -public abstract class MixinBackgroundRenderer { +@Mixin(FogRenderer.class) +public abstract class MixinFogRenderer { @Shadow @Nullable - private static BackgroundRenderer.@Nullable StatusEffectFogModifier getFogModifier(Entity entity, float tickDelta) { + protected static FogRenderer.MobEffectFogFunction getPriorityFogFunction(Entity entity, float f) { return null; } - @Inject(method = "applyFog", at = @At(value = "TAIL")) - private static void applyFog(Camera camera, BackgroundRenderer.FogType fogType, float viewDistance, boolean thickFog, float tickDelta, CallbackInfo ci) { - Entity entity = camera.getFocusedEntity(); - SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.putIfAbsent(entity.getWorld().getDimension().effects(), 0); - int fogDistance = SodiumExtraClientMod.options().renderSettings.multiDimensionFogControl ? SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.get(entity.getWorld().getDimension().effects()) : SodiumExtraClientMod.options().renderSettings.fogDistance; - BackgroundRenderer.StatusEffectFogModifier statusEffectFogModifier = getFogModifier(entity, tickDelta); - if (fogDistance == 0 || statusEffectFogModifier != null) { + @Inject(method = "setupFog", at = @At(value = "TAIL")) + private static void applyFog(Camera camera, FogRenderer.FogMode fogType, float viewDistance, boolean thickFog, float tickDelta, CallbackInfo ci) { + Entity entity = camera.getEntity(); + SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.putIfAbsent(entity.level().dimensionType().effectsLocation(), 0); + int fogDistance = SodiumExtraClientMod.options().renderSettings.multiDimensionFogControl ? SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.get(entity.level().dimensionType().effectsLocation()) : SodiumExtraClientMod.options().renderSettings.fogDistance; + FogRenderer.MobEffectFogFunction mobEffectFogFunction = getPriorityFogFunction(entity, tickDelta); + if (fogDistance == 0 || mobEffectFogFunction != null) { return; } - if (camera.getSubmersionType() == CameraSubmersionType.NONE && (thickFog || fogType == BackgroundRenderer.FogType.FOG_TERRAIN)) { + if (camera.getFluidInCamera() == FogType.NONE && (thickFog || fogType == FogRenderer.FogMode.FOG_TERRAIN)) { float fogStart = (float) SodiumExtraClientMod.options().renderSettings.fogStart / 100; if (fogDistance == 33) { RenderSystem.setShaderFogColor(1f, 1f, 1f, 0f); diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog_falloff/MixinBackgroundRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog_falloff/MixinFogRenderer.java similarity index 74% rename from src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog_falloff/MixinBackgroundRenderer.java rename to src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog_falloff/MixinFogRenderer.java index 67bd93993..2a7d20e1d 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog_falloff/MixinBackgroundRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog_falloff/MixinFogRenderer.java @@ -1,14 +1,14 @@ package me.flashyreese.mods.sodiumextra.mixin.fog_falloff; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.render.BackgroundRenderer; +import net.minecraft.client.renderer.FogRenderer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArg; -@Mixin(BackgroundRenderer.class) -public class MixinBackgroundRenderer { - @ModifyArg(method = "applyFog", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderFogStart(F)V"), index = 0) +@Mixin(FogRenderer.class) +public class MixinFogRenderer { + @ModifyArg(method = "setupFog", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderFogStart(F)V"), index = 0) private static float modifySetShaderFogStart(float original) { float fogStart = (float) SodiumExtraClientMod.options().renderSettings.fogStart / 100; return original * fogStart; diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/gui/MinecraftClientAccessor.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/gui/MinecraftClientAccessor.java index 22338b08b..ef5cdba33 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/gui/MinecraftClientAccessor.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/gui/MinecraftClientAccessor.java @@ -1,13 +1,13 @@ package me.flashyreese.mods.sodiumextra.mixin.gui; -import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Minecraft; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -@Mixin(MinecraftClient.class) +@Mixin(Minecraft.class) public interface MinecraftClientAccessor { - @Accessor("currentFps") - static int getCurrentFPS() { + @Accessor("fps") + static int getFPS() { return 0; } } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/instant_sneak/MixinCamera.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/instant_sneak/MixinCamera.java index 4947e54fe..a952f91f7 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/instant_sneak/MixinCamera.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/instant_sneak/MixinCamera.java @@ -1,8 +1,8 @@ package me.flashyreese.mods.sodiumextra.mixin.instant_sneak; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.render.Camera; -import net.minecraft.entity.Entity; +import net.minecraft.client.Camera; +import net.minecraft.world.entity.Entity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -13,15 +13,15 @@ public class MixinCamera { @Shadow - private float cameraY; + private float eyeHeight; @Shadow - private Entity focusedEntity; + private Entity entity; - @Inject(at = @At("HEAD"), method = "updateEyeHeight") + @Inject(at = @At("HEAD"), method = "tick") public void noLerp(CallbackInfo ci) { - if (SodiumExtraClientMod.options().extraSettings.instantSneak && this.focusedEntity != null) { - this.cameraY = this.focusedEntity.getStandingEyeHeight(); + if (SodiumExtraClientMod.options().extraSettings.instantSneak && this.entity != null) { + this.eyeHeight = this.entity.getEyeHeight(); } } } \ No newline at end of file diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/light_updates/MixinLightingProvider.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/light_updates/MixinLevelLightEngine.java similarity index 77% rename from src/main/java/me/flashyreese/mods/sodiumextra/mixin/light_updates/MixinLightingProvider.java rename to src/main/java/me/flashyreese/mods/sodiumextra/mixin/light_updates/MixinLevelLightEngine.java index 74e9b5944..980363181 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/light_updates/MixinLightingProvider.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/light_updates/MixinLevelLightEngine.java @@ -1,23 +1,23 @@ package me.flashyreese.mods.sodiumextra.mixin.light_updates; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.chunk.light.LightingProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.lighting.LevelLightEngine; 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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(LightingProvider.class) -public class MixinLightingProvider { +@Mixin(LevelLightEngine.class) +public class MixinLevelLightEngine { @Inject(at = @At("HEAD"), method = "checkBlock", cancellable = true) public void checkBlock(BlockPos pos, CallbackInfo ci) { if (!SodiumExtraClientMod.options().renderSettings.lightUpdates) ci.cancel(); } - @Inject(at = @At("RETURN"), method = "doLightUpdates", cancellable = true) + @Inject(at = @At("RETURN"), method = "runLightUpdates", cancellable = true) public void doLightUpdates(CallbackInfoReturnable cir) { if (!SodiumExtraClientMod.options().renderSettings.lightUpdates) cir.setReturnValue(0); diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/LevelRendererAccessor.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/LevelRendererAccessor.java new file mode 100644 index 000000000..c774917f9 --- /dev/null +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/LevelRendererAccessor.java @@ -0,0 +1,12 @@ +package me.flashyreese.mods.sodiumextra.mixin.optimizations.beacon_beam_rendering; + +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.culling.Frustum; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(LevelRenderer.class) +public interface LevelRendererAccessor { + @Accessor + Frustum getCullingFrustum(); +} \ No newline at end of file diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/MixinBeaconBlockEntityRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/MixinBeaconRenderer.java similarity index 54% rename from src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/MixinBeaconBlockEntityRenderer.java rename to src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/MixinBeaconRenderer.java index b80ecb7b5..72f9833d9 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/MixinBeaconBlockEntityRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/MixinBeaconRenderer.java @@ -1,21 +1,23 @@ package me.flashyreese.mods.sodiumextra.mixin.optimizations.beacon_beam_rendering; -import me.flashyreese.mods.sodiumextra.common.util.ColorRGBA; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Axis; import me.flashyreese.mods.sodiumextra.compat.IrisCompat; import net.caffeinemc.mods.sodium.api.math.MatrixHelper; import net.caffeinemc.mods.sodium.api.util.ColorARGB; import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; import net.caffeinemc.mods.sodium.api.vertex.format.common.ModelVertex; -import net.minecraft.block.entity.BeaconBlockEntity; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.*; -import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.ColorHelper; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RotationAxis; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.blockentity.BeaconRenderer; +import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.minecraft.world.level.block.entity.BeaconBlockEntity; +import net.minecraft.world.phys.AABB; import org.joml.Matrix3f; import org.joml.Matrix4f; import org.lwjgl.system.MemoryStack; @@ -25,15 +27,15 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(value = BeaconBlockEntityRenderer.class, priority = 1500) -public abstract class MixinBeaconBlockEntityRenderer { +@Mixin(value = BeaconRenderer.class, priority = 1500) +public abstract class MixinBeaconRenderer { /** * @author FlashyReese * @reason Use optimized vertex writer, also avoids unnecessary allocations */ - @Inject(method = "renderBeam(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/util/Identifier;FFJIIIFF)V", at = @At(value = "HEAD"), cancellable = true) - private static void optimizeRenderBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, Identifier textureId, float tickDelta, float heightScale, long worldTime, int yOffset, int maxY, int color, float innerRadius, float outerRadius, CallbackInfo ci) { + @Inject(method = "renderBeaconBeam(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/resources/ResourceLocation;FFJIIIFF)V", at = @At(value = "HEAD"), cancellable = true) + private static void optimizeRenderBeam(PoseStack poseStack, MultiBufferSource multiBufferSource, ResourceLocation resourceLocation, float tickDelta, float heightScale, long worldTime, int yOffset, int maxY, int color, float innerRadius, float outerRadius, CallbackInfo ci) { ci.cancel(); if (IrisCompat.isIrisPresent()) { if (IrisCompat.isRenderingShadowPass()) { @@ -42,13 +44,13 @@ private static void optimizeRenderBeam(MatrixStack matrices, VertexConsumerProvi } int height = yOffset + maxY; - matrices.push(); - matrices.translate(0.5, 0.0, 0.5); + poseStack.pushPose(); + poseStack.translate(0.5, 0.0, 0.5); float time = (float) Math.floorMod(worldTime, 40) + tickDelta; float negativeTime = maxY < 0 ? time : -time; - float fractionalPart = MathHelper.fractionalPart(negativeTime * 0.2F - (float) MathHelper.floor(negativeTime * 0.1F)); - matrices.push(); - matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(time * 2.25F - 45.0F)); + float fractionalPart = Mth.frac(negativeTime * 0.2F - (float) Mth.floor(negativeTime * 0.1F)); + poseStack.pushPose(); + poseStack.mulPose(Axis.YP.rotationDegrees(time * 2.25F - 45.0F)); float innerX1; float innerZ2; float innerX3 = -innerRadius; @@ -60,10 +62,10 @@ private static void optimizeRenderBeam(MatrixStack matrices, VertexConsumerProvi long buffer = stack.nmalloc(2 * 16 * ModelVertex.STRIDE); long ptr = buffer; // Note: ModelVertex color takes in ABGR - ptr = writeBeamLayerVertices(ptr, matrices, ColorARGB.toABGR(color), yOffset, height, 0.0F, innerRadius, innerRadius, 0.0F, innerX3, 0.0F, 0.0F, innerZ4, innerV1, innerV2); - VertexBufferWriter.of(vertexConsumerProvider.getBuffer(RenderLayer.getBeaconBeam(textureId, false))).push(stack, buffer, 16, ModelVertex.FORMAT); + ptr = writeBeamLayerVertices(ptr, poseStack, ColorARGB.toABGR(color), yOffset, height, 0.0F, innerRadius, innerRadius, 0.0F, innerX3, 0.0F, 0.0F, innerZ4, innerV1, innerV2); + VertexBufferWriter.of(multiBufferSource.getBuffer(RenderType.beaconBeam(resourceLocation, false))).push(stack, buffer, 16, ModelVertex.FORMAT); - matrices.pop(); + poseStack.popPose(); innerX1 = -outerRadius; float outerZ1 = -outerRadius; innerZ2 = -outerRadius; @@ -72,17 +74,17 @@ private static void optimizeRenderBeam(MatrixStack matrices, VertexConsumerProvi innerV1 = (float) maxY * heightScale + innerV2; buffer = ptr; - ptr = writeBeamLayerVertices(ptr, matrices, ColorARGB.toABGR(color, 32), yOffset, height, innerX1, outerZ1, outerRadius, innerZ2, innerX3, outerRadius, outerRadius, outerRadius, innerV1, innerV2); - VertexBufferWriter.of(vertexConsumerProvider.getBuffer(RenderLayer.getBeaconBeam(textureId, true))).push(stack, buffer, 16, ModelVertex.FORMAT); + ptr = writeBeamLayerVertices(ptr, poseStack, ColorARGB.toABGR(color, 32), yOffset, height, innerX1, outerZ1, outerRadius, innerZ2, innerX3, outerRadius, outerRadius, outerRadius, innerV1, innerV2); + VertexBufferWriter.of(multiBufferSource.getBuffer(RenderType.beaconBeam(resourceLocation, true))).push(stack, buffer, 16, ModelVertex.FORMAT); } - matrices.pop(); + poseStack.popPose(); } @Unique - private static long writeBeamLayerVertices(long ptr, MatrixStack matrixStack, int color, int yOffset, int height, float x1, float z1, float x2, float z2, float x3, float z3, float x4, float z4, float v1, float v2) { - MatrixStack.Entry entry = matrixStack.peek(); - Matrix4f positionMatrix = entry.getPositionMatrix(); - Matrix3f normalMatrix = entry.getNormalMatrix(); + private static long writeBeamLayerVertices(long ptr, PoseStack poseStack, int color, int yOffset, int height, float x1, float z1, float x2, float z2, float x3, float z3, float x4, float z4, float v1, float v2) { + PoseStack.Pose pose = poseStack.last(); + Matrix4f positionMatrix = pose.pose(); + Matrix3f normalMatrix = pose.normal(); var normal = MatrixHelper.transformNormal(normalMatrix, (float) 0.0, (float) 1.0, (float) 0.0); @@ -114,21 +116,21 @@ private static long transformAndWriteVertex(long ptr, Matrix4f positionMatrix, f float transformedY = MatrixHelper.transformPositionY(positionMatrix, x, y, z); float transformedZ = MatrixHelper.transformPositionZ(positionMatrix, x, y, z); - ModelVertex.write(ptr, transformedX, transformedY, transformedZ, color, u, v, LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV, normal); + ModelVertex.write(ptr, transformedX, transformedY, transformedZ, color, u, v, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, normal); ptr += ModelVertex.STRIDE; return ptr; } - @Inject(method = "render(Lnet/minecraft/block/entity/BeaconBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "HEAD"), cancellable = true) - public void render(BeaconBlockEntity beaconBlockEntity, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j, CallbackInfo ci) { - Frustum frustum = ((WorldRendererAccessor) MinecraftClient.getInstance().worldRenderer).getFrustum(); - Box box = new Box( - beaconBlockEntity.getPos().getX() - 1.0, - beaconBlockEntity.getPos().getY() - 1.0, - beaconBlockEntity.getPos().getZ() - 1.0, - beaconBlockEntity.getPos().getX() + 1.0, - beaconBlockEntity.getPos().getY() + (beaconBlockEntity.getBeamSegments().isEmpty() ? 1.0 : 1024.0), // todo: probably want to limit this to max height vanilla overshoots as well - beaconBlockEntity.getPos().getZ() + 1.0); + @Inject(method = "render(Lnet/minecraft/world/level/block/entity/BeaconBlockEntity;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;II)V", at = @At(value = "HEAD"), cancellable = true) + public void render(BeaconBlockEntity beaconBlockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j, CallbackInfo ci) { + Frustum frustum = ((LevelRendererAccessor) Minecraft.getInstance().levelRenderer).getCullingFrustum(); + AABB box = new AABB( + beaconBlockEntity.getBlockPos().getX() - 1.0, + beaconBlockEntity.getBlockPos().getY() - 1.0, + beaconBlockEntity.getBlockPos().getZ() - 1.0, + beaconBlockEntity.getBlockPos().getX() + 1.0, + beaconBlockEntity.getBlockPos().getY() + (beaconBlockEntity.getBeamSections().isEmpty() ? 1.0 : 1024.0), // todo: probably want to limit this to max height vanilla overshoots as well + beaconBlockEntity.getBlockPos().getZ() + 1.0); if (!frustum.isVisible(box)) { ci.cancel(); diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/MixinVertexSerializerRegistryImpl.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/MixinVertexSerializerRegistryImpl.java index a59d3cb77..a0e5a3fef 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/MixinVertexSerializerRegistryImpl.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/MixinVertexSerializerRegistryImpl.java @@ -1,5 +1,6 @@ package me.flashyreese.mods.sodiumextra.mixin.optimizations.beacon_beam_rendering; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; import it.unimi.dsi.fastutil.longs.Long2ReferenceMap; import me.flashyreese.mods.sodiumextra.compat.IrisCompat; import me.flashyreese.mods.sodiumextra.compat.ModelVertexToTerrainSerializer; @@ -7,7 +8,6 @@ import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription; import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatRegistry; import net.caffeinemc.mods.sodium.api.vertex.serializer.VertexSerializer; -import net.minecraft.client.render.VertexFormats; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -30,7 +30,7 @@ private static long createKey(VertexFormatDescription a, VertexFormatDescription @Inject(method = "", at = @At("TAIL")) private void putSerializerIris(CallbackInfo ci) { if (IrisCompat.isIrisPresent()) { - this.cache.put(createKey(VertexFormatRegistry.instance().get(VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL), VertexFormatRegistry.instance().get(IrisCompat.getTerrainFormat())), new ModelVertexToTerrainSerializer()); + this.cache.put(createKey(VertexFormatRegistry.instance().get(DefaultVertexFormat.NEW_ENTITY), VertexFormatRegistry.instance().get(IrisCompat.getTerrainFormat())), new ModelVertexToTerrainSerializer()); } } } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/WorldRendererAccessor.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/WorldRendererAccessor.java deleted file mode 100644 index 3ec14dc35..000000000 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/beacon_beam_rendering/WorldRendererAccessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package me.flashyreese.mods.sodiumextra.mixin.optimizations.beacon_beam_rendering; - -import net.minecraft.client.render.Frustum; -import net.minecraft.client.render.WorldRenderer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(WorldRenderer.class) -public interface WorldRendererAccessor { - @Accessor - Frustum getFrustum(); -} \ No newline at end of file diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/draw_helpers/MixinDrawContext.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/draw_helpers/MixinGuiGraphics.java similarity index 70% rename from src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/draw_helpers/MixinDrawContext.java rename to src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/draw_helpers/MixinGuiGraphics.java index 032cf0835..c9ef48798 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/draw_helpers/MixinDrawContext.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/draw_helpers/MixinGuiGraphics.java @@ -1,16 +1,18 @@ package me.flashyreese.mods.sodiumextra.mixin.optimizations.draw_helpers; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.*; import me.flashyreese.mods.sodiumextra.client.render.vertex.formats.TextureColorVertex; import me.flashyreese.mods.sodiumextra.client.render.vertex.formats.TextureVertex; import me.flashyreese.mods.sodiumextra.common.util.ColorRGBA; import net.caffeinemc.mods.sodium.api.util.ColorABGR; import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; import net.caffeinemc.mods.sodium.api.vertex.format.common.ColorVertex; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.*; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.resources.ResourceLocation; import org.joml.Matrix4f; import org.lwjgl.system.MemoryStack; import org.spongepowered.asm.mixin.Final; @@ -20,29 +22,29 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(value = DrawContext.class, priority = 1500) -public abstract class MixinDrawContext { +@Mixin(value = GuiGraphics.class, priority = 1500) +public abstract class MixinGuiGraphics { @Shadow @Final - private MatrixStack matrices; + private PoseStack pose; @Shadow @Final - private VertexConsumerProvider.Immediate vertexConsumers; + private MultiBufferSource.BufferSource bufferSource; @Shadow @Deprecated - protected abstract void tryDraw(); + protected abstract void flushIfUnmanaged(); /** * @author FlashyReese * @reason Impl Sodium's vertex writer */ - @Inject(method = "fillGradient(Lnet/minecraft/client/render/VertexConsumer;IIIIIII)V", at = @At(value = "HEAD"), cancellable = true) + @Inject(method = "fillGradient(Lcom/mojang/blaze3d/vertex/VertexConsumer;IIIIIII)V", at = @At(value = "HEAD"), cancellable = true) private void fillGradient(VertexConsumer vertexConsumer, int startX, int startY, int endX, int endY, int z, int colorStart, int colorEnd, CallbackInfo ci) { VertexBufferWriter writer = VertexBufferWriter.of(vertexConsumer); - Matrix4f matrix4f = this.matrices.peek().getPositionMatrix(); + Matrix4f matrix4f = this.pose.last().pose(); colorStart = ColorRGBA.fromOrToABGR(ColorRGBA.fromARGB(colorStart)); colorEnd = ColorRGBA.fromOrToABGR(ColorRGBA.fromARGB(colorEnd)); try (MemoryStack stack = MemoryStack.stackPush()) { @@ -70,9 +72,9 @@ private void fillGradient(VertexConsumer vertexConsumer, int startX, int startY, * @author FlashyReese * @reason Impl Sodium's vertex writer */ - @Inject(method = "fill(Lnet/minecraft/client/render/RenderLayer;IIIIII)V", at = @At(value = "HEAD"), cancellable = true) - public void fill(RenderLayer layer, int x1, int y1, int x2, int y2, int z, int color, CallbackInfo ci) { - Matrix4f matrix4f = this.matrices.peek().getPositionMatrix(); + @Inject(method = "fill(Lnet/minecraft/client/renderer/RenderType;IIIIII)V", at = @At(value = "HEAD"), cancellable = true) + public void fill(RenderType type, int x1, int y1, int x2, int y2, int z, int color, CallbackInfo ci) { + Matrix4f matrix4f = this.pose.last().pose(); if (x1 < x2) { int i = x1; x1 = x2; @@ -84,7 +86,7 @@ public void fill(RenderLayer layer, int x1, int y1, int x2, int y2, int z, int c y1 = y2; y2 = i; } - VertexConsumer vertexConsumer = this.vertexConsumers.getBuffer(layer); + VertexConsumer vertexConsumer = this.bufferSource.getBuffer(type); VertexBufferWriter writer = VertexBufferWriter.of(vertexConsumer); color = ColorRGBA.fromOrToABGR(ColorRGBA.fromARGB(color)); try (MemoryStack stack = MemoryStack.stackPush()) { @@ -105,7 +107,7 @@ public void fill(RenderLayer layer, int x1, int y1, int x2, int y2, int z, int c writer.push(stack, buffer, 4, ColorVertex.FORMAT); } - this.tryDraw(); + this.flushIfUnmanaged(); ci.cancel(); } @@ -114,12 +116,12 @@ public void fill(RenderLayer layer, int x1, int y1, int x2, int y2, int z, int c * @author FlashyReese * @reason Impl Sodium's vertex writer */ - @Inject(method = "drawTexturedQuad(Lnet/minecraft/util/Identifier;IIIIIFFFF)V", at = @At(value = "HEAD"), cancellable = true) - public void drawTexturedQuad(Identifier texture, int x1, int x2, int y1, int y2, int z, float u1, float u2, float v1, float v2, CallbackInfo ci) { + @Inject(method = "innerBlit(Lnet/minecraft/resources/ResourceLocation;IIIIIFFFF)V", at = @At(value = "HEAD"), cancellable = true) + public void drawTexturedQuad(ResourceLocation texture, int x1, int x2, int y1, int y2, int z, float u1, float u2, float v1, float v2, CallbackInfo ci) { RenderSystem.setShaderTexture(0, texture); - RenderSystem.setShader(GameRenderer::getPositionTexProgram); - Matrix4f matrix4f = this.matrices.peek().getPositionMatrix(); - BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + Matrix4f matrix4f = this.pose.last().pose(); + BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); VertexBufferWriter writer = VertexBufferWriter.of(bufferBuilder); try (MemoryStack stack = MemoryStack.stackPush()) { final long buffer = stack.nmalloc(4 * TextureVertex.STRIDE); @@ -139,7 +141,7 @@ public void drawTexturedQuad(Identifier texture, int x1, int x2, int y1, int y2, writer.push(stack, buffer, 4, TextureVertex.FORMAT); } - BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); + BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); ci.cancel(); } @@ -147,13 +149,13 @@ public void drawTexturedQuad(Identifier texture, int x1, int x2, int y1, int y2, * @author FlashyReese * @reason Impl Sodium's vertex writer */ - @Inject(method = "drawTexturedQuad(Lnet/minecraft/util/Identifier;IIIIIFFFFFFFF)V", at = @At(value = "HEAD"), cancellable = true) - public void drawTexturedQuad(Identifier texture, int x1, int x2, int y1, int y2, int z, float u1, float u2, float v1, float v2, float red, float green, float blue, float alpha, CallbackInfo ci) { + @Inject(method = "innerBlit(Lnet/minecraft/resources/ResourceLocation;IIIIIFFFFFFFF)V", at = @At(value = "HEAD"), cancellable = true) + public void drawTexturedQuad(ResourceLocation texture, int x1, int x2, int y1, int y2, int z, float u1, float u2, float v1, float v2, float red, float green, float blue, float alpha, CallbackInfo ci) { RenderSystem.setShaderTexture(0, texture); - RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); + RenderSystem.setShader(GameRenderer::getPositionTexColorShader); RenderSystem.enableBlend(); - Matrix4f matrix4f = this.matrices.peek().getPositionMatrix(); - BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); + Matrix4f matrix4f = this.pose.last().pose(); + BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); VertexBufferWriter writer = VertexBufferWriter.of(bufferBuilder); int color = ColorABGR.pack(red, green, blue, alpha); try (MemoryStack stack = MemoryStack.stackPush()) { @@ -174,7 +176,7 @@ public void drawTexturedQuad(Identifier texture, int x1, int x2, int y1, int y2, writer.push(stack, buffer, 4, TextureColorVertex.FORMAT); } - BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); + BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); RenderSystem.disableBlend(); ci.cancel(); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/fast_weather/MixinWorldRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/fast_weather/MixinLevelRenderer.java similarity index 73% rename from src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/fast_weather/MixinWorldRenderer.java rename to src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/fast_weather/MixinLevelRenderer.java index 167533180..f9fa1bf5c 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/fast_weather/MixinWorldRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/fast_weather/MixinLevelRenderer.java @@ -1,21 +1,24 @@ package me.flashyreese.mods.sodiumextra.mixin.optimizations.fast_weather; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.*; import it.unimi.dsi.fastutil.longs.Long2ReferenceMap; import it.unimi.dsi.fastutil.longs.Long2ReferenceOpenHashMap; import me.flashyreese.mods.sodiumextra.client.render.vertex.formats.WeatherVertex; import me.flashyreese.mods.sodiumextra.common.util.Utils; import net.caffeinemc.mods.sodium.api.util.ColorABGR; import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.*; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.Heightmap; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.levelgen.Heightmap; import org.lwjgl.system.MemoryStack; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -25,65 +28,63 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import static net.minecraft.client.render.WorldRenderer.getLightmapCoordinates; - -@Mixin(value = WorldRenderer.class, priority = 1500) -public class MixinWorldRenderer { +@Mixin(value = LevelRenderer.class, priority = 1500) +public class MixinLevelRenderer { @Shadow @Final - private static Identifier RAIN; + private static ResourceLocation RAIN_LOCATION; @Shadow @Final - private static Identifier SNOW; + private static ResourceLocation SNOW_LOCATION; @Unique private final Long2ReferenceMap biomeLong2ReferenceMap = new Long2ReferenceOpenHashMap<>(); @Shadow @Final - private MinecraftClient client; + private Minecraft minecraft; @Shadow private int ticks; @Shadow @Final - private float[] NORMAL_LINE_DX; + private float[] rainSizeX; @Shadow @Final - private float[] NORMAL_LINE_DZ; + private float[] rainSizeZ; - @Inject(method = "renderWeather", at = @At(value = "HEAD"), cancellable = true) - public void sodiumExtra$renderWeather(LightmapTextureManager manager, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) { - assert this.client.world != null; - float rainGradient = this.client.world.getRainGradient(tickDelta); + @Inject(method = "renderSnowAndRain", at = @At(value = "HEAD"), cancellable = true) + public void sodiumExtra$renderWeather(LightTexture lightTexture, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) { + assert this.minecraft.level != null; + float rainGradient = this.minecraft.level.getRainLevel(tickDelta); if (rainGradient > 0.0F) { - manager.enable(); - World world = this.client.world; - int cameraPosX = MathHelper.floor(cameraX); - int cameraPosY = MathHelper.floor(cameraY); - int cameraPosZ = MathHelper.floor(cameraZ); - Tessellator tessellator = Tessellator.getInstance(); + lightTexture.turnOnLightLayer(); + Level world = this.minecraft.level; + int cameraPosX = Mth.floor(cameraX); + int cameraPosY = Mth.floor(cameraY); + int cameraPosZ = Mth.floor(cameraZ); + Tesselator tessellator = Tesselator.getInstance(); BufferBuilder bufferBuilder = null; RenderSystem.disableCull(); RenderSystem.enableBlend(); RenderSystem.enableDepthTest(); - int range = MinecraftClient.isFancyGraphicsOrBetter() ? 10 : 5; + int range = Minecraft.useFancyGraphics() ? 10 : 5; - RenderSystem.depthMask(MinecraftClient.isFabulousGraphicsOrBetter()); + RenderSystem.depthMask(Minecraft.useShaderTransparency()); int precipitationType = -1; float time = (float) this.ticks + tickDelta; - RenderSystem.setShader(GameRenderer::getParticleProgram); - BlockPos.Mutable mutable = new BlockPos.Mutable(); + RenderSystem.setShader(GameRenderer::getParticleShader); + BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); for (int z = cameraPosZ - range; z <= cameraPosZ + range; ++z) { for (int x = cameraPosX - range; x <= cameraPosX + range; ++x) { int positionIndex = (z - cameraPosZ + 16) * 32 + x - cameraPosX + 16; - double offsetX = (double) this.NORMAL_LINE_DX[positionIndex] * 0.5; - double offsetZ = (double) this.NORMAL_LINE_DZ[positionIndex] * 0.5; + double offsetX = (double) this.rainSizeX[positionIndex] * 0.5; + double offsetZ = (double) this.rainSizeZ[positionIndex] * 0.5; mutable.set(x, cameraY, z); long biomePacked = Utils.packPosition(x, z); Biome biome = this.biomeLong2ReferenceMap.computeIfAbsent(biomePacked, key -> world.getBiome(mutable).value()); if (biome.hasPrecipitation()) { - int topY = world.getTopY(Heightmap.Type.MOTION_BLOCKING, x, z); + int topY = world.getHeight(Heightmap.Types.MOTION_BLOCKING, x, z); int minY = cameraPosY - range; int maxY = cameraPosY + range; if (minY < topY) { @@ -97,18 +98,18 @@ public class MixinWorldRenderer { int adjustedTopY = Math.max(topY, cameraPosY); if (minY != maxY) { - Random random = Random.create((long) x * x * 3121 + x * 45238971L ^ (long) z * z * 418711 + z * 13761L); + RandomSource random = RandomSource.create((long) x * x * 3121 + x * 45238971L ^ (long) z * z * 418711 + z * 13761L); mutable.set(x, minY, z); - Biome.Precipitation precipitation = biome.getPrecipitation(mutable); + Biome.Precipitation precipitation = biome.getPrecipitationAt(mutable); if (precipitation == Biome.Precipitation.RAIN) { if (precipitationType != 0) { if (precipitationType >= 0) { - BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); + BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); } precipitationType = 0; - RenderSystem.setShaderTexture(0, RAIN); - bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR_LIGHT); + RenderSystem.setShaderTexture(0, RAIN_LOCATION); + bufferBuilder = tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); } int ticksModulus = this.ticks & 131071; @@ -123,19 +124,19 @@ public class MixinWorldRenderer { float alpha = ((1.0F - distance * distance) * 0.5F + 0.5F) * rainGradient; mutable.set(x, adjustedTopY, z); int color = ColorABGR.pack(1.0F, 1.0F, 1.0F, alpha); - int light = getLightmapCoordinates(world, mutable); + int light = LevelRenderer.getLightColor(world, mutable); VertexBufferWriter writer = VertexBufferWriter.of(bufferBuilder); write(writer, cameraX, cameraY, cameraZ, x, z, offsetX, offsetZ, minY, maxY, 0, dropTextureOffset, color, light); } else if (precipitation == Biome.Precipitation.SNOW) { if (precipitationType != 1) { if (precipitationType >= 0) { - BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); + BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); } precipitationType = 1; - RenderSystem.setShaderTexture(0, SNOW); - bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR_LIGHT); + RenderSystem.setShaderTexture(0, SNOW_LOCATION); + bufferBuilder = tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); } float snowFallSpeed = -((float) (this.ticks & 511) + tickDelta) / 512.0F; @@ -148,11 +149,11 @@ public class MixinWorldRenderer { float alpha = ((1.0F - distance * distance) * 0.3F + 0.5F) * rainGradient; mutable.set(x, adjustedTopY, z); - int light = getLightmapCoordinates(world, mutable); - int blockLight = light >> 16 & (LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE | 65295); - int skyLight = light & (LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE | 65295); - int adjustedBlockLight = (blockLight * 3 + LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE) / 4; - int adjustedSkyLight = (skyLight * 3 + LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE) / 4; + int light = LevelRenderer.getLightColor(world, mutable); + int blockLight = light >> 16 & (LightTexture.FULL_BLOCK | 65295); + int skyLight = light & (LightTexture.FULL_BLOCK | 65295); + int adjustedBlockLight = (blockLight * 3 + LightTexture.FULL_BLOCK) / 4; + int adjustedSkyLight = (skyLight * 3 + LightTexture.FULL_BLOCK) / 4; VertexBufferWriter writer = VertexBufferWriter.of(bufferBuilder); int color = ColorABGR.pack(1.0F, 1.0F, 1.0F, alpha); @@ -165,17 +166,17 @@ public class MixinWorldRenderer { } if (precipitationType >= 0) { - BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); + BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); } RenderSystem.enableCull(); RenderSystem.disableBlend(); - manager.disable(); + lightTexture.turnOffLightLayer(); } ci.cancel(); } - @Inject(method = "reload()V", at = @At(value = "TAIL")) + @Inject(method = "allChanged", at = @At(value = "TAIL")) private void postReload(CallbackInfo ci) { this.biomeLong2ReferenceMap.clear(); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinFireworkParticle.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinFireworkParticle.java index fbbaed132..9dd466d75 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinFireworkParticle.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinFireworkParticle.java @@ -2,9 +2,9 @@ import it.unimi.dsi.fastutil.ints.IntList; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.particle.FireworksSparkParticle; +import net.minecraft.client.particle.FireworkParticles; import net.minecraft.client.particle.Particle; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -12,12 +12,12 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(FireworksSparkParticle.FireworkParticle.class) +@Mixin(FireworkParticles.Starter.class) public class MixinFireworkParticle { @Unique - private final Identifier fireworkIdentifier = Identifier.of("minecraft", "firework"); + private final ResourceLocation fireworkIdentifier = ResourceLocation.fromNamespaceAndPath("minecraft", "firework"); - @Inject(method = "addExplosionParticle", at = @At(value = "HEAD"), cancellable = true) + @Inject(method = "createParticle", at = @At(value = "HEAD"), cancellable = true) public void addExplosionParticle(double x, double y, double z, double velocityX, double velocityY, double velocityZ, IntList colors, IntList targetColors, boolean trail, boolean flicker, CallbackInfo ci) { if (!SodiumExtraClientMod.options().particleSettings.otherMap.getOrDefault(this.fireworkIdentifier, true) || !SodiumExtraClientMod.options().particleSettings.particles) { ci.cancel(); diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinWorldRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinLevelRenderer.java similarity index 60% rename from src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinWorldRenderer.java rename to src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinLevelRenderer.java index feba3d0d3..544f31d9f 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinWorldRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinLevelRenderer.java @@ -1,26 +1,25 @@ package me.flashyreese.mods.sodiumextra.mixin.particle; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.LightmapTextureManager; -import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.Camera; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.LightTexture; 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; -@Mixin(WorldRenderer.class) -public class MixinWorldRenderer { - - @Inject(method = "tickRainSplashing", at = @At(value = "HEAD"), cancellable = true) +@Mixin(LevelRenderer.class) +public class MixinLevelRenderer { + @Inject(method = "tickRain", at = @At(value = "HEAD"), cancellable = true) public void tickRainSplashing(Camera camera, CallbackInfo callbackInfo) { if (!(SodiumExtraClientMod.options().particleSettings.particles && SodiumExtraClientMod.options().particleSettings.rainSplash)) { callbackInfo.cancel(); } } - @Inject(method = "renderWeather", at = @At(value = "HEAD"), cancellable = true) - private void renderWeather(LightmapTextureManager manager, float f, double d, double e, double g, CallbackInfo callbackInfo) { + @Inject(method = "renderSnowAndRain", at = @At(value = "HEAD"), cancellable = true) + private void renderWeather(LightTexture manager, float f, double d, double e, double g, CallbackInfo callbackInfo) { if (!(SodiumExtraClientMod.options().detailSettings.rainSnow)) { callbackInfo.cancel(); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinParticleManager.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinParticleEngine.java similarity index 56% rename from src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinParticleManager.java rename to src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinParticleEngine.java index d649a9b19..8388bedad 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinParticleManager.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinParticleEngine.java @@ -1,40 +1,40 @@ package me.flashyreese.mods.sodiumextra.mixin.particle; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.block.BlockState; import net.minecraft.client.particle.Particle; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.particle.ParticleEffect; -import net.minecraft.registry.Registries; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.state.BlockState; 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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(ParticleManager.class) -public class MixinParticleManager { - @Inject(method = "addBlockBreakParticles", at = @At(value = "HEAD"), cancellable = true) +@Mixin(ParticleEngine.class) +public class MixinParticleEngine { + @Inject(method = "destroy", at = @At(value = "HEAD"), cancellable = true) public void addBlockBreakParticles(BlockPos pos, BlockState state, CallbackInfo ci) { if (!SodiumExtraClientMod.options().particleSettings.particles || !SodiumExtraClientMod.options().particleSettings.blockBreak) { ci.cancel(); } } - @Inject(method = "addBlockBreakingParticles", at = @At(value = "HEAD"), cancellable = true) + @Inject(method = "crack", at = @At(value = "HEAD"), cancellable = true) public void addBlockBreakingParticles(BlockPos pos, Direction direction, CallbackInfo ci) { if (!SodiumExtraClientMod.options().particleSettings.particles || !SodiumExtraClientMod.options().particleSettings.blockBreaking) { ci.cancel(); } } - @Inject(method = "addParticle(Lnet/minecraft/particle/ParticleEffect;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At(value = "HEAD"), cancellable = true) - public void addParticle(ParticleEffect parameters, double x, double y, double z, double velocityX, double velocityY, double velocityZ, CallbackInfoReturnable cir) { + @Inject(method = "createParticle", at = @At(value = "HEAD"), cancellable = true) + public void addParticle(ParticleOptions particleOptions, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable cir) { if (SodiumExtraClientMod.options().particleSettings.particles) { - Identifier particleTypeId = Registries.PARTICLE_TYPE.getId(parameters.getType()); + ResourceLocation particleTypeId = BuiltInRegistries.PARTICLE_TYPE.getKey(particleOptions.getType()); if (!SodiumExtraClientMod.options().particleSettings.otherMap.getOrDefault(particleTypeId, true)) { cir.setReturnValue(null); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/prevent_shaders/MixinGameRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/prevent_shaders/MixinGameRenderer.java index abc6401ce..2c1040fe7 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/prevent_shaders/MixinGameRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/prevent_shaders/MixinGameRenderer.java @@ -1,8 +1,8 @@ package me.flashyreese.mods.sodiumextra.mixin.prevent_shaders; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.util.Identifier; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.resources.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -11,15 +11,15 @@ @Mixin(GameRenderer.class) public class MixinGameRenderer { - @Inject(method = "togglePostProcessorEnabled", at = @At("HEAD"), cancellable = true) + @Inject(method = "togglePostEffect", at = @At("HEAD"), cancellable = true) private void preventShaders(CallbackInfo ci) { if (SodiumExtraClientMod.options().extraSettings.preventShaders) { ci.cancel(); } } - @Inject(method = "loadPostProcessor", at = @At("HEAD"), cancellable = true) - private void dontLoadShader(Identifier identifier, CallbackInfo ci) { + @Inject(method = "loadEffect", at = @At("HEAD"), cancellable = true) + private void dontLoadShader(ResourceLocation identifier, CallbackInfo ci) { if (SodiumExtraClientMod.options().extraSettings.preventShaders) { ci.cancel(); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinBlockEntityRenderDispatcher.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinBlockEntityRenderDispatcher.java index 836e48fab..2833b7854 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinBlockEntityRenderDispatcher.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinBlockEntityRenderDispatcher.java @@ -1,11 +1,11 @@ package me.flashyreese.mods.sodiumextra.mixin.profiler; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; -import net.minecraft.client.render.block.entity.BlockEntityRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.world.World; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -19,24 +19,24 @@ public class MixinBlockEntityRenderDispatcher { @Unique private static final WeakHashMap, String> names = new WeakHashMap<>(); - @Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/client/render/block/entity/BlockEntityRenderer;Lnet/minecraft/block/entity/BlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;)V") - private static void onRender(BlockEntityRenderer renderer, T blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo info) { - World world = blockEntity.getWorld(); - if (world != null) { + @Inject(at = @At("HEAD"), method = "setupAndRender") + private static void onRender(BlockEntityRenderer renderer, T blockEntity, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, CallbackInfo info) { + Level level = blockEntity.getLevel(); + if (level != null) { String name = names.computeIfAbsent(renderer.getClass(), Class::getSimpleName); if (!name.isEmpty()) { - world.getProfiler().push(name); + level.getProfiler().push(name); } } } - @Inject(at = @At("TAIL"), method = "render(Lnet/minecraft/client/render/block/entity/BlockEntityRenderer;Lnet/minecraft/block/entity/BlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;)V") - private static void afterRender(BlockEntityRenderer renderer, T blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo info) { - World world = blockEntity.getWorld(); - if (world != null) { + @Inject(at = @At("TAIL"), method = "setupAndRender") + private static void afterRender(BlockEntityRenderer renderer, T blockEntity, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, CallbackInfo info) { + Level level = blockEntity.getLevel(); + if (level != null) { String name = names.computeIfAbsent(renderer.getClass(), Class::getSimpleName); if (!name.isEmpty()) { - world.getProfiler().pop(); + level.getProfiler().pop(); } } } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinEntityRenderDispatcher.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinEntityRenderDispatcher.java index e0a4cefd9..3ca010fb9 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinEntityRenderDispatcher.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinEntityRenderDispatcher.java @@ -1,11 +1,11 @@ package me.flashyreese.mods.sodiumextra.mixin.profiler; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.EntityRenderDispatcher; -import net.minecraft.client.render.entity.EntityRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.Entity; -import net.minecraft.world.World; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -22,23 +22,23 @@ public abstract class MixinEntityRenderDispatcher { public abstract EntityRenderer getRenderer(T entity); @Inject(at = @At("HEAD"), method = "render") - private void onRender(E entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - World world = entity.getWorld(); - if (world != null) { + private void onRender(E entity, double x, double y, double z, float yaw, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, int light, CallbackInfo ci) { + Level level = entity.level(); + if (level != null) { String name = names.computeIfAbsent(this.getRenderer(entity).getClass(), Class::getSimpleName); if (!name.isEmpty()) { - world.getProfiler().push(name); + level.getProfiler().push(name); } } } @Inject(at = @At("TAIL"), method = "render") - private void afterRender(E entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - World world = entity.getWorld(); - if (world != null) { + private void afterRender(E entity, double x, double y, double z, float yaw, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, int light, CallbackInfo ci) { + Level level = entity.level(); + if (level != null) { String name = names.computeIfAbsent(this.getRenderer(entity).getClass(), Class::getSimpleName); if (!name.isEmpty()) { - world.getProfiler().pop(); + level.getProfiler().pop(); } } } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/reduce_resolution_on_mac/MixinWindow.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/reduce_resolution_on_mac/MixinWindow.java index 32ad66e27..f42195534 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/reduce_resolution_on_mac/MixinWindow.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/reduce_resolution_on_mac/MixinWindow.java @@ -1,8 +1,8 @@ package me.flashyreese.mods.sodiumextra.mixin.reduce_resolution_on_mac; +import com.mojang.blaze3d.platform.Window; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.Window; +import net.minecraft.client.Minecraft; import org.lwjgl.glfw.GLFW; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -32,15 +32,15 @@ public class MixinWindow { private void onDefaultWindowHints() { GLFW.glfwDefaultWindowHints(); - if (MinecraftClient.IS_SYSTEM_MAC && SodiumExtraClientMod.options().extraSettings.reduceResolutionOnMac) { + if (Minecraft.ON_OSX && SodiumExtraClientMod.options().extraSettings.reduceResolutionOnMac) { GLFW.glfwWindowHint(GLFW.GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW.GLFW_FALSE); } } - @Inject(at = @At(value = "RETURN"), method = "updateFramebufferSize") + @Inject(at = @At(value = "RETURN"), method = "refreshFramebufferSize") private void afterUpdateFrameBufferSize(CallbackInfo ci) { // prevents mis-scaled startup screen - if (MinecraftClient.IS_SYSTEM_MAC && SodiumExtraClientMod.options().extraSettings.reduceResolutionOnMac) { + if (Minecraft.ON_OSX && SodiumExtraClientMod.options().extraSettings.reduceResolutionOnMac) { framebufferWidth /= 2; framebufferHeight /= 2; } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinBeaconBlockEntityRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinBeaconBlockEntityRenderer.java deleted file mode 100644 index ab749f137..000000000 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinBeaconBlockEntityRenderer.java +++ /dev/null @@ -1,40 +0,0 @@ -package me.flashyreese.mods.sodiumextra.mixin.render.block.entity; - -import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.block.entity.BeaconBlockEntity; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer; -import net.minecraft.client.util.math.MatrixStack; -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.Coerce; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.Objects; - -@Mixin(value = BeaconBlockEntityRenderer.class, priority = 999) -public class MixinBeaconBlockEntityRenderer { - - @Shadow - private static void renderBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumers, float tickDelta, long worldTime, int yOffset, int maxY, int color) { - } - - @Inject(method = "render(Lnet/minecraft/block/entity/BeaconBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "HEAD"), cancellable = true) - public void render(BeaconBlockEntity beaconBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j, CallbackInfo ci) { - if (!SodiumExtraClientMod.options().renderSettings.beaconBeam) - ci.cancel(); - } - - @Coerce - @Redirect(method = "render(Lnet/minecraft/block/entity/BeaconBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/entity/BeaconBlockEntityRenderer;renderBeam(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;FJIII)V")) - private void modifyMaxY(MatrixStack matrices, VertexConsumerProvider vertexConsumers, float tickDelta, long worldTime, int yOffset, int maxY, int color, BeaconBlockEntity beaconBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) { - if (maxY == 1024 && SodiumExtraClientMod.options().renderSettings.limitBeaconBeamHeight) { - int lastSegment = beaconBlockEntity.getPos().getY() + yOffset; - maxY = Objects.requireNonNull(beaconBlockEntity.getWorld()).getTopY() - lastSegment; - } - renderBeam(matrices, vertexConsumers, tickDelta, worldTime, yOffset, maxY, color); - } -} diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinBeaconRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinBeaconRenderer.java new file mode 100644 index 000000000..8bdc114e3 --- /dev/null +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinBeaconRenderer.java @@ -0,0 +1,40 @@ +package me.flashyreese.mods.sodiumextra.mixin.render.block.entity; + +import com.mojang.blaze3d.vertex.PoseStack; +import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.blockentity.BeaconRenderer; +import net.minecraft.world.level.block.entity.BeaconBlockEntity; +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.Coerce; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Objects; + +@Mixin(value = BeaconRenderer.class, priority = 999) +public abstract class MixinBeaconRenderer { + + @Shadow + protected static void renderBeaconBeam(PoseStack poseStack, MultiBufferSource multiBufferSource, float f, long l, int i, int j, int k) { + } + + @Inject(method = "render(Lnet/minecraft/world/level/block/entity/BeaconBlockEntity;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;II)V", at = @At(value = "HEAD"), cancellable = true) + public void render(BeaconBlockEntity beaconBlockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j, CallbackInfo ci) { + if (!SodiumExtraClientMod.options().renderSettings.beaconBeam) + ci.cancel(); + } + + @Coerce + @Redirect(method = "render(Lnet/minecraft/world/level/block/entity/BeaconBlockEntity;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;II)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/blockentity/BeaconRenderer;renderBeaconBeam(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;FJIII)V")) + private void modifyMaxY(PoseStack matrices, MultiBufferSource vertexConsumers, float tickDelta, long worldTime, int yOffset, int maxY, int color, BeaconBlockEntity beaconBlockEntity, float f, PoseStack matrixStack, MultiBufferSource vertexConsumerProvider, int i, int j) { + if (maxY == 1024 && SodiumExtraClientMod.options().renderSettings.limitBeaconBeamHeight) { + int lastSegment = beaconBlockEntity.getBlockPos().getY() + yOffset; + maxY = Objects.requireNonNull(beaconBlockEntity.getLevel()).getMaxBuildHeight() - lastSegment; + } + renderBeaconBeam(matrices, vertexConsumers, tickDelta, worldTime, yOffset, maxY, color); + } +} diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinEnchantingTableBlockEntityRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinEnchantingTableBlockEntityRenderer.java index 3f6a55cba..55269afea 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinEnchantingTableBlockEntityRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinEnchantingTableBlockEntityRenderer.java @@ -1,19 +1,19 @@ package me.flashyreese.mods.sodiumextra.mixin.render.block.entity; +import com.mojang.blaze3d.vertex.PoseStack; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.block.entity.EnchantingTableBlockEntity; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.block.entity.EnchantingTableBlockEntityRenderer; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.blockentity.EnchantTableRenderer; +import net.minecraft.world.level.block.entity.EnchantingTableBlockEntity; 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; -@Mixin(EnchantingTableBlockEntityRenderer.class) +@Mixin(EnchantTableRenderer.class) public class MixinEnchantingTableBlockEntityRenderer { - @Inject(method = "render(Lnet/minecraft/block/entity/EnchantingTableBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "HEAD"), cancellable = true) - public void render(EnchantingTableBlockEntity enchantingTableBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j, CallbackInfo ci) { + @Inject(method = "render(Lnet/minecraft/world/level/block/entity/EnchantingTableBlockEntity;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;II)V", at = @At(value = "HEAD"), cancellable = true) + public void render(EnchantingTableBlockEntity enchantingTableBlockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j, CallbackInfo ci) { if (!SodiumExtraClientMod.options().renderSettings.enchantingTableBook) { ci.cancel(); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinPistonBlockEntityRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinPistonBlockEntityRenderer.java index a78ef8567..ac7f32f68 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinPistonBlockEntityRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinPistonBlockEntityRenderer.java @@ -1,19 +1,19 @@ package me.flashyreese.mods.sodiumextra.mixin.render.block.entity; +import com.mojang.blaze3d.vertex.PoseStack; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.block.entity.PistonBlockEntity; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.block.entity.PistonBlockEntityRenderer; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.blockentity.PistonHeadRenderer; +import net.minecraft.world.level.block.piston.PistonMovingBlockEntity; 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; -@Mixin(PistonBlockEntityRenderer.class) +@Mixin(PistonHeadRenderer.class) public class MixinPistonBlockEntityRenderer { - @Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/block/entity/PistonBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", cancellable = true) - public void render(PistonBlockEntity pistonBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j, CallbackInfo ci) { + @Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/world/level/block/piston/PistonMovingBlockEntity;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;II)V", cancellable = true) + public void render(PistonMovingBlockEntity pistonMovingBlockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j, CallbackInfo ci) { if (!SodiumExtraClientMod.options().renderSettings.piston) ci.cancel(); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinItemFrameEntityRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinItemFrameEntityRenderer.java index ebf0a25b5..e0c7881e1 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinItemFrameEntityRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinItemFrameEntityRenderer.java @@ -1,28 +1,28 @@ package me.flashyreese.mods.sodiumextra.mixin.render.entity; +import com.mojang.blaze3d.vertex.PoseStack; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.ItemFrameEntityRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.decoration.ItemFrameEntity; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.ItemFrameRenderer; +import net.minecraft.world.entity.decoration.ItemFrame; 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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(ItemFrameEntityRenderer.class) +@Mixin(ItemFrameRenderer.class) public class MixinItemFrameEntityRenderer { - @Inject(method = "render(Lnet/minecraft/entity/decoration/ItemFrameEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderer;render(Lnet/minecraft/entity/Entity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", shift = At.Shift.AFTER), cancellable = true) - public void render(ItemFrameEntity itemFrameEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { + @Inject(method = "render(Lnet/minecraft/world/entity/decoration/ItemFrame;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;render(Lnet/minecraft/world/entity/Entity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", shift = At.Shift.AFTER), cancellable = true) + public void render(ItemFrame itemFrame, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { if (!SodiumExtraClientMod.options().renderSettings.itemFrame) { ci.cancel(); } } - @Inject(method = "hasLabel(Lnet/minecraft/entity/decoration/ItemFrameEntity;)Z", at = @At(value = "HEAD"), cancellable = true) - private void hasLabel(T entity, CallbackInfoReturnable cir) { + @Inject(method = "shouldShowName(Lnet/minecraft/world/entity/decoration/ItemFrame;)Z", at = @At(value = "HEAD"), cancellable = true) + private void hasLabel(T entity, CallbackInfoReturnable cir) { if (!SodiumExtraClientMod.options().renderSettings.itemFrameNameTag) { cir.setReturnValue(false); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinLivingEntityRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinLivingEntityRenderer.java index d9e97d717..c32cdf6bf 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinLivingEntityRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinLivingEntityRenderer.java @@ -1,16 +1,16 @@ package me.flashyreese.mods.sodiumextra.mixin.render.entity; +import com.mojang.blaze3d.vertex.PoseStack; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.EntityRenderer; -import net.minecraft.client.render.entity.EntityRendererFactory; -import net.minecraft.client.render.entity.LivingEntityRenderer; -import net.minecraft.client.render.entity.feature.FeatureRendererContext; -import net.minecraft.client.render.entity.model.EntityModel; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.decoration.ArmorStandEntity; +import net.minecraft.client.model.EntityModel; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.client.renderer.entity.LivingEntityRenderer; +import net.minecraft.client.renderer.entity.RenderLayerParent; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.decoration.ArmorStand; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -18,24 +18,24 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(LivingEntityRenderer.class) -abstract class MixinLivingEntityRenderer> extends EntityRenderer implements FeatureRendererContext { - protected MixinLivingEntityRenderer(EntityRendererFactory.Context ctx) { +abstract class MixinLivingEntityRenderer> extends EntityRenderer implements RenderLayerParent { + protected MixinLivingEntityRenderer(EntityRendererProvider.Context ctx) { super(ctx); } - @Inject(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"), cancellable = true) - private void onRender(T entity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { - if (entity instanceof ArmorStandEntity && !SodiumExtraClientMod.options().renderSettings.armorStand) { + @Inject(method = "render(Lnet/minecraft/world/entity/LivingEntity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At("HEAD"), cancellable = true) + private void onRender(T entity, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { + if (entity instanceof ArmorStand && !SodiumExtraClientMod.options().renderSettings.armorStand) { ci.cancel(); - if (this.hasLabel(entity)) { - this.renderLabelIfPresent(entity, entity.getDisplayName(), matrixStack, vertexConsumerProvider, i, g); + if (this.shouldShowName(entity)) { + this.renderNameTag(entity, entity.getDisplayName(), poseStack, multiBufferSource, i, g); } } } - @Inject(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;)Z", at = @At(value = "HEAD"), cancellable = true) - private void hasLabel(T entity, CallbackInfoReturnable cir) { - if (entity instanceof AbstractClientPlayerEntity && !SodiumExtraClientMod.options().renderSettings.playerNameTag) { + @Inject(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;)Z", at = @At(value = "HEAD"), cancellable = true) + private void shouldShowName(T entity, CallbackInfoReturnable cir) { + if (entity instanceof AbstractClientPlayer && !SodiumExtraClientMod.options().renderSettings.playerNameTag) { cir.setReturnValue(false); } } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinPaintingEntityRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinPaintingEntityRenderer.java index ad621fc8a..b263b29cf 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinPaintingEntityRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinPaintingEntityRenderer.java @@ -1,19 +1,19 @@ package me.flashyreese.mods.sodiumextra.mixin.render.entity; +import com.mojang.blaze3d.vertex.PoseStack; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.PaintingEntityRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.decoration.painting.PaintingEntity; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.PaintingRenderer; +import net.minecraft.world.entity.decoration.Painting; 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; -@Mixin(PaintingEntityRenderer.class) +@Mixin(PaintingRenderer.class) public class MixinPaintingEntityRenderer { - @Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/entity/decoration/painting/PaintingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", cancellable = true) - public void render(PaintingEntity paintingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { + @Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/world/entity/decoration/Painting;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", cancellable = true) + public void render(Painting painting, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { if (!SodiumExtraClientMod.options().renderSettings.lightUpdates) ci.cancel(); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinWorldRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinLevelRenderer.java similarity index 53% rename from src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinWorldRenderer.java rename to src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinLevelRenderer.java index a8bcc4462..99b77c0ef 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinWorldRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinLevelRenderer.java @@ -1,10 +1,10 @@ package me.flashyreese.mods.sodiumextra.mixin.sky; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexBuffer; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.gl.ShaderProgram; -import net.minecraft.client.gl.VertexBuffer; -import net.minecraft.client.render.WorldRenderer; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.ShaderInstance; import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -12,24 +12,24 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(WorldRenderer.class) -public class MixinWorldRenderer { +@Mixin(LevelRenderer.class) +public class MixinLevelRenderer { @Redirect( - method = "renderSky(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;FLnet/minecraft/client/render/Camera;ZLjava/lang/Runnable;)V", + method = "renderSky", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/gl/VertexBuffer;draw(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;Lnet/minecraft/client/gl/ShaderProgram;)V", + target = "Lcom/mojang/blaze3d/vertex/VertexBuffer;drawWithShader(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;Lnet/minecraft/client/renderer/ShaderInstance;)V", ordinal = 0 ) ) - public void redirectSetSkyShader(VertexBuffer instance, Matrix4f viewMatrix, Matrix4f projectionMatrix, ShaderProgram program) { + public void redirectSetSkyShader(VertexBuffer instance, Matrix4f viewMatrix, Matrix4f projectionMatrix, ShaderInstance program) { if (SodiumExtraClientMod.options().detailSettings.sky) { - instance.draw(viewMatrix, projectionMatrix, program); + instance.drawWithShader(viewMatrix, projectionMatrix, program); } } @Inject(method = "renderEndSky", at = @At(value = "HEAD"), cancellable = true) - public void preRenderEndSky(MatrixStack matrices, CallbackInfo ci) { + public void preRenderEndSky(PoseStack stack, CallbackInfo ci) { if (!SodiumExtraClientMod.options().detailSettings.sky) { ci.cancel(); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky_colors/MixinBiome.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky_colors/MixinBiome.java index 440059976..6514440a7 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky_colors/MixinBiome.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky_colors/MixinBiome.java @@ -1,7 +1,7 @@ package me.flashyreese.mods.sodiumextra.mixin.sky_colors; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.world.biome.Biome; +import net.minecraft.world.level.biome.Biome; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/accessibility/MixinSodiumGameOptionPages.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/accessibility/MixinSodiumGameOptionPages.java index 3fbda7ba3..ac7a5ded5 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/accessibility/MixinSodiumGameOptionPages.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/accessibility/MixinSodiumGameOptionPages.java @@ -8,7 +8,7 @@ import me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter; import me.jellysquid.mods.sodium.client.gui.options.control.SliderControl; import me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -30,18 +30,18 @@ public class MixinSodiumGameOptionPages { private static void quality(CallbackInfoReturnable cir, List groups) { groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(int.class, vanillaOpts) - .setName(Text.translatable("options.screenEffectScale")) - .setTooltip(Text.translatable("options.screenEffectScale.tooltip")) + .setName(Component.translatable("options.screenEffectScale")) + .setTooltip(Component.translatable("options.screenEffectScale.tooltip")) .setControl(option -> new SliderControl(option, 0, 100, 1, ControlValueFormatter.percentage())) - .setBinding((opts, value) -> opts.getDistortionEffectScale().setValue((double) value / 100.0F), (opts) -> Math.toIntExact(Math.round(opts.getDistortionEffectScale().getValue() * 100.0F))) + .setBinding((opts, value) -> opts.screenEffectScale().set((double) value / 100.0F), (opts) -> Math.toIntExact(Math.round(opts.screenEffectScale().get() * 100.0F))) .setImpact(OptionImpact.LOW) .build() ) .add(OptionImpl.createBuilder(int.class, vanillaOpts) - .setName(Text.translatable("options.fovEffectScale")) - .setTooltip(Text.translatable("options.fovEffectScale.tooltip")) + .setName(Component.translatable("options.fovEffectScale")) + .setTooltip(Component.translatable("options.fovEffectScale.tooltip")) .setControl(option -> new SliderControl(option, 0, 100, 1, ControlValueFormatter.percentage())) - .setBinding((opts, value) -> opts.getFovEffectScale().setValue(Math.sqrt(value / 100.0F)), (opts) -> (int) Math.round(Math.pow(opts.getFovEffectScale().getValue(), 2.0D) * 100.0F)) + .setBinding((opts, value) -> opts.fovEffectScale().set(Math.sqrt(value / 100.0F)), (opts) -> (int) Math.round(Math.pow(opts.fovEffectScale().get(), 2.0D) * 100.0F)) .setImpact(OptionImpact.LOW) .build() ) diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/cloud/MixinCloudRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/cloud/MixinCloudRenderer.java index e74e0fe16..0dd31c6d6 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/cloud/MixinCloudRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/cloud/MixinCloudRenderer.java @@ -8,7 +8,7 @@ @Mixin(CloudRenderer.class) public class MixinCloudRenderer { - @ModifyVariable(method = "render", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/option/GameOptions;getClampedViewDistance()I"), index = 21, name = "renderDistance") + @ModifyVariable(method = "render", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/Options;getEffectiveRenderDistance()I"), index = 21, name = "renderDistance") public int modifyCloudRenderDistance(int original) { return original * SodiumExtraClientMod.options().extraSettings.cloudDistance / 100; } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/fog/MixinOcclusionCuller.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/fog/MixinOcclusionCuller.java index 99d762649..fa7463ba4 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/fog/MixinOcclusionCuller.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/fog/MixinOcclusionCuller.java @@ -4,7 +4,7 @@ import me.jellysquid.mods.sodium.client.render.chunk.RenderSection; import me.jellysquid.mods.sodium.client.render.chunk.occlusion.OcclusionCuller; import me.jellysquid.mods.sodium.client.render.viewport.CameraTransform; -import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Minecraft; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -21,7 +21,7 @@ private static int nearestToZero(int min, int max) { @Inject(method = "isWithinRenderDistance", at = @At(value = "HEAD"), cancellable = true) private static void isWithinRenderDistance(CameraTransform camera, RenderSection section, float maxDistance, CallbackInfoReturnable cir) { int fogDistance = SodiumExtraClientMod.options().renderSettings.multiDimensionFogControl ? - SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.getOrDefault(MinecraftClient.getInstance().world.getDimension().effects(), 0) : + SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.getOrDefault(Minecraft.getInstance().level.dimensionType().effectsLocation(), 0) : SodiumExtraClientMod.options().renderSettings.fogDistance; if (fogDistance == 33) { int ox = section.getOriginX() - camera.intX; diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/resolution/MixinSodiumGameOptionPages.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/resolution/MixinSodiumGameOptionPages.java index 4b9c6c775..16ef28a15 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/resolution/MixinSodiumGameOptionPages.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/resolution/MixinSodiumGameOptionPages.java @@ -1,5 +1,7 @@ package me.flashyreese.mods.sodiumextra.mixin.sodium.resolution; +import com.mojang.blaze3d.platform.VideoMode; +import com.mojang.blaze3d.platform.Window; import me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended; import me.flashyreese.mods.sodiumextra.common.util.ControlValueFormatterExtended; import me.jellysquid.mods.sodium.client.gui.SodiumGameOptionPages; @@ -8,10 +10,8 @@ import me.jellysquid.mods.sodium.client.gui.options.OptionImpl; import me.jellysquid.mods.sodium.client.gui.options.OptionPage; import me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.VideoMode; -import net.minecraft.client.util.Window; -import net.minecraft.text.Text; +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -32,28 +32,28 @@ public class MixinSodiumGameOptionPages { @Inject(method = "general", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/gui/options/OptionGroup;createBuilder()Lme/jellysquid/mods/sodium/client/gui/options/OptionGroup$Builder;", ordinal = 1, shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILSOFT, remap = false) private static void general(CallbackInfoReturnable cir, List groups) { - Window window = MinecraftClient.getInstance().getWindow(); + Window window = Minecraft.getInstance().getWindow(); groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(int.class, vanillaOpts) - .setName(Text.translatable("options.fullscreen.resolution")) - .setTooltip(Text.translatable("sodium-extra.option.resolution.tooltip")) - .setControl(option -> new SliderControlExtended(option, 0, window.getMonitor() != null ? window.getMonitor().getVideoModeCount() : 0, 1, ControlValueFormatterExtended.resolution(), false)) + .setName(Component.translatable("options.fullscreen.resolution")) + .setTooltip(Component.translatable("sodium-extra.option.resolution.tooltip")) + .setControl(option -> new SliderControlExtended(option, 0, window.findBestMonitor() != null ? window.findBestMonitor().getModeCount() : 0, 1, ControlValueFormatterExtended.resolution(), false)) .setBinding((options, value) -> { - if (window.getMonitor() != null) { + if (window.findBestMonitor() != null) { if (value == 0) { - window.setVideoMode(Optional.empty()); + window.setPreferredFullscreenVideoMode(Optional.empty()); } else { - window.setVideoMode(Optional.of(window.getMonitor().getVideoMode(value - 1))); + window.setPreferredFullscreenVideoMode(Optional.of(window.findBestMonitor().getMode(value - 1))); } } - window.applyVideoMode(); + window.changeFullscreenVideoMode(); }, options -> { - if (window.getMonitor() == null) { + if (window.findBestMonitor() == null) { return 0; } else { - Optional optional = window.getVideoMode(); - return optional.map((videoMode) -> window.getMonitor().findClosestVideoModeIndex(videoMode) + 1).orElse(0); + Optional optional = window.getPreferredFullscreenVideoMode(); + return optional.map((videoMode) -> window.findBestMonitor().getVideoModeIndex(videoMode) + 1).orElse(0); } }) .setImpact(OptionImpact.HIGH) diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/scrollable_page/MixinSodiumOptionsGUI.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/scrollable_page/MixinSodiumOptionsGUI.java index ec8d8c825..942e31c9f 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/scrollable_page/MixinSodiumOptionsGUI.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/scrollable_page/MixinSodiumOptionsGUI.java @@ -6,9 +6,9 @@ import me.jellysquid.mods.sodium.client.gui.options.control.ControlElement; import me.jellysquid.mods.sodium.client.gui.prompt.ScreenPrompt; import me.jellysquid.mods.sodium.client.util.Dim2i; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.Text; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.Component; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -25,7 +25,7 @@ public abstract class MixinSodiumOptionsGUI extends Screen { @Shadow private @Nullable ScreenPrompt prompt; - protected MixinSodiumOptionsGUI(Text title) { + protected MixinSodiumOptionsGUI(Component title) { super(title); } @@ -35,12 +35,12 @@ private void rebuildGUIOptions(CallbackInfo ci) { int y = 28; OptionPageScrollFrame optionPageScrollFrame = new OptionPageScrollFrame(new Dim2i(x, y, /*this.width - x * 2*/200, this.height - y - 10 /*- 64*/), this.currentPage); - this.addDrawableChild(optionPageScrollFrame); + this.addRenderableWidget(optionPageScrollFrame); ci.cancel(); } @Inject(method = "renderOptionTooltip", at = @At(value = "HEAD"), cancellable = true) - private void renderOptionTooltip(DrawContext drawContext, ControlElement element, CallbackInfo ci) { + private void renderOptionTooltip(GuiGraphics guiGraphics, ControlElement element, CallbackInfo ci) { ci.cancel(); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/vsync/MixinSodiumGameOptionsPages.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/vsync/MixinSodiumGameOptionsPages.java index 1e1fb17db..86f7ef9e3 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/vsync/MixinSodiumGameOptionsPages.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/vsync/MixinSodiumGameOptionsPages.java @@ -9,7 +9,7 @@ import me.jellysquid.mods.sodium.client.gui.options.OptionImpl; import me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl; import me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -24,34 +24,34 @@ public class MixinSodiumGameOptionsPages { @Redirect(method = "general", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/gui/options/OptionGroup$Builder;add(Lme/jellysquid/mods/sodium/client/gui/options/Option;)Lme/jellysquid/mods/sodium/client/gui/options/OptionGroup$Builder;", ordinal = 5), remap = false) private static OptionGroup.Builder redirectVsyncToggle(OptionGroup.Builder instance, Option option) { - if (!option.getTooltip().getString().equals(Text.translatable("sodium.options.v_sync.tooltip").getString())) { + if (!option.getTooltip().getString().equals(Component.translatable("sodium.options.v_sync.tooltip").getString())) { return instance.add(option); } return instance.add(OptionImpl.createBuilder(SodiumExtraGameOptions.VerticalSyncOption.class, SodiumExtraGameOptionPages.sodiumExtraOpts) - .setName(Text.translatable("options.vsync")) - .setTooltip(Text.literal(Text.translatable("sodium.options.v_sync.tooltip").getString() + "\n- " + Text.translatable("sodium-extra.option.use_adaptive_sync.name").getString() + ": " + Text.translatable("sodium-extra.option.use_adaptive_sync.tooltip").getString())) + .setName(Component.translatable("options.vsync")) + .setTooltip(Component.literal(Component.translatable("sodium.options.v_sync.tooltip").getString() + "\n- " + Component.translatable("sodium-extra.option.use_adaptive_sync.name").getString() + ": " + Component.translatable("sodium-extra.option.use_adaptive_sync.tooltip").getString())) .setControl((opt) -> new CyclingControl<>(opt, SodiumExtraGameOptions.VerticalSyncOption.class, SodiumExtraGameOptions.VerticalSyncOption.getAvailableOptions())) .setBinding((opts, value) -> { switch (value) { case OFF -> { opts.extraSettings.useAdaptiveSync = false; - vanillaOpts.getData().getEnableVsync().setValue(false); + vanillaOpts.getData().enableVsync().set(false); } case ON -> { opts.extraSettings.useAdaptiveSync = false; - vanillaOpts.getData().getEnableVsync().setValue(true); + vanillaOpts.getData().enableVsync().set(true); } case ADAPTIVE -> { opts.extraSettings.useAdaptiveSync = true; - vanillaOpts.getData().getEnableVsync().setValue(true); + vanillaOpts.getData().enableVsync().set(true); } } vanillaOpts.save(); }, opts -> { - if (vanillaOpts.getData().getEnableVsync().getValue() && !opts.extraSettings.useAdaptiveSync) { + if (vanillaOpts.getData().enableVsync().get() && !opts.extraSettings.useAdaptiveSync) { return SodiumExtraGameOptions.VerticalSyncOption.ON; - } else if (!vanillaOpts.getData().getEnableVsync().getValue() && !opts.extraSettings.useAdaptiveSync) { + } else if (!vanillaOpts.getData().enableVsync().get() && !opts.extraSettings.useAdaptiveSync) { return SodiumExtraGameOptions.VerticalSyncOption.OFF; } else { return SodiumExtraGameOptions.VerticalSyncOption.ADAPTIVE; diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinWorldRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinLevelRenderer.java similarity index 55% rename from src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinWorldRenderer.java rename to src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinLevelRenderer.java index 93faa94ca..bf03aaa85 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinWorldRenderer.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinLevelRenderer.java @@ -1,22 +1,22 @@ package me.flashyreese.mods.sodiumextra.mixin.stars; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.render.WorldRenderer; -import net.minecraft.client.world.ClientWorld; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.LevelRenderer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -@Mixin(WorldRenderer.class) -public class MixinWorldRenderer { +@Mixin(LevelRenderer.class) +public class MixinLevelRenderer { @Redirect( - method = "renderSky(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;FLnet/minecraft/client/render/Camera;ZLjava/lang/Runnable;)V", + method = "renderSky", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/world/ClientWorld;getStarBrightness(F)F" + target = "Lnet/minecraft/client/multiplayer/ClientLevel;getStarBrightness(F)F" ) ) - public float redirectGetStarBrightness(ClientWorld instance, float f) { + public float redirectGetStarBrightness(ClientLevel instance, float f) { if (SodiumExtraClientMod.options().detailSettings.stars) { return instance.getStarBrightness(f); } else { diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/steady_debug_hud/MixinDebugHud.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/steady_debug_hud/MixinDebugScreenOverlay.java similarity index 54% rename from src/main/java/me/flashyreese/mods/sodiumextra/mixin/steady_debug_hud/MixinDebugHud.java rename to src/main/java/me/flashyreese/mods/sodiumextra/mixin/steady_debug_hud/MixinDebugScreenOverlay.java index ec8ce919a..823820ea1 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/steady_debug_hud/MixinDebugHud.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/steady_debug_hud/MixinDebugScreenOverlay.java @@ -1,9 +1,9 @@ package me.flashyreese.mods.sodiumextra.mixin.steady_debug_hud; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.hud.DebugHud; -import net.minecraft.util.Util; +import net.minecraft.Util; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.DebugScreenOverlay; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -15,8 +15,9 @@ import java.util.ArrayList; import java.util.List; -@Mixin(DebugHud.class) -public abstract class MixinDebugHud { +@Mixin(DebugScreenOverlay.class) +public abstract class MixinDebugScreenOverlay { + @Shadow protected abstract void renderLines(GuiGraphics guiGraphics, List list, boolean bl); @Unique private final List leftTextCache = new ArrayList<>(); @@ -27,13 +28,10 @@ public abstract class MixinDebugHud { @Unique private boolean rebuild = true; - @Shadow - protected abstract void drawText(DrawContext context, List text, boolean left); - @Inject(method = "render", at = @At(value = "HEAD")) - public void preRender(DrawContext context, CallbackInfo ci) { + public void preRender(GuiGraphics guiGraphics, CallbackInfo ci) { if (SodiumExtraClientMod.options().extraSettings.steadyDebugHud) { - final long currentTime = Util.getMeasuringTimeMs(); + final long currentTime = Util.getMillis(); if (currentTime > this.nextTime) { this.rebuild = true; this.nextTime = currentTime + (SodiumExtraClientMod.options().extraSettings.steadyDebugHudRefreshInterval * 50L); @@ -45,21 +43,21 @@ public void preRender(DrawContext context, CallbackInfo ci) { } } - @Redirect(method = "drawLeftText", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;drawText(Lnet/minecraft/client/gui/DrawContext;Ljava/util/List;Z)V")) - public void sodiumExtra$redirectDrawLeftText(DebugHud instance, DrawContext context, List text, boolean left) { + @Redirect(method = "drawGameInformation", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/DebugScreenOverlay;renderLines(Lnet/minecraft/client/gui/GuiGraphics;Ljava/util/List;Z)V")) + public void sodiumExtra$redirectDrawLeftText(DebugScreenOverlay instance, GuiGraphics guiGraphics, List text, boolean left) { if (this.rebuild) { this.leftTextCache.clear(); this.leftTextCache.addAll(text); } - this.drawText(context, this.leftTextCache, left); + this.renderLines(guiGraphics, this.leftTextCache, left); } - @Redirect(method = "drawRightText", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;drawText(Lnet/minecraft/client/gui/DrawContext;Ljava/util/List;Z)V")) - public void sodiumExtra$redirectDrawRightText(DebugHud instance, DrawContext context, List text, boolean left) { + @Redirect(method = "drawSystemInformation", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/DebugScreenOverlay;renderLines(Lnet/minecraft/client/gui/GuiGraphics;Ljava/util/List;Z)V")) + public void sodiumExtra$redirectDrawRightText(DebugScreenOverlay instance, GuiGraphics guiGraphics, List text, boolean left) { if (this.rebuild) { this.rightTextCache.clear(); this.rightTextCache.addAll(text); } - this.drawText(context, this.rightTextCache, left); + this.renderLines(guiGraphics, this.rightTextCache, left); } } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinLevelRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinLevelRenderer.java new file mode 100644 index 000000000..e040f1519 --- /dev/null +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinLevelRenderer.java @@ -0,0 +1,57 @@ +package me.flashyreese.mods.sodiumextra.mixin.sun_moon; + +import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; +import net.minecraft.client.renderer.DimensionSpecialEffects; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.resources.ResourceLocation; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +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.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(LevelRenderer.class) +public class MixinLevelRenderer { + + @Mutable + @Shadow + @Final + private static ResourceLocation SUN_LOCATION; + + @Mutable + @Shadow + @Final + private static ResourceLocation MOON_LOCATION; + + @Redirect( + method = "renderSky", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/renderer/DimensionSpecialEffects;getSunriseColor(FF)[F" + ) + ) + public float[] redirectGetFogColorOverride(DimensionSpecialEffects instance, float skyAngle, float tickDelta) { + if (SodiumExtraClientMod.options().detailSettings.sunMoon) { + return instance.getSunriseColor(skyAngle, tickDelta); + } else { + return null; + } + } + + @Inject( + method = "allChanged()V", + at = @At(value = "TAIL") + ) + private void postWorldRendererReload(CallbackInfo ci) { + if (SodiumExtraClientMod.options().detailSettings.sunMoon) { + MOON_LOCATION = ResourceLocation.withDefaultNamespace("textures/environment/moon_phases.png"); + SUN_LOCATION = ResourceLocation.withDefaultNamespace("textures/environment/sun.png"); + } else { + MOON_LOCATION = ResourceLocation.fromNamespaceAndPath("sodium-extra", "textures/transparent.png"); + SUN_LOCATION = ResourceLocation.fromNamespaceAndPath("sodium-extra", "textures/transparent.png"); + } + } +} diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinWorldRenderer.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinWorldRenderer.java deleted file mode 100644 index f88284515..000000000 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinWorldRenderer.java +++ /dev/null @@ -1,57 +0,0 @@ -package me.flashyreese.mods.sodiumextra.mixin.sun_moon; - -import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.render.DimensionEffects; -import net.minecraft.client.render.WorldRenderer; -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(WorldRenderer.class) -public class MixinWorldRenderer { - - @Mutable - @Shadow - @Final - private static Identifier SUN; - - @Mutable - @Shadow - @Final - private static Identifier MOON_PHASES; - - @Redirect( - method = "renderSky(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;FLnet/minecraft/client/render/Camera;ZLjava/lang/Runnable;)V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/render/DimensionEffects;getFogColorOverride(FF)[F" - ) - ) - public float[] redirectGetFogColorOverride(DimensionEffects instance, float skyAngle, float tickDelta) { - if (SodiumExtraClientMod.options().detailSettings.sunMoon) { - return instance.getFogColorOverride(skyAngle, tickDelta); - } else { - return null; - } - } - - @Inject( - method = "reload()V", - at = @At(value = "TAIL") - ) - private void postWorldRendererReload(CallbackInfo ci) { - if (SodiumExtraClientMod.options().detailSettings.sunMoon) { - MOON_PHASES = Identifier.of("textures/environment/moon_phases.png"); - SUN = Identifier.of("textures/environment/sun.png"); - } else { - MOON_PHASES = Identifier.of("sodium-extra", "textures/transparent.png"); - SUN = Identifier.of("sodium-extra", "textures/transparent.png"); - } - } -} diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinAdvancementToast.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinAdvancementToast.java index f4503f46d..392cfd3cc 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinAdvancementToast.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinAdvancementToast.java @@ -1,10 +1,10 @@ package me.flashyreese.mods.sodiumextra.mixin.toasts; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.toast.AdvancementToast; -import net.minecraft.client.toast.Toast; -import net.minecraft.client.toast.ToastManager; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.toasts.AdvancementToast; +import net.minecraft.client.gui.components.toasts.Toast; +import net.minecraft.client.gui.components.toasts.ToastComponent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,8 +12,8 @@ @Mixin(AdvancementToast.class) public class MixinAdvancementToast { - @Inject(method = "draw", at = @At("HEAD"), cancellable = true) - public void draw(DrawContext context, ToastManager manager, long startTime, CallbackInfoReturnable cir) { + @Inject(method = "render", at = @At("HEAD"), cancellable = true) + public void draw(GuiGraphics guiGraphics, ToastComponent manager, long startTime, CallbackInfoReturnable cir) { if (!SodiumExtraClientMod.options().extraSettings.advancementToast) { cir.setReturnValue(Toast.Visibility.HIDE); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinRecipeToast.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinRecipeToast.java index b025b92dc..afbd8a70b 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinRecipeToast.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinRecipeToast.java @@ -1,10 +1,10 @@ package me.flashyreese.mods.sodiumextra.mixin.toasts; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.toast.RecipeToast; -import net.minecraft.client.toast.Toast; -import net.minecraft.client.toast.ToastManager; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.toasts.RecipeToast; +import net.minecraft.client.gui.components.toasts.Toast; +import net.minecraft.client.gui.components.toasts.ToastComponent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,8 +12,8 @@ @Mixin(RecipeToast.class) public class MixinRecipeToast { - @Inject(method = "draw", at = @At("HEAD"), cancellable = true) - public void draw(DrawContext context, ToastManager manager, long startTime, CallbackInfoReturnable cir) { + @Inject(method = "render", at = @At("HEAD"), cancellable = true) + public void draw(GuiGraphics guiGraphics, ToastComponent manager, long startTime, CallbackInfoReturnable cir) { if (!SodiumExtraClientMod.options().extraSettings.recipeToast) { cir.setReturnValue(Toast.Visibility.HIDE); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinSystemToast.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinSystemToast.java index ae3f39c51..468ab1a1c 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinSystemToast.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinSystemToast.java @@ -1,10 +1,10 @@ package me.flashyreese.mods.sodiumextra.mixin.toasts; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.toast.SystemToast; -import net.minecraft.client.toast.Toast; -import net.minecraft.client.toast.ToastManager; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.toasts.SystemToast; +import net.minecraft.client.gui.components.toasts.Toast; +import net.minecraft.client.gui.components.toasts.ToastComponent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,8 +12,8 @@ @Mixin(SystemToast.class) public class MixinSystemToast { - @Inject(method = "draw", at = @At("HEAD"), cancellable = true) - public void draw(DrawContext context, ToastManager manager, long startTime, CallbackInfoReturnable cir) { + @Inject(method = "render", at = @At("HEAD"), cancellable = true) + public void draw(GuiGraphics guiGraphics, ToastComponent manager, long startTime, CallbackInfoReturnable cir) { if (!SodiumExtraClientMod.options().extraSettings.systemToast) { cir.setReturnValue(Toast.Visibility.HIDE); } diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinToastManager.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinToastManager.java index 6c444522f..aad91bf63 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinToastManager.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinToastManager.java @@ -1,15 +1,15 @@ package me.flashyreese.mods.sodiumextra.mixin.toasts; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.toast.ToastManager; +import net.minecraft.client.gui.components.toasts.ToastComponent; 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; -@Mixin(ToastManager.class) +@Mixin(ToastComponent.class) public class MixinToastManager { - @Inject(method = "add", at = @At("HEAD"), cancellable = true) + @Inject(method = "addToast", at = @At("HEAD"), cancellable = true) public void goodByeToasts(CallbackInfo ci) { if (!SodiumExtraClientMod.options().extraSettings.toasts) { ci.cancel(); diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinTutorialToast.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinTutorialToast.java index 1b2fd4fb4..370f9366c 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinTutorialToast.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinTutorialToast.java @@ -1,10 +1,10 @@ package me.flashyreese.mods.sodiumextra.mixin.toasts; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.toast.Toast; -import net.minecraft.client.toast.ToastManager; -import net.minecraft.client.toast.TutorialToast; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.toasts.Toast; +import net.minecraft.client.gui.components.toasts.ToastComponent; +import net.minecraft.client.gui.components.toasts.TutorialToast; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,8 +12,8 @@ @Mixin(TutorialToast.class) public class MixinTutorialToast { - @Inject(method = "draw", at = @At("HEAD"), cancellable = true) - public void draw(DrawContext context, ToastManager manager, long startTime, CallbackInfoReturnable cir) { + @Inject(method = "render", at = @At("HEAD"), cancellable = true) + public void draw(GuiGraphics guiGraphics, ToastComponent manager, long startTime, CallbackInfoReturnable cir) { if (!SodiumExtraClientMod.options().extraSettings.tutorialToast) { cir.setReturnValue(Toast.Visibility.HIDE); } diff --git a/src/main/resources/sodium-extra.accesswidener b/src/main/resources/sodium-extra.accesswidener index 914d94a64..b199e25af 100644 --- a/src/main/resources/sodium-extra.accesswidener +++ b/src/main/resources/sodium-extra.accesswidener @@ -1,2 +1,2 @@ accessWidener v1 named -accessible class net/minecraft/client/render/BackgroundRenderer$StatusEffectFogModifier \ No newline at end of file +accessible class net/minecraft/client/renderer/FogRenderer$MobEffectFogFunction \ No newline at end of file diff --git a/src/main/resources/sodium-extra.mixins.json b/src/main/resources/sodium-extra.mixins.json index 510dc19ad..0cd861c3f 100644 --- a/src/main/resources/sodium-extra.mixins.json +++ b/src/main/resources/sodium-extra.mixins.json @@ -10,30 +10,30 @@ "biome_colors.MixinBiomeColors", "cloud.MixinDimensionEffectsOverworld", "compat.MixinSodiumOptionsGUI", - "fog.MixinBackgroundRenderer", - "fog_falloff.MixinBackgroundRenderer", + "fog.MixinFogRenderer", + "fog_falloff.MixinFogRenderer", "gui.MinecraftClientAccessor", "instant_sneak.MixinCamera", - "light_updates.MixinLightingProvider", - "optimizations.beacon_beam_rendering.MixinBeaconBlockEntityRenderer", + "light_updates.MixinLevelLightEngine", + "optimizations.beacon_beam_rendering.MixinBeaconRenderer", "optimizations.beacon_beam_rendering.MixinVertexSerializerRegistryImpl", - "optimizations.beacon_beam_rendering.WorldRendererAccessor", - "optimizations.draw_helpers.MixinDrawContext", - "optimizations.fast_weather.MixinWorldRenderer", + "optimizations.beacon_beam_rendering.LevelRendererAccessor", + "optimizations.draw_helpers.MixinGuiGraphics", + "optimizations.fast_weather.MixinLevelRenderer", "particle.MixinFireworkParticle", - "particle.MixinParticleManager", - "particle.MixinWorldRenderer", + "particle.MixinParticleEngine", + "particle.MixinLevelRenderer", "prevent_shaders.MixinGameRenderer", "profiler.MixinBlockEntityRenderDispatcher", "profiler.MixinEntityRenderDispatcher", "reduce_resolution_on_mac.MixinWindow", - "render.block.entity.MixinBeaconBlockEntityRenderer", + "render.block.entity.MixinBeaconRenderer", "render.block.entity.MixinEnchantingTableBlockEntityRenderer", "render.block.entity.MixinPistonBlockEntityRenderer", "render.entity.MixinItemFrameEntityRenderer", "render.entity.MixinLivingEntityRenderer", "render.entity.MixinPaintingEntityRenderer", - "sky.MixinWorldRenderer", + "sky.MixinLevelRenderer", "sky_colors.MixinBiome", "sodium.accessibility.MixinSodiumGameOptionPages", "sodium.cloud.MixinCloudRenderer", @@ -41,9 +41,9 @@ "sodium.resolution.MixinSodiumGameOptionPages", "sodium.scrollable_page.MixinSodiumOptionsGUI", "sodium.vsync.MixinSodiumGameOptionsPages", - "stars.MixinWorldRenderer", - "steady_debug_hud.MixinDebugHud", - "sun_moon.MixinWorldRenderer", + "stars.MixinLevelRenderer", + "steady_debug_hud.MixinDebugScreenOverlay", + "sun_moon.MixinLevelRenderer", "toasts.MixinAdvancementToast", "toasts.MixinRecipeToast", "toasts.MixinSystemToast",