mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-08 11:50:36 +01:00
Replace BlockModifier.java to BlockSetter & BlockGetter
This commit is contained in:
parent
41f769b8b2
commit
cb8ad02c0d
@ -19,7 +19,9 @@ import net.minestom.server.event.instance.AddEntityToInstanceEvent;
|
||||
import net.minestom.server.event.instance.InstanceTickEvent;
|
||||
import net.minestom.server.event.instance.RemoveEntityFromInstanceEvent;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.block.BlockGetter;
|
||||
import net.minestom.server.instance.block.BlockManager;
|
||||
import net.minestom.server.instance.block.BlockSetter;
|
||||
import net.minestom.server.network.packet.server.play.BlockActionPacket;
|
||||
import net.minestom.server.network.packet.server.play.TimeUpdatePacket;
|
||||
import net.minestom.server.storage.StorageLocation;
|
||||
@ -55,7 +57,7 @@ import java.util.function.Consumer;
|
||||
* you need to be sure to signal the {@link UpdateManager} of the changes using
|
||||
* {@link UpdateManager#signalChunkLoad(Chunk)} and {@link UpdateManager#signalChunkUnload(Chunk)}.
|
||||
*/
|
||||
public abstract class Instance implements BlockModifier, Tickable, EventHandler, DataContainer, PacketGroupingAudience {
|
||||
public abstract class Instance implements BlockGetter, BlockSetter, Tickable, EventHandler, DataContainer, PacketGroupingAudience {
|
||||
|
||||
protected static final BlockManager BLOCK_MANAGER = MinecraftServer.getBlockManager();
|
||||
protected static final UpdateManager UPDATE_MANAGER = MinecraftServer.getUpdateManager();
|
||||
@ -533,14 +535,7 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler,
|
||||
unloadChunk(chunk);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Block type from given coordinates.
|
||||
*
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param z z coordinate
|
||||
* @return Block at given position.
|
||||
*/
|
||||
@Override
|
||||
public @NotNull Block getBlock(int x, int y, int z) {
|
||||
final Chunk chunk = getChunkAt(x, z);
|
||||
Check.notNull(chunk, "The chunk at {0}:{1} is not loaded", x, z);
|
||||
@ -549,16 +544,6 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets block from given position.
|
||||
*
|
||||
* @param position position to get from
|
||||
* @return Block at given position.
|
||||
*/
|
||||
public @NotNull Block getBlock(@NotNull BlockPosition position) {
|
||||
return getBlock(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a {@link BlockActionPacket} for all the viewers of the specific position.
|
||||
*
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.instance.batch;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.instance.BlockModifier;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.block.BlockSetter;
|
||||
import net.minestom.server.utils.thread.MinestomThread;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -27,7 +27,7 @@ import java.util.concurrent.ExecutorService;
|
||||
* @see AbsoluteBlockBatch
|
||||
* @see RelativeBlockBatch
|
||||
*/
|
||||
public interface Batch<C> extends BlockModifier {
|
||||
public interface Batch<C> extends BlockSetter {
|
||||
|
||||
ExecutorService BLOCK_BATCH_POOL = new MinestomThread(
|
||||
MinecraftServer.THREAD_COUNT_BLOCK_BATCH,
|
||||
|
@ -0,0 +1,18 @@
|
||||
package net.minestom.server.instance.block;
|
||||
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface BlockGetter {
|
||||
@NotNull Block getBlock(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Gets block from given position.
|
||||
*
|
||||
* @param blockPosition position to get the block from
|
||||
* @return Block at given position.
|
||||
*/
|
||||
default @NotNull Block getBlock(@NotNull BlockPosition blockPosition) {
|
||||
return getBlock(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ());
|
||||
}
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
package net.minestom.server.instance;
|
||||
package net.minestom.server.instance.block;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.batch.Batch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.block.BlockManager;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -12,10 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* <p>
|
||||
* Notably used by {@link Instance}, {@link Batch}.
|
||||
*/
|
||||
public interface BlockModifier {
|
||||
|
||||
BlockManager BLOCK_MANAGER = MinecraftServer.getBlockManager();
|
||||
|
||||
public interface BlockSetter {
|
||||
void setBlock(int x, int y, int z, @NotNull Block block);
|
||||
|
||||
default void setBlock(@NotNull BlockPosition blockPosition, @NotNull Block block) {
|
Loading…
Reference in New Issue
Block a user