From a76bd342e59e5c487988934275a7f0e027bedc93 Mon Sep 17 00:00:00 2001 From: valoeghese Date: Mon, 24 Feb 2020 16:32:51 +1300 Subject: [PATCH 1/2] add SOD --- .../java/tk/valoeghese/sod/BinaryData.java | 64 ++++++++ .../java/tk/valoeghese/sod/DataSection.java | 106 +++++++++++++ src/main/java/tk/valoeghese/sod/Parser.java | 142 ++++++++++++++++++ src/main/java/tk/valoeghese/sod/TestMain.java | 53 +++++++ .../sod/exception/SODParseException.java | 9 ++ 5 files changed, 374 insertions(+) create mode 100644 src/main/java/tk/valoeghese/sod/BinaryData.java create mode 100644 src/main/java/tk/valoeghese/sod/DataSection.java create mode 100644 src/main/java/tk/valoeghese/sod/Parser.java create mode 100644 src/main/java/tk/valoeghese/sod/TestMain.java create mode 100644 src/main/java/tk/valoeghese/sod/exception/SODParseException.java diff --git a/src/main/java/tk/valoeghese/sod/BinaryData.java b/src/main/java/tk/valoeghese/sod/BinaryData.java new file mode 100644 index 0000000..fbb8a97 --- /dev/null +++ b/src/main/java/tk/valoeghese/sod/BinaryData.java @@ -0,0 +1,64 @@ +package tk.valoeghese.sod; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import tk.valoeghese.sod.exception.SODParseException; + +public class BinaryData implements Iterable> { + public BinaryData() { + this.sections = new HashMap<>(); + } + + private final Map sections; + + public DataSection get(String name) { + return this.sections.get(name); + } + + public DataSection getOrCreate(String name) { + return this.sections.computeIfAbsent(name, k -> new DataSection()); + } + + public void put(String name, DataSection section) { + this.sections.put(name, section); + } + + public boolean write(File file) { + try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(file))) { + Parser.write(this, dos); + return true; + } catch (IOException e) { + e.printStackTrace(); + return false; + } + } + + @Override + public Iterator> iterator() { + return this.sections.entrySet().iterator(); + } + + public static BinaryData read(File file) throws SODParseException { + try (DataInputStream dis = new DataInputStream(new FileInputStream(file))) { + long magic = dis.readLong(); + + if (magic != 0xA77D1E) { + throw new SODParseException("Not a valid SOD file!"); + } + + return Parser.parse(dis); + } catch (IOException e) { + e.printStackTrace(); + //throw new SODParseException("Error in parsing file " + file.toString()); + return new BinaryData(); + } + } +} diff --git a/src/main/java/tk/valoeghese/sod/DataSection.java b/src/main/java/tk/valoeghese/sod/DataSection.java new file mode 100644 index 0000000..a02016e --- /dev/null +++ b/src/main/java/tk/valoeghese/sod/DataSection.java @@ -0,0 +1,106 @@ +package tk.valoeghese.sod; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Represents a section of SOD data. + * @author Valoeghese + */ +public class DataSection implements Iterable { + public DataSection() { + this.data = new ArrayList<>(); + } + + private final List data; + + public void writeByte(byte data) { + this.data.add(data); + } + + public void writeShort(short data) { + this.data.add(data); + } + + public void writeInt(int data) { + this.data.add(data); + } + + public void writeLong(long data) { + this.data.add(data); + } + + public void writeFloat(float data) { + this.data.add(data); + } + + public void writeDouble(double data) { + this.data.add(data); + } + + public void writeString(String data) { + this.data.add(data); + } + + public void writeBoolean(boolean data) { + this.data.add(data ? (byte) 1 : (byte) 0); + } + + public > void writeEnum(T enumValue) { + this.data.add(enumValue.ordinal()); + } + + public > void writeEnumAsString(T enumValue) { + this.data.add(enumValue.toString()); + } + + public int size() { + return this.data.size(); + } + + public byte readByte(int index) { + return (byte) this.data.get(index); + } + + public short readShort(int index) { + return (short) this.data.get(index); + } + + public int readInt(int index) { + return (int) this.data.get(index); + } + + public long readLong(int index) { + return (long) this.data.get(index); + } + + public float readFloat(int index) { + return (float) this.data.get(index); + } + + public double readDouble(int index) { + return (double) this.data.get(index); + } + + public String readString(int index) { + return (String) this.data.get(index); + } + + public boolean readBoolean(int index) { + return ((byte) this.data.get(index)) != 0; + } + + public > T readEnumString(int index, Class type) { + return Enum.valueOf(type, (String) this.data.get(index)); + } + + public > T readEnum(int index, T[] values) { + return values[(int) this.data.get(index)]; + } + + @Override + public Iterator iterator() { + return this.data.iterator(); + } +} diff --git a/src/main/java/tk/valoeghese/sod/Parser.java b/src/main/java/tk/valoeghese/sod/Parser.java new file mode 100644 index 0000000..353169d --- /dev/null +++ b/src/main/java/tk/valoeghese/sod/Parser.java @@ -0,0 +1,142 @@ +package tk.valoeghese.sod; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Iterator; +import java.util.Map; + +import tk.valoeghese.sod.exception.SODParseException; + +final class Parser { + static BinaryData parse(DataInputStream input) throws IOException, SODParseException { + BinaryData data = new BinaryData(); + + DataType dataType; + dataType = DataType.of(input.readByte()); + + if (dataType != DataType.SECTION) { + throw new SODParseException("Data must be segregated into sections!"); + } + + DataSection currentSection = new DataSection(); + data.put(input.readUTF(), currentSection); + + while (input.available() > 0) { + dataType = DataType.of(input.readByte()); + + switch (dataType) { + case BYTE: + currentSection.writeByte(input.readByte()); + break; + case DOUBLE: + currentSection.writeDouble(input.readDouble()); + break; + case FLOAT: + currentSection.writeFloat(input.readFloat()); + break; + case INT: + currentSection.writeInt(input.readInt()); + break; + case LONG: + currentSection.writeLong(input.readLong()); + break; + case SECTION: + currentSection = new DataSection(); + data.put(input.readUTF(), currentSection); + break; + case SHORT: + currentSection.writeShort(input.readShort()); + break; + case STRING: + currentSection.writeString(input.readUTF()); + break; + default: + throw new RuntimeException("This error should never be thrown! If this error occurs, the parser is not properly dealing with a most-likely-invalid data type."); + } + } + + return data; + } + + static void write(BinaryData data, DataOutputStream dos) throws IOException { + dos.writeLong(0xA77D1E); + + Iterator> sectionStream = data.iterator(); + + while (sectionStream.hasNext()) { + Map.Entry section = sectionStream.next(); + dos.writeByte(DataType.SECTION.id); + dos.writeUTF(section.getKey()); + + Iterator dataStream = section.getValue().iterator(); + + while (dataStream.hasNext()) { + Object o = dataStream.next(); + + if (o instanceof Byte) { + dos.writeByte(DataType.BYTE.id); + dos.writeByte((byte) o); + } else if (o instanceof Short) { + dos.writeByte(DataType.SHORT.id); + dos.writeShort((short) o); + } else if (o instanceof Integer) { + dos.writeByte(DataType.INT.id); + dos.writeInt((int) o); + } else if (o instanceof Long) { + dos.writeByte(DataType.LONG.id); + dos.writeLong((long) o); + } else if (o instanceof Float) { + dos.writeByte(DataType.FLOAT.id); + dos.writeFloat((float) o); + } else if (o instanceof Double) { + dos.writeByte(DataType.DOUBLE.id); + dos.writeDouble((double) o); + } else if (o instanceof String) { + dos.writeByte(DataType.STRING.id); + dos.writeUTF((String) o); + } + } + } + } +} + +enum DataType { + SECTION(0), + BYTE(1), + SHORT(2), + INT(3), + LONG(4), + FLOAT(5), + DOUBLE(6), + STRING(7); + + private DataType(int id) { + this.id = (byte) id; + } + + public final byte id; + + public static DataType of(byte id) throws SODParseException { + switch (id) { + case 0: + return SECTION; + case 1: + return BYTE; + case 2: + return SHORT; + case 3: + return INT; + case 4: + return LONG; + case 5: + return FLOAT; + case 6: + return DOUBLE; + case 7: + return STRING; + default: + throw new SODParseException("Unknown data type " + String.valueOf(id)); + } + } +} \ No newline at end of file diff --git a/src/main/java/tk/valoeghese/sod/TestMain.java b/src/main/java/tk/valoeghese/sod/TestMain.java new file mode 100644 index 0000000..66be22e --- /dev/null +++ b/src/main/java/tk/valoeghese/sod/TestMain.java @@ -0,0 +1,53 @@ +package tk.valoeghese.sod; + +import java.io.File; +import java.io.IOException; + +public class TestMain { + + public static void main(String[] args) throws IOException { + //writeTest() + readTest(); + } + + static void readTest() throws IOException { + File f = new File("../test.sod"); + + if (!f.createNewFile()) { + BinaryData bd = BinaryData.read(f); + + DataSection ds1 = bd.get("DS1"); + + for (Object i : ds1) { + System.out.println(i); + } + + DataSection ds2 = bd.get("yeet"); + + for (Object i : ds2) { + System.out.println(i); + } + } + } + + static void writeTest() throws IOException { + File f = new File("../test.sod"); + f.createNewFile(); + BinaryData bd = new BinaryData(); + + DataSection ds1 = bd.getOrCreate("DS1"); + ds1.writeBoolean(false); + ds1.writeDouble(0.666D); + ds1.writeLong(69696969); + ds1.writeString("yaY33T"); + + DataSection ds2 = bd.getOrCreate("yeet"); + ds2.writeByte((byte) 4); + ds2.writeFloat(1.3F); + ds2.writeString("e"); + ds2.writeString("ff"); + + bd.write(f); + } + +} diff --git a/src/main/java/tk/valoeghese/sod/exception/SODParseException.java b/src/main/java/tk/valoeghese/sod/exception/SODParseException.java new file mode 100644 index 0000000..f91639a --- /dev/null +++ b/src/main/java/tk/valoeghese/sod/exception/SODParseException.java @@ -0,0 +1,9 @@ +package tk.valoeghese.sod.exception; + +public class SODParseException extends RuntimeException { + private static final long serialVersionUID = -3337517517501006140L; + + public SODParseException(String message) { + super(message); + } +} From 804ae4ad450edbef954755df04ad07cdbd9efee6 Mon Sep 17 00:00:00 2001 From: valoeghese Date: Mon, 24 Feb 2020 18:09:08 +1300 Subject: [PATCH 2/2] start world gen, add fastutils --- .settings/org.eclipse.jdt.core.prefs | 358 ++++++++++++++++++ .settings/org.eclipse.jdt.ui.prefs | 3 + pom.xml | 6 +- .../litecraft/types/block/Block.java | 26 ++ .../litecraft/types/block/BlockEntity.java | 12 + .../halotroop/litecraft/world/Chunk.java | 5 + 6 files changed, 409 insertions(+), 1 deletion(-) create mode 100644 .settings/org.eclipse.jdt.ui.prefs create mode 100644 src/main/java/io/github/halotroop/litecraft/types/block/Block.java create mode 100644 src/main/java/io/github/halotroop/litecraft/types/block/BlockEntity.java create mode 100644 src/main/java/io/github/halotroop/litecraft/world/Chunk.java diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index fbf1aac..21096ae 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -14,3 +14,361 @@ org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=enabled org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=true +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=false +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=false +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=false +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=false +org.eclipse.jdt.core.formatter.comment.indent_tag_description=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=150 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=false +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=1 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=1 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=false +org.eclipse.jdt.core.formatter.join_wrapped_lines=false +org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_if_single_item +org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_if_single_item +org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=true +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=true +org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_if_single_item +org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_if_single_item +org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_if_single_item +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true +org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_if_single_item +org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_if_single_item +org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_if_single_item +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=true +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=true +org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=true +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.lineSplit=500 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=0 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true +org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..3f1deaa --- /dev/null +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +formatter_profile=_Caroline's Preference +formatter_settings_version=17 diff --git a/pom.xml b/pom.xml index 8ecc8f1..f520ad9 100644 --- a/pom.xml +++ b/pom.xml @@ -276,6 +276,10 @@ ${lwjgl.version} natives-macos + + it.unimi.dsi + fastutil + 8.3.1 + - \ No newline at end of file diff --git a/src/main/java/io/github/halotroop/litecraft/types/block/Block.java b/src/main/java/io/github/halotroop/litecraft/types/block/Block.java new file mode 100644 index 0000000..fb9d768 --- /dev/null +++ b/src/main/java/io/github/halotroop/litecraft/types/block/Block.java @@ -0,0 +1,26 @@ +package io.github.halotroop.litecraft.types.block; + +import io.github.hydos.ginger.engine.obj.ModelLoader; +import io.github.hydos.ginger.engine.render.models.TexturedModel; + +public class Block +{ + protected Block(String texture, Properties properties) + { + this(ModelLoader.loadGenericCube(texture), properties); + } + + protected Block(TexturedModel model, Properties properties) + { + this.model = model; + } + + public final TexturedModel model; + + public static final Block GRASS = new Block("block/cubes/soil/gravel.png", new Properties()); + public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties()); + + public static class Properties { // add properties to this builder! + + } +} diff --git a/src/main/java/io/github/halotroop/litecraft/types/block/BlockEntity.java b/src/main/java/io/github/halotroop/litecraft/types/block/BlockEntity.java new file mode 100644 index 0000000..3c11f34 --- /dev/null +++ b/src/main/java/io/github/halotroop/litecraft/types/block/BlockEntity.java @@ -0,0 +1,12 @@ +package io.github.halotroop.litecraft.types.block; + +import io.github.hydos.ginger.engine.elements.objects.RenderObject; +import io.github.hydos.ginger.engine.math.vectors.Vector3f; + +public class BlockEntity extends RenderObject +{ + public BlockEntity(Block block, Vector3f position) + { + super(block.model, position, 0, 0, 0, new Vector3f(1f,1f,1f)); + } +} diff --git a/src/main/java/io/github/halotroop/litecraft/world/Chunk.java b/src/main/java/io/github/halotroop/litecraft/world/Chunk.java new file mode 100644 index 0000000..1dd0a1f --- /dev/null +++ b/src/main/java/io/github/halotroop/litecraft/world/Chunk.java @@ -0,0 +1,5 @@ +package io.github.halotroop.litecraft.world; + +public class Chunk { + +}