Skip to content

Commit ef535e8

Browse files
authored
Merge pull request #2109
anointments can now be applied in the smithing table
2 parents f51edbd + 46082b2 commit ef535e8

File tree

5 files changed

+111
-2
lines changed

5 files changed

+111
-2
lines changed

src/main/java/wayoftime/bloodmagic/common/item/ItemAnointmentProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public class ItemAnointmentProvider extends Item
2727
// public Anointment anointment;
2828
public ResourceLocation anointRL;
2929
private int colour;
30-
private int level;
31-
private int maxDamage;
30+
public int level;
31+
public int maxDamage;
3232

3333
public ItemAnointmentProvider(ResourceLocation anointRL, int colour, int level, int maxDamage)
3434
{

src/main/java/wayoftime/bloodmagic/common/registries/BloodMagicRecipeSerializers.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ private BloodMagicRecipeSerializers()
5959

6060
public static final IRecipeSerializerRegistryObject<RecipeFilterCopy> FILTER_COPY = RECIPE_SERIALIZERS.register("filter_copy", () -> new SimpleCraftingRecipeSerializer<>(RecipeFilterCopy::new));
6161

62+
public static final IRecipeSerializerRegistryObject<RecipeAnointmentApply> ANOINTMENT_APPLY = RECIPE_SERIALIZERS.register("anointment_apply", RecipeAnointmentApply.Serializer::new);
63+
6264
// public static final DeferredRegister<IRecipeSerializer<?>> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, BloodMagic.MODID);
6365

6466
// public static final DeferredObject<RecipeBloodAltar> REC = RECIPE_SERIALIZERS.register("test", () -> new BloodAltarRecipeSerializer<>(IRecipeBloodAltar::new));
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package wayoftime.bloodmagic.recipe;
2+
3+
4+
import com.google.gson.JsonObject;
5+
import net.minecraft.core.RegistryAccess;
6+
import net.minecraft.network.FriendlyByteBuf;
7+
import net.minecraft.resources.ResourceLocation;
8+
import net.minecraft.util.GsonHelper;
9+
import net.minecraft.world.Container;
10+
import net.minecraft.world.item.ItemStack;
11+
import net.minecraft.world.item.crafting.*;
12+
import net.minecraft.world.level.Level;
13+
import wayoftime.bloodmagic.BloodMagic;
14+
import wayoftime.bloodmagic.anointment.AnointmentData;
15+
import wayoftime.bloodmagic.anointment.AnointmentHolder;
16+
import wayoftime.bloodmagic.common.item.ItemAnointmentProvider;
17+
import wayoftime.bloodmagic.common.item.ItemBowAnointmentProvider;
18+
import wayoftime.bloodmagic.core.AnointmentRegistrar;
19+
20+
public class RecipeAnointmentApply implements SmithingRecipe {
21+
@Override
22+
public boolean isTemplateIngredient(ItemStack stack) {
23+
return stack.getItem() instanceof ItemAnointmentProvider;
24+
}
25+
26+
@Override
27+
public boolean isBaseIngredient(ItemStack stack) {
28+
return ItemAnointmentProvider.isItemSword(stack)
29+
|| ItemAnointmentProvider.isItemTool(stack)
30+
|| ItemBowAnointmentProvider.isItemBow(stack)
31+
|| ItemBowAnointmentProvider.isItemCrossbow(stack);
32+
}
33+
34+
@Override
35+
public boolean isAdditionIngredient(ItemStack stack) {
36+
return false;
37+
}
38+
39+
@Override
40+
public boolean matches(Container container, Level level) {
41+
// 0 Template, 1 Base, 2 Extra
42+
ItemStack anointmentStack = container.getItem(0);
43+
ItemStack toolStack = container.getItem(1);
44+
if (anointmentStack.getItem() instanceof ItemAnointmentProvider toolProvider) {
45+
return toolProvider.isItemValidForApplication(toolStack);
46+
}
47+
48+
return false;
49+
}
50+
51+
@Override
52+
public ItemStack assemble(Container container, RegistryAccess registries) {
53+
// 0 Template, 1 Base, 2 Extra
54+
ItemAnointmentProvider anointmentStack = (ItemAnointmentProvider) container.getItem(0).getItem();
55+
ItemStack weaponStack = container.getItem(1).copy();
56+
57+
AnointmentHolder holder = AnointmentHolder.fromItemStack(weaponStack);
58+
if (holder == null)
59+
{
60+
holder = new AnointmentHolder();
61+
}
62+
63+
if (holder.applyAnointment(weaponStack, AnointmentRegistrar.ANOINTMENT_MAP.get(anointmentStack.anointRL), new AnointmentData(anointmentStack.level, 0, anointmentStack.maxDamage)))
64+
{
65+
holder.toItemStack(weaponStack);
66+
return weaponStack;
67+
}
68+
69+
return ItemStack.EMPTY;
70+
}
71+
72+
@Override
73+
public ItemStack getResultItem(RegistryAccess registries) {
74+
return ItemStack.EMPTY;
75+
}
76+
77+
@Override
78+
public ResourceLocation getId() {
79+
return BloodMagic.rl("anointment_apply");
80+
}
81+
82+
@Override
83+
public RecipeSerializer<?> getSerializer() {
84+
return null;
85+
}
86+
87+
public static class Serializer implements RecipeSerializer<RecipeAnointmentApply> {
88+
public RecipeAnointmentApply fromJson(ResourceLocation p_266953_, JsonObject p_266720_) {
89+
return new RecipeAnointmentApply();
90+
}
91+
92+
public RecipeAnointmentApply fromNetwork(ResourceLocation p_267117_, FriendlyByteBuf p_267316_) {
93+
return new RecipeAnointmentApply();
94+
}
95+
96+
@Override
97+
public void toNetwork(FriendlyByteBuf p_44101_, RecipeAnointmentApply p_44102_) {
98+
}
99+
}
100+
}

src/main/resources/assets/bloodmagic/patchouli_books/guide/en_us/entries/alchemy_table/anointments.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"heading": "Slate-infused Vial",
1313
"recipe": "bloodmagic:alchemytable/slate_vial",
1414
"text": "A sturdy Vial that can contain otherwise uncontainable mixtures."
15+
},
16+
{
17+
"type": "patchouli:text",
18+
"text": "Its also possible to apply an $(item)anointment$() to an applicable item using a smithing table. This is particularly useful for two-handed weapons or $(l:bloodmagic:alchemy_array/living_equipment/armour_downgrades/crippled_arm)other situations where you might find yourself not having enough hands$(). The $(item)anointment$() takes the role of a smithing template in this process."
1519
}
1620
]
1721
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "bloodmagic:anointment_apply"
3+
}

0 commit comments

Comments
 (0)