-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement SchematicPasteOptions + clean up (#22)
- Loading branch information
Showing
14 changed files
with
215 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
main/src/main/java/org/minerift/ether/schematic/SchematicPasteFlags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.minerift.ether.schematic; | ||
|
||
@Deprecated | ||
public class SchematicPasteFlags { | ||
|
||
public static final byte IGNORE_AIR_BLOCKS = 1; | ||
public static final byte WITH_BIOMES = 2; | ||
public static final byte WITH_ENTITIES = 4; | ||
|
||
public static SchematicPasteFlags of(int flags) { | ||
return new SchematicPasteFlags(flags); | ||
} | ||
|
||
public static SchematicPasteFlags of(int flag, int ... flags) { | ||
for(int f : flags) { | ||
flag |= f; | ||
} | ||
return new SchematicPasteFlags(flag); | ||
} | ||
|
||
private final int flags; | ||
private SchematicPasteFlags(int flags) { | ||
this.flags = flags; | ||
} | ||
|
||
public void has(int flag, Runnable callback) { | ||
if(has(flag)) { | ||
callback.run(); | ||
} | ||
} | ||
|
||
public boolean has(int flag) { | ||
return (flags & flag) != 0; | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
main/src/main/java/org/minerift/ether/schematic/SchematicPasteOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package org.minerift.ether.schematic; | ||
|
||
import org.minerift.ether.util.math.Vec3i; | ||
|
||
public class SchematicPasteOptions { | ||
|
||
/** | ||
* Default SchematicPasteOptions with no changes. | ||
* Everything is defaulted to false or 0. | ||
*/ | ||
public static final SchematicPasteOptions EMPTY_DEFAULT; | ||
|
||
/** | ||
* Preferred default SchematicPasteOptions. | ||
* Will copy biomes and entities with zero offset and no ignored air blocks. | ||
*/ | ||
public static final SchematicPasteOptions DEFAULT; | ||
|
||
static { | ||
EMPTY_DEFAULT = SchematicPasteOptions.builder().build(); | ||
DEFAULT = SchematicPasteOptions.builder() | ||
.copyBiomes(true) | ||
.copyEntities(true) | ||
.build(); | ||
} | ||
|
||
public final boolean copyBiomes; | ||
public final boolean copyEntities; | ||
public final boolean ignoreAirBlocks; | ||
public final Vec3i offset; | ||
|
||
private SchematicPasteOptions(SchematicPasteOptions.Builder builder) { | ||
this.copyBiomes = builder.copyBiomes; | ||
this.copyEntities = builder.copyEntities; | ||
this.ignoreAirBlocks = builder.ignoreAirBlocks; | ||
this.offset = builder.offset; | ||
} | ||
|
||
public static SchematicPasteOptions.Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
private boolean copyBiomes; | ||
private boolean copyEntities; | ||
private boolean ignoreAirBlocks; | ||
private Vec3i offset; | ||
|
||
private Builder() { | ||
this.copyBiomes = false; | ||
this.copyEntities = false; | ||
this.ignoreAirBlocks = false; | ||
this.offset = Vec3i.ZERO; | ||
} | ||
|
||
public Builder copyBiomes(boolean val) { | ||
this.copyBiomes = val; | ||
return this; | ||
} | ||
|
||
public Builder copyEntities(boolean val) { | ||
this.copyEntities = val; | ||
return this; | ||
} | ||
|
||
public Builder ignoreAirBlocks(boolean val) { | ||
this.ignoreAirBlocks = val; | ||
return this; | ||
} | ||
|
||
public Builder setOffset(Vec3i val) { | ||
this.offset = val; | ||
return this; | ||
} | ||
|
||
public SchematicPasteOptions build() { | ||
return new SchematicPasteOptions(this); | ||
} | ||
} | ||
|
||
} |
3 changes: 2 additions & 1 deletion
3
main/src/main/java/org/minerift/ether/schematic/pasters/ISchematicPaster.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package org.minerift.ether.schematic.pasters; | ||
|
||
import org.minerift.ether.schematic.SchematicPasteOptions; | ||
import org.minerift.ether.schematic.types.Schematic; | ||
import org.minerift.ether.util.math.Vec3i; | ||
|
||
public interface ISchematicPaster<S extends Schematic> { | ||
void paste(S schem, Vec3i pos, String worldName); | ||
void paste(S schem, Vec3i pos, String worldName, SchematicPasteOptions options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.