Search in sources :

Example 11 with MaterialId

use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.

the class AdvancementsProvider method generate.

/**
 * Generates the advancements
 */
protected void generate() {
    // tinkering path
    Advancement materialsAndYou = builder(TinkerCommons.materialsAndYou, resource("tools/materials_and_you"), resource("textures/gui/advancement_background.png"), FrameType.TASK, builder -> builder.addCriterion("crafted_book", hasItem(TinkerCommons.materialsAndYou)));
    Advancement partBuilder = builder(TinkerTables.partBuilder, resource("tools/part_builder"), materialsAndYou, FrameType.TASK, builder -> builder.addCriterion("crafted_block", hasItem(TinkerTables.partBuilder)));
    builder(TinkerToolParts.pickHead.get().withMaterialForDisplay(MaterialIds.wood), resource("tools/make_part"), partBuilder, FrameType.TASK, builder -> builder.addCriterion("crafted_part", hasTag(TinkerTags.Items.TOOL_PARTS)));
    Advancement tinkerStation = builder(TinkerTables.tinkerStation, resource("tools/tinker_station"), partBuilder, FrameType.TASK, builder -> builder.addCriterion("crafted_block", hasItem(TinkerTables.tinkerStation)));
    Advancement tinkerTool = builder(TinkerTools.pickaxe.get().getRenderTool(), resource("tools/tinker_tool"), tinkerStation, FrameType.TASK, builder -> builder.addCriterion("crafted_tool", hasTag(TinkerTags.Items.MULTIPART_TOOL)));
    builder(TinkerMaterials.manyullyn.getIngot(), resource("tools/material_master"), tinkerTool, FrameType.CHALLENGE, builder -> {
        Consumer<MaterialId> with = id -> builder.addCriterion(id.getPath(), InventoryChangeTrigger.TriggerInstance.hasItems(ToolPredicate.builder().withMaterial(id).build()));
        // tier 1
        with.accept(MaterialIds.wood);
        with.accept(MaterialIds.flint);
        with.accept(MaterialIds.rock);
        with.accept(MaterialIds.bone);
        with.accept(MaterialIds.necroticBone);
        with.accept(MaterialIds.leather);
        with.accept(MaterialIds.string);
        with.accept(MaterialIds.vine);
        // tier 2
        with.accept(MaterialIds.iron);
        with.accept(MaterialIds.searedStone);
        with.accept(MaterialIds.scorchedStone);
        with.accept(MaterialIds.copper);
        with.accept(MaterialIds.slimewood);
        with.accept(MaterialIds.chain);
        with.accept(MaterialIds.skyslimeVine);
        // tier 3
        with.accept(MaterialIds.roseGold);
        with.accept(MaterialIds.slimesteel);
        with.accept(MaterialIds.nahuatl);
        with.accept(MaterialIds.bronze);
        with.accept(MaterialIds.pigIron);
        with.accept(MaterialIds.cobalt);
        // tier 4
        with.accept(MaterialIds.manyullyn);
        with.accept(MaterialIds.hepatizon);
        with.accept(MaterialIds.queensSlime);
        with.accept(MaterialIds.blazingBone);
        with.accept(MaterialIds.enderslimeVine);
    });
    builder(TinkerTools.travelersGear.get(ArmorSlotType.HELMET).getRenderTool(), resource("tools/travelers_gear"), tinkerStation, FrameType.TASK, builder -> TinkerTools.travelersGear.forEach((type, armor) -> builder.addCriterion("crafted_" + type.getSerializedName(), hasItem(armor))));
    builder(TinkerTools.pickaxe.get().getRenderTool(), resource("tools/tool_smith"), tinkerTool, FrameType.CHALLENGE, builder -> {
        Consumer<Item> with = item -> builder.addCriterion(Objects.requireNonNull(item.getRegistryName()).getPath(), hasItem(item));
        with.accept(TinkerTools.pickaxe.get());
        with.accept(TinkerTools.mattock.get());
        with.accept(TinkerTools.pickadze.get());
        with.accept(TinkerTools.handAxe.get());
        with.accept(TinkerTools.kama.get());
        with.accept(TinkerTools.dagger.get());
        with.accept(TinkerTools.sword.get());
    });
    Advancement modified = builder(Items.REDSTONE, resource("tools/modified"), tinkerTool, FrameType.TASK, builder -> builder.addCriterion("crafted_tool", InventoryChangeTrigger.TriggerInstance.hasItems(ToolPredicate.builder().hasUpgrades(true).build())));
    // builder(TinkerTools.cleaver.get().buildToolForRendering(), location("tools/glass_cannon"), modified, FrameType.CHALLENGE, builder ->
    // builder.addCriterion()("crafted_tool", InventoryChangeTrigger.TriggerInstance.hasItems(ToolPredicate.builder()
    // .withStat(StatPredicate.max(ToolStats.DURABILITY, 100))
    // .withStat(StatPredicate.min(ToolStats.ATTACK_DAMAGE, 20))
    // .build())));
    builder(Items.WRITABLE_BOOK, resource("tools/upgrade_slots"), modified, FrameType.CHALLENGE, builder -> builder.addCriterion("has_modified", InventoryChangeTrigger.TriggerInstance.hasItems(ToolPredicate.builder().upgrades(ModifierMatch.list(5, ModifierMatch.entry(TinkerModifiers.writable.get()), ModifierMatch.entry(TinkerModifiers.recapitated.get()), ModifierMatch.entry(TinkerModifiers.harmonious.get()), ModifierMatch.entry(TinkerModifiers.resurrected.get()), ModifierMatch.entry(TinkerModifiers.gilded.get()))).build())));
    // smeltery path
    Advancement punySmelting = builder(TinkerCommons.punySmelting, resource("smeltery/puny_smelting"), materialsAndYou, FrameType.TASK, builder -> builder.addCriterion("crafted_book", hasItem(TinkerCommons.punySmelting)));
    Advancement melter = builder(TinkerSmeltery.searedMelter, resource("smeltery/melter"), punySmelting, FrameType.TASK, builder -> {
        Consumer<Block> with = block -> builder.addCriterion(Objects.requireNonNull(block.getRegistryName()).getPath(), PlacedBlockTrigger.TriggerInstance.placedBlock(block));
        with.accept(TinkerSmeltery.searedMelter.get());
        with.accept(TinkerSmeltery.searedTable.get());
        with.accept(TinkerSmeltery.searedBasin.get());
        with.accept(TinkerSmeltery.searedFaucet.get());
        with.accept(TinkerSmeltery.searedHeater.get());
        TinkerSmeltery.searedTank.forEach(with);
        // first 4 are required, and then any of the last 5
        builder.requirements(new CountRequirementsStrategy(1, 1, 1, 1, 1 + TankType.values().length));
    });
    builder(TinkerSmeltery.toolHandleCast.getSand(), resource("smeltery/sand_casting"), melter, FrameType.TASK, builder -> builder.addCriterion("crafted_cast", hasTag(TinkerTags.Items.BLANK_SINGLE_USE_CASTS)));
    Advancement goldCasting = builder(TinkerSmeltery.pickHeadCast, resource("smeltery/gold_casting"), melter, FrameType.TASK, builder -> builder.addCriterion("crafted_cast", hasTag(TinkerTags.Items.GOLD_CASTS)));
    builder(TinkerSmeltery.hammerHeadCast, resource("smeltery/cast_collector"), goldCasting, FrameType.GOAL, builder -> {
        Consumer<CastItemObject> with = cast -> builder.addCriterion(cast.getName().getPath(), hasItem(cast.get()));
        with.accept(TinkerSmeltery.ingotCast);
        with.accept(TinkerSmeltery.nuggetCast);
        with.accept(TinkerSmeltery.gemCast);
        with.accept(TinkerSmeltery.rodCast);
        with.accept(TinkerSmeltery.repairKitCast);
        // parts
        with.accept(TinkerSmeltery.pickHeadCast);
        with.accept(TinkerSmeltery.smallAxeHeadCast);
        with.accept(TinkerSmeltery.smallBladeCast);
        with.accept(TinkerSmeltery.hammerHeadCast);
        with.accept(TinkerSmeltery.broadBladeCast);
        with.accept(TinkerSmeltery.broadAxeHeadCast);
        with.accept(TinkerSmeltery.toolBindingCast);
        with.accept(TinkerSmeltery.roundPlateCast);
        with.accept(TinkerSmeltery.largePlateCast);
        with.accept(TinkerSmeltery.toolHandleCast);
        with.accept(TinkerSmeltery.toughHandleCast);
    });
    Advancement mightySmelting = builder(TinkerCommons.mightySmelting, resource("smeltery/mighty_smelting"), melter, FrameType.TASK, builder -> builder.addCriterion("crafted_book", hasItem(TinkerCommons.mightySmelting)));
    Advancement smeltery = builder(TinkerSmeltery.smelteryController, resource("smeltery/structure"), mightySmelting, FrameType.TASK, builder -> builder.addCriterion("open_smeltery", BlockContainerOpenedTrigger.Instance.container(TinkerSmeltery.smeltery.get())));
    Advancement anvil = builder(TinkerTables.tinkersAnvil, resource("smeltery/tinkers_anvil"), smeltery, FrameType.GOAL, builder -> {
        builder.addCriterion("crafted_overworld", hasItem(TinkerTables.tinkersAnvil));
        builder.addCriterion("crafted_nether", hasItem(TinkerTables.scorchedAnvil));
        builder.requirements(RequirementsStrategy.OR);
    });
    builder(TinkerTools.veinHammer.get().getRenderTool(), resource("smeltery/tool_forge"), anvil, FrameType.CHALLENGE, builder -> {
        Consumer<Item> with = item -> builder.addCriterion(Objects.requireNonNull(item.getRegistryName()).getPath(), hasItem(item));
        with.accept(TinkerTools.sledgeHammer.get());
        with.accept(TinkerTools.veinHammer.get());
        with.accept(TinkerTools.excavator.get());
        with.accept(TinkerTools.broadAxe.get());
        with.accept(TinkerTools.scythe.get());
        with.accept(TinkerTools.cleaver.get());
    });
    builder(TinkerModifiers.silkyCloth, resource("smeltery/abilities"), anvil, FrameType.CHALLENGE, builder -> {
        Consumer<Supplier<? extends Modifier>> with = modifier -> builder.addCriterion(modifier.get().getId().getPath(), InventoryChangeTrigger.TriggerInstance.hasItems(ToolPredicate.builder().modifiers(ModifierMatch.entry(modifier.get())).build()));
        // general
        with.accept(TinkerModifiers.gilded);
        with.accept(TinkerModifiers.luck);
        with.accept(TinkerModifiers.reach);
        with.accept(TinkerModifiers.unbreakable);
        // armor
        with.accept(TinkerModifiers.aquaAffinity);
        with.accept(TinkerModifiers.bouncy);
        with.accept(TinkerModifiers.doubleJump);
        with.accept(TinkerModifiers.flamewake);
        with.accept(TinkerModifiers.frostWalker);
        with.accept(TinkerModifiers.looting);
        with.accept(TinkerModifiers.pathMaker);
        with.accept(TinkerModifiers.plowing);
        with.accept(TinkerModifiers.pockets);
        with.accept(TinkerModifiers.shieldStrap);
        with.accept(TinkerModifiers.slurping);
        with.accept(TinkerModifiers.snowdrift);
        with.accept(TinkerModifiers.strength);
        with.accept(TinkerModifiers.toolBelt);
        with.accept(TinkerModifiers.unarmed);
        with.accept(TinkerModifiers.zoom);
        // harvest
        with.accept(TinkerModifiers.autosmelt);
        with.accept(TinkerModifiers.exchanging);
        with.accept(TinkerModifiers.expanded);
        with.accept(TinkerModifiers.silky);
        // interact
        with.accept(TinkerModifiers.bucketing);
        with.accept(TinkerModifiers.firestarter);
        with.accept(TinkerModifiers.glowing);
        with.accept(TinkerModifiers.pathing);
        with.accept(TinkerModifiers.stripping);
        with.accept(TinkerModifiers.tilling);
        // weapon
        with.accept(TinkerModifiers.dualWielding);
        with.accept(TinkerModifiers.melting);
        with.accept(TinkerModifiers.spilling);
    });
    // foundry path
    Advancement fantasticFoundry = builder(TinkerCommons.fantasticFoundry, resource("foundry/fantastic_foundry"), materialsAndYou, FrameType.TASK, builder -> builder.addCriterion("crafted_book", hasItem(TinkerCommons.fantasticFoundry)));
    builder(TinkerCommons.encyclopedia, resource("foundry/encyclopedia"), fantasticFoundry, FrameType.GOAL, builder -> builder.addCriterion("crafted_book", hasItem(TinkerCommons.encyclopedia)));
    Advancement alloyer = builder(TinkerSmeltery.scorchedAlloyer, resource("foundry/alloyer"), fantasticFoundry, FrameType.TASK, builder -> {
        Consumer<Block> with = block -> builder.addCriterion(Objects.requireNonNull(block.getRegistryName()).getPath(), PlacedBlockTrigger.TriggerInstance.placedBlock(block));
        with.accept(TinkerSmeltery.scorchedAlloyer.get());
        with.accept(TinkerSmeltery.scorchedFaucet.get());
        with.accept(TinkerSmeltery.scorchedTable.get());
        with.accept(TinkerSmeltery.scorchedBasin.get());
        for (TankType type : TankType.values()) {
            with.accept(TinkerSmeltery.scorchedTank.get(type));
        }
        builder.requirements(new CountRequirementsStrategy(1, 1, 1, 1, 2, 2));
    });
    Advancement foundry = builder(TinkerSmeltery.foundryController, resource("foundry/structure"), alloyer, FrameType.TASK, builder -> builder.addCriterion("open_foundry", BlockContainerOpenedTrigger.Instance.container(TinkerSmeltery.foundry.get())));
    Advancement blazingBlood = builder(TankItem.setTank(new ItemStack(TinkerSmeltery.scorchedTank.get(TankType.FUEL_GAUGE)), getTankWith(TinkerFluids.blazingBlood.get(), TankType.FUEL_GAUGE.getCapacity())), resource("foundry/blaze"), foundry, FrameType.GOAL, builder -> {
        Consumer<SearedTankBlock> with = block -> {
            CompoundTag nbt = new CompoundTag();
            nbt.put(NBTTags.TANK, getTankWith(TinkerFluids.blazingBlood.get(), block.getCapacity()).writeToNBT(new CompoundTag()));
            builder.addCriterion(Objects.requireNonNull(block.getRegistryName()).getPath(), InventoryChangeTrigger.TriggerInstance.hasItems(ItemPredicate.Builder.item().of(block).hasNbt(nbt).build()));
            builder.requirements(RequirementsStrategy.OR);
        };
        TinkerSmeltery.searedTank.forEach(with);
        TinkerSmeltery.scorchedTank.forEach(with);
    });
    builder(TinkerTools.plateArmor.get(ArmorSlotType.CHESTPLATE).getRenderTool(), resource("foundry/plate_armor"), blazingBlood, FrameType.GOAL, builder -> TinkerTools.plateArmor.forEach((type, armor) -> builder.addCriterion("crafted_" + type.getSerializedName(), hasItem(armor))));
    builder(TankItem.setTank(new ItemStack(TinkerSmeltery.scorchedLantern), getTankWith(TinkerFluids.moltenManyullyn.get(), TinkerSmeltery.scorchedLantern.get().getCapacity())), resource("foundry/manyullyn_lanterns"), foundry, FrameType.CHALLENGE, builder -> {
        Consumer<SearedLanternBlock> with = block -> {
            CompoundTag nbt = new CompoundTag();
            nbt.put(NBTTags.TANK, getTankWith(TinkerFluids.moltenManyullyn.get(), block.getCapacity()).writeToNBT(new CompoundTag()));
            builder.addCriterion(Objects.requireNonNull(block.getRegistryName()).getPath(), InventoryChangeTrigger.TriggerInstance.hasItems(new ItemPredicate(null, Collections.singleton(block.asItem()), MinMaxBounds.Ints.atLeast(64), MinMaxBounds.Ints.ANY, EnchantmentPredicate.NONE, EnchantmentPredicate.NONE, null, new NbtPredicate(nbt))));
            builder.requirements(RequirementsStrategy.OR);
        };
        with.accept(TinkerSmeltery.searedLantern.get());
        with.accept(TinkerSmeltery.scorchedLantern.get());
    });
    // exploration path
    Advancement tinkersGadgetry = builder(TinkerCommons.tinkersGadgetry, resource("world/tinkers_gadgetry"), materialsAndYou, FrameType.TASK, builder -> builder.addCriterion("crafted_book", hasItem(TinkerCommons.tinkersGadgetry)));
    builder(TinkerWorld.slimeSapling.get(SlimeType.EARTH), resource("world/earth_island"), tinkersGadgetry, FrameType.GOAL, builder -> builder.addCriterion("found_island", LocationTrigger.TriggerInstance.located(LocationPredicate.inFeature(TinkerStructures.earthSlimeIsland.get()))));
    builder(TinkerWorld.slimeSapling.get(SlimeType.SKY), resource("world/sky_island"), tinkersGadgetry, FrameType.GOAL, builder -> builder.addCriterion("found_island", LocationTrigger.TriggerInstance.located(LocationPredicate.inFeature(TinkerStructures.skySlimeIsland.get()))));
    builder(TinkerWorld.slimeSapling.get(SlimeType.BLOOD), resource("world/blood_island"), tinkersGadgetry, FrameType.GOAL, builder -> builder.addCriterion("found_island", LocationTrigger.TriggerInstance.located(LocationPredicate.inFeature(TinkerStructures.bloodIsland.get()))));
    Advancement enderslimeIsland = builder(TinkerWorld.slimeSapling.get(SlimeType.ENDER), resource("world/ender_island"), tinkersGadgetry, FrameType.GOAL, builder -> builder.addCriterion("found_island", LocationTrigger.TriggerInstance.located(LocationPredicate.inFeature(TinkerStructures.endSlimeIsland.get()))));
    builder(Items.CLAY_BALL, resource("world/clay_island"), tinkersGadgetry, FrameType.GOAL, builder -> builder.addCriterion("found_island", LocationTrigger.TriggerInstance.located(LocationPredicate.inFeature(TinkerStructures.clayIsland.get()))));
    Advancement slimes = builder(TinkerCommons.slimeball.get(SlimeType.ICHOR), resource("world/slime_collector"), tinkersGadgetry, FrameType.TASK, builder -> {
        for (SlimeType type : SlimeType.values()) {
            builder.addCriterion(type.getSerializedName(), hasTag(type.getSlimeballTag()));
        }
        builder.addCriterion("magma_cream", hasItem(Items.MAGMA_CREAM));
    });
    builder(TinkerGadgets.slimeSling.get(SlimeType.ENDER), resource("world/slime_sling"), slimes, FrameType.CHALLENGE, builder -> {
        JsonObject boundJSON = new JsonObject();
        boundJSON.addProperty("max", 150);
        MinMaxBounds.Ints mojangDeletedTheMaxMethods = MinMaxBounds.Ints.fromJson(boundJSON);
        TinkerGadgets.slimeSling.forEach((type, sling) -> builder.addCriterion(type.getSerializedName(), ItemDurabilityTrigger.TriggerInstance.changedDurability(EntityPredicate.Composite.ANY, ItemPredicate.Builder.item().of(sling).build(), mojangDeletedTheMaxMethods)));
    });
    builder(TinkerGadgets.piggyBackpack, resource("world/piggybackpack"), tinkersGadgetry, FrameType.GOAL, builder -> builder.addCriterion("used_pack", PlayerInteractTrigger.TriggerInstance.itemUsedOnEntity(EntityPredicate.Composite.ANY, ItemPredicate.Builder.item().of(TinkerGadgets.piggyBackpack), EntityPredicate.Composite.wrap(EntityPredicate.Builder.entity().of(EntityType.PIG).build()))));
    Advancement slimesuit = builder(TinkerTools.slimesuit.get(ArmorSlotType.CHESTPLATE).getRenderTool(), resource("world/slimesuit"), enderslimeIsland, FrameType.GOAL, builder -> TinkerTools.slimesuit.forEach((type, armor) -> builder.addCriterion("crafted_" + type.getSerializedName(), hasItem(armor))));
    builder(new MaterialIdNBT(Collections.singletonList(MaterialIds.gunpowder)).updateStack(new ItemStack(TinkerTools.slimesuit.get(ArmorSlotType.HELMET))), resource("world/slimeskull"), slimesuit, FrameType.CHALLENGE, builder -> {
        Item helmet = TinkerTools.slimesuit.get(ArmorSlotType.HELMET);
        Consumer<MaterialId> with = mat -> builder.addCriterion(mat.getPath(), InventoryChangeTrigger.TriggerInstance.hasItems(ToolPredicate.builder(helmet).withMaterial(mat).build()));
        with.accept(MaterialIds.gunpowder);
        with.accept(MaterialIds.bone);
        with.accept(MaterialIds.necroticBone);
        with.accept(MaterialIds.rottenFlesh);
        with.accept(MaterialIds.enderPearl);
        with.accept(MaterialIds.bloodbone);
        with.accept(MaterialIds.spider);
        with.accept(MaterialIds.venom);
        with.accept(MaterialIds.iron);
        with.accept(MaterialIds.copper);
        with.accept(MaterialIds.blazingBone);
        with.accept(MaterialIds.gold);
        with.accept(MaterialIds.roseGold);
        with.accept(MaterialIds.pigIron);
    });
    // internal advancements
    hiddenBuilder(resource("internal/starting_book"), ConfigEnabledCondition.SPAWN_WITH_BOOK, builder -> {
        builder.addCriterion("tick", new TickTrigger.TriggerInstance(EntityPredicate.Composite.ANY));
        builder.rewards(AdvancementRewards.Builder.loot(TConstruct.getResource("gameplay/starting_book")));
    });
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) JsonObject(com.google.gson.JsonObject) InventoryChangeTrigger(net.minecraft.advancements.critereon.InventoryChangeTrigger) Items(net.minecraft.world.item.Items) ItemDurabilityTrigger(net.minecraft.advancements.critereon.ItemDurabilityTrigger) Item(net.minecraft.world.item.Item) ICondition(net.minecraftforge.common.crafting.conditions.ICondition) FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) MaterialIds(slimeknights.tconstruct.tools.data.material.MaterialIds) TinkerWorld(slimeknights.tconstruct.world.TinkerWorld) CastItemObject(slimeknights.tconstruct.common.registration.CastItemObject) ArmorSlotType(slimeknights.tconstruct.tools.item.ArmorSlotType) PlacedBlockTrigger(net.minecraft.advancements.critereon.PlacedBlockTrigger) TinkerGadgets(slimeknights.tconstruct.gadgets.TinkerGadgets) ItemPredicate(net.minecraft.advancements.critereon.ItemPredicate) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) TankType(slimeknights.tconstruct.smeltery.block.component.SearedTankBlock.TankType) RequirementsStrategy(net.minecraft.advancements.RequirementsStrategy) TinkerTables(slimeknights.tconstruct.tables.TinkerTables) SlimeType(slimeknights.tconstruct.shared.block.SlimeType) TinkerTags(slimeknights.tconstruct.common.TinkerTags) ModifierMatch(slimeknights.tconstruct.library.recipe.modifiers.ModifierMatch) EntityPredicate(net.minecraft.advancements.critereon.EntityPredicate) Set(java.util.Set) TinkerTools(slimeknights.tconstruct.tools.TinkerTools) BlockContainerOpenedTrigger(slimeknights.tconstruct.shared.inventory.BlockContainerOpenedTrigger) Sets(com.google.common.collect.Sets) ConfigEnabledCondition(slimeknights.tconstruct.common.json.ConfigEnabledCondition) Objects(java.util.Objects) EnchantmentPredicate(net.minecraft.advancements.critereon.EnchantmentPredicate) CompoundTag(net.minecraft.nbt.CompoundTag) CriterionTriggerInstance(net.minecraft.advancements.CriterionTriggerInstance) TinkerStructures(slimeknights.tconstruct.world.TinkerStructures) Modifier(slimeknights.tconstruct.library.modifiers.Modifier) MinMaxBounds(net.minecraft.advancements.critereon.MinMaxBounds) FluidStack(net.minecraftforge.fluids.FluidStack) ItemStack(net.minecraft.world.item.ItemStack) MaterialIdNBT(slimeknights.tconstruct.library.tools.nbt.MaterialIdNBT) ConditionalAdvancement(net.minecraftforge.common.crafting.ConditionalAdvancement) EntityType(net.minecraft.world.entity.EntityType) FluidAction(net.minecraftforge.fluids.capability.IFluidHandler.FluidAction) TinkerModifiers(slimeknights.tconstruct.tools.TinkerModifiers) TankItem(slimeknights.tconstruct.smeltery.item.TankItem) Supplier(java.util.function.Supplier) FrameType(net.minecraft.advancements.FrameType) LocationTrigger(net.minecraft.advancements.critereon.LocationTrigger) SearedLanternBlock(slimeknights.tconstruct.smeltery.block.SearedLanternBlock) PlayerInteractTrigger(net.minecraft.advancements.critereon.PlayerInteractTrigger) ItemLike(net.minecraft.world.level.ItemLike) TinkerToolParts(slimeknights.tconstruct.tools.TinkerToolParts) GenericDataProvider(slimeknights.mantle.data.GenericDataProvider) BiConsumer(java.util.function.BiConsumer) Fluid(net.minecraft.world.level.material.Fluid) TinkerMaterials(slimeknights.tconstruct.shared.TinkerMaterials) DataGenerator(net.minecraft.data.DataGenerator) TinkerCommons(slimeknights.tconstruct.shared.TinkerCommons) Nullable(javax.annotation.Nullable) AdvancementRewards(net.minecraft.advancements.AdvancementRewards) TinkerFluids(slimeknights.tconstruct.fluids.TinkerFluids) NbtPredicate(net.minecraft.advancements.critereon.NbtPredicate) TickTrigger(net.minecraft.advancements.critereon.TickTrigger) NBTTags(slimeknights.tconstruct.library.utils.NBTTags) HashCache(net.minecraft.data.HashCache) Advancement(net.minecraft.advancements.Advancement) Tag(net.minecraft.tags.Tag) TConstruct(slimeknights.tconstruct.TConstruct) Consumer(java.util.function.Consumer) TinkerSmeltery(slimeknights.tconstruct.smeltery.TinkerSmeltery) MaterialId(slimeknights.tconstruct.library.materials.definition.MaterialId) LocationPredicate(net.minecraft.advancements.critereon.LocationPredicate) Block(net.minecraft.world.level.block.Block) SearedTankBlock(slimeknights.tconstruct.smeltery.block.component.SearedTankBlock) ToolPredicate(slimeknights.tconstruct.library.tools.ToolPredicate) Collections(java.util.Collections) TankType(slimeknights.tconstruct.smeltery.block.component.SearedTankBlock.TankType) JsonObject(com.google.gson.JsonObject) SearedTankBlock(slimeknights.tconstruct.smeltery.block.component.SearedTankBlock) Item(net.minecraft.world.item.Item) TankItem(slimeknights.tconstruct.smeltery.item.TankItem) SlimeType(slimeknights.tconstruct.shared.block.SlimeType) Supplier(java.util.function.Supplier) Modifier(slimeknights.tconstruct.library.modifiers.Modifier) CompoundTag(net.minecraft.nbt.CompoundTag) SearedLanternBlock(slimeknights.tconstruct.smeltery.block.SearedLanternBlock) MaterialId(slimeknights.tconstruct.library.materials.definition.MaterialId) CastItemObject(slimeknights.tconstruct.common.registration.CastItemObject) ItemPredicate(net.minecraft.advancements.critereon.ItemPredicate) TickTrigger(net.minecraft.advancements.critereon.TickTrigger) MinMaxBounds(net.minecraft.advancements.critereon.MinMaxBounds) SearedLanternBlock(slimeknights.tconstruct.smeltery.block.SearedLanternBlock) Block(net.minecraft.world.level.block.Block) SearedTankBlock(slimeknights.tconstruct.smeltery.block.component.SearedTankBlock) NbtPredicate(net.minecraft.advancements.critereon.NbtPredicate) ItemStack(net.minecraft.world.item.ItemStack) MaterialIdNBT(slimeknights.tconstruct.library.tools.nbt.MaterialIdNBT) ConditionalAdvancement(net.minecraftforge.common.crafting.ConditionalAdvancement) Advancement(net.minecraft.advancements.Advancement)

