mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-23 00:29:51 +00:00
document a bunch of stuff
This commit is contained in:
@@ -16,12 +16,26 @@ import java.util.Map;
|
|||||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base interface which all Terra addons extend
|
||||||
|
*/
|
||||||
public interface BaseAddon extends StringIdentifiable {
|
public interface BaseAddon extends StringIdentifiable {
|
||||||
|
/**
|
||||||
|
* Initializes the addon. To be implemented by addons, but never manually invoked.
|
||||||
|
*/
|
||||||
default void initialize() { }
|
default void initialize() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the dependencies of this addon.
|
||||||
|
* @return Map of dependency ID to {@link VersionRange} of dependency
|
||||||
|
*/
|
||||||
default Map<String, VersionRange> getDependencies() {
|
default Map<String, VersionRange> getDependencies() {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the version of the addon
|
||||||
|
* @return Version of addon
|
||||||
|
*/
|
||||||
Version getVersion();
|
Version getVersion();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,16 @@ import java.nio.file.Path;
|
|||||||
import com.dfsek.terra.api.addon.BaseAddon;
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface representing a bootstrap addon.
|
||||||
|
*
|
||||||
|
* A bootstrap addon is the only type of addon Terra implements a loader for.
|
||||||
|
* It is a minimal base for addon loaders to be implemented on top of.
|
||||||
|
*
|
||||||
|
* Unless you are writing your own addon loader, you will want to depend on the
|
||||||
|
* {@code manifest-addon-loader} addon, and implement its AddonInitializer.
|
||||||
|
* @param <T> Type of addon this bootstrap addon loads
|
||||||
|
*/
|
||||||
public interface BootstrapBaseAddon<T extends BaseAddon> extends BaseAddon {
|
public interface BootstrapBaseAddon<T extends BaseAddon> extends BaseAddon {
|
||||||
/**
|
/**
|
||||||
* Load all the relevant addons in the specified path.
|
* Load all the relevant addons in the specified path.
|
||||||
|
|||||||
@@ -11,10 +11,25 @@ import com.dfsek.terra.api.Handle;
|
|||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a type of block
|
||||||
|
*/
|
||||||
public interface BlockType extends Handle {
|
public interface BlockType extends Handle {
|
||||||
|
/**
|
||||||
|
* Get the default {@link BlockState} of this block
|
||||||
|
* @return Default block state
|
||||||
|
*/
|
||||||
BlockState getDefaultState();
|
BlockState getDefaultState();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block is solid.
|
||||||
|
* @return Whether this block is solid.
|
||||||
|
*/
|
||||||
boolean isSolid();
|
boolean isSolid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block is water.
|
||||||
|
* @return Whether this block is water.
|
||||||
|
*/
|
||||||
boolean isWater();
|
boolean isWater();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,33 +14,88 @@ import com.dfsek.terra.api.block.BlockType;
|
|||||||
import com.dfsek.terra.api.block.state.properties.Property;
|
import com.dfsek.terra.api.block.state.properties.Property;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains basic data about a {@link BlockType} in the world
|
||||||
|
*/
|
||||||
public interface BlockState extends Handle {
|
public interface BlockState extends Handle {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this {@link BlockState} matches another.
|
||||||
|
*
|
||||||
|
* "matches" is defined as this {@link BlockState} holding a matching {@link #getBlockType()}.
|
||||||
|
* @param other Other {@link BlockState}
|
||||||
|
* @return Whether this state matches the other
|
||||||
|
*/
|
||||||
boolean matches(BlockState other);
|
boolean matches(BlockState other);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether this {@link BlockState} has a {@link Property}.
|
||||||
|
* @param property Property to check for
|
||||||
|
* @return Whether this state has the property.
|
||||||
|
*/
|
||||||
<T extends Comparable<T>> boolean has(Property<T> property);
|
<T extends Comparable<T>> boolean has(Property<T> property);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of a {@link Property} on this state.
|
||||||
|
* @param property Property to get
|
||||||
|
* @return Value of the property
|
||||||
|
*/
|
||||||
<T extends Comparable<T>> T get(Property<T> property);
|
<T extends Comparable<T>> T get(Property<T> property);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a new {@link BlockState} with a {@link Property} set to a value.
|
||||||
|
* @param property Property to set
|
||||||
|
* @param value Value of property
|
||||||
|
* @return New {@link BlockState} with property set.
|
||||||
|
*/
|
||||||
<T extends Comparable<T>> BlockState set(Property<T> property, T value);
|
<T extends Comparable<T>> BlockState set(Property<T> property, T value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform an action on this {@link BlockState} if it contains a {@link Property}
|
||||||
|
* @param property Property to check for
|
||||||
|
* @param action Action to perform if property is present
|
||||||
|
* @return This {@link BlockState}
|
||||||
|
*/
|
||||||
default <T extends Comparable<T>> BlockState ifProperty(Property<T> property, Consumer<BlockState> action) {
|
default <T extends Comparable<T>> BlockState ifProperty(Property<T> property, Consumer<BlockState> action) {
|
||||||
if(has(property)) action.accept(this);
|
if(has(property)) action.accept(this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of a {@link Property} on this {@link BlockState} if it is present.
|
||||||
|
* @param property Property to check for/set.
|
||||||
|
* @param value Value to set if property is present.
|
||||||
|
* @return Thie {@link BlockState}
|
||||||
|
*/
|
||||||
default <T extends Comparable<T>> BlockState setIfPresent(Property<T> property, T value) {
|
default <T extends Comparable<T>> BlockState setIfPresent(Property<T> property, T value) {
|
||||||
if(has(property)) set(property, value);
|
if(has(property)) set(property, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link BlockType} this state applies to.
|
||||||
|
* @return Block type.
|
||||||
|
*/
|
||||||
BlockType getBlockType();
|
BlockType getBlockType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get this state and its properties as a String
|
||||||
|
* @return String representation of this state
|
||||||
|
*/
|
||||||
default String getAsString() {
|
default String getAsString() {
|
||||||
return getAsString(true);
|
return getAsString(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get this state and its properties as a String
|
||||||
|
* @param properties Whether to include properties
|
||||||
|
* @return String representation of this state
|
||||||
|
*/
|
||||||
String getAsString(boolean properties);
|
String getAsString(boolean properties);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this BlockState is air
|
||||||
|
* @return Whether this state is air
|
||||||
|
*/
|
||||||
boolean isAir();
|
boolean isAir();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,24 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.api.block.state.properties;
|
package com.dfsek.terra.api.block.state.properties;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
|
||||||
public interface Property<T> {
|
/**
|
||||||
|
* Represents a property a state holds
|
||||||
|
*/
|
||||||
|
public interface Property<T> extends StringIdentifiable {
|
||||||
|
/**
|
||||||
|
* Get all possible values of this property
|
||||||
|
* @return All values of this property
|
||||||
|
*/
|
||||||
Collection<T> values();
|
Collection<T> values();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of this property.
|
||||||
|
* @return {@link Class} instance representing the type of this property
|
||||||
|
*/
|
||||||
Class<T> getType();
|
Class<T> getType();
|
||||||
|
|
||||||
String getName();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public interface BooleanProperty extends Property<Boolean> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getID() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public interface EnumProperty<T extends Enum<T>> extends Property<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getID() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public interface IntProperty extends Property<Integer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getID() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,5 +12,8 @@ import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
|||||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abstractable config template
|
||||||
|
*/
|
||||||
public interface AbstractableTemplate extends ConfigTemplate, StringIdentifiable {
|
public interface AbstractableTemplate extends ConfigTemplate, StringIdentifiable {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,24 +10,45 @@ package com.dfsek.terra.api.structure.feature;
|
|||||||
import java.util.function.IntConsumer;
|
import java.util.function.IntConsumer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A column of binary data
|
||||||
|
*/
|
||||||
public class BinaryColumn {
|
public class BinaryColumn {
|
||||||
private final boolean[] data;
|
private final boolean[] data;
|
||||||
private final int minY;
|
private final int minY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new {@link BinaryColumn} with all values initiated to {@code false}
|
||||||
|
* @param minY Minimum Y value
|
||||||
|
* @param maxY Maximum Y value
|
||||||
|
*/
|
||||||
public BinaryColumn(int minY, int maxY) {
|
public BinaryColumn(int minY, int maxY) {
|
||||||
this.minY = minY;
|
this.minY = minY;
|
||||||
if(maxY <= minY) throw new IllegalArgumentException("Max y must be greater than min y");
|
if(maxY <= minY) throw new IllegalArgumentException("Max y must be greater than min y");
|
||||||
this.data = new boolean[maxY - minY];
|
this.data = new boolean[maxY - minY];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of a height to {@code true}.
|
||||||
|
* @param y Height of entry to set.
|
||||||
|
*/
|
||||||
public void set(int y) {
|
public void set(int y) {
|
||||||
data[y - minY] = true;
|
data[y - minY] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value at a height.
|
||||||
|
* @param y Height of entry to get.
|
||||||
|
* @return Whether height has been set.
|
||||||
|
*/
|
||||||
public boolean get(int y) {
|
public boolean get(int y) {
|
||||||
return data[y - minY];
|
return data[y - minY];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform an action for all heights which have been set.
|
||||||
|
* @param consumer Action to perform
|
||||||
|
*/
|
||||||
public void forEach(IntConsumer consumer) {
|
public void forEach(IntConsumer consumer) {
|
||||||
for(int y = 0; y < data.length; y++) {
|
for(int y = 0; y < data.length; y++) {
|
||||||
if(data[y]) {
|
if(data[y]) {
|
||||||
@@ -36,6 +57,13 @@ public class BinaryColumn {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a {@link BinaryColumn} of equal height with a boolean AND operation applied to each height.
|
||||||
|
* @param that Other binary column, must match this column's height.
|
||||||
|
* @return Merged column.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if column heights do not match
|
||||||
|
*/
|
||||||
public BinaryColumn and(BinaryColumn that) {
|
public BinaryColumn and(BinaryColumn that) {
|
||||||
if(that.minY != this.minY) throw new IllegalArgumentException("Must share same min Y");
|
if(that.minY != this.minY) throw new IllegalArgumentException("Must share same min Y");
|
||||||
if(that.data.length != this.data.length) throw new IllegalArgumentException("Must share same max Y");
|
if(that.data.length != this.data.length) throw new IllegalArgumentException("Must share same max Y");
|
||||||
@@ -48,6 +76,13 @@ public class BinaryColumn {
|
|||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a {@link BinaryColumn} of equal height with a boolean OR operation applied to each height.
|
||||||
|
* @param that Other binary column, must match this column's height.
|
||||||
|
* @return Merged column.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if column heights do not match
|
||||||
|
*/
|
||||||
public BinaryColumn or(BinaryColumn that) {
|
public BinaryColumn or(BinaryColumn that) {
|
||||||
if(that.minY != this.minY) throw new IllegalArgumentException("Must share same min Y");
|
if(that.minY != this.minY) throw new IllegalArgumentException("Must share same min Y");
|
||||||
if(that.data.length != this.data.length) throw new IllegalArgumentException("Must share same max Y");
|
if(that.data.length != this.data.length) throw new IllegalArgumentException("Must share same max Y");
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when all transformation attempts fail
|
||||||
|
*/
|
||||||
public class AttemptsFailedException extends RuntimeException {
|
public class AttemptsFailedException extends RuntimeException {
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = -1160459550006067137L;
|
private static final long serialVersionUID = -1160459550006067137L;
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ import com.dfsek.terra.api.util.MathUtil;
|
|||||||
/**
|
/**
|
||||||
* oh yeah
|
* oh yeah
|
||||||
*/
|
*/
|
||||||
public class Vector2 implements Cloneable {
|
public class Vector2 {
|
||||||
private final double x;
|
protected double x;
|
||||||
private final double z;
|
protected double z;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a vector with a given X and Z component
|
* Create a vector with a given X and Z component
|
||||||
@@ -127,12 +127,10 @@ public class Vector2 implements Cloneable {
|
|||||||
return new Mutable(x, z);
|
return new Mutable(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Mutable {
|
public static class Mutable extends Vector2 {
|
||||||
private double x, z;
|
|
||||||
|
|
||||||
private Mutable(double x, double z) {
|
private Mutable(double x, double z) {
|
||||||
this.x = x;
|
super(x, z);
|
||||||
this.z = z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getX() {
|
public double getX() {
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package com.dfsek.terra.api.util.vector;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.util.Rotation;
|
import com.dfsek.terra.api.util.Rotation;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* oh yeah
|
* oh yeah
|
||||||
@@ -11,8 +9,8 @@ import java.util.Objects;
|
|||||||
public class Vector2Int {
|
public class Vector2Int {
|
||||||
private static final Vector2Int ZERO = new Vector2Int(0, 0);
|
private static final Vector2Int ZERO = new Vector2Int(0, 0);
|
||||||
private static final Vector2Int UNIT = new Vector2Int(0, 1);
|
private static final Vector2Int UNIT = new Vector2Int(0, 1);
|
||||||
private final int x;
|
protected int x;
|
||||||
private final int z;
|
protected int z;
|
||||||
|
|
||||||
protected Vector2Int(int x, int z) {
|
protected Vector2Int(int x, int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@@ -56,12 +54,10 @@ public class Vector2Int {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Mutable {
|
public static class Mutable extends Vector2Int {
|
||||||
private int x, z;
|
|
||||||
|
|
||||||
protected Mutable(int x, int z) {
|
protected Mutable(int x, int z) {
|
||||||
this.x = x;
|
super(x, z);
|
||||||
this.z = z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getZ() {
|
public int getZ() {
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ import com.dfsek.terra.api.util.MathUtil;
|
|||||||
|
|
||||||
|
|
||||||
public class Vector3 {
|
public class Vector3 {
|
||||||
private final double x;
|
protected double x;
|
||||||
private final double y;
|
protected double y;
|
||||||
private final double z;
|
protected double z;
|
||||||
|
|
||||||
private Vector3(double x, double y, double z) {
|
private Vector3(double x, double y, double z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@@ -146,13 +146,9 @@ public class Vector3 {
|
|||||||
return new Mutable(x, y, z);
|
return new Mutable(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Mutable {
|
public static class Mutable extends Vector3 {
|
||||||
private double x, y, z;
|
|
||||||
|
|
||||||
private Mutable(double x, double y, double z) {
|
private Mutable(double x, double y, double z) {
|
||||||
this.x = x;
|
super(x, y, z);
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Mutable of(double x, double y, double z) {
|
public static Mutable of(double x, double y, double z) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package com.dfsek.terra.api.util.vector;
|
|||||||
public class Vector3Int {
|
public class Vector3Int {
|
||||||
private static final Vector3Int ZERO = new Vector3Int(0, 0, 0);
|
private static final Vector3Int ZERO = new Vector3Int(0, 0, 0);
|
||||||
private static final Vector3Int UNIT = new Vector3Int(0, 1, 0);
|
private static final Vector3Int UNIT = new Vector3Int(0, 1, 0);
|
||||||
private final int x, y, z;
|
protected int x, y, z;
|
||||||
|
|
||||||
protected Vector3Int(int x, int y, int z) {
|
protected Vector3Int(int x, int y, int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@@ -48,13 +48,9 @@ public class Vector3Int {
|
|||||||
return Vector3.Mutable.of(x, y, z);
|
return Vector3.Mutable.of(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Mutable {
|
public static class Mutable extends Vector3Int {
|
||||||
private int x, y, z;
|
|
||||||
|
|
||||||
protected Mutable(int x, int y, int z) {
|
protected Mutable(int x, int y, int z) {
|
||||||
this.x = x;
|
super(x, y, z);
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getX() {
|
public int getX() {
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
|||||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link WritableWorld} implementation which delegates read/write operations to
|
||||||
|
* another {@link WritableWorld}, at an offset.
|
||||||
|
*/
|
||||||
public class BufferedWorld implements WritableWorld {
|
public class BufferedWorld implements WritableWorld {
|
||||||
private final WritableWorld delegate;
|
private final WritableWorld delegate;
|
||||||
private final int offsetX, offsetY, offsetZ;
|
private final int offsetX, offsetY, offsetZ;
|
||||||
@@ -76,6 +80,10 @@ public class BufferedWorld implements WritableWorld {
|
|||||||
return delegate.spawnEntity(x + offsetX, y + offsetY, z + offsetZ, entityType);
|
return delegate.spawnEntity(x + offsetX, y + offsetY, z + offsetZ, entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the world this {@link BufferedWorld} delegates to.
|
||||||
|
* @return Delegate world.
|
||||||
|
*/
|
||||||
public WritableWorld getDelegate() {
|
public WritableWorld getDelegate() {
|
||||||
return delegate;
|
return delegate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,25 +6,37 @@ import com.dfsek.terra.api.util.vector.Vector3;
|
|||||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link World} with read access.
|
||||||
|
*/
|
||||||
public interface ReadableWorld extends World {
|
public interface ReadableWorld extends World {
|
||||||
|
/**
|
||||||
|
* Get the {@link BlockState} at a location.
|
||||||
|
* @param x X coordinate
|
||||||
|
* @param y Y coordinate
|
||||||
|
* @param z Z coordinate
|
||||||
|
* @return {@link BlockState} at coordinates.
|
||||||
|
*/
|
||||||
BlockState getBlockState(int x, int y, int z);
|
BlockState getBlockState(int x, int y, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link BlockState} at a location.
|
||||||
|
* @param position Location to get block.
|
||||||
|
* @return {@link BlockState} at coordinates.
|
||||||
|
*/
|
||||||
default BlockState getBlockState(Vector3 position) {
|
default BlockState getBlockState(Vector3 position) {
|
||||||
return getBlockState(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
return getBlockState(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
default BlockState getBlockState(Vector3.Mutable position) {
|
/**
|
||||||
return getBlockState(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
* Get the {@link BlockState} at a location.
|
||||||
}
|
* @param position Location to get block.
|
||||||
|
* @return {@link BlockState} at coordinates.
|
||||||
|
*/
|
||||||
default BlockState getBlockState(Vector3Int position) {
|
default BlockState getBlockState(Vector3Int position) {
|
||||||
return getBlockState(position.getX(), position.getY(), position.getZ());
|
return getBlockState(position.getX(), position.getY(), position.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
default BlockState getBlockState(Vector3Int.Mutable position) {
|
|
||||||
return getBlockState(position.getX(), position.getY(), position.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockEntity getBlockEntity(int x, int y, int z);
|
BlockEntity getBlockEntity(int x, int y, int z);
|
||||||
|
|
||||||
default BlockEntity getBlockEntity(Vector3 position) {
|
default BlockEntity getBlockEntity(Vector3 position) {
|
||||||
|
|||||||
@@ -6,10 +6,25 @@ import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
|||||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a world.
|
||||||
|
*/
|
||||||
public interface World extends WorldProperties {
|
public interface World extends WorldProperties {
|
||||||
|
/**
|
||||||
|
* Get the {@link ChunkGenerator} this world uses.
|
||||||
|
* @return Chunk generator.
|
||||||
|
*/
|
||||||
ChunkGenerator getGenerator();
|
ChunkGenerator getGenerator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link BiomeProvider} this world uses.
|
||||||
|
* @return Biome provider.
|
||||||
|
*/
|
||||||
BiomeProvider getBiomeProvider();
|
BiomeProvider getBiomeProvider();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link ConfigPack} this world uses.
|
||||||
|
* @return Config pack.
|
||||||
|
*/
|
||||||
ConfigPack getPack();
|
ConfigPack getPack();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,23 +11,30 @@ package com.dfsek.terra.api.world.biome;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.dfsek.terra.api.properties.PropertyHolder;
|
import com.dfsek.terra.api.properties.PropertyHolder;
|
||||||
|
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a custom biome
|
* Represents a Terra biome
|
||||||
*/
|
*/
|
||||||
public interface Biome extends PropertyHolder {
|
public interface Biome extends PropertyHolder, StringIdentifiable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Vanilla biome to represent the custom biome.
|
* Gets the platform biome this custom biome delegates to.
|
||||||
*
|
*
|
||||||
* @return TerraBiome - The Vanilla biome.
|
* @return The platform biome.
|
||||||
*/
|
*/
|
||||||
PlatformBiome getPlatformBiome();
|
PlatformBiome getPlatformBiome();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the color of this biome.
|
||||||
|
* @return ARGB color of this biome
|
||||||
|
*/
|
||||||
int getColor();
|
int getColor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the tags this biome holds
|
||||||
|
* @return A {@link Set} of String tags this biome holds.
|
||||||
|
*/
|
||||||
Set<String> getTags();
|
Set<String> getTags();
|
||||||
|
|
||||||
String getID();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,16 +12,51 @@ import com.dfsek.terra.api.util.vector.Vector3;
|
|||||||
import com.dfsek.terra.api.world.biome.Biome;
|
import com.dfsek.terra.api.world.biome.Biome;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides locations of biomes in a world.
|
||||||
|
*/
|
||||||
public interface BiomeProvider {
|
public interface BiomeProvider {
|
||||||
|
/**
|
||||||
|
* Get the biome at a location.
|
||||||
|
*
|
||||||
|
* @param x X coordinate
|
||||||
|
* @param z Z coordinate
|
||||||
|
* @param seed World seed
|
||||||
|
*
|
||||||
|
* @return Biome at the location
|
||||||
|
*/
|
||||||
Biome getBiome(int x, int z, long seed);
|
Biome getBiome(int x, int z, long seed);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the biome at a location.
|
||||||
|
*
|
||||||
|
* @param vector2 Location
|
||||||
|
* @param seed World seed
|
||||||
|
*
|
||||||
|
* @return Biome at the location
|
||||||
|
*/
|
||||||
default Biome getBiome(Vector2 vector2, long seed) {
|
default Biome getBiome(Vector2 vector2, long seed) {
|
||||||
return getBiome(vector2.getBlockX(), vector2.getBlockZ(), seed);
|
return getBiome(vector2.getBlockX(), vector2.getBlockZ(), seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the biome at a location.
|
||||||
|
*
|
||||||
|
* @param vector3 Location
|
||||||
|
* @param seed World seed
|
||||||
|
*
|
||||||
|
* @return Biome at the location
|
||||||
|
*/
|
||||||
default Biome getBiome(Vector3 vector3, long seed) {
|
default Biome getBiome(Vector3 vector3, long seed) {
|
||||||
return getBiome(vector3.getBlockX(), vector3.getBlockZ(), seed);
|
return getBiome(vector3.getBlockX(), vector3.getBlockZ(), seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all biomes this {@link BiomeProvider} is capable of generating in the world.
|
||||||
|
* <p>
|
||||||
|
* Must contain all biomes that could possibly generate.
|
||||||
|
*
|
||||||
|
* @return {@link Iterable} of all biomes this provider can generate.
|
||||||
|
*/
|
||||||
Iterable<Biome> getBiomes();
|
Iterable<Biome> getBiomes();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ package com.dfsek.terra.fabric.mixin.implementations.block.state;
|
|||||||
import com.dfsek.terra.api.block.state.properties.Property;
|
import com.dfsek.terra.api.block.state.properties.Property;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Implements;
|
||||||
|
import org.spongepowered.asm.mixin.Interface;
|
||||||
|
import org.spongepowered.asm.mixin.Interface.Remap;
|
||||||
|
import org.spongepowered.asm.mixin.Intrinsic;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
@@ -10,7 +14,8 @@ import java.util.Collection;
|
|||||||
|
|
||||||
|
|
||||||
@Mixin(net.minecraft.state.property.Property.class)
|
@Mixin(net.minecraft.state.property.Property.class)
|
||||||
public abstract class PropertyMixin<T> implements Property<T> {
|
@Implements(@Interface(iface = Property.class, prefix = "terra$", remap = Remap.NONE))
|
||||||
|
public abstract class PropertyMixin<T> {
|
||||||
@Shadow
|
@Shadow
|
||||||
@Final
|
@Final
|
||||||
private Class<T> type;
|
private Class<T> type;
|
||||||
@@ -22,18 +27,18 @@ public abstract class PropertyMixin<T> implements Property<T> {
|
|||||||
@Final
|
@Final
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Override
|
@Intrinsic
|
||||||
public Collection<T> values() {
|
public Collection<T> terra$values() {
|
||||||
return getValues();
|
return getValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Intrinsic
|
||||||
public Class<T> getType() {
|
public Class<T> terra$getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Intrinsic
|
||||||
public String getName() {
|
public String terra$getID() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user