Fixed detector and improved manipulator

This commit is contained in:
Henry Mao 2012-12-27 15:20:28 +08:00
parent b867644894
commit d4781ab3b0
35 changed files with 1553 additions and 1229 deletions

291
Eclipse Java Standard.xml Normal file
View file

@ -0,0 +1,291 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="Calclavia Standard" version="12">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="48"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
<setting id="org.eclipse.jdt.core.compiler.source" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="1000"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="tab"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="next_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="next_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="next_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="next_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="next_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="100"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="next_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
</profile>
</profiles>

View file

@ -1 +1 @@
0.1.8
0.1.9

View file

@ -6,6 +6,7 @@ tile.crate.name=Crate
tile.conveyorBelt.name=Conveyor Belt
tile.stamper.name=Filter Stamper
tile.engineerTable.name=Engineer's Table
tile.detector.name=Detector
tile.armbot.name=Armbot
# Items

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

View file

@ -2,7 +2,7 @@
{
"modid" : "AssemblyLine",
"name" : "Assembly Line",
"version" : "0.1.8",
"version" : "0.1.9",
"url" : "http://calclavia.com/universalelectricity/?m=18",
"credits" : "",
"authors": [

View file

@ -3,18 +3,22 @@ package assemblyline.api;
import net.minecraft.item.ItemStack;
import universalelectricity.core.vector.Vector3;
/**
* Interface applied to the manipulator.
*
* @author Calclavia
*
*/
public interface IManipulator
{
/**
* Throws the items from the manipulator into the world
*
* @param outputPosition
* @param items
* Find items going into the manipulator and input them into an inventory behind this
* manipulator.
*/
public void rejectItem(Vector3 outputPosition, ItemStack items);
public void eject();
// TODO add a few more methods here to access
// the functions the manipulator
// can do. For example storing items, and
// retrieving items, or power on/off
/**
* Injects items
*/
public void inject();
}

View file

@ -5,10 +5,12 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import assemblyline.client.gui.GuiDetector;
import assemblyline.client.gui.GuiRejector;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.client.render.RenderConveyorBelt;
import assemblyline.client.render.RenderCrate;
import assemblyline.client.render.RenderHelper;
import assemblyline.client.render.RenderDetector;
import assemblyline.client.render.RenderManipulator;
import assemblyline.client.render.RenderSorter;
import assemblyline.common.AssemblyLine;
@ -17,6 +19,7 @@ import assemblyline.common.block.TileEntityCrate;
import assemblyline.common.machine.TileEntityManipulator;
import assemblyline.common.machine.TileEntityRejector;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import assemblyline.common.machine.detector.TileEntityDetector;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
@ -27,7 +30,7 @@ public class ClientProxy extends CommonProxy
public void preInit()
{
MinecraftForgeClient.preloadTexture(AssemblyLine.BLOCK_TEXTURE_PATH);
RenderingRegistry.registerBlockHandler(new RenderHelper());
RenderingRegistry.registerBlockHandler(new BlockRenderingHandler());
}
@Override
@ -38,6 +41,7 @@ public class ClientProxy extends CommonProxy
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRejector.class, new RenderSorter());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityManipulator.class, new RenderManipulator());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrate.class, new RenderCrate());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDetector.class, new RenderDetector());
}
@Override
@ -53,6 +57,8 @@ public class ClientProxy extends CommonProxy
return new GuiRejector(player.inventory, ((TileEntityRejector) tileEntity));
case GUI_STAMPER:
return new GuiRejector(player.inventory, ((TileEntityRejector) tileEntity));
case GUI_DETECTOR:
return new GuiDetector(player.inventory, ((TileEntityDetector) tileEntity));
}
}

View file

@ -0,0 +1,54 @@
package assemblyline.client.gui;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import assemblyline.common.machine.detector.ContainerDetector;
import assemblyline.common.machine.detector.TileEntityDetector;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* @author Briman0094
*/
@SideOnly(Side.CLIENT)
public class GuiDetector extends GuiContainer
{
private TileEntityDetector tileEntity;
public GuiDetector(InventoryPlayer inventory, TileEntityDetector tileEntity)
{
super(new ContainerDetector(inventory, tileEntity));
this.tileEntity = tileEntity;
this.allowUserInput = false;
short baseHeight = 222;
int var4 = baseHeight - 108;
this.ySize = var4 + 3 * 18;
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
fontRenderer.drawString(this.tileEntity.getInvName(), 8, 6, 4210752);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int var4 = this.mc.renderEngine.getTexture("/gui/container.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
int var5 = (this.width - this.xSize) / 2;
int var6 = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, 3 * 18 + 17);
this.drawTexturedModalRect(var5, var6 + 3 * 18 + 17, 0, 126, this.xSize, 96);
}
}

View file

@ -1,85 +0,0 @@
package assemblyline.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiSmallButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import assemblyline.common.machine.sensor.ContainerItemSensor;
import assemblyline.common.machine.sensor.TileItemSensor;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiItemSensor extends GuiContainer
{
private EntityPlayer player;
private GuiSmallButton invert;
private TileItemSensor tileEntity;
public GuiItemSensor(EntityPlayer player, TileItemSensor tileEntity)
{
super(new ContainerItemSensor(player.inventory, tileEntity));
this.tileEntity = tileEntity;
this.player = player;
this.allowUserInput = false;
short baseHeight = 222;
int var4 = baseHeight - 108;
this.ySize = var4 + 3 * 18;
}
@Override
public void initGui()
{
super.initGui();
invert = new GuiSmallButton(0, this.guiLeft + 82, this.guiTop + 5, 12, 12, "i");
controlList.add(invert);
}
@Override
protected void actionPerformed(GuiButton button)
{
switch (button.id)
{
case 0: //invert
{
PacketHandler.sendTileEntityAction(player, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, PacketHandler.PACKET_ACTION_ITEM_SENSOR);
}
}
}
@Override
public void updateScreen()
{
invert.displayString = tileEntity.isItemCheckInverted() ? "e" : "i";
super.updateScreen();
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
fontRenderer.drawString("Item Sensor", 8, 6, 4210752);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int var4 = this.mc.renderEngine.getTexture("/gui/container.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
int var5 = (this.width - this.xSize) / 2;
int var6 = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, 3 * 18 + 17);
this.drawTexturedModalRect(var5, var6 + 3 * 18 + 17, 0, 126, this.xSize, 96);
}
}

View file

