pull/68/head
Joshua7Perkins 4 years ago
parent dc3aef2218
commit c7da687185

@ -1,14 +1,75 @@
package net.fabricmc.example;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class ExampleMod implements ModInitializer {
// This is a generic Item template
// public static final Item FabricItem = new Item(new FabricItemSettings().group(ItemGroup.MISC));
// VT Tutorial Book
// Implemented by Jerbyl
public static final TutorialBook TUTORIAL_BOOK = new TutorialBook(new FabricItemSettings().group(ItemGroup.MISC));
public static final RingOfFlight RING_OF_FLIGHT = new RingOfFlight(new FabricItemSettings().group(ItemGroup.MISC));
// Charcoal block
// Implemented by Jerbyl
public static final Block BLOCK_OF_CHARCOAL = new Block(FabricBlockSettings.of(Material.STONE).hardness(5.0f));
// Gold-plated diamond armor items
// Implemented by Jerbyl
public static final Item GOLD_DIAMOND_HELMET = new ArmorItem(GoldDiamond.GOLD_DIAMOND, EquipmentSlot.HEAD, (new Item.Settings().group(ItemGroup.COMBAT)));
public static final Item GOLD_DIAMOND_CHESTPLATE = new ArmorItem(GoldDiamond.GOLD_DIAMOND, EquipmentSlot.CHEST, (new Item.Settings().group(ItemGroup.COMBAT)));
public static final Item GOLD_DIAMOND_LEGGINGS = new ArmorItem(GoldDiamond.GOLD_DIAMOND, EquipmentSlot.LEGS, (new Item.Settings().group(ItemGroup.COMBAT)));
public static final Item GOLD_DIAMOND_BOOTS = new ArmorItem(GoldDiamond.GOLD_DIAMOND, EquipmentSlot.FEET, (new Item.Settings().group(ItemGroup.COMBAT)));
// Gold-plated netherite armor items
// Implemented by Jerbyl
public static final Item GOLD_NETHERITE_HELMET = new ArmorItem(GoldNetherite.GOLD_NETHERITE, EquipmentSlot.HEAD, (new Item.Settings().group(ItemGroup.COMBAT)));
public static final Item GOLD_NETHERITE_CHESTPLATE = new ArmorItem(GoldNetherite.GOLD_NETHERITE, EquipmentSlot.CHEST, (new Item.Settings().group(ItemGroup.COMBAT)));
public static final Item GOLD_NETHERITE_LEGGINGS = new ArmorItem(GoldNetherite.GOLD_NETHERITE, EquipmentSlot.LEGS, (new Item.Settings().group(ItemGroup.COMBAT)));
public static final Item GOLD_NETHERITE_BOOTS = new ArmorItem(GoldNetherite.GOLD_NETHERITE, EquipmentSlot.FEET, (new Item.Settings().group(ItemGroup.COMBAT)));
@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
System.out.println("Hello Fabric world!");
// Adds registry entry for VT Tutorial Book
// Implemented by Jerbyl
Registry.register(Registry.ITEM, new Identifier("examplemod", "tutorial_book"), TUTORIAL_BOOK);
// Adds registry entry for Ring Of Flight
// Implemented by Jerbyl
Registry.register(Registry.ITEM, new Identifier("examplemod", "ring_of_flight"), RING_OF_FLIGHT);
// Adds registry entries for the Charcoal_Block item and block
// Implemented by Jerbyl
Registry.register(Registry.BLOCK, new Identifier("examplemod", "block_of_charcoal"), BLOCK_OF_CHARCOAL);
Registry.register(Registry.ITEM, new Identifier("examplemod", "block_of_charcoal"), new BlockItem(BLOCK_OF_CHARCOAL, new Item.Settings().group(ItemGroup.MISC)));
// Adds registry entries for gold-trimmed diamond and netherite armors.
// Implemented by Jerbyl
Registry.register(Registry.ITEM,new Identifier("examplemod","gold_diamond_helmet"), GOLD_DIAMOND_HELMET);
Registry.register(Registry.ITEM,new Identifier("examplemod","gold_diamond_chestplate"), GOLD_DIAMOND_CHESTPLATE);
Registry.register(Registry.ITEM,new Identifier("examplemod","gold_diamond_leggings"), GOLD_DIAMOND_LEGGINGS);
Registry.register(Registry.ITEM,new Identifier("examplemod","gold_diamond_boots"), GOLD_DIAMOND_BOOTS);
Registry.register(Registry.ITEM,new Identifier("examplemod","gold_netherite_helmet"), GOLD_NETHERITE_HELMET);
Registry.register(Registry.ITEM,new Identifier("examplemod","gold_netherite_chestplate"), GOLD_NETHERITE_CHESTPLATE);
Registry.register(Registry.ITEM,new Identifier("examplemod","gold_netherite_leggings"), GOLD_NETHERITE_LEGGINGS);
Registry.register(Registry.ITEM,new Identifier("examplemod","gold_netherite_boots"), GOLD_NETHERITE_BOOTS);
}
}
}

