基础操作

调整 Bukkit 位置

Pos3 pos3 = Pos3.from(location);

获取 CustomCrops 世界

BukkitCustomCropsPlugin.getInstance().getWorldManager().getWorld(Bukkit.getWorld("world"));

获取/删除 Blockstate

CustomCropsWorld<?> world = ...;
world.getBlockState(pos3);
world.removeBlockState(pos3);

添加 Blockstate

CropBlock cropBlock = (CropBlock) BuiltInBlockMechanics.CROP.mechanic();
CustomCropsBlockState blockState = cropBlock.createBlockState();
cropBlock.id(blockState, "tomato");
cropBlock.point(blockState, 0);
world.addBlockState(pos3, blockState);

在 Blockstate 中设置/删除/获取自定义数据

SynchronizedCompoundMap compoundMap = blockState.compoundMap();
compoundMap.remove("key");
compoundMap.put("key", new StringTag("key", "test"));
compoundMap.get("key");

从 Blockstate 获取方块类型

CustomCropsBlock block = blockState.type();
if (block instanceof CropBlock cropBlock) {
    CropConfig cropConfig = cropBlock.config(blockState);
}

从注册表获取内置方块/物品类型

PotBlock potBlock = (PotBlock) BuiltInBlockMechanics.POT.mechanic();

SeedItem seedItem = (SeedItem) BuiltInItemMechanics.SEED.mechanic();

在 Bukkit 世界上放置/删除方块

ItemManager itemManager = BukkitCustomCropsPlugin.getInstance().getItemManager();
itemManager.placeFurniture(location, "id", FurnitureRotation.NONE);
itemManager.placeBlock(location, "id");
itemManager.removeFurniture(location);
itemManager.removeBlock(location);

获取ID

ItemManager itemManager = BukkitCustomCropsPlugin.getInstance().getItemManager();
String blockID = itemManager.blockID(block);
String furnitureID = itemManager.furnitureID(entity);
String itemID = itemManager.id(itemStack);

获取内置物品的配置

CropConfig cropConfig = Registries.CROP.get("tomato");
SprinklerConfig sprinklerConfig = Registries.SPRINKLER.get("sprinkler");
PotConfig potConfig = Registries.POT.get("default");
WateringCanConfig wateringCanConfig = Registries.WATERING_CAN.get("watering_can_1");
FertilizerConfig fertilizerConfig = Registries.FERTILIZER.get("quality_1");

最后更新于