Skip to content

Commit

Permalink
BiomeNMS(1.18): Fix getClimate
Browse files Browse the repository at this point in the history
It used the holder directly, instead of calling `#value` to get the biome.
  • Loading branch information
tal5 committed May 12, 2023
1 parent 0054d05 commit 2f22d09
Showing 1 changed file with 13 additions and 25 deletions.
Expand Up @@ -38,16 +38,12 @@ public BiomeNMSImpl(ServerLevel world, String name) {
@Override
public DownfallType getDownfallType() {
Biome.Precipitation nmsType = biomeBase.value().getPrecipitation();
switch (nmsType) {
case RAIN:
return DownfallType.RAIN;
case SNOW:
return DownfallType.SNOW;
case NONE:
return DownfallType.NONE;
default:
throw new UnsupportedOperationException();
}
return switch (nmsType) {
case RAIN -> DownfallType.RAIN;
case SNOW -> DownfallType.SNOW;
case NONE -> DownfallType.NONE;
default -> throw new UnsupportedOperationException();
};
}

@Override
Expand Down Expand Up @@ -81,7 +77,7 @@ public List<EntityType> getWaterEntities() {
}

public Object getClimate() {
return ReflectionHelper.getFieldValue(net.minecraft.world.level.biome.Biome.class, ReflectionMappingsInfo.Biome_climateSettings, biomeBase);
return ReflectionHelper.getFieldValue(net.minecraft.world.level.biome.Biome.class, ReflectionMappingsInfo.Biome_climateSettings, biomeBase.value());
}

@Override
Expand All @@ -98,20 +94,12 @@ public void setTemperature(float temperature) {

@Override
public void setPrecipitation(DownfallType type) {
Biome.Precipitation nmsType;
switch (type) {
case NONE:
nmsType = Biome.Precipitation.NONE;
break;
case RAIN:
nmsType = Biome.Precipitation.RAIN;
break;
case SNOW:
nmsType = Biome.Precipitation.SNOW;
break;
default:
throw new UnsupportedOperationException();
}
Biome.Precipitation nmsType = switch (type) {
case RAIN -> Biome.Precipitation.RAIN;
case SNOW -> Biome.Precipitation.SNOW;
case NONE -> Biome.Precipitation.NONE;
default -> throw new UnsupportedOperationException();
};
Object climate = getClimate();
ReflectionHelper.setFieldValue(climate.getClass(), ReflectionMappingsInfo.Biome_ClimateSettings_precipitation, climate, nmsType);
}
Expand Down

0 comments on commit 2f22d09

Please sign in to comment.