Fixed grass/foliage colours
This commit is contained in:
parent
39aec91eb2
commit
70ee37f212
8 changed files with 81 additions and 9 deletions
|
@ -35,13 +35,17 @@ public class BiomeMetadata
|
|||
@Nullable
|
||||
private final BiFunction<Double, Double, Integer> grassColorFunction;
|
||||
|
||||
protected BiomeMetadata(Map<BOPClimates, Integer> weights, @Nullable RegistryKey<Biome> beachBiome, @Nullable RegistryKey<Biome> riverBiome, BiFunction<Double, Double, Integer> foliageColorFunction, BiFunction<Double, Double, Integer> grassColorFunction)
|
||||
@Nullable
|
||||
private final BiFunction<Double, Double, Integer> waterColorFunction;
|
||||
|
||||
protected BiomeMetadata(Map<BOPClimates, Integer> weights, @Nullable RegistryKey<Biome> beachBiome, @Nullable RegistryKey<Biome> riverBiome, BiFunction<Double, Double, Integer> foliageColorFunction, BiFunction<Double, Double, Integer> grassColorFunction, BiFunction<Double, Double, Integer> waterColorFunction)
|
||||
{
|
||||
this.weightMap = ImmutableMap.copyOf(weights);
|
||||
this.beachBiome = beachBiome;
|
||||
this.riverBiome = riverBiome;
|
||||
this.foliageColorFunction = foliageColorFunction;
|
||||
this.grassColorFunction = grassColorFunction;
|
||||
this.waterColorFunction = waterColorFunction;
|
||||
}
|
||||
|
||||
public Map<BOPClimates, Integer> getWeightMap()
|
||||
|
@ -73,6 +77,12 @@ public class BiomeMetadata
|
|||
return this.grassColorFunction;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BiFunction<Double, Double, Integer> getWaterColorFunction()
|
||||
{
|
||||
return this.waterColorFunction;
|
||||
}
|
||||
|
||||
public boolean hasWeights()
|
||||
{
|
||||
return !this.weightMap.isEmpty() && !this.weightMap.entrySet().stream().allMatch((entry) -> entry.getValue().equals(0));
|
||||
|
|
|
@ -34,6 +34,7 @@ public class BiomeTemplate
|
|||
private RegistryKey<Biome> riverBiome = Biomes.RIVER;
|
||||
private BiFunction<Double, Double, Integer> foliageColorFunction;
|
||||
private BiFunction<Double, Double, Integer> grassColorFunction;
|
||||
private BiFunction<Double, Double, Integer> waterColorFunction;
|
||||
|
||||
protected void configureBiome(Biome.Builder builder) {}
|
||||
protected void configureGeneration(BiomeGenerationSettingsRegistryBuilder builder) {}
|
||||
|
@ -66,7 +67,7 @@ public class BiomeTemplate
|
|||
|
||||
public final BiomeMetadata buildMetadata()
|
||||
{
|
||||
return new BiomeMetadata(this.weightMap, this.beachBiome, this.riverBiome, this.foliageColorFunction, this.grassColorFunction);
|
||||
return new BiomeMetadata(this.weightMap, this.beachBiome, this.riverBiome, this.foliageColorFunction, this.grassColorFunction, this.waterColorFunction);
|
||||
}
|
||||
|
||||
public void addWeight(BOPClimates climate, int weight)
|
||||
|
@ -94,6 +95,11 @@ public class BiomeTemplate
|
|||
this.grassColorFunction = func;
|
||||
}
|
||||
|
||||
public void setWaterColorFunction(BiFunction<Double, Double, Integer> func)
|
||||
{
|
||||
this.waterColorFunction = func;
|
||||
}
|
||||
|
||||
public static int calculateSkyColor(float temperature)
|
||||
{
|
||||
float lvt_1_1_ = temperature / 3.0F;
|
||||
|
|
|
@ -31,6 +31,7 @@ public class FungalJungleBiome extends BiomeTemplate
|
|||
{
|
||||
this.addWeight(BOPClimates.TROPICAL, 1);
|
||||
this.setBeachBiome(null);
|
||||
this.setGrassColorFunction(this::getGrassColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,9 +97,9 @@ public class FungalJungleBiome extends BiomeTemplate
|
|||
builder.addSpawn(EntityClassification.MONSTER, new MobSpawnInfo.Spawners(EntityType.WITCH, 5, 1, 1));
|
||||
}
|
||||
|
||||
//TODO: Change grass color to use new system in special effects
|
||||
/*public int getGrassColor(double x, double z) {
|
||||
public int getGrassColor(double x, double z)
|
||||
{
|
||||
double d0 = Biome.BIOME_INFO_NOISE.getValue(x * 0.0225D, z * 0.0225D, false);
|
||||
return d0 < -0.1D ? 0x4AA2F9 : 0x4DD6CA;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public class RainbowValleyBiome extends BiomeTemplate
|
|||
public RainbowValleyBiome()
|
||||
{
|
||||
this.setBeachBiome(null);
|
||||
this.setGrassColorFunction(this::getGrassColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,14 +92,13 @@ public class RainbowValleyBiome extends BiomeTemplate
|
|||
builder.addSpawn(EntityClassification.AMBIENT, new MobSpawnInfo.Spawners(EntityType.BAT, 10, 8, 8));
|
||||
}
|
||||
|
||||
//TODO: Change grass/foliage color to use new system in special effects
|
||||
/*public int getGrassColor(double x, double z)
|
||||
public int getGrassColor(double x, double z)
|
||||
{
|
||||
if (ClientProxy.isAprilFools) { return 0xFFFFFF; }
|
||||
|
||||
double d0 = Biome.BIOME_INFO_NOISE.getValue(x * 0.0225D, z * 0.0225D, false);
|
||||
return d0 < -0.1D ? 0x77CE7F : 0x75CE8D;
|
||||
}*/
|
||||
}
|
||||
|
||||
public int getFoliageColor()
|
||||
{
|
||||
|
|
|
@ -93,7 +93,6 @@ public class SilkgladeBiome extends BiomeTemplate
|
|||
|
||||
private int getGrassColor(double x, double z)
|
||||
{
|
||||
BiomesOPlenty.logger.info("Color!");
|
||||
double d0 = Biome.BIOME_INFO_NOISE.getValue(x * 0.0225D, z * 0.0225D, false);
|
||||
return d0 < -0.1D ? 0xB2B39F : 0x939F76;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ package biomesoplenty.common.util.biome;
|
|||
import biomesoplenty.common.biome.BiomeMetadata;
|
||||
import biomesoplenty.core.BiomesOPlenty;
|
||||
import biomesoplenty.init.ModBiomes;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.registry.DynamicRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
@ -84,4 +85,9 @@ public class BiomeUtil
|
|||
{
|
||||
return getBiome(id) != null;
|
||||
}
|
||||
|
||||
public static RegistryKey<Biome> getClientKey(Biome biome)
|
||||
{
|
||||
return Minecraft.getInstance().level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getResourceKey(biome).get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
******************************************************************************/
|
||||
package biomesoplenty.init;
|
||||
|
||||
import biomesoplenty.api.biome.BOPBiomes;
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.biome.BiomeMetadata;
|
||||
import biomesoplenty.common.biome.BiomeRegistry;
|
||||
|
@ -20,16 +21,21 @@ import biomesoplenty.common.util.biome.BiomeUtil;
|
|||
import biomesoplenty.common.world.BOPBiomeGeneratorTypeScreen;
|
||||
import biomesoplenty.common.world.BOPBiomeProvider;
|
||||
import biomesoplenty.common.world.BOPNetherBiomeProvider;
|
||||
import biomesoplenty.core.BiomesOPlenty;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.BiomeGeneratorTypeScreens;
|
||||
import net.minecraft.entity.villager.VillagerType;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeColors;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.world.level.ColorResolver;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
@ -56,6 +62,49 @@ public class ModBiomes
|
|||
{
|
||||
biomeGeneratorTypeScreenBOP = new BOPBiomeGeneratorTypeScreen();
|
||||
BiomeGeneratorTypeScreens.PRESETS.add(biomeGeneratorTypeScreenBOP);
|
||||
|
||||
ColorResolver grassColorResolver = BiomeColors.GRASS_COLOR_RESOLVER;
|
||||
ColorResolver foliageColorResolver = BiomeColors.FOLIAGE_COLOR_RESOLVER;
|
||||
ColorResolver waterColorResolver = BiomeColors.WATER_COLOR_RESOLVER;
|
||||
|
||||
BiomeColors.GRASS_COLOR_RESOLVER = (biome, posX, posZ) ->
|
||||
{
|
||||
RegistryKey<Biome> key = BiomeUtil.getClientKey(biome);
|
||||
BiomeMetadata meta = BiomeUtil.getMetadata(key);
|
||||
|
||||
if (meta != null && meta.getGrassColorFunction() != null)
|
||||
{
|
||||
return meta.getGrassColorFunction().apply(posX, posZ);
|
||||
}
|
||||
|
||||
return grassColorResolver.getColor(biome, posX, posZ);
|
||||
};
|
||||
|
||||
BiomeColors.FOLIAGE_COLOR_RESOLVER = (biome, posX, posZ) ->
|
||||
{
|
||||
RegistryKey<Biome> key = BiomeUtil.getClientKey(biome);
|
||||
BiomeMetadata meta = BiomeUtil.getMetadata(key);
|
||||
|
||||
if (meta != null && meta.getFoliageColorFunction() != null)
|
||||
{
|
||||
return meta.getGrassColorFunction().apply(posX, posZ);
|
||||
}
|
||||
|
||||
return foliageColorResolver.getColor(biome, posX, posZ);
|
||||
};
|
||||
|
||||
BiomeColors.WATER_COLOR_RESOLVER = (biome, posX, posZ) ->
|
||||
{
|
||||
RegistryKey<Biome> key = BiomeUtil.getClientKey(biome);
|
||||
BiomeMetadata meta = BiomeUtil.getMetadata(key);
|
||||
|
||||
if (meta != null && meta.getGrassColorFunction() != null)
|
||||
{
|
||||
return meta.getGrassColorFunction().apply(posX, posZ);
|
||||
}
|
||||
|
||||
return waterColorResolver.getColor(biome, posX, posZ);
|
||||
};
|
||||
}
|
||||
|
||||
// Register biome providers
|
||||
|
|
|
@ -6,6 +6,7 @@ public net.minecraft.client.gui.screen.BiomeGeneratorTypeScreens <init>(Ljava/la
|
|||
public net.minecraft.block.Blocks *()
|
||||
public net.minecraft.client.Minecraft$PackManager *()
|
||||
public-f net.minecraft.entity.villager.VillagerType field_221180_h
|
||||
public-f net.minecraft.world.biome.BiomeColors *
|
||||
|
||||
# Set worldtype as default and skip the confirm backup screen
|
||||
public-f net.minecraft.client.gui.screen.ConfirmBackupScreen *
|
||||
|
|
Loading…
Reference in a new issue