@ -0,0 +1,75 @@
package net.fabricmc.example;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.Items;
import net.minecraft.recipe.Ingredient;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Lazy;
import java.util.function.Supplier;
public enum GoldDiamond implements ArmorMaterial {
GOLD_DIAMOND("gold_diamond", 33, new int[]{3, 8, 6, 3}, 20, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 2.0F, 0.0F, () -> {
return Ingredient.ofItems(Items.DIAMOND);
});
private static final int[] BASE_DURABILITY = {13, 15, 16, 11};
private final String name;
private final int durabilityMultiplier;
private final int[] armorValues;
private final int enchantability;
private final SoundEvent equipSound;
private final float toughness;
private final float knockbackResistance;
private final Lazy<Ingredient> repairIngredient;
GoldDiamond(String name, int durabilityMultiplier, int[] armorValueArr, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier<Ingredient> repairIngredient) {
this.name = name;
this.durabilityMultiplier = durabilityMultiplier;
this.armorValues = armorValueArr;
this.enchantability = enchantability;
this.equipSound = soundEvent;
this.toughness = toughness;
this.knockbackResistance = knockbackResistance;
this.repairIngredient = new Lazy(repairIngredient);
}
public int getDurability(EquipmentSlot equipmentSlot_1) {
return BASE_DURABILITY[equipmentSlot_1.getEntitySlotId()] * this.durabilityMultiplier;
}
public int getProtectionAmount(EquipmentSlot equipmentSlot_1) {
return this.armorValues[equipmentSlot_1.getEntitySlotId()];
}
public int getEnchantability() {
return this.enchantability;
}
public SoundEvent getEquipSound() {
return this.equipSound;
}
public Ingredient getRepairIngredient() {
// We needed to make it a Lazy type so we can actually get the Ingredient from the Supplier.
return this.repairIngredient.get();
}
@Environment(EnvType.CLIENT)
public String getName() {
return this.name;
}
public float getToughness() {
return this.toughness;
}
public float getKnockbackResistance() {
return this.knockbackResistance;
}
}

