mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
BlockData -> BlockState
This commit is contained in:
@@ -2,13 +2,13 @@ package com.dfsek.terra.api.block;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
|
||||
public interface BlockData extends Cloneable, Handle {
|
||||
public interface BlockState extends Cloneable, Handle {
|
||||
|
||||
BlockType getBlockType();
|
||||
|
||||
boolean matches(BlockData other);
|
||||
boolean matches(BlockState other);
|
||||
|
||||
BlockData clone();
|
||||
BlockState clone();
|
||||
|
||||
String getAsString();
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.api.block;
|
||||
import com.dfsek.terra.api.Handle;
|
||||
|
||||
public interface BlockType extends Handle {
|
||||
BlockData getDefaultData();
|
||||
BlockState getDefaultData();
|
||||
|
||||
boolean isSolid();
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.api.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
|
||||
public interface AnaloguePowerable extends BlockData {
|
||||
public interface AnaloguePowerable extends BlockState {
|
||||
int getMaximumPower();
|
||||
|
||||
int getPower();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.api.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
|
||||
public interface Bisected extends BlockData {
|
||||
public interface Bisected extends BlockState {
|
||||
Half getHalf();
|
||||
|
||||
void setHalf(Half half);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.api.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
|
||||
public interface Directional extends BlockData {
|
||||
public interface Directional extends BlockState {
|
||||
BlockFace getFacing();
|
||||
|
||||
void setFacing(BlockFace facing);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.api.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface MultipleFacing extends BlockData {
|
||||
public interface MultipleFacing extends BlockState {
|
||||
Set<BlockFace> getFaces();
|
||||
|
||||
void setFace(BlockFace face, boolean facing);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.api.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.Axis;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface Orientable extends BlockData {
|
||||
public interface Orientable extends BlockState {
|
||||
Set<Axis> getAxes();
|
||||
|
||||
Axis getAxis();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.api.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
|
||||
public interface Rail extends BlockData {
|
||||
public interface Rail extends BlockState {
|
||||
Shape getShape();
|
||||
|
||||
void setShape(Shape newShape);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.api.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface RedstoneWire extends BlockData, AnaloguePowerable {
|
||||
public interface RedstoneWire extends BlockState, AnaloguePowerable {
|
||||
Set<BlockFace> getAllowedFaces();
|
||||
|
||||
Connection getFace(BlockFace face);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.api.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
|
||||
public interface Rotatable extends BlockData {
|
||||
public interface Rotatable extends BlockState {
|
||||
BlockFace getRotation();
|
||||
|
||||
void setRotation(BlockFace face);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.api.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
|
||||
public interface Wall extends BlockData, Waterlogged {
|
||||
public interface Wall extends BlockState, Waterlogged {
|
||||
boolean isUp();
|
||||
|
||||
void setHeight(BlockFace face, Height height);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.api.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
|
||||
public interface Waterlogged extends BlockData {
|
||||
public interface Waterlogged extends BlockState {
|
||||
boolean isWaterlogged();
|
||||
|
||||
void setWaterlogged(boolean waterlogged);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.block.state;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
|
||||
public interface BlockEntity extends Handle {
|
||||
@@ -13,7 +13,7 @@ public interface BlockEntity extends Handle {
|
||||
|
||||
int getZ();
|
||||
|
||||
BlockData getBlockData();
|
||||
BlockState getBlockData();
|
||||
|
||||
boolean update(boolean applyPhysics);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.api.handle;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.vector.Vector3;
|
||||
* Interface to be implemented for world manipulation.
|
||||
*/
|
||||
public interface WorldHandle {
|
||||
BlockData createBlockData(String data);
|
||||
BlockState createBlockData(String data);
|
||||
|
||||
EntityType getEntity(String id);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.api.world;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
|
||||
public interface Chunk extends ChunkAccess {
|
||||
int getX();
|
||||
@@ -9,11 +9,11 @@ public interface Chunk extends ChunkAccess {
|
||||
|
||||
World getWorld();
|
||||
|
||||
BlockData getBlock(int x, int y, int z);
|
||||
BlockState getBlock(int x, int y, int z);
|
||||
|
||||
void setBlock(int x, int y, int z, BlockData data, boolean physics);
|
||||
void setBlock(int x, int y, int z, BlockState data, boolean physics);
|
||||
|
||||
default void setBlock(int x, int y, int z, BlockData data) {
|
||||
default void setBlock(int x, int y, int z, BlockState data) {
|
||||
setBlock(x, y, z, data, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.world;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface ChunkAccess extends Handle {
|
||||
@@ -13,9 +13,9 @@ public interface ChunkAccess extends Handle {
|
||||
* @param x the x location in the chunk from 0-15 inclusive
|
||||
* @param y the y location in the chunk from 0 (inclusive) - maxHeight (exclusive)
|
||||
* @param z the z location in the chunk from 0-15 inclusive
|
||||
* @param blockData the type to set the block to
|
||||
* @param blockState the type to set the block to
|
||||
*/
|
||||
void setBlock(int x, int y, int z, @NotNull BlockData blockData);
|
||||
void setBlock(int x, int y, int z, @NotNull BlockState blockState);
|
||||
|
||||
/**
|
||||
* Get the type and data of the block at x, y, z.
|
||||
@@ -27,5 +27,5 @@ public interface ChunkAccess extends Handle {
|
||||
* @param z the z location in the chunk from 0-15 inclusive
|
||||
* @return the data of the block or the BlockData for air if x, y or z are outside the chunk's bounds
|
||||
*/
|
||||
@NotNull BlockData getBlock(int x, int y, int z);
|
||||
@NotNull BlockState getBlock(int x, int y, int z);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.api.world;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
@@ -22,7 +22,7 @@ public interface TerraWorld {
|
||||
* @param z Z coordinate
|
||||
* @return BlockData
|
||||
*/
|
||||
BlockData getUngeneratedBlock(int x, int y, int z);
|
||||
BlockState getUngeneratedBlock(int x, int y, int z);
|
||||
|
||||
BlockData getUngeneratedBlock(Vector3 v);
|
||||
BlockState getUngeneratedBlock(Vector3 v);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.world;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.state.BlockEntity;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
@@ -23,23 +23,23 @@ public interface World extends Handle {
|
||||
return getChunkAt(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
}
|
||||
|
||||
BlockData getBlockData(int x, int y, int z);
|
||||
BlockState getBlockData(int x, int y, int z);
|
||||
|
||||
default BlockData getBlockData(Vector3 position) {
|
||||
default BlockState getBlockData(Vector3 position) {
|
||||
return getBlockData(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
}
|
||||
|
||||
void setBlockData(int x, int y, int z, BlockData data, boolean physics);
|
||||
void setBlockData(int x, int y, int z, BlockState data, boolean physics);
|
||||
|
||||
default void setBlockData(int x, int y, int z, BlockData data) {
|
||||
default void setBlockData(int x, int y, int z, BlockState data) {
|
||||
setBlockData(x, y, z, data, false);
|
||||
}
|
||||
|
||||
default void setBlockData(Vector3 position, BlockData data) {
|
||||
default void setBlockData(Vector3 position, BlockState data) {
|
||||
setBlockData(position, data, false);
|
||||
}
|
||||
|
||||
default void setBlockData(Vector3 position, BlockData data, boolean physics) {
|
||||
default void setBlockData(Vector3 position, BlockState data, boolean physics) {
|
||||
setBlockData(position.getBlockX(), position.getBlockY(), position.getBlockZ(), data, physics);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.dfsek.terra.api.world.generator;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.ProbabilityCollection;
|
||||
|
||||
public interface Palette {
|
||||
Palette add(BlockData m, int layers, NoiseSampler sampler);
|
||||
Palette add(BlockState m, int layers, NoiseSampler sampler);
|
||||
|
||||
Palette add(ProbabilityCollection<BlockData> m, int layers, NoiseSampler sampler);
|
||||
Palette add(ProbabilityCollection<BlockState> m, int layers, NoiseSampler sampler);
|
||||
|
||||
/**
|
||||
* Fetches a material from the palette, at a given layer.
|
||||
@@ -15,7 +15,7 @@ public interface Palette {
|
||||
* @param layer - The layer at which to fetch the material.
|
||||
* @return BlockData - The material fetched.
|
||||
*/
|
||||
BlockData get(int layer, double x, double y, double z);
|
||||
BlockState get(int layer, double x, double y, double z);
|
||||
|
||||
int getSize();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.script.functions;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.structures.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.api.structures.parser.lang.Returnable;
|
||||
import com.dfsek.terra.api.structures.parser.lang.functions.Function;
|
||||
@@ -34,7 +34,7 @@ public abstract class AbstractBlockFunction implements Function<Void> {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
void setBlock(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap, TerraImplementationArguments arguments, BlockData rot) {
|
||||
void setBlock(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap, TerraImplementationArguments arguments, BlockState rot) {
|
||||
Vector2 xz = new Vector2Impl(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.script.functions;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.structures.parser.exceptions.ParseException;
|
||||
import com.dfsek.terra.api.structures.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.api.structures.parser.lang.Returnable;
|
||||
@@ -13,7 +13,7 @@ import com.dfsek.terra.api.structures.tokenizer.Position;
|
||||
import java.util.Map;
|
||||
|
||||
public class BlockFunction extends AbstractBlockFunction {
|
||||
private final BlockData data;
|
||||
private final BlockState data;
|
||||
|
||||
public BlockFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Returnable<String> data, Returnable<Boolean> overwrite, TerraPlugin main, Position position) throws ParseException {
|
||||
super(x, y, z, data, overwrite, main, position);
|
||||
@@ -29,7 +29,7 @@ public class BlockFunction extends AbstractBlockFunction {
|
||||
@Override
|
||||
public Void apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
BlockData rot = data.clone();
|
||||
BlockState rot = data.clone();
|
||||
setBlock(implementationArguments, variableMap, arguments, rot);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.script.functions;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.structures.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.api.structures.parser.lang.Returnable;
|
||||
import com.dfsek.terra.api.structures.parser.lang.variables.Variable;
|
||||
@@ -12,7 +12,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DynamicBlockFunction extends AbstractBlockFunction {
|
||||
private final Map<String, BlockData> data = new HashMap<>();
|
||||
private final Map<String, BlockState> data = new HashMap<>();
|
||||
private final Position position;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DynamicBlockFunction extends AbstractBlockFunction {
|
||||
@Override
|
||||
public Void apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
BlockData rot = data.computeIfAbsent(blockData.apply(implementationArguments, variableMap), main.getWorldHandle()::createBlockData).clone();
|
||||
BlockState rot = data.computeIfAbsent(blockData.apply(implementationArguments, variableMap), main.getWorldHandle()::createBlockData).clone();
|
||||
setBlock(implementationArguments, variableMap, arguments, rot);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.script.functions;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.structures.parser.exceptions.ParseException;
|
||||
import com.dfsek.terra.api.structures.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.api.structures.parser.lang.Returnable;
|
||||
@@ -20,7 +20,7 @@ import net.jafama.FastMath;
|
||||
import java.util.Map;
|
||||
|
||||
public class PullFunction implements Function<Void> {
|
||||
private final BlockData data;
|
||||
private final BlockState data;
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class PullFunction implements Function<Void> {
|
||||
Vector2 xz = new Vector2Impl(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
BlockData rot = data.clone();
|
||||
BlockState rot = data.clone();
|
||||
RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse());
|
||||
arguments.getBuffer().addItem(new BufferedPulledBlock(rot), new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())));
|
||||
return null;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package com.dfsek.terra.api.structures.structure.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.data.Waterlogged;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
public class BufferedBlock implements BufferedItem {
|
||||
private final BlockData data;
|
||||
private final BlockState data;
|
||||
private final boolean overwrite;
|
||||
private final TerraPlugin main;
|
||||
private final boolean waterlog;
|
||||
|
||||
public BufferedBlock(BlockData data, boolean overwrite, TerraPlugin main, boolean waterlog) {
|
||||
public BufferedBlock(BlockState data, boolean overwrite, TerraPlugin main, boolean waterlog) {
|
||||
this.data = data;
|
||||
this.overwrite = overwrite;
|
||||
this.main = main;
|
||||
@@ -23,7 +23,7 @@ public class BufferedBlock implements BufferedItem {
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
try {
|
||||
BlockData current = world.getBlockData(origin);
|
||||
BlockState current = world.getBlockData(origin);
|
||||
if(overwrite || current.isAir()) {
|
||||
if(waterlog && current instanceof Waterlogged && current.getBlockType().isWater())
|
||||
((Waterlogged) current).setWaterlogged(true);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.dfsek.terra.api.structures.structure.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
public class BufferedPulledBlock implements BufferedItem {
|
||||
private final BlockData data;
|
||||
private final BlockState data;
|
||||
|
||||
public BufferedPulledBlock(BlockData data) {
|
||||
public BufferedPulledBlock(BlockState data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.util;
|
||||
|
||||
import com.dfsek.terra.api.block.Axis;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
import com.dfsek.terra.api.block.data.Directional;
|
||||
import com.dfsek.terra.api.block.data.MultipleFacing;
|
||||
@@ -249,7 +249,7 @@ public class RotationUtil {
|
||||
return orig;
|
||||
}
|
||||
|
||||
public static void rotateBlockData(BlockData data, Rotation r) {
|
||||
public static void rotateBlockData(BlockState data, Rotation r) {
|
||||
if(data instanceof Rotatable) {
|
||||
BlockFace rt = getRotatedFace(((Rotatable) data).getRotation(), r);
|
||||
((Rotatable) data).setRotation(rt);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.api.util.collections;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -21,7 +21,7 @@ public class MaterialSet extends HashSet<BlockType> {
|
||||
return set;
|
||||
}
|
||||
|
||||
public static MaterialSet get(BlockData... materials) {
|
||||
public static MaterialSet get(BlockState... materials) {
|
||||
MaterialSet set = new MaterialSet();
|
||||
Arrays.stream(materials).forEach(set::add);
|
||||
return set;
|
||||
@@ -31,7 +31,7 @@ public class MaterialSet extends HashSet<BlockType> {
|
||||
return new MaterialSet();
|
||||
}
|
||||
|
||||
private void add(BlockData data) {
|
||||
private void add(BlockState data) {
|
||||
add(data.getBlockType());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.api.world.palette;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
import java.util.List;
|
||||
@@ -15,7 +15,7 @@ public class NoisePalette extends PaletteImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData get(int layer, double x, double y, double z) {
|
||||
public BlockState get(int layer, double x, double y, double z) {
|
||||
PaletteLayer paletteLayer;
|
||||
if(layer > this.getSize()) paletteLayer = this.getLayers().get(this.getLayers().size() - 1);
|
||||
else {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.api.world.palette;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.GlueList;
|
||||
import com.dfsek.terra.api.util.ProbabilityCollection;
|
||||
@@ -24,7 +24,7 @@ public abstract class PaletteImpl implements com.dfsek.terra.api.world.generator
|
||||
}
|
||||
|
||||
@Override
|
||||
public Palette add(BlockData m, int layers, NoiseSampler sampler) {
|
||||
public Palette add(BlockState m, int layers, NoiseSampler sampler) {
|
||||
for(int i = 0; i < layers; i++) {
|
||||
pallet.add(new PaletteLayer(m, sampler));
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public abstract class PaletteImpl implements com.dfsek.terra.api.world.generator
|
||||
}
|
||||
|
||||
@Override
|
||||
public Palette add(ProbabilityCollection<BlockData> m, int layers, NoiseSampler sampler) {
|
||||
public Palette add(ProbabilityCollection<BlockState> m, int layers, NoiseSampler sampler) {
|
||||
for(int i = 0; i < layers; i++) {
|
||||
pallet.add(new PaletteLayer(m, sampler));
|
||||
}
|
||||
@@ -54,9 +54,9 @@ public abstract class PaletteImpl implements com.dfsek.terra.api.world.generator
|
||||
*/
|
||||
public static class PaletteLayer {
|
||||
private final boolean col; // Is layer using a collection?
|
||||
private ProbabilityCollection<BlockData> collection;
|
||||
private ProbabilityCollection<BlockState> collection;
|
||||
private final NoiseSampler sampler;
|
||||
private BlockData m;
|
||||
private BlockState m;
|
||||
|
||||
/**
|
||||
* Constructs a PaletteLayerHolder with a ProbabilityCollection of materials and a number of layers.
|
||||
@@ -64,7 +64,7 @@ public abstract class PaletteImpl implements com.dfsek.terra.api.world.generator
|
||||
* @param type The collection of materials to choose from.
|
||||
* @param sampler Noise sampler to use
|
||||
*/
|
||||
public PaletteLayer(ProbabilityCollection<BlockData> type, NoiseSampler sampler) {
|
||||
public PaletteLayer(ProbabilityCollection<BlockState> type, NoiseSampler sampler) {
|
||||
this.sampler = sampler;
|
||||
this.col = true;
|
||||
this.collection = type;
|
||||
@@ -76,7 +76,7 @@ public abstract class PaletteImpl implements com.dfsek.terra.api.world.generator
|
||||
* @param type The material to use.
|
||||
* @param sampler Noise sampler to use
|
||||
*/
|
||||
public PaletteLayer(BlockData type, NoiseSampler sampler) {
|
||||
public PaletteLayer(BlockState type, NoiseSampler sampler) {
|
||||
this.sampler = sampler;
|
||||
this.col = false;
|
||||
this.m = type;
|
||||
@@ -91,31 +91,31 @@ public abstract class PaletteImpl implements com.dfsek.terra.api.world.generator
|
||||
*
|
||||
* @return Material - the material..
|
||||
*/
|
||||
public BlockData get(Random random) {
|
||||
public BlockState get(Random random) {
|
||||
if(col) return this.collection.get(random);
|
||||
return m;
|
||||
}
|
||||
|
||||
public BlockData get(NoiseSampler random, double x, double y, double z, boolean is2D) {
|
||||
public BlockState get(NoiseSampler random, double x, double y, double z, boolean is2D) {
|
||||
if(col && is2D) return this.collection.get(random, x, z);
|
||||
else if(col) return this.collection.get(random, x, y, z);
|
||||
return m;
|
||||
}
|
||||
|
||||
public ProbabilityCollection<BlockData> getCollection() {
|
||||
public ProbabilityCollection<BlockState> getCollection() {
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Singleton extends PaletteImpl {
|
||||
private final BlockData item;
|
||||
private final BlockState item;
|
||||
|
||||
public Singleton(BlockData item) {
|
||||
public Singleton(BlockState item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData get(int layer, double x, double y, double z) {
|
||||
public BlockState get(int layer, double x, double y, double z) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package com.dfsek.terra.api.world.palette.holder;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.ProbabilityCollection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PaletteLayerHolder {
|
||||
private final ProbabilityCollection<BlockData> layer;
|
||||
private final ProbabilityCollection<BlockState> layer;
|
||||
private final NoiseSampler sampler;
|
||||
private final int size;
|
||||
|
||||
public PaletteLayerHolder(@NotNull ProbabilityCollection<BlockData> layer, NoiseSampler sampler, int size) {
|
||||
public PaletteLayerHolder(@NotNull ProbabilityCollection<BlockState> layer, NoiseSampler sampler, int size) {
|
||||
this.layer = layer;
|
||||
this.sampler = sampler;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ProbabilityCollection<BlockData> getLayer() {
|
||||
public ProbabilityCollection<BlockState> getLayer() {
|
||||
return layer;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.carving;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.util.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.collections.MaterialSet;
|
||||
@@ -13,8 +13,8 @@ import java.util.TreeMap;
|
||||
public class CarverPalette {
|
||||
private final boolean blacklist;
|
||||
private final MaterialSet replace;
|
||||
private final TreeMap<Integer, ProbabilityCollection<BlockData>> map = new TreeMap<>();
|
||||
private ProbabilityCollection<BlockData>[] layers;
|
||||
private final TreeMap<Integer, ProbabilityCollection<BlockState>> map = new TreeMap<>();
|
||||
private ProbabilityCollection<BlockState>[] layers;
|
||||
private int offset = 0;
|
||||
|
||||
public CarverPalette(MaterialSet replaceable, boolean blacklist) {
|
||||
@@ -22,12 +22,12 @@ public class CarverPalette {
|
||||
this.replace = replaceable;
|
||||
}
|
||||
|
||||
public CarverPalette add(ProbabilityCollection<BlockData> collection, int y) {
|
||||
public CarverPalette add(ProbabilityCollection<BlockState> collection, int y) {
|
||||
map.put(y, collection);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProbabilityCollection<BlockData> get(int y) {
|
||||
public ProbabilityCollection<BlockState> get(int y) {
|
||||
int index = y + offset;
|
||||
return index >= 0
|
||||
? index < layers.length
|
||||
@@ -49,8 +49,8 @@ public class CarverPalette {
|
||||
|
||||
layers = new ProbabilityCollection[map.lastKey() + 1 - min];
|
||||
for(int y = min; y <= FastMath.max(map.lastKey(), max); y++) {
|
||||
ProbabilityCollection<BlockData> d = null;
|
||||
for(Map.Entry<Integer, ProbabilityCollection<BlockData>> e : map.entrySet()) {
|
||||
ProbabilityCollection<BlockState> d = null;
|
||||
for(Map.Entry<Integer, ProbabilityCollection<BlockState>> e : map.entrySet()) {
|
||||
if(e.getKey() >= y) {
|
||||
d = e.getValue();
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.commands.structure;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.state.BlockEntity;
|
||||
import com.dfsek.terra.api.block.state.Sign;
|
||||
import com.dfsek.terra.api.command.CommandTemplate;
|
||||
@@ -75,7 +75,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
for(int y = l1.getBlockY(); y <= l2.getBlockY(); y++) {
|
||||
for(int z = l1.getBlockZ(); z <= l2.getBlockZ(); z++) {
|
||||
|
||||
BlockData data = player.world().getBlockData(x, y, z);
|
||||
BlockState data = player.world().getBlockData(x, y, z);
|
||||
if(data.isStructureVoid()) continue;
|
||||
BlockEntity state = player.world().getBlockState(x, y, z);
|
||||
if(state instanceof Sign) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.config.dummy;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.state.BlockEntity;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
@@ -37,12 +37,12 @@ public class DummyWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(int x, int y, int z) {
|
||||
public BlockState getBlockData(int x, int y, int z) {
|
||||
throw new UnsupportedOperationException("Cannot get block in DummyWorld");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockData(int x, int y, int z, BlockData data, boolean physics) {
|
||||
public void setBlockData(int x, int y, int z, BlockState data, boolean physics) {
|
||||
throw new UnsupportedOperationException("Cannot set block in DummyWorld");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.config.factories;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.config.templates.OreTemplate;
|
||||
import com.dfsek.terra.world.population.items.ores.Ore;
|
||||
import com.dfsek.terra.world.population.items.ores.VanillaOre;
|
||||
@@ -9,7 +9,7 @@ import com.dfsek.terra.world.population.items.ores.VanillaOre;
|
||||
public class OreFactory implements ConfigFactory<OreTemplate, Ore> {
|
||||
@Override
|
||||
public Ore build(OreTemplate config, TerraPlugin main) {
|
||||
BlockData m = config.getMaterial();
|
||||
BlockState m = config.getMaterial();
|
||||
return new VanillaOre(m, config.getReplaceable(), config.doPhysics(), config.getSize(), main, config.getMaterialOverrides());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.config.loaders;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.util.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.world.Flora;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
@@ -28,7 +28,7 @@ public final class Types {
|
||||
TERRA_BIOME_TERRA_BIOME_PROBABILITY_COLLECTION_MAP = getType("terraBiomeProbabilityCollectionMap");
|
||||
}
|
||||
|
||||
private ProbabilityCollection<BlockData> blockDataProbabilityCollection;
|
||||
private ProbabilityCollection<BlockState> blockStateProbabilityCollection;
|
||||
private ProbabilityCollection<Flora> floraProbabilityCollection;
|
||||
private ProbabilityCollection<Tree> treeProbabilityCollection;
|
||||
private ProbabilityCollection<TerraBiome> terraBiomeProbabilityCollection;
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.tectonic.config.Configuration;
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.util.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.collections.MaterialSet;
|
||||
import com.dfsek.terra.carving.CarverPalette;
|
||||
@@ -24,7 +24,7 @@ public class CarverPaletteLoader implements TypeLoader<CarverPalette> {
|
||||
CarverPalette palette = new CarverPalette((MaterialSet) configLoader.loadType(MaterialSet.class, configuration.get("replace")), (Boolean) configuration.get("replace-blacklist"));
|
||||
|
||||
for(Map<String, Object> map : (List<Map<String, Object>>) configuration.get("layers")) {
|
||||
ProbabilityCollection<BlockData> layer = (ProbabilityCollection<BlockData>) configLoader.loadType(Types.BLOCK_DATA_PROBABILITY_COLLECTION_TYPE, map.get("materials"));
|
||||
ProbabilityCollection<BlockState> layer = (ProbabilityCollection<BlockState>) configLoader.loadType(Types.BLOCK_DATA_PROBABILITY_COLLECTION_TYPE, map.get("materials"));
|
||||
palette.add(layer, (Integer) map.get("y"));
|
||||
}
|
||||
palette.build();
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.config.loaders.palette;
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
|
||||
@@ -18,7 +18,7 @@ public class PaletteLayerLoader implements TypeLoader<PaletteLayerHolder> {
|
||||
@Override
|
||||
public PaletteLayerHolder load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
Map<String, Object> map = (Map<String, Object>) o;
|
||||
ProbabilityCollection<BlockData> collection = (ProbabilityCollection<BlockData>) configLoader.loadType(Types.BLOCK_DATA_PROBABILITY_COLLECTION_TYPE, map.get("materials"));
|
||||
ProbabilityCollection<BlockState> collection = (ProbabilityCollection<BlockState>) configLoader.loadType(Types.BLOCK_DATA_PROBABILITY_COLLECTION_TYPE, map.get("materials"));
|
||||
|
||||
NoiseSampler sampler = null;
|
||||
if(map.containsKey("noise")) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.config.templates;
|
||||
import com.dfsek.tectonic.annotations.Abstractable;
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.util.collections.MaterialSet;
|
||||
@@ -18,12 +18,12 @@ public class OreTemplate extends AbstractableTemplate {
|
||||
|
||||
@Value("material")
|
||||
@Abstractable
|
||||
private BlockData material;
|
||||
private BlockState material;
|
||||
|
||||
@Value("material-overrides")
|
||||
@Default
|
||||
@Abstractable
|
||||
private Map<BlockType, BlockData> materials = new HashMap<>();
|
||||
private Map<BlockType, BlockState> materials = new HashMap<>();
|
||||
|
||||
@Value("replace")
|
||||
@Abstractable
|
||||
@@ -60,7 +60,7 @@ public class OreTemplate extends AbstractableTemplate {
|
||||
return size;
|
||||
}
|
||||
|
||||
public BlockData getMaterial() {
|
||||
public BlockState getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class OreTemplate extends AbstractableTemplate {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Map<BlockType, BlockData> getMaterialOverrides() {
|
||||
public Map<BlockType, BlockState> getMaterialOverrides() {
|
||||
return materials;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.world;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.event.events.world.TerraWorldLoadEvent;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
@@ -19,7 +19,7 @@ public class TerraWorldImpl implements TerraWorld {
|
||||
private final WorldConfigImpl config;
|
||||
private final boolean safe;
|
||||
private final World world;
|
||||
private final BlockData air;
|
||||
private final BlockState air;
|
||||
|
||||
|
||||
public TerraWorldImpl(World w, ConfigPack c, TerraPlugin main) {
|
||||
@@ -56,7 +56,7 @@ public class TerraWorldImpl implements TerraWorld {
|
||||
|
||||
|
||||
@Override
|
||||
public BlockData getUngeneratedBlock(int x, int y, int z) {
|
||||
public BlockState getUngeneratedBlock(int x, int y, int z) {
|
||||
UserDefinedBiome biome = (UserDefinedBiome) provider.getBiome(x, z);
|
||||
Palette palette = biome.getGenerator(world).getPalette(y);
|
||||
Sampler sampler = config.getSamplerCache().get(x, z);
|
||||
@@ -76,7 +76,7 @@ public class TerraWorldImpl implements TerraWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getUngeneratedBlock(Vector3 v) {
|
||||
public BlockState getUngeneratedBlock(Vector3 v) {
|
||||
return getUngeneratedBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.world.carving;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.world.ChunkAccess;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
@@ -11,10 +11,10 @@ import com.dfsek.terra.world.generation.math.interpolation.ChunkInterpolator3D;
|
||||
|
||||
public class NoiseCarver implements Carver {
|
||||
private final Range range;
|
||||
private final BlockData data;
|
||||
private final BlockState data;
|
||||
private final TerraPlugin main;
|
||||
|
||||
public NoiseCarver(Range range, BlockData data, TerraPlugin main) {
|
||||
public NoiseCarver(Range range, BlockState data, TerraPlugin main) {
|
||||
this.range = range;
|
||||
this.data = data;
|
||||
this.main = main;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.world.generation.generators;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.math.range.ConstantRange;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.util.PaletteUtil;
|
||||
@@ -92,7 +92,7 @@ public class DefaultChunkGenerator2D implements TerraChunkGenerator {
|
||||
int height = FastMath.min((int) sampler.sample(x, 0, z), world.getMaxHeight() - 1);
|
||||
|
||||
for(int y = FastMath.max(height, c.getSeaLevel()); y >= 0; y--) {
|
||||
BlockData data = y > height ? seaPalette.get(seaPaletteLevel++, cx, y, cz) : PaletteUtil.getPalette(x, y, z, c, sampler).get(paletteLevel++, cx, y, cz);
|
||||
BlockState data = y > height ? seaPalette.get(seaPaletteLevel++, cx, y, cz) : PaletteUtil.getPalette(x, y, z, c, sampler).get(paletteLevel++, cx, y, cz);
|
||||
chunk.setBlock(x, y, z, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.world.generation.generators;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.data.Bisected;
|
||||
@@ -103,7 +103,7 @@ public class DefaultChunkGenerator3D implements TerraChunkGenerator {
|
||||
Palette seaPalette = c.getOceanPalette();
|
||||
|
||||
boolean justSet = false;
|
||||
BlockData data = null;
|
||||
BlockState data = null;
|
||||
for(int y = world.getMaxHeight() - 1; y >= world.getMinHeight(); y--) {
|
||||
if(sampler.sample(x, y, z) > 0) {
|
||||
justSet = true;
|
||||
@@ -138,20 +138,20 @@ public class DefaultChunkGenerator3D implements TerraChunkGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareBlockPartFloor(BlockData down, BlockData orig, ChunkData chunk, Vector3 block, Map<BlockType, Palette> slabs,
|
||||
private void prepareBlockPartFloor(BlockState down, BlockState orig, ChunkData chunk, Vector3 block, Map<BlockType, Palette> slabs,
|
||||
Map<BlockType, Palette> stairs, double thresh, Sampler sampler) {
|
||||
if(sampler.sample(block.getX(), block.getY() - 0.4, block.getZ()) > thresh) {
|
||||
if(stairs != null) {
|
||||
Palette stairPalette = stairs.get(down.getBlockType());
|
||||
if(stairPalette != null) {
|
||||
BlockData stair = stairPalette.get(0, block.getX(), block.getY(), block.getZ()).clone();
|
||||
BlockState stair = stairPalette.get(0, block.getX(), block.getY(), block.getZ()).clone();
|
||||
if(stair instanceof Stairs) {
|
||||
Stairs stairNew = (Stairs) stair;
|
||||
if(placeStair(orig, chunk, block, thresh, sampler, stairNew)) return; // Successfully placed part.
|
||||
}
|
||||
}
|
||||
}
|
||||
BlockData slab = slabs.getOrDefault(down.getBlockType(), blank).get(0, block.getX(), block.getY(), block.getZ());
|
||||
BlockState slab = slabs.getOrDefault(down.getBlockType(), blank).get(0, block.getX(), block.getY(), block.getZ());
|
||||
if(slab instanceof Waterlogged) {
|
||||
((Waterlogged) slab).setWaterlogged(orig.getBlockType().equals(water));
|
||||
} else if(orig.getBlockType().equals(water)) return;
|
||||
@@ -159,13 +159,13 @@ public class DefaultChunkGenerator3D implements TerraChunkGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareBlockPartCeiling(BlockData up, BlockData orig, ChunkData chunk, Vector3 block, Map<BlockType, Palette> slabs,
|
||||
private void prepareBlockPartCeiling(BlockState up, BlockState orig, ChunkData chunk, Vector3 block, Map<BlockType, Palette> slabs,
|
||||
Map<BlockType, Palette> stairs, double thresh, Sampler sampler) {
|
||||
if(sampler.sample(block.getX(), block.getY() + 0.4, block.getZ()) > thresh) {
|
||||
if(stairs != null) {
|
||||
Palette stairPalette = stairs.get(up.getBlockType());
|
||||
if(stairPalette != null) {
|
||||
BlockData stair = stairPalette.get(0, block.getX(), block.getY(), block.getZ()).clone();
|
||||
BlockState stair = stairPalette.get(0, block.getX(), block.getY(), block.getZ()).clone();
|
||||
if(stair instanceof Stairs) {
|
||||
Stairs stairNew = (Stairs) stair.clone();
|
||||
stairNew.setHalf(Bisected.Half.TOP);
|
||||
@@ -173,7 +173,7 @@ public class DefaultChunkGenerator3D implements TerraChunkGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
BlockData slab = slabs.getOrDefault(up.getBlockType(), blank).get(0, block.getX(), block.getY(), block.getZ()).clone();
|
||||
BlockState slab = slabs.getOrDefault(up.getBlockType(), blank).get(0, block.getX(), block.getY(), block.getZ()).clone();
|
||||
if(slab instanceof Bisected) ((Bisected) slab).setHalf(Bisected.Half.TOP);
|
||||
if(slab instanceof Slab) ((Slab) slab).setType(Slab.Type.TOP);
|
||||
if(slab instanceof Waterlogged) {
|
||||
@@ -183,7 +183,7 @@ public class DefaultChunkGenerator3D implements TerraChunkGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean placeStair(BlockData orig, ChunkData chunk, Vector3 block, double thresh, Sampler sampler, Stairs stairNew) {
|
||||
private boolean placeStair(BlockState orig, ChunkData chunk, Vector3 block, double thresh, Sampler sampler, Stairs stairNew) {
|
||||
|
||||
if(sampler.sample(block.getBlockX() - 0.55, block.getY(), block.getZ()) > thresh) {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.world.population;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
@@ -22,7 +22,7 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class CavePopulator implements TerraBlockPopulator, Chunkified {
|
||||
private static final Map<BlockType, BlockData> shiftStorage = new HashMap<>(); // Persist BlockData created for shifts, to avoid re-calculating each time.
|
||||
private static final Map<BlockType, BlockState> shiftStorage = new HashMap<>(); // Persist BlockData created for shifts, to avoid re-calculating each time.
|
||||
private final TerraPlugin main;
|
||||
|
||||
public CavePopulator(TerraPlugin main) {
|
||||
@@ -34,7 +34,7 @@ public class CavePopulator implements TerraBlockPopulator, Chunkified {
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
TerraWorld tw = main.getWorld(world);
|
||||
WorldHandle handle = main.getWorldHandle();
|
||||
BlockData AIR = handle.createBlockData("minecraft:air");
|
||||
BlockState AIR = handle.createBlockData("minecraft:air");
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("carving")) {
|
||||
Random random = PopulationUtil.getRandom(chunk);
|
||||
if(!tw.isSafe()) return;
|
||||
@@ -43,10 +43,10 @@ public class CavePopulator implements TerraBlockPopulator, Chunkified {
|
||||
|
||||
for(UserDefinedCarver c : config.getRegistry(UserDefinedCarver.class).entries()) {
|
||||
CarverTemplate template = c.getConfig();
|
||||
Map<Vector3, BlockData> shiftCandidate = new HashMap<>();
|
||||
Map<Vector3, BlockState> shiftCandidate = new HashMap<>();
|
||||
c.carve(chunk.getX(), chunk.getZ(), world, (v, type) -> {
|
||||
try(ProfileFrame ignored = main.getProfiler().profile("carving:" + c.getConfig().getID())) {
|
||||
BlockData m = chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||
BlockState m = chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||
BlockType re = m.getBlockType();
|
||||
switch(type) {
|
||||
case CENTER:
|
||||
@@ -76,10 +76,10 @@ public class CavePopulator implements TerraBlockPopulator, Chunkified {
|
||||
}
|
||||
}
|
||||
});
|
||||
for(Map.Entry<Vector3, BlockData> entry : shiftCandidate.entrySet()) {
|
||||
for(Map.Entry<Vector3, BlockState> entry : shiftCandidate.entrySet()) {
|
||||
Vector3 l = entry.getKey();
|
||||
Vector3 mut = l.clone();
|
||||
BlockData orig = chunk.getBlock(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
BlockState orig = chunk.getBlock(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
do mut.subtract(0, 1, 0);
|
||||
while(mut.getY() > world.getMinHeight() && chunk.getBlock(mut.getBlockX(), mut.getBlockY(), mut.getBlockZ()).matches(orig));
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.world.population.items.flora;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
import com.dfsek.terra.api.block.data.Directional;
|
||||
import com.dfsek.terra.api.block.data.MultipleFacing;
|
||||
@@ -105,7 +105,7 @@ public class TerraFlora implements Flora {
|
||||
|
||||
for(int i = 0; FastMath.abs(i) < size; i += c) { // Down if ceiling, up if floor
|
||||
int lvl = (FastMath.abs(i));
|
||||
BlockData data = floraPalette.get((ceiling ? lvl : size - lvl - 1), location.getX(), location.getY(), location.getZ()).clone();
|
||||
BlockState data = floraPalette.get((ceiling ? lvl : size - lvl - 1), location.getX(), location.getY(), location.getZ()).clone();
|
||||
if(doRotation) {
|
||||
BlockFace oneFace = faces.get(new FastRandom(location.getBlockX() ^ location.getBlockZ()).nextInt(faces.size())); // Get random face.
|
||||
if(data instanceof Directional) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.world.population.items.ores;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.util.collections.MaterialSet;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
@@ -12,13 +12,13 @@ import java.util.Random;
|
||||
|
||||
public abstract class Ore {
|
||||
|
||||
private final BlockData material;
|
||||
private final BlockState material;
|
||||
private final MaterialSet replaceable;
|
||||
private final boolean applyGravity;
|
||||
protected TerraPlugin main;
|
||||
private final Map<BlockType, BlockData> materials;
|
||||
private final Map<BlockType, BlockState> materials;
|
||||
|
||||
public Ore(BlockData material, MaterialSet replaceable, boolean applyGravity, TerraPlugin main, Map<BlockType, BlockData> materials) {
|
||||
public Ore(BlockState material, MaterialSet replaceable, boolean applyGravity, TerraPlugin main, Map<BlockType, BlockState> materials) {
|
||||
this.material = material;
|
||||
this.replaceable = replaceable;
|
||||
this.applyGravity = applyGravity;
|
||||
@@ -28,7 +28,7 @@ public abstract class Ore {
|
||||
|
||||
public abstract void generate(Vector3Impl origin, Chunk c, Random r);
|
||||
|
||||
public BlockData getMaterial(BlockType replace) {
|
||||
public BlockState getMaterial(BlockType replace) {
|
||||
return materials.getOrDefault(replace, material);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.world.population.items.ores;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.util.collections.MaterialSet;
|
||||
@@ -16,7 +16,7 @@ import java.util.Random;
|
||||
public class VanillaOre extends Ore {
|
||||
private final Range sizeRange;
|
||||
|
||||
public VanillaOre(BlockData material, MaterialSet replaceable, boolean applyGravity, Range size, TerraPlugin main, Map<BlockType, BlockData> materials) {
|
||||
public VanillaOre(BlockState material, MaterialSet replaceable, boolean applyGravity, Range size, TerraPlugin main, Map<BlockType, BlockState> materials) {
|
||||
super(material, replaceable, applyGravity, main, materials);
|
||||
this.sizeRange = size;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
import com.dfsek.terra.api.addon.annotations.Version;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.command.CommandManager;
|
||||
import com.dfsek.terra.api.command.TerraCommandManager;
|
||||
import com.dfsek.terra.api.command.exception.MalformedCommandException;
|
||||
@@ -302,7 +302,7 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
||||
@Override
|
||||
public void register(TypeRegistry registry) {
|
||||
registry
|
||||
.registerLoader(BlockData.class, (t, o, l) -> handle.createBlockData((String) o))
|
||||
.registerLoader(BlockState.class, (t, o, l) -> handle.createBlockData((String) o))
|
||||
.registerLoader(Biome.class, (t, o, l) -> parseBiome((String) o))
|
||||
.registerLoader(EntityType.class, (t, o, l) -> EntityType.valueOf((String) o));
|
||||
genericLoaders.register(registry);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.bukkit.generator;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockData;
|
||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockState;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -38,14 +38,14 @@ public class BukkitChunkGenerator implements com.dfsek.terra.api.world.generator
|
||||
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, @NotNull BlockData blockData) {
|
||||
delegate.setBlock(x, y, z, ((BukkitBlockData) blockData).getHandle());
|
||||
public void setBlock(int x, int y, int z, @NotNull BlockState blockState) {
|
||||
delegate.setBlock(x, y, z, ((BukkitBlockState) blockState).getHandle());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull BlockData getBlock(int x, int y, int z) {
|
||||
return BukkitBlockData.newInstance(delegate.getBlockData(x, y, z));
|
||||
public @NotNull BlockState getBlock(int x, int y, int z) {
|
||||
return BukkitBlockState.newInstance(delegate.getBlockData(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.handles;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
@@ -8,16 +8,16 @@ import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.bukkit.structure.WorldEditUtil;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockData;
|
||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockState;
|
||||
import com.dfsek.terra.bukkit.world.entity.BukkitEntityType;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BukkitWorldHandle implements WorldHandle {
|
||||
|
||||
@Override
|
||||
public BlockData createBlockData(String data) {
|
||||
public BlockState createBlockData(String data) {
|
||||
org.bukkit.block.data.BlockData bukkitData = Bukkit.createBlockData(data);
|
||||
return BukkitBlockData.newInstance(bukkitData);
|
||||
return BukkitBlockState.newInstance(bukkitData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.bukkit.world;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.block.Axis;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.data.Bisected;
|
||||
@@ -22,7 +22,7 @@ import com.dfsek.terra.bukkit.BukkitCommandSender;
|
||||
import com.dfsek.terra.bukkit.BukkitEntity;
|
||||
import com.dfsek.terra.bukkit.BukkitPlayer;
|
||||
import com.dfsek.terra.bukkit.world.block.BukkitBlockTypeAndItem;
|
||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockData;
|
||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockState;
|
||||
import com.dfsek.terra.bukkit.world.inventory.BukkitItemStack;
|
||||
import com.dfsek.terra.bukkit.world.inventory.meta.BukkitEnchantment;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
@@ -67,12 +67,12 @@ public final class BukkitAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockData adapt(org.bukkit.block.data.BlockData data) {
|
||||
return BukkitBlockData.newInstance(data);
|
||||
public static BlockState adapt(org.bukkit.block.data.BlockData data) {
|
||||
return BukkitBlockState.newInstance(data);
|
||||
}
|
||||
|
||||
public static org.bukkit.block.data.BlockData adapt(BlockData data) {
|
||||
return ((BukkitBlockData) data).getHandle();
|
||||
public static org.bukkit.block.data.BlockData adapt(BlockState data) {
|
||||
return ((BukkitBlockState) data).getHandle();
|
||||
}
|
||||
|
||||
public static Axis adapt(org.bukkit.Axis axis) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.world;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -33,17 +33,17 @@ public class BukkitChunk implements Chunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, @NotNull BlockData blockData) {
|
||||
delegate.getBlock(x, y, z).setBlockData(BukkitAdapter.adapt(blockData));
|
||||
public void setBlock(int x, int y, int z, @NotNull BlockState blockState) {
|
||||
delegate.getBlock(x, y, z).setBlockData(BukkitAdapter.adapt(blockState));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull BlockData getBlock(int x, int y, int z) {
|
||||
public @NotNull BlockState getBlock(int x, int y, int z) {
|
||||
return BukkitAdapter.adapt(delegate.getBlock(x, y, z).getBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, BlockData data, boolean physics) {
|
||||
public void setBlock(int x, int y, int z, BlockState data, boolean physics) {
|
||||
delegate.getBlock(x, y, z).setBlockData(BukkitAdapter.adapt(data), physics);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.world;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.state.BlockEntity;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
@@ -56,12 +56,12 @@ public class BukkitWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(int x, int y, int z) {
|
||||
public BlockState getBlockData(int x, int y, int z) {
|
||||
return BukkitAdapter.adapt(delegate.getBlockAt(x, y, z).getBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockData(int x, int y, int z, BlockData data, boolean physics) {
|
||||
public void setBlockData(int x, int y, int z, BlockState data, boolean physics) {
|
||||
delegate.getBlockAt(x, y, z).setBlockData(BukkitAdapter.adapt(data), physics);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.world.block;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.inventory.Item;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
@@ -20,7 +20,7 @@ public class BukkitBlockTypeAndItem implements BlockType, Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getDefaultData() {
|
||||
public BlockState getDefaultData() {
|
||||
return BukkitAdapter.adapt(delegate.createBlockData());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.bukkit.world.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.data.AnaloguePowerable;
|
||||
|
||||
public class BukkitAnaloguePowerable extends BukkitBlockData implements AnaloguePowerable {
|
||||
public class BukkitAnaloguePowerable extends BukkitBlockState implements AnaloguePowerable {
|
||||
public BukkitAnaloguePowerable(org.bukkit.block.data.AnaloguePowerable delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.world.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
@@ -17,14 +17,14 @@ import org.bukkit.block.data.type.Slab;
|
||||
import org.bukkit.block.data.type.Stairs;
|
||||
import org.bukkit.block.data.type.Wall;
|
||||
|
||||
public class BukkitBlockData implements BlockData {
|
||||
public class BukkitBlockState implements BlockState {
|
||||
private org.bukkit.block.data.BlockData delegate;
|
||||
|
||||
protected BukkitBlockData(org.bukkit.block.data.BlockData delegate) {
|
||||
protected BukkitBlockState(org.bukkit.block.data.BlockData delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public static BukkitBlockData newInstance(org.bukkit.block.data.BlockData bukkitData) {
|
||||
public static BukkitBlockState newInstance(org.bukkit.block.data.BlockData bukkitData) {
|
||||
|
||||
if(bukkitData instanceof Rail) return new BukkitRail((Rail) bukkitData);
|
||||
if(bukkitData instanceof Stairs) return new BukkitStairs((Stairs) bukkitData);
|
||||
@@ -43,7 +43,7 @@ public class BukkitBlockData implements BlockData {
|
||||
|
||||
if(bukkitData instanceof Waterlogged) return new BukkitWaterlogged((Waterlogged) bukkitData);
|
||||
|
||||
return new BukkitBlockData(bukkitData);
|
||||
return new BukkitBlockState(bukkitData);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,14 +58,14 @@ public class BukkitBlockData implements BlockData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(BlockData data) {
|
||||
return delegate.getMaterial() == ((BukkitBlockData) data).getHandle().getMaterial();
|
||||
public boolean matches(BlockState data) {
|
||||
return delegate.getMaterial() == ((BukkitBlockState) data).getHandle().getMaterial();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitBlockData clone() {
|
||||
public BukkitBlockState clone() {
|
||||
try {
|
||||
BukkitBlockData n = (BukkitBlockData) super.clone();
|
||||
BukkitBlockState n = (BukkitBlockState) super.clone();
|
||||
n.delegate = delegate.clone();
|
||||
return n;
|
||||
} catch(CloneNotSupportedException e) {
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.terra.api.block.BlockFace;
|
||||
import com.dfsek.terra.api.block.data.Directional;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
|
||||
public class BukkitDirectional extends BukkitBlockData implements Directional {
|
||||
public class BukkitDirectional extends BukkitBlockState implements Directional {
|
||||
public BukkitDirectional(org.bukkit.block.data.Directional delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BukkitMultipleFacing extends BukkitBlockData implements MultipleFacing {
|
||||
public class BukkitMultipleFacing extends BukkitBlockState implements MultipleFacing {
|
||||
|
||||
public BukkitMultipleFacing(org.bukkit.block.data.MultipleFacing delegate) {
|
||||
super(delegate);
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BukkitOrientable extends BukkitBlockData implements Orientable {
|
||||
public class BukkitOrientable extends BukkitBlockState implements Orientable {
|
||||
|
||||
public BukkitOrientable(org.bukkit.block.data.Orientable delegate) {
|
||||
super(delegate);
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.bukkit.world.block.data;
|
||||
import com.dfsek.terra.api.block.data.Rail;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
|
||||
public class BukkitRail extends BukkitBlockData implements Rail {
|
||||
public class BukkitRail extends BukkitBlockState implements Rail {
|
||||
public BukkitRail(org.bukkit.block.data.Rail delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.terra.api.block.BlockFace;
|
||||
import com.dfsek.terra.api.block.data.Rotatable;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
|
||||
public class BukkitRotatable extends BukkitBlockData implements Rotatable {
|
||||
public class BukkitRotatable extends BukkitBlockState implements Rotatable {
|
||||
public BukkitRotatable(org.bukkit.block.data.Rotatable delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.terra.api.block.BlockFace;
|
||||
import com.dfsek.terra.api.block.data.Stairs;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
|
||||
public class BukkitStairs extends BukkitBlockData implements Stairs {
|
||||
public class BukkitStairs extends BukkitBlockState implements Stairs {
|
||||
|
||||
public BukkitStairs(org.bukkit.block.data.type.Stairs delegate) {
|
||||
super(delegate);
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.bukkit.world.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.data.Waterlogged;
|
||||
|
||||
public class BukkitWaterlogged extends BukkitBlockData implements Waterlogged {
|
||||
public class BukkitWaterlogged extends BukkitBlockState implements Waterlogged {
|
||||
public BukkitWaterlogged(org.bukkit.block.data.Waterlogged delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.dfsek.terra.bukkit.world.block.state;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.state.BlockEntity;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockData;
|
||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockState;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.block.Sign;
|
||||
@@ -49,8 +49,8 @@ public class BukkitBlockEntity implements BlockEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData() {
|
||||
return BukkitBlockData.newInstance(delegate.getBlockData());
|
||||
public BlockState getBlockData() {
|
||||
return BukkitBlockState.newInstance(delegate.getBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
import com.dfsek.terra.api.addon.annotations.Version;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.command.CommandManager;
|
||||
import com.dfsek.terra.api.command.TerraCommandManager;
|
||||
import com.dfsek.terra.api.command.exception.MalformedCommandException;
|
||||
@@ -235,7 +235,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
public void register(TypeRegistry registry) {
|
||||
genericLoaders.register(registry);
|
||||
registry
|
||||
.registerLoader(BlockData.class, (t, o, l) -> worldHandle.createBlockData((String) o))
|
||||
.registerLoader(BlockState.class, (t, o, l) -> worldHandle.createBlockData((String) o))
|
||||
.registerLoader(com.dfsek.terra.api.world.biome.Biome.class, (t, o, l) -> parseBiome((String) o))
|
||||
.registerLoader(Identifier.class, (t, o, l) -> {
|
||||
Identifier identifier = Identifier.tryParse((String) o);
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.dfsek.terra.fabric.block;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.fabric.mixin.access.StateAccessor;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FabricBlockData implements BlockData {
|
||||
protected BlockState delegate;
|
||||
public class FabricBlockState implements BlockState {
|
||||
protected net.minecraft.block.BlockState delegate;
|
||||
|
||||
public FabricBlockData(BlockState delegate) {
|
||||
public FabricBlockState(net.minecraft.block.BlockState delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@@ -22,14 +21,14 @@ public class FabricBlockData implements BlockData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(BlockData other) {
|
||||
return delegate.getBlock() == ((FabricBlockData) other).delegate.getBlock();
|
||||
public boolean matches(BlockState other) {
|
||||
return delegate.getBlock() == ((FabricBlockState) other).delegate.getBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData clone() {
|
||||
public BlockState clone() {
|
||||
try {
|
||||
return (FabricBlockData) super.clone();
|
||||
return (FabricBlockState) super.clone();
|
||||
} catch(CloneNotSupportedException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
@@ -57,7 +56,7 @@ public class FabricBlockData implements BlockData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getHandle() {
|
||||
public net.minecraft.block.BlockState getHandle() {
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.data.AnaloguePowerable;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
/**
|
||||
* None of this actually has implementation, TODO: implement this if we ever end up needing it.
|
||||
*/
|
||||
public class FabricAnaloguePowerable extends FabricBlockData implements AnaloguePowerable {
|
||||
public class FabricAnaloguePowerable extends FabricBlockState implements AnaloguePowerable {
|
||||
public FabricAnaloguePowerable(BlockState delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
import com.dfsek.terra.api.block.data.Directional;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
|
||||
public class FabricDirectional extends FabricBlockData implements Directional {
|
||||
public class FabricDirectional extends FabricBlockState implements Directional {
|
||||
private final DirectionProperty property;
|
||||
|
||||
public FabricDirectional(BlockState delegate, DirectionProperty property) {
|
||||
|
||||
@@ -2,14 +2,14 @@ package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
import com.dfsek.terra.api.block.data.MultipleFacing;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class FabricMultipleFacing extends FabricBlockData implements MultipleFacing {
|
||||
public class FabricMultipleFacing extends FabricBlockState implements MultipleFacing {
|
||||
public FabricMultipleFacing(BlockState delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.Axis;
|
||||
import com.dfsek.terra.api.block.data.Orientable;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
@@ -12,7 +12,7 @@ import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FabricOrientable extends FabricBlockData implements Orientable {
|
||||
public class FabricOrientable extends FabricBlockState implements Orientable {
|
||||
private final EnumProperty<Direction.Axis> property;
|
||||
|
||||
public FabricOrientable(BlockState delegate, EnumProperty<Direction.Axis> property) {
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
import com.dfsek.terra.api.block.data.Rotatable;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
|
||||
public class FabricRotatable extends FabricBlockData implements Rotatable {
|
||||
public class FabricRotatable extends FabricBlockState implements Rotatable {
|
||||
public FabricRotatable(BlockState delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.data.Waterlogged;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
|
||||
public class FabricWaterlogged extends FabricBlockData implements Waterlogged {
|
||||
public class FabricWaterlogged extends FabricBlockState implements Waterlogged {
|
||||
public FabricWaterlogged(BlockState delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.world.generator.TerraChunkGenerator;
|
||||
import com.dfsek.terra.api.world.locate.AsyncStructureFinder;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import com.dfsek.terra.fabric.mixin.StructureAccessorAccessor;
|
||||
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
|
||||
@@ -177,7 +177,7 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
||||
public int getHeight(int x, int z, Heightmap.Type heightmap, HeightLimitView heightmapType) {
|
||||
TerraWorld world = TerraFabricPlugin.getInstance().getWorld(dimensionType);
|
||||
int height = world.getWorld().getMaxHeight();
|
||||
while(height >= world.getWorld().getMinHeight() && !heightmap.getBlockPredicate().test(((FabricBlockData) world.getUngeneratedBlock(x, height - 1, z)).getHandle())) {
|
||||
while(height >= world.getWorld().getMinHeight() && !heightmap.getBlockPredicate().test(((FabricBlockState) world.getUngeneratedBlock(x, height - 1, z)).getHandle())) {
|
||||
height--;
|
||||
}
|
||||
return height;
|
||||
@@ -188,7 +188,7 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
||||
TerraWorld world = TerraFabricPlugin.getInstance().getWorld(dimensionType);
|
||||
BlockState[] array = new BlockState[view.getHeight()];
|
||||
for(int y = view.getBottomY() + view.getHeight() - 1; y >= view.getBottomY(); y--) {
|
||||
array[y] = ((FabricBlockData) world.getUngeneratedBlock(x, y, z)).getHandle();
|
||||
array[y] = ((FabricBlockState) world.getUngeneratedBlock(x, y, z)).getHandle();
|
||||
}
|
||||
return new VerticalBlockSample(view.getBottomY(), array);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.util.WorldEditUtil;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
@@ -20,7 +20,7 @@ import java.util.Locale;
|
||||
public class FabricWorldHandle implements WorldHandle {
|
||||
|
||||
@Override
|
||||
public FabricBlockData createBlockData(String data) {
|
||||
public FabricBlockState createBlockData(String data) {
|
||||
BlockArgumentParser parser = new BlockArgumentParser(new StringReader(data), true);
|
||||
try {
|
||||
BlockState state = parser.parse(true).getBlockState();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations.block;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.state.BlockEntity;
|
||||
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -46,7 +46,7 @@ public abstract class BlockEntityMixin {
|
||||
return pos.getZ();
|
||||
}
|
||||
|
||||
public BlockData terra$getBlockData() {
|
||||
public BlockState terra$getBlockData() {
|
||||
return FabricAdapter.adapt(getCachedState());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations.block;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
@@ -16,14 +15,14 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
@Implements(@Interface(iface = BlockType.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class BlockMixin {
|
||||
@Shadow
|
||||
private BlockState defaultState;
|
||||
private net.minecraft.block.BlockState defaultState;
|
||||
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockData terra$getDefaultData() {
|
||||
public BlockState terra$getDefaultData() {
|
||||
return FabricAdapter.adapt(defaultState);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations.chunk;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.ChunkRegion;
|
||||
@@ -33,12 +33,12 @@ public abstract class ChunkRegionMixin {
|
||||
return (World) this;
|
||||
}
|
||||
|
||||
public @NotNull BlockData terraChunk$getBlock(int x, int y, int z) {
|
||||
return new FabricBlockData(((ChunkRegion) (Object) this).getBlockState(new BlockPos(x + (centerPos.x << 4), y, z + (centerPos.z << 4))));
|
||||
public @NotNull BlockState terraChunk$getBlock(int x, int y, int z) {
|
||||
return new FabricBlockState(((ChunkRegion) (Object) this).getBlockState(new BlockPos(x + (centerPos.x << 4), y, z + (centerPos.z << 4))));
|
||||
}
|
||||
|
||||
public void terraChunk$setBlock(int x, int y, int z, @NotNull BlockData blockData, boolean physics) {
|
||||
((ChunkRegion) (Object) this).setBlockState(new BlockPos(x + (centerPos.x << 4), y, z + (centerPos.z << 4)), ((FabricBlockData) blockData).getHandle(), 0);
|
||||
public void terraChunk$setBlock(int x, int y, int z, @NotNull BlockState blockState, boolean physics) {
|
||||
((ChunkRegion) (Object) this).setBlockState(new BlockPos(x + (centerPos.x << 4), y, z + (centerPos.z << 4)), ((FabricBlockState) blockState).getHandle(), 0);
|
||||
}
|
||||
|
||||
// getHandle already added in world/ChunkRegionMixin.
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations.chunk;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import net.minecraft.block.BlockState;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -24,11 +23,11 @@ public abstract class WorldChunkMixin {
|
||||
private net.minecraft.world.World world;
|
||||
|
||||
@Shadow
|
||||
public abstract BlockState getBlockState(BlockPos pos);
|
||||
public abstract net.minecraft.block.BlockState getBlockState(BlockPos pos);
|
||||
|
||||
@Shadow
|
||||
@Nullable
|
||||
public abstract BlockState setBlockState(BlockPos pos, BlockState state, boolean moved);
|
||||
public abstract net.minecraft.block.BlockState setBlockState(BlockPos pos, net.minecraft.block.BlockState state, boolean moved);
|
||||
|
||||
public int terra$getX() {
|
||||
return ((net.minecraft.world.chunk.Chunk) this).getPos().x;
|
||||
@@ -42,16 +41,16 @@ public abstract class WorldChunkMixin {
|
||||
return (World) world;
|
||||
}
|
||||
|
||||
public @NotNull BlockData terra$getBlock(int x, int y, int z) {
|
||||
return new FabricBlockData(getBlockState(new BlockPos(x, y, z)));
|
||||
public @NotNull BlockState terra$getBlock(int x, int y, int z) {
|
||||
return new FabricBlockState(getBlockState(new BlockPos(x, y, z)));
|
||||
}
|
||||
|
||||
public void terra$setBlock(int x, int y, int z, BlockData data, boolean physics) {
|
||||
setBlockState(new BlockPos(x, y, z), ((FabricBlockData) data).getHandle(), false);
|
||||
public void terra$setBlock(int x, int y, int z, BlockState data, boolean physics) {
|
||||
setBlockState(new BlockPos(x, y, z), ((FabricBlockState) data).getHandle(), false);
|
||||
}
|
||||
|
||||
public void terra$setBlock(int x, int y, int z, @NotNull BlockData blockData) {
|
||||
((net.minecraft.world.chunk.Chunk) this).setBlockState(new BlockPos(x, y, z), ((FabricBlockData) blockData).getHandle(), false);
|
||||
public void terra$setBlock(int x, int y, int z, @NotNull BlockState blockState) {
|
||||
((net.minecraft.world.chunk.Chunk) this).setBlockState(new BlockPos(x, y, z), ((FabricBlockState) blockState).getHandle(), false);
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations.chunk.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import net.minecraft.block.BlockState;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.ProtoChunk;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -17,14 +16,14 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
@Implements(@Interface(iface = ChunkData.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ProtoChunkMixin {
|
||||
@Shadow
|
||||
public abstract BlockState getBlockState(BlockPos pos);
|
||||
public abstract net.minecraft.block.BlockState getBlockState(BlockPos pos);
|
||||
|
||||
public @NotNull BlockData terra$getBlock(int x, int y, int z) {
|
||||
return new FabricBlockData(getBlockState(new BlockPos(x, y, z)));
|
||||
public @NotNull BlockState terra$getBlock(int x, int y, int z) {
|
||||
return new FabricBlockState(getBlockState(new BlockPos(x, y, z)));
|
||||
}
|
||||
|
||||
public void terra$setBlock(int x, int y, int z, @NotNull BlockData blockData) {
|
||||
((net.minecraft.world.chunk.Chunk) this).setBlockState(new BlockPos(x, y, z), ((FabricBlockData) blockData).getHandle(), false);
|
||||
public void terra$setBlock(int x, int y, int z, @NotNull BlockState blockState) {
|
||||
((net.minecraft.world.chunk.Chunk) this).setBlockState(new BlockPos(x, y, z), ((FabricBlockState) blockState).getHandle(), false);
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations.world;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.state.BlockEntity;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
@@ -10,10 +10,9 @@ import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.world.generator.TerraChunkGenerator;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
@@ -41,7 +40,7 @@ public abstract class ChunkRegionMixin {
|
||||
private long seed;
|
||||
|
||||
@Shadow
|
||||
public abstract boolean setBlockState(BlockPos pos, BlockState state, int flags, int maxUpdateDepth);
|
||||
public abstract boolean setBlockState(BlockPos pos, net.minecraft.block.BlockState state, int flags, int maxUpdateDepth);
|
||||
|
||||
@Shadow
|
||||
public abstract TickScheduler<Fluid> getFluidTickScheduler();
|
||||
@@ -72,17 +71,17 @@ public abstract class ChunkRegionMixin {
|
||||
}
|
||||
|
||||
@Intrinsic(displace = true)
|
||||
public BlockData terraWorld$getBlockData(int x, int y, int z) {
|
||||
public BlockState terraWorld$getBlockData(int x, int y, int z) {
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
return new FabricBlockData(((ChunkRegion) (Object) this).getBlockState(pos));
|
||||
return new FabricBlockState(((ChunkRegion) (Object) this).getBlockState(pos));
|
||||
}
|
||||
|
||||
@Intrinsic(displace = true)
|
||||
public void terraWorld$setBlockData(int x, int y, int z, BlockData data, boolean physics) {
|
||||
public void terraWorld$setBlockData(int x, int y, int z, BlockState data, boolean physics) {
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
((ChunkRegion) (Object) this).setBlockState(pos, ((FabricBlockData) data).getHandle(), physics ? 3 : 1042);
|
||||
if(physics && ((FabricBlockData) data).getHandle().getBlock() instanceof FluidBlock) {
|
||||
getFluidTickScheduler().schedule(pos, ((FluidBlock) ((FabricBlockData) data).getHandle().getBlock()).getFluidState(((FabricBlockData) data).getHandle()).getFluid(), 0);
|
||||
((ChunkRegion) (Object) this).setBlockState(pos, ((FabricBlockState) data).getHandle(), physics ? 3 : 1042);
|
||||
if(physics && ((FabricBlockState) data).getHandle().getBlock() instanceof FluidBlock) {
|
||||
getFluidTickScheduler().schedule(pos, ((FluidBlock) ((FabricBlockState) data).getHandle().getBlock()).getFluidState(((FabricBlockState) data).getHandle()).getFluid(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations.world;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.state.BlockEntity;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.world.generator.TerraChunkGenerator;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
@@ -45,13 +45,13 @@ public abstract class ServerWorldMixin {
|
||||
return FabricUtil.createState((WorldAccess) this, new BlockPos(x, y, z));
|
||||
}
|
||||
|
||||
public BlockData terra$getBlockData(int x, int y, int z) {
|
||||
return new FabricBlockData(((ServerWorld) (Object) this).getBlockState(new BlockPos(x, y, z)));
|
||||
public BlockState terra$getBlockData(int x, int y, int z) {
|
||||
return new FabricBlockState(((ServerWorld) (Object) this).getBlockState(new BlockPos(x, y, z)));
|
||||
}
|
||||
|
||||
public void terra$setBlockData(int x, int y, int z, BlockData data, boolean physics) {
|
||||
public void terra$setBlockData(int x, int y, int z, BlockState data, boolean physics) {
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
((ServerWorld) (Object) this).setBlockState(pos, ((FabricBlockData) data).getHandle(), physics ? 3 : 1042);
|
||||
((ServerWorld) (Object) this).setBlockState(pos, ((FabricBlockState) data).getHandle(), physics ? 3 : 1042);
|
||||
}
|
||||
|
||||
public Entity terra$spawnEntity(Vector3 location, EntityType entityType) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.dfsek.terra.api.block.data.Bisected;
|
||||
import com.dfsek.terra.api.block.data.Slab;
|
||||
import com.dfsek.terra.api.block.data.Stairs;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import com.dfsek.terra.fabric.block.data.FabricDirectional;
|
||||
import com.dfsek.terra.fabric.block.data.FabricMultipleFacing;
|
||||
import com.dfsek.terra.fabric.block.data.FabricOrientable;
|
||||
@@ -34,7 +34,7 @@ public final class FabricAdapter {
|
||||
return new Vector3Impl(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
public static FabricBlockData adapt(BlockState state) {
|
||||
public static FabricBlockState adapt(BlockState state) {
|
||||
if(state.contains(Properties.STAIR_SHAPE)) return new FabricStairs(state);
|
||||
|
||||
if(state.contains(Properties.SLAB_TYPE)) return new FabricSlab(state);
|
||||
@@ -51,7 +51,7 @@ public final class FabricAdapter {
|
||||
if(state.getProperties().containsAll(Arrays.asList(Properties.NORTH, Properties.SOUTH, Properties.EAST, Properties.WEST)))
|
||||
return new FabricMultipleFacing(state);
|
||||
if(state.contains(Properties.WATERLOGGED)) return new FabricWaterlogged(state);
|
||||
return new FabricBlockData(state);
|
||||
return new FabricBlockState(state);
|
||||
}
|
||||
|
||||
public static Direction adapt(BlockFace face) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra;
|
||||
import com.dfsek.tectonic.loading.TypeRegistry;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.PluginConfig;
|
||||
import com.dfsek.terra.api.event.EventManager;
|
||||
@@ -136,7 +136,7 @@ public class StandalonePlugin implements TerraPlugin {
|
||||
@Override
|
||||
public void register(TypeRegistry registry) {
|
||||
registry
|
||||
.registerLoader(BlockData.class, (t, o, l) -> worldHandle.createBlockData((String) o))
|
||||
.registerLoader(BlockState.class, (t, o, l) -> worldHandle.createBlockData((String) o))
|
||||
.registerLoader(Biome.class, (t, o, l) -> new RawBiome(o.toString()));
|
||||
new GenericLoaders(this).register(registry);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.state.BlockEntity;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class DirectBlockEntity implements BlockEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData() {
|
||||
public BlockState getBlockData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
||||
import net.querz.mca.Chunk;
|
||||
@@ -31,19 +31,19 @@ public class DirectChunkData implements ChunkData, com.dfsek.terra.api.world.Chu
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, @NotNull BlockData blockData) {
|
||||
delegate.setBlockStateAt(x, y, z, ((Data) blockData).getHandle(), false);
|
||||
public void setBlock(int x, int y, int z, @NotNull BlockState blockState) {
|
||||
delegate.setBlockStateAt(x, y, z, ((State) blockState).getHandle(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull BlockData getBlock(int x, int y, int z) {
|
||||
public @NotNull BlockState getBlock(int x, int y, int z) {
|
||||
CompoundTag tag = delegate.getBlockStateAt(x, y, z);
|
||||
if(tag == null) return new Data("minecraft:air");
|
||||
return new Data(tag.getString("Name"));
|
||||
if(tag == null) return new State("minecraft:air");
|
||||
return new State(tag.getString("Name"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, BlockData data, boolean physics) {
|
||||
public void setBlock(int x, int y, int z, BlockState data, boolean physics) {
|
||||
setBlock(x, y, z, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.DirectUtils;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.state.BlockEntity;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
@@ -57,12 +57,12 @@ public class DirectWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(int x, int y, int z) {
|
||||
public BlockState getBlockData(int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockData(int x, int y, int z, BlockData data, boolean physics) {
|
||||
public void setBlockData(int x, int y, int z, BlockState data, boolean physics) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
|
||||
public class RawWorldHandle implements WorldHandle {
|
||||
|
||||
@Override
|
||||
public BlockData createBlockData(String data) {
|
||||
return new Data(data);
|
||||
public BlockState createBlockData(String data) {
|
||||
return new State(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
|
||||
public class Data implements BlockData, BlockType {
|
||||
public class State implements BlockState, BlockType {
|
||||
private final CompoundTag data;
|
||||
private final String noProp;
|
||||
|
||||
public Data(String data) {
|
||||
public State(String data) {
|
||||
this.data = new CompoundTag();
|
||||
if(data.contains("[")) {
|
||||
noProp = data.substring(0, data.indexOf('[')); // Strip properties
|
||||
@@ -26,7 +26,7 @@ public class Data implements BlockData, BlockType {
|
||||
this.data.putString("Name", noProp);
|
||||
}
|
||||
|
||||
public Data(CompoundTag tag) {
|
||||
public State(CompoundTag tag) {
|
||||
if(tag == null) {
|
||||
this.data = new CompoundTag();
|
||||
data.putString("Name", "minecraft:air");
|
||||
@@ -43,8 +43,8 @@ public class Data implements BlockData, BlockType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(BlockData other) {
|
||||
return ((Data) other).noProp.equals(noProp);
|
||||
public boolean matches(BlockState other) {
|
||||
return ((State) other).noProp.equals(noProp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,9 +59,9 @@ public class Data implements BlockData, BlockType {
|
||||
|
||||
|
||||
@Override
|
||||
public BlockData clone() {
|
||||
public BlockState clone() {
|
||||
try {
|
||||
return (BlockData) super.clone();
|
||||
return (BlockState) super.clone();
|
||||
} catch(CloneNotSupportedException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
@@ -84,12 +84,12 @@ public class Data implements BlockData, BlockType {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof Data)) return false;
|
||||
return ((Data) obj).noProp.equals(noProp);
|
||||
if(!(obj instanceof State)) return false;
|
||||
return ((State) obj).noProp.equals(noProp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getDefaultData() {
|
||||
public BlockState getDefaultData() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.dfsek.terra.sponge;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.sponge.world.block.data.SpongeBlockData;
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.sponge.world.block.data.SpongeBlockState;
|
||||
|
||||
public final class SpongeAdapter {
|
||||
public static BlockData adapt(BlockState state) {
|
||||
return new SpongeBlockData(state);
|
||||
public static BlockState adapt(org.spongepowered.api.block.BlockState state) {
|
||||
return new SpongeBlockState(state);
|
||||
}
|
||||
|
||||
public static BlockState adapt(BlockData data) {
|
||||
return ((SpongeBlockData) data).getHandle();
|
||||
public static org.spongepowered.api.block.BlockState adapt(BlockState data) {
|
||||
return ((SpongeBlockState) data).getHandle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package com.dfsek.terra.sponge.world;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.sponge.SpongeAdapter;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
|
||||
public class SpongeWorldHandle implements WorldHandle {
|
||||
@Override
|
||||
public BlockData createBlockData(String data) {
|
||||
return SpongeAdapter.adapt(Sponge.getRegistry().getType(BlockState.class, data).orElseThrow(() -> new IllegalArgumentException("Invalid block data \"" + data + "\"")));
|
||||
public BlockState createBlockData(String data) {
|
||||
return SpongeAdapter.adapt(Sponge.getRegistry().getType(org.spongepowered.api.block.BlockState.class, data).orElseThrow(() -> new IllegalArgumentException("Invalid block data \"" + data + "\"")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.dfsek.terra.sponge.world.block.data;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
|
||||
public class SpongeBlockData implements BlockData {
|
||||
private final BlockState delegate;
|
||||
public class SpongeBlockState implements BlockState {
|
||||
private final org.spongepowered.api.block.BlockState delegate;
|
||||
|
||||
public SpongeBlockData(BlockState delegate) {
|
||||
public SpongeBlockState(org.spongepowered.api.block.BlockState delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getHandle() {
|
||||
public org.spongepowered.api.block.BlockState getHandle() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
@@ -22,12 +21,12 @@ public class SpongeBlockData implements BlockData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(BlockData other) {
|
||||
public boolean matches(BlockState other) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData clone() {
|
||||
public BlockState clone() {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user