Example 12 with MaterialId

use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.

the class PartBuilderScreen method setDisplayForMaterial.

/**
 * Updates the data in the material display
 * @param materialRecipe  New material recipe
 */
private void setDisplayForMaterial(MaterialRecipe materialRecipe) {
    MaterialVariant materialVariant = materialRecipe.getMaterial();
    this.infoPanelScreen.setCaption(MaterialTooltipCache.getColoredDisplayName(materialVariant.getVariant()));
    // determine how much material we have
    // get exact number of material, rather than rounded
    float value = materialRecipe.getMaterialValue(this.tile.getInventoryWrapper());
    MutableComponent formatted = new TextComponent(Util.COMMA_FORMAT.format(value));
    // if we have a part recipe, mark material red when not enough
    IPartBuilderRecipe partRecipe = this.tile.getPartRecipe();
    if (partRecipe != null && value < partRecipe.getCost()) {
        formatted = formatted.withStyle(ChatFormatting.DARK_RED);
    }
    this.infoPanelScreen.setMaterialValue(formatted);
    // update stats and traits
    List<Component> stats = Lists.newLinkedList();
    List<Component> tips = Lists.newArrayList();
    // add warning that the material is uncraftable
    if (!materialVariant.get().isCraftable()) {
        stats.add(UNCRAFTABLE_MATERIAL);
        stats.add(TextComponent.EMPTY);
        tips.add(UNCRAFTABLE_MATERIAL_TOOLTIP);
        tips.add(TextComponent.EMPTY);
    }
    MaterialId id = materialVariant.getId();
    for (IMaterialStats stat : MaterialRegistry.getInstance().getAllStats(id)) {
        List<Component> info = stat.getLocalizedInfo();
        if (!info.isEmpty()) {
            stats.add(stat.getLocalizedName().withStyle(ChatFormatting.UNDERLINE));
            tips.add(TextComponent.EMPTY);
            stats.addAll(info);
            tips.addAll(stat.getLocalizedDescriptions());
            List<ModifierEntry> traits = MaterialRegistry.getInstance().getTraits(id, stat.getIdentifier());
            if (!traits.isEmpty()) {
                for (ModifierEntry trait : traits) {
                    Modifier mod = trait.getModifier();
                    stats.add(mod.getDisplayName(trait.getLevel()));
                    tips.add(mod.getDescription(trait.getLevel()));
                }
            }
            stats.add(TextComponent.EMPTY);
            tips.add(TextComponent.EMPTY);
        }
    }
    // remove last line if empty
    if (!stats.isEmpty() && stats.get(stats.size() - 1).getString().isEmpty()) {
        stats.remove(stats.size() - 1);
        tips.remove(tips.size() - 1);
    }
    this.infoPanelScreen.setText(stats, tips);
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) IPartBuilderRecipe(slimeknights.tconstruct.library.recipe.partbuilder.IPartBuilderRecipe) MaterialId(slimeknights.tconstruct.library.materials.definition.MaterialId) MutableComponent(net.minecraft.network.chat.MutableComponent) MaterialVariant(slimeknights.tconstruct.library.materials.definition.MaterialVariant) IMaterialStats(slimeknights.tconstruct.library.materials.stats.IMaterialStats) ModifierEntry(slimeknights.tconstruct.library.modifiers.ModifierEntry) MutableComponent(net.minecraft.network.chat.MutableComponent) Component(net.minecraft.network.chat.Component) TextComponent(net.minecraft.network.chat.TextComponent) Modifier(slimeknights.tconstruct.library.modifiers.Modifier)

Example 13 with MaterialId

use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.

the class MaterialMeltingRecipe method getRecipes.

@Override
public List<MeltingRecipe> getRecipes() {
    if (multiRecipes == null) {
        if (input.get().isHidden()) {
            multiRecipes = Collections.emptyList();
        } else {
            // 1 recipe for each part
            MaterialId inputId = input.getId();
            multiRecipes = MaterialCastingLookup.getAllItemCosts().stream().filter(entry -> entry.getKey().canUseMaterial(inputId)).map(entry -> {
                FluidStack output = this.result;
                if (entry.getIntValue() != 1) {
                    output = new FluidStack(output, output.getAmount() * entry.getIntValue());
                }
                return new MeltingRecipe(id, "", MaterialIngredient.fromItem(entry.getKey(), inputId), output, temperature, IMeltingRecipe.calcTimeForAmount(temperature, output.getAmount()), Collections.emptyList());
            }).collect(Collectors.toList());
        }
    }
    return multiRecipes;
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) JsonObject(com.google.gson.JsonObject) LoggingRecipeSerializer(slimeknights.mantle.recipe.helper.LoggingRecipeSerializer) Getter(lombok.Getter) RecipeSerializer(net.minecraft.world.item.crafting.RecipeSerializer) MaterialVariant(slimeknights.tconstruct.library.materials.definition.MaterialVariant) RecipeHelper(slimeknights.mantle.recipe.helper.RecipeHelper) FriendlyByteBuf(net.minecraft.network.FriendlyByteBuf) MaterialVariantId(slimeknights.tconstruct.library.materials.definition.MaterialVariantId) Collectors(java.util.stream.Collectors) IMultiRecipe(slimeknights.mantle.recipe.IMultiRecipe) MaterialIngredient(slimeknights.tconstruct.library.recipe.ingredient.MaterialIngredient) TinkerSmeltery(slimeknights.tconstruct.smeltery.TinkerSmeltery) List(java.util.List) MaterialId(slimeknights.tconstruct.library.materials.definition.MaterialId) MaterialCastingLookup(slimeknights.tconstruct.library.recipe.casting.material.MaterialCastingLookup) GsonHelper(net.minecraft.util.GsonHelper) FluidStack(net.minecraftforge.fluids.FluidStack) ItemStack(net.minecraft.world.item.ItemStack) Level(net.minecraft.world.level.Level) Collections(java.util.Collections) Nullable(javax.annotation.Nullable) MaterialId(slimeknights.tconstruct.library.materials.definition.MaterialId) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 14 with MaterialId

use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.

the class MaterialDataProvider method addMaterials.

@Override
protected void addMaterials() {
    // tier 1
    addMaterial(MaterialIds.wood, 1, ORDER_GENERAL, true);
    addMaterial(MaterialIds.rock, 1, ORDER_HARVEST, true);
    addMaterial(MaterialIds.flint, 1, ORDER_WEAPON, true);
    addMaterial(MaterialIds.copper, 1, ORDER_SPECIAL, true);
    addMaterial(MaterialIds.bone, 1, ORDER_SPECIAL, true);
    // tier 1 - binding
    addMaterial(MaterialIds.string, 1, ORDER_BINDING, true);
    addMaterial(MaterialIds.leather, 1, ORDER_BINDING, true);
    addMaterial(MaterialIds.vine, 1, ORDER_BINDING, true);
    // tier 2
    addMaterial(MaterialIds.iron, 2, ORDER_GENERAL, false);
    addMaterial(MaterialIds.searedStone, 2, ORDER_HARVEST, false);
    addMaterial(MaterialIds.bloodbone, 2, ORDER_WEAPON, false);
    addMaterial(MaterialIds.slimewood, 2, ORDER_SPECIAL, true);
    // tier 2 - nether
    addMaterial(MaterialIds.scorchedStone, 2, ORDER_NETHER, false);
    addMaterial(MaterialIds.necroticBone, 2, ORDER_NETHER, true);
    // tier 2 - binding
    addMaterial(MaterialIds.chain, 2, ORDER_BINDING, true);
    addMaterial(MaterialIds.skyslimeVine, 2, ORDER_BINDING, true);
    // tier 3
    addMaterial(MaterialIds.slimesteel, 3, ORDER_GENERAL, false);
    addMaterial(MaterialIds.amethystBronze, 3, ORDER_HARVEST, false);
    addMaterial(MaterialIds.nahuatl, 3, ORDER_WEAPON, false);
    addMaterial(MaterialIds.roseGold, 3, ORDER_SPECIAL, false);
    addMaterial(MaterialIds.pigIron, 3, ORDER_SPECIAL, false);
    // tier 3 (nether)
    addMaterial(MaterialIds.cobalt, 3, ORDER_NETHER, false);
    // tier 4
    addMaterial(MaterialIds.queensSlime, 4, ORDER_GENERAL, false);
    addMaterial(MaterialIds.hepatizon, 4, ORDER_HARVEST, false);
    addMaterial(MaterialIds.manyullyn, 4, ORDER_WEAPON, false);
    addMaterial(MaterialIds.blazingBone, 4, ORDER_SPECIAL, false);
    // addMetalMaterial(MaterialIds.soulsteel, 4, ORDER_SPECIAL, false, 0x6a5244);
    // tier 5 binding, temporarily in book 4
    addMaterial(MaterialIds.enderslimeVine, 4, ORDER_BINDING, true);
    // tier 2 (end)
    // addMaterialNoFluid(MaterialIds.endstone, 2, ORDER_END, true, 0xe0d890);
    // tier 2 (mod integration)
    addCompatMetalMaterial(MaterialIds.osmium, 2, ORDER_COMPAT + ORDER_GENERAL);
    addCompatMetalMaterial(MaterialIds.tungsten, 2, ORDER_COMPAT + ORDER_HARVEST);
    addCompatMetalMaterial(MaterialIds.platinum, 2, ORDER_COMPAT + ORDER_HARVEST);
    addCompatMetalMaterial(MaterialIds.silver, 2, ORDER_COMPAT + ORDER_WEAPON);
    addCompatMetalMaterial(MaterialIds.lead, 2, ORDER_COMPAT + ORDER_WEAPON);
    ICondition condition = new OrCondition(ConfigEnabledCondition.FORCE_INTEGRATION_MATERIALS, tagExistsCondition("ingots/aluminum"), tagExistsCondition("ingots/tin"), tagExistsCondition("ingots/zinc"));
    addMaterial(MaterialIds.whitestone, 2, ORDER_COMPAT + ORDER_SPECIAL, false, false, condition);
    // tier 3 (mod integration)
    addCompatMetalMaterial(MaterialIds.steel, 3, ORDER_COMPAT + ORDER_GENERAL);
    addCompatMetalMaterial(MaterialIds.bronze, 3, ORDER_COMPAT + ORDER_HARVEST);
    addCompatMetalMaterial(MaterialIds.constantan, 3, ORDER_COMPAT + ORDER_HARVEST);
    addCompatMetalMaterial(MaterialIds.invar, 3, ORDER_COMPAT + ORDER_WEAPON);
    addCompatMetalMaterial(MaterialIds.necronium, 3, ORDER_COMPAT + ORDER_WEAPON, "uranium");
    addCompatMetalMaterial(MaterialIds.electrum, 3, ORDER_COMPAT + ORDER_SPECIAL);
    addCompatMetalMaterial(MaterialIds.platedSlimewood, 3, ORDER_COMPAT + ORDER_SPECIAL, "brass");
    // plate
    addMaterial(MaterialIds.netherite, 6, 9, false);
    addCompatMetalMaterial(MaterialIds.aluminum, 6, 9);
    addCompatMetalMaterial(MaterialIds.nickel, 6, 9);
    addCompatMetalMaterial(MaterialIds.tin, 6, 9);
    addCompatMetalMaterial(MaterialIds.zinc, 6, 9);
    addCompatMetalMaterial(MaterialIds.brass, 6, 9);
    addCompatMetalMaterial(MaterialIds.uranium, 6, 9);
    // slimeskull - marked tier 6 to push to tne end of repair kits
    addMaterial(MaterialIds.gold, 6, 0, false);
    addMaterial(MaterialIds.gunpowder, 6, 1, true);
    addMaterial(MaterialIds.rottenFlesh, 6, 2, true);
    addMaterial(MaterialIds.spider, 6, 4, true);
    addMaterial(MaterialIds.venom, 6, 5, true);
    addMaterial(MaterialIds.enderPearl, 6, 6, true);
    // slimesuit - textures
    addMaterial(MaterialIds.earthslime, 6, 9, true);
    addMaterial(MaterialIds.skyslime, 6, 9, true);
    addMaterial(MaterialIds.blood, 6, 9, true);
    addMaterial(MaterialIds.ichor, 6, 9, true);
    addMaterial(MaterialIds.enderslime, 6, 9, true);
    // slimesuit - repair
    addMaterial(MaterialIds.phantom, 6, 9, true);
    addMaterial(MaterialIds.chorus, 6, 9, true);
    addMaterial(MaterialIds.rabbit, 6, 9, true);
    // legacy
    addRedirect(new MaterialId(TConstruct.MOD_ID, "stone"), redirect(MaterialIds.rock));
    addRedirect(new MaterialId(TConstruct.MOD_ID, "tinkers_bronze"), redirect(MaterialIds.bronze));
}
Also used : MaterialId(slimeknights.tconstruct.library.materials.definition.MaterialId) OrCondition(net.minecraftforge.common.crafting.conditions.OrCondition) ICondition(net.minecraftforge.common.crafting.conditions.ICondition)

Example 15 with MaterialId

use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.

the class TinkerStationRepairRecipe method matches.

@Override
public boolean matches(ITinkerStationContainer inv, Level world) {
    // must be repairable
    ItemStack tinkerable = inv.getTinkerableStack();
    // if its not multipart, different recipe will be used to repair it (as it has a dedicated repair item)
    if (tinkerable.isEmpty() || !TinkerTags.Items.MULTIPART_TOOL.contains(tinkerable.getItem()) || !TinkerTags.Items.DURABILITY.contains(tinkerable.getItem())) {
        return false;
    }
    // validate materials
    MaterialId material = null;
    ToolStack tool = ToolStack.from(tinkerable);
    // not sure why you are tagging a tool with no parts as multipart, you are wrong and should feel ashamed of yourself
    if (!tool.getDefinition().isMultipart()) {
        return false;
    }
    for (int i = 0; i < inv.getInputCount(); i++) {
        // skip empty slots
        ItemStack stack = inv.getInput(i);
        if (stack.isEmpty()) {
            continue;
        }
        // ensure we have a material
        MaterialId inputMaterial = getMaterialFrom(inv, i);
        if (inputMaterial.equals(IMaterial.UNKNOWN_ID)) {
            return false;
        }
        // on first match, store and validate the material. For later matches, just ensure material matches
        if (material == null) {
            material = inputMaterial;
            if (getRepairIndex(tool, material) < 0) {
                return false;
            }
        } else if (!material.equals(inputMaterial)) {
            return false;
        }
    }
    // must have a material (will only be null if all slots were empty at this point)
    return material != null;
}
Also used : MaterialId(slimeknights.tconstruct.library.materials.definition.MaterialId) ItemStack(net.minecraft.world.item.ItemStack) ToolStack(slimeknights.tconstruct.library.tools.nbt.ToolStack)

Aggregations

MaterialId (slimeknights.tconstruct.library.materials.definition.MaterialId)41 Test (org.junit.jupiter.api.Test)11 BaseMcTest (slimeknights.tconstruct.test.BaseMcTest)11 Nullable (javax.annotation.Nullable)9 ModifierEntry (slimeknights.tconstruct.library.modifiers.ModifierEntry)9 ResourceLocation (net.minecraft.resources.ResourceLocation)8 ItemStack (net.minecraft.world.item.ItemStack)7 Collections (java.util.Collections)6 List (java.util.List)6 IMaterial (slimeknights.tconstruct.library.materials.definition.IMaterial)6 ToolStack (slimeknights.tconstruct.library.tools.nbt.ToolStack)6 Collectors (java.util.stream.Collectors)5 MaterialVariantId (slimeknights.tconstruct.library.materials.definition.MaterialVariantId)5 JsonObject (com.google.gson.JsonObject)4 JsonSyntaxException (com.google.gson.JsonSyntaxException)4 TConstruct (slimeknights.tconstruct.TConstruct)4 MaterialStatsId (slimeknights.tconstruct.library.materials.stats.MaterialStatsId)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 JsonElement (com.google.gson.JsonElement)3 Function (java.util.function.Function)3