Files
src
build.gradle
gradle.properties
settings.gradle
Code
107 1,206
src/main/java/com/kodari/astralite/Astralite.java
package com.kodari.astralite;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.creativetab.v1.CreativeModeTabEvents;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.DamageTypeTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.world.item.AxeItem;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.BowItem;
import net.minecraft.world.item.CrossbowItem;
import net.minecraft.world.item.HoeItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.item.ShieldItem;
import net.minecraft.world.item.ShovelItem;
import net.minecraft.world.item.ShearsItem;
import net.minecraft.world.item.ToolMaterial;
import net.minecraft.world.item.component.BlocksAttacks;
import net.minecraft.world.item.component.ChargedProjectiles;
import net.minecraft.world.item.equipment.ArmorMaterial;
import net.minecraft.world.item.equipment.ArmorType;
import net.minecraft.world.item.equipment.EquipmentAsset;
import net.minecraft.world.item.equipment.EquipmentAssets;
import net.minecraft.world.item.equipment.Equippable;
import net.minecraft.world.level.block.entity.BannerPatternLayers;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.Unit;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.core.component.DataComponents;
public final class Astralite implements ModInitializer {
public static final String MOD_ID = "astralite";
private static final ResourceKey<EquipmentAsset> ASTRALITE_EQUIPMENT_ASSET = ResourceKey.create(
EquipmentAssets.ROOT_ID,
Identifier.fromNamespaceAndPath(MOD_ID, "astralite")
);
private static final ToolMaterial ASTRALITE_TOOLS = new ToolMaterial(
BlockTags.INCORRECT_FOR_NETHERITE_TOOL,
6000,
15.0F,
6.0F,
20,
ItemTags.NETHERITE_TOOL_MATERIALS
);
private static final ToolMaterial ASTRALITE_WEAPONS = new ToolMaterial(
BlockTags.INCORRECT_FOR_NETHERITE_TOOL,
3072,
15.0F,
6.0F,
20,
ItemTags.NETHERITE_TOOL_MATERIALS
);
private static final ArmorMaterial ASTRALITE_ARMOR = new ArmorMaterial(
33,
java.util.Map.of(
ArmorType.HELMET, 4,
ArmorType.CHESTPLATE, 9,
ArmorType.LEGGINGS, 7,
ArmorType.BOOTS, 4
),
20,
SoundEvents.ARMOR_EQUIP_NETHERITE,
3.5F,
0.15F,
ItemTags.REPAIRS_NETHERITE_ARMOR,
ASTRALITE_EQUIPMENT_ASSET
);
public static final Block ASTRALITE_ORE_BLOCK = registerBlock(
"astralite_ore",
BlockBehaviour.Properties.of().strength(5.0F, 9.0F).requiresCorrectToolForDrops()
);
public static final Item ASTRALITE_ORE_ITEM = register(
"astralite_ore",
properties -> new BlockItem(ASTRALITE_ORE_BLOCK, properties),
new Item.Properties()
);
public static final Item ASTRALITE_SCRAP = register("astralite_scrap", new Item.Properties().fireResistant());
public static final Item ASTRALITE_INGOT = register("astralite_ingot", new Item.Properties().fireResistant());
public static final Item ASTRALITE_UPGRADE_SMITHING_TEMPLATE = register(
"astralite_upgrade_smithing_template",
new Item.Properties()
);
public static final Item ASTRALITE_HELMET = register(
"astralite_helmet",
new Item.Properties().humanoidArmor(ASTRALITE_ARMOR, ArmorType.HELMET).durability(700).fireResistant()
);
public static final Item ASTRALITE_CHESTPLATE = register(
"astralite_chestplate",
new Item.Properties().humanoidArmor(ASTRALITE_ARMOR, ArmorType.CHESTPLATE).durability(850).fireResistant()
);
public static final Item ASTRALITE_LEGGINGS = register(
"astralite_leggings",
new Item.Properties().humanoidArmor(ASTRALITE_ARMOR, ArmorType.LEGGINGS).durability(800).fireResistant()
);
public static final Item ASTRALITE_BOOTS = register(
"astralite_boots",
new Item.Properties().humanoidArmor(ASTRALITE_ARMOR, ArmorType.BOOTS).durability(680).fireResistant()
);
public static final Item ASTRALITE_SWORD = register(
"astralite_sword",
new Item.Properties().sword(ASTRALITE_WEAPONS, 3.0F, -2.4F).fireResistant()
);
public static final Item ASTRALITE_SPEAR = register(
"astralite_spear",
new Item.Properties().spear(ASTRALITE_WEAPONS, 1.15F, 1.35F, 0.4F, 2.5F, 9.0F, 5.5F, 5.1F, 8.75F, 4.6F).fireResistant()
);
public static final Item ASTRALITE_PICKAXE = register(
"astralite_pickaxe",
new Item.Properties().pickaxe(ASTRALITE_TOOLS, 1.0F, -2.8F).fireResistant()
);
public static final Item ASTRALITE_AXE = register(
"astralite_axe",
properties -> new AxeItem(ASTRALITE_TOOLS, 6.0F, -3.0F, properties),
new Item.Properties().fireResistant()
);
public static final Item ASTRALITE_SHOVEL = register(
"astralite_shovel",
properties -> new ShovelItem(ASTRALITE_TOOLS, 1.5F, -3.0F, properties),
new Item.Properties().fireResistant()
);
public static final Item ASTRALITE_HOE = register(
"astralite_hoe",
properties -> new HoeItem(ASTRALITE_TOOLS, -4.0F, 0.0F, properties),
new Item.Properties().fireResistant()
);
public static final Item ASTRALITE_BOW = register(
"astralite_bow",
BowItem::new,
new Item.Properties().durability(2304).enchantable(20).fireResistant()
);
public static final Item ASTRALITE_CROSSBOW = register(
"astralite_crossbow",
CrossbowItem::new,
new Item.Properties()
.stacksTo(1)
.durability(2790)
.component(DataComponents.CHARGED_PROJECTILES, ChargedProjectiles.EMPTY)
.enchantable(20)
.fireResistant()
);
public static final Item ASTRALITE_SHIELD = register(
"astralite_shield",
ShieldItem::new,
new Item.Properties()
.durability(1536)
.component(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY)
.repairable(ItemTags.WOODEN_TOOL_MATERIALS)
.equippableUnswappable(EquipmentSlot.OFFHAND)
.delayedComponent(
DataComponents.BLOCKS_ATTACKS,
context -> new BlocksAttacks(
0.25F,
1.0F,
List.of(new BlocksAttacks.DamageReduction(90.0F, Optional.empty(), 0.0F, 1.0F)),
new BlocksAttacks.ItemDamageFunction(3.0F, 1.0F, 1.0F),
Optional.of(context.getOrThrow(DamageTypeTags.BYPASSES_SHIELD)),
Optional.of(SoundEvents.SHIELD_BLOCK),
Optional.of(SoundEvents.SHIELD_BREAK)
)
)
.component(DataComponents.BREAK_SOUND, SoundEvents.SHIELD_BREAK)
.fireResistant()
);
public static final Item ASTRALITE_ELYTRA = register(
"astralite_elytra",
new Item.Properties()
.durability(2048)
.fireResistant()
.component(DataComponents.GLIDER, Unit.INSTANCE)
.component(
DataComponents.EQUIPPABLE,
Equippable.builder(EquipmentSlot.CHEST)
.setEquipSound(SoundEvents.ARMOR_EQUIP_ELYTRA)
.setAsset(EquipmentAssets.ELYTRA)
.setDamageOnHurt(false)
.build()
)
.repairable(Items.PHANTOM_MEMBRANE)
);
public static final Item ASTRALITE_SHEARS = register(