This commit is contained in:
jaredlll08 committed 2015-08-31 19:08:46 +02:00
1 parent fd17ded261
commit 54ec75fd3d
11 files changed
+872 -571

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -14,17 +14,17 @@ import stanhebben.zenscript.annotations.ZenOperator;
import stanhebben.zenscript.annotations.ZenSetter;
/**
* Contains an item stack. An item stack consists of an item definition,
* a meta or damage value and NBT data.
* Contains an item stack. An item stack consists of an item definition, a meta
* or damage value and NBT data.
*
* Item stacks can be retrieved using its name (or ID, in 1.6.4) with the bracket
* syntax. When using the bracket syntax, by default, the item stack will match
* any size when used as ingredient. Item stacks can be multiplied with an integer
* to create a stack of different size.
* Item stacks can be retrieved using its name (or ID, in 1.6.4) with the
* bracket syntax. When using the bracket syntax, by default, the item stack
* will match any size when used as ingredient. Item stacks can be multiplied
* with an integer to create a stack of different size.
*
* Item stacks are immutable. You can, however, easily create modified stacks using
* the helper methods. Adding conditions and transformations will turn the item
* stack into an ingredients.
* Item stacks are immutable. You can, however, easily create modified stacks
* using the helper methods. Adding conditions and transformations will turn the
* item stack into an ingredients.
*
* @author Stan Hebben
*/
@@ -37,7 +37,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenGetter("definition")
public IItemDefinition getDefinition();
/**
* Gets the unlocalized item name.
*
@@ -45,7 +45,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenGetter("name")
public String getName();
/**
* Gets the display name. By default, it is the localized item name, but
* could also be the display name from NBT data, or another item-specific
@@ -55,7 +55,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenGetter("displayName")
public String getDisplayName();
/**
* Sets the display name. Only works if the name is translatable. Does not
* override names set by NBT data or using item-specific logic.
@@ -64,15 +64,15 @@ public interface IItemStack extends IIngredient {
*/
@ZenSetter("displayName")
public void setDisplayName(String name);
/**
* Gets the max stack size for an item
*
* @return int max stack size
*/
@ZenGetter
@ZenGetter("maxStackSize")
public int getMaxStackSize();
/**
* Sets the ItemStack max stack size.
*
@@ -80,7 +80,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenSetter("maxStackSize")
public void setMaxStackSize(int size);
/**
* Gets the item damage. Returns 0 if the item cannot be damaged.
*
@@ -88,7 +88,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenGetter("damage")
public int getDamage();
/**
* Gets the maximum item damage. Returns 0 if the item cannot be damaged.
*
@@ -96,7 +96,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenGetter("maxDamage")
public int getMaxDamage();
/**
* Gets the item tag. (NBT data) The resulting data is immutable and can
* only be changed with updateTag. Returns empty data if there is no data.
@@ -106,17 +106,17 @@ public interface IItemStack extends IIngredient {
*/
@ZenGetter("tag")
public IData getTag();
/**
* Gets the liquid contained in this item, if any. If this item stack is not
* an item container, it returns null. Only returns the amount of liquid
* in a single item and doesn't into account stack size.
* an item container, it returns null. Only returns the amount of liquid in
* a single item and doesn't into account stack size.
*
* @return liquid data
*/
@ZenGetter("liquid")
public ILiquidStack getLiquid();
/**
* Creates a new item stack with a different stack size.
*
@@ -126,7 +126,7 @@ public interface IItemStack extends IIngredient {
@ZenOperator(OperatorType.MUL)
@ZenMethod
public IItemStack amount(int amount);
/**
* Creates a weighted item stack with the given percentage chance. Does the
* same as item.weight(p * 0.01).
@@ -136,7 +136,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenOperator(OperatorType.MOD)
public WeightedItemStack percent(float p);
/**
* Creates a weighted item stack with the given weight.
*
@@ -145,7 +145,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenMethod
public WeightedItemStack weight(float p);
/**
* Creates an item stack with the same item and stack size, but accepting
* any damage value. Only useful for items used as ingredients.
@@ -154,7 +154,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenMethod
public IIngredient anyDamage();
/**
* Creates an item stack with the specified damage.
*
@@ -163,7 +163,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenMethod
public IItemStack withDamage(int damage);
/**
* Creates an item stack with the specified stack size.
*
@@ -172,7 +172,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenMethod
public IItemStack withAmount(int amount);
/**
* Creates an item stack with wildcard stack size.
*
@@ -180,7 +180,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenMethod
public IItemStack anyAmount();
/**
* Creates an item stack with the given nbt tag. Ignores existing tags.
*
@@ -189,7 +189,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenMethod
public IItemStack withTag(IData tag);
/**
* Creates an item stack with updated nbt tag. Updates existing tags.
*
@@ -198,7 +198,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenMethod
public IItemStack updateTag(IData tagUpdate);
/**
* Converts this item stack into a block.
*
@@ -206,7 +206,7 @@ public interface IItemStack extends IIngredient {
*/
@ZenCaster
public IBlock asBlock();
/**
* Retrieves all the ores referring to this item. Includes wildcard ore
* entries.
+295
View File
@@ -0,0 +1,295 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="NOVA" version="12">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" 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.insert_new_line_in_empty_annotation_declaration" 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.insert_space_before_at_in_annotation_type_declaration" 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_space_after_comma_in_constructor_declaration_parameters" 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_new_line_after_annotation_on_package" value="insert"/>
<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.blank_lines_after_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<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_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" 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.insert_space_after_comma_in_type_arguments" value="insert"/>
<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.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="0"/>
<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.comment.indent_root_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
<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_parenthesized_expression_in_return" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="0"/>
<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.keep_then_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" 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.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="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_after_opening_paren_in_catch" value="do not 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_new_line_after_annotation_on_method" value="insert"/>
<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_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<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.never_indent_line_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not 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_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
<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_opening_brace_in_enum_constant" value="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_space_after_assignment_operator" value="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_opening_paren_in_for" 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_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
<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.alignment_for_union_type_in_multicatch" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
<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_after_closing_angle_bracket_in_type_arguments" 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.alignment_for_binary_expression" value="0"/>
<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_before_comma_in_array_initializer" 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_comma_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="0"/>
<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_after_comma_in_superinterfaces" 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_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<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_paren_in_catch" value="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.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
<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_before_catch_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" 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.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<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_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<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_after_colon_in_assert" value="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.insert_space_before_comma_in_type_arguments" 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_new_line_in_empty_type_declaration" value="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.comment.format_line_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" 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_between_empty_parens_in_method_declaration" value="do not insert"/>
<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.alignment_for_superinterfaces_in_type_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="0"/>
<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_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<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_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
<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.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="0"/>
<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_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
<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.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>
<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.indent_switchstatements_compare_to_cases" value="true"/>
<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.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
<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_selector_in_method_invocation" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.compiler.source" value="1.8"/>
<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_comma_in_constructor_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<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_comma_in_allocation_expression" value="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.insert_space_after_colon_in_conditional" value="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_brace_in_array_initializer" value="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_semicolon_in_try_resources" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
<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_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not 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.insert_new_line_after_type_annotation" 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.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
<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_after_closing_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
<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.insert_space_after_unary_operator" value="do not insert"/>
<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_arguments_in_annotation" value="0"/>
<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.keep_empty_array_initializer_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="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.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<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_after_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" 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_before_comma_in_method_declaration_parameters" value="do not insert"/>
<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_closing_paren_in_cast" 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.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<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_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="0"/>
<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_new_line_in_empty_enum_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_before_closing_paren_in_method_declaration" 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.insert_space_before_semicolon" 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.insert_space_after_opening_paren_in_try" 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.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="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.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="0"/>
<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_before_opening_angle_bracket_in_type_parameters" 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_after_comma_in_method_declaration_throws" value="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.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
<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_before_prefix_operator" 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.wrap_before_binary_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="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.compiler.compliance" value="1.8"/>
<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_space_after_comma_in_annotation" value="insert"/>
<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_between_empty_braces_in_array_initializer" value="do not insert"/>
<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_before_comma_in_multiple_local_declarations" 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.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
<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.wrap_outer_expressions_when_nested" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
<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_before_opening_paren_in_synchronized" 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_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
<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.insert_space_before_closing_paren_in_enum_constant" 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_closing_paren_in_annotation" 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.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="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.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
<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_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="tab"/>
<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.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="80"/>
<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.insert_space_before_opening_paren_in_switch" value="insert"/>
</profile>
</profiles>
@@ -17,8 +17,11 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.VillagerRegistry;
import cpw.mods.fml.relauncher.Side;
import java.io.File;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.logger.FileLogger;
@@ -56,7 +56,7 @@ public class MCItemStack implements IItemStack {
throw new IllegalArgumentException("stack cannot be null");
stack = itemStack.copy();
items = Collections.<IItemStack> singletonList(this);
items = Collections.<IItemStack>singletonList(this);
}
public MCItemStack(ItemStack itemStack, boolean wildcardSize) {
@@ -70,13 +70,13 @@ public class MCItemStack implements IItemStack {
throw new IllegalArgumentException("stack cannot be null");
stack = itemStack;
items = Collections.<IItemStack> singletonList(this);
items = Collections.<IItemStack>singletonList(this);
this.tag = tag;
}
private MCItemStack(ItemStack itemStack, IData tag, boolean wildcardSize) {
stack = itemStack;
items = Collections.<IItemStack> singletonList(this);
items = Collections.<IItemStack>singletonList(this);
this.tag = tag;
this.wildcardSize = wildcardSize;
}
@@ -108,7 +108,6 @@ public class MCItemStack implements IItemStack {
@Override
public void setMaxStackSize(int size) {
System.out.println("changing stack size");
MineTweakerAPI.apply(new SetStackSizeAction((ItemStack) getInternal(), size));
}
@@ -36,16 +36,16 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
public class MCRecipeManager implements IRecipeManager {
private final List<IRecipe> recipes;
private final List<ICraftingRecipe> transformerRecipes;
public MCRecipeManager() {
recipes = (List<IRecipe>) CraftingManager.getInstance().getRecipeList();
transformerRecipes = new ArrayList<ICraftingRecipe>();
}
public boolean hasTransformerRecipes() {
return transformerRecipes.size() > 0;
}
public void applyTransformations(ICraftingInventory inventory, IPlayer byPlayer) {
for (ICraftingRecipe recipe : transformerRecipes) {
if (recipe.matches(inventory)) {
@@ -54,40 +54,40 @@ public class MCRecipeManager implements IRecipeManager {
}
}
}
@Override
public List<ICraftingRecipe> getRecipesFor(IIngredient ingredient) {
List<ICraftingRecipe> results = new ArrayList<ICraftingRecipe>();
for (IRecipe recipe : recipes) {
if (ingredient.matches(MineTweakerMC.getIItemStack(recipe.getRecipeOutput()))) {
ICraftingRecipe converted = RecipeConverter.toCraftingRecipe(recipe);
results.add(converted);
}
}
return results;
}
@Override
public List<ICraftingRecipe> getAll() {
List<ICraftingRecipe> results = new ArrayList<ICraftingRecipe>();
for (IRecipe recipe : recipes) {
ICraftingRecipe converted = RecipeConverter.toCraftingRecipe(recipe);
results.add(converted);
}
return results;
}
@Override
public int remove(IIngredient output) {
List<IRecipe> toRemove = new ArrayList<IRecipe>();
List<Integer> removeIndex = new ArrayList<Integer>();
for (int i = 0; i < recipes.size(); i++) {
IRecipe recipe = recipes.get(i);
// certain special recipes have no predefined output. ignore those
// since these cannot be removed with MineTweaker scripts
if (recipe.getRecipeOutput() != null) {
@@ -97,11 +97,11 @@ public class MCRecipeManager implements IRecipeManager {
}
}
}
MineTweakerAPI.apply(new ActionRemoveRecipes(toRemove, removeIndex));
return toRemove.size();
}
@Override
public void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function) {
addShaped(output, ingredients, function, false);
@@ -123,24 +123,24 @@ public class MCRecipeManager implements IRecipeManager {
public int removeShaped(IIngredient output, IIngredient[][] ingredients) {
int ingredientsWidth = 0;
int ingredientsHeight = 0;
if (ingredients != null) {
ingredientsHeight = ingredients.length;
for (int i = 0; i < ingredients.length; i++) {
ingredientsWidth = Math.max(ingredientsWidth, ingredients[i].length);
}
}
List<IRecipe> toRemove = new ArrayList<IRecipe>();
List<Integer> removeIndex = new ArrayList<Integer>();
outer: for (int i = 0; i < recipes.size(); i++) {
IRecipe recipe = recipes.get(i);
if (recipe.getRecipeOutput() == null || !output.matches(getIItemStack(recipe.getRecipeOutput()))) {
continue;
}
if (ingredients != null) {
if (recipe instanceof ShapedRecipes) {
ShapedRecipes srecipe = (ShapedRecipes) recipe;
@@ -153,7 +153,7 @@ public class MCRecipeManager implements IRecipeManager {
for (int k = 0; k < ingredientsWidth; k++) {
IIngredient ingredient = k > row.length ? null : row[k];
ItemStack recipeIngredient = srecipe.recipeItems[j * srecipe.recipeWidth + k];
if (!matches(recipeIngredient, ingredient)) {
continue outer;
}
@@ -166,7 +166,7 @@ public class MCRecipeManager implements IRecipeManager {
if (ingredientsWidth != recipeWidth || ingredientsHeight != recipeHeight) {
continue;
}
for (int j = 0; j < ingredientsHeight; j++) {
IIngredient[] row = ingredients[j];
for (int k = 0; k < ingredientsWidth; k++) {
@@ -180,14 +180,14 @@ public class MCRecipeManager implements IRecipeManager {
}
} else {
if (recipe instanceof ShapedRecipes) {
} else if (recipe instanceof ShapedOreRecipe) {
} else {
continue;
}
}
toRemove.add(recipe);
removeIndex.add(i);
}
@@ -202,60 +202,61 @@ public class MCRecipeManager implements IRecipeManager {
List<Integer> removeIndex = new ArrayList<Integer>();
outer: for (int i = 0; i < recipes.size(); i++) {
IRecipe recipe = recipes.get(i);
if (recipe.getRecipeOutput() == null || !output.matches(getIItemStack(recipe.getRecipeOutput()))) {
continue;
}
if (ingredients != null) {
if (recipe instanceof ShapelessRecipes) {
ShapelessRecipes srecipe = (ShapelessRecipes) recipe;
if (ingredients.length > srecipe.getRecipeSize()) {
continue;
} else if (!wildcard && ingredients.length < srecipe.getRecipeSize()) {
continue;
}
checkIngredient: for (int j = 0; j < ingredients.length; j++) {
for (int k = 0; k < srecipe.getRecipeSize(); k++) {
if (matches(srecipe.recipeItems.get(k), ingredients[j])) {
continue checkIngredient;
}
}
continue outer;
}
} else if (recipe instanceof ShapelessOreRecipe) {
ShapelessOreRecipe srecipe = (ShapelessOreRecipe) recipe;
ArrayList<Object> inputs = srecipe.getInput();
if (inputs.size() < ingredients.length) {
continue;
} if (!wildcard && inputs.size() > ingredients.length) {
}
if (!wildcard && inputs.size() > ingredients.length) {
continue;
}
checkIngredient: for (int j = 0; j < ingredients.length; j++) {
for (int k = 0; k < srecipe.getRecipeSize(); k++) {
if (matches(inputs.get(k), ingredients[j])) {
continue checkIngredient;
}
}
continue outer;
}
}
} else {
if (recipe instanceof ShapelessRecipes) {
} else if (recipe instanceof ShapelessOreRecipe) {
} else {
continue;
}
}
toRemove.add(recipe);
removeIndex.add(i);
}
@@ -267,13 +268,13 @@ public class MCRecipeManager implements IRecipeManager {
@Override
public IItemStack craft(IItemStack[][] contents) {
Container container = new ContainerVirtual();
int width = 0;
int height = contents.length;
for (IItemStack[] row : contents) {
width = Math.max(width, row.length);
}
ItemStack[] iContents = new ItemStack[width * height];
for (int i = 0; i < height; i++) {
for (int j = 0; j < contents[i].length; j++) {
@@ -282,7 +283,7 @@ public class MCRecipeManager implements IRecipeManager {
}
}
}
InventoryCrafting inventory = new InventoryCrafting(container, width, height);
for (int i = 0; i < iContents.length; i++) {
inventory.setInventorySlotContents(i, iContents[i]);
@@ -294,18 +295,18 @@ public class MCRecipeManager implements IRecipeManager {
return getIItemStack(result);
}
}
private class ContainerVirtual extends Container {
@Override
public boolean canInteractWith(EntityPlayer var1) {
return false;
}
}
private class ActionRemoveRecipes implements IUndoableAction {
private final List<Integer> removingIndices;
private final List<IRecipe> removingRecipes;
public ActionRemoveRecipes(List<IRecipe> recipes, List<Integer> indices) {
this.removingIndices = indices;
this.removingRecipes = recipes;
@@ -346,11 +347,11 @@ public class MCRecipeManager implements IRecipeManager {
return null;
}
}
private class ActionAddRecipe implements IUndoableAction {
private final IRecipe recipe;
private final ICraftingRecipe craftingRecipe;
public ActionAddRecipe(IRecipe recipe, ICraftingRecipe craftingRecipe) {
this.recipe = recipe;
this.craftingRecipe = craftingRecipe;
@@ -398,7 +399,7 @@ public class MCRecipeManager implements IRecipeManager {
IRecipe irecipe = RecipeConverter.convert(recipe);
MineTweakerAPI.apply(new ActionAddRecipe(irecipe, recipe));
}
private static boolean matches(Object input, IIngredient ingredient) {
if ((input == null) != (ingredient == null)) {
return false;
@@ -413,7 +414,7 @@ public class MCRecipeManager implements IRecipeManager {
}
}
}
return true;
}
}
@@ -37,9 +37,9 @@ import static stanhebben.zenscript.util.ZenTypeUtil.internal;
* Main module class. Contains a compiled module. The static methods of this
* class can be used to compile a specific file or files.
*
* Modules may contain statements in their source, or define functions. Functions
* in different scripts within the same module are accessible to each other, but
* not to other modules.
* Modules may contain statements in their source, or define functions.
* Functions in different scripts within the same module are accessible to each
* other, but not to other modules.
*
* @author Stan Hebben
*/
@@ -55,11 +55,11 @@ public class ZenModule {
public static void compileScripts(String mainFileName, List<ZenParsedFile> scripts, IEnvironmentGlobal environmentGlobal, boolean debug) {
ClassWriter clsMain = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
clsMain.visitSource(mainFileName, null);
clsMain.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, "__ZenMain__", null, internal(Object.class), new String[] {internal(Runnable.class)});
clsMain.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, "__ZenMain__", null, internal(Object.class), new String[] { internal(Runnable.class) });
MethodOutput mainRun = new MethodOutput(clsMain, Opcodes.ACC_PUBLIC, "run", "()V", null, null);
mainRun.start();
for (ZenParsedFile script : scripts) {
for (Map.Entry<String, ParsedFunction> function : script.getFunctions().entrySet()) {
ParsedFunction fn = function.getValue();
@@ -71,17 +71,17 @@ public class ZenModule {
fn.getReturnType()), fn.getPosition());
}
}
for (ZenParsedFile script : scripts) {
ClassWriter clsScript = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
clsScript.visitSource(script.getFileName(), null);
EnvironmentClass environmentScript = new EnvironmentClass(clsScript, script.getEnvironment());
clsScript.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, script.getClassName().replace('.', '/'), null, internal(Object.class), new String[] {internal(Runnable.class)});
clsScript.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, script.getClassName().replace('.', '/'), null, internal(Object.class), new String[] { internal(Runnable.class) });
for (Map.Entry<String, ParsedFunction> function : script.getFunctions().entrySet()) {
ParsedFunction fn = function.getValue();
String signature = fn.getSignature();
MethodOutput methodOutput = new MethodOutput(clsScript, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, function.getKey(), signature, null, null);
EnvironmentMethod methodEnvironment = new EnvironmentMethod(methodOutput, environmentScript);
@@ -101,14 +101,14 @@ public class ZenModule {
if (statements[statements.length - 1] instanceof StatementReturn) {
if (((StatementReturn) statements[statements.length - 1]).getExpression() != null) {
fn.getReturnType()
.defaultValue(fn.getPosition())
.compile(true, methodEnvironment);
.defaultValue(fn.getPosition())
.compile(true, methodEnvironment);
methodOutput.returnType(fn.getReturnType().toASMType());
}
} else {
fn.getReturnType()
.defaultValue(fn.getPosition())
.compile(true, methodEnvironment);
.defaultValue(fn.getPosition())
.compile(true, methodEnvironment);
methodOutput.returnType(fn.getReturnType().toASMType());
}
}
@@ -118,25 +118,25 @@ public class ZenModule {
if (script.getStatements().size() > 0) {
MethodOutput scriptOutput = new MethodOutput(clsScript, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "__script__", "()V", null, null);
IEnvironmentMethod functionMethod = new EnvironmentMethod(scriptOutput, environmentScript);
//scriptOutput.enableDebug();
// scriptOutput.enableDebug();
scriptOutput.start();
for (Statement statement : script.getStatements()) {
statement.compile(functionMethod);
}
scriptOutput.ret();
scriptOutput.end();
mainRun.invokeStatic(script.getClassName().replace('.', '/'), "__script__", "()V");
}
clsScript.visitEnd();
environmentGlobal.putClass(script.getClassName(), clsScript.toByteArray());
}
mainRun.ret();
mainRun.end();
clsMain.visitEnd();
MethodVisitor constructor = clsMain.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
constructor.visitCode();
constructor.visitVarInsn(Opcodes.ALOAD, 0);
@@ -144,7 +144,7 @@ public class ZenModule {
constructor.visitInsn(Opcodes.RETURN);
constructor.visitMaxs(0, 0);
constructor.visitEnd();
// debug: output classes
if (debug) {
try {
@@ -153,11 +153,11 @@ public class ZenModule {
for (String className : environmentGlobal.getClassNames()) {
File outputFile = new File(outputDir, className.replace('.', '/') + ".class");
if (!outputFile.getParentFile().exists()) {
outputFile.getParentFile().mkdirs();
}
FileOutputStream output = new FileOutputStream(outputFile);
output.write(environmentGlobal.getClass(className));
output.close();
@@ -166,10 +166,10 @@ public class ZenModule {
ex.printStackTrace();
}
}
environmentGlobal.putClass("__ZenMain__", clsMain.toByteArray());
}
/**
* Compiles a single script file.
*
@@ -186,26 +186,26 @@ public class ZenModule {
environment,
classes,
nameGen
);
);
String filename = single.getName();
String className = extractClassName(filename);
FileInputStream input = new FileInputStream(single);
Reader reader = new InputStreamReader(new BufferedInputStream(input));
ZenTokener parser = new ZenTokener(reader, environment);
ZenParsedFile file = new ZenParsedFile(filename, className, parser, environmentGlobal);
reader.close();
List<ZenParsedFile> files = new ArrayList<ZenParsedFile>();
files.add(file);
compileScripts(filename, files, environmentGlobal, false);
// debug: output classes
File outputDir = new File("generated");
outputDir.mkdir();
for (Map.Entry<String, byte[]> entry : classes.entrySet()) {
File outputFile = new File(outputDir, entry.getKey().replace('.', '/') + ".class");
if (!outputFile.getParentFile().exists()) {
@@ -215,10 +215,10 @@ public class ZenModule {
output.write(entry.getValue());
output.close();
}
return new ZenModule(classes, baseClassLoader);
}
/**
* Compiles a zip file as module. All containing files (inside the given
* subdirectory) will be compiled.
@@ -240,19 +240,19 @@ public class ZenModule {
environment,
classes,
nameGen
);
);
List<ZenParsedFile> files = new ArrayList<ZenParsedFile>();
ZipFile zipFile = new ZipFile(file);
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (entry.getName().startsWith(subdir) && !entry.getName().equals(subdir)) {
String filename = entry.getName().substring(subdir.length());
String className = extractClassName(filename);
Reader reader = new InputStreamReader(new BufferedInputStream(zipFile.getInputStream(entry)));
ZenTokener parser = new ZenTokener(reader, environment);
ZenParsedFile pfile = new ZenParsedFile(filename, className, parser, environmentGlobal);
@@ -260,30 +260,30 @@ public class ZenModule {
reader.close();
}
}
String filename = file.getName();
compileScripts(filename, files, environmentGlobal, true);
return new ZenModule(classes, baseClassLoader);
}
private final Map<String, byte[]> classes;
private final MyClassLoader classLoader;
/**
* Constructs a module for the given set of classes. Mostly intended for
* internal use.
*
* @param classes
* @param classes
*/
public ZenModule(Map<String, byte[]> classes, ClassLoader baseClassLoader) {
this.classes = classes;
classLoader = new MyClassLoader(baseClassLoader);
}
/**
* Retrieves the main runnable. Running this runnable will execute the content
* of the given module.
* Retrieves the main runnable. Running this runnable will execute the
* content of the given module.
*
* @return main runnable
*/
@@ -298,11 +298,11 @@ public class ZenModule {
return null;
}
}
// ######################
// ### Static methods ###
// ######################
/**
* Converts a filename into a class name.
*
@@ -311,11 +311,12 @@ public class ZenModule {
*/
public static String extractClassName(String filename) {
filename = filename.replace('\\', '/');
if (filename.startsWith("/")) filename = filename.substring(1);
if (filename.startsWith("/"))
filename = filename.substring(1);
int lastSlash = filename.lastIndexOf('/');
int lastDot = filename.lastIndexOf('.');
if (lastDot > lastSlash) {
filename = filename.substring(0, lastDot);
}
@@ -327,11 +328,11 @@ public class ZenModule {
return filename.substring(0, 1).toUpperCase() + filename.substring(1);
}
}
// #############################
// ### Private inner classes ###
// #############################
/**
* Custom class loader. Loads classes from this module.
*/
@@ -339,13 +340,13 @@ public class ZenModule {
private MyClassLoader(ClassLoader baseClassLoader) {
super(baseClassLoader);
}
@Override
public Class<?> findClass(String name) throws ClassNotFoundException {
if (classes.containsKey(name)) {
return defineClass(name, classes.get(name), 0, classes.get(name).length);
}
return super.findClass(name);
}
}
@@ -41,10 +41,10 @@ import stanhebben.zenscript.value.IAny;
*/
public class TypeRegistry implements ITypeRegistry {
private final Map<Class, ZenType> types;
public TypeRegistry() {
types = new HashMap<Class, ZenType>();
types.put(boolean.class, ZenType.BOOL);
types.put(byte.class, ZenTypeByte.INSTANCE);
types.put(short.class, ZenTypeShort.INSTANCE);
@@ -53,7 +53,7 @@ public class TypeRegistry implements ITypeRegistry {
types.put(float.class, ZenTypeFloat.INSTANCE);
types.put(double.class, ZenTypeDouble.INSTANCE);
types.put(void.class, ZenTypeVoid.INSTANCE);
types.put(Boolean.class, ZenTypeBoolObject.INSTANCE);
types.put(Byte.class, ZenTypeByteObject.INSTANCE);
types.put(Short.class, ZenTypeShortObject.INSTANCE);
@@ -61,13 +61,13 @@ public class TypeRegistry implements ITypeRegistry {
types.put(Long.class, ZenTypeLongObject.INSTANCE);
types.put(Float.class, ZenTypeFloatObject.INSTANCE);
types.put(Double.class, ZenTypeDoubleObject.INSTANCE);
types.put(IAny.class, ZenTypeAny.INSTANCE);
types.put(String.class, ZenTypeString.INSTANCE);
types.put(List.class, new ZenTypeArrayBasic(ZenTypeAny.INSTANCE));
}
public ZenType getClassType(Class cls) {
if (types.containsKey(cls)) {
return types.get(cls);
@@ -82,7 +82,7 @@ public class TypeRegistry implements ITypeRegistry {
return result;
}
}
@Override
public ZenType getType(Type type) {
if (type instanceof ParameterizedType) {
@@ -107,22 +107,22 @@ public class TypeRegistry implements ITypeRegistry {
return null;
}
}
private ZenType getListType(ParameterizedType type) {
if (type.getRawType() == List.class) {
return new ZenTypeArrayList(getType(type.getActualTypeArguments()[0]));
}
return null;
}
private ZenType getMapType(ParameterizedType type) {
if (type.getRawType() == Map.class) {
return new ZenTypeAssociative(
getType(type.getActualTypeArguments()[1]),
getType(type.getActualTypeArguments()[0]));
}
return null;
}
}
@@ -6,10 +6,10 @@ import stanhebben.zenscript.util.ZenPosition;
public class StatementExpression extends Statement {
private final ParsedExpression expression;
public StatementExpression(ZenPosition position, ParsedExpression expression) {
super(position);
this.expression = expression;
}
@@ -17,7 +17,7 @@ public class StatementExpression extends Statement {
public void compile(IEnvironmentMethod environment) {
environment.getOutput().position(getPosition());
expression.compile(environment, null)
.eval(environment)
.compile(false, environment);
.eval(environment)
.compile(false, environment);
}
}
@@ -17,20 +17,20 @@ import stanhebben.zenscript.util.MethodOutput;
*/
public interface IJavaMethod {
public boolean isStatic();
public boolean accepts(int numArguments);
public boolean accepts(IEnvironmentGlobal environment, Expression... arguments);
public int getPriority(IEnvironmentGlobal environment, Expression... arguments);
public void invokeVirtual(MethodOutput output);
public void invokeStatic(MethodOutput output);
public ZenType[] getParameterTypes();
public ZenType getReturnType();
public boolean isVarargs();
}
@@ -28,15 +28,15 @@ public class ZenNativeMember {
private IJavaMethod getter;
private IJavaMethod setter;
private final List<IJavaMethod> methods = new ArrayList<IJavaMethod>();
public IJavaMethod getGetter() {
return getter;
}
public IJavaMethod getSetter() {
return setter;
}
public void setGetter(IJavaMethod getter) {
if (this.getter == null) {
this.getter = getter;
@@ -44,7 +44,7 @@ public class ZenNativeMember {
throw new RuntimeException("already has a getter");
}
}
public void setSetter(IJavaMethod setter) {
if (this.setter == null) {
this.setter = setter;
@@ -60,20 +60,20 @@ public class ZenNativeMember {
public IPartialExpression instance(ZenPosition position, IEnvironmentGlobal environment) {
return new StaticGetValue(position);
}
public void addMethod(JavaMethod method) {
methods.add(method);
}
private class InstanceGetValue implements IPartialExpression {
private final ZenPosition position;
private final IPartialExpression value;
public InstanceGetValue(ZenPosition position, IPartialExpression value) {
this.position = position;
this.value = value;
}
@Override
public Expression eval(IEnvironmentGlobal environment) {
return new ExpressionCallVirtual(position, environment, getter, value.eval(environment));
@@ -99,17 +99,17 @@ public class ZenNativeMember {
return new ExpressionCallVirtual(position, environment, method, value.eval(environment), values);
}
}
@Override
public ZenType[] predictCallTypes(int numArguments) {
return JavaMethod.predict(methods, numArguments);
}
@Override
public IZenSymbol toSymbol() {
return null;
}
@Override
public ZenType getType() {
return getter.getReturnType();
@@ -121,14 +121,14 @@ public class ZenNativeMember {
return ZenType.ANY;
}
}
private class StaticGetValue implements IPartialExpression {
private final ZenPosition position;
public StaticGetValue(ZenPosition position) {
this.position = position;
}
@Override
public Expression eval(IEnvironmentGlobal environment) {
return new ExpressionCallStatic(position, environment, setter);
@@ -154,7 +154,7 @@ public class ZenNativeMember {
return new ExpressionCallStatic(position, environment, method, values);
}
}
@Override
public ZenType[] predictCallTypes(int numArguments) {
return JavaMethod.predict(methods, numArguments);
@@ -164,7 +164,7 @@ public class ZenNativeMember {
public IZenSymbol toSymbol() {
return new StaticSymbol();
}
@Override
public ZenType getType() {
return getter.getReturnType();
@@ -176,7 +176,7 @@ public class ZenNativeMember {
return ZenType.ANY;
}
}
private class StaticSymbol implements IZenSymbol {
@Override
public IPartialExpression instance(ZenPosition position) {