@ -7,8 +7,9 @@ import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.TranslationHelper;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.ContainerRejector;
import assemblyline.common.machine.filter.ContainerStamper;
public class GuiStamper extends GuiContainer
{
@ -17,7 +18,7 @@ public class GuiStamper extends GuiContainer
public GuiStamper(InventoryPlayer par1InventoryPlayer, World worldObj, Vector3 position)
{
super(new ContainerRejector(par1InventoryPlayer, worldObj, position));
super(new ContainerStamper(par1InventoryPlayer, worldObj, position));
}
/**
@ -26,7 +27,7 @@ public class GuiStamper extends GuiContainer
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
this.fontRenderer.drawString(AssemblyLine.translateLocal("assemblyline.gui.stamper"), 55, 6, 4210752);
this.fontRenderer.drawString(TranslationHelper.getLocal("tile.stamper.name"), 55, 6, 4210752);
}
/**
@ -35,18 +36,11 @@ public class GuiStamper extends GuiContainer
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "gui_ejector.png");
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "gui_empty.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
containerWidth = (this.width - this.xSize) / 2;
containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
// GUI button changes
for (int i = 1; i < this.tileEntity.guiButtons.length; i++)
{
this.drawTexturedModalRect(containerWidth + 17 + i * 18, containerHeight + 17, 176, +(tileEntity.guiButtons[i] ? 12 : 0), 12, 12);
}
this.fontRenderer.drawString((tileEntity.guiButtons[0] ? "Inv" : "Other"), containerWidth + 108, containerHeight + 22, 4210752);
}
}

View file

@ -1,216 +1,202 @@
package assemblyline.client.model;
import static org.lwjgl.opengl.GL11.GL_QUADS;
import static org.lwjgl.opengl.GL11.glBegin;
import static org.lwjgl.opengl.GL11.glEnd;
import static org.lwjgl.opengl.GL11.glTexCoord2f;
import static org.lwjgl.opengl.GL11.glVertex3d;
import assemblyline.common.BlockSide;
import net.minecraft.util.Vec3;
public class ModelHelper
{
private static int gTexWidth = 64;
private static int gTexHeight = 32;
private static int sTexWidth = 64;
private static int sTexHeight = 32;
private static int texOffsetX = 0;
private static int texOffsetY = 0;
private static float texScale = 16f; // 16 pixels per world unit
private static boolean clip = false; // clip textures instead of scaling them
/**
*
* @param v1
* Top Left
* @param v2
* Top Right
* @param v3
* Bottom Right
* @param v4
* Bottom Left
*/
private static void drawQuadRaw(Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, int side)
{
glBegin(GL_QUADS);
float quadWidth = 1;
float quadHeight = 1;
float subWidth = ((float) sTexWidth / (float) gTexWidth);
float subHeight = ((float) sTexHeight / (float) gTexHeight);
float xMin = ((float) texOffsetX / sTexWidth) * subWidth;
float yMin = ((float) texOffsetY / sTexHeight) * subHeight;
float subSqX = 0;
float subSqY = 0;
float subSqWidth = 0.25f * ((float) sTexWidth / (float) gTexWidth); // constant for now
float subSqHeight = 0.5f * ((float) sTexHeight / (float) gTexHeight);
// System.out.println("SubWidth: " + subWidth);
switch (side)
{
case BlockSide.YPLUS: // top
{
subSqX = 2f * subSqWidth;
subSqY = 0;
quadWidth = (float) Math.abs(v2.xCoord - v1.xCoord);
quadHeight = (float) Math.abs(v4.zCoord - v1.zCoord);
break;
}
case BlockSide.YMINUS: // bottom
{
subSqX = 1f * subSqWidth;
subSqY = 0;
quadWidth = (float) Math.abs(v2.xCoord - v1.xCoord);
quadHeight = (float) Math.abs(v4.zCoord - v1.zCoord);
break;
}
case BlockSide.XPLUS: // right
{
subSqX = 0;
subSqY = subSqHeight;
quadWidth = (float) Math.abs(v2.zCoord - v1.zCoord);
quadHeight = (float) Math.abs(v4.yCoord - v1.yCoord);
break;
}
case BlockSide.XMINUS: // left
{
subSqX = 2f * subSqWidth;
subSqY = subSqHeight;
quadWidth = (float) Math.abs(v2.zCoord - v1.zCoord);
quadHeight = (float) Math.abs(v4.yCoord - v1.yCoord);
break;
}
case BlockSide.ZPLUS: // back
{
subSqX = subSqWidth;
subSqY = subSqHeight;
quadWidth = (float) Math.abs(v2.xCoord - v1.xCoord);
quadHeight = (float) Math.abs(v4.yCoord - v1.yCoord);
break;
}
case BlockSide.ZMINUS: // front
{
subSqX = 3f * subSqWidth;
subSqY = subSqHeight;
quadWidth = (float) Math.abs(v2.xCoord - v1.xCoord);
quadHeight = (float) Math.abs(v4.yCoord - v1.yCoord);
break;
}
}
float xMax, yMax;
xMin += subSqX;
yMin += subSqY;
if (clip)
{
xMin += (1f - quadWidth) * subSqWidth;
yMin += (1f - quadHeight) * subSqHeight;
xMax = xMin + (subSqWidth * quadWidth);
yMax = yMin + (subSqHeight * quadHeight);
}
else
{
xMax = xMin + (subSqWidth);
yMax = yMin + (subSqHeight);
}
// System.out.println("xMin: " + xMin + "; xMax: " + xMax);
glTexCoord2f(xMin, yMin);
glVertex3d(v1.xCoord, v1.yCoord, v1.zCoord);
glTexCoord2f(xMax, yMin);
glVertex3d(v2.xCoord, v2.yCoord, v2.zCoord);
glTexCoord2f(xMax, yMax);
glVertex3d(v3.xCoord, v3.yCoord, v3.zCoord);
glTexCoord2f(xMin, yMax);
glVertex3d(v4.xCoord, v4.yCoord, v4.zCoord);
glEnd();
}
/**
*
* @param v1
* Top Left Back
* @param v2
* Top Right Back
* @param v3
* Top Right Front
* @param v4
* Top Left Front
* @param v5
* Bottom Left Front
* @param v6
* Bottom Right Front
* @param v7
* Bottom Right Back
* @param v8
* Bottom Left Back
*/
private static void drawCuboidRaw(Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, Vec3 v5, Vec3 v6, Vec3 v7, Vec3 v8)
{
drawQuadRaw(v1, v2, v3, v4, BlockSide.YPLUS); // top
drawQuadRaw(v7, v6, v3, v2, BlockSide.XPLUS); // right
drawQuadRaw(v5, v6, v7, v8, BlockSide.YMINUS); // bottom
drawQuadRaw(v5, v8, v1, v4, BlockSide.XMINUS); // left
drawQuadRaw(v6, v5, v4, v3, BlockSide.ZMINUS); // front
drawQuadRaw(v8, v7, v2, v1, BlockSide.ZPLUS); // back
}
public static void drawCuboid(float xOffset, float yOffset, float zOffset, float xSize, float ySize, float zSize)
{
Vec3 v1, v2, v3, v4, v5, v6, v7, v8;
float x, y, z;
float x2, y2, z2;
x = xOffset;
y = yOffset;
z = zOffset;
x2 = x + xSize;
y2 = y + ySize;
z2 = z + zSize;
v1 = Vec3.createVectorHelper(x, y2, z2);
v2 = Vec3.createVectorHelper(x2, y2, z2);
v3 = Vec3.createVectorHelper(x2, y2, z);
v4 = Vec3.createVectorHelper(x, y2, z);
v5 = Vec3.createVectorHelper(x, y, z);
v6 = Vec3.createVectorHelper(x2, y, z);
v7 = Vec3.createVectorHelper(x2, y, z2);
v8 = Vec3.createVectorHelper(x, y, z2);
drawCuboidRaw(v1, v2, v3, v4, v5, v6, v7, v8);
}
public static void setTextureOffset(int xOffset, int yOffset)
{
texOffsetX = xOffset;
texOffsetY = yOffset;
}
public static void setGlobalTextureResolution(int width, int height)
{
gTexWidth = width;
gTexHeight = height;
}
public static void setTextureSubResolution(int width, int height)
{
sTexWidth = width;
sTexHeight = height;
}
/**
* Sets whether or not to clip the texture.
*
* @param clip
* If true, textures on blocks less than 1x1x1 will be clipped. If false, they will be scaled.
*/
public static void setTextureClip(boolean clip)
{
ModelHelper.clip = clip;
}
}
package assemblyline.client.model;
import static org.lwjgl.opengl.GL11.GL_QUADS;
import static org.lwjgl.opengl.GL11.glBegin;
import static org.lwjgl.opengl.GL11.glEnd;
import static org.lwjgl.opengl.GL11.glTexCoord2f;
import static org.lwjgl.opengl.GL11.glVertex3d;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.ForgeDirection;
public class ModelHelper
{
private static int gTexWidth = 64;
private static int gTexHeight = 32;
private static int sTexWidth = 64;
private static int sTexHeight = 32;
private static int texOffsetX = 0;
private static int texOffsetY = 0;
private static float texScale = 16f; // 16 pixels per world unit
private static boolean clip = false; // clip textures instead of scaling them
/**
*
* @param v1 Top Left
* @param v2 Top Right
* @param v3 Bottom Right
* @param v4 Bottom Left
*/
private static void drawQuadRaw(Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, ForgeDirection side)
{
glBegin(GL_QUADS);
float quadWidth = 1;
float quadHeight = 1;
float subWidth = ((float) sTexWidth / (float) gTexWidth);
float subHeight = ((float) sTexHeight / (float) gTexHeight);
float xMin = ((float) texOffsetX / sTexWidth) * subWidth;
float yMin = ((float) texOffsetY / sTexHeight) * subHeight;
float subSqX = 0;
float subSqY = 0;
float subSqWidth = 0.25f * ((float) sTexWidth / (float) gTexWidth); // constant for now
float subSqHeight = 0.5f * ((float) sTexHeight / (float) gTexHeight);
switch (side)
{
case UP: // top
{
subSqX = 2f * subSqWidth;
subSqY = 0;
quadWidth = (float) Math.abs(v2.xCoord - v1.xCoord);
quadHeight = (float) Math.abs(v4.zCoord - v1.zCoord);
break;
}
case DOWN: // bottom
{
subSqX = 1f * subSqWidth;
subSqY = 0;
quadWidth = (float) Math.abs(v2.xCoord - v1.xCoord);
quadHeight = (float) Math.abs(v4.zCoord - v1.zCoord);
break;
}
case EAST: // right
{
subSqX = 0;
subSqY = subSqHeight;
quadWidth = (float) Math.abs(v2.zCoord - v1.zCoord);
quadHeight = (float) Math.abs(v4.yCoord - v1.yCoord);
break;
}
case WEST: // left
{
subSqX = 2f * subSqWidth;
subSqY = subSqHeight;
quadWidth = (float) Math.abs(v2.zCoord - v1.zCoord);
quadHeight = (float) Math.abs(v4.yCoord - v1.yCoord);
break;
}
case SOUTH: // back
{
subSqX = subSqWidth;
subSqY = subSqHeight;
quadWidth = (float) Math.abs(v2.xCoord - v1.xCoord);
quadHeight = (float) Math.abs(v4.yCoord - v1.yCoord);
break;
}
case NORTH: // front
{
subSqX = 3f * subSqWidth;
subSqY = subSqHeight;
quadWidth = (float) Math.abs(v2.xCoord - v1.xCoord);
quadHeight = (float) Math.abs(v4.yCoord - v1.yCoord);
break;
}
default:
break;
}
float xMax, yMax;
xMin += subSqX;
yMin += subSqY;
if (clip)
{
xMin += (1f - quadWidth) * subSqWidth;
yMin += (1f - quadHeight) * subSqHeight;
xMax = xMin + (subSqWidth * quadWidth);
yMax = yMin + (subSqHeight * quadHeight);
}
else
{
xMax = xMin + (subSqWidth);
yMax = yMin + (subSqHeight);
}
// System.out.println("xMin: " + xMin + "; xMax: " + xMax);
glTexCoord2f(xMin, yMin);
glVertex3d(v1.xCoord, v1.yCoord, v1.zCoord);
glTexCoord2f(xMax, yMin);
glVertex3d(v2.xCoord, v2.yCoord, v2.zCoord);
glTexCoord2f(xMax, yMax);
glVertex3d(v3.xCoord, v3.yCoord, v3.zCoord);
glTexCoord2f(xMin, yMax);
glVertex3d(v4.xCoord, v4.yCoord, v4.zCoord);
glEnd();
}
/**
*
* @param v1 Top Left Back
* @param v2 Top Right Back
* @param v3 Top Right Front
* @param v4 Top Left Front
* @param v5 Bottom Left Front
* @param v6 Bottom Right Front
* @param v7 Bottom Right Back
* @param v8 Bottom Left Back
*/
private static void drawCuboidRaw(Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, Vec3 v5, Vec3 v6, Vec3 v7, Vec3 v8)
{
drawQuadRaw(v1, v2, v3, v4, ForgeDirection.UP); // top
drawQuadRaw(v7, v6, v3, v2, ForgeDirection.EAST); // right
drawQuadRaw(v5, v6, v7, v8, ForgeDirection.DOWN); // bottom
drawQuadRaw(v5, v8, v1, v4, ForgeDirection.WEST); // left
drawQuadRaw(v6, v5, v4, v3, ForgeDirection.NORTH); // front
drawQuadRaw(v8, v7, v2, v1, ForgeDirection.SOUTH); // back
}
public static void drawCuboid(float xOffset, float yOffset, float zOffset, float xSize, float ySize, float zSize)
{
Vec3 v1, v2, v3, v4, v5, v6, v7, v8;
float x, y, z;
float x2, y2, z2;
x = xOffset;
y = yOffset;
z = zOffset;
x2 = x + xSize;
y2 = y + ySize;
z2 = z + zSize;
v1 = Vec3.createVectorHelper(x, y2, z2);
v2 = Vec3.createVectorHelper(x2, y2, z2);
v3 = Vec3.createVectorHelper(x2, y2, z);
v4 = Vec3.createVectorHelper(x, y2, z);
v5 = Vec3.createVectorHelper(x, y, z);
v6 = Vec3.createVectorHelper(x2, y, z);
v7 = Vec3.createVectorHelper(x2, y, z2);
v8 = Vec3.createVectorHelper(x, y, z2);
drawCuboidRaw(v1, v2, v3, v4, v5, v6, v7, v8);
}
public static void setTextureOffset(int xOffset, int yOffset)
{
texOffsetX = xOffset;
texOffsetY = yOffset;
}
public static void setGlobalTextureResolution(int width, int height)
{
gTexWidth = width;
gTexHeight = height;
}
public static void setTextureSubResolution(int width, int height)
{
sTexWidth = width;
sTexHeight = height;
}
/**
* Sets whether or not to clip the texture.
*
* @param clip If true, textures on blocks less than 1x1x1 will be clipped. If false, they will
* be scaled.
*/
public static void setTextureClip(boolean clip)
{
ModelHelper.clip = clip;
}
}