@ -0,0 +1,75 @@
package net.fabricmc.example;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.Items;
import net.minecraft.recipe.Ingredient;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Lazy;
import java.util.function.Supplier;
public enum GoldNetherite implements ArmorMaterial {
GOLD_NETHERITE("gold_netherite", 37, new int[]{3, 8, 6, 3}, 25, SoundEvents.ITEM_ARMOR_EQUIP_NETHERITE, 3.0F, 1.0F, () -> {
return Ingredient.ofItems(Items.NETHERITE_INGOT);
});
private static final int[] BASE_DURABILITY = {13, 15, 16, 11};
private final String name;
private final int durabilityMultiplier;
private final int[] armorValues;
private final int enchantability;
private final SoundEvent equipSound;
private final float toughness;
private final float knockbackResistance;
private final Lazy<Ingredient> repairIngredient;
GoldNetherite(String name, int durabilityMultiplier, int[] armorValueArr, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier<Ingredient> repairIngredient) {
this.name = name;
this.durabilityMultiplier = durabilityMultiplier;
this.armorValues = armorValueArr;
this.enchantability = enchantability;
this.equipSound = soundEvent;
this.toughness = toughness;
this.knockbackResistance = knockbackResistance;
this.repairIngredient = new Lazy(repairIngredient);
}
public int getDurability(EquipmentSlot equipmentSlot_1) {
return BASE_DURABILITY[equipmentSlot_1.getEntitySlotId()] * this.durabilityMultiplier;
}
public int getProtectionAmount(EquipmentSlot equipmentSlot_1) {
return this.armorValues[equipmentSlot_1.getEntitySlotId()];
}
public int getEnchantability() {
return this.enchantability;
}
public SoundEvent getEquipSound() {
return this.equipSound;
}
public Ingredient getRepairIngredient() {
// We needed to make it a Lazy type so we can actually get the Ingredient from the Supplier.
return this.repairIngredient.get();
}
@Environment(EnvType.CLIENT)
public String getName() {
return this.name;
}
public float getToughness() {
return this.toughness;
}
public float getKnockbackResistance() {
return this.knockbackResistance;
}
}

@ -0,0 +1,25 @@
package net.fabricmc.example;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
public class RingOfFlight extends Item {
public RingOfFlight(Settings settings) {
super(settings);
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
playerEntity.playSound(SoundEvents.ENTITY_ARROW_HIT_PLAYER, 1.0F, 1.0F);
return new TypedActionResult<>(ActionResult.SUCCESS, playerEntity.getStackInHand(hand));
}
}

@ -0,0 +1,25 @@
package net.fabricmc.example;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
public class TutorialBook extends Item {
public TutorialBook(Settings settings) {
super(settings);
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
playerEntity.playSound(SoundEvents.ENTITY_PLAYER_HURT, 1.0F, 1.0F);
return new TypedActionResult<>(ActionResult.SUCCESS, playerEntity.getStackInHand(hand));
}
}

@ -0,0 +1,6 @@
{
"variants": {
"": { "model": "examplemod:block/block_of_charcoal" }
}
}

@ -0,0 +1,7 @@
{
"parent": "block/cube_all",
"textures": {
"all": "examplemod:block/block_of_charcoal"
}
}

@ -0,0 +1,3 @@
{
"parent": "examplemod:block/block_of_charcoal"
}

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "examplemod:item/tutorial_book"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"name": "examplemod:block_of_charcoal",
"type": "minecraft:item"
}
],
"rolls": 1
}
]
}

@ -0,0 +1,16 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"C"
],
"key": {
"C": {
"item": "examplemod:block_of_charcoal"
}
},
"result": {
"item": "minecraft:charcoal",
"count": 9
}
}

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"CCC",
"CCC"
],
"key": {
"C": {
"item": "minecraft:charcoal"
}
},
"result": {
"item": "examplemod:block_of_charcoal"
}
}

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"D D",
"DDD",
"D D"
],
"key": {
"D": {
"item": "minecraft:diamond"
}
},
"result": {
"item": "minecraft:diamond_horse_armor"
}
}

@ -0,0 +1,24 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"SES",
"SDS",
"SSS"
],
"key": {
"S": {
"item": "minecraft:end_stone"
},
"E": {
"item": "minecraft:ender_eye"
},
"D": {
"item": "minecraft:dragon_egg"
}
},
"result": {
"item": "minecraft:end_portal_frame",
"count": 12
}
}

@ -0,0 +1,8 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": ["minecraft:arrow", "minecraft:ender_eye"],
"result": {
"item": "vt:ender_arrow"
}
}

@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"BBB",
"BEB",
"BBB"
],
"key": {
"E": {
"item": "minecraft:emerald"
},
"B": {
"item": "minecraft:iron_bars"
},
},
"result": {
"item": "examplemod:experience_cage"
}
}

