|
| 1 | +package me.outspending.biomesapi.renderer; |
| 2 | + |
| 3 | +import me.outspending.biomesapi.wrapper.AmbientParticle; |
| 4 | +import me.outspending.biomesapi.wrapper.MoonPhase; |
| 5 | +import me.outspending.biomesapi.wrapper.WrappedEnvironmentAttribute; |
| 6 | +import net.minecraft.core.particles.ParticleOptions; |
| 7 | +import net.minecraft.world.attribute.EnvironmentAttributeMap; |
| 8 | +import net.minecraft.world.attribute.EnvironmentAttributes; |
| 9 | + |
| 10 | + |
| 11 | +public class VisualElements { |
| 12 | + |
| 13 | + // fogColor handled elsewhere |
| 14 | + private WrappedEnvironmentAttribute<Float, Float> fogStartDistance; |
| 15 | + private WrappedEnvironmentAttribute<Float, Float> fogEndDistance; |
| 16 | + private WrappedEnvironmentAttribute<Float, Float> skyFogEndDistance; |
| 17 | + private WrappedEnvironmentAttribute<Float, Float> cloudFogEndDistance; |
| 18 | + // waterFogColor handled elsewhere |
| 19 | + private WrappedEnvironmentAttribute<Float, Float> waterFogStartDistance; |
| 20 | + private WrappedEnvironmentAttribute<Float, Float> waterFogEndDistance; |
| 21 | + // skyColor handled elsewhere |
| 22 | + private WrappedEnvironmentAttribute<Integer, Integer> sunriseSunsetColor; |
| 23 | + private WrappedEnvironmentAttribute<Integer, Integer> cloudColor; |
| 24 | + private WrappedEnvironmentAttribute<Float, Float> cloudHeight; |
| 25 | + private WrappedEnvironmentAttribute<Float, Float> sunAngle; |
| 26 | + private WrappedEnvironmentAttribute<Float, Float> moonAngle; |
| 27 | + private WrappedEnvironmentAttribute<Float, Float> starAngle; |
| 28 | + private WrappedEnvironmentAttribute<net.minecraft.world.level.MoonPhase, MoonPhase> moonPhase; |
| 29 | + private WrappedEnvironmentAttribute<Float, Float> starBrightness; |
| 30 | + // skyLightColor handled elsewhere |
| 31 | + private WrappedEnvironmentAttribute<Float, Float> skyLightFactor; |
| 32 | + private WrappedEnvironmentAttribute<ParticleOptions, AmbientParticle> defaultDripstoneParticle; |
| 33 | + // ambientParticles handled elsewhere |
| 34 | + |
| 35 | + |
| 36 | + public VisualElements(Builder builder) { |
| 37 | + this.fogStartDistance = builder.fogStartDistance; |
| 38 | + this.fogEndDistance = builder.fogEndDistance; |
| 39 | + this.skyFogEndDistance = builder.skyFogEndDistance; |
| 40 | + this.cloudFogEndDistance = builder.cloudFogEndDistance; |
| 41 | + this.waterFogStartDistance = builder.waterFogStartDistance; |
| 42 | + this.waterFogEndDistance = builder.waterFogEndDistance; |
| 43 | + this.sunriseSunsetColor = builder.sunriseSunsetColor; |
| 44 | + this.cloudColor = builder.cloudColor; |
| 45 | + this.cloudHeight = builder.cloudHeight; |
| 46 | + this.sunAngle = builder.sunAngle; |
| 47 | + this.moonAngle = builder.moonAngle; |
| 48 | + this.starAngle = builder.starAngle; |
| 49 | + this.moonPhase = builder.moonPhase; |
| 50 | + this.starBrightness = builder.starBrightness; |
| 51 | + this.skyLightFactor = builder.skyLightFactor; |
| 52 | + this.defaultDripstoneParticle = builder.defaultDripstoneParticle; |
| 53 | + } |
| 54 | + |
| 55 | + |
| 56 | + public void applyToEnvironment(EnvironmentAttributeMap map) { |
| 57 | + fogStartDistance.applyToEnvironment(map); |
| 58 | + fogEndDistance.applyToEnvironment(map); |
| 59 | + skyFogEndDistance.applyToEnvironment(map); |
| 60 | + cloudFogEndDistance.applyToEnvironment(map); |
| 61 | + waterFogStartDistance.applyToEnvironment(map); |
| 62 | + waterFogEndDistance.applyToEnvironment(map); |
| 63 | + sunriseSunsetColor.applyToEnvironment(map); |
| 64 | + cloudColor.applyToEnvironment(map); |
| 65 | + cloudHeight.applyToEnvironment(map); |
| 66 | + sunAngle.applyToEnvironment(map); |
| 67 | + moonAngle.applyToEnvironment(map); |
| 68 | + starAngle.applyToEnvironment(map); |
| 69 | + moonPhase.applyToEnvironment(map); |
| 70 | + starBrightness.applyToEnvironment(map); |
| 71 | + skyLightFactor.applyToEnvironment(map); |
| 72 | + defaultDripstoneParticle.applyToEnvironment(map); |
| 73 | + } |
| 74 | + |
| 75 | + |
| 76 | + public static class Builder { |
| 77 | + |
| 78 | + private WrappedEnvironmentAttribute<Float, Float> fogStartDistance = WrappedEnvironmentAttribute.of(EnvironmentAttributes.FOG_START_DISTANCE); |
| 79 | + private WrappedEnvironmentAttribute<Float, Float> fogEndDistance = WrappedEnvironmentAttribute.of(EnvironmentAttributes.FOG_END_DISTANCE); |
| 80 | + private WrappedEnvironmentAttribute<Float, Float> skyFogEndDistance = WrappedEnvironmentAttribute.of(EnvironmentAttributes.SKY_FOG_END_DISTANCE); |
| 81 | + private WrappedEnvironmentAttribute<Float, Float> cloudFogEndDistance = WrappedEnvironmentAttribute.of(EnvironmentAttributes.CLOUD_FOG_END_DISTANCE); |
| 82 | + private WrappedEnvironmentAttribute<Float, Float> waterFogStartDistance = WrappedEnvironmentAttribute.of(EnvironmentAttributes.WATER_FOG_START_DISTANCE); |
| 83 | + private WrappedEnvironmentAttribute<Float, Float> waterFogEndDistance = WrappedEnvironmentAttribute.of(EnvironmentAttributes.WATER_FOG_END_DISTANCE); |
| 84 | + private WrappedEnvironmentAttribute<Integer, Integer> sunriseSunsetColor = WrappedEnvironmentAttribute.of(EnvironmentAttributes.SUNRISE_SUNSET_COLOR); |
| 85 | + private WrappedEnvironmentAttribute<Integer, Integer> cloudColor = WrappedEnvironmentAttribute.of(EnvironmentAttributes.CLOUD_COLOR); |
| 86 | + private WrappedEnvironmentAttribute<Float, Float> cloudHeight = WrappedEnvironmentAttribute.of(EnvironmentAttributes.CLOUD_HEIGHT); |
| 87 | + private WrappedEnvironmentAttribute<Float, Float> sunAngle = WrappedEnvironmentAttribute.of(EnvironmentAttributes.SUN_ANGLE); |
| 88 | + private WrappedEnvironmentAttribute<Float, Float> moonAngle = WrappedEnvironmentAttribute.of(EnvironmentAttributes.MOON_ANGLE); |
| 89 | + private WrappedEnvironmentAttribute<Float, Float> starAngle = WrappedEnvironmentAttribute.of(EnvironmentAttributes.STAR_ANGLE); |
| 90 | + private WrappedEnvironmentAttribute<net.minecraft.world.level.MoonPhase, MoonPhase> moonPhase = WrappedEnvironmentAttribute.of(EnvironmentAttributes.MOON_PHASE, MoonPhase::getDelegatePhase); |
| 91 | + private WrappedEnvironmentAttribute<Float, Float> starBrightness = WrappedEnvironmentAttribute.of(EnvironmentAttributes.STAR_BRIGHTNESS); |
| 92 | + private WrappedEnvironmentAttribute<Float, Float> skyLightFactor = WrappedEnvironmentAttribute.of(EnvironmentAttributes.SKY_LIGHT_FACTOR); |
| 93 | + private WrappedEnvironmentAttribute<ParticleOptions, AmbientParticle> defaultDripstoneParticle = WrappedEnvironmentAttribute.of(EnvironmentAttributes.DEFAULT_DRIPSTONE_PARTICLE, AmbientParticle::getSimpleParticle); |
| 94 | + |
| 95 | + public Builder fogStartDistance(float distance) { |
| 96 | + this.fogStartDistance.setValue(distance); |
| 97 | + return this; |
| 98 | + } |
| 99 | + |
| 100 | + public Builder fogEndDistance(float distance) { |
| 101 | + this.fogEndDistance.setValue(distance); |
| 102 | + return this; |
| 103 | + } |
| 104 | + |
| 105 | + public Builder skyFogEndDistance(float distance) { |
| 106 | + this.skyFogEndDistance.setValue(distance); |
| 107 | + return this; |
| 108 | + } |
| 109 | + |
| 110 | + public Builder cloudFogEndDistance(float distance) { |
| 111 | + this.cloudFogEndDistance.setValue(distance); |
| 112 | + return this; |
| 113 | + } |
| 114 | + |
| 115 | + public Builder waterFogStartDistance(float distance) { |
| 116 | + this.waterFogStartDistance.setValue(distance); |
| 117 | + return this; |
| 118 | + } |
| 119 | + |
| 120 | + public Builder waterFogEndDistance(float distance) { |
| 121 | + this.waterFogEndDistance.setValue(distance); |
| 122 | + return this; |
| 123 | + } |
| 124 | + |
| 125 | + public Builder sunriseSunsetColor(int color) { |
| 126 | + this.sunriseSunsetColor.setValue(color); |
| 127 | + return this; |
| 128 | + } |
| 129 | + |
| 130 | + public Builder cloudColor(int color) { |
| 131 | + this.cloudColor.setValue(color); |
| 132 | + return this; |
| 133 | + } |
| 134 | + |
| 135 | + public Builder cloudHeight(float height) { |
| 136 | + this.cloudHeight.setValue(height); |
| 137 | + return this; |
| 138 | + } |
| 139 | + |
| 140 | + public Builder sunAngle(float angle) { |
| 141 | + this.sunAngle.setValue(angle); |
| 142 | + return this; |
| 143 | + } |
| 144 | + |
| 145 | + public Builder moonAngle(float angle) { |
| 146 | + this.moonAngle.setValue(angle); |
| 147 | + return this; |
| 148 | + } |
| 149 | + |
| 150 | + public Builder starAngle(float angle) { |
| 151 | + this.starAngle.setValue(angle); |
| 152 | + return this; |
| 153 | + } |
| 154 | + |
| 155 | + public Builder moonPhase(MoonPhase phase) { |
| 156 | + this.moonPhase.setValue(phase); |
| 157 | + return this; |
| 158 | + } |
| 159 | + |
| 160 | + public Builder starBrightness(float brightness) { |
| 161 | + this.starBrightness.setValue(brightness); |
| 162 | + return this; |
| 163 | + } |
| 164 | + |
| 165 | + public Builder skyLightFactor(float factor) { |
| 166 | + this.skyLightFactor.setValue(factor); |
| 167 | + return this; |
| 168 | + } |
| 169 | + |
| 170 | + public Builder defaultDripstoneParticle(AmbientParticle particle) { |
| 171 | + this.defaultDripstoneParticle.setValue(particle); |
| 172 | + return this; |
| 173 | + } |
| 174 | + |
| 175 | + public VisualElements build() { |
| 176 | + return new VisualElements(this); |
| 177 | + } |
| 178 | + } |
| 179 | + |
| 180 | + |
| 181 | + |
| 182 | +} |
0 commit comments