diff --git a/src/main/java/com/minelittlepony/unicopia/item/BluntWeaponItem.java b/src/main/java/com/minelittlepony/unicopia/item/BluntWeaponItem.java new file mode 100644 index 00000000..3fa3cb20 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/item/BluntWeaponItem.java @@ -0,0 +1,30 @@ +package com.minelittlepony.unicopia.item; + +import java.util.UUID; + +import com.google.common.collect.Multimap; + +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.attribute.EntityAttribute; +import net.minecraft.entity.attribute.EntityAttributeModifier; +import net.minecraft.item.Item; + +public class BluntWeaponItem extends Item { + private final Multimap modifiers; + + public static final UUID KNOCKBACK_MODIFIER_ID = UUID.fromString("7b16994b-1edb-4381-be62-94317f39ec8f"); + public static final UUID LUCK_MODIFIER_ID = UUID.fromString("7b16994b-1edb-8431-be62-7f39ec94318f"); + + public BluntWeaponItem(Settings settings, Multimap modifiers) { + super(settings); + this.modifiers = modifiers; + } + + @Override + public Multimap getAttributeModifiers(EquipmentSlot slot) { + if (slot == EquipmentSlot.OFFHAND) { + return modifiers; + } + return super.getAttributeModifiers(slot); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/item/UItems.java b/src/main/java/com/minelittlepony/unicopia/item/UItems.java index 27b8262f..12d0137e 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/item/UItems.java @@ -1,5 +1,6 @@ package com.minelittlepony.unicopia.item; +import com.google.common.collect.ImmutableMultimap; import com.minelittlepony.unicopia.*; import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.block.UWoodTypes; @@ -13,6 +14,8 @@ import com.terraformersmc.terraform.boat.api.TerraformBoatType; import com.terraformersmc.terraform.boat.api.TerraformBoatTypeRegistry; import com.terraformersmc.terraform.boat.api.item.TerraformBoatItemHelper; +import net.minecraft.entity.attribute.EntityAttributeModifier; +import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.item.*; import net.minecraft.item.Item.Settings; @@ -80,7 +83,12 @@ public interface UItems { Item PEBBLES = register("pebbles", new RacePredicatedAliasedBlockItem(UBlocks.ROCKS, new Item.Settings(), Race::canUseEarth), ItemGroups.NATURAL); Item ROCK = register("rock", new HeavyProjectileItem(new Item.Settings(), 3), ItemGroups.NATURAL); - Item WEIRD_ROCK = register("weird_rock", new Item(new Item.Settings()), ItemGroups.NATURAL); + Item WEIRD_ROCK = register("weird_rock", new BluntWeaponItem(new Item.Settings(), ImmutableMultimap.of( + EntityAttributes.GENERIC_LUCK, new EntityAttributeModifier(BluntWeaponItem.LUCK_MODIFIER_ID, "Weapon modifier", 9, EntityAttributeModifier.Operation.ADDITION) + )), ItemGroups.NATURAL); + Item TOM = register("tom", new BluntWeaponItem(new Item.Settings(), ImmutableMultimap.of( + EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(BluntWeaponItem.KNOCKBACK_MODIFIER_ID, "Weapon modifier", 0.9, EntityAttributeModifier.Operation.ADDITION) + )), ItemGroups.NATURAL); Item ROCK_STEW = register("rock_stew", new Item(new Item.Settings().food(FoodComponents.MUSHROOM_STEW)), ItemGroups.FOOD_AND_DRINK); Item GREEN_APPLE_SEEDS = register("green_apple_seeds", new AliasedBlockItem(UBlocks.GREEN_APPLE_SPROUT, new Item.Settings()), ItemGroups.NATURAL); diff --git a/src/main/java/com/minelittlepony/unicopia/item/URecipes.java b/src/main/java/com/minelittlepony/unicopia/item/URecipes.java index a3d13d6e..363d3855 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/URecipes.java +++ b/src/main/java/com/minelittlepony/unicopia/item/URecipes.java @@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.crafting.*; import net.fabricmc.fabric.api.loot.v2.LootTableEvents; import net.minecraft.loot.LootTable; +import net.minecraft.loot.context.LootContextTypes; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.RecipeType; @@ -48,8 +49,17 @@ public interface URecipes { Identifier modId = new Identifier("unicopiamc", id.getPath()); LootTable table = manager.getLootTable(modId); + if (table != LootTable.EMPTY) { - supplier.pools(List.of(table.pools)); + if (table.getType() == LootContextTypes.ARCHAEOLOGY) { + supplier.modifyPools(poolBuilder -> { + for (var pool : table.pools) { + poolBuilder.with(List.of(pool.entries)); + } + }); + } else { + supplier.pools(List.of(table.pools)); + } } }); } diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index 5f10a3f4..267b8975 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -98,6 +98,7 @@ "item.unicopia.pebbles": "Pebbles", "item.unicopia.rock": "Rock", "item.unicopia.weird_rock": "Weird Rock", + "item.unicopia.tom": "Tom", "item.unicopia.rock_stew": "Rock Stew", "item.unicopia.pinecone": "Pinecone", "item.unicopia.acorn": "Acorn", diff --git a/src/main/resources/assets/unicopia/models/item/tom.json b/src/main/resources/assets/unicopia/models/item/tom.json new file mode 100644 index 00000000..c22e6ac2 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/item/tom.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "unicopia:item/tom" + } +} diff --git a/src/main/resources/assets/unicopia/textures/item/tom.png b/src/main/resources/assets/unicopia/textures/item/tom.png new file mode 100644 index 00000000..308f085b Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/tom.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/tom.png.mcmeta b/src/main/resources/assets/unicopia/textures/item/tom.png.mcmeta new file mode 100644 index 00000000..a8ee6d0b --- /dev/null +++ b/src/main/resources/assets/unicopia/textures/item/tom.png.mcmeta @@ -0,0 +1,31 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + { + "index": 0, + "time": 1000 + }, + { + "index": 1, + "time": 2 + }, + { + "index": 0, + "time": 2000 + }, + { + "index": 1, + "time": 2 + }, + { + "index": 0, + "time": 4000 + }, + { + "index": 1, + "time": 2 + } + ] + } +} diff --git a/src/main/resources/data/unicopiamc/loot_tables/archaeology/desert_well.json b/src/main/resources/data/unicopiamc/loot_tables/archaeology/desert_well.json new file mode 100644 index 00000000..25d4fc53 --- /dev/null +++ b/src/main/resources/data/unicopiamc/loot_tables/archaeology/desert_well.json @@ -0,0 +1,37 @@ +{ + "type": "minecraft:archaeology", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "unicopia:weird_rock", + "weight": 2 + }, + { + "type": "minecraft:item", + "name": "unicopia:rock", + "weight": 1 + }, + { + "type": "minecraft:item", + "name": "unicopia:tom", + "weight": 1 + }, + { + "type": "minecraft:item", + "name": "unicopia:rock_stew", + "weight": 1 + }, + { + "type": "minecraft:item", + "name": "unicopia:pebbles", + "weight": 1 + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:archaeology/desert_well" +} diff --git a/src/main/resources/data/unicopiamc/loot_tables/archaeology/trail_ruins_common.json b/src/main/resources/data/unicopiamc/loot_tables/archaeology/trail_ruins_common.json new file mode 100644 index 00000000..0aac2574 --- /dev/null +++ b/src/main/resources/data/unicopiamc/loot_tables/archaeology/trail_ruins_common.json @@ -0,0 +1,27 @@ +{ + "type": "minecraft:archaeology", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "unicopia:meadowbrooks_staff", + "weight": 2 + }, + { + "type": "minecraft:item", + "name": "unicopia:botched_gem", + "weight": 3 + }, + { + "type": "minecraft:item", + "name": "unicopia:pegasus_feather", + "weight": 1 + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:archaeology/desert_well" +} diff --git a/src/main/resources/data/unicopiamc/loot_tables/archaeology/trail_ruins_rare.json b/src/main/resources/data/unicopiamc/loot_tables/archaeology/trail_ruins_rare.json new file mode 100644 index 00000000..83b35921 --- /dev/null +++ b/src/main/resources/data/unicopiamc/loot_tables/archaeology/trail_ruins_rare.json @@ -0,0 +1,27 @@ +{ + "type": "minecraft:archaeology", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "unicopia:broken_sunglasses", + "weight": 2 + }, + { + "type": "minecraft:item", + "name": "unicopia:empty_jar", + "weight": 2 + }, + { + "type": "minecraft:item", + "name": "unicopia:music_disc_crusade", + "weight": 1 + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:archaeology/desert_well" +}