【寿司職人になろう】寿司衣装を追加しよう

1 : 鎧素材クラスの作成
1-1 : 鎧の素材クラスを作成しよう

  1. src/main/java/mark/sushi/sushimodを開く
  2. 右側で、ファイル作成をクリック
  3. ModArmorMaterials.javaと入力して、ファイルを作成し以下をコピペ
package mark.sushi.sushimod;


import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.recipe.Ingredient;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;

import java.util.function.Supplier;

public enum ModArmorMaterials implements ArmorMaterial {
  ITAMAE(
      "itamae",
      25,
      new int[] { 3, 8, 6, 3 },
      19,
      SoundEvents.ITEM_ARMOR_EQUIP_NETHERITE,
      2f,
      0.1f, () -> Ingredient.ofItems(ModItems.SUSHI)
  );

  private final String name;
  private final int durabilityMultiplier;
  private final int[] protectionAmounts;
  private final int enchantability;
  private final SoundEvent equipSound;
  private final float toughness;
  private final float knockbackResistance;
  private final Supplier<Ingredient> repairIngredient;

  private static final int[] BASE_DURABILITY = { 11, 16, 15, 13 };

  ModArmorMaterials(String name, int durabilityMultiplier, int[] protectionAmounts, int enchantability, SoundEvent equipSound,
            float toughness, float knockbackResistance, Supplier<Ingredient> repairIngredient) {
    this.name = name;
    this.durabilityMultiplier = durabilityMultiplier;
    this.protectionAmounts = protectionAmounts;
    this.enchantability = enchantability;
    this.equipSound = equipSound;
    this.toughness = toughness;
    this.knockbackResistance = knockbackResistance;
    this.repairIngredient = repairIngredient;
  }

  @Override
  public int getDurability(ArmorItem.Type type) {
    return BASE_DURABILITY[type.ordinal()] * this.durabilityMultiplier;
  }

  @Override
  public int getProtection(ArmorItem.Type type) {
    return protectionAmounts[type.ordinal()];
  }

  @Override
  public int getEnchantability() {
    return this.enchantability;
  }

  @Override
  public SoundEvent getEquipSound() {
    return this.equipSound;
  }

  @Override
  public Ingredient getRepairIngredient() {
    return this.repairIngredient.get();
  }

  @Override
  public String getName() {
    return SushiMod.MOD_ID + ":" + this.name;
  }

  @Override
  public float getToughness() {
    return this.toughness;
  }

  @Override
  public float getKnockbackResistance() {
    return this.knockbackResistance;
  }
}

ハチマキを追加

ModItems.javaに以下のコードを追加

  public static final Item HACHIMAKI = registerItem("hachimaki",
      new  ArmorItem(
          ModArmorMaterials.ITAMAE,
          ArmorItem.Type.HELMET,
          new FabricItemSettings()
      ));

ModItemGroup.javaに以下のコードを追加

 entries.add(ModItems.HACHIMAKI);

テクスチャを追加

3-2 : テクスチャの保存
textures/itemディレクトリをクリック!
画面右側からアップロードをクリックして、ダウンロードしたhachimaki.pngをアップロードしよう!
3-3 : アイテムモデルの設定
models/itemフォルダをクリック!
画面右側からファイル作成をクリックして、hachimaki.jsonというファイルを作成しよう
hachimaki.jsonを以下のように編集しよう

{
  "parent": "minecraft:item/generated",
  "textures": {
  "layer0": "sushimod:item/hachimaki"
  }
}

服を追加

ModItems.javaに以下のコードを追加

  public static final Item TOPS = registerItem("tops",
      new  ArmorItem(
          ModArmorMaterials.ITAMAE,
          ArmorItem.Type.CHESTPLATE,
           new FabricItemSettings()
      ));

ModItemGroup.javaに以下のコードを追加

entries.add(ModItems.TOPS);

2-2 : テクスチャの保存
textures/itemディレクトリをクリック!
画面右側からアップロードをクリックして、ダウンロードしたtops.pngをアップロードしよう!
2-3 : アイテムモデルの設定
models/itemフォルダをクリック!
画面右側からファイル作成をクリックして、tops.jsonというファイルを作成しよう
tops.jsonを以下のように編集しよう

{
  "parent": "minecraft:item/generated",
  "textures": {
  "layer0": "sushimod:item/tops"
  }
}

ズボンを追加

ModItems.javaに以下のコードを追加

    public static final Item PANTS = registerItem("pants",
      new  ArmorItem(
          ModArmorMaterials.ITAMAE,
          ArmorItem.Type.LEGGINGS,
          new FabricItemSettings()
      ));

ModItemGroup.javaに以下のコードを追加

entries.add(ModItems.PANTS);

2-2 : テクスチャの保存
textures/itemディレクトリをクリック!
画面右側からアップロードをクリックして、ダウンロードしたpants.pngをアップロードしよう!
2-3 : アイテムモデルの設定
models/itemフォルダをクリック!
画面右側からファイル作成をクリックして、pants.jsonというファイルを作成しよう
pants.jsonを以下のように編集しよう

{
  "parent": "minecraft:item/generated",
  "textures": {
  "layer0": "sushimod:item/pants"
  }
}

靴を追加

ModItems.javaに以下のコードを追加

   public static final Item GETA = registerItem("geta"
      , new  ArmorItem(
          ModArmorMaterials.ITAMAE,
          ArmorItem.Type.BOOTS,
          new FabricItemSettings()
      ));

ModItemGroup.javaに以下のコードを追加

entries.add(ModItems.GETA);

2-2 : テクスチャの保存
textures/itemディレクトリをクリック!
画面右側からアップロードをクリックして、ダウンロードしたgeta.pngをアップロードしよう!
2-3 : アイテムモデルの設定
models/itemフォルダをクリック!
画面右側からファイル作成をクリックして、geta.jsonというファイルを作成しよう
geta.jsonを以下のように編集しよう

{
  "parent": "minecraft:item/generated",
  "textures": {
  "layer0": "sushimod:item/geta"
  }
}

寿司職人の装備を着れるようにしよう!!

1-2 : 装着用のテクスチャを保存しよう!
texturesディレクトリをクリック!
画面右側からディレクトリ作成をクリックして、modelsと入力してディレクトリを作成しよう
textures/modelsディレクトリをクリック!
画面右側からディレクトリ作成をクリックして、armorと入力してディレクトリを作成しよう
textures/models/armorディレクトリをクリック!
画面右側からアップロードをクリックして、ダウンロードしたitamae_layer_1.png, itamae_layer_2.pngをアップロードしよう!

タイトルとURLをコピーしました