remove BiomeEffectsAccessor

This commit is contained in:
dfsek
2022-04-24 21:57:51 -07:00
parent 85d951e367
commit 834404c477
3 changed files with 10 additions and 62 deletions

View File

@@ -1,49 +0,0 @@
/*
* This file is part of Terra.
*
* Terra is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Terra 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
*/
package com.dfsek.terra.fabric.mixin.access;
import net.minecraft.world.biome.BiomeEffects;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Optional;
@Mixin(BiomeEffects.class)
public interface BiomeEffectsAccessor {
@Accessor("fogColor")
int getFogColor();
@Accessor("waterColor")
int getWaterColor();
@Accessor("waterFogColor")
int getWaterFogColor();
@Accessor("skyColor")
int getSkyColor();
@Accessor("foliageColor")
Optional<Integer> getFoliageColor();
@Accessor("grassColor")
Optional<Integer> getGrassColor();
@Accessor("grassColorModifier")
BiomeEffects.GrassColorModifier getGrassColorModifier();
}

View File

@@ -50,7 +50,6 @@ import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.fabric.FabricEntryPoint;
import com.dfsek.terra.fabric.config.PreLoadCompatibilityOptions;
import com.dfsek.terra.fabric.config.VanillaBiomeProperties;
import com.dfsek.terra.fabric.mixin.access.BiomeEffectsAccessor;
public final class FabricUtil {
@@ -137,10 +136,8 @@ public final class FabricUtil {
public static net.minecraft.world.biome.Biome createBiome(Biome biome, net.minecraft.world.biome.Biome vanilla) {
GenerationSettings.Builder generationSettings = new GenerationSettings.Builder();
BiomeEffectsAccessor accessor = (BiomeEffectsAccessor) vanilla.getEffects();
BiomeEffects.Builder effects = new BiomeEffects.Builder();
net.minecraft.world.biome.Biome.Builder builder = new Builder();
if(biome.getContext().has(VanillaBiomeProperties.class)) {
@@ -150,17 +147,17 @@ public final class FabricUtil {
.waterFogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterFogColor(), vanilla.getWaterFogColor()))
.fogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFogColor(), vanilla.getFogColor()))
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()))
.grassColorModifier(Objects.requireNonNullElse(vanillaBiomeProperties.getModifier(), accessor.getGrassColorModifier()));
.grassColorModifier(Objects.requireNonNullElse(vanillaBiomeProperties.getModifier(), vanilla.getEffects().getGrassColorModifier()));
if(vanillaBiomeProperties.getGrassColor() == null) {
accessor.getGrassColor().ifPresent(effects::grassColor);
vanilla.getEffects().getGrassColor().ifPresent(effects::grassColor);
} else {
effects.grassColor(vanillaBiomeProperties.getGrassColor());
}
if(vanillaBiomeProperties.getFoliageColor() == null) {
accessor.getFoliageColor().ifPresent(effects::foliageColor);
vanilla.getEffects().getFoliageColor().ifPresent(effects::foliageColor);
} else {
effects.foliageColor(vanillaBiomeProperties.getFoliageColor());
}
@@ -170,12 +167,13 @@ public final class FabricUtil {
.category(Objects.requireNonNullElse(vanillaBiomeProperties.getCategory(), vanilla.getCategory()));
} else {
effects.waterColor(accessor.getWaterColor())
.waterFogColor(accessor.getWaterFogColor())
.fogColor(accessor.getFogColor())
.skyColor(accessor.getSkyColor());
accessor.getFoliageColor().ifPresent(effects::foliageColor);
accessor.getGrassColor().ifPresent(effects::grassColor);
effects.waterColor(vanilla.getWaterColor())
.waterFogColor(vanilla.getWaterFogColor())
.fogColor(vanilla.getFogColor())
.skyColor(vanilla.getSkyColor());
vanilla.getEffects().getFoliageColor().ifPresent(effects::foliageColor);
vanilla.getEffects().getGrassColor().ifPresent(effects::grassColor);
builder.precipitation(vanilla.getPrecipitation())
.category(vanilla.getCategory());

View File

@@ -4,7 +4,6 @@
"package": "com.dfsek.terra.fabric.mixin",
"compatibilityLevel": "JAVA_16",
"mixins": [
"access.BiomeEffectsAccessor",
"access.MobSpawnerLogicAccessor",
"access.StateAccessor",
"access.StructureAccessorAccessor",