View file

@ -1,62 +0,0 @@
package assemblyline.client.model;
import static assemblyline.client.model.ModelHelper.*;
import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glScalef;
import static org.lwjgl.opengl.GL11.glTranslated;
import net.minecraft.client.model.ModelBase;
import net.minecraftforge.client.ForgeHooksClient;
import assemblyline.common.AssemblyLine;
import assemblyline.common.CommonProxy;
import assemblyline.common.machine.sensor.TileItemSensor;
public class ModelItemSensor extends ModelBase
{
public void render(TileItemSensor entity, double x, double y, double z)
{
glPushMatrix();
glTranslated(x, y, z);
ForgeHooksClient.bindTexture(AssemblyLine.TEXTURE_PATH + "sensor.png", 0);
setGlobalTextureResolution(128, 128);
setTextureClip(false);
ModelHelper.setTextureOffset(0, 64);
setTextureSubResolution(64, 64);
drawCuboid(0.45f, 12f/16f, 0.45f, 2f/16f, 4f/16f, 2f/16f); //stand
ModelHelper.setTextureOffset(0, 0);
setTextureSubResolution(128, 64);
drawCuboid(0.25f, 0.25f, 0.25f, 8f/16f, 8f/16f, 8f/16f); //block
ModelHelper.setTextureOffset(64, 64);
setTextureSubResolution(64, 32);
drawCuboid(0.375f, 0.25f - (1f/16f), 0.375f, 4f/16f, 1f/16f, 4f/16f); //lens
glPopMatrix();
}
public void render()
{
glPushMatrix();
glScalef(1.5f, 1.5f, 1.5f);
ForgeHooksClient.bindTexture(AssemblyLine.TEXTURE_PATH + "sensor.png", 0);
setGlobalTextureResolution(128, 128);
setTextureClip(false);
ModelHelper.setTextureOffset(0, 64);
setTextureSubResolution(64, 64);
drawCuboid(0.45f, 12f/16f, 0.45f, 2f/16f, 4f/16f, 2f/16f); //stand
ModelHelper.setTextureOffset(0, 0);
setTextureSubResolution(128, 64);
drawCuboid(0.25f, 0.25f, 0.25f, 8f/16f, 8f/16f, 8f/16f); //block
ModelHelper.setTextureOffset(64, 64);
setTextureSubResolution(64, 32);
drawCuboid(0.375f, 0.25f - (1f/16f), 0.375f, 4f/16f, 1f/16f, 4f/16f); //lens
glPopMatrix();
}
}

View file

