munntosss

я хочу сделать на свой сервер такую штуку как новую команду которая будет выполнять функцию такую что она находит случайную шахту которая ближе всего и очень глубоко ("/caver") и телепортирует в нее и команда которая делает спавн домой ("/sethome") и команда которая телепортирует домой куда ты вел команду ту прошлую ("/home") но не плагин а мод для версии 1.21.11 fabric java

Kodari AI
KodariJun 24 at 9:42 pm 15
CaverMod
A Fabric 1.21.11 mod adding three commands: /caver teleports the player to the nearest deep cave (searches for a cave below y=0 or deep underground near the player), /sethome saves the player's current position as their home, and /home teleports the player back to their saved home. Home data persists across sessions using Cardinal Components.

Let me read the relevant docs first.

CaverMod
A Fabric 1.21.11 mod adding three server-side commands: /caver scans the surrounding chunks for the nearest deep underground cave (air pocket below y=20 with solid floor) and teleports the player there; /sethome saves the player's current position and dimension as their home; /home teleports the player back to their saved home, including cross-dimension support. Home data persists across sessions using Cardinal Components.

Plan:

  • HomeComponent interface + HomeComponentImpl (Cardinal Components, persists x/y/z/yaw/pitch/worldId)

  • ModComponents registration class (EntityComponentInitializer)

  • CaverCommands — all 3 commands registration + cave-finding logic

  • CaverMod main initializer

  • Build files + resources


Готово! Вот что создано:

Команды:

  • /caver — сканирует загруженные чанки в радиусе 160 блоков, ищет самое глубокое место пещеры (воздух ниже Y=20 с твёрдым полом), телепортирует туда

  • /sethome — сохраняет текущую позицию и измерение как дом

  • /home — телепортирует обратно домой, поддерживает смену измерений (нижний мир, энд и т.д.)

Технические детали:

  • Дом хранится через Cardinal Components — переживает перезагрузку сервера и смерть игрока

  • Поиск пещеры проверяет только загруженные чанки (нет лагов от принудительной загрузки чанков)

  • Все сообщения на русском языке

  • Для установки нужен Fabric Loader 0.19.2+ и Fabric API

munntosss

The compilation failed with this error:

code
Compilation failed with 36 error(s):

ERROR in src/main/java/com/example/cavermod/component/HomeComponent.java at line 3: package org.ladysnake.cca.api.v3.component does not exist
import org.ladysnake.cca.api.v3.component.ComponentV3;
                                         ^