@ -0,0 +1,9 @@
{
"type": "minecraft:smelting",
"ingredients": {
"item": "minecraft:rotten_flesh"
},
"result": {
"item": "minecraft:leather"
}
}

@ -0,0 +1,23 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"FGF",
"GEG",
"GGG"
],
"key": {
"F": {
"item": "minecraft:feather"
},
"E": {
"item": "minecraft:elytra"
},
"G": {
"item": "minecraft:gold_ingot"
}
},
"result": {
"item": "examplemod:ring_of_flight"
}
}

@ -0,0 +1,13 @@
{
"type": "smithing",
"base": {
"item": "minecraft:diamond_boots"
},
"addition": {
"item": "minecraft:gold_block"
},
"result": {
"item": "examplemod:gold_diamond_boots"
}
}

@ -0,0 +1,13 @@
{
"type": "smithing",
"base": {
"item": "minecraft:diamond_chestplate"
},
"addition": {
"item": "minecraft:gold_block"
},
"result": {
"item": "examplemod:gold_diamond_chestplate"
}
}

@ -0,0 +1,13 @@
{
"type": "smithing",
"base": {
"item": "minecraft:diamond_helmet"
},
"addition": {
"item": "minecraft:gold_block"
},
"result": {
"item": "examplemod:gold_diamond_helmet"
}
}

@ -0,0 +1,13 @@
{
"type": "smithing",
"base": {
"item": "minecraft:diamond_leggings"
},
"addition": {
"item": "minecraft:gold_block"
},
"result": {
"item": "examplemod:gold_diamond_leggings"
}
}

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"G G",
"GGG",
"G G"
],
"key": {
"G": {
"item": "minecraft:gold_ingot"
}
},
"result": {
"item": "minecraft:golden_horse_armor"
}
}

@ -0,0 +1,13 @@
{
"type": "smithing",
"base": {
"item": "minecraft:netherite_boots"
},
"addition": {
"item": "minecraft:gold_block"
},
"result": {
"item": "examplemod:gold_netherite_boots"
}
}

@ -0,0 +1,13 @@
{
"type": "smithing",
"base": {
"item": "minecraft:netherite_chestplate"
},
"addition": {
"item": "minecraft:gold_block"
},
"result": {
"item": "examplemod:gold_netherite_chestplate"
}
}

@ -0,0 +1,13 @@
{
"type": "smithing",
"base": {
"item": "minecraft:netherite_helmet"
},
"addition": {
"item": "minecraft:gold_block"
},
"result": {
"item": "examplemod:gold_netherite_helmet"
}
}

@ -0,0 +1,13 @@
{
"type": "smithing",
"base": {
"item": "minecraft:netherite_leggings"
},
"addition": {
"item": "minecraft:gold_block"
},
"result": {
"item": "examplemod:gold_netherite_leggings"
}
}

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"I I",
"III",
"I I"
],
"key": {
"I": {
"item": "minecraft:iron_ingot"
}
},
"result": {
"item": "minecraft:iron_horse_armor"
}
}

@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shapeless",
"pattern": [
"SP "
],
"key": {
"S": {
"item": "minecraft:string"
},
"P": {
"item": "minecraft:paper"
}
},
"result": {
"item": "minecraft:name_tag"
}
}

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"N N",
"NNN",
"N N"
],
"key": {
"N": {
"item": "minecraft:netherite_ingot"
}
},
"result": {
"item": "examplemod:netherite_horse_armor"
}
}

@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"LLL",
"T T",
" "
],
"key": {
"L": {
"item": "minecraft:leather"
},
"T": {
"item": "minecraft:tripwire_hook"
}
},
"result": {
"item": "minecraft:saddle"
}
}

@ -0,0 +1,21 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"WSW",
"W W",
"W W"
],
"key": {
"S": {
"item": "minecraft:string"
},
"W": {
"item": "minecraft:stick"
}
},
"result": {
"item": "minecraft:scaffolding",
"count": 6
}
}
Loading…
Cancel
Save