remove Block from API

This commit is contained in:
dfsek
2021-06-24 08:25:50 -07:00
parent 255e4396dd
commit 18d071128d
8 changed files with 33 additions and 61 deletions
@@ -1,35 +0,0 @@
package com.dfsek.terra.api.block;
import com.dfsek.terra.api.Handle;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.vector.Location;
public interface Block extends Handle {
void setBlockData(BlockData data, boolean physics);
BlockData getBlockData();
BlockState getState();
default Block getRelative(BlockFace face) {
return getRelative(face, 1);
}
Block getRelative(BlockFace face, int len);
boolean isEmpty();
Location getLocation();
default BlockType getType() {
return getBlockData().getBlockType();
}
int getX();
int getZ();
int getY();
boolean isPassable();
}
@@ -1,11 +1,11 @@
package com.dfsek.terra.api.block.state; package com.dfsek.terra.api.block.state;
import com.dfsek.terra.api.Handle; import com.dfsek.terra.api.Handle;
import com.dfsek.terra.api.block.Block;
import com.dfsek.terra.api.block.BlockData; import com.dfsek.terra.api.block.BlockData;
import com.dfsek.terra.api.vector.Vector3;
public interface BlockState extends Handle { public interface BlockState extends Handle {
Block getBlock(); Vector3 getPosition();
int getX(); int getX();
@@ -1,6 +1,5 @@
package com.dfsek.terra.api.event.events.world.generation; package com.dfsek.terra.api.event.events.world.generation;
import com.dfsek.terra.api.block.Block;
import com.dfsek.terra.api.block.state.Container; import com.dfsek.terra.api.block.state.Container;
import com.dfsek.terra.api.config.ConfigPack; import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.event.events.AbstractCancellable; import com.dfsek.terra.api.event.events.AbstractCancellable;
@@ -8,20 +7,19 @@ import com.dfsek.terra.api.event.events.Cancellable;
import com.dfsek.terra.api.event.events.PackEvent; import com.dfsek.terra.api.event.events.PackEvent;
import com.dfsek.terra.api.structure.LootTable; import com.dfsek.terra.api.structure.LootTable;
import com.dfsek.terra.api.structure.Structure; import com.dfsek.terra.api.structure.Structure;
import com.dfsek.terra.api.vector.Vector3;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
* Called when loot is populated. * Called when loot is populated.
*/ */
public class LootPopulateEvent extends AbstractCancellable implements PackEvent, Cancellable { public class LootPopulateEvent extends AbstractCancellable implements PackEvent, Cancellable {
private final Block block;
private final Container container; private final Container container;
private LootTable table; private LootTable table;
private final ConfigPack pack; private final ConfigPack pack;
private final Structure structure; private final Structure structure;
public LootPopulateEvent(Block block, Container container, LootTable table, ConfigPack pack, Structure structure) { public LootPopulateEvent(Container container, LootTable table, ConfigPack pack, Structure structure) {
this.block = block;
this.container = container; this.container = container;
this.table = table; this.table = table;
this.pack = pack; this.pack = pack;
@@ -33,13 +31,8 @@ public class LootPopulateEvent extends AbstractCancellable implements PackEvent,
return pack; return pack;
} }
/** public Vector3 getPosition() {
* Get the block containing the tile entity loot is applied to. return container.getPosition();
*
* @return Block at which loot is applied.
*/
public Block getBlock() {
return block;
} }
/** /**
@@ -1,7 +1,7 @@
package com.dfsek.terra.api.inventory; package com.dfsek.terra.api.inventory;
import com.dfsek.terra.api.block.Block; import com.dfsek.terra.api.vector.Vector3;
public interface BlockInventoryHolder extends InventoryHolder { public interface BlockInventoryHolder extends InventoryHolder {
Block getBlock(); Vector3 getPosition();
} }
@@ -1,6 +1,5 @@
package com.dfsek.terra.api.vector; package com.dfsek.terra.api.vector;
import com.dfsek.terra.api.block.Block;
import com.dfsek.terra.api.world.World; import com.dfsek.terra.api.world.World;
public interface Location extends Cloneable { public interface Location extends Cloneable {
@@ -34,8 +33,6 @@ public interface Location extends Cloneable {
Location add(double x, double y, double z); Location add(double x, double y, double z);
Block getBlock();
Location subtract(int x, int y, int z); Location subtract(int x, int y, int z);
Location add(Vector3 add); Location add(Vector3 add);
@@ -1,6 +1,6 @@
package com.dfsek.terra.api.world; package com.dfsek.terra.api.world;
import com.dfsek.terra.api.block.Block; import com.dfsek.terra.api.block.BlockData;
public interface Chunk extends ChunkAccess { public interface Chunk extends ChunkAccess {
int getX(); int getX();
@@ -9,5 +9,11 @@ public interface Chunk extends ChunkAccess {
World getWorld(); World getWorld();
Block getBlock(int x, int y, int z); BlockData getBlockData(int x, int y, int z);
void setBlockData(int x, int y, int z, BlockData data, boolean physics);
default void setBlockData(int x, int y, int z, BlockData data) {
setBlockData(x, y, z, data, false);
}
} }
@@ -1,13 +1,13 @@
package com.dfsek.terra.api.world; package com.dfsek.terra.api.world;
import com.dfsek.terra.api.block.Block;
import com.dfsek.terra.api.util.Range; import com.dfsek.terra.api.util.Range;
import com.dfsek.terra.api.vector.Location; import com.dfsek.terra.api.vector.Location;
import com.dfsek.terra.api.vector.Vector3;
import java.util.List; import java.util.List;
public interface Flora { public interface Flora {
List<Block> getValidSpawnsAt(Chunk chunk, int x, int z, Range check); List<Vector3> getValidSpawnsAt(Chunk chunk, int x, int z, Range check);
boolean plant(Location l); boolean plant(Location l);
} }
@@ -1,10 +1,11 @@
package com.dfsek.terra.api.world; package com.dfsek.terra.api.world;
import com.dfsek.terra.api.Handle; import com.dfsek.terra.api.Handle;
import com.dfsek.terra.api.block.Block; import com.dfsek.terra.api.block.BlockData;
import com.dfsek.terra.api.entity.Entity; import com.dfsek.terra.api.entity.Entity;
import com.dfsek.terra.api.entity.EntityType; import com.dfsek.terra.api.entity.EntityType;
import com.dfsek.terra.api.vector.Location; import com.dfsek.terra.api.vector.Location;
import com.dfsek.terra.api.vector.Vector3;
import com.dfsek.terra.api.world.generator.ChunkGenerator; import com.dfsek.terra.api.world.generator.ChunkGenerator;
import com.dfsek.terra.api.world.generator.GeneratorWrapper; import com.dfsek.terra.api.world.generator.GeneratorWrapper;
import com.dfsek.terra.api.world.generator.TerraChunkGenerator; import com.dfsek.terra.api.world.generator.TerraChunkGenerator;
@@ -22,10 +23,20 @@ public interface World extends Handle {
return getChunkAt(location.getBlockX() >> 4, location.getBlockZ() >> 4); return getChunkAt(location.getBlockX() >> 4, location.getBlockZ() >> 4);
} }
Block getBlockAt(int x, int y, int z); BlockData getBlockData(int x, int y, int z);
default Block getBlockAt(Location l) { default BlockData getBlockData(Vector3 position) {
return getBlockAt(l.getBlockX(), l.getBlockY(), l.getBlockZ()); return getBlockData(position.getBlockX(), position.getBlockY(), position.getBlockZ());
}
void setBlockData(int x, int y, int z, BlockData data, boolean physics);
default void setBlockData(int x, int y, int z, BlockData data) {
setBlockData(x, y, z, data, false);
}
default void setBlockData(Vector3 position, BlockData data) {
setBlockData(position.getBlockX(), position.getBlockY(), position.getBlockZ(), data);
} }
Entity spawnEntity(Location location, EntityType entityType); Entity spawnEntity(Location location, EntityType entityType);