Skip to content

Commit

Permalink
Add aluminum helment (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
legobmw99 committed Jan 13, 2024
1 parent e5f23d3 commit 6988235
Show file tree
Hide file tree
Showing 20 changed files with 198 additions and 17 deletions.
3 changes: 3 additions & 0 deletions src/generated/resources/assets/allomancy/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"advancements.local_metallurgist.title": "Local Metallurgist!",
"advancements.metallic_collector.desc": "Collect every single metallic flake, even the useless ones",
"advancements.metallic_collector.title": "Metallic Collector",
"advancements.tin_foil_hat.desc": "Protect yourself, and be a bit paranoid too",
"advancements.tin_foil_hat.title": "Tin foil hat",
"allomancy.networking.failed": "Allomancy packet failed to play: %s",
"allomancy.networking.kicked": "Requested illegal action: %s",
"block.allomancy.aluminum_block": "Aluminum Block",
Expand Down Expand Up @@ -317,6 +319,7 @@
"entity.allomancy.nugget_projectile": "Nugget Projectile",
"item.allomancy.allomantic_grinder": "Hand Grinder",
"item.allomancy.aluminum_flakes": "Aluminum Flakes",
"item.allomancy.aluminum_helmet": "Aluminum Helmet",
"item.allomancy.aluminum_ingot": "Aluminum Ingot",
"item.allomancy.aluminum_nugget": "Aluminum Nugget",
"item.allomancy.aluminum_pattern": "Banner Pattern",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "allomancy:item/aluminum_helmet"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@
},
"frame": "challenge",
"icon": {
"item": "allomancy:vial"
"item": "allomancy:vial",
"nbt": "{CustomModelData:1}"
},
"title": {
"translate": "advancements.metallic_collector.title"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"parent": "allomancy:main/metallurgist",
"criteria": {
"tin_foil_hat": {
"conditions": {
"items": [
{
"items": [
"allomancy:aluminum_helmet"
]
}
]
},
"trigger": "minecraft:inventory_changed"
}
},
"display": {
"announce_to_chat": false,
"description": {
"translate": "advancements.tin_foil_hat.desc"
},
"hidden": true,
"icon": {
"item": "allomancy:aluminum_helmet",
"nbt": "{Damage:0}"
},
"title": {
"translate": "advancements.tin_foil_hat.title"
}
},
"requirements": [
[
"tin_foil_hat"
]
],
"sends_telemetry_event": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_aluminum_ingot": {
"conditions": {
"items": [
{
"items": [
"allomancy:aluminum_ingot"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "allomancy:aluminum_helmet"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_aluminum_ingot"
]
],
"rewards": {
"recipes": [
"allomancy:aluminum_helmet"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"items": [
{
"items": [
"allomancy:mistcloak"
"minecraft:gold_nugget"
]
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "minecraft:crafting_shaped",
"category": "equipment",
"key": {
"A": {
"tag": "forge:ingots/aluminum"
}
},
"pattern": [
"AAA",
"A A"
],
"result": {
"item": "allomancy:aluminum_helmet"
}
}
21 changes: 19 additions & 2 deletions src/main/java/com/legobmw99/allomancy/datagen/Advancements.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import net.minecraft.advancements.*;
import net.minecraft.advancements.critereon.*;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.common.data.AdvancementProvider;
import net.neoforged.neoforge.common.data.ExistingFileHelper;

Expand Down Expand Up @@ -44,11 +46,16 @@ public void generate(HolderLookup.Provider registries, Consumer<AdvancementHolde
.rewards(AdvancementRewards.Builder.experience(100))
.save(saver, "allomancy:main/become_mistborn");

ItemStack vial = new ItemStack(ConsumeSetup.VIAL.get());
CompoundTag nbt = new CompoundTag();
nbt.putInt("CustomModelData", 1);
vial.setTag(nbt);

var allMetals = Advancement.Builder
.advancement()
.parent(Advancement.Builder.advancement().build(new ResourceLocation(Allomancy.MODID, "main/metallurgist")))
.display(ConsumeSetup.VIAL.get(), Component.translatable("advancements.metallic_collector.title"), Component.translatable("advancements.metallic_collector.desc"),
null, AdvancementType.CHALLENGE, true, true, false);
.display(vial, Component.translatable("advancements.metallic_collector.title"), Component.translatable("advancements.metallic_collector.desc"), null,
AdvancementType.CHALLENGE, true, true, false);
for (var flake : MaterialsSetup.FLAKES) {
allMetals.addCriterion("has_" + flake.getId().getPath(), InventoryChangeTrigger.TriggerInstance.hasItems(flake.get()));
}
Expand All @@ -65,5 +72,15 @@ public void generate(HolderLookup.Provider registries, Consumer<AdvancementHolde
.damageType()
.tag(TagPredicate.is(CombatSetup.IS_COIN_HIT))))
.save(saver, "allomancy:main/coinshot");


Advancement.Builder
.advancement()
.parent(Advancement.Builder.advancement().build(new ResourceLocation(Allomancy.MODID, "main/metallurgist")))
.display(CombatSetup.ALUMINUM_HELMET.get(), Component.translatable("advancements.tin_foil_hat.title"), Component.translatable("advancements.tin_foil_hat.desc"),
null, AdvancementType.TASK, true, false, true)
.addCriterion("tin_foil_hat", InventoryChangeTrigger.TriggerInstance.hasItems(CombatSetup.ALUMINUM_HELMET.get()))
// TODO require that someone actually use allomancy on you
.save(saver, "allomancy:main/tin_foil_hat");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected void registerModels() {
itemGenerated(ExtrasSetup.IRON_LEVER_ITEM.get(), "block/iron_lever");

itemGenerated(CombatSetup.MISTCLOAK.get());
itemGenerated(CombatSetup.ALUMINUM_HELMET.get());
itemGenerated(CombatSetup.COIN_BAG.get());
itemHandheld(CombatSetup.OBSIDIAN_DAGGER.get());
largeItemHandheld(CombatSetup.KOLOSS_BLADE.get());
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/legobmw99/allomancy/datagen/Languages.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected void addTranslations() {
add(ConsumeSetup.LERASIUM_NUGGET.get(), "Lerasium Nugget");
add("item.allomancy.lerasium_nugget.lore", "This item is endowed with strange powers, perhaps you should ingest it?");
add(CombatSetup.MISTCLOAK.get(), "Mistcloak");
add(CombatSetup.ALUMINUM_HELMET.get(), "Aluminum Helmet");
add(CombatSetup.COIN_BAG.get(), "Coin Bag");
add(CombatSetup.OBSIDIAN_DAGGER.get(), "Obsidian Dagger");
add(CombatSetup.KOLOSS_BLADE.get(), "Koloss Blade");
Expand Down Expand Up @@ -109,6 +110,8 @@ protected void addTranslations() {
add("advancements.metallic_collector.desc", "Collect every single metallic flake, even the useless ones");
add("advancements.coinshot.title", "Coinshot");
add("advancements.coinshot.desc", "Kill a mob with the bag of coins.");
add("advancements.tin_foil_hat.title", "Tin foil hat");
add("advancements.tin_foil_hat.desc", "Protect yourself, and be a bit paranoid too");

add("key.categories.allomancy", "Allomancy");
add("key.burn", "Burn Metals");
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/legobmw99/allomancy/datagen/Recipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public Recipes(PackOutput packOutput, CompletableFuture<HolderLookup.Provider> l
add('W', Items.GRAY_WOOL);
add('O', Tags.Items.OBSIDIAN);
add('C', Items.COBBLESTONE);
add('A', ing("forge:ingots/aluminum"));

}

Expand Down Expand Up @@ -135,6 +136,8 @@ protected void buildRecipes(RecipeOutput consumer) {
buildShaped(consumer, RecipeCategory.FOOD, ConsumeSetup.ALLOMANTIC_GRINDER.get(), Items.IRON_INGOT, "ggg", "iii", "ggg");
buildShaped(consumer, RecipeCategory.FOOD, ConsumeSetup.VIAL.get(), 4, Items.GLASS, " S ", "G G", " G ");
buildShaped(consumer, RecipeCategory.COMBAT, CombatSetup.MISTCLOAK.get(), ConsumeSetup.VIAL.get(), "W W", "WWW", "WWW");
buildShaped(consumer, RecipeCategory.COMBAT, CombatSetup.ALUMINUM_HELMET.get(), MaterialsSetup.INGOTS.get(Metal.ALUMINUM.getIndex()).get(), "AAA", "A A");

buildShaped(consumer, RecipeCategory.COMBAT, CombatSetup.OBSIDIAN_DAGGER.get(), CombatSetup.MISTCLOAK.get(), " O", " O ", "s ");
buildShaped(consumer, RecipeCategory.COMBAT, CombatSetup.KOLOSS_BLADE.get(), ConsumeSetup.LERASIUM_NUGGET.get(), "CC", "CC", "sC");

Expand Down Expand Up @@ -248,7 +251,7 @@ protected void buildRecipes(RecipeOutput consumer) {
Allomancy.LOGGER.debug("Creating Shaped Recipe for allomancy:coin_bag");
ShapedRecipeBuilder
.shaped(RecipeCategory.COMBAT, CombatSetup.COIN_BAG.get())
.unlockedBy("has_gold_nugget", InventoryChangeTrigger.TriggerInstance.hasItems(CombatSetup.MISTCLOAK.get()))
.unlockedBy("has_gold_nugget", InventoryChangeTrigger.TriggerInstance.hasItems(Items.GOLD_NUGGET))
.showNotification(true)
.define('#', Items.LEAD)
.define('l', Items.LEATHER)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.legobmw99.allomancy.modules.combat;

import com.legobmw99.allomancy.Allomancy;
import com.legobmw99.allomancy.api.enums.Metal;
import com.legobmw99.allomancy.modules.combat.entity.ProjectileNuggetEntity;
import com.legobmw99.allomancy.modules.combat.item.CoinBagItem;
import com.legobmw99.allomancy.modules.combat.item.KolossBladeItem;
import com.legobmw99.allomancy.modules.combat.item.MistcloakItem;
import com.legobmw99.allomancy.modules.combat.item.ObsidianDaggerItem;
import com.legobmw99.allomancy.modules.materials.MaterialsSetup;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -17,6 +19,7 @@
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.neoforged.bus.api.IEventBus;
Expand Down Expand Up @@ -76,8 +79,53 @@ public float getKnockbackResistance() {
}

};

public static final ArmorMaterial AluminumArmor = new ArmorMaterial() {
@Override
public int getDurabilityForType(ArmorItem.Type type) {
return 155;
}

@Override
public int getDefenseForType(ArmorItem.Type type) {
return type == ArmorItem.Type.HELMET ? 2 : 0;
}

@Override
public int getEnchantmentValue() {
return 0;
}

@Override
public SoundEvent getEquipSound() {
return SoundEvents.ARMOR_EQUIP_IRON;
}

@Override
public Ingredient getRepairIngredient() {
return Ingredient.of(MaterialsSetup.INGOTS.get(Metal.ALUMINUM.getIndex()));
}

@Override
public String getName() {
return "allomancy:aluminum";
}

@Override
public float getToughness() {
return 0;
}

@Override
public float getKnockbackResistance() {
return 0;
}
};
public static final DeferredItem<MistcloakItem> MISTCLOAK = ITEMS.register("mistcloak", MistcloakItem::new);

public static final DeferredItem<ArmorItem> ALUMINUM_HELMET = ITEMS.register("aluminum_helmet",
() -> new ArmorItem(AluminumArmor, ArmorItem.Type.HELMET, new Item.Properties()));

public static void register(IEventBus bus) {
ENTITIES.register(bus);
ITEMS.register(bus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
import java.util.UUID;

public class MistcloakItem extends ArmorItem {
private static final UUID[] ARMOR_MODIFIERS = new UUID[]{UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"),
UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")};
private static final UUID MODIFIER = UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E");

private final Multimap<Attribute, AttributeModifier> attributes;

public MistcloakItem() {
super(CombatSetup.WoolArmor, Type.CHESTPLATE, new Item.Properties());

ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
UUID uuid = ARMOR_MODIFIERS[this.getEquipmentSlot().getIndex()];
builder.put(Attributes.ARMOR, new AttributeModifier(uuid, "Armor modifier", this.getDefense(), AttributeModifier.Operation.ADDITION));
builder.put(Attributes.ARMOR_TOUGHNESS, new AttributeModifier(uuid, "Armor toughness", this.getToughness(), AttributeModifier.Operation.ADDITION));
builder.put(Attributes.MOVEMENT_SPEED, new AttributeModifier(uuid, "Speed Modifier", .25, AttributeModifier.Operation.MULTIPLY_TOTAL));
builder.put(Attributes.ARMOR, new AttributeModifier(MODIFIER, "Armor modifier", this.getDefense(), AttributeModifier.Operation.ADDITION));
builder.put(Attributes.ARMOR_TOUGHNESS, new AttributeModifier(MODIFIER, "Armor toughness", this.getToughness(), AttributeModifier.Operation.ADDITION));
builder.put(Attributes.MOVEMENT_SPEED, new AttributeModifier(MODIFIER, "Speed Modifier", .25, AttributeModifier.Operation.MULTIPLY_TOTAL));
this.attributes = builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.neoforged.neoforge.event.LootTableLoadEvent;

public class LootTableInjector {
// TODO replace https://docs.neoforged.net/docs/resources/server/glm/
@SubscribeEvent
public static void onLootTableLoad(final LootTableLoadEvent event) {
if (event.getName() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public static void onDamage(final LivingHurtEvent event) {
}

if (data.isBurning(Metal.CHROMIUM)) {
if (event.getEntity() instanceof Player player) {
if (event.getEntity() instanceof Player player && !PowerUtils.hasTinFoilHat(player)) {
PowerUtils.wipePlayer(player);
}
}
Expand Down
Loading

0 comments on commit 6988235

Please sign in to comment.