# 基础操作

## 调整 Bukkit 位置 <a href="#adapt-bukkit-location" id="adapt-bukkit-location"></a>

```java
Pos3 pos3 = Pos3.from(location);
```

## 获取 CustomCrops 世界 <a href="#get-customcrops-world" id="get-customcrops-world"></a>

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

## 获取/删除 Blockstate <a href="#get-remove-blockstate" id="get-remove-blockstate"></a>

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

## 添加 Blockstate <a href="#add-blockstate" id="add-blockstate"></a>

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

## 在 Blockstate 中设置/删除/获取自定义数据 <a href="#set-remove-get-custom-data-in-blockstate" id="set-remove-get-custom-data-in-blockstate"></a>

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

## 从 Blockstate 获取方块类型 <a href="#get-the-block-type-from-blockstate" id="get-the-block-type-from-blockstate"></a>

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

## 从注册表获取内置方块/物品类型 <a href="#get-built-in-block-item-type-from-registry" id="get-built-in-block-item-type-from-registry"></a>

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

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

## 在 Bukkit 世界上放置/删除方块 <a href="#place-remove-blocks-on-bukkit-worlds" id="place-remove-blocks-on-bukkit-worlds"></a>

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

## 获取ID <a href="#get-ids" id="get-ids"></a>

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

## 获取内置物品的配置 <a href="#get-configs-of-the-built-in-items" id="get-configs-of-the-built-in-items"></a>

```java
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");
```
