diff --git a/build.gradle b/build.gradle index d9d30ae..1ef49dc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.10-SNAPSHOT' + id 'fabric-loom' version '0.12-SNAPSHOT' id 'maven-publish' } @@ -16,7 +16,7 @@ archivesBaseName = project.archives_base_name version = "${project.mod_version}+mc.${project.minecraft_version}" group = project.maven_group -minecraft { +loom { } dependencies { @@ -39,12 +39,12 @@ dependencies { // runtime only setups // modRuntimeOnly "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" // modRuntimeOnly("com.terraformersmc:modmenu:${project.mod_menu_version}") { transitive = false } - modRuntimeOnly fabricApi.module("fabric-rendering-data-attachment-v1", project.fabric_version) - modRuntimeOnly fabricApi.module("fabric-rendering-fluids-v1", project.fabric_version) - modRuntimeOnly "maven.modrinth:sodium:${project.sodium_version}" + // modRuntimeOnly fabricApi.module("fabric-rendering-data-attachment-v1", project.fabric_version) + // modRuntimeOnly fabricApi.module("fabric-rendering-fluids-v1", project.fabric_version) + // modRuntimeOnly "maven.modrinth:sodium:${project.sodium_version}" // because Loom doesn't load Sodium's included non-mod dependency - runtimeOnly "org.joml:joml:1.10.2" + // runtimeOnly "org.joml:joml:1.10.2" } processResources { diff --git a/gradle.properties b/gradle.properties index b8528ee..f597ecb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.18.2 - yarn_mappings=1.18.2+build.2 - loader_version=0.13.3 + minecraft_version=1.19-pre1 + yarn_mappings=1.19-pre1+build.7 + loader_version=0.14.6 # Mod Properties mod_version = 3.1.2-snapshot maven_group = io.github.kvverti @@ -13,6 +13,6 @@ org.gradle.jvmargs=-Xmx1G # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api - fabric_version=0.47.10+1.18.2 + fabric_version=0.53.1+1.19 mod_menu_version=3.1.0 sodium_version=mc1.18.2-0.4.1 diff --git a/src/main/java/io/github/kvverti/colormatic/Colormatic.java b/src/main/java/io/github/kvverti/colormatic/Colormatic.java index 5009c94..b54bb9d 100644 --- a/src/main/java/io/github/kvverti/colormatic/Colormatic.java +++ b/src/main/java/io/github/kvverti/colormatic/Colormatic.java @@ -49,6 +49,8 @@ public class Colormatic implements ClientModInitializer { public static final String MODID = "colormatic"; + public static final Identifier OVERWORLD_ID = new Identifier("minecraft:overworld"); + public static final BiomeColormapResource WATER_COLORS = new BiomeColormapResource(new Identifier(MODID, "colormap/water")); public static final BiomeColormapResource UNDERWATER_COLORS = @@ -95,7 +97,7 @@ public static Identifier getDimId(World world) { DimensionType type = world.getDimension(); Identifier id = world.getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(type); if(id == null) { - id = DimensionType.OVERWORLD_ID; + id = OVERWORLD_ID; } return id; } diff --git a/src/main/java/io/github/kvverti/colormatic/ColormaticConfigController.java b/src/main/java/io/github/kvverti/colormatic/ColormaticConfigController.java index 5d2bc5a..0eb15c0 100644 --- a/src/main/java/io/github/kvverti/colormatic/ColormaticConfigController.java +++ b/src/main/java/io/github/kvverti/colormatic/ColormaticConfigController.java @@ -33,8 +33,7 @@ import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.LiteralText; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.Text; /** * This class holds functions that control loading, opening, and persisting @@ -52,7 +51,7 @@ private ColormaticConfigController() { } public static Screen getConfigScreen(ColormaticConfig config, Screen parent) { - return new ColormaticConfigScreen(new TranslatableText("colormatic.config.title.subtitle"), parent, config); + return new ColormaticConfigScreen(Text.translatable("colormatic.config.title.subtitle"), parent, config); } private static final String CLEAR_SKY = "fog.clearSky"; diff --git a/src/main/java/io/github/kvverti/colormatic/ColormaticConfigScreen.java b/src/main/java/io/github/kvverti/colormatic/ColormaticConfigScreen.java index ac54934..6962cd2 100644 --- a/src/main/java/io/github/kvverti/colormatic/ColormaticConfigScreen.java +++ b/src/main/java/io/github/kvverti/colormatic/ColormaticConfigScreen.java @@ -26,16 +26,14 @@ import org.jetbrains.annotations.Nullable; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ScreenTexts; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.CyclingButtonWidget; import net.minecraft.client.gui.widget.SliderWidget; import net.minecraft.client.util.OrderableTooltip; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.LiteralText; +import net.minecraft.screen.ScreenTexts; import net.minecraft.text.OrderedText; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; public class ColormaticConfigScreen extends Screen { @@ -65,49 +63,49 @@ protected void init() { var clearSkyBtn = this.addDrawableChild(CyclingButtonWidget .onOffBuilder() .initially(config.clearSky) - .tooltip(value -> this.textRenderer.wrapLines(new TranslatableText("colormatic.config.option.clearSky.desc"), STANDARD_WIDTH)) + .tooltip(value -> this.textRenderer.wrapLines(Text.translatable("colormatic.config.option.clearSky.desc"), STANDARD_WIDTH)) .build( centerX - STANDARD_MARGIN - STANDARD_WIDTH, TOP_MARGIN + 2 * STANDARD_HEIGHT, STANDARD_WIDTH, STANDARD_HEIGHT, - new TranslatableText("colormatic.config.option.clearSky"), + Text.translatable("colormatic.config.option.clearSky"), (button, value) -> config.clearSky = value)); var clearVoidBtn = this.addDrawableChild(CyclingButtonWidget .onOffBuilder() .initially(config.clearVoid) - .tooltip(value -> this.textRenderer.wrapLines(new TranslatableText("colormatic.config.option.clearVoid.desc"), STANDARD_WIDTH)) + .tooltip(value -> this.textRenderer.wrapLines(Text.translatable("colormatic.config.option.clearVoid.desc"), STANDARD_WIDTH)) .build( centerX + STANDARD_MARGIN, TOP_MARGIN + 2 * STANDARD_HEIGHT, STANDARD_WIDTH, STANDARD_HEIGHT, - new TranslatableText("colormatic.config.option.clearVoid"), + Text.translatable("colormatic.config.option.clearVoid"), (button, value) -> config.clearVoid = value)); this.fogSectionBottom = clearVoidBtn.y + clearVoidBtn.getHeight() + STANDARD_MARGIN; // lighting settings var blendSkyLightBtn = this.addDrawableChild(CyclingButtonWidget .onOffBuilder() .initially(config.blendSkyLight) - .tooltip(value -> this.textRenderer.wrapLines(new TranslatableText("colormatic.config.option.blendSkyLight.desc"), STANDARD_WIDTH)) + .tooltip(value -> this.textRenderer.wrapLines(Text.translatable("colormatic.config.option.blendSkyLight.desc"), STANDARD_WIDTH)) .build( clearSkyBtn.x, this.fogSectionBottom + 2 * STANDARD_HEIGHT, STANDARD_WIDTH, STANDARD_HEIGHT, - new TranslatableText("colormatic.config.option.blendSkyLight"), + Text.translatable("colormatic.config.option.blendSkyLight"), (button, value) -> config.blendSkyLight = value )); this.addDrawableChild(CyclingButtonWidget .onOffBuilder() .initially(config.flickerBlockLight) - .tooltip(value -> this.textRenderer.wrapLines(new TranslatableText("colormatic.config.option.flickerBlockLight.desc"), STANDARD_WIDTH)) + .tooltip(value -> this.textRenderer.wrapLines(Text.translatable("colormatic.config.option.flickerBlockLight.desc"), STANDARD_WIDTH)) .build( clearVoidBtn.x, this.fogSectionBottom + 2 * STANDARD_HEIGHT, STANDARD_WIDTH, STANDARD_HEIGHT, - new TranslatableText("colormatic.config.option.flickerBlockLight"), + Text.translatable("colormatic.config.option.flickerBlockLight"), (button, value) -> config.flickerBlockLight = value )); this.addDrawableChild(new BlockLightIntensitySlider( @@ -129,13 +127,13 @@ protected void init() { public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { // draw category labels this.renderBackground(matrices); - var title = new TranslatableText("colormatic.config.title"); + var title = Text.translatable("colormatic.config.title"); var width = this.textRenderer.getWidth(title); this.textRenderer.drawWithShadow(matrices, title, (this.width - width) / 2.0f, TOP_MARGIN, -1); - var fogSettingsTitle = new TranslatableText("colormatic.config.category.fog"); + var fogSettingsTitle = Text.translatable("colormatic.config.category.fog"); width = this.textRenderer.getWidth(fogSettingsTitle); this.textRenderer.drawWithShadow(matrices, fogSettingsTitle, (this.width - width) / 2.0f, TOP_MARGIN + STANDARD_HEIGHT, -1); - var lightSettingsTitle = new TranslatableText("colormatic.config.category.light"); + var lightSettingsTitle = Text.translatable("colormatic.config.category.light"); width = this.textRenderer.getWidth(lightSettingsTitle); this.textRenderer.drawWithShadow(matrices, lightSettingsTitle, (this.width - width) / 2.0f, this.fogSectionBottom + STANDARD_HEIGHT, -1); var tooltip = this.getTooltip(mouseX, mouseY); @@ -174,16 +172,16 @@ public BlockLightIntensitySlider(int x, int y) { y, ColormaticConfigScreen.STANDARD_WIDTH, ColormaticConfigScreen.STANDARD_HEIGHT, - LiteralText.EMPTY, + Text.empty(), 1.0 - ColormaticConfigScreen.this.config.relativeBlockLightIntensityExponent / -16.0); this.updateMessage(); } @Override protected void updateMessage() { - this.setMessage(new TranslatableText("colormatic.config.option.relativeBlockLightIntensity") + this.setMessage(Text.translatable("colormatic.config.option.relativeBlockLightIntensity") .append(": ") - .append(new LiteralText(String.valueOf((int)(100 * Math.exp(ColormaticConfig.scaled(this.configValue()))))).append("%"))); + .append(Text.literal(String.valueOf((int)(100 * Math.exp(ColormaticConfig.scaled(this.configValue()))))).append("%"))); } @Override @@ -197,7 +195,7 @@ private double configValue() { @Override public List getOrderedTooltip() { - return ColormaticConfigScreen.this.textRenderer.wrapLines(new TranslatableText("colormatic.config.option.relativeBlockLightIntensity.desc"), TOOLTIP_WIDTH); + return ColormaticConfigScreen.this.textRenderer.wrapLines(Text.translatable("colormatic.config.option.relativeBlockLightIntensity.desc"), TOOLTIP_WIDTH); } } } diff --git a/src/main/java/io/github/kvverti/colormatic/colormap/DefaultColormaticResolverProviders.java b/src/main/java/io/github/kvverti/colormatic/colormap/DefaultColormaticResolverProviders.java index 4323377..119a0cc 100644 --- a/src/main/java/io/github/kvverti/colormatic/colormap/DefaultColormaticResolverProviders.java +++ b/src/main/java/io/github/kvverti/colormatic/colormap/DefaultColormaticResolverProviders.java @@ -1,6 +1,6 @@ /* * Colormatic - * Copyright (C) 2021 Thalia Nero + * Copyright (C) 2021-2022 Thalia Nero * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -72,7 +72,7 @@ private static ColormaticResolver byBlock(Block key) { private static ColormaticResolver bySky(Identifier key) { return (manager, biome, posX, posY, posZ) -> { int color; - if(Colormatic.SKY_COLORS.hasCustomColormap() && key.equals(DimensionType.OVERWORLD_ID)) { + if(Colormatic.SKY_COLORS.hasCustomColormap() && key.equals(Colormatic.OVERWORLD_ID)) { color = Colormatic.SKY_COLORS.getColormap().getColor(manager, biome, posX, posY, posZ); } else { color = Colormatic.COLOR_PROPS.getProperties().getDimensionSky(key); @@ -87,7 +87,7 @@ private static ColormaticResolver bySky(Identifier key) { private static ColormaticResolver byFog(Identifier key) { return (manager, biome, posX, posY, posZ) -> { int color; - if(Colormatic.FOG_COLORS.hasCustomColormap() && key.equals(DimensionType.OVERWORLD_ID)) { + if(Colormatic.FOG_COLORS.hasCustomColormap() && key.equals(Colormatic.OVERWORLD_ID)) { color = 0xff000000 | Colormatic.FOG_COLORS.getColormap().getColor(manager, biome, posX, posY, posZ); } else { color = Colormatic.COLOR_PROPS.getProperties().getDimensionFog(key); diff --git a/src/main/java/io/github/kvverti/colormatic/iface/ColormaticFluidRenderHandler.java b/src/main/java/io/github/kvverti/colormatic/iface/ColormaticFluidRenderHandler.java index c91167d..1844de9 100644 --- a/src/main/java/io/github/kvverti/colormatic/iface/ColormaticFluidRenderHandler.java +++ b/src/main/java/io/github/kvverti/colormatic/iface/ColormaticFluidRenderHandler.java @@ -59,8 +59,8 @@ public int getFluidColor(@Nullable BlockRenderView view, @Nullable BlockPos pos, } @Override - public boolean renderFluid(BlockPos pos, BlockRenderView world, VertexConsumer vertexConsumer, BlockState blockState, FluidState fluidState) { - return this.delegate.renderFluid(pos, world, vertexConsumer, blockState, fluidState); + public void renderFluid(BlockPos pos, BlockRenderView world, VertexConsumer vertexConsumer, BlockState blockState, FluidState fluidState) { + this.delegate.renderFluid(pos, world, vertexConsumer, blockState, fluidState); } @Override diff --git a/src/main/java/io/github/kvverti/colormatic/iface/DimensionTypeEquals.java b/src/main/java/io/github/kvverti/colormatic/iface/DimensionTypeEquals.java deleted file mode 100644 index 8aedeab..0000000 --- a/src/main/java/io/github/kvverti/colormatic/iface/DimensionTypeEquals.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Colormatic - * Copyright (C) 2022 Thalia Nero - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * As an additional permission, when conveying the Corresponding Source of an - * object code form of this work, you may exclude the Corresponding Source for - * "Minecraft" by Mojang Studios, AB. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ -package io.github.kvverti.colormatic.iface; - -import org.jetbrains.annotations.Nullable; - -import net.minecraft.world.dimension.DimensionType; - -/** - * Stores an equals() method for DimensionTypes. Because Mojang got rid of the existing one. - */ -public interface DimensionTypeEquals { - - /** - * Equality for two dimension types. - */ - boolean colormatic_equals(@Nullable DimensionType other); -} diff --git a/src/main/java/io/github/kvverti/colormatic/mixin/block/RedstoneWireBlockMixin.java b/src/main/java/io/github/kvverti/colormatic/mixin/block/RedstoneWireBlockMixin.java index 88c25c8..f663460 100644 --- a/src/main/java/io/github/kvverti/colormatic/mixin/block/RedstoneWireBlockMixin.java +++ b/src/main/java/io/github/kvverti/colormatic/mixin/block/RedstoneWireBlockMixin.java @@ -1,6 +1,6 @@ /* * Colormatic - * Copyright (C) 2021 Thalia Nero + * Copyright (C) 2021-2022 Thalia Nero * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -21,8 +21,6 @@ */ package io.github.kvverti.colormatic.mixin.block; -import java.util.Random; - import io.github.kvverti.colormatic.Colormatic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -37,6 +35,7 @@ import net.minecraft.particle.DustParticleEffect; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.random.Random; import net.minecraft.world.World; /** diff --git a/src/main/java/io/github/kvverti/colormatic/mixin/model/ModelLoaderMixin.java b/src/main/java/io/github/kvverti/colormatic/mixin/model/ModelLoaderMixin.java index 8b666fb..ce6b599 100644 --- a/src/main/java/io/github/kvverti/colormatic/mixin/model/ModelLoaderMixin.java +++ b/src/main/java/io/github/kvverti/colormatic/mixin/model/ModelLoaderMixin.java @@ -1,6 +1,6 @@ /* * Colormatic - * Copyright (C) 2021 Thalia Nero + * Copyright (C) 2021-2022 Thalia Nero * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -37,15 +37,18 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.model.ModelLoader; import net.minecraft.client.util.ModelIdentifier; +import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.argument.BlockStateArgumentType; import net.minecraft.util.Identifier; +import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.util.registry.Registry; @Mixin(ModelLoader.class) public abstract class ModelLoaderMixin { + // using the built in DRM is fine because blocks aren't dynamic. @Unique - private static final BlockStateArgumentType BLOCK_STATE_PARSER = BlockStateArgumentType.blockState(); + private static final BlockStateArgumentType BLOCK_STATE_PARSER = BlockStateArgumentType.blockState(new CommandRegistryAccess(DynamicRegistryManager.BUILTIN.get())); /** * Partially determines whether Colormatic should replace the tint on a model. diff --git a/src/main/java/io/github/kvverti/colormatic/mixin/network/ClientPlayNetworkHandlerMixin.java b/src/main/java/io/github/kvverti/colormatic/mixin/network/ClientPlayNetworkHandlerMixin.java deleted file mode 100644 index 7712184..0000000 --- a/src/main/java/io/github/kvverti/colormatic/mixin/network/ClientPlayNetworkHandlerMixin.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Colormatic - * Copyright (C) 2021-2022 Thalia Nero - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * As an additional permission, when conveying the Corresponding Source of an - * object code form of this work, you may exclude the Corresponding Source for - * "Minecraft" by Mojang Studios, AB. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ -package io.github.kvverti.colormatic.mixin.network; - -import io.github.kvverti.colormatic.Colormatic; -import io.github.kvverti.colormatic.iface.DimensionTypeEquals; -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.ModifyVariable; - -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.util.registry.DynamicRegistryManager; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryEntry; -import net.minecraft.world.dimension.DimensionType; - -@Mixin(ClientPlayNetworkHandler.class) -public abstract class ClientPlayNetworkHandlerMixin { - - @Shadow - private DynamicRegistryManager.Immutable registryManager; - - /** - * We loop through and make the instances identical since we want to be able to get the ID for a given dimension - * type. - */ - @ModifyVariable( - method = "onPlayerRespawn", - ordinal = 0, - at = @At( - value = "STORE", - ordinal = 0 - ) - ) - private RegistryEntry fixDimensionTypeOnPlayerRespawn(RegistryEntry targetEntry) { - var registry = this.registryManager.get(Registry.DIMENSION_TYPE_KEY); - var target = (DimensionTypeEquals)Colormatic.getRegistryValue(registry, targetEntry); - for(DimensionType dimType : registry) { - if(target.colormatic_equals(dimType)) { - // packet deserializer expects a direct entry - return RegistryEntry.of(dimType); - } - } - return targetEntry; - } -} diff --git a/src/main/java/io/github/kvverti/colormatic/mixin/network/DimensionTypeMixin.java b/src/main/java/io/github/kvverti/colormatic/mixin/network/DimensionTypeMixin.java deleted file mode 100644 index e4c1ec1..0000000 --- a/src/main/java/io/github/kvverti/colormatic/mixin/network/DimensionTypeMixin.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Colormatic - * Copyright (C) 2022 Thalia Nero - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * As an additional permission, when conveying the Corresponding Source of an - * object code form of this work, you may exclude the Corresponding Source for - * "Minecraft" by Mojang Studios, AB. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ -package io.github.kvverti.colormatic.mixin.network; - -import java.util.Arrays; -import java.util.OptionalLong; - -import io.github.kvverti.colormatic.iface.DimensionTypeEquals; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import net.minecraft.block.Block; -import net.minecraft.tag.TagKey; -import net.minecraft.util.Identifier; -import net.minecraft.world.dimension.DimensionType; - -@Mixin(DimensionType.class) -public abstract class DimensionTypeMixin implements DimensionTypeEquals { - @Shadow - @Final - private OptionalLong fixedTime; - - @Shadow - @Final - private boolean hasSkyLight; - - @Shadow - @Final - private boolean hasCeiling; - - @Shadow - @Final - private boolean ultrawarm; - - @Shadow - @Final - private boolean natural; - - @Shadow - @Final - private double coordinateScale; - - @Shadow - @Final - private boolean hasEnderDragonFight; - - @Shadow - @Final - private boolean piglinSafe; - - @Shadow - @Final - private boolean bedWorks; - - @Shadow - @Final - private boolean respawnAnchorWorks; - - @Shadow - @Final - private boolean hasRaids; - - @Shadow - @Final - private int minimumY; - - @Shadow - @Final - private int height; - - @Shadow - @Final - private int logicalHeight; - - @Shadow - @Final - private TagKey infiniburn; - - @Shadow - @Final - private Identifier effects; - - @Shadow - @Final - private float ambientLight; - - @Shadow - @Final - private transient float[] brightnessByLightLevel; - - @Override - public boolean colormatic_equals(@Nullable DimensionType other) { - if(other == null) { - return false; - } - // no-op cast - var that = (DimensionTypeMixin)(Object)other; - return this.fixedTime.equals(that.fixedTime) - && this.hasSkyLight == that.hasSkyLight - && this.hasCeiling == that.hasCeiling - && this.ultrawarm == that.ultrawarm - && this.natural == that.natural - && this.coordinateScale == that.coordinateScale - && this.hasEnderDragonFight == that.hasEnderDragonFight - && this.piglinSafe == that.piglinSafe - && this.bedWorks == that.bedWorks - && this.respawnAnchorWorks == that.respawnAnchorWorks - && this.hasRaids == that.hasRaids - && this.minimumY == that.minimumY - && this.height == that.height - && this.logicalHeight == that.logicalHeight - && this.infiniburn.equals(that.infiniburn) - && this.effects.equals(that.effects) - && this.ambientLight == that.ambientLight - && Arrays.equals(this.brightnessByLightLevel, that.brightnessByLightLevel); - } -} diff --git a/src/main/java/io/github/kvverti/colormatic/mixin/network/GameJoinS2CPacketMixin.java b/src/main/java/io/github/kvverti/colormatic/mixin/network/GameJoinS2CPacketMixin.java deleted file mode 100644 index 0a2d3dc..0000000 --- a/src/main/java/io/github/kvverti/colormatic/mixin/network/GameJoinS2CPacketMixin.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Colormatic - * Copyright (C) 2021-2022 Thalia Nero - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * As an additional permission, when conveying the Corresponding Source of an - * object code form of this work, you may exclude the Corresponding Source for - * "Minecraft" by Mojang Studios, AB. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ -package io.github.kvverti.colormatic.mixin.network; - -import io.github.kvverti.colormatic.Colormatic; -import io.github.kvverti.colormatic.iface.DimensionTypeEquals; -import org.objectweb.asm.Opcodes; -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.callback.CallbackInfo; - -import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; -import net.minecraft.util.registry.DynamicRegistryManager; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryEntry; -import net.minecraft.world.dimension.DimensionType; - -@Mixin(GameJoinS2CPacket.class) -public abstract class GameJoinS2CPacketMixin { - - @Final - @Mutable - @Shadow - private RegistryEntry dimensionType; - - @Final - @Shadow - private DynamicRegistryManager.Immutable registryManager; - - /** - * We loop through and make the instances identical since we want to be able to get the ID for a given dimension - * type. - */ - @Inject( - method = "(IZLnet/minecraft/world/GameMode;Lnet/minecraft/world/GameMode;Ljava/util/Set;Lnet/minecraft/util/registry/DynamicRegistryManager$Immutable;Lnet/minecraft/util/registry/RegistryEntry;Lnet/minecraft/util/registry/RegistryKey;JIIIZZZZ)V", - at = @At( - value = "FIELD", - target = "Lnet/minecraft/network/packet/s2c/play/GameJoinS2CPacket;dimensionType:Lnet/minecraft/util/registry/RegistryEntry;", - ordinal = 0, - opcode = Opcodes.PUTFIELD, - shift = At.Shift.AFTER - ) - ) - private void fixDimensionType(CallbackInfo info) { - Registry registry = this.registryManager.get(Registry.DIMENSION_TYPE_KEY); - DimensionTypeEquals target = (DimensionTypeEquals)Colormatic.getRegistryValue(registry, this.dimensionType); - for(DimensionType dimType : registry) { - if(target.colormatic_equals(dimType)) { - // ClientWorld eventually expects a direct entry - this.dimensionType = RegistryEntry.of(dimType); - break; - } - } - } -} diff --git a/src/main/java/io/github/kvverti/colormatic/mixin/render/LightmapTextureManagerMixin.java b/src/main/java/io/github/kvverti/colormatic/mixin/render/LightmapTextureManagerMixin.java index 99a01bb..fb9fa67 100644 --- a/src/main/java/io/github/kvverti/colormatic/mixin/render/LightmapTextureManagerMixin.java +++ b/src/main/java/io/github/kvverti/colormatic/mixin/render/LightmapTextureManagerMixin.java @@ -203,7 +203,7 @@ private void onUpdate(float partialTicks, CallbackInfo info) { rbright = 1.0f - rbright; gbright = 1.0f - gbright; bbright = 1.0f - bbright; - float brightness = (float)this.client.options.gamma; + float brightness = this.client.options.getGamma().getValue().floatValue(); r = r * (1.0f - brightness) + rbright * brightness; g = g * (1.0f - brightness) + gbright * brightness; b = b * (1.0f - brightness) + bbright * brightness; @@ -246,7 +246,7 @@ private float modifySkyAmbience(float ambience) { value = "STORE", ordinal = 0 ), - index = 13 + index = 16 ) private float modifyFlickerIntensity(float blockLight) { int sky = lightIndex >>> 4; diff --git a/src/main/java/io/github/kvverti/colormatic/mixin/world/ClientWorldMixin.java b/src/main/java/io/github/kvverti/colormatic/mixin/world/ClientWorldMixin.java index d5724ba..2f2b9a6 100644 --- a/src/main/java/io/github/kvverti/colormatic/mixin/world/ClientWorldMixin.java +++ b/src/main/java/io/github/kvverti/colormatic/mixin/world/ClientWorldMixin.java @@ -1,6 +1,6 @@ /* * Colormatic - * Copyright (C) 2021 Thalia Nero + * Copyright (C) 2021-2022 Thalia Nero * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -62,7 +62,7 @@ public abstract class ClientWorldMixin extends World { public abstract DynamicRegistryManager getRegistryManager(); private ClientWorldMixin() { - super(null, null, null, null, false, false, 0L); + super(null, null, null, null, false, false, 0L, 0); } @ModifyArg( diff --git a/src/main/java/io/github/kvverti/colormatic/mixinsodium/world/SodiumClientWorldMixin.java b/src/main/java/io/github/kvverti/colormatic/mixinsodium/world/SodiumClientWorldMixin.java index 7ba45bc..df49468 100644 --- a/src/main/java/io/github/kvverti/colormatic/mixinsodium/world/SodiumClientWorldMixin.java +++ b/src/main/java/io/github/kvverti/colormatic/mixinsodium/world/SodiumClientWorldMixin.java @@ -35,7 +35,7 @@ public abstract class SodiumClientWorldMixin extends World implements BiomeSeedProvider { private SodiumClientWorldMixin() { - super(null, null, null, null, false, false, 0L); + super(null, null, null, null, false, false, 0L, 0); } @Override diff --git a/src/main/java/io/github/kvverti/colormatic/properties/ColormapProperties.java b/src/main/java/io/github/kvverti/colormatic/properties/ColormapProperties.java index 2af0ae2..bc90d4b 100644 --- a/src/main/java/io/github/kvverti/colormatic/properties/ColormapProperties.java +++ b/src/main/java/io/github/kvverti/colormatic/properties/ColormapProperties.java @@ -327,7 +327,7 @@ public String asString() { * from the identifier name. */ public static ColormapProperties load(ResourceManager manager, Identifier id, boolean custom) { - try(Resource rsc = manager.getResource(id); InputStream in = rsc.getInputStream()) { + try(InputStream in = manager.getResourceOrThrow(id).getInputStream()) { try(Reader r = PropertyUtil.getJsonReader(in, id, k -> k, "blocks"::equals)) { return loadFromJson(r, id, custom); } diff --git a/src/main/java/io/github/kvverti/colormatic/properties/GlobalColorProperties.java b/src/main/java/io/github/kvverti/colormatic/properties/GlobalColorProperties.java index cfc36d3..f8ae8ac 100644 --- a/src/main/java/io/github/kvverti/colormatic/properties/GlobalColorProperties.java +++ b/src/main/java/io/github/kvverti/colormatic/properties/GlobalColorProperties.java @@ -1,6 +1,6 @@ /* * Colormatic - * Copyright (C) 2021 Thalia Nero + * Copyright (C) 2021-2022 Thalia Nero * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -322,7 +322,7 @@ public String asString() { } public static GlobalColorProperties load(ResourceManager manager, Identifier id, boolean fall) { - try(Resource rsc = manager.getResource(id); InputStream in = rsc.getInputStream()) { + try(InputStream in = manager.getResourceOrThrow(id).getInputStream()) { try(Reader r = PropertyUtil.getJsonReader(in, id, k -> keyRemap.getOrDefault(k, k), k -> false)) { return loadFromJson(r, id); } diff --git a/src/main/java/io/github/kvverti/colormatic/properties/LightmapProperties.java b/src/main/java/io/github/kvverti/colormatic/properties/LightmapProperties.java index 99a2012..8a5c774 100644 --- a/src/main/java/io/github/kvverti/colormatic/properties/LightmapProperties.java +++ b/src/main/java/io/github/kvverti/colormatic/properties/LightmapProperties.java @@ -1,6 +1,6 @@ /* * Colormatic - * Copyright (C) 2021 Thalia Nero + * Copyright (C) 2021-2022 Thalia Nero * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -50,7 +50,7 @@ private LightmapProperties(Settings settings) { */ public static LightmapProperties load(ResourceManager manager, Identifier id) { Settings settings; - try(Resource rsc = manager.getResource(id); Reader in = new InputStreamReader(rsc.getInputStream())) { + try(Reader in = new InputStreamReader(manager.getResourceOrThrow(id).getInputStream())) { settings = PropertyUtil.PROPERTY_GSON.fromJson(in, Settings.class); } catch(JsonParseException e) { log.error("Error parsing {}: {}", id, e.getMessage()); diff --git a/src/main/java/io/github/kvverti/colormatic/properties/PropertyUtil.java b/src/main/java/io/github/kvverti/colormatic/properties/PropertyUtil.java index 9da594e..6c47e4e 100644 --- a/src/main/java/io/github/kvverti/colormatic/properties/PropertyUtil.java +++ b/src/main/java/io/github/kvverti/colormatic/properties/PropertyUtil.java @@ -45,7 +45,6 @@ import net.minecraft.block.MapColor; import net.minecraft.client.texture.NativeImage; -import net.minecraft.resource.Resource; import net.minecraft.resource.ResourceManager; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; @@ -175,7 +174,7 @@ public static PropertyImage loadColormap(ResourceManager manager, Identifier id, // fixed format does not have a corresponding image return new PropertyImage(props, null); } - try(Resource rsc = manager.getResource(props.getSource()); InputStream in = rsc.getInputStream()) { + try(InputStream in = manager.getResourceOrThrow(props.getSource()).getInputStream()) { NativeImage image = NativeImage.read(in); if(ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) { // swap the red and blue channels of every pixel, because the biome diff --git a/src/main/java/io/github/kvverti/colormatic/resource/CustomBiomeColormapsResource.java b/src/main/java/io/github/kvverti/colormatic/resource/CustomBiomeColormapsResource.java index 092488a..a83b96b 100644 --- a/src/main/java/io/github/kvverti/colormatic/resource/CustomBiomeColormapsResource.java +++ b/src/main/java/io/github/kvverti/colormatic/resource/CustomBiomeColormapsResource.java @@ -1,6 +1,6 @@ /* * Colormatic - * Copyright (C) 2021 Thalia Nero + * Copyright (C) 2021-2022 Thalia Nero * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -72,9 +72,10 @@ public void reload(ResourceManager manager) { private static void addColormaps(ResourceManager manager, Identifier dir, boolean json) { String ext = json ? ".json" : ".properties"; - Collection files = manager.findResources(dir.getPath(), s -> s.endsWith(ext) || s.endsWith(".png")) + Collection files = manager.findResources(dir.getPath(), + id -> id.getNamespace().equals(dir.getNamespace()) && (id.getPath().endsWith(ext) || id.getPath().endsWith(".png"))) + .keySet() .stream() - .filter(id -> id.getNamespace().equals(dir.getNamespace())) .map(id -> { // count plain source images as properties so they're found var path = id.getPath(); diff --git a/src/main/java/io/github/kvverti/colormatic/resource/LightmapsResource.java b/src/main/java/io/github/kvverti/colormatic/resource/LightmapsResource.java index 4c88679..92d1812 100644 --- a/src/main/java/io/github/kvverti/colormatic/resource/LightmapsResource.java +++ b/src/main/java/io/github/kvverti/colormatic/resource/LightmapsResource.java @@ -1,6 +1,6 @@ /* * Colormatic - * Copyright (C) 2021 Thalia Nero + * Copyright (C) 2021-2022 Thalia Nero * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -21,12 +21,9 @@ */ package io.github.kvverti.colormatic.resource; -import static java.util.stream.Collectors.toList; - import java.io.IOException; import java.io.InputStream; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; @@ -36,14 +33,13 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import net.fabricmc.fabric.api.resource.SimpleResourceReloadListener; import net.minecraft.client.texture.NativeImage; import net.minecraft.resource.Resource; import net.minecraft.resource.ResourceManager; import net.minecraft.util.Identifier; import net.minecraft.util.profiler.Profiler; -import net.fabricmc.fabric.api.resource.SimpleResourceReloadListener; - public class LightmapsResource implements SimpleResourceReloadListener> { private static final Logger logger = LogManager.getLogger(); @@ -72,14 +68,12 @@ public CompletableFuture> load(ResourceManager mana // Key = dimension ID, Value = lightmap image private static Map getLightmaps(ResourceManager manager, Identifier dir) { - List files = manager.findResources(dir.getPath(), s -> s.endsWith(".png")) - .stream() - .filter(id -> id.getNamespace().equals(dir.getNamespace())) - .distinct() - .collect(toList()); + Map files = manager + .findResources(dir.getPath(), s -> s.getPath().endsWith(".png") && s.getNamespace().equals(dir.getNamespace())); Map res = new HashMap<>(files.size()); - for(Identifier id : files) { - try(Resource rsc = manager.getResource(id); InputStream in = rsc.getInputStream()) { + for(Map.Entry entry : files.entrySet()) { + Identifier id = entry.getKey(); + try(InputStream in = entry.getValue().getInputStream()) { // colormatic:lightmap/minecraft/overworld.png -> minecraft:overworld // colormatic:lightmap/the_nether.png -> minecraft:the_nether // minecraft:optifine/lightmap/world1.png -> minecraft:the_end @@ -102,16 +96,12 @@ private static Map getLightmaps(ResourceManager manager private static String fixOptifineDimId(String dimIdStr) { // fix Optifine dimension IDs - switch(dimIdStr) { - case "world0": - return "minecraft:overworld"; - case "world1": - return "minecraft:the_end"; - case "world-1": - return "minecraft:the_nether"; - default: - return dimIdStr; - } + return switch(dimIdStr) { + case "world0" -> "minecraft:overworld"; + case "world1" -> "minecraft:the_end"; + case "world-1" -> "minecraft:the_nether"; + default -> dimIdStr; + }; } @Override diff --git a/src/main/resources/colormatic.mixins.json b/src/main/resources/colormatic.mixins.json index 7845931..09517c4 100644 --- a/src/main/resources/colormatic.mixins.json +++ b/src/main/resources/colormatic.mixins.json @@ -20,9 +20,6 @@ "model.BakedQuadFactoryMixin", "model.JsonUnbakedModelMixin", "model.ModelLoaderMixin", - "network.ClientPlayNetworkHandlerMixin", - "network.DimensionTypeMixin", - "network.GameJoinS2CPacketMixin", "network.MinecraftClientMixin", "particle.DrippingLavaParticleMixin", "particle.DustParticleEffectMixin",