User Tools

Site Tools


ru:tutorial:items

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ru:tutorial:items [2021/08/11 17:41] – created vlad_coolru:tutorial:items [2022/02/27 09:43] (current) – external edit 127.0.0.1
Line 3: Line 3:
 ==== Введение ==== ==== Введение ====
  
-Добавление простого предмета - один из первых шагов в создании модов. Вы собираетесь создать объект  ''Предмет'', зарегистрировать его и дать ему текстуру. Чтобы добавить дополнительное поведение предмету, вам необходимо сделать ваш собственный класс предмета. В этом и следующих туториалах пространство имён “tutorial” используется как образец, Если у Вас есть отдельное modid - не стесняйтесь использовать его вместо “tutorial”.+Добавление простого предмета - один из первых шагов в создании модов. Вы собираетесь создать объект ''Item'', зарегистрировать его и дать ему текстуру. Чтобы добавить дополнительное поведение предмету, вам необходимо сделать ваш собственный класс предмета. В этом и следующих туториалах имена “tutorial” используются как образец, Если у Вас есть отдельное modid - не стесняйтесь использовать его вместо “tutorial”.
 ==== Регистрация предмета ==== ==== Регистрация предмета ====
  
Line 11: Line 11:
 public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
  
-    // an instance of our new item+    // экземпляр нашего нового предмета
     public static final Item FABRIC_ITEM = new Item(new FabricItemSettings().group(ItemGroup.MISC));     public static final Item FABRIC_ITEM = new Item(new FabricItemSettings().group(ItemGroup.MISC));
     [...]     [...]
 } }
 </code> </code>
-You'll use the vanilla registry system for registering new contentThe basic syntax is ''Registry#register(Registry Type, Identifier, Content)''Registry types are stored as static fields in the ''Registry'' classand the identifier is what labels your contentContent is an instance of whatever you're addingThis can be called anywhere as long as it occurs during initialization.+Вы будете использовать классическую систему регистрации нового контентаВот базовый синтаксис ''Registry#register(Registry Type, Identifier, Content)''Типы регистрации хранятся как статические типы в классе ''Registry'', и идентификатор обозначает ваш контентКонтент - это экземпляр всего, что вы добавляетеОн может быть вызван в любой момент во время инициализации.
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
 public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
  
-    // an instance of our new item+    // экземпляр нашего нового предмета
     public static final Item FABRIC_ITEM = new Item(new FabricItemSettings().group(ItemGroup.MISC));     public static final Item FABRIC_ITEM = new Item(new FabricItemSettings().group(ItemGroup.MISC));
              
Line 29: Line 29:
 } }
 </code> </code>
-Иеперь Ваш предмет добавлен в Minecraft. Нажмите задачу Gradle ''runClient'', чтобы увидеть его в действии+Теперь Ваш предмет добавлен в Minecraft. Нажмите задачу Gradle ''runClient'', чтобы увидеть его в действии
  
 {{:tutorial:2019-02-17_16.50.44.png?400|}} {{:tutorial:2019-02-17_16.50.44.png?400|}}
Line 45: Line 45:
     [Server-Worker-1/WARN]: Unable to load model: 'tutorial:fabric_item#inventory' referenced from: tutorial:fabric_item#inventory: java.io.FileNotFoundException: tutorial:models/item/fabric_item.json     [Server-Worker-1/WARN]: Unable to load model: 'tutorial:fabric_item#inventory' referenced from: tutorial:fabric_item#inventory: java.io.FileNotFoundException: tutorial:models/item/fabric_item.json
  
-It conveniently tells you exactly where it expects your asset[s] to be found-- when in doubtcheck the log.+Он удобно сообщает вам, где именно, как он ожидает, будут найдены ваши текстуры -- если вы сомневаетесьпроверьте логи.
  
-A basic item model template is:+Базовым шаблоном модели предмета является:
 <code JavaScript> <code JavaScript>
 { {
Line 56: Line 56:
 } }
 </code> </code>
-The parent of your item changes how it's rendered in the hand and comes in useful for things like block items in the inventory"item/handheld" is used for tools that are held from the bottom left of the texture. textures/layer0 is the location of your image file.+''Parent'' указывает, как предмет должен отображаться в руке, это полезно для таких вещей, как предметы блоков в инвентаре''item/handheld'' используется для инструментов, которые держатся за нижний левый угол текстуры''textures/layer0'' это расположение файла с картинкой.
  
-Final textured result:+Конечный текстурированный результат:
  
 {{:tutorial:item_texture.png?400|}} {{:tutorial:item_texture.png?400|}}
  
-==== Creating an Item class ====+==== Создание класса предмета ====
  
-To add additional behavior to the item you will need to create an Item classThe default constructor requires an Item.Settings object.+Чтобы добавить дополнительное поведение к предмету, вам нужно будет создать класс предметаКонструктору по умолчанию требуется объект ''Item.Settings''.
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
 public class FabricItem extends Item { public class FabricItem extends Item {
Line 74: Line 74:
 </code> </code>
  
-A practical use-case for a custom item class would be making the item play a sound when you use it:+Практическим вариантом использования класса предмета было бы заставить предмет воспроизводить звук, когда вы его используете:
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
 public class FabricItem extends Item { public class FabricItem extends Item {
Line 90: Line 90:
 </code> </code>
  
-Replace the old Item object with an instance of your new item class:+Замените старый объект Item экземпляром вашего нового класса предмета:
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
 public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
  
-    // an instance of our new item+    // экземпляр нашего нового предмета
     public static final FabricItem FABRIC_ITEM = new FabricItem(new FabricItemSettings().group(ItemGroup.MISC));     public static final FabricItem FABRIC_ITEM = new FabricItem(new FabricItemSettings().group(ItemGroup.MISC));
     [...]     [...]
 } }
 </code> </code>
-If you did everything correctlyusing the item should now play a sound.+Если вы все сделали правильното при использовании предмета теперь должен воспроизводиться звук.
  
-==== What if I want to change the stack size of my item? ====+==== Что делать, если я хочу изменить размер стака моего предмета? ====
  
-For this you would use ''maxCount(int size)'' inside ''FabricItemSettings'' to specify the max stack sizeNote that if your item is damageable you cannot specify a maximum stack size or the game will throw a RuntimeException.+Для этого вы должны использовать ''maxCount(int size)'' внутри ''FabricItemSettings'', чтобы указать максимальный размер стекаОбратите внимание, что если ваш предмет может быть поврежден, вы не можете указать максимальный размер стека, иначе игра выдаст исключение RuntimeException.
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
 public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
  
-    // An instance of our new itemwhere the maximum stack size is 16+    // Экземпляр нашего нового предметагде стак предметов это 16
     public static final FabricItem FABRIC_ITEM = new FabricItem(new FabricItemSettings().group(ItemGroup.MISC).maxCount(16));     public static final FabricItem FABRIC_ITEM = new FabricItem(new FabricItemSettings().group(ItemGroup.MISC).maxCount(16));
     [...]     [...]
 } }
 </code> </code>
-==== Next Steps ==== +==== Следующие шаги ==== 
-[[tutorial:itemgroup|Add your item to your own ItemGroup]].+[[ru:tutorial:itemgroup|Добавьте свой предмет в свою собственную группу предметов]].
ru/tutorial/items.1628703692.txt.gz · Last modified: 2021/08/11 17:41 by vlad_cool