mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-05 02:10:24 +01:00
BlockHandler default impl
This commit is contained in:
parent
c312bf59fc
commit
b464b637a4
@ -24,7 +24,8 @@ public interface BlockHandler {
|
||||
* @param instance the instance of the block
|
||||
* @param blockPosition the position of the block
|
||||
*/
|
||||
void onPlace(@NotNull Instance instance, @NotNull BlockPosition blockPosition);
|
||||
default void onPlace(@NotNull Instance instance, @NotNull BlockPosition blockPosition) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block has been destroyed or replaced.
|
||||
@ -32,7 +33,8 @@ public interface BlockHandler {
|
||||
* @param instance the instance of the block
|
||||
* @param blockPosition the position of the block
|
||||
*/
|
||||
void onDestroy(@NotNull Instance instance, @NotNull BlockPosition blockPosition);
|
||||
default void onDestroy(@NotNull Instance instance, @NotNull BlockPosition blockPosition) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles interactions with this block. Can also block normal item use (containers should block when opening the
|
||||
@ -43,7 +45,9 @@ public interface BlockHandler {
|
||||
* @param blockPosition the position of this block
|
||||
* @return true if this block blocks normal item use, false otherwise
|
||||
*/
|
||||
boolean onInteract(@NotNull Player player, @NotNull Player.Hand hand, @NotNull BlockPosition blockPosition);
|
||||
default boolean onInteract(@NotNull Player player, @NotNull Player.Hand hand, @NotNull BlockPosition blockPosition) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines custom behaviour for entities touching this block.
|
||||
|
@ -1,7 +1,5 @@
|
||||
package demo.block;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.block.BlockHandler;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.Material;
|
||||
@ -10,7 +8,6 @@ import net.minestom.server.tag.Tag;
|
||||
import net.minestom.server.tag.TagReadable;
|
||||
import net.minestom.server.tag.TagSerializer;
|
||||
import net.minestom.server.tag.TagWritable;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.NamespaceID;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -60,21 +57,6 @@ public class CampfireHandler implements BlockHandler {
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onPlace(@NotNull Instance instance, @NotNull BlockPosition blockPosition) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(@NotNull Instance instance, @NotNull BlockPosition blockPosition) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInteract(@NotNull Player player, Player.@NotNull Hand hand, @NotNull BlockPosition blockPosition) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<Tag<?>> getBlockEntityTags() {
|
||||
return List.of(ITEMS);
|
||||
|
Loading…
Reference in New Issue
Block a user