Modding:Advanced Items/ru: Difference between revisions

From Vintage Story Wiki
no edit summary
(Created page with "Как обычно, мы можем обратиться к [https://apidocs.vintagestory.at/api/Vintagestory.API.Common.Item.html#methods item api docs], чтобы найти функцию, которую мы можем использовать. Хотя сам класс item не содержит соответствующей функции, мы также можем обратиться к [https://apidocs.vintagestory.at/api/Vintagestory.API.Common.Collectible...")
No edit summary
 
(13 intermediate revisions by 2 users not shown)
Line 75: Line 75:
{
{


<!--T:20-->
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 90: Line 89:


<!--T:24-->
<!--T:24-->
<div lang="en" dir="ltr" class="mw-content-ltr">
В нашем конкретном случае мы можем переопределить метод <code>bool OnBlockBrokenWith(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, BlockSelection blockSel, float dropQuantityMultiplier = 1)</code>.
In our specific case, we can override the method <code>bool OnBlockBrokenWith(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, BlockSelection blockSel, float dropQuantityMultiplier = 1)</code>.
</div>


<!--T:25-->
<!--T:25-->
<div lang="en" dir="ltr" class="mw-content-ltr">
Нам нужно знать, с какой стороны стоит игрок (на какую сторону он ориентируется) и находится ли он в творческом режиме или режиме выживания (нужно ли сбрасывать добытые предметы или нет). Прежде чем переопределять <code>OnBlockBrokenWith</code>, мы должны создать метод, который уничтожает все блоки между двумя позициями блока (min и max). Он также должен сбрасывать предметы, только если игрок находится в режиме выживания:
We need to be aware of the facing (which side the player is focusing) and if the player is in creative or survival mode (whether items should be dropped or not). Before we are going to override <code>OnBlockBrokenWith</code> we should create a method which destroys all blocks between two block positions (min & max). It should also only drop items if the player is in survival mode:
</div>


<!--T:26-->
<!--T:26-->
Line 122: Line 117:


<!--T:27-->
<!--T:27-->
<div lang="en" dir="ltr" class="mw-content-ltr">
Теперь мы можем реализовать <code>OnBlockBroken</code> довольно легко, позаботившись обо всех возможных осях, с которыми может столкнуться игрок:
Now we can implement <code>OnBlockBroken</code> rather easily, by taken care of every possible axis the player could face:
</div>
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
public override bool OnBlockBrokenWith(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, BlockSelection blockSel, float dropQuantityMultiplier = 1)
public override bool OnBlockBrokenWith(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, BlockSelection blockSel, float dropQuantityMultiplier = 1)
Line 156: Line 149:


<!--T:29-->
<!--T:29-->
<div lang="en" dir="ltr" class="mw-content-ltr">
Если вы всё сделали правильно, то ваш файл должен быть похож на:
If you have done everything right, your file should look similar to this:
</div>
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
using Vintagestory.API.Common;
using Vintagestory.API.Common;
Line 164: Line 155:
using Vintagestory.API.MathTools;
using Vintagestory.API.MathTools;


<!--T:30-->
namespace ExampleMods
namespace ExampleMods
{
{
Line 170: Line 160:
     {
     {


        <!--T:31-->
public override void Start(ICoreAPI api)
public override void Start(ICoreAPI api)
         {
         {
Line 177: Line 166:
         }
         }


    <!--T:32-->
}
}


    <!--T:33-->
public class TunnlerItem : Item
public class TunnlerItem : Item
     {
     {


        <!--T:34-->
public void DestroyBlocks(IWorldAccessor world, BlockPos min, BlockPos max, IPlayer player)
public void DestroyBlocks(IWorldAccessor world, BlockPos min, BlockPos max, IPlayer player)
         {
         {
Line 204: Line 190:
         }
         }


        <!--T:35-->
public override bool OnBlockBrokenWith(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, BlockSelection blockSel, float dropQuantityMultiplier = 1)
public override bool OnBlockBrokenWith(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, BlockSelection blockSel, float dropQuantityMultiplier = 1)
         {
         {
Line 230: Line 215:
         }
         }


    <!--T:36-->
}
}
}
}


<!--T:37-->
</syntaxhighlight>
</syntaxhighlight>


<!--T:38-->
<!--T:38-->
<div lang="en" dir="ltr" class="mw-content-ltr">
Вы также можете скачать файл напрямую: [https://wiki.vintagestory.at/images/a/ad/Tunnler.cs Tunnler.cs].
You can also download the file directly: [https://wiki.vintagestory.at/images/a/ad/Tunnler.cs Tunnler.cs].
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
== Тестирование == <!--T:39-->
== Testing ==
</div> <!--T:39-->


<!--T:40-->
<!--T:40-->
<div lang="en" dir="ltr" class="mw-content-ltr">
Вот как это выглядит в игре:
This is how it looks ingame:
</div>


<!--T:41-->
<!--T:41-->
<youtube>2MRzYKguVFY</youtube>
<youtube>2MRzYKguVFY</youtube>


<div lang="en" dir="ltr" class="mw-content-ltr">
== Распространение == <!--T:42-->
== Distribution ==
</div> <!--T:42-->


<div lang="en" dir="ltr" class="mw-content-ltr">
=== Использование нового Шаблона Мода === <!--T:43-->
=== Using the new Mod Template ===
Если вы используете шаблон мода, следуйте инструкциям [[Modding:Setting up your Development Environment#Packaging the Mod|Настройка среды разработки]], чтобы упаковать ваш мод для дальнейшего распространения.
</div> <!--T:43-->
<div lang="en" dir="ltr" class="mw-content-ltr">
If using the mod template setup, follow the instructions on [[Modding:Setting up your Development Environment#Packaging%20the%20Mod|Setting up your Development Environment]] to pack and distribute your mod.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
=== Использование Modtools (старый способ) === <!--T:44-->
=== Using the (old) Modtools ===
Если вы используете программу modtools, откройте её и введите <code>pack <your mod id></code>. Теперь вы можете взять zip-файл и поделиться им с другими людьми. Он будет работать так же, как и обычные моды, вы можете установить его, скопировав в папку <code>mods</code>.
</div> <!--T:44-->
= Скачать Мод =
<div lang="en" dir="ltr" class="mw-content-ltr">
If using the modtools program, open the modtools and type in <code>pack <your mod id></code>. Now you can take the zip file and share it with other people. It will work in the same way as ordinary mods, you can install it by copying it into the <code>mods</code> folder.
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
= Mod Download =
</div>


<!--T:45-->
<!--T:45-->
<div lang="en" dir="ltr" class="mw-content-ltr">
Варианты мода из этого руководства:  
Here is my version:
</div>
* for VS v1.9: [https://wiki.vintagestory.at/images/7/7b/Tunnler_vs1.9_v1.0.0.zip Tunnler_vs1.9_v1.0.0.zip]
* for VS v1.9: [https://wiki.vintagestory.at/images/7/7b/Tunnler_vs1.9_v1.0.0.zip Tunnler_vs1.9_v1.0.0.zip]
* for VS v1.8: [https://wiki.vintagestory.at/images/6/66/Tunnler.zip Tunnler.zip]
* for VS v1.8: [https://wiki.vintagestory.at/images/6/66/Tunnler.zip Tunnler.zip]
Confirmedusers
409

edits