adolfpuskarev-netizen

Привет мне нужна ванильная винтовка для майнкрафт автомат Калашникова в стиле и цвете Украины который крафтится из жёлтой и синий шерсти и из железа для самой новой версии он будет стрелять файер боллами

Kodari AI
KodariJun 25 at 8:02 am 14
UkraineRifle
Adds a Ukrainian-styled Kalashnikov assault rifle to Minecraft. Crafted from yellow wool, blue wool, and iron ingots, the rifle fires explosive fireballs on right-click with a cooldown. Features custom texture in Ukraine's blue and yellow colors. Fully registered for Fabric 1.21.11 with item model definition and recipe.

Отлично, у меня есть все необходимое. Создаю полный мод.

UkraineRifle
Adds a Ukrainian-styled Kalashnikov assault rifle to Minecraft. Crafted from yellow wool, blue wool, and iron ingots, the rifle fires explosive small fireballs on right-click with a short cooldown. Features custom blue-and-yellow Ukraine-color texture. Fully compatible with Fabric 1.21.11.

Теперь создам текстуру в стиле флага Украины (синее и жёлтое):

Текстуру нужно нарисовать вручную — вот схема пикселей 16×16 для автомата АК в синем и жёлтом:

Plain Text
Схема (U=жёлтый #FFD700, B=синий #005BBB, X=тёмно-серый #333333, .=прозрачный):
Row  0: . . . . . . . . . . . . . . . .
Row  1: . . . . . . . . . . . . U U . .
Row  2: . . . . . . . . . . . U U U U .
Row  3: . . B B B B B B B B B B U U . .
Row  4: . B B U U U U U U U U B B B . .
Row  5: B B U U U U U U U U U U B . . .
Row  6: B B U U U U U U U U U B B . . .
Row  7: . B B B B B B B B B B B . . . .
Row  8: . . . B . . . . . . . . . . . .
Row 9: . . B . . . . . . . . . . . . .
Row 10: . B . . . . . . . . . . . . . .
Row 11: B . . . . . . . . . . . . . . .

Поскольку PNG-код нельзя создать напрямую в тексте, вот готовый Python-скрипт для генерации текстуры:

Python
from PIL import Image

img = Image.new("RGBA", (16, 16), (0, 0, 0, 0))
pixels = img.load()

yellow = (255, 215, 0, 255)
blue   = (0, 91, 187, 255)
dark   = (50, 50, 50, 255)

# Ствол (body) — горизонтальные полосы
for x in range(2, 15):
    pixels[x][4] = blue
    pixels[x][7] = blue

for x in range(1, 14):
    pixels[x][5] = yellow
    pixels[x][6] = yellow

# Магазин (magazine)
for y in range(8, 12):
    pixels[3 - y + 8][y] = dark

# Приклад
for x in range(11, 15):
    pixels[x][2] = yellow
    pixels[x][3] = yellow

img.save("kalashnikov.png")

Запусти скрипт и положи kalashnikov.png в: src/main/resources/assets/ukrainerifle/textures/item/


Структура мода

  • KalashnikovItem.java — при правом клике стреляет SmallFireballEntity в направлении взгляда, кулдаун 10 тиков (0,5 сек)

  • ModItems.java — регистрирует предмет с RegistryKey (обязательно для 1.21.11)

  • Рецепт крафта (kalashnikov.json):

    Plain Text
    Y B I
    Y B I
    Y   I
    

    Y = Жёлтая шерсть, B = Синяя шерсть, I = Железный слиток

  • Модель — handheld (держится как инструмент/меч)

⚠️ Текстуру нужно нарисовать отдельно — используй скрипт выше или любой пиксель-арт редактор (16×16 PNG). Положи файл в src/main/resources/assets/ukrainerifle/textures/item/kalashnikov.png.

adolfpuskarev-netizen

The compilation failed with this error:

code
Compilation failed with 12 error(s):

ERROR in src/main/java/com/ukrainerifle/KalashnikovItem.java at line 10: cannot find symbol
import net.minecraft.util.TypedActionResult;
                         ^
  symbol: class TypedActionResult
  location: package net.minecraft.util

ERROR in src/main/java/com/ukrainerifle/KalashnikovItem.java at line 22: cannot find symbol
    public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
           ^
  symbol: class TypedActionResult
  location: class KalashnikovItem

ERROR in src/main/java/com/ukrainerifle/KalashnikovItem.java at line 25: isClient has private access in World
        if (!world.isClient) {
                  ^

ERROR in src/main/java/com/ukrainerifle/KalashnikovItem.java at line 41: incompatible types: PlayerEntity cannot be converted to double
                    user,
                    ^

ERROR in src/main/java/com/ukrainerifle/KalashnikovItem.java at line 52: cannot find symbol
        return TypedActionResult.success(stack, world.isClient());
               ^
  symbol: variable TypedActionResult
  location: class KalashnikovItem

ERROR in src/main/java/com/ukrainerifle/KalashnikovItem.java at line 55: method does not override or implement a method from a supertype
    @Override
    ^

ERROR in   src/main/java/com/ukrainerifle/KalashnikovItem.java at line 41: incompatible types: PlayerEntity cannot be converted to double
                      user,
                      ^

ERROR in   src/main/java/com/ukrainerifle/KalashnikovItem.java at line 10: cannot find symbol
  import net.minecraft.util.TypedActionResult;
                           ^
  symbol: class TypedActionResult
  location: package net.minecraft.util

ERROR in   src/main/java/com/ukrainerifle/KalashnikovItem.java at line 22: cannot find symbol
      public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
             ^
  symbol: class TypedActionResult
  location: class KalashnikovItem

ERROR in   src/main/java/com/ukrainerifle/KalashnikovItem.java at line 52: cannot find symbol
          return TypedActionResult.success(stack, world.isClient());
                 ^
  symbol: variable TypedActionResult
  location: class KalashnikovItem

ERROR in   src/main/java/com/ukrainerifle/KalashnikovItem.java at line 25: isClient has private access in World
          if (!world.isClient) {
                    ^

ERROR in   src/main/java/com/ukrainerifle/KalashnikovItem.java at line 55: method does not override or implement a method from a supertype
      @Override
      ^


=== COMPILATION ERROR ANALYSIS ===

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

TYPE MISMATCHES:
  - incompatible types: PlayerEntity cannot be converted to double
  - incompatible types: PlayerEntity cannot be converted to double
ACTION: Fix variable types or casting

FILES TO INVESTIGATE:
  - src/main/java/com/ukrainerifle/KalashnikovItem.java
  -   src/main/java/com/ukrainerifle/KalashnikovItem.java

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

Kodari AI
KodariJun 25 at 8:04 am 9

Проблемы понятны: TypedActionResult удалён в 1.21.5+, world.isClient стал методом, и конструктор SmallFireballEntity изменился. Перепишу файл полностью.

Что исправлено:

  • TypedActionResult → ActionResult (удалён в 1.21.5+), возвращаем ActionResult.SUCCESS

  • world.isClient (поле) → world.isClient() (метод)

  • Конструктор SmallFireballEntity(World, LivingEntity, d, d, d) → SmallFireballEntity(World, x, y, z, Vec3d velocity) + fireball.setOwner(user) отдельно

adolfpuskarev-netizen

Готово?

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
Code
12 224
src/main/java/com/ukrainerifle/UkraineRifleMod.java
package com.ukrainerifle;

import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

    @Override
    public void onInitialize() {
        ModItems.initialize();
        ModRecipes.initialize();
    }
}