| /* 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.chunk.Chunk; |
| |
| public class CustomWorldProvider extends WorldProvider { |
| public CustomWorldProvider() { |
| this.average_ground_level = -1; |
| this.max_height = 256; |
| this.is_force_snow = false; |
| this.allow_lighting = true; |
| this.allow_snow_and_ice = true; |
| } |
| |
| 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 is_force_snow; |
| private boolean allow_lighting; |
| private boolean allow_snow_and_ice; |
| |
| 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_in (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 canSnowAt(int x, int y, int z, boolean should_check_light) { |
| return is_force_snow ? true : super.canSnowAt(x, y, z, should_check_light); |
| } |
| |
| public boolean is_force_snow() { |
| return is_force_snow; |
| } |
| |
| public void set_force_snow(boolean value) { |
| is_force_snow = value; |
| } |
| |
| // (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; |
| } |
| } |