@ -6,6 +6,7 @@ import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
import assemblyline.client.model.ModelConveyorBelt;
import assemblyline.client.model.ModelManipulator;
import assemblyline.client.model.ModelSorter;
@ -18,9 +19,9 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderHelper implements ISimpleBlockRenderingHandler
public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
{
public static RenderHelper instance = new RenderHelper();
public static BlockRenderingHandler instance = new BlockRenderingHandler();
public static final int BLOCK_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
private ModelConveyorBelt modelConveyorBelt = new ModelConveyorBelt();
private ModelSorter modelEjector = new ModelSorter();
@ -38,6 +39,10 @@ public class RenderHelper implements ISimpleBlockRenderingHandler
modelConveyorBelt.render(0.0625F, 0, false, false, false);
GL11.glPopMatrix();
}
if (block.blockID == AssemblyLine.blockDetector.blockID)
{
RenderDetector.render(false, new Vector3());
}
else if (block.blockID == AssemblyLine.blockMulti.blockID)
{
if (metadata == MachineType.REJECTOR.metadata)

View file

@ -0,0 +1,61 @@
package assemblyline.client.render;
import static assemblyline.client.model.ModelHelper.drawCuboid;
import static assemblyline.client.model.ModelHelper.setGlobalTextureResolution;
import static assemblyline.client.model.ModelHelper.setTextureClip;
import static assemblyline.client.model.ModelHelper.setTextureSubResolution;
import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glTranslated;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.ForgeHooksClient;
import universalelectricity.core.vector.Vector3;
import assemblyline.client.model.ModelHelper;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.detector.TileEntityDetector;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderDetector extends TileEntitySpecialRenderer
{
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
{
if (tileEntity instanceof TileEntityDetector)
{
this.render(((TileEntityDetector) tileEntity).isInverted(), new Vector3(x, y, z));
}
}
public static void render(boolean isInverted, Vector3 position)
{
glPushMatrix();
glTranslated(position.x, position.y, position.z);
if (isInverted)
{
ForgeHooksClient.bindTexture(AssemblyLine.TEXTURE_PATH + "detector_red.png", 0);
}
else
{
ForgeHooksClient.bindTexture(AssemblyLine.TEXTURE_PATH + "detector_green.png", 0);
}
setGlobalTextureResolution(128, 128);
setTextureClip(false);
ModelHelper.setTextureOffset(0, 64);
setTextureSubResolution(64, 64);
drawCuboid(0.45f, 12f / 16f, 0.45f, 2f / 16f, 4f / 16f, 2f / 16f); // stand
ModelHelper.setTextureOffset(0, 0);
setTextureSubResolution(128, 64);
drawCuboid(0.25f, 0.25f, 0.25f, 8f / 16f, 8f / 16f, 8f / 16f); // block
ModelHelper.setTextureOffset(64, 64);
setTextureSubResolution(64, 32);
drawCuboid(0.375f, 0.25f - (1f / 16f), 0.375f, 4f / 16f, 1f / 16f, 4f / 16f); // lens
glPopMatrix();
}
}

View file

@ -1,27 +0,0 @@
package assemblyline.client.render;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import assemblyline.client.model.ModelItemSensor;
import assemblyline.common.machine.sensor.TileItemSensor;
public class RenderItemSensor extends TileEntitySpecialRenderer
{
ModelItemSensor model;
public RenderItemSensor()
{
model = new ModelItemSensor();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
{
if (tileEntity instanceof TileItemSensor)
{
model.render((TileItemSensor) tileEntity, x, y, z);
}
}
}

View file

@ -21,7 +21,7 @@ public class RenderManipulator extends TileEntitySpecialRenderer
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glRotatef(180f, 0f, 0f, 1f);
if (tileEntity.isOutput)
if (tileEntity.isOutput())
{
this.bindTextureByName(AssemblyLine.TEXTURE_PATH + "manipulator1.png");
}

View file

@ -11,17 +11,20 @@ import net.minecraftforge.common.Configuration;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.UETab;
import universalelectricity.prefab.UpdateNotifier;
import universalelectricity.prefab.network.PacketManager;
import assemblyline.common.block.BlockCrate;
import assemblyline.common.block.BlockEngineerTable;
import assemblyline.common.block.BlockStamper;
import assemblyline.common.block.ItemBlockCrate;
import assemblyline.common.machine.BlockMulti;
import assemblyline.common.machine.BlockMulti.MachineType;
import assemblyline.common.machine.ItemBlockMulti;
import assemblyline.common.machine.belt.BlockConveyorBelt;
import assemblyline.common.machine.detector.BlockDetector;
import assemblyline.common.machine.filter.BlockStamper;
import assemblyline.common.machine.filter.ItemFilter;
import cpw.mods.fml.common.ICraftingHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
@ -48,7 +51,7 @@ public class AssemblyLine
public static final String NAME = "Assembly Line";
public static final String VERSION = "0.1.8";
public static final String VERSION = "0.1.9";
public static final String CHANNEL = "AssemblyLine";
@ -68,9 +71,10 @@ public class AssemblyLine
public static Block blockEngineerTable;
public static Block blockCrate;
public static Block blockStamper;
public static Block blockDetector;
public static final int ITEM_ID_PREFIX = 3030;
public static Item itemCrate;
public static Item itemFilter;
@PreInit
public void preInit(FMLPreInitializationEvent event)
@ -84,8 +88,9 @@ public class AssemblyLine
blockEngineerTable = new BlockEngineerTable(CONFIGURATION.getBlock("Architect's Table", BLOCK_ID_PREFIX + 2).getInt());
blockCrate = new BlockCrate(CONFIGURATION.getBlock("Crate", BLOCK_ID_PREFIX + 3).getInt(), 0);
blockStamper = new BlockStamper(CONFIGURATION.getBlock("Stamper", BLOCK_ID_PREFIX + 4).getInt(), 0);
blockDetector = new BlockDetector(CONFIGURATION.getBlock("Detector", BLOCK_ID_PREFIX + 5).getInt());
itemCrate = new ItemFilter(CONFIGURATION.getBlock("Filter", ITEM_ID_PREFIX).getInt());
itemFilter = new ItemFilter(CONFIGURATION.getBlock("Filter", ITEM_ID_PREFIX).getInt());
CONFIGURATION.save();
NetworkRegistry.instance().registerGuiHandler(this, this.proxy);
@ -93,6 +98,8 @@ public class AssemblyLine
GameRegistry.registerBlock(blockCrate, ItemBlockCrate.class, "Crate");
GameRegistry.registerBlock(blockMulti, ItemBlockMulti.class, "Machine");
GameRegistry.registerBlock(blockEngineerTable, "Engineer's Table");
GameRegistry.registerBlock(blockStamper, "Stamper");
GameRegistry.registerBlock(blockDetector, "Detector");
UpdateNotifier.INSTANCE.checkUpdate(NAME, VERSION, "http://calclavia.com/downloads/al/recommendedversion.txt");
@ -101,6 +108,7 @@ public class AssemblyLine
@Override
public void onCrafting(EntityPlayer player, ItemStack itemStack, IInventory craftMatrix)
{
// TODO Make this work for the filter
System.out.println("TEST: " + craftMatrix.getSizeInventory());
}
@ -110,6 +118,7 @@ public class AssemblyLine
}
});
proxy.preInit();
}
@ -118,40 +127,7 @@ public class AssemblyLine
{
proxy.init();
int languages = 0;
/**
* Load all languages.
*/
for (String language : LANGUAGES_SUPPORTED)
{
LanguageRegistry.instance().loadLocalization(LANGUAGE_PATH + language + ".properties", language, false);
if (LanguageRegistry.instance().getStringLocalization("children", language) != "")
{
try
{
String[] children = LanguageRegistry.instance().getStringLocalization("children", language).split(",");
for (String child : children)
{
if (child != "" || child != null)
{
LanguageRegistry.instance().loadLocalization(LANGUAGE_PATH + language + ".properties", child, false);
languages++;
}
}
languages++;
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
System.out.println(NAME + ": Loaded " + languages + " languages.");
System.out.println(NAME + " Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " languages.");
// Add Names
for (MachineType type : MachineType.values())
@ -173,10 +149,4 @@ public class AssemblyLine
UETab.setItemStack(new ItemStack(blockConveyorBelt));
}
public static String translateLocal(String string)
{
// TODO Auto-generated method stub
return null;
}
}

View file

@ -1,11 +0,0 @@
package assemblyline.common;
public class BlockSide
{
public static final int YMINUS = 0;
public static final int YPLUS = 1;
public static final int ZMINUS = 2;
public static final int ZPLUS = 3;
public static final int XMINUS = 4;
public static final int XPLUS = 5;
}

View file

@ -3,11 +3,15 @@ package assemblyline.common;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
import assemblyline.common.block.TileEntityCrate;
import assemblyline.common.machine.ContainerRejector;
import assemblyline.common.machine.TileEntityManipulator;
import assemblyline.common.machine.TileEntityRejector;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import assemblyline.common.machine.detector.ContainerDetector;
import assemblyline.common.machine.detector.TileEntityDetector;
import assemblyline.common.machine.filter.ContainerStamper;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
@ -16,9 +20,7 @@ public class CommonProxy implements IGuiHandler
public static final int GUI_REJECTOR = 0;
public static final int GUI_STAMPER = 1;
public static final int GUI_ARCHITECHT_TABLE = 2;
public static final int GUI_SENSOR = 3;
public static final int RENDER_SENSOR = 0;
public static final int GUI_DETECTOR = 3;
public void preInit()
{
@ -31,6 +33,7 @@ public class CommonProxy implements IGuiHandler
GameRegistry.registerTileEntity(TileEntityRejector.class, "ALSorter");
GameRegistry.registerTileEntity(TileEntityManipulator.class, "ALManipulator");
GameRegistry.registerTileEntity(TileEntityCrate.class, "ALCrate");
GameRegistry.registerTileEntity(TileEntityDetector.class, "ALDetector");
}
@Override
@ -45,7 +48,10 @@ public class CommonProxy implements IGuiHandler
case GUI_REJECTOR:
return new ContainerRejector(player.inventory, ((TileEntityRejector) tileEntity));
case GUI_STAMPER:
return new ContainerRejector(player.inventory, ((TileEntityRejector) tileEntity));
return new ContainerStamper(player.inventory, world, new Vector3(x, y, z));
case GUI_DETECTOR:
return new ContainerDetector(player.inventory, ((TileEntityDetector) tileEntity));
}
}

View file

@ -14,9 +14,8 @@ import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.UETab;
import universalelectricity.prefab.implement.IRedstoneReceptor;
import assemblyline.client.render.RenderHelper;
import assemblyline.common.AssemblyLine;
import cpw.mods.fml.common.network.PacketDispatcher;
import universalelectricity.prefab.multiblock.IBlockActivate;
import assemblyline.client.render.BlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -111,18 +110,16 @@ public class BlockMulti extends BlockMachine
}
@Override
public boolean onMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
{
if (!par1World.isRemote)
if (!world.isRemote)
{
int metadata = par1World.getBlockMetadata(x, y, z);
int guiID = MachineType.get(metadata).metadata;
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (guiID == -1) { return false; }
par5EntityPlayer.openGui(AssemblyLine.instance, guiID, par1World, x, y, z);
return true;
if (tileEntity instanceof IBlockActivate)
{
((IBlockActivate) tileEntity).onActivated(entityPlayer);
}
}
return true;
}
@ -168,12 +165,8 @@ public class BlockMulti extends BlockMachine
if (MachineType.get(metadata) == MachineType.MANIPULATOR)
{
TileEntityManipulator tileEntity = (TileEntityManipulator) par1World.getBlockTileEntity(x, y, z);
tileEntity.isOutput = !tileEntity.isOutput;
tileEntity.toggleOutput();
if (!par1World.isRemote)
{
PacketDispatcher.sendPacketToAllPlayers(tileEntity.getDescriptionPacket());
}
return true;
}
else
@ -231,7 +224,7 @@ public class BlockMulti extends BlockMachine
@Override
public int getRenderType()
{
return RenderHelper.BLOCK_RENDER_ID;
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
@Override

View file

@ -17,6 +17,7 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IRedstoneReceptor;
import universalelectricity.prefab.multiblock.IBlockActivate;
import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager;
import assemblyline.api.IManipulator;
@ -25,15 +26,39 @@ import assemblyline.common.machine.BlockMulti.MachineType;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityManipulator extends TileEntityAssemblyNetwork implements IRedstoneReceptor, IPacketReceiver, IManipulator
import cpw.mods.fml.common.network.PacketDispatcher;
public class TileEntityManipulator extends TileEntityAssemblyNetwork implements IRedstoneReceptor, IPacketReceiver, IManipulator, IBlockActivate
{
public boolean selfPulse = false;
/**
* Is the manipulator wrenched to turn into output mode?
*/
public boolean isOutput = false;
private boolean isOutput = false;
private boolean isRedstonePowered = false;
public boolean isOutput()
{
return this.isOutput;
}
public void setOutput(boolean isOutput)
{
this.isOutput = isOutput;
if (!this.worldObj.isRemote)
{
PacketDispatcher.sendPacketToAllPlayers(this.getDescriptionPacket());
}
}
public void toggleOutput()
{
this.setOutput(!this.isOutput());
}
@Override
protected void onUpdate()
{
@ -48,96 +73,116 @@ public class TileEntityManipulator extends TileEntityAssemblyNetwork implements
{
if (!this.isOutput)
{
/**
* Find items going into the manipulator and input them into an inventory behind
* this manipulator.
*/
Vector3 inputPosition = new Vector3(this);
Vector3 outputUp = new Vector3(this);
outputUp.modifyPositionFromSide(ForgeDirection.UP);
Vector3 outputDown = new Vector3(this);
outputDown.modifyPositionFromSide(ForgeDirection.DOWN);
Vector3 outputPosition = new Vector3(this);
outputPosition.modifyPositionFromSide(this.getBeltDirection().getOpposite());
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(inputPosition.x, inputPosition.y, inputPosition.z, inputPosition.x + 1, inputPosition.y + 1, inputPosition.z + 1);
List<EntityItem> itemsInBound = this.worldObj.getEntitiesWithinAABB(EntityItem.class, bounds);
for (EntityItem entity : itemsInBound)
{
/**
* Try top first, then bottom, then the sides to see if it is possible to
* insert the item into a inventory.
*/
ItemStack remainingStack = this.tryPlaceInPosition(entity.func_92014_d().copy(), outputUp, ForgeDirection.DOWN);
if (remainingStack != null)
{
remainingStack = this.tryPlaceInPosition(remainingStack, outputDown, ForgeDirection.UP);
}
if (remainingStack != null)
{
remainingStack = this.tryPlaceInPosition(remainingStack, outputPosition, this.getBeltDirection().getOpposite());
}
if (remainingStack != null && remainingStack.stackSize > 0)
{
this.rejectItem(outputPosition, remainingStack);
}
entity.setDead();
}
this.inject();
}
else
{
if (this.selfPulse && this.ticks % 10 == 0)
{
this.isRedstonePowered = true;
}
/**
* Finds the connected inventory and outputs the items upon a redstone pulse.
*/
if (this.isRedstonePowered)
{
this.onPowerOff();
Vector3 inputUp = new Vector3(this);
inputUp.modifyPositionFromSide(ForgeDirection.UP);
Vector3 inputDown = new Vector3(this);
inputDown.modifyPositionFromSide(ForgeDirection.DOWN);
Vector3 inputPosition = new Vector3(this);
inputPosition.modifyPositionFromSide(this.getBeltDirection().getOpposite());
Vector3 outputPosition = new Vector3(this);
outputPosition.modifyPositionFromSide(this.getBeltDirection());
ItemStack itemStack = this.tryGrabFromPosition(inputUp, ForgeDirection.DOWN);
if (itemStack == null)
{
itemStack = this.tryGrabFromPosition(inputDown, ForgeDirection.UP);
}
if (itemStack == null)
{
itemStack = this.tryGrabFromPosition(inputPosition, this.getBeltDirection().getOpposite());
}
if (itemStack != null)
{
if (itemStack.stackSize > 0)
{
this.rejectItem(outputPosition, itemStack);
}
}
this.eject();
}
}
}
}
}
/**
* Find items going into the manipulator and input them into an inventory behind this
* manipulator.
*/
@Override
public void inject()
{
Vector3 inputPosition = new Vector3(this);
Vector3 outputUp = new Vector3(this);
outputUp.modifyPositionFromSide(ForgeDirection.UP);
Vector3 outputDown = new Vector3(this);
outputDown.modifyPositionFromSide(ForgeDirection.DOWN);
Vector3 outputPosition = new Vector3(this);
outputPosition.modifyPositionFromSide(this.getBeltDirection().getOpposite());
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(inputPosition.x, inputPosition.y, inputPosition.z, inputPosition.x + 1, inputPosition.y + 1, inputPosition.z + 1);
List<EntityItem> itemsInBound = this.worldObj.getEntitiesWithinAABB(EntityItem.class, bounds);
for (EntityItem entity : itemsInBound)
{
/**
* Try top first, then bottom, then the sides to see if it is possible to insert the
* item into a inventory.
*/
ItemStack remainingStack = this.tryPlaceInPosition(entity.func_92014_d().copy(), outputUp, ForgeDirection.DOWN);
if (remainingStack != null)
{
remainingStack = this.tryPlaceInPosition(remainingStack, outputDown, ForgeDirection.UP);
}
if (remainingStack != null)
{
remainingStack = this.tryPlaceInPosition(remainingStack, outputPosition, this.getBeltDirection().getOpposite());
}
if (remainingStack != null && remainingStack.stackSize > 0)
{
this.throwItem(outputPosition, remainingStack);
}
entity.setDead();
}
}
/**
* Injects items
*/
@Override
public void eject()
{
this.onPowerOff();
Vector3 inputUp = new Vector3(this);
inputUp.modifyPositionFromSide(ForgeDirection.UP);
Vector3 inputDown = new Vector3(this);
inputDown.modifyPositionFromSide(ForgeDirection.DOWN);
Vector3 inputPosition = new Vector3(this);
inputPosition.modifyPositionFromSide(this.getBeltDirection().getOpposite());
Vector3 outputPosition = new Vector3(this);
outputPosition.modifyPositionFromSide(this.getBeltDirection());
ItemStack itemStack = this.tryGrabFromPosition(inputUp, ForgeDirection.DOWN);
if (itemStack == null)
{
itemStack = this.tryGrabFromPosition(inputDown, ForgeDirection.UP);
}
if (itemStack == null)
{
itemStack = this.tryGrabFromPosition(inputPosition, this.getBeltDirection().getOpposite());
}
if (itemStack != null)
{
if (itemStack.stackSize > 0)
{
this.throwItem(outputPosition, itemStack);
}
}
}
@Override
public Packet getDescriptionPacket()
{
@ -167,7 +212,7 @@ public class TileEntityManipulator extends TileEntityAssemblyNetwork implements
* @param outputPosition
* @param items
*/
public void rejectItem(Vector3 outputPosition, ItemStack items)
public void throwItem(Vector3 outputPosition, ItemStack items)
{
EntityItem entityItem = new EntityItem(worldObj, outputPosition.x + 0.5, outputPosition.y + 0.8, outputPosition.z + 0.5, items);
entityItem.motionX = 0;
@ -407,4 +452,11 @@ public class TileEntityManipulator extends TileEntityAssemblyNetwork implements
{
this.isRedstonePowered = false;
}
@Override
public boolean onActivated(EntityPlayer entityPlayer)
{
this.selfPulse = !this.selfPulse;
return true;
}
}

View file

@ -16,9 +16,11 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.multiblock.IBlockActivate;
import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager;
import assemblyline.common.AssemblyLine;
import assemblyline.common.CommonProxy;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import com.google.common.io.ByteArrayDataInput;
@ -30,7 +32,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
* @author Darkguardsman
*
*/
public class TileEntityRejector extends TileEntityAssemblyNetwork implements IPacketReceiver, IInventory
public class TileEntityRejector extends TileEntityAssemblyNetwork implements IPacketReceiver, IInventory, IBlockActivate
{
/**
* The items this container contains.
@ -450,4 +452,11 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IPa
{
return 1;
}
@Override
public boolean onActivated(EntityPlayer entityPlayer)
{
entityPlayer.openGui(AssemblyLine.instance, CommonProxy.GUI_REJECTOR, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
return true;
}
}

View file

@ -11,7 +11,7 @@ import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.UETab;
import assemblyline.client.render.RenderHelper;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.machine.belt.TileEntityConveyorBelt.SlantType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -185,7 +185,7 @@ public class BlockConveyorBelt extends BlockMachine
@Override
public int getRenderType()
{
return RenderHelper.BLOCK_RENDER_ID;
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
@Override

View file

@ -1,222 +1,221 @@
package assemblyline.common.machine.sensor;
import java.util.Random;
import assemblyline.client.ClientProxy;
import assemblyline.common.AssemblyLine;
import assemblyline.common.BlockSide;
import assemblyline.common.CommonProxy;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public class BlockItemSensor extends BlockContainer
{
private Random random = new Random();
public BlockItemSensor(int blockID, Material material)
{
super(blockID, material);
this.blockIndexInTexture = 0;
setBlockBounds(0.25f, 0, 0.25f, 0.75f, 0.75f, 0.75f);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking())
{
return false;
}
if (tileEntity instanceof TileItemSensor)
{
player.openGui(AssemblyLine.instance, ClientProxy.GUI_SENSOR, world, x, y, z);
return true;
}
return false;
}
/*@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entity)
{
if (entity instanceof EntityPlayer)
{
world.notifyBlocksOfNeighborChange(x + 1, y, z, blockID);
world.notifyBlocksOfNeighborChange(x - 1, y, z, blockID);
world.notifyBlocksOfNeighborChange(x, y, z + 1, blockID);
world.notifyBlocksOfNeighborChange(x, y, z - 1, blockID);
}
}*/
@Override
public void breakBlock(World world, int x, int y, int z, int int1, int int2)
{
TileItemSensor te = (TileItemSensor) world.getBlockTileEntity(x, y, z);
if (te != null)
{
for (int i = 0; i < te.getSizeInventory(); ++i)
{
ItemStack stack = te.getStackInSlot(i);
if (stack != null)
{
float xShift = this.random.nextFloat() * 0.8F + 0.1F;
float yShift = this.random.nextFloat() * 0.8F + 0.1F;
EntityItem eI;
for (float zShift = this.random.nextFloat() * 0.8F + 0.1F; stack.stackSize > 0; world.spawnEntityInWorld(eI))
{
int count = this.random.nextInt(21) + 10;
if (count > stack.stackSize)
{
count = stack.stackSize;
}
stack.stackSize -= count;
eI = new EntityItem(world, (double) ((float) x + xShift), (double) ((float) y + yShift), (double) ((float) z + zShift), new ItemStack(stack.itemID, count, stack.getItemDamage()));
float var15 = 0.05F;
eI.motionX = (double) ((float) this.random.nextGaussian() * var15);
eI.motionY = (double) ((float) this.random.nextGaussian() * var15 + 0.2F);
eI.motionZ = (double) ((float) this.random.nextGaussian() * var15);
if (stack.hasTagCompound())
{
eI.func_92014_d().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
}
}
}
}
}
super.breakBlock(world, x, y, z, int1, int2);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
{
if (!canBlockStay(world, x, y, z))
{
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockWithNotify(x, y, z, 0);
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess par1iBlockAccess, int par2, int par3, int par4)
{
setBlockBounds(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f);
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side)
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return CommonProxy.RENDER_SENSOR;
}
@Override
public String getTextureFile()
{
return AssemblyLine.BLOCK_TEXTURE_PATH;
}
@Override
public void onEntityWalking(World world, int x, int y, int z, Entity entity)
{
onEntityCollidedWithBlock(world, x, y, z, entity);
}
@Override
public boolean isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int direction)
{
if (direction == BlockSide.YMINUS)
{
TileEntity te = world.getBlockTileEntity(x, y, z);
if (te != null)
{
if (te instanceof TileItemSensor)
{
TileItemSensor tis = (TileItemSensor) te;
if (tis.isPowering())
return true;
}
}
}
return false;
}
@Override
public boolean isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int direction)
{
if (direction != BlockSide.YMINUS && direction != BlockSide.YPLUS)
{
TileEntity te = world.getBlockTileEntity(x, y, z);
if (te != null)
{
if (te instanceof TileItemSensor)
{
TileItemSensor tis = (TileItemSensor) te;
if (tis.isPowering())
return true;
}
}
}
return false;
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
if (world.isBlockSolidOnSide(x, y + 1, z, ForgeDirection.DOWN))
return true;
return false;
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
return canBlockStay(world, x, y, z);
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileItemSensor();
}
}
package assemblyline.common.machine.detector;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.UETab;
import assemblyline.client.ClientProxy;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.AssemblyLine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* @author Briman0094
*/
public class BlockDetector extends BlockMachine
{
private Random random = new Random();
public BlockDetector(int blockID)
{
super("detector", blockID, UniversalElectricity.machine, UETab.INSTANCE);
this.setBlockBounds(0.25f, 0, 0.25f, 0.75f, 0.75f, 0.75f);
}
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity != null)
{
if (tileEntity instanceof TileEntityDetector)
{
player.openGui(AssemblyLine.instance, ClientProxy.GUI_DETECTOR, world, x, y, z);
return true;
}
}
return false;
}
@Override
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity != null)
{
if (tileEntity instanceof TileEntityDetector)
{
((TileEntityDetector) tileEntity).toggleInversion();
}
}
return true;
}
/*
* @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entity)
* { if (entity instanceof EntityPlayer) { world.notifyBlocksOfNeighborChange(x + 1, y, z,
* blockID); world.notifyBlocksOfNeighborChange(x - 1, y, z, blockID);
* world.notifyBlocksOfNeighborChange(x, y, z + 1, blockID);
* world.notifyBlocksOfNeighborChange(x, y, z - 1, blockID); } }
*/
@Override
public void breakBlock(World world, int x, int y, int z, int int1, int int2)
{
TileEntityDetector te = (TileEntityDetector) world.getBlockTileEntity(x, y, z);
if (te != null)
{
for (int i = 0; i < te.getSizeInventory(); ++i)
{
ItemStack stack = te.getStackInSlot(i);
if (stack != null)
{
float xShift = this.random.nextFloat() * 0.8F + 0.1F;
float yShift = this.random.nextFloat() * 0.8F + 0.1F;
EntityItem eI;
for (float zShift = this.random.nextFloat() * 0.8F + 0.1F; stack.stackSize > 0; world.spawnEntityInWorld(eI))
{
int count = this.random.nextInt(21) + 10;
if (count > stack.stackSize)
{
count = stack.stackSize;
}
stack.stackSize -= count;
eI = new EntityItem(world, (double) ((float) x + xShift), (double) ((float) y + yShift), (double) ((float) z + zShift), new ItemStack(stack.itemID, count, stack.getItemDamage()));
float var15 = 0.05F;
eI.motionX = (double) ((float) this.random.nextGaussian() * var15);
eI.motionY = (double) ((float) this.random.nextGaussian() * var15 + 0.2F);
eI.motionZ = (double) ((float) this.random.nextGaussian() * var15);
if (stack.hasTagCompound())
{
eI.func_92014_d().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
}
}
}
}
}
super.breakBlock(world, x, y, z, int1, int2);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
{
if (!canBlockStay(world, x, y, z))
{
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockWithNotify(x, y, z, 0);
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess par1iBlockAccess, int par2, int par3, int par4)
{
setBlockBounds(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f);
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side)
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType()
{
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
@Override
public void onEntityWalking(World world, int x, int y, int z, Entity entity)
{
onEntityCollidedWithBlock(world, x, y, z, entity);
}
@Override
public boolean isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int direction)
{
if (direction == ForgeDirection.DOWN.ordinal())
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity != null)
{
if (tileEntity instanceof TileEntityDetector) { return ((TileEntityDetector) tileEntity).isPoweringTo(ForgeDirection.getOrientation(direction)); }
}
}
return false;
}
@Override
public boolean isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int direction)
{
if (direction != ForgeDirection.DOWN.ordinal() && direction != ForgeDirection.UP.ordinal())
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity != null)
{
if (tileEntity instanceof TileEntityDetector) { return ((TileEntityDetector) tileEntity).isPoweringTo(ForgeDirection.getOrientation(direction)); }
}
}
return false;
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
if (world.isBlockSolidOnSide(x, y + 1, z, ForgeDirection.DOWN))
return true;
return false;
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
return canBlockStay(world, x, y, z);
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileEntityDetector();
}
}

