├── .bzrignore ├── .gitignore ├── .project ├── .settings ├── org.eclipse.jdt.core.prefs ├── org.eclipse.jdt.ui.prefs └── org.eclipse.ltk.core.refactoring.prefs ├── COPYING ├── CheckLegal.ps1 ├── CodingStyle.xml ├── DEVELOPER-ENVIRONMENT-SETUP.TXT ├── HowToRelease.txt ├── LICENSE ├── Releases ├── NewBiospheresMod-1.7.10-0.7.jar ├── NewBiospheresMod-1.7.x-0.8.jar └── NewBiospheresMod-1.7.x-0.85.jar ├── RestoreWorld.bat ├── Testing └── NewBiospheresMod-Experimental-2015-04-16.jar ├── build.gradle ├── commit.bat ├── eclipse └── .metadata │ └── .plugins │ └── org.eclipse.ui.workbench │ ├── dialog_settings.xml │ └── workingsets.xml ├── include.bat ├── lib └── concurrentlinkedhashmap-lru-1.4.jar ├── logo.pdn ├── preferences.epf ├── publish.bat ├── pull.bat ├── push.bat └── src └── main ├── java └── newBiospheresMod │ ├── BiomeEntry.java │ ├── BiosphereChunkManager.java │ ├── BiosphereChunkProvider.java │ ├── BiosphereMapGen.java │ ├── BiosphereWorldProvider.java │ ├── BiosphereWorldType.java │ ├── BlockData.java │ ├── BlockDome.java │ ├── BlockEntry.java │ ├── Configuration │ ├── Categories.java │ ├── ConfigScreens.java │ ├── CustomWorldData.java │ ├── GuiConfigTab.java │ ├── GuiConfigTabEntry.java │ ├── IGuiConfigTabProvider.java │ ├── ModConfig.java │ ├── ModConfigGuiFactory.java │ └── ModGuiConfigTabProvider.java │ ├── Helpers │ ├── AvgCalc.java │ ├── Blx.java │ ├── Creator.java │ ├── Func.java │ ├── Func2.java │ ├── IKeyProvider.java │ ├── LruCacheList.java │ ├── ModConsts.java │ ├── Predicate.java │ ├── TopDownBoundingBox.java │ └── Utils.java │ ├── Models │ ├── NoiseChunk.java │ ├── Sphere.java │ └── SphereChunk.java │ └── NewBiospheresMod.java └── resources ├── MODINFO.TXT ├── logo.png ├── mcmod.info ├── screenshot1.png └── screenshot2.png /.bzrignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.class 3 | bin 4 | *.log.gz 5 | eclipse/config 6 | eclipse/saves 7 | *.snap 8 | .gradle 9 | MinecraftForge-Credits.txt 10 | MinecraftForge-License.txt 11 | build 12 | eclipse 13 | forge-1.7.10-10.13.1.1217-changelog.txt 14 | gradle 15 | gradlew 16 | gradlew.bat 17 | mcp 18 | CREDITS-fml.txt 19 | README.txt 20 | LICENSE-fml.txt 21 | .classpath 22 | TODO.txt 23 | conf 24 | config 25 | mods 26 | python27.dll 27 | mcedit.exe 28 | mcedit.ini 29 | mcedit.log 30 | screenshots 31 | ServerJarStorage 32 | resourcepacks 33 | options.txt 34 | logs 35 | crash-reports 36 | MCEdit-0.1.7.1.win-amd64 37 | MCEdit-schematics 38 | .lock 39 | .log 40 | .plugins 41 | version.ini 42 | org.eclipse.core.resources 43 | org.eclipse.core.runtime 44 | org.eclipse.debug.core 45 | org.eclipse.debug.ui 46 | org.eclipse.e4.workbench 47 | org.eclipse.jdt.core 48 | org.eclipse.jdt.debug.ui 49 | org.eclipse.jdt.launching 50 | org.eclipse.jdt.ui 51 | org.eclipse.ltk.core.refactoring 52 | org.eclipse.ltk.ui.refactoring 53 | org.eclipse.pde.api.tools 54 | org.eclipse.pde.core 55 | org.eclipse.search 56 | org.eclipse.ui.editors 57 | org.eclipse.ui.ide 58 | org.eclipse.ui.workbench 59 | org.eclipse.ui.workbench.texteditor 60 | org.eclipse.team.ui 61 | eclipse/.metadata/.plugins/org.eclipse.equinox.p2.ui 62 | eclipse/.metadata/.plugins/org.eclipse.jdt.junit.core 63 | forge-*.txt -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.class 3 | bin 4 | *.log.gz 5 | eclipse/config 6 | eclipse/saves 7 | *.snap 8 | .gradle 9 | MinecraftForge-Credits.txt 10 | MinecraftForge-License.txt 11 | build 12 | eclipse 13 | forge-1.7.10-10.13.1.1217-changelog.txt 14 | gradle 15 | gradlew 16 | gradlew.bat 17 | mcp 18 | CREDITS-fml.txt 19 | README.txt 20 | LICENSE-fml.txt 21 | .classpath 22 | TODO.txt 23 | conf 24 | config 25 | mods 26 | python27.dll 27 | mcedit.exe 28 | mcedit.ini 29 | mcedit.log 30 | screenshots 31 | ServerJarStorage 32 | resourcepacks 33 | options.txt 34 | logs 35 | crash-reports 36 | MCEdit-0.1.7.1.win-amd64 37 | MCEdit-schematics 38 | .lock 39 | .log 40 | .plugins 41 | version.ini 42 | org.eclipse.core.resources 43 | org.eclipse.core.runtime 44 | org.eclipse.debug.core 45 | org.eclipse.debug.ui 46 | org.eclipse.e4.workbench 47 | org.eclipse.jdt.core 48 | org.eclipse.jdt.debug.ui 49 | org.eclipse.jdt.launching 50 | org.eclipse.jdt.ui 51 | org.eclipse.ltk.core.refactoring 52 | org.eclipse.ltk.ui.refactoring 53 | org.eclipse.pde.api.tools 54 | org.eclipse.pde.core 55 | org.eclipse.search 56 | org.eclipse.ui.editors 57 | org.eclipse.ui.ide 58 | org.eclipse.ui.workbench 59 | org.eclipse.ui.workbench.texteditor 60 | org.eclipse.team.ui 61 | eclipse/.metadata/.plugins/org.eclipse.equinox.p2.ui 62 | eclipse/.metadata/.plugins/org.eclipse.jdt.junit.core 63 | forge-*.txt -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | NewBiospheresMod 4 | 5 | 6 | 7 | org.eclipse.jdt.core.javanature 8 | 9 | 10 | 11 | org.eclipse.jdt.core.javabuilder 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.6 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.6 12 | org.eclipse.jdt.core.formatter.align_type_members_on_columns=false 13 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=20 14 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=52 15 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=0 16 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=20 17 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=20 18 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=20 19 | org.eclipse.jdt.core.formatter.alignment_for_assignment=20 20 | org.eclipse.jdt.core.formatter.alignment_for_binary_expression=20 21 | org.eclipse.jdt.core.formatter.alignment_for_compact_if=20 22 | org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=20 23 | org.eclipse.jdt.core.formatter.alignment_for_enum_constants=48 24 | org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=20 25 | org.eclipse.jdt.core.formatter.alignment_for_method_declaration=20 26 | org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 27 | org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=20 28 | org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=20 29 | org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=20 30 | org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=20 31 | org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=20 32 | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=20 33 | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=20 34 | org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=20 35 | org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=20 36 | org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=20 37 | org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 38 | org.eclipse.jdt.core.formatter.blank_lines_after_package=1 39 | org.eclipse.jdt.core.formatter.blank_lines_before_field=0 40 | org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 41 | org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 42 | org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 43 | org.eclipse.jdt.core.formatter.blank_lines_before_method=1 44 | org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 45 | org.eclipse.jdt.core.formatter.blank_lines_before_package=0 46 | org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 47 | org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 48 | org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line 49 | org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line 50 | org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=next_line 51 | org.eclipse.jdt.core.formatter.brace_position_for_block=next_line 52 | org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line 53 | org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line 54 | org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line 55 | org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line 56 | org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line 57 | org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line 58 | org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line 59 | org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line 60 | org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true 61 | org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false 62 | org.eclipse.jdt.core.formatter.comment.format_block_comments=true 63 | org.eclipse.jdt.core.formatter.comment.format_header=true 64 | org.eclipse.jdt.core.formatter.comment.format_html=true 65 | org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true 66 | org.eclipse.jdt.core.formatter.comment.format_line_comments=true 67 | org.eclipse.jdt.core.formatter.comment.format_source_code=true 68 | org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true 69 | org.eclipse.jdt.core.formatter.comment.indent_root_tags=true 70 | org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert 71 | org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert 72 | org.eclipse.jdt.core.formatter.comment.line_length=120 73 | org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true 74 | org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true 75 | org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=true 76 | org.eclipse.jdt.core.formatter.compact_else_if=true 77 | org.eclipse.jdt.core.formatter.continuation_indentation=1 78 | org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=0 79 | org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off 80 | org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on 81 | org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=true 82 | org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true 83 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true 84 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true 85 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true 86 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true 87 | org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true 88 | org.eclipse.jdt.core.formatter.indent_empty_lines=false 89 | org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true 90 | org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true 91 | org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true 92 | org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false 93 | org.eclipse.jdt.core.formatter.indentation.size=4 94 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert 95 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert 96 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert 97 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert 98 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert 99 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert 100 | org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert 101 | org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert 102 | org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert 103 | org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert 104 | org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert 105 | org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert 106 | org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert 107 | org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert 108 | org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert 109 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert 110 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert 111 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert 112 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert 113 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert 114 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert 115 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert 116 | org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert 117 | org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert 118 | org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert 119 | org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert 120 | org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert 121 | org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert 122 | org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert 123 | org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert 124 | org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=do not insert 125 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert 126 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert 127 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert 128 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert 129 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert 130 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert 131 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert 132 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert 133 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert 134 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert 135 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert 136 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert 137 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert 138 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert 139 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert 140 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert 141 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert 142 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert 143 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert 144 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert 145 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert 146 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert 147 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert 148 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert 149 | org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert 150 | org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert 151 | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert 152 | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert 153 | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert 154 | org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert 155 | org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert 156 | org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert 157 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert 158 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert 159 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert 160 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert 161 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert 162 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert 163 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert 164 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert 165 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert 166 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert 167 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert 168 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert 169 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert 170 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert 171 | org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert 172 | org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert 173 | org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert 174 | org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert 175 | org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert 176 | org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert 177 | org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert 178 | org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert 179 | org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert 180 | org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert 181 | org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert 182 | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert 183 | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert 184 | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert 185 | org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert 186 | org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert 187 | org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert 188 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert 189 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert 190 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert 191 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert 192 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert 193 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert 194 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert 195 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert 196 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert 197 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert 198 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert 199 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert 200 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert 201 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert 202 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=do not insert 203 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert 204 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert 205 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert 206 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=do not insert 207 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert 208 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert 209 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert 210 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert 211 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert 212 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert 213 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert 214 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert 215 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert 216 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert 217 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert 218 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert 219 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert 220 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert 221 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert 222 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert 223 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert 224 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert 225 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert 226 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert 227 | org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert 228 | org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert 229 | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert 230 | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert 231 | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert 232 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert 233 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert 234 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert 235 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert 236 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert 237 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert 238 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert 239 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert 240 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert 241 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert 242 | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert 243 | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert 244 | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert 245 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert 246 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert 247 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert 248 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert 249 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert 250 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert 251 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert 252 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert 253 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert 254 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert 255 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert 256 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert 257 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert 258 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert 259 | org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert 260 | org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert 261 | org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert 262 | org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert 263 | org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert 264 | org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert 265 | org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert 266 | org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert 267 | org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert 268 | org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert 269 | org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert 270 | org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=insert 271 | org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert 272 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert 273 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert 274 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert 275 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert 276 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert 277 | org.eclipse.jdt.core.formatter.join_lines_in_comments=true 278 | org.eclipse.jdt.core.formatter.join_wrapped_lines=false 279 | org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=true 280 | org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=true 281 | org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true 282 | org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=true 283 | org.eclipse.jdt.core.formatter.lineSplit=100 284 | org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false 285 | org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false 286 | org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 287 | org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 288 | org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false 289 | org.eclipse.jdt.core.formatter.tabulation.char=tab 290 | org.eclipse.jdt.core.formatter.tabulation.size=4 291 | org.eclipse.jdt.core.formatter.use_on_off_tags=false 292 | org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false 293 | org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true 294 | org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true 295 | org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true 296 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | cleanup.add_default_serial_version_id=true 2 | cleanup.add_generated_serial_version_id=false 3 | cleanup.add_missing_annotations=true 4 | cleanup.add_missing_deprecated_annotations=false 5 | cleanup.add_missing_methods=false 6 | cleanup.add_missing_nls_tags=false 7 | cleanup.add_missing_override_annotations=true 8 | cleanup.add_missing_override_annotations_interface_methods=true 9 | cleanup.add_serial_version_id=false 10 | cleanup.always_use_blocks=true 11 | cleanup.always_use_parentheses_in_expressions=true 12 | cleanup.always_use_this_for_non_static_field_access=true 13 | cleanup.always_use_this_for_non_static_method_access=true 14 | cleanup.convert_functional_interfaces=false 15 | cleanup.convert_to_enhanced_for_loop=false 16 | cleanup.correct_indentation=true 17 | cleanup.format_source_code=true 18 | cleanup.format_source_code_changes_only=false 19 | cleanup.insert_inferred_type_arguments=false 20 | cleanup.make_local_variable_final=true 21 | cleanup.make_parameters_final=true 22 | cleanup.make_private_fields_final=true 23 | cleanup.make_type_abstract_if_missing_method=false 24 | cleanup.make_variable_declarations_final=true 25 | cleanup.never_use_blocks=false 26 | cleanup.never_use_parentheses_in_expressions=false 27 | cleanup.organize_imports=true 28 | cleanup.qualify_static_field_accesses_with_declaring_class=true 29 | cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true 30 | cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true 31 | cleanup.qualify_static_member_accesses_with_declaring_class=true 32 | cleanup.qualify_static_method_accesses_with_declaring_class=true 33 | cleanup.remove_private_constructors=true 34 | cleanup.remove_redundant_type_arguments=true 35 | cleanup.remove_trailing_whitespaces=true 36 | cleanup.remove_trailing_whitespaces_all=true 37 | cleanup.remove_trailing_whitespaces_ignore_empty=false 38 | cleanup.remove_unnecessary_casts=true 39 | cleanup.remove_unnecessary_nls_tags=true 40 | cleanup.remove_unused_imports=true 41 | cleanup.remove_unused_local_variables=false 42 | cleanup.remove_unused_private_fields=true 43 | cleanup.remove_unused_private_members=false 44 | cleanup.remove_unused_private_methods=true 45 | cleanup.remove_unused_private_types=true 46 | cleanup.sort_members=false 47 | cleanup.sort_members_all=false 48 | cleanup.use_anonymous_class_creation=false 49 | cleanup.use_blocks=false 50 | cleanup.use_blocks_only_for_return_and_throw=false 51 | cleanup.use_lambda=true 52 | cleanup.use_parentheses_in_expressions=true 53 | cleanup.use_this_for_non_static_field_access=true 54 | cleanup.use_this_for_non_static_field_access_only_if_necessary=false 55 | cleanup.use_this_for_non_static_method_access=true 56 | cleanup.use_this_for_non_static_method_access_only_if_necessary=false 57 | cleanup.use_type_arguments=false 58 | cleanup_profile=_CLEAN-IT\! 59 | cleanup_settings_version=2 60 | eclipse.preferences.version=1 61 | formatter_profile=_Mikey 62 | formatter_settings_version=12 63 | org.eclipse.jdt.ui.ignorelowercasenames=true 64 | org.eclipse.jdt.ui.importorder=java;javax;org;com; 65 | org.eclipse.jdt.ui.ondemandthreshold=99 66 | org.eclipse.jdt.ui.staticondemandthreshold=99 67 | -------------------------------------------------------------------------------- /.settings/org.eclipse.ltk.core.refactoring.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false 3 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | -------------------------------------------------------------------------------- /CheckLegal.ps1: -------------------------------------------------------------------------------- 1 | try 2 | { 3 | cd src 4 | gci -recu -inc "*.java" | ? { -not ([string]::Concat((Get-Content $_)).Contains("Sam Hocevar")); } 5 | } 6 | finally 7 | { 8 | cd .. 9 | } -------------------------------------------------------------------------------- /CodingStyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | -------------------------------------------------------------------------------- /DEVELOPER-ENVIRONMENT-SETUP.TXT: -------------------------------------------------------------------------------- 1 | 1.) Install the following, for command line utilities, please make sure they're in your path: 2 | 3 | + JDK 1.7 64-bit 4 | (do not install the 32-bit version, do not install the 32-bit JRE, do not install the JDK 1.8, 5 | if any versions of the Java JRE or JDK are installed that are either 32-bit bit, or 1.8, 6 | UNINSTALL them and reboot before proceeding. Then install the correct version: the latest 7 | 1.7 64-bit JDK, and nothing else.) 8 | 9 | + Info-Zip 10 | Zip.exe: 3.0 http://gnuwin32.sourceforge.net/packages/zip.htm 11 | Unzip.exe 5.5 http://gnuwin32.sourceforge.net/packages/unzip.htm 12 | 13 | Just grab the binaries in both cases and unzip the .exes to your path somewhere. 14 | Alternately, I've found bins here as well: http://www.willus.com/archive/zip64/ 15 | 16 | + GIT (or another utility that can pull down code from github). 17 | 18 | + Eclipse (Luna at the time of this writing) 19 | 20 | + A legal, licensed, paid for, etc. version of Minecraft. 21 | 22 | 2.) Install and run the latest version of Minecraft, configure it to run version 1.7.10, and launch 23 | it at least once. Then install Forge for that version of Minecraft. 24 | 25 | 3.) Build and Configure the Forge Workspace: 26 | 27 | + Head on over to: http://files.minecraftforge.net/ 28 | + Download the latest version of Forge for Minecraft 1.7.10. 29 | (At the time of this writing that's: forge-1.7.10-10.13.1.1224-src.zip) 30 | 31 | + Create a new folder for the project, copy the archive in there, and unzip it. 32 | 33 | c:\biz\baz\> cd /d x:\foo\bar\ 34 | 35 | x:\foo\bar\> md NewBiospheresMod 36 | 37 | x:\foo\bar\NewBiospheresMod\> copy c:\foo\bar\downloads\forge-1.7.10-10.13.1.1224-src.zip 38 | 39 | x:\foo\bar\NewBiospheresMod\> unzip forge-1.7.10-10.13.1.1224-src.zip 40 | 41 | x:\foo\bar\NewBiospheresMod\> del forge-1.7.10-10.13.1.1224-src.zip 42 | 43 | + Follow the instructions in the "README.TXT" to setup a new environment: 44 | 45 | x:\foo\bar\NewBiospheresMod\> gradlew clean 46 | x:\foo\bar\NewBiospheresMod\> gradlew cleanCache 47 | x:\foo\bar\NewBiospheresMod\> gradlew setupDecompWorkspace --refresh-dependencies 48 | x:\foo\bar\NewBiospheresMod\> gradlew eclipse 49 | 50 | -- OR -- 51 | gradlew clean && gradlew cleanCache && gradlew setupDecompWorkspace --refresh-dependencies && gradlew eclipse 52 | 53 | + Delete the "src" folder. 54 | 55 | x:\foo\bar\NewBiospheresMod\> rd /s /q src 56 | 57 | + Pull down the code from the git repo! 58 | Now, usually this isn't allowed, so you'll have to do some hackery. 59 | Essentially clone the repro somewhere, and move in the ".git" folder and then perform a hard 60 | reset to the latest version. Like so: 61 | 62 | x:\foo\bar\NewBiospheresMod\> git clone --no-checkout https://github.com/BrainSlugs83/NewBiospheresMod.git temp 63 | x:\foo\bar\NewBiospheresMod\> mv temp/.git . 64 | x:\foo\bar\NewBiospheresMod\> rd /s /q temp 65 | x:\foo\bar\NewBiospheresMod\> git reset --hard HEAD 66 | 67 | + Manually edit the .classpath file, add the following tag: 68 | 69 | 70 | 71 | + You can now work with the project in eclipse, either by using the workspace in the 72 | "NewBiospheresMod\Eclipse" folder, or by importing it into an existing workspace, to create a 73 | deployable .jar file, run the publish.bat command, if all goes well, both should work without 74 | error. 75 | -------------------------------------------------------------------------------- /HowToRelease.txt: -------------------------------------------------------------------------------- 1 | Update Version # in src/main/resources/mcmod.info 2 | Update Version # in src/main/java/newBiospheresMod/Helpers/ModConsts.java 3 | Update Version # in build.gradle 4 | Run Publish.bat 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ======================== NEW BIOSPHERES MOD ========================= 2 | Copyright (c) 2014 Michael Jensen 3 | This work is free. You can redistribute it and/or modify it under the 4 | terms of the Do What The Fuck You Want To Public License, Version 2, 5 | as published by Sam Hocevar. See the COPYING file for more details. 6 | 7 | This program is free software. It comes without any warranty, to 8 | the extent permitted by applicable law. You can redistribute it 9 | and/or modify it under the terms of the Do What The Fuck You Want 10 | To Public License, Version 2, as published by Sam Hocevar. See 11 | http://www.wtfpl.net/ for more details. 12 | 13 | ===================== Concurrent Linked Hashmap ===================== 14 | Applies to: lib\concurrentlinkedhashmap-lru-1.4.jar 15 | Project Page: https://code.google.com/p/concurrentlinkedhashmap/ 16 | License: Apache 2.0 17 | 18 | ========================== Minecraft Forge ========================== 19 | Applies to: build.gradle 20 | Project Page: http://www.minecraftforge.net/ 21 | License: GPL 2.1 22 | 23 | ===================================================================== 24 | -------------------------------------------------------------------------------- /Releases/NewBiospheresMod-1.7.10-0.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrainSlugs83/NewBiospheresMod/1493b5219d7a71db13a0e027da293324f1018821/Releases/NewBiospheresMod-1.7.10-0.7.jar -------------------------------------------------------------------------------- /Releases/NewBiospheresMod-1.7.x-0.8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrainSlugs83/NewBiospheresMod/1493b5219d7a71db13a0e027da293324f1018821/Releases/NewBiospheresMod-1.7.x-0.8.jar -------------------------------------------------------------------------------- /Releases/NewBiospheresMod-1.7.x-0.85.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrainSlugs83/NewBiospheresMod/1493b5219d7a71db13a0e027da293324f1018821/Releases/NewBiospheresMod-1.7.x-0.85.jar -------------------------------------------------------------------------------- /RestoreWorld.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | cd .\eclipse\saves 4 | call RestoreWorld.bat -------------------------------------------------------------------------------- /Testing/NewBiospheresMod-Experimental-2015-04-16.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrainSlugs83/NewBiospheresMod/1493b5219d7a71db13a0e027da293324f1018821/Testing/NewBiospheresMod-Experimental-2015-04-16.jar -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | maven { 5 | name = "forge" 6 | url = "http://files.minecraftforge.net/maven" 7 | } 8 | maven { 9 | name = "sonatype" 10 | url = "https://oss.sonatype.org/content/repositories/snapshots/" 11 | } 12 | } 13 | dependencies { 14 | classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' 15 | } 16 | } 17 | 18 | apply plugin: 'forge' 19 | 20 | version = "0.85" 21 | group = "com.brainslugs83.newBiospheresMod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html 22 | archivesBaseName = "NewBiospheresMod" 23 | 24 | minecraft { 25 | version = "1.7.10-10.13.1.1217" 26 | runDir = "eclipse" 27 | } 28 | 29 | dependencies { 30 | // you may put jars on which you depend on in ./libs 31 | // or you may define them like so.. 32 | //compile "some.group:artifact:version:classifier" 33 | //compile "some.group:artifact:version" 34 | 35 | // real examples 36 | //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env 37 | //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env 38 | 39 | // for more info... 40 | // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html 41 | // http://www.gradle.org/docs/current/userguide/dependency_management.html 42 | 43 | compile files { 44 | "lib/concurrentlinkedhashmap-lru-1.4.jar" 45 | } 46 | 47 | } 48 | 49 | processResources 50 | { 51 | // this will ensure that this task is redone when the versions change. 52 | inputs.property "version", project.version 53 | inputs.property "mcversion", project.minecraft.version 54 | 55 | // replace stuff in mcmod.info, nothing else 56 | from(sourceSets.main.resources.srcDirs) { 57 | include 'mcmod.info' 58 | 59 | // replace version and mcversion 60 | expand 'version':project.version, 'mcversion':project.minecraft.version 61 | } 62 | 63 | // copy everything else, thats not the mcmod.info 64 | from(sourceSets.main.resources.srcDirs) { 65 | exclude 'mcmod.info' 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /commit.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | git commit -a -------------------------------------------------------------------------------- /eclipse/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 |
12 |
13 | 14 |
15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
32 | 33 | 34 | 35 | 36 |
37 |
38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
63 |
64 | 65 | 66 | 67 | 68 | 69 |
70 |
71 | 72 | 73 | 74 | 75 | 76 | 77 |
78 |
79 | -------------------------------------------------------------------------------- /eclipse/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /include.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SET ERRORLEVEL= 3 | VERIFY OTHER 2>nul 4 | SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS 5 | IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 6 | 7 | REM FOR DEBUGGING ONLY (DO NOT UNCOMMENT) 8 | REM if "%1" == "" include NewBiospheresMod-0.7.jar lib\concurrentlinkedhashmap-lru-1.4.jar 9 | REM if "%2" == "" include "%~1" lib\concurrentlinkedhashmap-lru-1.4.jar 10 | 11 | cd /d "%~dp2" 12 | if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 13 | 14 | rd /s /q temp 2>nul 1>nul 15 | 16 | md temp 17 | if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 18 | 19 | copy "%~nx2" temp 20 | if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 21 | 22 | cd temp 23 | if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 24 | 25 | unzip -o "%~nx2" 26 | if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 27 | 28 | rd /s /q META-INF 29 | del "%~nx2" 30 | if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 31 | 32 | for /R %%f in (*.*) do ( 33 | 34 | set file=%%f 35 | set file=!file:%cd%\=! 36 | 37 | if NOT "%%~nxf" == "dirFile.txt" ( 38 | 39 | echo !file! >> dirFile.txt 40 | ) 41 | ) 42 | 43 | zip -9 -m -@ "..\..\%~nx1" < dirFile.txt 44 | if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 45 | 46 | cd .. 47 | rd /s /q temp 48 | if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 49 | -------------------------------------------------------------------------------- /lib/concurrentlinkedhashmap-lru-1.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrainSlugs83/NewBiospheresMod/1493b5219d7a71db13a0e027da293324f1018821/lib/concurrentlinkedhashmap-lru-1.4.jar -------------------------------------------------------------------------------- /logo.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrainSlugs83/NewBiospheresMod/1493b5219d7a71db13a0e027da293324f1018821/logo.pdn -------------------------------------------------------------------------------- /publish.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SET ERRORLEVEL= 3 | VERIFY OTHER 2>nul 4 | SETLOCAL ENABLEDELAYEDEXPANSION 5 | IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 6 | 7 | set /A startedAt=(%time:~0,2% * 3600) + (%time:~3,2% * 60) + (%time:~6,2%) 8 | 9 | del *.jar 2>nul 1>nul 10 | call gradlew build 11 | if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 12 | 13 | set datestamp=%date:~10,4%-%date:~4,2%-%date:~7,2% 14 | set /A timestamp=(%time:~0,2% * 3600) + (%time:~3,2% * 60) + (%time:~6,2%) 15 | set outputFolder=.\build\libs\ 16 | set zipName="Source (%datestamp%-%timestamp%).zip" 17 | 18 | for /F %%f in ('dir "%outputFolder%*.jar" /b') do ( 19 | 20 | rem copy "%outputFolder%%%f" . /y 21 | move /y "%outputFolder%%%f" . 22 | if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 23 | 24 | rem zip -9 -r %zipName% src 25 | rem if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 26 | 27 | rem zip -9 -m "%%f" %zipName% 28 | rem if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 29 | 30 | rem zip -9 "%%f" MODINFO.TXT 31 | rem if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 32 | 33 | call include.bat "%%f" "lib\concurrentlinkedhashmap-lru-1.4.jar" 34 | if ERRORLEVEL 1 EXIT /B %ERRORLEVEL% 35 | 36 | rem this improves the compression slightly: 37 | rd /s /q temp 2>nul 1>nul 38 | md temp 39 | copy "%%f" temp 40 | cd temp 41 | unzip "%%~nxf" 42 | del "%%~nxf" 43 | jar cvf "%%~nxf" * 44 | copy /y "%%~nxf" .. 45 | cd .. 46 | rd /s /q temp 47 | ) 48 | 49 | set /A endedAt=(%time:~0,2% * 3600) + (%time:~3,2% * 60) + (%time:~6,2%) 50 | set /A elapsed=(%endedAt% - %startedAt%) 51 | if "%elapsed:~0,1%" == "-" set /a elapsed=%elapsed% + (24 * 3600) 52 | 53 | echo. 54 | echo SUCCESS! 55 | echo Total Time Elapsed: %elapsed% second(s). 56 | echo. 57 | dir *.jar 58 | echo. 59 | -------------------------------------------------------------------------------- /pull.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SETLOCAL 3 | 4 | echo ARE YOU SURE YOU WANT TO GET THE LATEST CODEBASE? 5 | echo (ALL PENDING CHANGES IN THIS BRANCH WILL BE LOST!) 6 | set /p ans=^> 7 | if /i NOT "%ans:~0,1%" == "y" EXIT /B 1 8 | 9 | :: bzr pull https://github.com/BrainSlugs83/NewBiospheresMod.git/,branch=master 10 | 11 | echo. 12 | echo ===== Pulling ===== 13 | git pull 14 | 15 | echo. 16 | echo ===== Resetting to Latest ===== 17 | git reset --hard HEAD 18 | 19 | -------------------------------------------------------------------------------- /push.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | :: bzr dpush https://github.com/BrainSlugs83/NewBiospheresMod.git/,branch=master 3 | git push origin master -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/BiomeEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod; 8 | 9 | import net.minecraft.util.WeightedRandom; 10 | import net.minecraft.world.biome.BiomeGenBase; 11 | 12 | public class BiomeEntry extends WeightedRandom.Item 13 | { 14 | public final BiomeGenBase biome; 15 | 16 | public BiomeEntry(BiomeGenBase biomegenbase, int i) 17 | { 18 | super(i); 19 | this.biome = biomegenbase; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/BiosphereChunkManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod; 8 | 9 | import java.util.List; 10 | import java.util.Random; 11 | import java.util.UUID; 12 | 13 | import net.minecraft.util.WeightedRandom; 14 | import net.minecraft.world.World; 15 | import net.minecraft.world.WorldType; 16 | import net.minecraft.world.biome.BiomeGenBase; 17 | import net.minecraft.world.biome.WorldChunkManager; 18 | import newBiospheresMod.Configuration.ModConfig; 19 | 20 | public class BiosphereChunkManager extends WorldChunkManager 21 | { 22 | private final World world; 23 | private final ModConfig config; 24 | 25 | private final long seed; 26 | private static long lastSeed = 0; 27 | 28 | //private final Random rnd; 29 | 30 | // private static long getNewSeed() 31 | // { 32 | // long uuid = UUID.randomUUID().hashCode() 33 | // return uuid | (uuid << 32); 34 | // } 35 | // 36 | public BiosphereChunkManager() 37 | { 38 | this(lastSeed, NewBiospheresMod.biosphereWorldType); 39 | } 40 | 41 | public BiosphereChunkManager(World world) 42 | { 43 | this(world, world.getSeed(), NewBiospheresMod.biosphereWorldType); 44 | } 45 | 46 | public BiosphereChunkManager(long worldSeed, WorldType worldType) 47 | { 48 | this(null, worldSeed, worldType); 49 | } 50 | 51 | public BiosphereChunkManager(World world, long worldSeed, WorldType worldType) 52 | { 53 | super(worldSeed, worldType); 54 | 55 | this.world = world; 56 | this.seed = worldSeed; 57 | this.lastSeed = worldSeed; 58 | //this.rnd = new Random(this.seed); 59 | this.config = ModConfig.get(world); 60 | } 61 | 62 | /** 63 | * checks given Chunk's Biomes against List of allowed ones 64 | */ 65 | @Override 66 | public boolean areBiomesViable(int i, int j, int k, List list) 67 | { 68 | return true; 69 | } 70 | 71 | // public float getHumid(int i, int j) 72 | // { 73 | // float f = this.getBiomeGenAt(i, j).rainfall; 74 | // return f <= 1.0F ? f : 1.0F; 75 | // } 76 | 77 | // /** 78 | // * Returns a list of rainfall values for the specified blocks. Args: listToReuse, x, z, width, length. 79 | // */ 80 | // @Override 81 | // public float[] getRainfall(float[] listToReuse, int x, int z, int width, int length) 82 | // { 83 | // IntCache.resetIntCache(); 84 | // 85 | // if (listToReuse == null || listToReuse.length < width * length) 86 | // { 87 | // listToReuse = new float[width * length]; 88 | // } 89 | // 90 | // float f = this.getHumid(x, z); 91 | // int i1 = 0; 92 | // 93 | // for (int j1 = 0; j1 < width; ++j1) 94 | // { 95 | // for (int k1 = 0; k1 < length; ++k1) 96 | // { 97 | // listToReuse[i1] = f; 98 | // ++i1; 99 | // } 100 | // } 101 | // 102 | // return listToReuse; 103 | // } 104 | 105 | // public float getTemp(int i, int j) 106 | // { 107 | // float f = this.getBiomeGenAt(i, j).temperature; 108 | // return f <= 1.0F ? f : 1.0F; 109 | // } 110 | 111 | // /** 112 | // * Returns a list of temperatures to use for the specified blocks. Args: listToReuse, x, z, width, length 113 | // */ 114 | // public float[] getTemperatures(float[] listToReuse, int x, int z, int width, int length) 115 | // { 116 | // IntCache.resetIntCache(); 117 | // 118 | // if (listToReuse == null || listToReuse.length < width * length) 119 | // { 120 | // listToReuse = new float[width * length]; 121 | // } 122 | // 123 | // float f = this.getTemp(x, z); 124 | // int i1 = 0; 125 | // 126 | // for (int j1 = 0; j1 < width; ++j1) 127 | // { 128 | // for (int k1 = 0; k1 < length; ++k1) 129 | // { 130 | // listToReuse[i1] = f; 131 | // ++i1; 132 | // } 133 | // } 134 | // 135 | // return listToReuse; 136 | // } 137 | 138 | /** 139 | * Returns the BiomeGenBase related to the x, z position on the world. 140 | */ 141 | 142 | @Override 143 | public BiomeGenBase getBiomeGenAt(int x, int z) 144 | { 145 | int k = x >> 4; 146 | int l = z >> 4; 147 | int i1 = (k - (int)Math.floor(Math.IEEEremainder(k, config.getScaledGridSize())) << 4) + 8; 148 | int j1 = (l - (int)Math.floor(Math.IEEEremainder(l, config.getScaledGridSize())) << 4) + 8; 149 | 150 | Random rnd = new Random(this.seed); 151 | long l1 = rnd.nextLong() / 2L * 2L + 1L; 152 | long l2 = rnd.nextLong() / 2L * 2L + 1L; 153 | rnd .setSeed((i1 * l1 + j1 * l2) * 7215145L ^ this.seed); 154 | return ((BiomeEntry)WeightedRandom.getRandomItem(rnd, config.AllBiomes)).biome; 155 | } 156 | 157 | // /** 158 | // * Returns an array of biomes for the location input. 159 | // */ 160 | // @Override 161 | // public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase[] biomes, int i, int j, int k, int l) 162 | // { 163 | // return this.getBiomeGenAt(biomes, i, j, k, l, false); 164 | // } 165 | 166 | // /** 167 | // * Return a list of biomes for the specified blocks. Args: listToReuse, x, y, width, length, cacheFlag (if false, 168 | // * don't check biomeCache to avoid infinite loop in BiomeCacheBlock) 169 | // */ 170 | // @Override 171 | // public BiomeGenBase[] getBiomeGenAt(BiomeGenBase[] biomes, int x, int z, int width, int length, boolean 172 | // cacheFlag) 173 | // { 174 | // IntCache.resetIntCache(); 175 | // 176 | // final int size = width * length; 177 | // 178 | // if (biomes == null || biomes.length < size) 179 | // { 180 | // biomes = new BiomeGenBase[size]; 181 | // } 182 | // 183 | // BiomeGenBase biomegenbase = this.getBiomeGenAt(x, z); 184 | // 185 | // for (int i = 0; i < size; i++) 186 | // { 187 | // biomes[i] = biomegenbase; 188 | // } 189 | // 190 | // return biomes; 191 | // } 192 | 193 | // /** 194 | // * Finds a valid position within a range, that is in one of the listed biomes. Searches {par1,par2} +-par3 blocks. 195 | // * Strongly favors positive y positions. 196 | // */ 197 | // @Override 198 | // public ChunkPosition findBiomePosition(int i, int j, int k, List list, Random random) 199 | // { 200 | // return new ChunkPosition(0, 64, 0); 201 | // } 202 | 203 | } 204 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/BiosphereChunkProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod; 8 | 9 | import java.util.Arrays; 10 | import java.util.List; 11 | import java.util.Random; 12 | 13 | import scala.Array; 14 | import net.minecraft.block.Block; 15 | import net.minecraft.block.BlockFlower; 16 | import net.minecraft.block.BlockSand; 17 | import net.minecraft.block.material.Material; 18 | import net.minecraft.entity.EnumCreatureType; 19 | import net.minecraft.init.Blocks; 20 | import net.minecraft.util.IProgressUpdate; 21 | import net.minecraft.util.WeightedRandom; 22 | import net.minecraft.world.ChunkPosition; 23 | import net.minecraft.world.SpawnerAnimals; 24 | import net.minecraft.world.World; 25 | import net.minecraft.world.biome.BiomeGenBase; 26 | import net.minecraft.world.chunk.Chunk; 27 | import net.minecraft.world.chunk.IChunkProvider; 28 | import net.minecraft.world.gen.MapGenBase; 29 | import net.minecraft.world.gen.NoiseGeneratorOctaves; 30 | import net.minecraft.world.gen.feature.WorldGenBigMushroom; 31 | import net.minecraft.world.gen.feature.WorldGenCactus; 32 | import net.minecraft.world.gen.feature.WorldGenClay; 33 | import net.minecraft.world.gen.feature.WorldGenDeadBush; 34 | import net.minecraft.world.gen.feature.WorldGenFire; 35 | import net.minecraft.world.gen.feature.WorldGenFlowers; 36 | import net.minecraft.world.gen.feature.WorldGenMinable; 37 | import net.minecraft.world.gen.feature.WorldGenPumpkin; 38 | import net.minecraft.world.gen.feature.WorldGenReed; 39 | import net.minecraft.world.gen.feature.WorldGenTallGrass; 40 | import net.minecraft.world.gen.feature.WorldGenWaterlily; 41 | import net.minecraft.world.gen.feature.WorldGenerator; 42 | import newBiospheresMod.Configuration.ModConfig; 43 | import newBiospheresMod.Helpers.AvgCalc; 44 | import newBiospheresMod.Helpers.Blx; 45 | import newBiospheresMod.Helpers.Creator; 46 | import newBiospheresMod.Helpers.IKeyProvider; 47 | import newBiospheresMod.Helpers.LruCacheList; 48 | import newBiospheresMod.Helpers.ModConsts; 49 | import newBiospheresMod.Helpers.Predicate; 50 | import newBiospheresMod.Helpers.TopDownBoundingBox; 51 | import newBiospheresMod.Helpers.Utils; 52 | import newBiospheresMod.Models.Sphere; 53 | import newBiospheresMod.Models.SphereChunk; 54 | 55 | public class BiosphereChunkProvider implements IChunkProvider 56 | { 57 | // #region Caching 58 | 59 | private static LruCacheList chunkProviders = new LruCacheList(3, 60 | new IKeyProvider() 61 | { 62 | @Override 63 | public Object provideKey(BiosphereChunkProvider item) 64 | { 65 | if (item == null) { return null; } 66 | return item.world; 67 | } 68 | }); 69 | 70 | public static BiosphereChunkProvider get(final World world) 71 | { 72 | return chunkProviders.FindOrAdd(world, new Creator() 73 | { 74 | @Override 75 | public BiosphereChunkProvider create() 76 | { 77 | return new BiosphereChunkProvider(world); 78 | } 79 | }); 80 | } 81 | 82 | // #endregion 83 | 84 | // #region Chunk Caching 85 | 86 | private static class ChunkCacheKey 87 | { 88 | public final int x; 89 | public final int z; 90 | public final World world; 91 | 92 | public ChunkCacheKey(final World world, final int x, final int z) 93 | { 94 | this.world = world; 95 | this.x = x; 96 | this.z = z; 97 | } 98 | 99 | @Override 100 | public boolean equals(Object obj) 101 | { 102 | if (obj == null) { return false; } 103 | if (this == obj) { return true; } 104 | if (!(obj instanceof ChunkCacheKey)) { return false; } 105 | ChunkCacheKey other = (ChunkCacheKey)obj; 106 | 107 | return this.x == other.x && this.z == other.z && this.world == other.world; 108 | } 109 | 110 | @Override 111 | public int hashCode() 112 | { 113 | int worldHash = (world == null) ? 0 : world.hashCode(); 114 | return ((x & 0xFFFF) | ((z & 0xFFFF) << 16)) ^ worldHash ^ 319023957; 115 | } 116 | } 117 | 118 | LruCacheList ChunksCache = new LruCacheList(15, new IKeyProvider() 119 | { 120 | @Override 121 | public Object provideKey(Chunk item) 122 | { 123 | if (item == null) { return 0; } 124 | if (!item.isChunkLoaded) { return 0; } 125 | return new ChunkCacheKey(item.worldObj, item.xPosition, item.zPosition); 126 | } 127 | }); 128 | 129 | // #endregion 130 | 131 | // #region Fields 132 | 133 | public final World world; 134 | public final ModConfig config; 135 | public final NoiseGeneratorOctaves noiseGenerator; 136 | public final long worldSeed; 137 | private final MapGenBase caveGen = new BiosphereMapGen(); 138 | 139 | // #endregion 140 | 141 | // /** 142 | // * Get whether the map features (e.g. strongholds) generation is enabled or disabled. 143 | // */ 144 | // public boolean getMapFeaturesEnabled() 145 | // { 146 | // return world.getWorldInfo().isMapFeaturesEnabled(); 147 | // } 148 | 149 | private BiosphereChunkProvider(World world) 150 | { 151 | this.world = world; 152 | this.worldSeed = world.getSeed(); 153 | this.config = ModConfig.get(world); 154 | this.config.update(); 155 | 156 | if (this.config.isNoiseEnabled()) 157 | { 158 | noiseGenerator = new NoiseGeneratorOctaves(new Random(this.worldSeed), 4); 159 | } 160 | else 161 | { 162 | noiseGenerator = null; 163 | } 164 | } 165 | 166 | private SphereChunk GenerateChunk(int chunkX, int chunkZ, BlockData[] blocks) 167 | { 168 | Arrays.fill(blocks, config.getOutsideFillerBlock()); 169 | 170 | SphereChunk chunk = SphereChunk.get(this, chunkX, chunkZ); 171 | 172 | if (chunk != null && chunk.masterSphere != null) 173 | { 174 | Sphere sphere = chunk.masterSphere; 175 | 176 | final TopDownBoundingBox chunkBox = TopDownBoundingBox.FromChunk(chunkX, chunkZ); 177 | 178 | if (Utils.Any(Utils.Where(sphere.getBoundingBoxes(), new Predicate() 179 | { 180 | @Override 181 | public boolean test(TopDownBoundingBox box) 182 | { 183 | return chunkBox.CollidesWith(box); 184 | } 185 | }))) 186 | { 187 | // we collided with something like a sphere, ore orb, bridge, or other feature. 188 | GenerateChunkInner(chunkX, chunkZ, blocks, chunk); 189 | } 190 | } 191 | 192 | return chunk; 193 | } 194 | 195 | private void GenerateChunkInner(int chunkX, int chunkZ, BlockData[] blocks, SphereChunk chunk) 196 | { 197 | final int baseX = chunkX << 4; 198 | final int baseZ = chunkZ << 4; 199 | final int bridgeWidth = config.getBridgeWidth(); 200 | final BlockData outsideFillerBlock = config.getOutsideFillerBlock(); 201 | 202 | Sphere sphere = chunk.masterSphere; 203 | Random rnd = chunk.GetPhaseRandom("GenerateChunk"); 204 | 205 | for (int zo = 0; zo < 16; ++zo) 206 | { 207 | for (int xo = 0; xo < 16; ++xo) 208 | { 209 | int midY = chunk.getChunkBoundSurfaceLevel(xo, zo); 210 | 211 | for (int rawY = ModConsts.WORLD_MAX_Y; rawY >= ModConsts.WORLD_MIN_Y; rawY--) 212 | { 213 | int idx = ModConsts.GetChunkArrayIndex(xo, rawY, zo); 214 | BlockData block = BlockData.Empty; 215 | 216 | int rawX = baseX + xo; 217 | int rawZ = baseZ + zo; 218 | 219 | int sphereDistance = sphere.getMainDistance(rawX, rawY, rawZ); 220 | int orbDistance = sphere.getOrbDistance(rawX, rawY, rawZ); 221 | int lakeDistance = sphere.getLakeDistance(rawX, rawY, rawZ); 222 | 223 | if (sphereDistance > sphere.scaledSphereRadius) 224 | { 225 | BlockData stairwayBlock = sphere.getOrbStairwayBlock(rawX, rawY, rawZ); 226 | 227 | if (stairwayBlock != null) 228 | { 229 | block = stairwayBlock; 230 | } 231 | } 232 | 233 | if (rawY > midY) 234 | { 235 | if (sphere.scaledSphereRadius == sphereDistance) 236 | { 237 | if (rawY >= midY + 4 || Math.abs(rawX - sphere.sphereLocation.posX) > bridgeWidth 238 | && Math.abs(rawZ - sphere.sphereLocation.posZ) > bridgeWidth) 239 | { 240 | block = sphere.getDomeBlock(rawX, rawY, rawZ); 241 | } 242 | } 243 | else if (sphere.hasLake && config.isNoiseEnabled() && sphere.isDesert 244 | && (lakeDistance > sphere.scaledLakeRadius && lakeDistance <= sphere.scaledLakeEdgeRadius)) 245 | { 246 | if (rawY == sphere.lakeLocation.posY) 247 | { 248 | block = new BlockData(sphere.biome.topBlock); 249 | } 250 | else if (rawY < sphere.lakeLocation.posY) 251 | { 252 | block = new BlockData(sphere.biome.fillerBlock); 253 | } 254 | } 255 | else if (sphere.hasLake && config.isNoiseEnabled() && sphere.isDesert 256 | && lakeDistance <= sphere.scaledLakeRadius) 257 | { 258 | if (rawY == sphere.lakeLocation.posY && sphere.biome == BiomeGenBase.icePlains) 259 | { 260 | block = new BlockData(Blx.ice); 261 | } 262 | else if (rawY <= sphere.lakeLocation.posY) 263 | { 264 | block = sphere.GetLakeBlock(); 265 | } 266 | } 267 | else if (config.doesNeedProtectionGlass() 268 | && rawY <= midY + 4 269 | && sphereDistance > sphere.scaledSphereRadius 270 | && (Math.abs(rawX - sphere.sphereLocation.posX) == bridgeWidth || Math.abs(rawZ 271 | - sphere.sphereLocation.posZ) == bridgeWidth)) 272 | { 273 | block = sphere.getDomeBlock(rawX, rawY, rawZ); 274 | } 275 | else if (config.doesNeedProtectionGlass() 276 | && rawY == midY + 4 277 | && sphereDistance > sphere.scaledSphereRadius 278 | && (Math.abs(rawX - sphere.sphereLocation.posX) < bridgeWidth || Math.abs(rawZ 279 | - sphere.sphereLocation.posZ) < bridgeWidth)) 280 | { 281 | block = sphere.getDomeBlock(rawX, rawY, rawZ); 282 | } 283 | else if (config.doesNeedProtectionGlass() 284 | && rawY < midY + 4 285 | && sphereDistance > sphere.scaledSphereRadius 286 | && (Math.abs(rawX - sphere.sphereLocation.posX) < bridgeWidth || Math.abs(rawZ 287 | - sphere.sphereLocation.posZ) < bridgeWidth)) 288 | { 289 | block = BlockData.Empty; 290 | } 291 | else if (config.doesNeedProtectionGlass() && sphereDistance > sphere.scaledSphereRadius) 292 | { 293 | block = outsideFillerBlock; 294 | } 295 | else if (rawY == midY + 1 296 | && sphereDistance > sphere.scaledSphereRadius 297 | && (Math.abs(rawX - sphere.sphereLocation.posX) == bridgeWidth || Math.abs(rawZ 298 | - sphere.sphereLocation.posZ) == bridgeWidth)) 299 | { 300 | block = config.getBridgeRailBlock(); 301 | } 302 | } 303 | else if (sphere.scaledSphereRadius == sphereDistance) 304 | { 305 | block = new BlockData(Blx.stone); 306 | } 307 | else if (sphere.hasLake && sphere.isDesert 308 | && lakeDistance <= sphere.scaledLakeRadius) 309 | { 310 | if (rawY == sphere.lakeLocation.posY && sphere.biome == BiomeGenBase.icePlains) 311 | { 312 | block = new BlockData(Blx.ice); 313 | } 314 | else if (rawY <= sphere.lakeLocation.posY) 315 | { 316 | block = sphere.GetLakeBlock(); 317 | } 318 | } 319 | else if (sphere.hasLake && rawY < sphere.lakeLocation.posY - 1 320 | && sphere.isDesert && lakeDistance <= sphere.scaledLakeEdgeRadius) 321 | { 322 | if (ModConsts.DEBUG) 323 | { 324 | block = new BlockData(Blx.glowstone); 325 | } 326 | else 327 | { 328 | block = new BlockData(sphere.lavaLake ? Blx.gravel : Blx.sand); 329 | } 330 | } 331 | else if (sphereDistance < sphere.scaledSphereRadius) 332 | { 333 | if (rawY == midY) 334 | { 335 | block = new BlockData(sphere.biome.topBlock); 336 | } 337 | else if (rawY == midY - 1) 338 | { 339 | block = new BlockData(sphere.biome.fillerBlock); 340 | } 341 | else 342 | { 343 | block = new BlockData(Blx.stone); 344 | } 345 | } 346 | else if (rawY == midY 347 | && sphereDistance > sphere.scaledSphereRadius 348 | && (Math.abs(rawX - sphere.sphereLocation.posX) < bridgeWidth + 1 || Math.abs(rawZ 349 | - sphere.sphereLocation.posZ) < bridgeWidth + 1)) 350 | { 351 | block = config.getBridgeSupportBlock(); 352 | } 353 | else if (config.doesNeedProtectionGlass() && sphereDistance > sphere.scaledSphereRadius) 354 | { 355 | block = outsideFillerBlock; 356 | } 357 | 358 | if (sphere.scaledOrbRadius == orbDistance) 359 | { 360 | block = config.getOrbBlock(); 361 | } 362 | else if (orbDistance < sphere.scaledOrbRadius) 363 | { 364 | block = ((BlockEntry)WeightedRandom.getRandomItem(rnd, config.OreOrbBlocks)).Block; 365 | } 366 | 367 | blocks[idx] = block; 368 | } 369 | } 370 | } 371 | } 372 | 373 | /** 374 | * loads or generates the chunk at the chunk location specified 375 | */ 376 | @Override 377 | public Chunk loadChunk(int x, int z) 378 | { 379 | return this.provideChunk(x, z); 380 | } 381 | 382 | /** 383 | * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the 384 | * specified chunk from the map seed and chunk seed 385 | */ 386 | @Override 387 | public Chunk provideChunk(final int x, final int z) 388 | { 389 | return ChunksCache.FindOrAdd(new ChunkCacheKey(this.world, x, z), new Creator() 390 | { 391 | @Override 392 | public Chunk create() 393 | { 394 | return GenerateNewChunk(x, z); 395 | } 396 | }); 397 | } 398 | 399 | private static final AvgCalc avg = new AvgCalc(); 400 | private static long lastPrintedAt = Long.MIN_VALUE; 401 | 402 | private Chunk GenerateNewChunk(int x, int z) 403 | { 404 | long startedAt = System.currentTimeMillis(); 405 | 406 | BlockData[] blockData = new BlockData[ModConsts.GetChunkArraySize()]; 407 | SphereChunk sphereChunk = this.GenerateChunk(x, z, blockData); 408 | 409 | Block[] blocks = BlockData.getBlockArray(blockData); 410 | byte[] metadata = BlockData.getMetadataArray(blockData); 411 | 412 | this.caveGen.func_151539_a(this, this.world, x, z, blocks); // func_151539_a == generate 413 | 414 | Chunk chunk = new Chunk(this.world, blocks, metadata, x, z); 415 | chunk.generateSkylightMap(); 416 | 417 | // Fix for Issue #24: 418 | if (sphereChunk != null) 419 | { 420 | if (sphereChunk.masterSphere != null) 421 | { 422 | if (sphereChunk.masterSphere.biome != null) 423 | { 424 | // System.out.println("Biome at " + sphereChunk.chunkX + ", " + sphereChunk.chunkZ + ": " + 425 | // sphereChunk.masterSphere.biome.biomeName); 426 | 427 | byte[] biomes = new byte[256]; 428 | Arrays.fill(biomes, (byte)(sphereChunk.masterSphere.biome.biomeID & 0xFF)); 429 | chunk.setBiomeArray(biomes); 430 | } 431 | } 432 | } 433 | 434 | // It's normal to see performance warnings for a few chunks at start-up and maybe every once in a while after 435 | // that, but the average should drop down to less than a millisecond within a minute or so. 436 | 437 | long now = System.currentTimeMillis(); 438 | long elapsed = now - startedAt; 439 | avg.addValue(elapsed / 1000d); 440 | if (elapsed >= 100) 441 | { 442 | System.out.printf("WARNING: BIOSPHERE GENERATE NEW CHUNK @ [%d, %d] TOOK %.3f SECONDS!%n", x, z, 443 | (elapsed / 1000d)); 444 | } 445 | 446 | if (lastPrintedAt == Long.MIN_VALUE || (now - lastPrintedAt) > 2500) 447 | { 448 | lastPrintedAt = now; 449 | if (avg.getCount() >= 5) 450 | { 451 | double av = avg.getAverage(); 452 | if (av >= .02D) 453 | { 454 | System.out.printf("INFO: BIOSPHERE GENERATE NEW CHUNK ON AVERAGE TAKES %.3f SECONDS.%n", av); 455 | } 456 | } 457 | } 458 | 459 | return chunk; 460 | } 461 | 462 | /** 463 | * Checks to see if a chunk exists at x, z 464 | */ 465 | @Override 466 | public boolean chunkExists(int x, int z) 467 | { 468 | return true; 469 | } 470 | 471 | /** 472 | * Populates chunk with ores etc etc 473 | */ 474 | @Override 475 | public void populate(IChunkProvider chunkProvider, int chunkX, int chunkZ) 476 | { 477 | SphereChunk chunk = SphereChunk.get(this, chunkX, chunkZ); 478 | Sphere sphere = chunk.masterSphere; 479 | Random rnd = chunk.GetPhaseRandom("populate"); 480 | 481 | BlockSand.fallInstantly = true; 482 | int absX = chunkX << 4; 483 | int absZ = chunkZ << 4; 484 | 485 | for (int i = 0; i < 20; i++) 486 | { 487 | int x = absX + rnd.nextInt(16); 488 | int y = rnd.nextInt(ModConsts.WORLD_HEIGHT); 489 | int z = absZ + rnd.nextInt(16); 490 | 491 | (new WorldGenMinable(Blx.coal_ore, 16)).generate(this.world, rnd, x, y, z); 492 | } 493 | 494 | for (int i = 0; i < 20; i++) 495 | { 496 | int x = absX + rnd.nextInt(16); 497 | int y = rnd.nextInt(ModConsts.WORLD_HEIGHT); 498 | int z = absZ + rnd.nextInt(16); 499 | 500 | (new WorldGenMinable(Blx.iron_ore, 8)).generate(this.world, rnd, x, y, z); 501 | } 502 | 503 | for (int i = 0; i < 2; i++) 504 | { 505 | int x = absX + rnd.nextInt(16); 506 | int y = rnd.nextInt(ModConsts.WORLD_HEIGHT); 507 | int z = absZ + rnd.nextInt(16); 508 | 509 | (new WorldGenMinable(Blx.gold_ore, 8)).generate(this.world, rnd, x, y, z); 510 | } 511 | 512 | for (int i = 0; i < 8; i++) 513 | { 514 | int x = absX + rnd.nextInt(16); 515 | int y = rnd.nextInt(ModConsts.WORLD_HEIGHT); 516 | int z = absZ + rnd.nextInt(16); 517 | 518 | (new WorldGenMinable(Blx.redstone_ore, 7)).generate(this.world, rnd, x, y, z); 519 | } 520 | 521 | for (int i = 0; i < sphere.biome.theBiomeDecorator.sandPerChunk2; i++) 522 | { 523 | int x = absX + rnd.nextInt(16) + 8; 524 | int z = absZ + rnd.nextInt(16) + 8; 525 | int y = getBioTopSolidOrLiquidBlock(x, z); 526 | 527 | sphere.biome.theBiomeDecorator.sandGen.generate(this.world, rnd, x, y, z); 528 | } 529 | 530 | for (int i = 0; i < sphere.biome.theBiomeDecorator.clayPerChunk; i++) 531 | { 532 | int x = absX + rnd.nextInt(16) + 8; 533 | int z = absZ + rnd.nextInt(16) + 8; 534 | int y = getBioTopSolidOrLiquidBlock(x, z); 535 | 536 | if (y > 0) 537 | { 538 | sphere.biome.theBiomeDecorator.clayGen.generate(this.world, rnd, x, y, z); 539 | } 540 | } 541 | 542 | for (int i = 0; i < sphere.biome.theBiomeDecorator.sandPerChunk; i++) 543 | { 544 | int x = absX + rnd.nextInt(16) + 8; 545 | int z = absZ + rnd.nextInt(16) + 8; 546 | int y = getBioTopSolidOrLiquidBlock(x, z); 547 | 548 | if (y > 0) 549 | { 550 | sphere.biome.theBiomeDecorator.gravelAsSandGen.generate(this.world, rnd, x, y, z); 551 | } 552 | } 553 | 554 | int treesPerChunk = sphere.biome.theBiomeDecorator.treesPerChunk; 555 | 556 | if (rnd.nextInt(10) == 0) 557 | { 558 | treesPerChunk++; 559 | } 560 | 561 | for (int i = 0; i < treesPerChunk; i++) 562 | { 563 | int x = absX + rnd.nextInt(16) + 8; 564 | int z = absZ + rnd.nextInt(16) + 8; 565 | int y = this.world.getHeightValue(x, z); 566 | 567 | if (y > 0) 568 | { 569 | // func_150567_a == getRandomWorldGenForTrees 570 | WorldGenerator gen = sphere.biome.func_150567_a(rnd); 571 | 572 | gen.setScale(config.getScale(), config.getScale(), config.getScale()); 573 | gen.generate(this.world, rnd, x, y, z); 574 | } 575 | } 576 | 577 | for (int i = 0; i < sphere.biome.theBiomeDecorator.bigMushroomsPerChunk; i++) 578 | { 579 | int x = absX + rnd.nextInt(16) + 8; 580 | int z = absZ + rnd.nextInt(16) + 8; 581 | int y = getBioHeightValue(x, z); 582 | 583 | if (y > 0) 584 | { 585 | sphere.biome.theBiomeDecorator.bigMushroomGen.generate(this.world, rnd, x, y, z); 586 | } 587 | } 588 | 589 | for (int i = 0; i < sphere.biome.theBiomeDecorator.flowersPerChunk; i++) 590 | { 591 | int x = absX + rnd.nextInt(16) + 8; 592 | int z = absZ + rnd.nextInt(16) + 8; 593 | int y = getBioHeightValue(x, z); 594 | 595 | if (y > 0) 596 | { 597 | y = rnd.nextInt(y + 32); 598 | String s = sphere.biome.func_150572_a(rnd, x, y, z); 599 | 600 | BlockFlower f = BlockFlower.func_149857_e(s); 601 | if (f.getMaterial() != Material.air) 602 | { 603 | (new WorldGenFlowers(f)).generate(this.world, rnd, x, y, z); 604 | } 605 | } 606 | } 607 | 608 | for (int i = 0; i <= sphere.biome.theBiomeDecorator.mushroomsPerChunk; i++) 609 | { 610 | int x = absX + rnd.nextInt(16) + 8; 611 | int z = absZ + rnd.nextInt(16) + 8; 612 | int y = getBioHeightValue(x, z); 613 | 614 | if (y > 0) 615 | { 616 | if (i == 0) 617 | { y = rnd.nextInt(y * 2); } 618 | 619 | if (rnd.nextInt(4) == 0) 620 | { 621 | sphere.biome.theBiomeDecorator.mushroomBrownGen.generate(world, rnd, x, y, z); 622 | } 623 | 624 | if (rnd.nextInt(8) == 0) 625 | { 626 | if (i != 0) 627 | { y = rnd.nextInt(y * 2); } 628 | 629 | sphere.biome.theBiomeDecorator.mushroomRedGen.generate(world, rnd, x, y, z); 630 | } 631 | } 632 | } 633 | 634 | for (int i = 0; i < sphere.biome.theBiomeDecorator.deadBushPerChunk; i++) 635 | { 636 | int x = absX + rnd.nextInt(16) + 8; 637 | int z = absZ + rnd.nextInt(16) + 8; 638 | int y = getBioHeightValue(x, z); 639 | 640 | if (y > 0) 641 | { 642 | y = rnd.nextInt(y * 2); 643 | (new WorldGenDeadBush(Blx.deadbush)).generate(this.world, rnd, x, y, z); 644 | } 645 | } 646 | 647 | if (config.isTallGrassEnabled()) 648 | { 649 | int grassPerChunk = sphere.biome.theBiomeDecorator.grassPerChunk; 650 | for (int i = 0; i < grassPerChunk; i++) 651 | { 652 | int x = absX + rnd.nextInt(16) + 8; 653 | int z = absZ + rnd.nextInt(16) + 8; 654 | int y = getBioHeightValue(x, z); 655 | 656 | if (y > 0) 657 | { 658 | y = rnd.nextInt(y * 2); 659 | WorldGenerator worldgenerator = sphere.biome.getRandomWorldGenForGrass(rnd); 660 | worldgenerator.generate(world, rnd, x, y, z); 661 | } 662 | } 663 | } 664 | 665 | for (int i = 0; i < sphere.biome.theBiomeDecorator.reedsPerChunk + 10; i++) 666 | { 667 | int x = absX + rnd.nextInt(16) + 8; 668 | int z = absZ + rnd.nextInt(16) + 8; 669 | int y = getBioHeightValue(x, z); 670 | 671 | if (y > 0) 672 | { 673 | y = rnd.nextInt(y * 2); 674 | (new WorldGenReed()).generate(this.world, rnd, x, y, z); 675 | } 676 | } 677 | 678 | if (rnd.nextInt(32) == 0) 679 | { 680 | int x = absX + rnd.nextInt(16) + 8; 681 | int z = absZ + rnd.nextInt(16) + 8; 682 | int y = getBioHeightValue(x, z); 683 | if (y > 0) 684 | { 685 | y = rnd.nextInt(y); 686 | (new WorldGenPumpkin()).generate(this.world, rnd, x, y, z); 687 | } 688 | } 689 | 690 | for (int i = 0; i < sphere.biome.theBiomeDecorator.cactiPerChunk; i++) 691 | { 692 | int x = absX + rnd.nextInt(16) + 8; 693 | int z = absZ + rnd.nextInt(16) + 8; 694 | int y = getBioHeightValue(x, z); 695 | 696 | if (y > 0) 697 | { 698 | y = rnd.nextInt(y * 2); 699 | (new WorldGenCactus()).generate(this.world, rnd, x, y, z); 700 | } 701 | } 702 | 703 | if (sphere.biome == BiomeGenBase.hell) 704 | { 705 | if (rnd.nextBoolean()) 706 | { 707 | int x = absX + rnd.nextInt(16) + 8; 708 | int z = absZ + rnd.nextInt(16) + 8; 709 | int y = this.world.getHeightValue(x, z); 710 | if (y > 0) 711 | { 712 | (new WorldGenFire()).generate(this.world, rnd, x, y, z); 713 | } 714 | } 715 | 716 | if (rnd.nextBoolean()) 717 | { 718 | int x = absX + rnd.nextInt(16) + 8; 719 | int z = absZ + rnd.nextInt(16) + 8; 720 | int y = this.world.getHeightValue(x, z); 721 | if (y > 0) 722 | { 723 | (new WorldGenFlowers(Blx.brown_mushroom)).generate(world, rnd, x, y, z); 724 | } 725 | } 726 | 727 | if (rnd.nextBoolean()) 728 | { 729 | int x = absX + rnd.nextInt(16) + 8; 730 | int z = absZ + rnd.nextInt(16) + 8; 731 | int y = this.world.getHeightValue(x, z); 732 | if (y > 0) 733 | { 734 | (new WorldGenFlowers(Blx.red_mushroom)).generate(world, rnd, x, y, z); 735 | } 736 | } 737 | } 738 | else if (sphere.biome.getEnableSnow()) 739 | { 740 | for (int zo = 0; zo < 16; zo++) 741 | { 742 | for (int xo = 0; xo < 16; xo++) 743 | { 744 | int x = xo + absX; 745 | int z = zo + absZ; 746 | int y = this.world.getHeightValue(x, z) + 16; 747 | while (y > 0 && (world.isAirBlock(x, --y, z) || (world.getBlock(x, y, z) instanceof BlockDome))) 748 | { /* do nothing */} 749 | 750 | if (y > 0) 751 | { 752 | if (world.isBlockFreezable(x, y, z)) 753 | { 754 | world.setBlock(x, y, z, Blx.ice); 755 | } 756 | else if (world.func_147478_e(x, y, z, false) && 757 | Blx.snow_layer.canPlaceBlockAt(world, x, y + 1, z)) 758 | { 759 | if (!(world.getBlock(x, y + 1, z) instanceof BlockDome)) 760 | { 761 | world.setBlock(x, y + 1, z, Blx.snow_layer, 0, 2); 762 | } 763 | } 764 | } 765 | } 766 | } 767 | } 768 | 769 | for (int i = 0; i < sphere.biome.theBiomeDecorator.waterlilyPerChunk; i++) 770 | { 771 | int x = absX + rnd.nextInt(16) + 8; 772 | int z = absZ + rnd.nextInt(16) + 8; 773 | int y = this.world.getHeightValue(x, z); 774 | 775 | if (y > 0) 776 | { 777 | while (y < world.getActualHeight() && !world.isAirBlock(x, ++y, z)) 778 | { /* do nothing */ } 779 | 780 | while (y > 0 && (world.isAirBlock(x, --y - 1, z) || world.getBlock(x, y, z) instanceof BlockDome)) 781 | { /* do nothing */ } 782 | 783 | (new WorldGenWaterlily()).generate(this.world, rnd, x, y + 1, z); 784 | } 785 | } 786 | 787 | SpawnerAnimals.performWorldGenSpawning(this.world, sphere.biome, absX + 8, absZ + 8, 16, 16, rnd); 788 | BlockSand.fallInstantly = false; 789 | } 790 | 791 | private int getBioHeightValue(int x, int z) 792 | { 793 | return world.getHeightValue(x, z); 794 | } 795 | 796 | private int getBioTopSolidOrLiquidBlock(int x, int z) 797 | { 798 | for (int y = world.getHeightValue(x, z); y > 0; y--) 799 | { 800 | Block b = world.getBlock(x, y, z); 801 | if (!(b instanceof BlockDome) && b.getMaterial().blocksMovement() 802 | && b.getMaterial() != Material.leaves && !b.isFoliage(world, x, y, z)) 803 | { 804 | return y + 1; 805 | } 806 | } 807 | 808 | return -1; 809 | } 810 | 811 | /** 812 | * Two modes of operation: if passed true, save all Chunks in one go. If passed false, save up to two chunks. Return 813 | * true if all chunks have been saved. 814 | */ 815 | @Override 816 | public boolean saveChunks(boolean flag, IProgressUpdate iprogressupdate) 817 | { 818 | return true; 819 | } 820 | 821 | /** 822 | * Unloads chunks that are marked to be unloaded. This is not guaranteed to unload every such chunk. 823 | */ 824 | @Override 825 | public boolean unloadQueuedChunks() 826 | { 827 | return false; 828 | } 829 | 830 | /** 831 | * Returns if the IChunkProvider supports saving. 832 | */ 833 | @Override 834 | public boolean canSave() 835 | { 836 | return true; 837 | } 838 | 839 | /** 840 | * Converts the instance data to a readable string. 841 | */ 842 | @Override 843 | public String makeString() 844 | { 845 | return "RandomLevelSource"; 846 | } 847 | 848 | /** 849 | * Returns a list of creatures of the specified type that can spawn at the given location. 850 | */ 851 | @Override 852 | public List getPossibleCreatures(EnumCreatureType enumcreaturetype, int i, int j, int k) 853 | { 854 | BiomeGenBase biomegenbase = this.world.getBiomeGenForCoords(i, k); 855 | return biomegenbase == null ? null : biomegenbase.getSpawnableList(enumcreaturetype); 856 | } 857 | 858 | /** 859 | * Returns the location of the closest structure of the specified type. If not found returns null. 860 | */ 861 | public ChunkPosition findClosestStructure(World world1, String s, int i, int j, int k) 862 | { 863 | return null; 864 | } 865 | 866 | @Override 867 | public int getLoadedChunkCount() 868 | { 869 | return 0; 870 | } 871 | 872 | @Override 873 | public void recreateStructures(int var1, int var2) 874 | { 875 | /* do nothing */ 876 | } 877 | 878 | @Override 879 | public void saveExtraData() 880 | { 881 | /* do nothing */ 882 | } 883 | 884 | @Override 885 | public ChunkPosition func_147416_a(World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, 886 | int p_147416_5_) 887 | { 888 | return null; 889 | } 890 | } 891 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/BiosphereMapGen.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod; 8 | 9 | import java.util.Random; 10 | 11 | import net.minecraft.block.Block; 12 | import net.minecraft.util.MathHelper; 13 | import net.minecraft.world.World; 14 | import net.minecraft.world.chunk.IChunkProvider; 15 | import net.minecraft.world.gen.MapGenBase; 16 | import newBiospheresMod.Helpers.Blx; 17 | import newBiospheresMod.Helpers.ModConsts; 18 | import newBiospheresMod.Models.Sphere; 19 | import newBiospheresMod.Models.SphereChunk; 20 | 21 | public class BiosphereMapGen extends MapGenBase 22 | { 23 | BiosphereChunkProvider chunkProvider = null; 24 | 25 | @Override 26 | public void func_151539_a(IChunkProvider chunkProvider, World world, int x, int z, Block[] blocks) 27 | { 28 | if (this.chunkProvider == null && chunkProvider instanceof BiosphereChunkProvider) 29 | { 30 | this.chunkProvider = (BiosphereChunkProvider)chunkProvider; 31 | } 32 | 33 | super.func_151539_a(chunkProvider, world, x, z, blocks); 34 | } 35 | 36 | protected void a(int i, int j, Block[] blocks, double d, double d1, double d2) 37 | { 38 | this.a(i, j, blocks, d, d1, d2, 10.0F + this.rand.nextFloat() * 20.0F, 0.0F, 0.0F, -1, -1, 0.5D); 39 | } 40 | 41 | protected void a(int chunkX, int chunkZ, Block[] blocks, double d, double d1, double d2, float f, float f1, 42 | float f2, int k, int l, double d3) 43 | { 44 | int chunkHeight = blocks.length / (16 * 16); 45 | 46 | SphereChunk chunk = null; 47 | Sphere sphere = null; 48 | 49 | if (this.chunkProvider != null) 50 | { 51 | chunk = SphereChunk.get(chunkProvider, chunkX, chunkZ); 52 | if (chunk != null) 53 | { 54 | sphere = chunk.masterSphere; 55 | } 56 | } 57 | 58 | double ccx = chunkX * 16 + 8; 59 | double ccz = chunkZ * 16 + 8; 60 | float f3 = 0.0F; 61 | float f4 = 0.0F; 62 | Random random = new Random(this.rand.nextLong()); 63 | 64 | if (l <= 0) 65 | { 66 | int flag = this.range * 16 - 16; 67 | l = flag - random.nextInt(flag / 4); 68 | } 69 | 70 | boolean var61 = false; 71 | 72 | if (k == -1) 73 | { 74 | k = l / 2; 75 | var61 = true; 76 | } 77 | 78 | int j1 = random.nextInt(l / 2) + l / 4; 79 | 80 | for (boolean flag1 = random.nextInt(6) == 0; k < l; ++k) 81 | { 82 | double d6 = 1.5D + MathHelper.sin(k * (float)Math.PI / l) * f * 1.0F; 83 | double d7 = d6 * d3; 84 | float f5 = MathHelper.cos(f2); 85 | float f6 = MathHelper.sin(f2); 86 | d += MathHelper.cos(f1) * f5; 87 | d1 += f6; 88 | d2 += MathHelper.sin(f1) * f5; 89 | 90 | if (flag1) 91 | { 92 | f2 *= 0.92F; 93 | } 94 | else 95 | { 96 | f2 *= 0.7F; 97 | } 98 | 99 | f2 += f4 * 0.1F; 100 | f1 += f3 * 0.1F; 101 | f4 *= 0.9F; 102 | f3 *= 0.75F; 103 | f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F; 104 | f3 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0F; 105 | 106 | if (!var61 && k == j1 && f > 1.0F) 107 | { 108 | this.a(chunkX, chunkZ, blocks, d, d1, d2, random.nextFloat() * 0.5F + 0.5F, f1 - ((float)Math.PI / 2F), 109 | f2 / 3.0F, k, l, 1.0D); 110 | this.a(chunkX, chunkZ, blocks, d, d1, d2, random.nextFloat() * 0.5F + 0.5F, f1 + ((float)Math.PI / 2F), 111 | f2 / 3.0F, k, l, 1.0D); 112 | return; 113 | } 114 | 115 | if (var61 || random.nextInt(4) != 0) 116 | { 117 | double d8 = d - ccx; 118 | double d9 = d2 - ccz; 119 | double d10 = l - k; 120 | double d11 = f + 2.0F + 16.0F; 121 | 122 | if (d8 * d8 + d9 * d9 - d10 * d10 > d11 * d11) { return; } 123 | 124 | if (d >= ccx - 16.0D - d6 * 2.0D && d2 >= ccz - 16.0D - d6 * 2.0D && d <= ccx + 16.0D + d6 * 2.0D 125 | && d2 <= ccz + 16.0D + d6 * 2.0D) 126 | { 127 | int k1 = MathHelper.truncateDoubleToInt(d - d6) - chunkX * 16 - 1; 128 | int l1 = MathHelper.truncateDoubleToInt(d + d6) - chunkX * 16 + 1; 129 | int i2 = MathHelper.truncateDoubleToInt(d1 - d7) - 1; 130 | int j2 = MathHelper.truncateDoubleToInt(d1 + d7) + 1; 131 | int k2 = MathHelper.truncateDoubleToInt(d2 - d6) - chunkZ * 16 - 1; 132 | int l2 = MathHelper.truncateDoubleToInt(d2 + d6) - chunkZ * 16 + 1; 133 | 134 | if (k1 < 0) 135 | { 136 | k1 = 0; 137 | } 138 | 139 | if (l1 > 16) 140 | { 141 | l1 = 16; 142 | } 143 | 144 | if (i2 < 1) 145 | { 146 | i2 = 1; 147 | } 148 | 149 | if (j2 > 120) 150 | { 151 | j2 = 120; 152 | } 153 | 154 | if (k2 < 0) 155 | { 156 | k2 = 0; 157 | } 158 | 159 | if (l2 > 16) 160 | { 161 | l2 = 16; 162 | } 163 | 164 | boolean flag2 = false; 165 | int j3; 166 | int l3; 167 | 168 | for (l3 = k1; !flag2 && l3 < l1; ++l3) 169 | { 170 | for (int d12 = k2; !flag2 && d12 < l2; ++d12) 171 | { 172 | for (int j4 = j2 + 1; !flag2 && j4 >= i2 - 1; --j4) 173 | { 174 | j3 = (l3 * 16 + d12) * chunkHeight + j4; 175 | 176 | if (j4 >= 0 && j4 < chunkHeight) 177 | { 178 | if (blocks[j3] == Blx.flowing_water || blocks[j3] == Blx.water 179 | || blocks[j3] == Blx.flowing_lava || blocks[j3] == Blx.lava) 180 | { 181 | flag2 = true; 182 | } 183 | 184 | if (j4 != i2 - 1 && l3 != k1 && l3 != l1 - 1 && d12 != k2 && d12 != l2 - 1) 185 | { 186 | j4 = i2; 187 | } 188 | } 189 | } 190 | } 191 | } 192 | 193 | if (!flag2) 194 | { 195 | for (l3 = k1; l3 < l1; ++l3) 196 | { 197 | double var62 = (l3 + chunkX * 16 + 0.5D - d) / d6; 198 | 199 | for (j3 = k2; j3 < l2; ++j3) 200 | { 201 | int midY = chunk.getChunkBoundSurfaceLevel(l3, j3); 202 | double d13 = (j3 + chunkZ * 16 + 0.5D - d2) / d6; 203 | int k4 = (l3 * 16 + j3) * chunkHeight + j2; 204 | 205 | for (int l4 = j2 - 1; l4 >= i2; --l4) 206 | { 207 | double d14 = (l4 + 0.5D - d1) / d7; 208 | 209 | if (d14 > -0.7D && var62 * var62 + d14 * d14 + d13 * d13 < 1.0D) 210 | { 211 | Block block = blocks[k4]; 212 | 213 | if (block == Blx.stone || block == Blx.sand || block == Blx.gravel 214 | || block == Blx.diamond_ore || block == Blx.lapis_ore 215 | || block == Blx.emerald_ore) 216 | { 217 | if (l4 < ModConsts.LAVA_LEVEL) 218 | { 219 | if (this.chunkProvider != null) 220 | { 221 | double d15 = sphere.getMainDistance( 222 | (int)Math.round(ccx + l3 - 8.0D), l4 - 1, (int)Math.round(ccz 223 | + j3 - 8.0D)); 224 | 225 | if (d15 >= sphere.scaledSphereRadius 226 | && d15 < (sphere.scaledSphereRadius + 5d)) 227 | 228 | { 229 | blocks[k4] = Blx.obsidian; 230 | } 231 | else if (d15 < sphere.scaledSphereRadius) 232 | { 233 | blocks[k4] = Blx.flowing_lava; 234 | } 235 | } 236 | else 237 | { 238 | blocks[k4] = Blx.flowing_lava; 239 | } 240 | } 241 | else if (l4 < midY - 2 || l4 > midY - 1) 242 | { 243 | blocks[k4] = Blx.air; 244 | } 245 | } 246 | } 247 | 248 | --k4; 249 | } 250 | } 251 | } 252 | 253 | if (var61) 254 | { 255 | break; 256 | } 257 | } 258 | } 259 | } 260 | } 261 | } 262 | 263 | /** 264 | * Recursively called by generate() (generate) and optionally by itself. 265 | */ 266 | protected void recursiveGenerate(World world, int chunkX, int chunkZ, int k, int l, Block[] blocks) 267 | { 268 | int i1 = this.rand.nextInt(this.rand.nextInt(this.rand.nextInt(10) + 1) + 1); 269 | 270 | if (this.rand.nextInt(5) != 0) 271 | { 272 | i1 = 0; 273 | } 274 | 275 | for (int j1 = 0; j1 < i1; ++j1) 276 | { 277 | double x = chunkX * 16 + this.rand.nextInt(16); 278 | double y = this.rand.nextInt(ModConsts.WORLD_HEIGHT); 279 | double z = chunkZ * 16 + this.rand.nextInt(16); 280 | int k1 = 1; 281 | 282 | if (this.rand.nextInt(4) == 0) 283 | { 284 | this.a(k, l, blocks, x, y, z); 285 | k1 += this.rand.nextInt(4); 286 | } 287 | 288 | for (int l1 = 0; l1 < k1; ++l1) 289 | { 290 | float f = this.rand.nextFloat() * (float)Math.PI * 2.0F; 291 | float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F; 292 | float f2 = this.rand.nextFloat() * 2.0F + this.rand.nextFloat(); 293 | this.a(k, l, blocks, x, y, z, f2 * 5.0F, f, f1, 0, 0, 0.5D); 294 | } 295 | } 296 | } 297 | } 298 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/BiosphereWorldProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod; 8 | 9 | import net.minecraft.block.Block; 10 | import net.minecraft.util.ChunkCoordinates; 11 | import net.minecraft.world.World; 12 | import net.minecraft.world.WorldProviderSurface; 13 | import newBiospheresMod.Configuration.ModConfig; 14 | import newBiospheresMod.Helpers.AvgCalc; 15 | import newBiospheresMod.Helpers.Blx; 16 | import newBiospheresMod.Helpers.ModConsts; 17 | import newBiospheresMod.Helpers.Utils; 18 | import newBiospheresMod.Models.Sphere; 19 | 20 | public class BiosphereWorldProvider extends WorldProviderSurface 21 | { 22 | private ModConfig config; 23 | 24 | @Override 25 | public ChunkCoordinates getRandomizedSpawnPoint() 26 | { 27 | ChunkCoordinates coords = super.getSpawnPoint(); 28 | 29 | FixSpawnLocation(coords); //, true); 30 | 31 | return coords; 32 | } 33 | 34 | @Override 35 | public ChunkCoordinates getSpawnPoint() 36 | { 37 | ChunkCoordinates coords = super.getSpawnPoint(); 38 | 39 | FixSpawnLocation(coords); //, false); 40 | 41 | return coords; 42 | } 43 | 44 | private boolean ValidSpawnLocation(ChunkCoordinates coords) 45 | { 46 | if (coords == null) { return true; } 47 | 48 | World world = this.worldObj; 49 | if (world == null) { return true; } 50 | 51 | int x = coords.posX; 52 | int z = coords.posZ; 53 | 54 | for (int y = 0; y < ModConsts.WORLD_HEIGHT; y++) 55 | { 56 | Block block = world.getBlock(x, y, z); 57 | if (block != Blx.air && !block.isAir(world, x, y, z)) 58 | { 59 | return true; 60 | } 61 | } 62 | 63 | // no solid ground at this location! 64 | return false; 65 | } 66 | 67 | private static final double searchGridSize = 2.5d; 68 | private static final double searchGridAngles = 12; 69 | private static final double toRadians = Math.PI / (searchGridAngles / 2); 70 | 71 | private static final AvgCalc avg = new AvgCalc(); 72 | private static long lastPrintedAt = Long.MIN_VALUE; 73 | 74 | public void FixSpawnLocation(ChunkCoordinates coords) 75 | { 76 | ChunkCoordinates orgCoords = Utils.GetCoords(coords); 77 | 78 | double angle = 0; 79 | double power = 1; 80 | 81 | while (!ValidSpawnLocation(coords)) 82 | { 83 | angle++; 84 | if (angle >= searchGridAngles) 85 | { 86 | angle -= searchGridAngles; 87 | power++; 88 | } 89 | 90 | if (power >= 50) 91 | { 92 | coords.posX = orgCoords.posX; 93 | coords.posZ = orgCoords.posZ; 94 | 95 | if (ModConsts.DEBUG) 96 | { 97 | System.out.println("WARNING: BIOSPHERE FIX SPAWN LOCATION FAILED!!"); 98 | } 99 | 100 | break; 101 | } 102 | 103 | double x = Math.cos(angle * toRadians) * (power * searchGridSize); 104 | double z = Math.sin(angle * toRadians) * (power * searchGridSize); 105 | 106 | coords.posX = orgCoords.posX + (int)Math.round(x); 107 | coords.posZ = orgCoords.posZ + (int)Math.round(z); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/BiosphereWorldType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod; 8 | 9 | import net.minecraft.world.World; 10 | import net.minecraft.world.WorldType; 11 | import net.minecraft.world.biome.BiomeGenBase; 12 | import net.minecraft.world.biome.WorldChunkManager; 13 | import net.minecraft.world.chunk.IChunkProvider; 14 | import newBiospheresMod.Configuration.CustomWorldData; 15 | import newBiospheresMod.Configuration.ModConfig; 16 | import newBiospheresMod.Helpers.Blx; 17 | import newBiospheresMod.Helpers.IKeyProvider; 18 | import newBiospheresMod.Helpers.LruCacheList; 19 | 20 | public class BiosphereWorldType extends WorldType 21 | { 22 | // #region Ownership Tracking 23 | 24 | private static final LruCacheList BiosphereWorlds = new LruCacheList(3, new IKeyProvider() 25 | { 26 | @Override 27 | public Object provideKey(World item) 28 | { 29 | return item; 30 | } 31 | }); 32 | 33 | public static final String IsBiosphereWorldKey = "IsBiosphereWorld"; 34 | 35 | public static boolean IsBiosphereWorld(World world) 36 | { 37 | if (world != null) 38 | { 39 | if (BiosphereWorlds.Contains(world)) { return true; } 40 | 41 | CustomWorldData data = CustomWorldData.FromWorld(world); 42 | if (data != null) 43 | { 44 | if (data.getBool(IsBiosphereWorldKey)) 45 | { 46 | EnsureWorldIsTracked(world); 47 | return true; 48 | } 49 | } 50 | } 51 | 52 | return false; 53 | } 54 | 55 | // #endregion 56 | 57 | public BiosphereWorldType(String s) 58 | { 59 | super(s); 60 | } 61 | 62 | @Override 63 | public WorldChunkManager getChunkManager(World world) 64 | { 65 | // TODO: FIND A WAY TO UNREGISTER THIS IF THE PLAYER LOADS ANOTHER WORLD. 66 | BiomeGenBase.hell.topBlock = BiomeGenBase.hell.fillerBlock = Blx.netherrack; 67 | BiomeGenBase.sky.topBlock = BiomeGenBase.sky.fillerBlock = Blx.end_stone; 68 | 69 | Blx.water.setLightOpacity(0); 70 | Blx.flowing_water.setLightOpacity(0); 71 | 72 | Blx.lava.setLightOpacity(0); 73 | Blx.flowing_lava.setLightOpacity(0); 74 | 75 | BiosphereWorlds.Push(world); 76 | return new BiosphereChunkManager(world); 77 | } 78 | 79 | @Override 80 | public IChunkProvider getChunkGenerator(World world, String params) 81 | { 82 | BiosphereWorlds.Push(world); 83 | return BiosphereChunkProvider.get(world); 84 | } 85 | 86 | @Override 87 | public boolean hasVoidParticles(boolean flag) 88 | { 89 | return false; 90 | } 91 | 92 | public int getSeaLevel(World world) 93 | { 94 | BiosphereWorlds.Push(world); 95 | return ModConfig.get(world).getSeaLevel() + 1; 96 | } 97 | 98 | @Override 99 | public double voidFadeMagnitude() 100 | { 101 | return 1.0D; 102 | } 103 | 104 | private static void EnsureWorldIsTracked(World world) 105 | { 106 | if (world != null) 107 | { 108 | BiosphereWorlds.Push(world); 109 | 110 | CustomWorldData data = CustomWorldData.FromWorld(world); 111 | if (data != null) 112 | { 113 | data.put(IsBiosphereWorldKey, true); 114 | } 115 | 116 | ModConfig.get(world).update(); 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/BlockData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod; 8 | 9 | import net.minecraft.block.*; 10 | import newBiospheresMod.Helpers.Blx; 11 | import newBiospheresMod.Helpers.Utils; 12 | 13 | public final class BlockData 14 | { 15 | // #region Static Utilities 16 | 17 | public static final BlockData Empty = new BlockData(null, 0); 18 | 19 | public static boolean IsNullOrEmpty(BlockData input) 20 | { 21 | return (input == null) ? true : input.IsEmpty(); 22 | } 23 | 24 | private static byte FixMetadata(int value) 25 | { 26 | // Detect Issues 27 | Utils.Assert(0 <= value && value < 16, "metadata out of range.", 1); 28 | 29 | // Clamp the Value 30 | return (byte)(value & 0x0F); 31 | } 32 | 33 | public static Block[] getBlockArray(BlockData[] input) 34 | { 35 | if (input == null) { return null; } 36 | 37 | Block[] output = new Block[input.length]; 38 | for (int i = 0; i < input.length; i++) 39 | { 40 | if (input[i] != null) 41 | { 42 | output[i] = input[i].Block; 43 | } 44 | } 45 | 46 | return output; 47 | } 48 | 49 | public static byte[] getMetadataArray(BlockData[] input) 50 | { 51 | if (input == null) { return null; } 52 | 53 | byte[] output = new byte[input.length]; 54 | for (int i = 0; i < input.length; i++) 55 | { 56 | if (input[i] != null) 57 | { 58 | output[i] = input[i].Metadata; 59 | } 60 | } 61 | 62 | return output; 63 | } 64 | 65 | // #endregion 66 | 67 | // #region Instance Data 68 | 69 | public final Block Block; 70 | public final byte Metadata; 71 | 72 | // #endregion 73 | 74 | // #region Properties 75 | 76 | public boolean IsEmpty() 77 | { 78 | return (this.Block == Blx.air || this.Block == null) && this.Metadata == 0; 79 | } 80 | 81 | // #endregion 82 | 83 | // #region Constructors 84 | 85 | public BlockData(Block block) 86 | { 87 | this(block, 0); 88 | } 89 | 90 | public BlockData(Block block, int metadata) 91 | { 92 | this(block, FixMetadata(metadata)); 93 | } 94 | 95 | public BlockData(Block block, byte metadata) 96 | { 97 | if (block == null) 98 | { 99 | block = Blx.air; 100 | } 101 | 102 | this.Block = block; 103 | this.Metadata = FixMetadata(metadata); 104 | } 105 | 106 | // #endregion 107 | 108 | // #region Methods 109 | 110 | public BlockData setBlock(Block block) 111 | { 112 | return new BlockData(block, this.Metadata); 113 | } 114 | 115 | public BlockData setMetadata(int metadata) 116 | { 117 | return new BlockData(this.Block, metadata); 118 | } 119 | 120 | // #endregion 121 | 122 | // #region ToString Support 123 | 124 | @Override 125 | public String toString() 126 | { 127 | return toString(this.Block, this.Metadata); 128 | } 129 | 130 | public static String toString(Block block, int metadata) 131 | { 132 | String ret = null; 133 | 134 | try 135 | { 136 | ret = net.minecraft.block.Block.blockRegistry.getNameForObject(block); 137 | } 138 | catch (Exception ignore) 139 | { /* do nothing */} 140 | 141 | if (ret == null || ret.length() < 1) 142 | { 143 | ret = Integer.toString(net.minecraft.block.Block.getIdFromBlock(block)); 144 | } 145 | 146 | if (ret != null && ret.toLowerCase().startsWith("minecraft:")) 147 | { 148 | ret = ret.substring(10); 149 | } 150 | 151 | metadata = FixMetadata(metadata); 152 | 153 | if (metadata != 0) 154 | { 155 | ret += ":" + metadata; 156 | } 157 | 158 | return ret; 159 | } 160 | 161 | @Override 162 | public int hashCode() 163 | { 164 | return toString().hashCode(); 165 | } 166 | 167 | // #endregion 168 | 169 | // #region Parse Support 170 | 171 | public static BlockData Parse(String value) 172 | { 173 | return Parse(value, BlockData.Empty); 174 | } 175 | 176 | public static BlockData Parse(String value, BlockData fallbackBlock) 177 | { 178 | Block block = net.minecraft.block.Block.getBlockFromName(value); 179 | 180 | if (block != null) 181 | { 182 | // Block was parsable, it does not contain metadata. 183 | return new BlockData(block, 0); 184 | } 185 | else 186 | { 187 | int sIndex = value.lastIndexOf(':'); 188 | if (sIndex >= 0) 189 | { 190 | try 191 | { 192 | String blockString = value.substring(0, sIndex); 193 | String metaString = value.substring(sIndex + 1); 194 | 195 | block = net.minecraft.block.Block.getBlockFromName(blockString); 196 | int metadata = Integer.parseInt(metaString); 197 | 198 | if (block != null) 199 | { 200 | return new BlockData(block, metadata); 201 | } 202 | } 203 | catch (Throwable ignore) 204 | { /* do nothing */ } 205 | } 206 | 207 | Utils.Assert(false, "Unable to parse BlockData: " + value, 1); 208 | return fallbackBlock; 209 | } 210 | } 211 | 212 | // #endregion 213 | } 214 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/BlockEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod; 8 | 9 | import net.minecraft.block.Block; 10 | import net.minecraft.util.WeightedRandom; 11 | import newBiospheresMod.Helpers.Blx; 12 | import newBiospheresMod.Helpers.Utils; 13 | 14 | public class BlockEntry extends WeightedRandom.Item 15 | { 16 | public final BlockData Block; 17 | 18 | public BlockEntry(Block block, int metadata, int weight) 19 | { 20 | this(new BlockData(block, metadata), weight); 21 | } 22 | 23 | public BlockEntry(BlockData block, int weight) 24 | { 25 | super(weight); 26 | 27 | if (block == null) 28 | { block = BlockData.Empty; } 29 | 30 | this.Block = block; 31 | } 32 | 33 | @Override 34 | public String toString() 35 | { 36 | return this.Block + ", " + this.itemWeight; 37 | } 38 | 39 | public static BlockEntry Parse(String input) 40 | { 41 | if (input != null && input.length() > 0) 42 | { 43 | try 44 | { 45 | int idx = input.lastIndexOf(","); 46 | 47 | String blockName = null; 48 | String weight = null; 49 | 50 | if (idx > 0) 51 | { 52 | blockName = input.substring(0, idx).trim(); 53 | weight = input.substring(idx + 1).trim(); 54 | } 55 | else 56 | { 57 | blockName = input; 58 | } 59 | 60 | if (blockName == null || blockName.length() < 1) 61 | { 62 | blockName = "air"; 63 | } 64 | 65 | if (weight == null || weight.length() < 1) 66 | { 67 | weight = "10"; 68 | } 69 | 70 | int iWeight = Integer.parseInt(weight); 71 | if (iWeight < 0) 72 | { 73 | iWeight = 0; 74 | } 75 | 76 | return new BlockEntry(BlockData.Parse(blockName), iWeight); 77 | } 78 | catch (Throwable ignore) 79 | { 80 | // do nothing 81 | } 82 | } 83 | 84 | return new BlockEntry(BlockData.Empty, 0); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Configuration/Categories.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Configuration; 8 | 9 | public class Categories 10 | { 11 | public static final String General = "general"; 12 | public static final String Biospheres = "biospheres"; 13 | public static final String OreOrbs = "oreorbs"; 14 | // public static final String OreOrbOreBlocks = "oreorboreblocks"; 15 | public static final String BiomeWeights = "biomeweights"; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Configuration/ConfigScreens.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Configuration; 8 | 9 | import net.minecraft.client.gui.GuiScreen; 10 | import net.minecraftforge.common.config.ConfigElement; 11 | 12 | public class ConfigScreens 13 | { 14 | public static class GeneralGuiConfigTab extends SimpleGuiConfigTab 15 | { 16 | private static final String Category = Categories.General; 17 | 18 | public GeneralGuiConfigTab(GuiScreen parent) 19 | { 20 | super(parent, Category); 21 | } 22 | 23 | public GeneralGuiConfigTab(GuiScreen parent, IGuiConfigTabProvider provider) 24 | { 25 | super(parent, provider, Category); 26 | } 27 | } 28 | 29 | public static class BiospheresGuiConfigTab extends SimpleGuiConfigTab 30 | { 31 | private static final String Category = Categories.Biospheres; 32 | 33 | public BiospheresGuiConfigTab(GuiScreen parent) 34 | { 35 | super(parent, Category); 36 | } 37 | 38 | public BiospheresGuiConfigTab(GuiScreen parent, IGuiConfigTabProvider provider) 39 | { 40 | super(parent, provider, Category); 41 | } 42 | } 43 | 44 | public static class OreOrbsGuiConfigTab extends SimpleGuiConfigTab 45 | { 46 | private static final String Category = Categories.OreOrbs; 47 | 48 | public OreOrbsGuiConfigTab(GuiScreen parent) 49 | { 50 | super(parent, Category); 51 | } 52 | 53 | public OreOrbsGuiConfigTab(GuiScreen parent, IGuiConfigTabProvider provider) 54 | { 55 | super(parent, provider, Category); 56 | } 57 | } 58 | 59 | // public static class OreOrbOreBlocksGuiConfigTab extends SimpleGuiConfigTab 60 | // { 61 | // private static final String Category = Categories.OreOrbOreBlocks; 62 | // 63 | // public OreOrbOreBlocksGuiConfigTab(GuiScreen parent) 64 | // { 65 | // super(parent, Category); 66 | // } 67 | // 68 | // public OreOrbOreBlocksGuiConfigTab(GuiScreen parent, IGuiConfigTabProvider provider) 69 | // { 70 | // super(parent, provider, Category); 71 | // } 72 | // } 73 | 74 | public static class BiomeWeightsGuiConfigTab extends SimpleGuiConfigTab 75 | { 76 | private static final String Category = Categories.BiomeWeights; 77 | 78 | public BiomeWeightsGuiConfigTab(GuiScreen parent) 79 | { 80 | super(parent, Category); 81 | } 82 | 83 | public BiomeWeightsGuiConfigTab(GuiScreen parent, IGuiConfigTabProvider provider) 84 | { 85 | super(parent, provider, Category); 86 | } 87 | } 88 | 89 | private static abstract class SimpleGuiConfigTab extends GuiConfigTab 90 | { 91 | public SimpleGuiConfigTab(GuiScreen parent, String category) 92 | { 93 | this(parent, ModGuiConfigTabProvider.SingletonInstance, category); 94 | } 95 | 96 | public SimpleGuiConfigTab(GuiScreen parent, IGuiConfigTabProvider provider, String category) 97 | { 98 | super(parent, provider, category, 99 | new ConfigElement(ModConfig.getConfigFile().getCategory(category)).getChildElements()); 100 | } 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Configuration/CustomWorldData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Configuration; 8 | 9 | import io.netty.util.internal.chmv8.ConcurrentHashMapV8; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import java.util.Map; 14 | import java.util.Set; 15 | 16 | import net.minecraft.block.Block; 17 | import net.minecraft.nbt.NBTTagCompound; 18 | import net.minecraft.world.World; 19 | import net.minecraft.world.WorldSavedData; 20 | import net.minecraft.world.storage.MapStorage; 21 | import newBiospheresMod.BlockData; 22 | import newBiospheresMod.Helpers.Blx; 23 | import newBiospheresMod.Helpers.ModConsts; 24 | import newBiospheresMod.Helpers.Utils; 25 | 26 | public class CustomWorldData extends WorldSavedData 27 | { 28 | public final String ContainerName; 29 | private final Map Data = new ConcurrentHashMapV8(); 30 | 31 | private boolean isNew = true; 32 | private boolean makeNotNewTriggered = false; 33 | 34 | public boolean getIsNew() 35 | { 36 | return isNew; 37 | } 38 | 39 | public void MakeNotNew() 40 | { 41 | makeNotNewTriggered = true; 42 | } 43 | 44 | public Set Keys() 45 | { 46 | return Data.keySet(); 47 | } 48 | 49 | public boolean ContainsKey(String keyName) 50 | { 51 | return Data.containsKey(keyName); 52 | } 53 | 54 | public void put(String keyName, String value) 55 | { 56 | String prevValue = Data.put(keyName, value); 57 | 58 | if (prevValue == null ? value != null : !prevValue.equals(value)) 59 | { 60 | markDirty(); 61 | } 62 | } 63 | 64 | public String get(String keyName) 65 | { 66 | if (ContainsKey(keyName)) { return Data.get(keyName); } 67 | 68 | return null; 69 | } 70 | 71 | public String RemoveKey(String keyName) 72 | { 73 | String returnValue = Data.remove(keyName); 74 | 75 | if (returnValue != null) 76 | { 77 | markDirty(); 78 | } 79 | 80 | return returnValue; 81 | } 82 | 83 | public CustomWorldData(String containerName) 84 | { 85 | super(containerName); 86 | this.ContainerName = containerName; 87 | } 88 | 89 | public static CustomWorldData FromWorld(World world) 90 | { 91 | return FromWorld(world, ModConsts.ModId.toLowerCase().replace(" ", "")); 92 | } 93 | 94 | public static CustomWorldData FromWorld(World world, String containerName) 95 | { 96 | // Retrieves the CustomWorldData instance for the given world, creating it if necessary 97 | MapStorage storage = world.mapStorage; 98 | CustomWorldData result = (CustomWorldData)storage.loadData(CustomWorldData.class, containerName); 99 | if (result == null) 100 | { 101 | result = new CustomWorldData(containerName); 102 | storage.setData(containerName, result); 103 | } 104 | else 105 | { 106 | // returned object is not new, it was loaded. 107 | result.MakeNotNew(); 108 | } 109 | 110 | return result; 111 | } 112 | 113 | private static List GetNbtTagKeys(NBTTagCompound nbtTag) 114 | { 115 | List keys = new ArrayList(); 116 | 117 | if (nbtTag != null) 118 | { 119 | for (Object _key: nbtTag.func_150296_c()) 120 | { 121 | String key = null; 122 | 123 | if (_key != null) 124 | { 125 | if (_key instanceof String) 126 | { 127 | key = (String)_key; 128 | } 129 | else 130 | { 131 | key = _key.toString(); 132 | } 133 | } 134 | 135 | if (key != null) 136 | { 137 | keys.add(key); 138 | } 139 | } 140 | } 141 | 142 | return keys; 143 | } 144 | 145 | @Override 146 | public void readFromNBT(NBTTagCompound nbtTag) 147 | { 148 | Data.clear(); 149 | 150 | if (nbtTag != null) 151 | { 152 | for (String key: GetNbtTagKeys(nbtTag)) 153 | { 154 | // System.out.println("LOADING: " + key); 155 | this.put(key, nbtTag.getString(key)); 156 | } 157 | } 158 | } 159 | 160 | @Override 161 | public void writeToNBT(NBTTagCompound nbtTag) 162 | { 163 | if (nbtTag != null) 164 | { 165 | for (String key: GetNbtTagKeys(nbtTag)) 166 | { 167 | nbtTag.removeTag(key); 168 | } 169 | 170 | for (String key: Keys()) 171 | { 172 | // System.out.println("SAVING: " + key); 173 | nbtTag.setString(key, Data.get(key)); 174 | } 175 | 176 | if (makeNotNewTriggered) 177 | { 178 | isNew = false; 179 | makeNotNewTriggered = false; 180 | } 181 | } 182 | } 183 | 184 | public void put(String key, boolean value) 185 | { 186 | put(key, Boolean.toString(value)); 187 | } 188 | 189 | public void put(String key, int value) 190 | { 191 | put(key, Integer.toString(value)); 192 | } 193 | 194 | public void put(String key, float value) 195 | { 196 | put(key, Float.toString(value)); 197 | } 198 | 199 | public void put(String key, double value) 200 | { 201 | put(key, Double.toString(value)); 202 | } 203 | 204 | public void put(String key, BlockData value) 205 | { 206 | put(key, value.toString()); 207 | } 208 | 209 | public boolean getBool(String key) 210 | { 211 | return getBool(key, false); 212 | } 213 | 214 | public boolean getBool(String key, boolean defaultValue) 215 | { 216 | if (ContainsKey(key)) 217 | { 218 | try 219 | { 220 | return Boolean.parseBoolean(get(key)); 221 | } 222 | catch (Throwable ignore) 223 | { /* do nothing */} 224 | } 225 | 226 | return defaultValue; 227 | } 228 | 229 | public int getInt(String key) 230 | { 231 | return getInt(key, 0); 232 | } 233 | 234 | public int getInt(String key, int defaultValue) 235 | { 236 | if (ContainsKey(key)) 237 | { 238 | try 239 | { 240 | return Integer.parseInt(get(key)); 241 | } 242 | catch (Throwable ignore) 243 | { /* do nothing */} 244 | } 245 | 246 | return defaultValue; 247 | } 248 | 249 | public double getDouble(String key) 250 | { 251 | return getDouble(key, 0); 252 | } 253 | 254 | public double getDouble(String key, double defaultValue) 255 | { 256 | if (ContainsKey(key)) 257 | { 258 | try 259 | { 260 | return Double.parseDouble(get(key)); 261 | } 262 | catch (Throwable ignore) 263 | { /* do nothing */} 264 | } 265 | 266 | return defaultValue; 267 | } 268 | 269 | public float getFloat(String key) 270 | { 271 | return getFloat(key, 0); 272 | } 273 | 274 | public float getFloat(String key, float defaultValue) 275 | { 276 | if (ContainsKey(key)) 277 | { 278 | try 279 | { 280 | return Float.parseFloat(get(key)); 281 | } 282 | catch (Throwable ignore) 283 | { /* do nothing */} 284 | } 285 | 286 | return defaultValue; 287 | } 288 | 289 | public BlockData getBlock(String key) 290 | { 291 | return getBlock(key, BlockData.Empty); 292 | } 293 | 294 | public BlockData getBlock(String key, BlockData defaultValue) 295 | { 296 | if (ContainsKey(key)) 297 | { 298 | try 299 | { 300 | return BlockData.Parse(get(key), defaultValue); 301 | } 302 | catch (Throwable ignore) 303 | { /* do nothing */} 304 | } 305 | 306 | return defaultValue; 307 | } 308 | 309 | } 310 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Configuration/GuiConfigTab.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Configuration; 8 | 9 | import java.util.HashMap; 10 | import java.util.List; 11 | import java.util.Map; 12 | import java.util.Random; 13 | 14 | import net.minecraft.client.gui.GuiButton; 15 | import net.minecraft.client.gui.GuiScreen; 16 | import newBiospheresMod.Helpers.ModConsts; 17 | import cpw.mods.fml.client.config.GuiConfig; 18 | import cpw.mods.fml.client.config.IConfigElement; 19 | 20 | public class GuiConfigTab extends GuiConfig 21 | { 22 | private static final Random Rnd = new Random(System.currentTimeMillis()); 23 | 24 | private final IGuiConfigTabProvider Provider; 25 | private final String Category; 26 | private Map TabMap; 27 | 28 | public GuiConfigTab(GuiScreen parent, IGuiConfigTabProvider provider, String category, 29 | List childElements) 30 | { 31 | super( 32 | parent, 33 | childElements, 34 | ModConsts.ModId, provider.getAllRequireWorldRestart(), provider.getAllRequireMcRestart(), 35 | provider.getTitle()); 36 | 37 | this.Provider = provider; 38 | this.Category = category; 39 | } 40 | 41 | private int getUniqueButtonId() 42 | { 43 | int id = 0; 44 | boolean keepTrying = true; 45 | while (keepTrying) 46 | { 47 | id = 600000 + Math.abs(Rnd.nextInt(400000)); 48 | keepTrying = false; 49 | 50 | if (this.buttonList != null) 51 | { 52 | for (Object btn: this.buttonList) 53 | { 54 | if (btn != null && btn instanceof GuiButton) 55 | { 56 | if (((GuiButton)btn).id == id) 57 | { 58 | keepTrying = true; 59 | break; 60 | } 61 | } 62 | } 63 | } 64 | } 65 | return id; 66 | } 67 | 68 | @Override 69 | public void initGui() 70 | { 71 | if (TabMap != null) 72 | { 73 | this.buttonList.removeAll(TabMap.keySet()); 74 | TabMap.clear(); 75 | } 76 | else 77 | { 78 | TabMap = new HashMap(); 79 | } 80 | 81 | int x = 8; 82 | int y = 27; 83 | int height = 16; 84 | 85 | for (GuiConfigTabEntry tab: Provider.getTabs()) 86 | { 87 | String text = tab.Title; 88 | int width = this.fontRendererObj.getStringWidth(text) + 16; 89 | 90 | GuiButton button = new GuiButton(getUniqueButtonId(), x, y, width, height, text); 91 | if (tab.Category.equals(this.Category)) 92 | { 93 | button.packedFGColour = 255 << 8; 94 | } 95 | 96 | this.TabMap.put(button, tab); 97 | this.buttonList.add(button); 98 | 99 | x += (width + 8); 100 | } 101 | 102 | super.initGui(); 103 | this.entryList.top = y + height; 104 | } 105 | 106 | @Override 107 | protected void actionPerformed(GuiButton guiButton) 108 | { 109 | super.actionPerformed(guiButton); 110 | 111 | if (guiButton != null) 112 | { 113 | if (TabMap.containsKey(guiButton)) 114 | { 115 | NavigateTo(TabMap.get(guiButton)); 116 | } 117 | } 118 | } 119 | 120 | public void NavigateTo(GuiConfigTabEntry entry) 121 | { 122 | if (entry != null && this.Provider != null) 123 | { 124 | if (!entry.Category.equals(this.Category)) 125 | { 126 | this.entryList.saveConfigElements(); 127 | mc.displayGuiScreen(entry.getScreen.func(this.parentScreen, this.Provider)); 128 | } 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Configuration/GuiConfigTabEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Configuration; 8 | 9 | import net.minecraft.client.gui.GuiScreen; 10 | import newBiospheresMod.Helpers.Func2; 11 | 12 | public class GuiConfigTabEntry 13 | { 14 | public final String Category; 15 | public final String Title; 16 | 17 | public final Func2 getScreen; 18 | 19 | public GuiConfigTabEntry(String category, String title, Func2 getScreen) 20 | { 21 | this.Category = category; 22 | this.Title = title; 23 | this.getScreen = getScreen; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Configuration/IGuiConfigTabProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Configuration; 8 | 9 | public interface IGuiConfigTabProvider 10 | { 11 | String getTitle(); 12 | 13 | boolean getAllRequireWorldRestart(); 14 | 15 | boolean getAllRequireMcRestart(); 16 | 17 | Iterable getTabs(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Configuration/ModConfigGuiFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Configuration; 8 | 9 | import java.util.Set; 10 | 11 | import net.minecraft.client.Minecraft; 12 | import net.minecraft.client.gui.GuiScreen; 13 | import cpw.mods.fml.client.IModGuiFactory; 14 | 15 | public class ModConfigGuiFactory implements IModGuiFactory 16 | { 17 | @Override 18 | public void initialize(Minecraft minecraftInstance) 19 | { 20 | /* do nothing */ 21 | } 22 | 23 | @Override 24 | public Class mainConfigGuiClass() 25 | { 26 | return ConfigScreens.GeneralGuiConfigTab.class; 27 | } 28 | 29 | @Override 30 | public Set runtimeGuiCategories() 31 | { 32 | return null; 33 | } 34 | 35 | @Override 36 | public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) 37 | { 38 | return null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Configuration/ModGuiConfigTabProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Configuration; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | import net.minecraft.client.gui.GuiScreen; 13 | import newBiospheresMod.Helpers.Func2; 14 | import newBiospheresMod.Helpers.ModConsts; 15 | 16 | public class ModGuiConfigTabProvider implements IGuiConfigTabProvider 17 | { 18 | public static final ModGuiConfigTabProvider SingletonInstance = new ModGuiConfigTabProvider(); 19 | 20 | private ModGuiConfigTabProvider() 21 | { 22 | // hidden 23 | } 24 | 25 | @Override 26 | public String getTitle() 27 | { 28 | return ModConsts.ModId; 29 | } 30 | 31 | @Override 32 | public boolean getAllRequireWorldRestart() 33 | { 34 | return false; 35 | } 36 | 37 | @Override 38 | public boolean getAllRequireMcRestart() 39 | { 40 | return false; 41 | } 42 | 43 | @Override 44 | public Iterable getTabs() 45 | { 46 | List tabs = new ArrayList(); 47 | 48 | tabs.add(new GuiConfigTabEntry(Categories.General, "General", 49 | new Func2() 50 | { 51 | @Override 52 | public GuiScreen func(GuiScreen parent, IGuiConfigTabProvider provider) 53 | { 54 | return new ConfigScreens.GeneralGuiConfigTab(parent, provider); 55 | } 56 | })); 57 | 58 | tabs.add(new GuiConfigTabEntry(Categories.Biospheres, "Biospheres", 59 | new Func2() 60 | { 61 | @Override 62 | public GuiScreen func(GuiScreen parent, IGuiConfigTabProvider provider) 63 | { 64 | return new ConfigScreens.BiospheresGuiConfigTab(parent, provider); 65 | } 66 | })); 67 | 68 | tabs.add(new GuiConfigTabEntry(Categories.OreOrbs, "Ore Orbs", 69 | new Func2() 70 | { 71 | @Override 72 | public GuiScreen func(GuiScreen parent, IGuiConfigTabProvider provider) 73 | { 74 | return new ConfigScreens.OreOrbsGuiConfigTab(parent, provider); 75 | } 76 | })); 77 | 78 | // tabs.add(new GuiConfigTabEntry(Categories.OreOrbOreBlocks, "Ore Orbs 2", 79 | // new Func2() 80 | // { 81 | // @Override 82 | // public GuiScreen func(GuiScreen parent, IGuiConfigTabProvider provider) 83 | // { 84 | // return new ConfigScreens.OreOrbOreBlocksGuiConfigTab(parent, provider); 85 | // } 86 | // })); 87 | 88 | tabs.add(new GuiConfigTabEntry(Categories.BiomeWeights, "Biomes", 89 | new Func2() 90 | { 91 | @Override 92 | public GuiScreen func(GuiScreen parent, IGuiConfigTabProvider provider) 93 | { 94 | return new ConfigScreens.BiomeWeightsGuiConfigTab(parent, provider); 95 | } 96 | })); 97 | 98 | return tabs; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Helpers/AvgCalc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Helpers; 8 | 9 | public class AvgCalc 10 | { 11 | private double average = 0d; 12 | private double count = 0d; 13 | 14 | public int getCount() 15 | { 16 | return (int)count; 17 | } 18 | 19 | public double getAverage() 20 | { 21 | return average; 22 | } 23 | 24 | public void addValue(double amount) 25 | { 26 | double newAverage = average * count; 27 | average = (newAverage + amount) / (++count); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Helpers/Creator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Helpers; 8 | 9 | public abstract class Creator 10 | { 11 | public abstract T create(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Helpers/Func.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Helpers; 8 | 9 | public abstract class Func 10 | { 11 | public abstract Toutput func(Tinput value); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Helpers/Func2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Helpers; 8 | 9 | public abstract class Func2 10 | { 11 | public abstract Toutput func(Tinput1 value1, Tinput2 value2); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Helpers/IKeyProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Helpers; 8 | 9 | public interface IKeyProvider 10 | { 11 | Object provideKey(T item); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Helpers/LruCacheList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Helpers; 8 | 9 | import java.util.concurrent.ConcurrentMap; 10 | 11 | import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap; 12 | 13 | public class LruCacheList 14 | { 15 | // apparently this library doesn't like using "null" as a key, which is stupid. So, let's use this random object 16 | // instead. 17 | private static final Object nullKeySubstitute = new Object(); 18 | 19 | public final int TotalItems; 20 | public final IKeyProvider KeyProvider; 21 | 22 | private final ConcurrentMap _backingMap; 23 | 24 | public LruCacheList(int totalItems, IKeyProvider keyProvider) 25 | { 26 | this.TotalItems = totalItems; 27 | this.KeyProvider = keyProvider; 28 | 29 | _backingMap = new ConcurrentLinkedHashMap.Builder().maximumWeightedCapacity(totalItems).build(); 30 | } 31 | 32 | public void Push(T item) 33 | { 34 | Object key = KeyProvider.provideKey(item); 35 | if (key == null) key = nullKeySubstitute; 36 | 37 | _backingMap.put(key, item); 38 | } 39 | 40 | public boolean Contains(T item) 41 | { 42 | Object key = KeyProvider.provideKey(item); 43 | if (key == null) key = nullKeySubstitute; 44 | 45 | return _backingMap.containsKey(key); 46 | } 47 | 48 | public T FindOrAdd(Object key, Creator factory) 49 | { 50 | if (key == null) key = nullKeySubstitute; 51 | 52 | T returnValue = _backingMap.get(key); 53 | if (returnValue == null) 54 | { 55 | try 56 | { 57 | returnValue = factory.create(); 58 | } 59 | catch (Throwable ignore) 60 | { 61 | // do nothing 62 | } 63 | 64 | if (returnValue != null) 65 | { 66 | _backingMap.put(key, returnValue); 67 | } 68 | } 69 | 70 | return returnValue; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Helpers/ModConsts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Helpers; 8 | 9 | public class ModConsts 10 | { 11 | public static final String OldModId = "New Biospheres Mod"; 12 | public static final String ModId = "NewBiospheresMod"; 13 | public static final String ModVersion = "0.85"; 14 | 15 | public static final int WORLD_HEIGHT = 256; 16 | 17 | public static final int WORLD_MAX_Y = WORLD_HEIGHT - 1; 18 | public static final int WORLD_MIN_Y = 0; 19 | 20 | public static final int LAVA_LEVEL = 50; 21 | 22 | public static final boolean DEBUG = false; 23 | 24 | public static int GetChunkArraySize() 25 | { 26 | return 16 * WORLD_HEIGHT * 16; 27 | } 28 | 29 | public static int GetChunkArrayIndex(int x, int y, int z) 30 | { 31 | return (x * WORLD_HEIGHT * 16) + (z * WORLD_HEIGHT) + y; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Helpers/Predicate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Helpers; 8 | 9 | public abstract class Predicate 10 | { 11 | public abstract boolean test(T value); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Helpers/TopDownBoundingBox.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Helpers; 8 | 9 | import net.minecraft.util.ChunkCoordinates; 10 | 11 | public class TopDownBoundingBox 12 | { 13 | public final int x1, z1, x2, z2; 14 | 15 | public TopDownBoundingBox(int x1, int z1, int x2, int z2) 16 | { 17 | this.x1 = x1; 18 | this.z1 = z1; 19 | this.x2 = x2; 20 | this.z2 = z2; 21 | } 22 | 23 | public static TopDownBoundingBox FromChunk(int chunkX, int chunkZ) 24 | { 25 | chunkX <<= 4; 26 | chunkZ <<= 4; 27 | 28 | return new TopDownBoundingBox(chunkX, chunkZ, chunkX + 15, chunkZ + 15); 29 | } 30 | 31 | public static TopDownBoundingBox FromCircle(int cx, int cz, int r) 32 | { 33 | return new TopDownBoundingBox(cx - r, cz - r, cx + r, cz + r); 34 | } 35 | 36 | public static TopDownBoundingBox FromArray(Iterable coords) 37 | { 38 | if (coords != null) 39 | { 40 | boolean first = true; 41 | int minX, minZ, maxX, maxZ; 42 | minX = minZ = maxX = maxZ = 0; 43 | 44 | for (ChunkCoordinates coord: coords) 45 | { 46 | if (coord != null) 47 | { 48 | if (first) 49 | { 50 | minX = maxX = coord.posX; 51 | minZ = maxZ = coord.posZ; 52 | first = false; 53 | } 54 | else 55 | { 56 | if (coord.posX < minX) 57 | { 58 | minX = coord.posX; 59 | } 60 | if (coord.posX > maxX) 61 | { 62 | maxX = coord.posX; 63 | } 64 | if (coord.posZ < minZ) 65 | { 66 | minZ = coord.posZ; 67 | } 68 | if (coord.posZ > maxZ) 69 | { 70 | maxZ = coord.posZ; 71 | } 72 | } 73 | } 74 | } 75 | 76 | if (!first) { return new TopDownBoundingBox(minX, minZ, maxX, maxZ); } 77 | } 78 | 79 | return null; 80 | } 81 | 82 | public boolean CollidesWith(TopDownBoundingBox box) 83 | { 84 | if (box == this) { return true; } 85 | if (box == null) { return false; } 86 | 87 | if (this.x2 < box.x1) { return false; } 88 | if (this.z2 < box.z1) { return false; } 89 | if (this.x1 > box.x2) { return false; } 90 | if (this.z1 > box.z2) { return false; } 91 | 92 | return true; 93 | } 94 | 95 | public boolean CollidesWith(int x, int z) 96 | { 97 | if (x < this.x1) { return false; } 98 | if (z < this.z1) { return false; } 99 | if (x > this.x2) { return false; } 100 | if (z > this.z2) { return false; } 101 | 102 | return true; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Helpers/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Helpers; 8 | 9 | import java.lang.reflect.Field; 10 | import java.util.*; 11 | 12 | import net.minecraft.block.*; 13 | import net.minecraft.entity.Entity; 14 | import net.minecraft.entity.player.EntityPlayer; 15 | import net.minecraft.util.ChunkCoordinates; 16 | import net.minecraft.world.*; 17 | import net.minecraft.world.storage.*; 18 | import newBiospheresMod.BlockData; 19 | 20 | public class Utils 21 | { 22 | public static void Assert(boolean test) 23 | { 24 | Assert(test, null, false, 0); 25 | } 26 | 27 | public static void Assert(boolean test, String failMessage) 28 | { 29 | Assert(test, failMessage, false, 0); 30 | } 31 | 32 | public static void Assert(boolean test, String failMessage, boolean shouldExplode) 33 | { 34 | Assert(test, failMessage, shouldExplode, 0); 35 | } 36 | 37 | public static void Assert(boolean test, int callerOffset) 38 | { 39 | Assert(test, null, false, callerOffset); 40 | } 41 | 42 | public static void Assert(boolean test, String failMessage, int callerOffset) 43 | { 44 | Assert(test, failMessage, false, callerOffset); 45 | } 46 | 47 | public static void Assert(boolean test, String failMessage, boolean shouldExplode, int callerOffset) 48 | { 49 | if (!test) 50 | { 51 | // Assert Failed at this point, not too worried about performance 52 | 53 | StackTraceElement[] stack = Thread.currentThread().getStackTrace(); 54 | StackTraceElement caller = null; 55 | 56 | int callerIdx; 57 | for (callerIdx = 1; callerIdx < stack.length; callerIdx++) 58 | { 59 | caller = stack[callerIdx]; 60 | if (caller.getMethodName() != "Assert") { break; } 61 | } 62 | 63 | if (callerOffset != 0) 64 | { 65 | caller = stack[callerIdx + callerOffset]; 66 | } 67 | 68 | StringBuilder sb = new StringBuilder(); 69 | sb.append(ModConsts.ModId); 70 | sb.append("("); 71 | sb.append(ModConsts.ModVersion); 72 | sb.append(") ASSERT FAILED! @ "); 73 | sb.append(caller.getClassName()); 74 | sb.append("::"); 75 | sb.append(caller.getMethodName()); 76 | sb.append(" (Line: "); 77 | sb.append(caller.getLineNumber()); 78 | sb.append(")"); 79 | 80 | if (failMessage != null && failMessage.length() > 0) 81 | { 82 | sb.append(": "); 83 | sb.append(failMessage); 84 | } 85 | 86 | String err = sb.toString(); 87 | System.out.println(err); 88 | if (shouldExplode) { throw new Error(err); } 89 | } 90 | } 91 | 92 | public static String GetName(Object obj) 93 | { 94 | if (obj == null) { return "(null)"; } 95 | 96 | if (obj instanceof BlockData) { return ((BlockData)obj).toString(); } 97 | if (obj instanceof Block) { return BlockData.toString((Block)obj, 0); } 98 | 99 | String name = obj.getClass().getSimpleName(); 100 | if (name == null || name.length() < 1) 101 | { 102 | name = obj.getClass().getName(); 103 | } 104 | 105 | return name; 106 | } 107 | 108 | public static boolean IsPlayer(Entity e) 109 | { 110 | if (e == null) { return false; } 111 | 112 | if (e instanceof EntityPlayer) { return true; } 113 | 114 | // NOTE: This works, but I'm guessing it won't work on the obfuscated code, so, whatever. 115 | // if (e instanceof EntityLivingBase) 116 | // { 117 | // Class c = e.getClass(); 118 | // 119 | // while (c != null) 120 | // { 121 | // try 122 | // { 123 | // java.lang.reflect.Method m = c.getDeclaredMethod("isPlayer"); 124 | // m.setAccessible(true); 125 | // 126 | // boolean result = ((Boolean)m.invoke(e)).booleanValue(); 127 | // return result; 128 | // } 129 | // catch (Throwable ignore) 130 | // { 131 | // c = c.getSuperclass(); 132 | // } 133 | // } 134 | // } 135 | 136 | return false; 137 | } 138 | 139 | public static GameRules GetGameRules(World world) 140 | { 141 | if (world != null) 142 | { 143 | WorldInfo info = world.getWorldInfo(); 144 | if (info != null) { return info.getGameRulesInstance(); } 145 | } 146 | return null; 147 | } 148 | 149 | public static ChunkCoordinates GetCoords(ChunkCoordinates copyMe) 150 | { 151 | if (copyMe == null) { return GetCoords(0, 0, 0); } 152 | return GetCoords(copyMe.posX, copyMe.posY, copyMe.posZ); 153 | } 154 | 155 | public static ChunkCoordinates GetCoords(Entity e) 156 | { 157 | if (e == null) { return GetCoords(0, 0, 0); } 158 | return GetCoords(e.posX, e.posY, e.posZ); 159 | } 160 | 161 | public static ChunkCoordinates GetCoords(double x, double y, double z) 162 | { 163 | return GetCoords((int)Math.round(x), (int)Math.round(y), (int)Math.round(z)); 164 | } 165 | 166 | public static ChunkCoordinates GetCoords(int x, int y, int z) 167 | { 168 | ChunkCoordinates coords = new ChunkCoordinates(); 169 | coords.posX = x; 170 | coords.posY = y; 171 | coords.posZ = z; 172 | 173 | return coords; 174 | } 175 | 176 | public static boolean FuzzyEquals(String a, String b) 177 | { 178 | if (a == b) { return true; } 179 | if (a == null) 180 | { 181 | a = ""; 182 | } 183 | if (b == null) 184 | { 185 | b = ""; 186 | } 187 | 188 | a = a.trim(); 189 | b = b.trim(); 190 | 191 | return a.equalsIgnoreCase(b); 192 | } 193 | 194 | public static > T ParseEnum(Class _class, String input) 195 | { 196 | return ParseEnum(_class, input, null); 197 | } 198 | 199 | @SuppressWarnings("unchecked") 200 | public static > T ParseEnum(Class _class, String input, T fallbackValue) 201 | { 202 | if (input != null && input.length() > 0) 203 | { 204 | 205 | for (Field f: _class.getDeclaredFields()) 206 | { 207 | try 208 | { 209 | if (f.isEnumConstant()) 210 | { 211 | if (FuzzyEquals(f.getName(), input)) { return (T)f.get(null); } 212 | } 213 | } 214 | catch (Throwable ignoreMe) 215 | { /* do nothing */} 216 | } 217 | } 218 | 219 | return fallbackValue; 220 | } 221 | 222 | public static int RndBetween(Random rnd, int low, int high) 223 | { 224 | double range = high - low; 225 | range *= rnd.nextDouble(); 226 | range += low; 227 | range = Math.round(range); 228 | if (range < low) 229 | { 230 | range = low; 231 | } 232 | if (range > high) 233 | { 234 | range = high; 235 | } 236 | 237 | return (int)range; 238 | } 239 | 240 | public static void DoLine(int x0, int y0, int x1, int y1, Func2 func) 241 | { 242 | if (func != null) 243 | { 244 | int dx = Math.abs(x1 - x0); 245 | int dy = Math.abs(y1 - y0); 246 | 247 | int sx = x0 < x1 ? 1 : -1; 248 | int sy = y0 < y1 ? 1 : -1; 249 | 250 | int err = dx - dy; 251 | int e2; 252 | 253 | while (true) 254 | { 255 | try 256 | { 257 | if (!func.func(x0, y0)) 258 | { 259 | break; 260 | } 261 | } 262 | catch (Throwable ignore) 263 | { 264 | break; 265 | } 266 | 267 | if (x0 == x1 && y0 == y1) break; 268 | 269 | e2 = 2 * err; 270 | if (e2 > -dy) 271 | { 272 | err = err - dy; 273 | x0 = x0 + sx; 274 | } 275 | 276 | if (e2 < dx) 277 | { 278 | err = err + dx; 279 | y0 = y0 + sy; 280 | } 281 | } 282 | } 283 | } 284 | 285 | // #region LINQ-like helpers 286 | 287 | public static ArrayList ToList(final Iterable input) 288 | { 289 | ArrayList output = new ArrayList(); 290 | if (input != null) 291 | { 292 | for (T item: input) 293 | { 294 | output.add(item); 295 | } 296 | } 297 | 298 | return output; 299 | } 300 | 301 | public static Iterable ToIterable(final T[] input) 302 | { 303 | return new Iterable() 304 | { 305 | @Override 306 | public Iterator iterator() 307 | { 308 | return new Iterator() 309 | { 310 | private int idx = 0; 311 | 312 | @Override 313 | public boolean hasNext() 314 | { 315 | return (input != null && idx < input.length); 316 | } 317 | 318 | @Override 319 | public T next() 320 | { 321 | if (hasNext()) 322 | { 323 | return input[idx++]; 324 | } 325 | 326 | return null; 327 | } 328 | 329 | @Override 330 | public void remove() 331 | { 332 | throw new UnsupportedOperationException("remove not supported"); 333 | } 334 | }; 335 | } 336 | 337 | }; 338 | } 339 | 340 | public static double Average(final Iterable input, final Func func) 341 | { 342 | double output = 0; 343 | double count = 0; 344 | 345 | if (input != null && func != null) 346 | { 347 | for(T item: input) 348 | { 349 | if (item != null) 350 | { 351 | output += func.func(item); 352 | count++; 353 | } 354 | } 355 | } 356 | 357 | return (output / count); 358 | } 359 | 360 | public static double SumDouble(final Iterable input, final Func func) 361 | { 362 | double output = 0; 363 | 364 | if (input != null && func != null) 365 | { 366 | for(T item: input) 367 | { 368 | if (item != null) 369 | { 370 | output += func.func(item); 371 | } 372 | } 373 | } 374 | 375 | return output; 376 | } 377 | 378 | public static Integer SumInt(final Iterable input, final Func func) 379 | { 380 | int output = 0; 381 | 382 | if (input != null && func != null) 383 | { 384 | for(T item: input) 385 | { 386 | if (item != null) 387 | { 388 | output += func.func(item); 389 | } 390 | } 391 | } 392 | 393 | return output; 394 | } 395 | 396 | public static Iterable Where(final Iterable input, final Predicate predicate) 397 | { 398 | if (predicate == null && input != null) { return input; } 399 | if (input == null) { return new ArrayList(); } // empty collection 400 | 401 | final Iterator inner = input.iterator(); 402 | if (inner == null) { return new ArrayList(); } // empty collection 403 | 404 | return new Iterable() 405 | { 406 | @Override 407 | public Iterator iterator() 408 | { 409 | return new Iterator() 410 | { 411 | private boolean hasItem = false; 412 | private T _next = null; 413 | 414 | private T GetNext() 415 | { 416 | while (!hasItem && inner.hasNext()) 417 | { 418 | T item = inner.next(); 419 | if (predicate.test(item)) 420 | { 421 | _next = item; 422 | hasItem = true; 423 | } 424 | } 425 | 426 | if (!hasItem) 427 | { 428 | _next = null; 429 | return null; 430 | } 431 | 432 | return _next; 433 | } 434 | 435 | @Override 436 | public boolean hasNext() 437 | { 438 | GetNext(); 439 | return hasItem; 440 | } 441 | 442 | @Override 443 | public T next() 444 | { 445 | T next = GetNext(); 446 | hasItem = false; 447 | return next; 448 | } 449 | 450 | @Override 451 | public void remove() 452 | { 453 | throw new UnsupportedOperationException("remove not supported"); 454 | } 455 | 456 | }; 457 | } 458 | 459 | }; 460 | } 461 | 462 | public static Predicate NotNull() 463 | { 464 | return new Predicate() 465 | { 466 | @Override 467 | public boolean test(T value) 468 | { 469 | return value != null; 470 | } 471 | }; 472 | } 473 | 474 | public static Predicate NotNull(Class clazz) 475 | { 476 | // Man, the Java type system is a fucking nightmare. 477 | 478 | return new Predicate() 479 | { 480 | @Override 481 | public boolean test(T value) 482 | { 483 | return value != null; 484 | } 485 | }; 486 | } 487 | 488 | private static ArrayList> FilterPredicates(Predicate ... _clauses) 489 | { 490 | ArrayList> clauses = new ArrayList>(); 491 | 492 | if (_clauses != null && _clauses.length > 0) 493 | { 494 | // Pre-Filter the nulls, quickly 495 | 496 | for(Predicate clause: _clauses) 497 | { 498 | if (clause != null) 499 | { 500 | clauses.add(clause); 501 | } 502 | } 503 | } 504 | 505 | return clauses; 506 | } 507 | 508 | public static Predicate And(Predicate ... _clauses) 509 | { 510 | final ArrayList> clauses = FilterPredicates(_clauses); 511 | if (clauses.size() < 1) { return null; } 512 | if (clauses.size() == 1) { return clauses.get(0); } 513 | 514 | return new Predicate() 515 | { 516 | @Override 517 | public boolean test(T value) 518 | { 519 | for(Predicate clause: clauses) 520 | { 521 | if (!clause.test(value)) { return false; } 522 | } 523 | 524 | return true; 525 | } 526 | }; 527 | } 528 | 529 | public static Predicate Or(Predicate ... _clauses) 530 | { 531 | final ArrayList> clauses = FilterPredicates(_clauses); 532 | if (clauses.size() < 1) { return null; } 533 | if (clauses.size() == 1) { return clauses.get(0); } 534 | 535 | return new Predicate() 536 | { 537 | @Override 538 | public boolean test(T value) 539 | { 540 | for(Predicate clause: clauses) 541 | { 542 | if (clause.test(value)) { return true; } 543 | } 544 | 545 | return false; 546 | } 547 | }; 548 | } 549 | 550 | @SuppressWarnings("unused") 551 | public static boolean Any(final Iterable input) 552 | { 553 | if (input != null) 554 | { 555 | for (T obj: input) 556 | { 557 | return true; 558 | } 559 | } 560 | 561 | return false; 562 | } 563 | 564 | public static double Min(final double[] input) 565 | { 566 | if (input == null || input.length < 1) { return 0; } 567 | 568 | double output = input[0]; 569 | for (int i = 1; i < input.length; i++) 570 | { 571 | if (input[i] < output) 572 | { 573 | output = input[i]; 574 | } 575 | } 576 | 577 | return output; 578 | } 579 | 580 | public static double Max(final double[] input) 581 | { 582 | if (input == null || input.length < 1) { return 0; } 583 | 584 | double output = input[0]; 585 | for (int i = 1; i < input.length; i++) 586 | { 587 | if (input[i] > output) 588 | { 589 | output = input[i]; 590 | } 591 | } 592 | 593 | return output; 594 | } 595 | 596 | // public static long Avg(Iterable it) 597 | // { 598 | // long result = 0; 599 | // long count = 0; 600 | // 601 | // if (it != null) 602 | // { 603 | // for (long value: it) 604 | // { 605 | // result += value; 606 | // count++; 607 | // } 608 | // } 609 | // 610 | // if (count > 0) 611 | // { 612 | // result /= count; 613 | // } 614 | // return result; 615 | // } 616 | 617 | // #endregion 618 | 619 | // #region Array Serialization 620 | 621 | private static String __ConvertArrayToString(T[] args, Func converter) 622 | { 623 | StringBuilder sb = new StringBuilder(); 624 | 625 | boolean first = true; 626 | 627 | if (args != null && converter != null) 628 | { 629 | for (T item: args) 630 | { 631 | try 632 | { 633 | String value = first ? "" : ", "; 634 | value += converter.func(item); 635 | sb.append(value); 636 | first = false; 637 | } 638 | catch (Throwable ignore) 639 | { 640 | // skip this item! 641 | } 642 | } 643 | } 644 | 645 | return sb.toString(); 646 | } 647 | 648 | private static List __ConvertStringToList(String input, Func converter) 649 | { 650 | List output = new ArrayList(); 651 | if (input != null && input.length() > 0 && converter != null) 652 | { 653 | String[] results = input.split("\\s*,\\s*"); 654 | for (String result: results) 655 | { 656 | try 657 | { 658 | if (result != null) 659 | { 660 | output.add(converter.func(result)); 661 | } 662 | } 663 | catch (Throwable ignore) 664 | { /* skip this field */} 665 | } 666 | } 667 | 668 | return output; 669 | } 670 | 671 | public static String ConvertIntegersToString(Integer... args) 672 | { 673 | return __ConvertArrayToString(args, new Func() 674 | { 675 | @Override 676 | public String func(Integer input) 677 | { 678 | return Integer.toString(input.intValue()); 679 | } 680 | }); 681 | } 682 | 683 | public static List ConvertStringToIntegers(String input) 684 | { 685 | return __ConvertStringToList(input, new Func() 686 | { 687 | @Override 688 | public Integer func(String input) 689 | { 690 | return Integer.parseInt(input); 691 | } 692 | }); 693 | } 694 | 695 | public static String ConvertDoublesToString(Double... args) 696 | { 697 | return __ConvertArrayToString(args, new Func() 698 | { 699 | @Override 700 | public String func(Double input) 701 | { 702 | return Double.toString(input.doubleValue()); 703 | } 704 | }); 705 | } 706 | 707 | public static List ConvertStringToDoubles(String input) 708 | { 709 | return __ConvertStringToList(input, new Func() 710 | { 711 | @Override 712 | public Double func(String input) 713 | { 714 | return Double.parseDouble(input); 715 | } 716 | }); 717 | } 718 | 719 | // #endregion 720 | 721 | // #region GetDistance / GetInverseDistance 722 | 723 | public static int GetDistance(ChunkCoordinates coords1, ChunkCoordinates coords2) 724 | { 725 | if (coords2 == null) 726 | { 727 | coords2 = new ChunkCoordinates(); 728 | } 729 | return GetDistance(coords1, coords2.posX, coords2.posY, coords2.posZ); 730 | } 731 | 732 | public static int GetDistance(ChunkCoordinates coords, int x, int y, int z) 733 | { 734 | if (coords == null) 735 | { 736 | coords = new ChunkCoordinates(); 737 | } 738 | return GetDistance(coords.posX, coords.posY, coords.posZ, x, y, z); 739 | } 740 | 741 | public static int GetDistance(int x1, int y1, int z1, int x2, int y2, int z2) 742 | { 743 | return (int)Math.round(GetDistance((double)x1, (double)y1, (double)z1, (double)x2, (double)y2, (double)z2)); 744 | } 745 | 746 | public static double GetDistance(double x1, double y1, double z1, double x2, double y2, double z2) 747 | { 748 | return Math.sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1) + (z2 - z1) * (z2 - z1)); 749 | } 750 | 751 | // #endregion 752 | 753 | // #region File System Utilities 754 | 755 | public static String GetFileExtension(String path) 756 | { 757 | String extension = ""; 758 | 759 | if (path != null && path.length() > 0) 760 | { 761 | int idx = path.lastIndexOf('.'); 762 | if (idx >= 0) 763 | { 764 | int lastSlashIdx = path.lastIndexOf(java.io.File.separatorChar); 765 | 766 | if (idx > lastSlashIdx) 767 | { 768 | extension = path.substring(idx + 1); 769 | } 770 | } 771 | } 772 | 773 | return extension; 774 | } 775 | 776 | // #endregion 777 | 778 | } 779 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Models/NoiseChunk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Models; 8 | 9 | import net.minecraft.world.World; 10 | import net.minecraft.world.gen.NoiseGeneratorOctaves; 11 | import newBiospheresMod.Helpers.Creator; 12 | import newBiospheresMod.Helpers.IKeyProvider; 13 | import newBiospheresMod.Helpers.LruCacheList; 14 | import newBiospheresMod.Helpers.ModConsts; 15 | import newBiospheresMod.Helpers.Utils; 16 | 17 | public class NoiseChunk 18 | { 19 | // #region Caching 20 | 21 | private static class CacheKey 22 | { 23 | public final int x; 24 | public final int z; 25 | public final World world; 26 | 27 | public CacheKey(final World world, final int x, final int z) 28 | { 29 | this.world = world; 30 | this.x = x; 31 | this.z = z; 32 | } 33 | 34 | @Override 35 | public boolean equals(Object obj) 36 | { 37 | if (obj == null) { return false; } 38 | if (this == obj) { return true; } 39 | if (!(obj instanceof CacheKey)) { return false; } 40 | CacheKey other = (CacheKey)obj; 41 | 42 | return this.x == other.x && this.z == other.z && this.world == other.world; 43 | } 44 | 45 | @Override 46 | public int hashCode() 47 | { 48 | int worldHash = (world == null) ? 0 : world.hashCode(); 49 | return ((x & 0xFFFF) | ((z & 0xFFFF) << 16)) ^ worldHash ^ 949032852; 50 | } 51 | } 52 | 53 | private static LruCacheList noiseChunks = new LruCacheList(25, 54 | new IKeyProvider() 55 | { 56 | @Override 57 | public Object provideKey(NoiseChunk item) 58 | { 59 | if (item == null) { return null; } 60 | 61 | return new CacheKey(item.world, item.chunkX, item.chunkZ); 62 | } 63 | }); 64 | 65 | public static NoiseChunk get(final World world, final int chunkX, final int chunkZ, 66 | final NoiseGeneratorOctaves noiseGen, final double scale, final int seaLevel) 67 | { 68 | Object key = new CacheKey(world, chunkX, chunkZ); 69 | 70 | return noiseChunks.FindOrAdd(key, new Creator() 71 | { 72 | @Override 73 | public NoiseChunk create() 74 | { 75 | return new NoiseChunk(world, chunkX, chunkZ, noiseGen, scale, seaLevel); 76 | } 77 | }); 78 | } 79 | 80 | // #endregion 81 | 82 | public final int chunkX; 83 | public final int chunkZ; 84 | public final World world; 85 | 86 | private final double[] noise; 87 | public final double minNoise, maxNoise; 88 | private final double scale; 89 | private static final double noiseScale = 0.0078125D; 90 | 91 | private final int seaLevel; 92 | 93 | public final NoiseGeneratorOctaves noiseGenerator; 94 | 95 | private NoiseChunk(World world, int chunkX, int chunkZ, NoiseGeneratorOctaves noiseGen, double scale, int seaLevel) 96 | { 97 | this.chunkX = chunkX; 98 | this.chunkZ = chunkZ; 99 | this.world = world; 100 | this.scale = scale; 101 | this.noiseGenerator = noiseGen; 102 | 103 | noise = noiseGen.generateNoiseOctaves(null, chunkX << 4, ModConsts.WORLD_HEIGHT, chunkZ << 4, 16, 1, 16, 104 | noiseScale, 1.0D, noiseScale); 105 | 106 | minNoise = Utils.Min(noise); 107 | maxNoise = Utils.Max(noise); 108 | 109 | this.seaLevel = seaLevel; 110 | } 111 | 112 | public int getChunkBoundSurfaceLevel(int boundX, int boundZ) 113 | { 114 | return getChunkBoundSurfaceLevel(boundX, boundZ, this.seaLevel); 115 | } 116 | 117 | public int getChunkBoundSurfaceLevel(int boundX, int boundZ, int baseLevel) 118 | { 119 | if (boundX < 0 || boundX >= 16) { throw new IndexOutOfBoundsException("boundX"); } 120 | if (boundZ < 0 || boundZ >= 16) { throw new IndexOutOfBoundsException("boundZ"); } 121 | 122 | double ret = baseLevel; 123 | ret += noise[boundZ + (boundX << 4)] * 8.0D * scale; 124 | return (int)Math.round(ret); 125 | } 126 | 127 | public int getRawSurfaceLevel(int rawX, int rawZ) 128 | { 129 | return getRawSurfaceLevel(rawX, rawZ, this.seaLevel); 130 | } 131 | 132 | public int getRawSurfaceLevel(int rawX, int rawZ, int baseLevel) 133 | { 134 | int chunkX = (int)Math.floor(rawX / 16d); 135 | int chunkZ = (int)Math.floor(rawZ / 16d); 136 | rawX -= (chunkX << 4); 137 | rawZ -= (chunkZ << 4); 138 | 139 | if (this.chunkX == chunkX && this.chunkZ == chunkZ) { return getChunkBoundSurfaceLevel(rawX, rawZ, baseLevel); } 140 | 141 | return get(world, chunkX, chunkZ, noiseGenerator, scale, seaLevel).getChunkBoundSurfaceLevel(rawX, rawZ); 142 | } 143 | 144 | public NoiseChunk GetChunkAt(int rawX, int rawZ) 145 | { 146 | int chunkX = (int)Math.floor(rawX / 16d); 147 | int chunkZ = (int)Math.floor(rawZ / 16d); 148 | 149 | if (this.chunkX == chunkX && this.chunkZ == chunkZ) { return this; } 150 | 151 | return get(world, chunkX, chunkZ, noiseGenerator, scale, seaLevel); 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Models/Sphere.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Models; 8 | 9 | import java.util.ArrayList; 10 | import java.util.HashMap; 11 | import java.util.List; 12 | import java.util.Map; 13 | import java.util.Random; 14 | 15 | import net.minecraft.block.Block; 16 | import net.minecraft.util.ChunkCoordinates; 17 | import net.minecraft.util.WeightedRandom; 18 | import net.minecraft.world.World; 19 | import net.minecraft.world.biome.BiomeGenBase; 20 | import newBiospheresMod.BiosphereChunkProvider; 21 | import newBiospheresMod.BlockData; 22 | import newBiospheresMod.BlockDome; 23 | import newBiospheresMod.BlockEntry; 24 | import newBiospheresMod.Configuration.ModConfig; 25 | import newBiospheresMod.Helpers.Blx; 26 | import newBiospheresMod.Helpers.Creator; 27 | import newBiospheresMod.Helpers.Func2; 28 | import newBiospheresMod.Helpers.IKeyProvider; 29 | import newBiospheresMod.Helpers.LruCacheList; 30 | import newBiospheresMod.Helpers.ModConsts; 31 | import newBiospheresMod.Helpers.TopDownBoundingBox; 32 | import newBiospheresMod.Helpers.Utils; 33 | 34 | public class Sphere 35 | { 36 | // #region Caching 37 | 38 | private static class CacheKey 39 | { 40 | public final int x; 41 | public final int z; 42 | public final BiosphereChunkProvider chunkProvider; 43 | 44 | public CacheKey(final BiosphereChunkProvider chunkProvider, final int x, final int z) 45 | { 46 | this.chunkProvider = chunkProvider; 47 | this.x = x; 48 | this.z = z; 49 | } 50 | 51 | @Override 52 | public boolean equals(Object obj) 53 | { 54 | if (obj == null) { return false; } 55 | if (this == obj) { return true; } 56 | if (!(obj instanceof CacheKey)) { return false; } 57 | CacheKey other = (CacheKey)obj; 58 | 59 | return this.x == other.x && this.z == other.z && this.chunkProvider == other.chunkProvider; 60 | } 61 | 62 | @Override 63 | public int hashCode() 64 | { 65 | int chunkProviderHash = (chunkProvider == null) ? 0 : chunkProvider.hashCode(); 66 | return ((x & 0xFFFF) | ((z & 0xFFFF) << 16)) ^ chunkProviderHash ^ 438129048; 67 | } 68 | } 69 | 70 | private static LruCacheList spheresCache = new LruCacheList(12, new IKeyProvider() 71 | { 72 | @Override 73 | public Object provideKey(Sphere item) 74 | { 75 | if (item == null) { return null; } 76 | return new CacheKey(item.chunkProvider, item.sphereLocation.posX, item.sphereLocation.posZ); 77 | } 78 | }); 79 | 80 | public static Sphere get(final World world, final int chunkX, final int chunkZ) 81 | { 82 | if (world == null) { return null; } 83 | final BiosphereChunkProvider provider = BiosphereChunkProvider.get(world); 84 | return get(provider, chunkX, chunkZ); 85 | } 86 | 87 | public static Sphere get(final BiosphereChunkProvider chunkProvider, final int chunkX, final int chunkZ) 88 | { 89 | if (chunkProvider == null) { return null; } 90 | 91 | ChunkCoordinates coords = GetSphereCenter(chunkX, chunkZ, chunkProvider.config); 92 | Object key = new CacheKey(chunkProvider, coords.posX, coords.posZ); 93 | 94 | return spheresCache.FindOrAdd(key, new Creator() 95 | { 96 | @Override 97 | public Sphere create() 98 | { 99 | return new Sphere(chunkProvider, chunkX, chunkZ); 100 | } 101 | }); 102 | } 103 | 104 | // #endregion 105 | 106 | // #region Fields 107 | 108 | private final int centerChunkX, centerChunkZ; 109 | private final NoiseChunk centerNoiseChunk; 110 | private final long seed; 111 | 112 | public final BiosphereChunkProvider chunkProvider; 113 | 114 | public final ChunkCoordinates sphereLocation; 115 | public final ChunkCoordinates orbLocation; 116 | public final ChunkCoordinates lakeLocation; 117 | public final boolean lavaLake; 118 | public final boolean hasLake; 119 | 120 | public final int scaledLakeEdgeRadius; 121 | public final int scaledOrbRadius; 122 | public final int scaledSphereRadius; 123 | public final int scaledLakeRadius; 124 | 125 | public final BiomeGenBase biome; 126 | 127 | public final double scale; 128 | public final boolean isNoiseEnabled; 129 | public final int scaledGridSize; 130 | public final int bridgeWidth; 131 | 132 | private TopDownBoundingBox orbStairwayBox; 133 | private Map orbStairwayBlx; 134 | 135 | private List boundingBoxes = null; 136 | 137 | public final int seaLevel; 138 | 139 | public final int sphereType; 140 | 141 | public final boolean isDesert; 142 | 143 | // #endregion 144 | 145 | private Sphere(BiosphereChunkProvider chunkProvider, int chunkX, int chunkZ) 146 | { 147 | this.chunkProvider = chunkProvider; 148 | ModConfig _cfg = this.chunkProvider.config; 149 | 150 | this.seaLevel = _cfg.getSeaLevel(); 151 | this.scale = _cfg.getScale(); 152 | this.isNoiseEnabled = _cfg.isNoiseEnabled(); 153 | this.scaledGridSize = _cfg.getScaledGridSize(); 154 | this.bridgeWidth = _cfg.getBridgeWidth(); 155 | this.scaledOrbRadius = _cfg.getScaledOrbRadius(); 156 | 157 | this.sphereLocation = GetSphereCenter(chunkX, chunkZ, _cfg); 158 | centerChunkX = sphereLocation.posX >> 4; 159 | centerChunkZ = sphereLocation.posZ >> 4; 160 | 161 | if (this.isNoiseEnabled) 162 | { 163 | centerNoiseChunk = NoiseChunk.get(chunkProvider.world, centerChunkX, centerChunkZ, 164 | this.chunkProvider.noiseGenerator, this.scale, this.seaLevel); 165 | } 166 | else 167 | { 168 | centerNoiseChunk = null; 169 | } 170 | 171 | // Correct the Y value if Noise is enabled. 172 | this.sphereLocation.posY = getRawSurfaceLevel(sphereLocation.posX, sphereLocation.posZ); 173 | 174 | // Seed local random number generator 175 | Random rnd = new Random(chunkProvider.worldSeed); 176 | long xm = rnd.nextLong() / 2L * 2L + 1L; 177 | long zm = rnd.nextLong() / 2L * 2L + 1L; 178 | long _seed = (sphereLocation.posX * xm + sphereLocation.posZ * zm) * 2512576L ^ chunkProvider.worldSeed; 179 | rnd.setSeed(_seed); 180 | 181 | double minRad = _cfg.getMinSphereRadius() * scale; 182 | double maxRad = _cfg.getMaxSphereRadius() * scale; 183 | 184 | double radRange = (maxRad - minRad); 185 | 186 | // Get sphere radius 187 | this.scaledSphereRadius = (int)Math.round(minRad + (rnd.nextDouble() * radRange)); 188 | 189 | // Get lake radius 190 | double lakeRatio = _cfg.getMinLakeRatio() 191 | + ((_cfg.getMaxLakeRatio() - _cfg.getMinLakeRatio()) * rnd.nextDouble()); 192 | this.scaledLakeRadius = (int)Math.round(this.scaledSphereRadius * lakeRatio); 193 | this.scaledLakeEdgeRadius = scaledLakeRadius + 2; 194 | 195 | // Get the biome for the sphere. 196 | this.biome = this.chunkProvider.world.getWorldChunkManager().getBiomeGenAt 197 | ( 198 | sphereLocation.posX, 199 | sphereLocation.posZ 200 | ); 201 | 202 | this.isDesert = (biome.getFloatRainfall() <= 0); 203 | 204 | // is it a lava lake? 205 | this.lavaLake = this.biome == BiomeGenBase.hell || this.biome != BiomeGenBase.swampland 206 | && this.biome != BiomeGenBase.taiga && this.biome != BiomeGenBase.icePlains 207 | && this.biome != BiomeGenBase.sky && rnd.nextInt(10) == 0; 208 | this.hasLake = this.biome == BiomeGenBase.swampland || this.biome != BiomeGenBase.sky && rnd.nextInt(2) == 0; 209 | 210 | // Get the location of the ore orb 211 | orbLocation = Utils.GetCoords(sphereLocation); 212 | int lowY = this.sphereLocation.posY - scaledSphereRadius; 213 | int highY = this.sphereLocation.posY + scaledSphereRadius; 214 | 215 | int orbRange = ((this.scaledGridSize * 8)) - this.scaledOrbRadius; 216 | 217 | orbLocation.posX = this.sphereLocation.posX; 218 | orbLocation.posZ = this.sphereLocation.posZ; 219 | orbLocation.posY = this.seaLevel; 220 | 221 | // TODO: let's make this algorithm more efficient 222 | int giveUpAfter = 100; 223 | while (!ValidOrbLocation() && giveUpAfter > 0) 224 | { 225 | giveUpAfter--; 226 | orbLocation.posX = (this.sphereLocation.posX - orbRange) 227 | + (int)Math.round(rnd.nextDouble() * (orbRange * 2)); 228 | 229 | orbLocation.posZ = (this.sphereLocation.posZ - orbRange) 230 | + (int)Math.round(rnd.nextDouble() * (orbRange * 2)); 231 | 232 | orbLocation.posY = Utils.RndBetween(rnd, lowY, highY); 233 | } 234 | 235 | if (!ValidOrbLocation()) 236 | { 237 | // put the orb out of range 238 | orbLocation.posY = this.seaLevel; 239 | orbLocation.posX = sphereLocation.posX + (this.scaledGridSize * 32); 240 | orbLocation.posZ = sphereLocation.posZ + (this.scaledGridSize * 32); 241 | } 242 | 243 | lakeLocation = Utils.GetCoords(sphereLocation); 244 | 245 | if (this.hasLake && this.isNoiseEnabled) 246 | { 247 | SetLakeHeight(); 248 | 249 | if (rnd.nextDouble() > .65d) 250 | { 251 | lakeLocation.posY -= (int)(Math.round((rnd.nextDouble() * 2d) * scale)); 252 | } 253 | } 254 | 255 | SetupOrbStairway(rnd); 256 | 257 | xm = rnd.nextLong() / 2L * 2L + 1L; 258 | zm = rnd.nextLong() / 2L * 2L + 1L; 259 | this.seed = (centerChunkX * xm + centerChunkZ * zm) * 3168045L ^ this.chunkProvider.worldSeed; 260 | 261 | rnd = GetPhaseRandom("SphereType", centerChunkX, centerChunkZ); 262 | int sType = -1; 263 | if (AnySphereTypeValid()) 264 | { 265 | while (!SphereTypeValid(sType)) 266 | { 267 | sType = rnd.nextInt() % ModConfig.DOMETYPE_COUNT; 268 | } 269 | } 270 | this.sphereType = sType; 271 | } 272 | 273 | // #region Public Methods 274 | 275 | private static final BlockData glassDomeBlock = new BlockData(Blx.glass); 276 | 277 | public BlockData getDomeBlock(int x, int y, int z) 278 | { 279 | BlockData ret = glassDomeBlock; 280 | 281 | if (SphereTypeValid(this.sphereType)) 282 | { 283 | Random rnd = GetPhaseRandom 284 | ( 285 | "SphereType_" + Integer.toString(x) + "_" + Integer.toString(y) + "_" + Integer.toString(z), 286 | centerChunkX, 287 | centerChunkZ 288 | ); 289 | 290 | ret = ((BlockEntry)WeightedRandom.getRandomItem(rnd, this.chunkProvider.config.DomeBlocks[this.sphereType])).Block; 291 | } 292 | 293 | return BlockDome.GetDomeBlock(ret); 294 | } 295 | 296 | public int getMainDistance(int rawX, int rawY, int rawZ) 297 | { 298 | return Utils.GetDistance(this.sphereLocation, rawX, rawY, rawZ); 299 | } 300 | 301 | public int getOrbDistance(int rawX, int rawY, int rawZ) 302 | { 303 | return Utils.GetDistance(this.orbLocation, rawX, rawY, rawZ); 304 | } 305 | 306 | public int getLakeDistance(int rawX, int rawY, int rawZ) 307 | { 308 | if (!hasLake) { return Integer.MAX_VALUE; } 309 | 310 | int lly = lakeLocation.posY; 311 | 312 | // a positive "dy" value indicates you are above the lake, while negative indicates below the lake. 313 | double dy = rawY - lly; 314 | 315 | // lets increase the distance slightly to give an ellipsoid shape. 316 | if (dy < 0) 317 | { 318 | dy = dy * 2; 319 | 320 | if (this.isNoiseEnabled) 321 | { 322 | int beforeNoise = (int)Math.round(Utils.GetDistance(lakeLocation.posX, 0, lakeLocation.posZ, rawX, dy, 323 | rawZ)); 324 | 325 | if (rawX >= (lakeLocation.posX - scaledLakeEdgeRadius) 326 | && rawZ >= (lakeLocation.posZ - scaledLakeEdgeRadius) 327 | && rawX <= (lakeLocation.posX + scaledLakeEdgeRadius) 328 | && rawZ <= (lakeLocation.posZ + scaledLakeEdgeRadius)) 329 | { 330 | int x = sphereLocation.posX + ((rawX - sphereLocation.posX) * 20); 331 | int z = sphereLocation.posZ + ((rawZ - sphereLocation.posZ) * 20); 332 | 333 | double offset = getRawSurfaceLevel(x, z) - this.seaLevel; 334 | dy += Math.abs((offset / 4d)); 335 | } 336 | 337 | int afterNoise = (int)Math.round(Utils.GetDistance(lakeLocation.posX, 0, lakeLocation.posZ, rawX, dy, 338 | rawZ)); 339 | if (afterNoise < beforeNoise) 340 | { 341 | return afterNoise; 342 | } 343 | else 344 | { 345 | return beforeNoise; 346 | } 347 | } 348 | } 349 | 350 | return (int)Math.round(Utils.GetDistance(lakeLocation.posX, 0, lakeLocation.posZ, rawX, dy, rawZ)); 351 | } 352 | 353 | public int getRawSurfaceLevel(int rawX, int rawZ) 354 | { 355 | if (centerNoiseChunk != null) { return centerNoiseChunk.getRawSurfaceLevel(rawX, rawZ); } 356 | return this.seaLevel; 357 | } 358 | 359 | private static final BlockData flowing_lava = new BlockData(Blx.flowing_lava); 360 | private static final BlockData flowing_water = new BlockData(Blx.flowing_water); 361 | 362 | public BlockData GetLakeBlock() 363 | { 364 | if (!this.hasLake) { return BlockData.Empty; } 365 | return this.lavaLake ? flowing_lava : flowing_water; 366 | } 367 | 368 | public List getBoundingBoxes() 369 | { 370 | if (boundingBoxes == null) 371 | { 372 | boundingBoxes = new ArrayList(); 373 | 374 | // Sphere 375 | boundingBoxes.add(TopDownBoundingBox.FromCircle(sphereLocation.posX, sphereLocation.posZ, 376 | this.scaledSphereRadius + 1)); 377 | 378 | // Ore Orb 379 | boundingBoxes.add(TopDownBoundingBox.FromCircle(orbLocation.posX, orbLocation.posZ, (scaledOrbRadius + 1))); 380 | 381 | // Z-aligned bridge 382 | boundingBoxes.add(new TopDownBoundingBox(sphereLocation.posX - (bridgeWidth + 1), Integer.MIN_VALUE, 383 | sphereLocation.posX + (bridgeWidth + 1), Integer.MAX_VALUE)); 384 | 385 | // X-aligned bridge 386 | boundingBoxes.add(new TopDownBoundingBox(Integer.MIN_VALUE, sphereLocation.posZ - (bridgeWidth + 1), 387 | Integer.MAX_VALUE, sphereLocation.posZ + (bridgeWidth + 1))); 388 | 389 | // Stairway 390 | if (orbStairwayBox != null) 391 | { 392 | boundingBoxes.add(orbStairwayBox); 393 | } 394 | } 395 | 396 | return boundingBoxes; 397 | } 398 | 399 | public BlockData getOrbStairwayBlock(int x, int y, int z) 400 | { 401 | if (orbStairwayBox == null) { return null; } 402 | if (!orbStairwayBox.CollidesWith(x, z)) { return null; } 403 | 404 | ChunkCoordinates key = Utils.GetCoords(x, y, z); 405 | 406 | if (orbStairwayBlx.containsKey(key)) { return orbStairwayBlx.get(key); } 407 | 408 | return null; 409 | } 410 | 411 | public Random GetPhaseRandom(String phase, int chunkX, int chunkZ) 412 | { 413 | Random rnd = new Random(this.seed); 414 | 415 | long xm = rnd.nextLong() / 2L * 2L + 1L; 416 | long zm = rnd.nextLong() / 2L * 2L + 1L; 417 | 418 | long _seed = (chunkX * xm + chunkZ * zm) * phase.hashCode() ^ this.chunkProvider.worldSeed; 419 | 420 | rnd.setSeed(_seed); 421 | return rnd; 422 | } 423 | 424 | // #endregion 425 | 426 | // #region Private Methods 427 | 428 | private boolean AnySphereTypeValid() 429 | { 430 | for (int i = 0; i < ModConfig.DOMETYPE_COUNT; i++) 431 | { 432 | if (SphereTypeValid(i)) { return true; } 433 | } 434 | 435 | return false; 436 | } 437 | 438 | private boolean SphereTypeValid(int typeIndex) 439 | { 440 | if (typeIndex < 0) { return false; } 441 | if (typeIndex >= ModConfig.DOMETYPE_COUNT) { return false; } 442 | 443 | ModConfig config = chunkProvider.config; 444 | 445 | if (config.DomeBlocks[typeIndex] != null) 446 | { 447 | for (int i = 0; i < config.DomeBlocks[typeIndex].size(); i++) 448 | { 449 | if (config.DomeBlocks[typeIndex].get(i).itemWeight > 0) 450 | { 451 | return true; 452 | } 453 | } 454 | } 455 | 456 | return false; 457 | } 458 | 459 | private static ChunkCoordinates GetSphereCenter(int chunkX, int chunkZ, ModConfig cfg) 460 | { 461 | if (cfg == null) { return null; } 462 | 463 | int chunkOffsetToCenterX = -(int)Math.floor(Math.IEEEremainder(chunkX, cfg.getScaledGridSize())); 464 | int chunkOffsetToCenterZ = -(int)Math.floor(Math.IEEEremainder(chunkZ, cfg.getScaledGridSize())); 465 | 466 | chunkX += chunkOffsetToCenterX; 467 | chunkZ += chunkOffsetToCenterZ; 468 | 469 | int x = ((chunkX) << 4) + 8; 470 | int z = ((chunkZ) << 4) + 8; 471 | int y = cfg.getSeaLevel(); 472 | 473 | return Utils.GetCoords(x, y, z); 474 | } 475 | 476 | private boolean ValidOrbLocation() 477 | { 478 | if (orbLocation.posY < (ModConsts.WORLD_MIN_Y + this.scaledOrbRadius)) { return false; } 479 | if (orbLocation.posY > (ModConsts.WORLD_MAX_Y - this.scaledOrbRadius)) { return false; } 480 | 481 | int groundLevel = getRawSurfaceLevel(orbLocation.posX, orbLocation.posZ); 482 | if (Math.abs(groundLevel - orbLocation.posY) <= (this.scaledOrbRadius + 2)) { return false; } 483 | 484 | TopDownBoundingBox sphereBox = TopDownBoundingBox.FromCircle(sphereLocation.posX, sphereLocation.posZ, 485 | this.scaledSphereRadius + 1); 486 | 487 | TopDownBoundingBox orbBox = TopDownBoundingBox.FromCircle(orbLocation.posX, orbLocation.posZ, 488 | (scaledOrbRadius + 1)); 489 | 490 | return !orbBox.CollidesWith(sphereBox); 491 | 492 | // return Utils.GetDistance(orbLocation, sphereLocation) > (this.scaledOrbRadius + this.scaledSphereRadius); 493 | } 494 | 495 | private void SetLakeHeight() 496 | { 497 | if (centerNoiseChunk == null) 498 | { 499 | lakeLocation.posY = this.seaLevel; 500 | } 501 | else 502 | { 503 | int x = lakeLocation.posX - scaledLakeRadius; 504 | int z = lakeLocation.posZ - scaledLakeRadius; 505 | boolean first = true; 506 | double min = 0; 507 | 508 | while (x <= (lakeLocation.posX + scaledLakeRadius)) 509 | { 510 | while (z <= (lakeLocation.posZ + scaledLakeRadius)) 511 | { 512 | double val = centerNoiseChunk.GetChunkAt(x, z).minNoise; 513 | if (first || val < min) 514 | { 515 | min = val; 516 | first = false; 517 | } 518 | 519 | z += 16; 520 | } 521 | x += 16; 522 | } 523 | 524 | lakeLocation.posY = (int)Math.round(this.seaLevel + min * 8.0D * scale); 525 | } 526 | } 527 | 528 | private void SetupOrbStairway(final Random rnd) 529 | { 530 | if (chunkProvider.config.doesNeedProtectionGlass()) { return; } 531 | 532 | final List stairwayBlocks = chunkProvider.config.StairwayBlocks; 533 | 534 | boolean foundBlock = false; 535 | for (BlockEntry be: stairwayBlocks) 536 | { 537 | if (be.itemWeight > 0) 538 | { 539 | foundBlock = true; 540 | break; 541 | } 542 | } 543 | if (!foundBlock) { return; } 544 | 545 | int orbDistX, orbDistZ; 546 | 547 | orbDistX = orbLocation.posX - sphereLocation.posX; 548 | orbDistZ = orbLocation.posZ - sphereLocation.posZ; 549 | 550 | if (Math.abs(orbDistX) < Math.abs(orbDistZ)) 551 | { 552 | orbDistZ = 0; 553 | } 554 | else if (Math.abs(orbDistX) > Math.abs(orbDistZ)) 555 | { 556 | orbDistX = 0; 557 | } 558 | else 559 | { 560 | if (rnd.nextBoolean()) 561 | { 562 | orbDistX = 0; 563 | } 564 | else 565 | { 566 | orbDistZ = 0; 567 | } 568 | } 569 | 570 | // bridge intersection point 571 | int ix = orbLocation.posX - orbDistX; 572 | int iz = orbLocation.posZ - orbDistZ; 573 | int iy = getRawSurfaceLevel(ix, iz); 574 | 575 | final int tox = (orbDistX == 0 ? 0 : ((orbDistX > 0) ? 1 : -1)); 576 | final int toz = (orbDistZ == 0 ? 0 : ((orbDistZ > 0) ? 1 : -1)); 577 | 578 | orbStairwayBlx = new HashMap(); 579 | 580 | if (orbDistZ == 0) 581 | { 582 | Utils.DoLine(orbLocation.posX, orbLocation.posY, ix, iy, new Func2() 583 | { 584 | @Override 585 | public Boolean func(Integer x, Integer y) 586 | { 587 | for (int z = orbLocation.posZ - bridgeWidth; z <= orbLocation.posZ + bridgeWidth; z++) 588 | { 589 | BlockData block = ((BlockEntry)WeightedRandom.getRandomItem(rnd, stairwayBlocks)).Block; 590 | if (!BlockData.IsNullOrEmpty(block)) 591 | { 592 | orbStairwayBlx.put(Utils.GetCoords(x, y, z), block); 593 | } 594 | 595 | block = ((BlockEntry)WeightedRandom.getRandomItem(rnd, stairwayBlocks)).Block; 596 | if (!BlockData.IsNullOrEmpty(block)) 597 | { 598 | orbStairwayBlx.put(Utils.GetCoords(x + tox, y, z + toz), block); 599 | } 600 | } 601 | 602 | return true; 603 | } 604 | }); 605 | } 606 | else 607 | { 608 | Utils.DoLine(orbLocation.posZ, orbLocation.posY, iz, iy, new Func2() 609 | { 610 | @Override 611 | public Boolean func(Integer z, Integer y) 612 | { 613 | for (int x = orbLocation.posX - bridgeWidth; x <= orbLocation.posX + bridgeWidth; x++) 614 | { 615 | BlockData block = ((BlockEntry)WeightedRandom.getRandomItem(rnd, stairwayBlocks)).Block; 616 | if (!BlockData.IsNullOrEmpty(block)) 617 | { 618 | orbStairwayBlx.put(Utils.GetCoords(x, y, z), block); 619 | } 620 | 621 | block = ((BlockEntry)WeightedRandom.getRandomItem(rnd, stairwayBlocks)).Block; 622 | if (!BlockData.IsNullOrEmpty(block)) 623 | { 624 | orbStairwayBlx.put(Utils.GetCoords(x + tox, y, z + toz), block); 625 | } 626 | } 627 | 628 | return true; 629 | } 630 | }); 631 | } 632 | 633 | orbStairwayBox = TopDownBoundingBox.FromArray(orbStairwayBlx.keySet()); 634 | } 635 | // #endregion 636 | 637 | } 638 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/Models/SphereChunk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod.Models; 8 | 9 | import java.util.Random; 10 | 11 | import newBiospheresMod.BiosphereChunkProvider; 12 | import newBiospheresMod.Configuration.ModConfig; 13 | import newBiospheresMod.Helpers.Creator; 14 | import newBiospheresMod.Helpers.IKeyProvider; 15 | import newBiospheresMod.Helpers.LruCacheList; 16 | 17 | public class SphereChunk 18 | { 19 | // #region Caching 20 | 21 | private static class CacheKey 22 | { 23 | public final int x; 24 | public final int z; 25 | public final BiosphereChunkProvider chunkProvider; 26 | 27 | public CacheKey(final BiosphereChunkProvider chunkProvider, final int x, final int z) 28 | { 29 | this.chunkProvider = chunkProvider; 30 | this.x = x; 31 | this.z = z; 32 | } 33 | 34 | @Override 35 | public boolean equals(Object obj) 36 | { 37 | if (obj == null) { return false; } 38 | if (this == obj) { return true; } 39 | if (!(obj instanceof CacheKey)) { return false; } 40 | CacheKey other = (CacheKey)obj; 41 | 42 | return this.x == other.x && this.z == other.z && this.chunkProvider == other.chunkProvider; 43 | } 44 | 45 | @Override 46 | public int hashCode() 47 | { 48 | int chunkProviderHash = (chunkProvider == null) ? 0 : chunkProvider.hashCode(); 49 | return ((x & 0xFFFF) | ((z & 0xFFFF) << 16)) ^ chunkProviderHash ^ 1890321837; 50 | } 51 | } 52 | 53 | private static LruCacheList sphereChunksCache = new LruCacheList(15, 54 | new IKeyProvider() 55 | { 56 | @Override 57 | public Object provideKey(SphereChunk item) 58 | { 59 | if (item == null) { return null; } 60 | return new CacheKey(item.chunkProvider, item.chunkX, item.chunkZ); 61 | } 62 | }); 63 | 64 | public static SphereChunk get(final BiosphereChunkProvider chunkProvider, final int chunkX, final int chunkZ) 65 | { 66 | return sphereChunksCache.FindOrAdd(new CacheKey(chunkProvider, chunkX, chunkZ), new Creator() 67 | { 68 | @Override 69 | public SphereChunk create() 70 | { 71 | return new SphereChunk(chunkProvider, chunkX, chunkZ); 72 | } 73 | }); 74 | } 75 | 76 | // #endregion 77 | 78 | public final int chunkX, chunkZ; 79 | 80 | public final BiosphereChunkProvider chunkProvider; 81 | public final Sphere masterSphere; 82 | 83 | public final boolean isNoiseEnabled; 84 | public final NoiseChunk noise; 85 | 86 | public SphereChunk(BiosphereChunkProvider chunkProvider, int chunkX, int chunkZ) 87 | { 88 | this.chunkProvider = chunkProvider; 89 | this.chunkX = chunkX; 90 | this.chunkZ = chunkZ; 91 | 92 | ModConfig cfg = this.chunkProvider.config; 93 | this.isNoiseEnabled = cfg.isNoiseEnabled(); 94 | 95 | noise = isNoiseEnabled ? NoiseChunk.get(this.chunkProvider.world, chunkX, chunkZ, 96 | this.chunkProvider.noiseGenerator, cfg.getScale(), cfg.getSeaLevel()) : null; 97 | 98 | masterSphere = Sphere.get(chunkProvider, chunkX, chunkZ); 99 | } 100 | 101 | public Random GetPhaseRandom(String phase) 102 | { 103 | return masterSphere.GetPhaseRandom(phase, chunkX, chunkZ); 104 | } 105 | 106 | public int getChunkBoundSurfaceLevel(int boundX, int boundZ) 107 | { 108 | if (this.noise != null) { return noise.getChunkBoundSurfaceLevel(boundX, boundZ); } 109 | return this.chunkProvider.config.getSeaLevel(); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/newBiospheresMod/NewBiospheresMod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute 3 | * it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by 4 | * Sam Hocevar. See http://www.wtfpl.net/ for more details. 5 | */ 6 | 7 | package newBiospheresMod; 8 | 9 | import java.io.File; 10 | 11 | import com.google.common.io.Files; 12 | 13 | import net.minecraft.world.WorldType; 14 | import net.minecraftforge.common.DimensionManager; 15 | import net.minecraftforge.common.config.Configuration; 16 | import newBiospheresMod.Configuration.ModConfig; 17 | import newBiospheresMod.Helpers.ModConsts; 18 | import newBiospheresMod.Helpers.Utils; 19 | import cpw.mods.fml.client.event.ConfigChangedEvent; 20 | import cpw.mods.fml.common.FMLCommonHandler; 21 | import cpw.mods.fml.common.Mod; 22 | import cpw.mods.fml.common.Mod.EventHandler; 23 | import cpw.mods.fml.common.event.FMLInitializationEvent; 24 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; 25 | import cpw.mods.fml.common.eventhandler.SubscribeEvent; 26 | import cpw.mods.fml.common.registry.LanguageRegistry; 27 | 28 | @Mod( 29 | modid = ModConsts.ModId, 30 | version = ModConsts.ModVersion, 31 | guiFactory = "newBiospheresMod.Configuration.ModConfigGuiFactory") 32 | public class NewBiospheresMod 33 | { 34 | public static WorldType biosphereWorldType; 35 | 36 | @EventHandler 37 | public void PreInit(FMLPreInitializationEvent event) 38 | { 39 | // Migrate the Configuration File forward to the new Mod Id. 40 | 41 | // TODO: Move this somewhere more fitting 42 | File configFile = event.getSuggestedConfigurationFile(); 43 | if (!configFile.exists()) 44 | { 45 | File oldConfigFile = new File(configFile.getParent() + File.separator 46 | + ModConsts.OldModId + "." 47 | + Utils.GetFileExtension(configFile.getPath())); 48 | if (oldConfigFile.exists()) 49 | { 50 | try 51 | { 52 | Files.move(oldConfigFile, configFile); 53 | } 54 | catch (Exception e) 55 | { 56 | System.out 57 | .println("Unable to move config file; attempting to use old config file in place."); 58 | configFile = oldConfigFile; 59 | } 60 | } 61 | } 62 | 63 | // Load the Configuration File 64 | ModConfig.setConfigFile(new Configuration(configFile, ModConsts.ModVersion)); 65 | ModConfig.updateFile(); 66 | } 67 | 68 | @EventHandler 69 | public void Init(FMLInitializationEvent event) 70 | { 71 | // TODO: Update this to use the new resource localization crap 72 | LanguageRegistry.instance().addStringLocalization("generator.biosphere", "Biospheres"); 73 | 74 | biosphereWorldType = new BiosphereWorldType("biosphere"); 75 | 76 | DimensionManager.unregisterProviderType(0); 77 | DimensionManager.registerProviderType(0, BiosphereWorldProvider.class, true); 78 | 79 | FMLCommonHandler.instance().bus().register(this); 80 | } 81 | 82 | @EventHandler 83 | public void PostInit(FMLInitializationEvent event) 84 | { 85 | BlockDome.InitalizeAllRegisteredBlocks(); 86 | } 87 | 88 | @SubscribeEvent 89 | public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) 90 | { 91 | if (eventArgs.modID.equalsIgnoreCase(ModConsts.ModId)) 92 | { 93 | ModConfig.updateFile(); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/resources/MODINFO.TXT: -------------------------------------------------------------------------------- 1 | For the latest version of this mod, please see the Minecraft Forum thread: 2 | 3 | http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/2236413-new-biospheres-mod 4 | 5 | For the latest source code, please see the GitHub repository: 6 | 7 | https://github.com/BrainSlugs83/NewBiospheresMod 8 | 9 | Find me on twitter at: 10 | 11 | http://www.twitter.com/BrainSlugs83 12 | -------------------------------------------------------------------------------- /src/main/resources/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrainSlugs83/NewBiospheresMod/1493b5219d7a71db13a0e027da293324f1018821/src/main/resources/logo.png -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "NewBiospheresMod", 4 | "name": "New Biospheres Mod", 5 | "description": "Adds a 'Biospheres' WorldType to Minecraft. Based on Risugami's original mod for Minecraft 1.6.", 6 | "version": "0.85", 7 | "mcversion": "${mcversion}", 8 | "url": "http://www.twitter.com/BrainSlugs83", 9 | "updateUrl": "", 10 | "authorList": ["BrainSlugs83", "Original Mod: Risugami"], 11 | "credits": "Thanks to: TheLoneWolfling, GotoLink, CosmicDan, Choonster, Trevordebrecht", 12 | "logoFile": "logo.png", 13 | "screenshots": ["screenshot1.png", "screenshot2.png"], 14 | "dependencies": [] 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /src/main/resources/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrainSlugs83/NewBiospheresMod/1493b5219d7a71db13a0e027da293324f1018821/src/main/resources/screenshot1.png -------------------------------------------------------------------------------- /src/main/resources/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrainSlugs83/NewBiospheresMod/1493b5219d7a71db13a0e027da293324f1018821/src/main/resources/screenshot2.png --------------------------------------------------------------------------------