ERROR in src/main/java/com/example/cavermod/component/HomeComponent.java at line 5: cannot find symbol
public interface HomeComponent extends ComponentV3 {
                                       ^
  symbol: class ComponentV3

ERROR in src/main/java/com/example/cavermod/component/ModComponents.java at line 5: package org.ladysnake.cca.api.v3.component does not exist
import org.ladysnake.cca.api.v3.component.ComponentKey;
                                         ^

ERROR in src/main/java/com/example/cavermod/component/ModComponents.java at line 6: package org.ladysnake.cca.api.v3.component does not exist
import org.ladysnake.cca.api.v3.component.ComponentRegistryV3;
                                         ^

ERROR in src/main/java/com/example/cavermod/component/ModComponents.java at line 7: package org.ladysnake.cca.api.v3.entity does not exist
import org.ladysnake.cca.api.v3.entity.EntityComponentFactoryRegistry;
                                      ^

ERROR in src/main/java/com/example/cavermod/component/ModComponents.java at line 8: package org.ladysnake.cca.api.v3.entity does not exist
import org.ladysnake.cca.api.v3.entity.EntityComponentInitializer;
                                      ^

ERROR in src/main/java/com/example/cavermod/component/ModComponents.java at line 9: package org.ladysnake.cca.api.v3.entity does not exist
import org.ladysnake.cca.api.v3.entity.RespawnCopyStrategy;
                                      ^

ERROR in src/main/java/com/example/cavermod/component/ModComponents.java at line 11: cannot find symbol
public class ModComponents implements EntityComponentInitializer {
                                      ^
  symbol: class EntityComponentInitializer

ERROR in src/main/java/com/example/cavermod/component/ModComponents.java at line 13: cannot find symbol
    public static final ComponentKey<HomeComponent> HOME = ComponentRegistryV3.INSTANCE
                        ^
  symbol: class ComponentKey
  location: class ModComponents

ERROR in src/main/java/com/example/cavermod/component/ModComponents.java at line 17: cannot find symbol
    public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) {
                                                 ^
  symbol: class EntityComponentFactoryRegistry
  location: class ModComponents

ERROR in src/main/java/com/example/cavermod/command/CaverCommands.java at line 38: no suitable method found for teleport(TeleportTarget)
                        player.teleport(new TeleportTarget(
                              ^

ERROR in src/main/java/com/example/cavermod/command/CaverCommands.java at line 57: cannot find symbol
                        Vec3d pos = player.getPos();
                                          ^
  symbol: method getPos()
  location: variable player of type ServerPlayerEntity

ERROR in src/main/java/com/example/cavermod/command/CaverCommands.java at line 89: no suitable method found for teleport(TeleportTarget)
                        player.teleport(new TeleportTarget(
                              ^

ERROR in src/main/java/com/example/cavermod/component/HomeComponentImpl.java at line 30: method does not override or implement a method from a supertype
    @Override
    ^

ERROR in src/main/java/com/example/cavermod/component/HomeComponentImpl.java at line 41: method does not override or implement a method from a supertype
    @Override
    ^

ERROR in src/main/java/com/example/cavermod/component/ModComponents.java at line 13: package ComponentRegistryV3 does not exist
    public static final ComponentKey<HomeComponent> HOME = ComponentRegistryV3.INSTANCE
                                                                              ^

ERROR in src/main/java/com/example/cavermod/component/ModComponents.java at line 16: method does not override or implement a method from a supertype
    @Override
    ^

ERROR in src/main/java/com/example/cavermod/component/ModComponents.java at line 21: cannot find symbol
                RespawnCopyStrategy.ALWAYS_COPY
                ^
  symbol: variable RespawnCopyStrategy
  location: class ModComponents

ERROR in   src/main/java/com/example/cavermod/command/CaverCommands.java at line 38: no suitable method found for teleport(TeleportTarget)
                          player.teleport(new TeleportTarget(
                                ^

ERROR in   src/main/java/com/example/cavermod/command/CaverCommands.java at line 89: no suitable method found for teleport(TeleportTarget)
                          player.teleport(new TeleportTarget(
                                ^

ERROR in   src/main/java/com/example/cavermod/component/ModComponents.java at line 13: cannot find symbol
      public static final ComponentKey<HomeComponent> HOME = ComponentRegistryV3.INSTANCE
                          ^
  symbol: class ComponentKey
  location: class ModComponents

ERROR in   src/main/java/com/example/cavermod/component/ModComponents.java at line 17: cannot find symbol
      public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) {
                                                   ^
  symbol: class EntityComponentFactoryRegistry
  location: class ModComponents

ERROR in   src/main/java/com/example/cavermod/component/ModComponents.java at line 21: cannot find symbol
                  RespawnCopyStrategy.ALWAYS_COPY
                  ^
  symbol: variable RespawnCopyStrategy
  location: class ModComponents

ERROR in   src/main/java/com/example/cavermod/component/HomeComponentImpl.java at line 30: method does not override or implement a method from a supertype
      @Override
      ^

ERROR in   src/main/java/com/example/cavermod/component/HomeComponentImpl.java at line 41: method does not override or implement a method from a supertype
      @Override
      ^

ERROR in   src/main/java/com/example/cavermod/component/ModComponents.java at line 16: method does not override or implement a method from a supertype
      @Override
      ^

ERROR in   src/main/java/com/example/cavermod/component/HomeComponent.java at line 5: cannot find symbol
  public interface HomeComponent extends ComponentV3 {
                                         ^
  symbol: class ComponentV3

ERROR in   src/main/java/com/example/cavermod/component/ModComponents.java at line 11: cannot find symbol
  public class ModComponents implements EntityComponentInitializer {
                                        ^
  symbol: class EntityComponentInitializer

ERROR in   src/main/java/com/example/cavermod/command/CaverCommands.java at line 57: cannot find symbol
                          Vec3d pos = player.getPos();
                                            ^
  symbol: method getPos()
  location: variable player of type ServerPlayerEntity

ERROR in   src/main/java/com/example/cavermod/component/HomeComponent.java at line 3: package org.ladysnake.cca.api.v3.component does not exist
  import org.ladysnake.cca.api.v3.component.ComponentV3;
                                           ^

ERROR in   src/main/java/com/example/cavermod/component/ModComponents.java at line 5: package org.ladysnake.cca.api.v3.component does not exist
  import org.ladysnake.cca.api.v3.component.ComponentKey;
                                           ^

ERROR in   src/main/java/com/example/cavermod/component/ModComponents.java at line 6: package org.ladysnake.cca.api.v3.component does not exist
  import org.ladysnake.cca.api.v3.component.ComponentRegistryV3;
                                           ^

ERROR in   src/main/java/com/example/cavermod/component/ModComponents.java at line 7: package org.ladysnake.cca.api.v3.entity does not exist
  import org.ladysnake.cca.api.v3.entity.EntityComponentFactoryRegistry;
                                        ^

ERROR in   src/main/java/com/example/cavermod/component/ModComponents.java at line 8: package org.ladysnake.cca.api.v3.entity does not exist
  import org.ladysnake.cca.api.v3.entity.EntityComponentInitializer;
                                        ^

ERROR in   src/main/java/com/example/cavermod/component/ModComponents.java at line 9: package org.ladysnake.cca.api.v3.entity does not exist
  import org.ladysnake.cca.api.v3.entity.RespawnCopyStrategy;
                                        ^

ERROR in   src/main/java/com/example/cavermod/component/ModComponents.java at line 13: package ComponentRegistryV3 does not exist
      public static final ComponentKey<HomeComponent> HOME = ComponentRegistryV3.INSTANCE
                                                                                ^


=== COMPILATION ERROR ANALYSIS ===

MISSING CLASSES:
  - ComponentV3
  - EntityComponentInitializer
  - ComponentKey
  - EntityComponentFactoryRegistry
ACTION: Create these classes or check imports

MISSING METHODS:
  - getPos()
ACTION: Check method names and signatures

FILES TO INVESTIGATE:
  - src/main/java/com/example/cavermod/component/HomeComponent.java
  - src/main/java/com/example/cavermod/component/ModComponents.java
  - src/main/java/com/example/cavermod/command/CaverCommands.java
  - src/main/java/com/example/cavermod/component/HomeComponentImpl.java
  -   src/main/java/com/example/cavermod/command/CaverCommands.java
  -   src/main/java/com/example/cavermod/component/ModComponents.java
  -   src/main/java/com/example/cavermod/component/HomeComponentImpl.java
  -   src/main/java/com/example/cavermod/component/HomeComponent.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariJun 24 at 9:49 pm 25

Now I have everything I need. The issues are:

  1. Cardinal Components — wrong readFromNbt/writeToNbt signatures (no RegistryWrapper), and the fabric.mod.json entrypoint key must be "cardinal-components" not "cardinal-components-entity"

  2. player.getPos() doesn’t exist → use player.getX(), player.getY(), player.getZ()

  3. player.teleport(TeleportTarget) wrong overload → correct signature from breaking_change-guide

Let me read the current files to patch them precisely.

The root cause is CCA jar not resolving from the Ladysnake maven during compilation. The cleanest fix is to drop Cardinal Components entirely and use vanilla PersistentState — it’s perfect for storing per-player data keyed by UUID, has zero external dependencies, and persists through restarts.

Now create HomeDataState.java and rewrite CaverCommands.java:

Изменения:

  • Убран Cardinal Components — заменён на ванильный PersistentState. Никаких внешних зависимостей, никаких maven-репозиториев

  • HomeDataState — хранит дома всех игроков в файле cavermod_homes.dat в папке мира, переживает перезагрузки сервера

  • player.getPos() заменён на player.getX()/getY()/getZ() (каскадная ошибка компилятора исчезнет)

  • build.gradle и fabric.mod.json очищены от CCA зависимостей

  • manifest.kod удалён — внешние библиотеки не нужны

munntosss

The compilation failed with this error:

code
Compilation failed with 14 error(s):

ERROR in src/main/java/com/example/cavermod/component/HomeDataState.java at line 16: cannot find symbol
    public static final Type<HomeDataState> TYPE = new Type<>(
                        ^
  symbol: class Type
  location: class HomeDataState

ERROR in src/main/java/com/example/cavermod/command/CaverCommands.java at line 39: no suitable method found for teleport(TeleportTarget)
                        player.teleport(new TeleportTarget(
                              ^

ERROR in src/main/java/com/example/cavermod/command/CaverCommands.java at line 95: no suitable method found for teleport(TeleportTarget)
                        player.teleport(new TeleportTarget(
                              ^

ERROR in src/main/java/com/example/cavermod/component/HomeDataState.java at line 16: cannot find symbol
    public static final Type<HomeDataState> TYPE = new Type<>(
                                                       ^
  symbol: class Type
  location: class HomeDataState

ERROR in src/main/java/com/example/cavermod/component/HomeDataState.java at line 49: cannot find symbol
            UUID uuid = entry.getUuid("uuid");
                             ^
  symbol: method getUuid(String)
  location: variable entry of type NbtCompound

ERROR in src/main/java/com/example/cavermod/component/HomeDataState.java at line 61: method does not override or implement a method from a supertype
    @Override
    ^

ERROR in src/main/java/com/example/cavermod/component/HomeDataState.java at line 66: cannot find symbol
            tag.putUuid("uuid", entry.getKey());
               ^
  symbol: method putUuid(String,UUID)
  location: variable tag of type NbtCompound

ERROR in   src/main/java/com/example/cavermod/command/CaverCommands.java at line 39: no suitable method found for teleport(TeleportTarget)
                          player.teleport(new TeleportTarget(
                                ^

ERROR in   src/main/java/com/example/cavermod/command/CaverCommands.java at line 95: no suitable method found for teleport(TeleportTarget)
                          player.teleport(new TeleportTarget(
                                ^

ERROR in   src/main/java/com/example/cavermod/component/HomeDataState.java at line 16: cannot find symbol
      public static final Type<HomeDataState> TYPE = new Type<>(
                          ^
  symbol: class Type
  location: class HomeDataState

ERROR in   src/main/java/com/example/cavermod/component/HomeDataState.java at line 16: cannot find symbol
      public static final Type<HomeDataState> TYPE = new Type<>(
                                                         ^
  symbol: class Type
  location: class HomeDataState

ERROR in   src/main/java/com/example/cavermod/component/HomeDataState.java at line 61: method does not override or implement a method from a supertype
      @Override
      ^

ERROR in   src/main/java/com/example/cavermod/component/HomeDataState.java at line 49: cannot find symbol
              UUID uuid = entry.getUuid("uuid");
                               ^
  symbol: method getUuid(String)
  location: variable entry of type NbtCompound

ERROR in   src/main/java/com/example/cavermod/component/HomeDataState.java at line 66: cannot find symbol
              tag.putUuid("uuid", entry.getKey());
                 ^
  symbol: method putUuid(String,UUID)
  location: variable tag of type NbtCompound


=== COMPILATION ERROR ANALYSIS ===

MISSING CLASSES:
  - Type
ACTION: Create these classes or check imports

MISSING METHODS:
  - getUuid(String)
  - putUuid(String,UUID)
ACTION: Check method names and signatures

FILES TO INVESTIGATE:
  - src/main/java/com/example/cavermod/component/HomeDataState.java
  - src/main/java/com/example/cavermod/command/CaverCommands.java
  -   src/main/java/com/example/cavermod/command/CaverCommands.java
  -   src/main/java/com/example/cavermod/component/HomeDataState.java

Please fix this error by creating a new artifact with the corrected code.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
8 339
src/main/java/com/example/cavermod/CaverMod.java
package com.example.cavermod;

import com.example.cavermod.command.CaverCommands;
import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CaverMod implements ModInitializer {
    public static final String MOD_ID = "cavermod";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

    @Override
    public void onInitialize() {
        CaverCommands.register();
    }
}