This repository has been archived by the owner on Jul 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba49540
commit fcce7f9
Showing
6 changed files
with
54 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/net/tonimatasdev/mossy/api/blocks/ChestBlockHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package net.tonimatasdev.mossy.api.blocks; | ||
|
||
import net.minestom.server.instance.block.BlockHandler; | ||
import net.minestom.server.utils.NamespaceID; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ChestBlockHandler implements BlockHandler { | ||
@Override | ||
public boolean onInteract(@NotNull Interaction interaction) { | ||
System.out.println("Chest opened."); | ||
return BlockHandler.super.onInteract(interaction); | ||
} | ||
|
||
@Override | ||
public @NotNull NamespaceID getNamespaceId() { | ||
return NamespaceID.from("minecraft:chest"); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/net/tonimatasdev/mossy/manager/MossyBlockManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package net.tonimatasdev.mossy.manager; | ||
|
||
import net.minestom.server.MinecraftServer; | ||
import net.minestom.server.instance.block.Block; | ||
import net.minestom.server.instance.block.BlockHandler; | ||
import net.minestom.server.instance.block.BlockManager; | ||
import net.minestom.server.utils.NamespaceID; | ||
import net.tonimatasdev.mossy.api.blocks.ChestBlockHandler; | ||
import net.tonimatasdev.mossy.logger.Logger; | ||
|
||
import java.util.Objects; | ||
|
||
public class MossyBlockManager { | ||
private static BlockManager blockManager = MinecraftServer.getBlockManager(); | ||
|
||
public static void init() { | ||
registerHandler(Block.CHEST, new ChestBlockHandler()); | ||
Logger.info("All blocks registered."); | ||
} | ||
|
||
private static void registerHandler(Block block, BlockHandler blockHandler) { | ||
blockManager.registerHandler(NamespaceID.from("minecraft:" + block.name().toLowerCase()), () -> Objects.requireNonNull(block.withHandler(new ChestBlockHandler()).handler())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters