Skip to content

Commit

Permalink
Implement travelers shield
Browse files Browse the repository at this point in the history
Travelers shields are lightweight shields, allowing you to dash while shielding. They only block a max of 10 damage, which is sufficient against most attacks
Plate shield will come in a later commit
  • Loading branch information
KnightMiner committed Feb 2, 2023
1 parent 42a3a84 commit 278d60d
Show file tree
Hide file tree
Showing 29 changed files with 288 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"tconstruct:armor/building/travelers_shield"
]
},
"criteria": {
"has_item": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"tag": "forge:ingots/copper"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "tconstruct:armor/building/travelers_shield"
}
}
},
"requirements": [
[
"has_item",
"has_the_recipe"
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
" c ",
"cwc",
" c "
],
"key": {
"c": {
"tag": "forge:ingots/copper"
},
"w": {
"tag": "minecraft:planks"
}
},
"result": {
"item": "tconstruct:travelers_shield"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
},
{
"item": "tconstruct:travelers_helmet"
},
{
"item": "tconstruct:travelers_shield"
}
],
"repair_material": "tconstruct:copper"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
},
{
"item": "tconstruct:travelers_helmet"
},
{
"item": "tconstruct:travelers_shield"
}
],
"repair_material": "tconstruct:copper"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "tconstruct:specialized_repair_kit",
"tool": {
"item": "tconstruct:travelers_shield"
},
"repair_material": "tconstruct:wood"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "tconstruct:specialized_station_repair",
"tool": {
"item": "tconstruct:travelers_shield"
},
"repair_material": "tconstruct:wood"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"tconstruct:slime_boots",
"tconstruct:slime_leggings",
"tconstruct:slime_chestplate",
"tconstruct:slime_helmet"
"tconstruct:slime_helmet",
"tconstruct:travelers_shield"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"tconstruct:travelers_boots",
"tconstruct:travelers_leggings",
"tconstruct:travelers_chestplate",
"tconstruct:travelers_helmet"
"tconstruct:travelers_helmet",
"tconstruct:travelers_shield"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"values": [
"tconstruct:crossbow",
"tconstruct:longbow",
"tconstruct:travelers_shield",
"#tconstruct:modifiable/interactable/dual"
]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"replace": false,
"values": []
"values": [
"tconstruct:travelers_shield"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"stats": {
"base": {
"tconstruct:durability": 200.0,
"tconstruct:block_amount": 10.0
}
},
"slots": {
"upgrades": 3,
"defense": 2,
"abilities": 1
},
"traits": [
{
"name": "tconstruct:blocking",
"level": 1
},
{
"name": "tconstruct:fast_use_item",
"level": 1
}
],
"modules": {
"tconstruct:tool_interaction": {
"type": "tconstruct:preference_set_interaction",
"preferred_source": "right_click",
"preferred_modifiers": {
"type": "tconstruct:single",
"modifier": "tconstruct:blocking"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ private void addTools() {
addToolTags(TinkerTools.slimesuit.get(ArmorSlotType.HELMET), MULTIPART_TOOL);

// shields
tag(SHIELDS);
addToolTags(TinkerTools.travelersShield, DURABILITY, DYEABLE, SHIELDS, INTERACTABLE_LEFT);


// add tags to other tags
// harvest primary and stone harvest are both automatically harvest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.UseAnim;
import slimeknights.tconstruct.TConstruct;
import slimeknights.tconstruct.library.tools.capability.TinkerDataCapability;
import slimeknights.tconstruct.library.tools.item.ModifiableLauncherItem;
Expand Down Expand Up @@ -50,6 +51,21 @@ public class TinkerItemProperties {
return 0;
};

/** ID for the pulling property */
private static final ResourceLocation CHARGING_ID = TConstruct.getResource("charging");
/** Boolean indicating the bow is pulling */
private static final ItemPropertyFunction CHARGING = (stack, level, holder, seed) -> {
if (holder != null && holder.isUsingItem() && holder.getUseItem() == stack) {
UseAnim anim = stack.getUseAnimation();
if (anim == UseAnim.BLOCK) {
return 2;
} else if (anim != UseAnim.EAT && anim != UseAnim.DRINK) {
return 1;
}
}
return 0;
};

/** Registers properties for a bow */
public static void registerBowProperties(Item item) {
ItemProperties.register(item, PULL_ID, PULL);
Expand All @@ -61,4 +77,9 @@ public static void registerCrossbowProperties(Item item) {
registerBowProperties(item);
ItemProperties.register(item, AMMO_ID, AMMO);
}

/** Registers properties for a bow */
public static void registerToolProperties(Item item) {
ItemProperties.register(item, CHARGING_ID, CHARGING);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package slimeknights.tconstruct.library.json.predicate.modifier;

import com.google.gson.JsonObject;
import net.minecraft.network.FriendlyByteBuf;
import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader;
import slimeknights.mantle.data.predicate.IJsonPredicate;
import slimeknights.mantle.util.JsonHelper;
import slimeknights.tconstruct.library.modifiers.ModifierId;

/** Predicate matching a single modifier */
public record SingleModifierPredicate(ModifierId modifier) implements ModifierPredicate {
@Override
public boolean matches(ModifierId input) {
return input.equals(modifier);
}

@Override
public IGenericLoader<? extends IJsonPredicate<ModifierId>> getLoader() {
return LOADER;
}

public static final IGenericLoader<SingleModifierPredicate> LOADER = new IGenericLoader<>() {
@Override
public SingleModifierPredicate deserialize(JsonObject json) {
return new SingleModifierPredicate(new ModifierId(JsonHelper.getResourceLocation(json, "modifier")));
}

@Override
public SingleModifierPredicate fromNetwork(FriendlyByteBuf buffer) {
return new SingleModifierPredicate(new ModifierId(buffer.readResourceLocation()));
}

@Override
public void serialize(SingleModifierPredicate object, JsonObject json) {
json.addProperty("modifier", object.modifier.toString());
}

@Override
public void toNetwork(SingleModifierPredicate object, FriendlyByteBuf buffer) {
buffer.writeResourceLocation(object.modifier);
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void validate(ToolDefinitionData data) {
.setStatsProvider(ToolStatProviders.NO_PARTS)
.setSoundEvent(Sounds.EQUIP_TRAVELERS.getSound())
.build();
public static final ToolDefinition TRAVELERS_SHIELD = ToolDefinition.builder(TinkerTools.travelersShield).noParts().build();

/** High defense armor set */
public static final ModifiableArmorMaterial PLATE = ModifiableArmorMaterial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import slimeknights.tconstruct.common.TinkerModule;
import slimeknights.tconstruct.common.data.tags.ModifierTagProvider;
import slimeknights.tconstruct.library.json.predicate.modifier.ModifierPredicate;
import slimeknights.tconstruct.library.json.predicate.modifier.SingleModifierPredicate;
import slimeknights.tconstruct.library.json.predicate.modifier.SlotTypeModifierPredicate;
import slimeknights.tconstruct.library.json.predicate.modifier.TagModifierPredicate;
import slimeknights.tconstruct.library.modifiers.Modifier;
Expand Down Expand Up @@ -566,6 +567,7 @@ void registerSerializers(RegistryEvent.Register<RecipeSerializer<?>> event) {
ModifierPredicate.LOADER.register(TConstruct.getResource("or"), ModifierPredicate.OR);
ModifierPredicate.LOADER.register(TConstruct.getResource("inverted"), ModifierPredicate.INVERTED);
ModifierPredicate.LOADER.register(TConstruct.getResource("always"), ModifierPredicate.ALWAYS.getLoader());
ModifierPredicate.LOADER.register(TConstruct.getResource("single"), SingleModifierPredicate.LOADER);
ModifierPredicate.LOADER.register(TConstruct.getResource("tag"), TagModifierPredicate.LOADER);
ModifierPredicate.LOADER.register(TConstruct.getResource("slot_type"), SlotTypeModifierPredicate.LOADER);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/slimeknights/tconstruct/tools/TinkerTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import slimeknights.tconstruct.library.tools.item.ModifiableArmorItem;
import slimeknights.tconstruct.library.tools.item.ModifiableItem;
import slimeknights.tconstruct.library.tools.item.ModifiableLauncherItem;
import slimeknights.tconstruct.library.tools.item.ModifiableStaffItem;
import slimeknights.tconstruct.library.utils.BlockSideHitListener;
import slimeknights.tconstruct.tools.data.StationSlotLayoutProvider;
import slimeknights.tconstruct.tools.data.ToolDefinitionDataProvider;
Expand Down Expand Up @@ -138,6 +139,9 @@ public TinkerTools() {
.put(ArmorSlotType.HELMET, ITEMS.register("slime_helmet", () -> new SlimeskullItem(ArmorDefinitions.SLIMESUIT, TOOL)))
.build();

// shields
public static final ItemObject<ModifiableItem> travelersShield = ITEMS.register("travelers_shield", () -> new ModifiableStaffItem(TOOL, ArmorDefinitions.TRAVELERS_SHIELD));

// arrows
public static final ItemObject<ArrowItem> crystalshotItem = ITEMS.register("crystalshot", () -> new CrystalshotItem(new Item.Properties().tab(TAB_TOOLS)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ static void clientSetupEvent(FMLClientSetupEvent event) {
// properties
TinkerItemProperties.registerCrossbowProperties(TinkerTools.crossbow.asItem());
TinkerItemProperties.registerBowProperties(TinkerTools.longbow.asItem());
TinkerItemProperties.registerToolProperties(TinkerTools.travelersShield.asItem());
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import slimeknights.tconstruct.library.data.tinkering.AbstractToolDefinitionDataProvider;
import slimeknights.tconstruct.library.json.predicate.block.BlockPredicate;
import slimeknights.tconstruct.library.json.predicate.block.TagBlockPredicate;
import slimeknights.tconstruct.library.json.predicate.modifier.SingleModifierPredicate;
import slimeknights.tconstruct.library.modifiers.hook.interaction.InteractionSource;
import slimeknights.tconstruct.library.tools.SlotType;
import slimeknights.tconstruct.library.tools.definition.aoe.BoxAOEIterator;
import slimeknights.tconstruct.library.tools.definition.aoe.CircleAOEIterator;
Expand All @@ -20,6 +22,8 @@
import slimeknights.tconstruct.library.tools.definition.harvest.FixedTierHarvestLogic;
import slimeknights.tconstruct.library.tools.definition.harvest.IHarvestLogic;
import slimeknights.tconstruct.library.tools.definition.harvest.ModifiedHarvestLogic;
import slimeknights.tconstruct.library.tools.definition.module.ToolModuleHooks;
import slimeknights.tconstruct.library.tools.definition.module.interaction.PreferenceSetInteraction;
import slimeknights.tconstruct.library.tools.definition.weapon.CircleWeaponAttack;
import slimeknights.tconstruct.library.tools.definition.weapon.ParticleWeaponAttack;
import slimeknights.tconstruct.library.tools.definition.weapon.SweepWeaponAttack;
Expand Down Expand Up @@ -390,6 +394,15 @@ TinkerTags.Blocks.TREE_LOGS, new TreeAOEIterator(0, 0),
.startingSlots(SlotType.UPGRADE, 3)
.startingSlots(SlotType.DEFENSE, 2)
.startingSlots(SlotType.ABILITY, 1);
define(ArmorDefinitions.TRAVELERS_SHIELD)
.stat(ToolStats.DURABILITY, 200)
.stat(ToolStats.BLOCK_AMOUNT, 10)
.startingSlots(SlotType.UPGRADE, 3)
.startingSlots(SlotType.DEFENSE, 2)
.startingSlots(SlotType.ABILITY, 1)
.trait(TinkerModifiers.blocking)
.trait(ModifierIds.fastUseItem)
.module(ToolModuleHooks.INTERACTION, new PreferenceSetInteraction(InteractionSource.RIGHT_CLICK, new SingleModifierPredicate(TinkerModifiers.blocking.getId())));

// plate armor
defineArmor(ArmorDefinitions.PLATE)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package slimeknights.tconstruct.tools.data;

import com.google.common.collect.Streams;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
Expand Down Expand Up @@ -33,6 +35,7 @@

import java.util.Collections;
import java.util.function.Consumer;
import java.util.stream.Stream;

public class ToolsRecipeProvider extends BaseRecipeProvider implements IMaterialRecipeHelper, IToolRecipeHelper {
public ToolsRecipeProvider(DataGenerator generator) {
Expand Down Expand Up @@ -124,13 +127,23 @@ private void addToolBuildingRecipes(Consumer<FinishedRecipe> consumer) {
.define('l', Tags.Items.LEATHER)
.unlockedBy("has_item", has(Tags.Items.INGOTS_COPPER))
.save(consumer, modResource(armorFolder + "travelers_boots"));
Ingredient travelers = Ingredient.of(TinkerTools.travelersGear.values().stream().map(ItemStack::new));
SpecializedRepairRecipeBuilder.repair(travelers, MaterialIds.copper)
ShapedRecipeBuilder.shaped(TinkerTools.travelersShield)
.pattern(" c ")
.pattern("cwc")
.pattern(" c ")
.define('c', Tags.Items.INGOTS_COPPER)
.define('w', ItemTags.PLANKS)
.unlockedBy("has_item", has(Tags.Items.INGOTS_COPPER))
.save(consumer, modResource(armorFolder + "travelers_shield"));
SpecializedRepairRecipeBuilder.repair(Ingredient.of(Streams.concat(TinkerTools.travelersGear.values().stream(), Stream.of(TinkerTools.travelersShield.get())).map(ItemStack::new)), MaterialIds.copper)
.buildRepairKit(consumer, modResource(armorRepairFolder + "travelers_copper_repair_kit"))
.save(consumer, modResource(armorRepairFolder + "travelers_copper_station"));
SpecializedRepairRecipeBuilder.repair(travelers, MaterialIds.leather)
SpecializedRepairRecipeBuilder.repair(Ingredient.of(TinkerTools.travelersGear.values().stream().map(ItemStack::new)), MaterialIds.leather)
.buildRepairKit(consumer, modResource(armorRepairFolder + "travelers_leather_repair_kit"))
.save(consumer, modResource(armorRepairFolder + "travelers_leather_station"));
SpecializedRepairRecipeBuilder.repair(Ingredient.of(TinkerTools.travelersShield), MaterialIds.wood)
.buildRepairKit(consumer, modResource(armorRepairFolder + "travelers_wood_repair_kit"))
.save(consumer, modResource(armorRepairFolder + "travelers_wood_station"));

// plate armor
ShapedRecipeBuilder.shaped(TinkerTools.plateArmor.get(ArmorSlotType.HELMET))
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/tconstruct/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@
"item.tconstruct.travelers_chestplate": "Traveler's Vest",
"item.tconstruct.travelers_leggings": "Traveler's Pants",
"item.tconstruct.travelers_boots": "Traveler's Boots",
"item.tconstruct.travelers_shield": "Traveler's Shield",

"item.tconstruct.plate_helmet": "Plate Helmet",
"item.tconstruct.plate_chestplate": "Plate Chestplate",
Expand Down

0 comments on commit 278d60d

Please sign in to comment.