blob: 899d1641c4f8c55a52c4dff8956f395ac0851cfb [file] [log] [blame] [raw]
/* Copyright 2015-2020 Rivoreo
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package rivoreo.minecraft.worldmgr;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
public class CustomWorldProvider extends WorldProvider {
public CustomWorldProvider() {
this.average_ground_level = -1;
this.max_height = 256;
this.should_force_generate_ice = false;
this.should_force_freeze_block = false;
this.should_force_snow = false;
this.allow_lighting = true;
this.allow_snow_and_ice = true;
this.daytime = CustomWorldProviderDayTime.NORMAL_DAYTIME;
}
public CustomWorldProvider(String world_name) {
this();
this.world_name = world_name;
}
private String world_name;
private int average_ground_level;
private int max_height;
private boolean should_force_generate_ice;
public boolean should_force_freeze_block;
public boolean should_force_snow;
public boolean should_force_wet;
private boolean allow_lighting;
private boolean allow_snow_and_ice;
public int daytime;
private BiomeGenBase force_biome;
public boolean is_custom_world_name_set() {
return world_name != null;
}
public void set_world_name(String world_name) {
if(world_name == null) throw new IllegalArgumentException("world_name is null");
if(this.world_name != null) throw new IllegalStateException("world name can only be set once");
this.world_name = world_name;
}
// get_world_name
public String func_80007_l() {
return world_name == null ? "Custom" : world_name;
}
// get_save_directory_name (Forge added method)
public String getSaveFolder() {
return world_name == null ? "CUSTOM" : world_name;
}
// get_respawn_world_id (Forge added method)
public int getRespawnDimension() {
return field_76574_g;
}
// get_average_ground_level
public int func_74889_b() {
return average_ground_level < 0 ? super.func_74889_b() : average_ground_level;
}
public void set_average_ground_level(int value) {
average_ground_level = value;
}
// (Forge added method)
public int getHeight() {
return max_height;
}
// (Forge added method)
public int getActualHeight() {
//return Math.min(super.getActualHeight(), max_height);
return max_height;
}
public void set_max_height(int value) {
max_height = value;
}
// (Forge added method)
public boolean canBlockFreeze(int x, int y, int z, boolean should_check_water) {
if(should_force_generate_ice) return true;
return should_force_freeze_block && should_check_water ?
true : super.canBlockFreeze(x, y, z, should_check_water);
}
public void set_force_generate_ice(boolean value) {
should_force_generate_ice = value;
}
// (Forge added method)
public boolean canSnowAt(int x, int y, int z, boolean should_check_light) {
return should_force_snow ? true : super.canSnowAt(x, y, z, should_check_light);
}
// (Forge added method)
public boolean isBlockHighHumidity(int x, int y, int z) {
return should_force_wet ? true : super.isBlockHighHumidity(x, y, z);
}
// (Forge added method)
public boolean canDoLightning(Chunk chunk) {
return allow_lighting;
}
public void set_allow_lighting(boolean value) {
allow_lighting = value;
}
// (Forge added method)
public boolean canDoRainSnowIce(Chunk chunk) {
return allow_snow_and_ice;
}
public void set_allow_snow_and_ice(boolean value) {
allow_snow_and_ice = value;
}
// (Forge added method)
public boolean isDaytime() {
if(daytime == CustomWorldProviderDayTime.ALWAYS_DAYTIME) return true;
if(daytime == CustomWorldProviderDayTime.NEVER_DAYTIME) return false;
return super.isDaytime();
}
public void set_force_biome(BiomeGenBase biome) {
force_biome = biome;
}
// (Forge added method)
public BiomeGenBase getBiomeGenForCoords(int x, int z) {
return force_biome == null ? super.getBiomeGenForCoords(x, z) : force_biome;
}
}