-
Notifications
You must be signed in to change notification settings - Fork 53
For developers
PetteriM1 edited this page Sep 16, 2024
·
14 revisions
https://suomicraftpe.ddns.net/javadocs/nukkit-pm1e/
<dependency>
<groupId>cn.nukkit</groupId>
<artifactId>Nukkit</artifactId>
<version>PM1E</version>
<scope>system</scope>
<systemPath>${basedir}/lib/patched.jar</systemPath>
</dependency>
dependencies {
implementation(files("lib/patched.jar"))
}
(Put patched.jar
from server-dir/.cache
into a folder called lib
in your project folder)
https://github.com/CloudburstMC/protocol-docs
https://wiki.vg/Bedrock_Protocol
void registerBlock(int blockId, Class<? extends Block> blockClass) {
Block.list[blockId] = blockClass;
Block block;
try {
block = blockClass.newInstance();
try {
Constructor<?> constructor = blockClass.getDeclaredConstructor(int.class);
constructor.setAccessible(true);
for (int data = 0; data < (1 << Block.DATA_BITS); ++data) {
int fullId = (blockId << Block.DATA_BITS) | data;
Block.fullList[fullId] = (Block) constructor.newInstance(data);
}
Block.hasMeta[blockId] = true;
} catch (NoSuchMethodException ignore) {
for (int data = 0; data < Block.DATA_SIZE; ++data) {
int fullId = (blockId << Block.DATA_BITS) | data;
Block.fullList[fullId] = block;
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
Block.solid[blockId] = block.isSolid();
Block.transparent[blockId] = block.isTransparent();
Block.hardness[blockId] = block.getHardness();
Block.light[blockId] = block.getLightLevel();
if (block.isSolid()) {
if (block.isTransparent()) {
if (block instanceof BlockLiquid || block instanceof BlockIce) {
Block.lightFilter[blockId] = 2;
} else {
Block.lightFilter[blockId] = 1;
}
} else {
Block.lightFilter[blockId] = 15;
}
} else {
Block.lightFilter[blockId] = 1;
}
}
See https://github.com/PetteriM1/CustomBlockExample
Entity.registerEntity(String saveId, Class<? extends Entity> entityClass)
See https://github.com/PetteriM1/CustomEntityExample
BlockEntity.registerBlockEntity(String saveId, Class<? extends BlockEntity> blockEntityClass)
Item.list[id] = YourItem.class
See https://github.com/PetteriM1/CustomItemExample
Enchantment.enchantments[id] = YourEnchantment.class
See https://github.com/CloudburstMC/Nukkit/pull/2181 and https://github.com/PetteriM1/SimpleScoreboards
// Recipe can be a ShapedRecipe, ShapelessRecipe, FurnaceRecipe, etc.
server.getCraftingManager().registerRecipe(recipe)
// Update cached recipe packet after registering your recipes
server.getCraftingManager().rebuildPacket()