View file

@ -0,0 +1,79 @@
package assemblyline.common.machine.detector;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerDetector extends Container
{
protected TileEntityDetector tileEntity;
private int numRows = 3;
public ContainerDetector(InventoryPlayer inventoryPlayer, TileEntityDetector tileEntity)
{
this.tileEntity = tileEntity;
int var3 = (numRows - 4) * 18;
int x;
int y;
for (x = 0; x < numRows; ++x)
{
for (y = 0; y < 9; ++y)
{
this.addSlotToContainer(new Slot(tileEntity, y + x * 9, 8 + y * 18, 18 + x * 18));
}
}
for (x = 0; x < 3; ++x)
{
for (y = 0; y < 9; ++y)
{
this.addSlotToContainer(new Slot(inventoryPlayer, y + x * 9 + 9, 8 + y * 18, 103 + x * 18 + var3));
}
}
for (x = 0; x < 9; ++x)
{
this.addSlotToContainer(new Slot(inventoryPlayer, x, 8 + x * 18, 161 + var3));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
{
ItemStack var3 = null;
Slot var4 = (Slot) this.inventorySlots.get(par2);
if (var4 != null && var4.getHasStack())
{
ItemStack var5 = var4.getStack();
var3 = var5.copy();
if (par2 < this.numRows * 9)
{
if (!this.mergeItemStack(var5, this.numRows * 9, this.inventorySlots.size(), true)) { return null; }
}
else if (!this.mergeItemStack(var5, 0, this.numRows * 9, false)) { return null; }
if (var5.stackSize == 0)
{
var4.putStack((ItemStack) null);
}
else
{
var4.onSlotChanged();
}
}
return var3;
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return tileEntity.isUseableByPlayer(player);
}
}

View file

@ -0,0 +1,346 @@
package assemblyline.common.machine.detector;
import java.util.ArrayList;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.implement.IRedstoneProvider;
import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager;
import assemblyline.common.AssemblyLine;
public class TileEntityDetector extends TileEntity implements IInventory, IRedstoneProvider, IPacketReceiver
{
private boolean powering = false;
private boolean isInverted = false;
private ItemStack[] containingItems = new ItemStack[27];
@Override
public void updateEntity()
{
int metadata = this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord) & 3;
AxisAlignedBB testArea = AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord - 1, this.yCoord, this.xCoord + 1, this.yCoord, this.zCoord + 1);
ArrayList<Entity> entities = (ArrayList<Entity>) this.worldObj.getEntitiesWithinAABB(EntityItem.class, testArea);
boolean powerCheck = false;
if (entities.size() > 0)
{
if (hasItems())
{
for (int i = 0; i < entities.size(); i++)
{
EntityItem e = (EntityItem) entities.get(i);
ItemStack item = e.func_92014_d();
boolean tFound = false;
for (int ii = 0; ii < this.containingItems.length; ii++)
{
ItemStack compare = this.containingItems[ii];
if (compare != null)
{
if (this.isInverted)
{
if (item.itemID == compare.itemID)
{
if (item.getItemDamage() == compare.getItemDamage())
{
if (item.hasTagCompound())
{
if (item.getTagCompound().equals(compare.getTagCompound()))
{
tFound = true;
break;
}
}
else
{
tFound = true;
break;
}
}
}
}
else
{
if (item.itemID == compare.itemID)
{
if (item.getItemDamage() == compare.getItemDamage())
{
if (item.hasTagCompound())
{
if (item.getTagCompound().equals(compare.getTagCompound()))
{
powerCheck = true;
break;
}
}
else
{
powerCheck = true;
break;
}
}
}
}
}
}
if (this.isInverted)
{
if (!tFound)
{
powerCheck = true;
break;
}
}
}
}
else
{
powerCheck = true;
}
}
else
{
powerCheck = false;
}
if (powerCheck != this.powering)
{
this.powering = powerCheck;
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, AssemblyLine.blockDetector.blockID);
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord + 1, this.zCoord, AssemblyLine.blockDetector.blockID);
for (int x = this.xCoord - 1; x <= this.xCoord + 1; x++)
{
for (int z = this.zCoord - 1; z <= this.zCoord + 1; z++)
{
this.worldObj.notifyBlocksOfNeighborChange(x, this.yCoord + 1, z, AssemblyLine.blockDetector.blockID);
}
}
}
}
public boolean hasItems()
{
for (int i = 0; i < this.containingItems.length; i++)
{
if (this.containingItems[i] != null) { return true; }
}
return false;
}
public boolean isInverted()
{
return isInverted;
}
public void setInversion(boolean inverted)
{
this.isInverted = inverted;
if (this.worldObj.isRemote)
{
PacketManager.sendPacketToClients(this.getDescriptionPacket());
}
}
public void toggleInversion()
{
this.setInversion(!this.isInverted);
}
@Override
public Packet getDescriptionPacket()
{
return PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.isInverted);
}
@Override
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
{
if (this.worldObj.isRemote)
{
try
{
this.isInverted = dataStream.readBoolean();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
NBTTagList itemList = tag.getTagList("Items");
this.containingItems = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < itemList.tagCount(); ++i)
{
NBTTagCompound itemAt = (NBTTagCompound) itemList.tagAt(i);
int itemSlot = itemAt.getByte("Slot") & 255;
if (itemSlot >= 0 && itemSlot < this.containingItems.length)
{
this.containingItems[itemSlot] = ItemStack.loadItemStackFromNBT(itemAt);
}
}
this.isInverted = tag.getBoolean("isInverted");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < this.containingItems.length; ++i)
{
if (this.containingItems[i] != null)
{
NBTTagCompound itemAt = new NBTTagCompound();
itemAt.setByte("Slot", (byte) i);
this.containingItems[i].writeToNBT(itemAt);
itemList.appendTag(itemAt);
}
}
tag.setTag("Items", itemList);
tag.setBoolean("isInverted", this.isInverted);
}
@Override
public int getSizeInventory()
{
return 27;
}
@Override
public ItemStack getStackInSlot(int slot)
{
return containingItems[slot];
}
@Override
public ItemStack decrStackSize(int slot, int amount)
{
if (this.containingItems[slot] != null)
{
ItemStack var3;
if (this.containingItems[slot].stackSize <= amount)
{
var3 = this.containingItems[slot];
this.containingItems[slot] = null;
this.onInventoryChanged();
return var3;
}
else
{
var3 = this.containingItems[slot].splitStack(amount);
if (this.containingItems[slot].stackSize == 0)
{
this.containingItems[slot] = null;
}
this.onInventoryChanged();
return var3;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
if (this.containingItems[slot] != null)
{
ItemStack var2 = this.containingItems[slot];
this.containingItems[slot] = null;
return var2;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack)
{
this.containingItems[slot] = stack;
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
{
stack.stackSize = this.getInventoryStackLimit();
}
this.onInventoryChanged();
}
@Override
public String getInvName()
{
return TranslationHelper.getLocal("tile.detector.name");
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player)
{
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D;
}
@Override
public void openChest()
{
}
@Override
public void closeChest()
{
}
@Override
public boolean isPoweringTo(ForgeDirection side)
{
return this.powering;
}
@Override
public boolean isIndirectlyPoweringTo(ForgeDirection side)
{
return this.isPoweringTo(side);
}
}

View file

@ -1,4 +1,4 @@
package assemblyline.common.block;
package assemblyline.common.machine.filter;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

View file

@ -1,4 +1,4 @@
package assemblyline.common.machine;
package assemblyline.common.machine.filter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;

View file

@ -1,4 +1,4 @@
package assemblyline.common;
package assemblyline.common.machine.filter;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,100 +0,0 @@
package assemblyline.common.machine.sensor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerItemSensor extends Container
{
protected TileItemSensor tileEntity;
public ContainerItemSensor(InventoryPlayer inventoryPlayer, TileItemSensor te)
{
tileEntity = te;
int numRows = 3;
int var3 = (numRows - 4) * 18;
int x;
int y;
for (x = 0; x < numRows; ++x)
{
for (y = 0; y < 9; ++y)
{
this.addSlotToContainer(new Slot(te, y + x * 9, 8 + y * 18, 18 + x * 18));
}
}
for (x = 0; x < 3; ++x)
{
for (y = 0; y < 9; ++y)
{
this.addSlotToContainer(new Slot(inventoryPlayer, y + x * 9 + 9, 8 + y * 18, 103 + x * 18 + var3));
}
}
for (x = 0; x < 9; ++x)
{
this.addSlotToContainer(new Slot(inventoryPlayer, x, 8 + x * 18, 161 + var3));
}
}
public ItemStack func_82846_b(EntityPlayer player, int slotNum)
{
ItemStack stack = null;
Slot slot = (Slot)this.inventorySlots.get(slotNum);
if (slot != null && slot.getHasStack())
{
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotNum < 3 * 9)
{
if (!this.mergeItemStack(slotStack, 3 * 9, this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(slotStack, 0, 3 * 9, false))
{
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
}
return stack;
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return tileEntity.isUseableByPlayer(player);
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 9; j++)
{
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; i++)
{
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
}
}
}

View file

@ -1,328 +0,0 @@
package assemblyline.common.machine.sensor;
import java.util.ArrayList;
import assemblyline.common.AssemblyLine;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
public class TileItemSensor extends TileEntity implements IInventory
{
private boolean powering;
private boolean invertItemCheck;
private ItemStack[] iContents = new ItemStack[27];
public TileItemSensor()
{
powering = false;
}
public boolean hasItems()
{
for (int i = 0; i < iContents.length; i++)
{
if (iContents[i] != null)
{
return true;
}
}
return false;
}
@Override
public void updateEntity()
{
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) & 3;
AxisAlignedBB testArea = AxisAlignedBB.getBoundingBox(xCoord, yCoord - 1, zCoord, xCoord + 1, yCoord, zCoord + 1);
ArrayList<Entity> entities = (ArrayList<Entity>) worldObj.getEntitiesWithinAABB(EntityItem.class, testArea);
boolean tPowering = false;
if (entities.size() > 0)
{
if (hasItems())
{
for (int i = 0; i < entities.size(); i++)
{
EntityItem e = (EntityItem) entities.get(i);
ItemStack item = e.func_92014_d();
boolean tFound = false;
for (int ii = 0; ii < iContents.length; ii++)
{
ItemStack compare = iContents[ii];
if (compare != null)
{
if (invertItemCheck)
{
if (item.itemID == compare.itemID)
{
if (item.getItemDamage() == compare.getItemDamage())
{
if (item.hasTagCompound())
{
if (item.getTagCompound().equals(compare.getTagCompound()))
{
tFound = true;
break;
}
}
else
{
tFound = true;
break;
}
}
}
}
else
{
if (item.itemID == compare.itemID)
{
if (item.getItemDamage() == compare.getItemDamage())
{
if (item.hasTagCompound())
{
if (item.getTagCompound().equals(compare.getTagCompound()))
{
tPowering = true;
break;
}
}
else
{
tPowering = true;
break;
}
}
}
}
}
}
if (invertItemCheck)
{
if (!tFound)
{
tPowering = true;
break;
}
}
}
}
else
{
tPowering = true;
}
}
else
{
tPowering = false;
}
if (tPowering != powering)
{
powering = tPowering;
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, AssemblyLine.blockSensor.blockID);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, AssemblyLine.blockSensor.blockID);
for (int x = xCoord - 1; x <= xCoord + 1; x++)
{
for (int z = zCoord - 1; z <= zCoord + 1; z++)
{
worldObj.notifyBlocksOfNeighborChange(x, yCoord + 1, z, AssemblyLine.blockSensor.blockID);
}
}
}
}
public boolean isPowering()
{
return powering;
}
public boolean isItemCheckInverted()
{
return invertItemCheck;
}
public void setItemCheckInverted(boolean inverted)
{
invertItemCheck = inverted;
}
@Override
public Packet getDescriptionPacket()
{
Packet132TileEntityData pack = new Packet132TileEntityData();
pack.xPosition = xCoord;
pack.yPosition = yCoord;
pack.zPosition = zCoord;
pack.actionType = 0;
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
pack.customParam1 = tag;
return pack;
}
@Override
public void onDataPacket(INetworkManager netManager, Packet132TileEntityData packet)
{
super.onDataPacket(netManager, packet);
readFromNBT(packet.customParam1);
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
NBTTagList itemList = tag.getTagList("Items");
this.iContents = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < itemList.tagCount(); ++i)
{
NBTTagCompound itemAt = (NBTTagCompound) itemList.tagAt(i);
int itemSlot = itemAt.getByte("Slot") & 255;
if (itemSlot >= 0 && itemSlot < this.iContents.length)
{
this.iContents[itemSlot] = ItemStack.loadItemStackFromNBT(itemAt);
}
}
invertItemCheck = tag.getBoolean("inverted");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < this.iContents.length; ++i)
{
if (this.iContents[i] != null)
{
NBTTagCompound itemAt = new NBTTagCompound();
itemAt.setByte("Slot", (byte) i);
this.iContents[i].writeToNBT(itemAt);
itemList.appendTag(itemAt);
}
}
tag.setTag("Items", itemList);
tag.setBoolean("inverted", invertItemCheck);
}
@Override
public int getSizeInventory()
{
return 27;
}
@Override
public ItemStack getStackInSlot(int slot)
{
return iContents[slot];
}
@Override
public ItemStack decrStackSize(int slot, int amount)
{
if (this.iContents[slot] != null)
{
ItemStack var3;
if (this.iContents[slot].stackSize <= amount)
{
var3 = this.iContents[slot];
this.iContents[slot] = null;
this.onInventoryChanged();
return var3;
}
else
{
var3 = this.iContents[slot].splitStack(amount);
if (this.iContents[slot].stackSize == 0)
{
this.iContents[slot] = null;
}
this.onInventoryChanged();
return var3;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
if (this.iContents[slot] != null)
{
ItemStack var2 = this.iContents[slot];
this.iContents[slot] = null;
return var2;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack)
{
this.iContents[slot] = stack;
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
{
stack.stackSize = this.getInventoryStackLimit();
}
this.onInventoryChanged();
}
@Override
public String getInvName()
{
return "container.itemSensor";
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player)
{
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D;
}
@Override
public void openChest()
{
}
@Override
public void closeChest()
{
}
}

View file

@ -0,0 +1,81 @@
package universalelectricity.prefab;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.registry.LanguageRegistry;
/**
* A class to help you out with translations.
*
* @author Calclavia
*
*/
public class TranslationHelper
{
/**
* Loads all the language files for a mod. This supports the loading of "child" language files
* for sub-languages to be loaded all from one file instead of creating multiple of them. An
* example of this usage would be different Spanish sub-translations (es_MX, es_YU).
*
* @param languagePath - The path to the mod's language file folder.
* @param languageSupported - The languages supported. E.g: new String[]{"en_US", "en_AU",
* "en_UK"}
* @return The amount of language files loaded successfully.
*/
public static int loadLanguages(String languagePath, String[] languageSupported)
{
int languages = 0;
/**
* Load all languages.
*/
for (String language : languageSupported)
{
LanguageRegistry.instance().loadLocalization(languagePath + language + ".properties", language, false);
if (LanguageRegistry.instance().getStringLocalization("children", language) != "")
{
try
{
String[] children = LanguageRegistry.instance().getStringLocalization("children", language).split(",");
for (String child : children)
{
if (child != "" || child != null)
{
LanguageRegistry.instance().loadLocalization(languagePath + language + ".properties", child, false);
languages++;
}
}
}
catch (Exception e)
{
FMLLog.severe("Failed to load a child language file.");
e.printStackTrace();
}
}
languages++;
}
return languages;
}
/**
* Gets the local text of your translation based on the given key. This will look through your
* mod's translation file that was previously registered. Make sure you enter the full name
*
* @param key - e.g tile.block.name
* @return The translated string or the default English translation if none was found.
*/
public static String getLocal(String key)
{
String text = LanguageRegistry.instance().getStringLocalization(key);
if (text == null || text == "")
{
text = LanguageRegistry.instance().getStringLocalization(key, "en_US");
}
return text;
}
}