fix client methods in biome, fixes #870
This commit is contained in:
1 parent
4466c77780
commit
7fd49e0f04
4 files changed
+81
-5
No files matched your search
@@ -0,0 +1,12 @@
|
|||||||
|
package carpet.fakes;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface BiomeEffectsInterface
|
||||||
|
{
|
||||||
|
int getCMFogColor();
|
||||||
|
Optional<Integer> getCMFoliageColor();
|
||||||
|
int getCMSkyColor();
|
||||||
|
int getCMWaterColor();
|
||||||
|
int getCMWaterFogColor();
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package carpet.mixins;
|
||||||
|
|
||||||
|
import carpet.fakes.BiomeEffectsInterface;
|
||||||
|
import net.minecraft.world.biome.BiomeEffects;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Mixin(BiomeEffects.class)
|
||||||
|
public class BiomeEffects_scarpetMixin implements BiomeEffectsInterface
|
||||||
|
{
|
||||||
|
@Shadow @Final private int fogColor;
|
||||||
|
|
||||||
|
@Shadow @Final private Optional<Integer> foliageColor;
|
||||||
|
|
||||||
|
@Shadow @Final private int skyColor;
|
||||||
|
|
||||||
|
@Shadow @Final private int waterColor;
|
||||||
|
|
||||||
|
@Shadow @Final private int waterFogColor;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCMFogColor()
|
||||||
|
{
|
||||||
|
return fogColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Integer> getCMFoliageColor()
|
||||||
|
{
|
||||||
|
return foliageColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCMSkyColor()
|
||||||
|
{
|
||||||
|
return skyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCMWaterColor()
|
||||||
|
{
|
||||||
|
return waterColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCMWaterFogColor()
|
||||||
|
{
|
||||||
|
return waterFogColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
package carpet.script.utils;
|
package carpet.script.utils;
|
||||||
|
|
||||||
|
import carpet.fakes.BiomeEffectsInterface;
|
||||||
import carpet.script.value.BlockValue;
|
import carpet.script.value.BlockValue;
|
||||||
import carpet.script.value.ListValue;
|
import carpet.script.value.ListValue;
|
||||||
import carpet.script.value.NumericValue;
|
import carpet.script.value.NumericValue;
|
||||||
import carpet.script.value.StringValue;
|
import carpet.script.value.StringValue;
|
||||||
import carpet.script.value.Value;
|
import carpet.script.value.Value;
|
||||||
import carpet.script.value.ValueConversions;
|
import carpet.script.value.ValueConversions;
|
||||||
|
import net.minecraft.client.color.world.FoliageColors;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||||
@@ -18,16 +21,23 @@ import java.util.function.BiFunction;
|
|||||||
|
|
||||||
public class BiomeInfo
|
public class BiomeInfo
|
||||||
{
|
{
|
||||||
|
// copy of from Biome.getDefaultFoliageColor
|
||||||
|
private static int getDefaultFoliageColor(Biome b) {
|
||||||
|
double d = MathHelper.clamp(b.getTemperature(), 0.0F, 1.0F);
|
||||||
|
double e = MathHelper.clamp(b.getDownfall(), 0.0F, 1.0F);
|
||||||
|
return FoliageColors.getColor(d, e);
|
||||||
|
}
|
||||||
|
|
||||||
public final static Map<String, BiFunction<ServerWorld, Biome, Value>> biomeFeatures = new HashMap<String, BiFunction<ServerWorld, Biome, Value>>(){{
|
public final static Map<String, BiFunction<ServerWorld, Biome, Value>> biomeFeatures = new HashMap<String, BiFunction<ServerWorld, Biome, Value>>(){{
|
||||||
put("top_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getTopMaterial(), null, null));
|
put("top_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getTopMaterial(), null, null));
|
||||||
put("under_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getUnderMaterial(), null, null));
|
put("under_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getUnderMaterial(), null, null));
|
||||||
put("category", (w, b) -> StringValue.of(b.getCategory().getName()));
|
put("category", (w, b) -> StringValue.of(b.getCategory().getName()));
|
||||||
put("temperature", (w, b) -> NumericValue.of(b.getTemperature()));
|
put("temperature", (w, b) -> NumericValue.of(b.getTemperature()));
|
||||||
put("fog_color", (w, b) -> ValueConversions.ofRGB(b.getFogColor()));
|
put("fog_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMFogColor()));
|
||||||
put("foliage_color", (w, b) -> ValueConversions.ofRGB(b.getFoliageColor()));
|
put("foliage_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMFoliageColor().orElseGet(() -> getDefaultFoliageColor(b))));
|
||||||
put("sky_color", (w, b) -> ValueConversions.ofRGB(b.getSkyColor()));
|
put("sky_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMSkyColor()));
|
||||||
put("water_color", (w, b) -> ValueConversions.ofRGB(b.getWaterColor()));
|
put("water_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMWaterColor()));
|
||||||
put("water_fog_color", (w, b) -> ValueConversions.ofRGB(b.getWaterFogColor()));
|
put("water_fog_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMWaterFogColor()));
|
||||||
put("humidity", (w, b) -> NumericValue.of(b.getDownfall()));
|
put("humidity", (w, b) -> NumericValue.of(b.getDownfall()));
|
||||||
put("precipitation", (w, b) -> StringValue.of(b.getPrecipitation().getName()));
|
put("precipitation", (w, b) -> StringValue.of(b.getPrecipitation().getName()));
|
||||||
put("depth", (w, b) -> NumericValue.of(b.getDepth()));
|
put("depth", (w, b) -> NumericValue.of(b.getDepth()));
|
||||||
|
|||||||
@@ -175,6 +175,7 @@
|
|||||||
"Scoreboard_scarpetMixin",
|
"Scoreboard_scarpetMixin",
|
||||||
"TradeOutputSlot_scarpetEventMixin",
|
"TradeOutputSlot_scarpetEventMixin",
|
||||||
|
|
||||||
|
"BiomeEffects_scarpetMixin",
|
||||||
"ChunkTicketManager_scarpetMixin",
|
"ChunkTicketManager_scarpetMixin",
|
||||||
"StatType_scarpetMixin",
|
"StatType_scarpetMixin",
|
||||||
"PointOfInterest_scarpetMixin",
|
"PointOfInterest_scarpetMixin",
|
||||||
|
|||||||
Reference in new issue
Block a user