com.magistuarmory.item.crafting.HeraldryRecipe Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of 1.20.2-epic-knights-common Show documentation
Show all versions of 1.20.2-epic-knights-common Show documentation
mod that adds medieval stuff to the game
package com.magistuarmory.item.crafting;
import com.magistuarmory.EpicKnights;
import com.magistuarmory.item.ArmorDecorationItem;
import com.magistuarmory.item.MedievalShieldItem;
import com.magistuarmory.item.armor.ISurcoat;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.class_1304;
import net.minecraft.class_1738;
import net.minecraft.class_1746;
import net.minecraft.class_1747;
import net.minecraft.class_1767;
import net.minecraft.class_1792;
import net.minecraft.class_1799;
import net.minecraft.class_1852;
import net.minecraft.class_1865;
import net.minecraft.class_1866;
import net.minecraft.class_1937;
import net.minecraft.class_2487;
import net.minecraft.class_2561;
import net.minecraft.class_4059;
import net.minecraft.class_5455;
import net.minecraft.class_7710;
import net.minecraft.class_8566;
import net.minecraft.world.item.*;
import org.jetbrains.annotations.NotNull;
public class HeraldryRecipe extends class_1852
{
public static class_1865 SERIALIZER = new class_1866<>(HeraldryRecipe::new);
public HeraldryRecipe(class_7710 category)
{
super(category);
//super(location, CraftingBookCategory.MISC);
}
@Override
public boolean matches(class_8566 container, class_1937 level)
{
class_1799 stack = class_1799.field_8037;
class_1799 stack2 = class_1799.field_8037;
for(int i = 0; i < container.method_5439(); ++i)
{
class_1799 stack3 = container.method_5438(i);
if (!stack3.method_7960())
{
if (stack3.method_7909() instanceof class_1746)
{
if (!stack2.method_7960())
return false;
stack2 = stack3;
}
else
{
if (!isApplicableForBanner(stack3.method_7909()))
return false;
if (!stack.method_7960())
return false;
if (class_1747.method_38072(stack3) != null)
return false;
stack = stack3;
}
}
}
return !stack.method_7960() && !stack2.method_7960();
}
@Override
public class_1799 assemble(class_8566 container, @NotNull class_5455 access)
{
class_1799 stack = class_1799.field_8037;
class_1799 stack1 = class_1799.field_8037;
for(int i = 0; i < container.method_5439(); ++i)
{
class_1799 stack2 = container.method_5438(i);
if (!stack2.method_7960())
{
if (stack2.method_7909() instanceof class_1746)
{
stack = stack2;
}
else if (isApplicableForBanner(stack2.method_7909()))
{
stack1 = stack2.method_7972();
}
}
}
if (!stack1.method_7960())
{
class_2487 compoundtag = class_1747.method_38072(stack);
class_2487 compoundtag1 = compoundtag == null ? new class_2487() : compoundtag.method_10553();
class_1767 basecolor = ((class_1746) stack.method_7909()).method_7706();
compoundtag1.method_10569("Base", ((class_1746) stack.method_7909()).method_7706().method_7789());
if (wornWithSurcoat(stack1.method_7909()))
stack1.method_7977(class_2561.method_43469("magistuarmory.withsurcoat." + basecolor.method_7792(), stack1.method_7964().getString()));
else if (wornWithCaparison(stack1.method_7909()))
stack1.method_7977(class_2561.method_43469("magistuarmory.withcaparison." + basecolor.method_7792(), stack1.method_7964().getString()));
stack1.method_7959("BlockEntityTag", compoundtag1);
}
return stack1;
}
@Override
public boolean method_8113(int p_44298_, int p_44299_)
{
return p_44298_ * p_44299_ >= 2;
}
@Override
public @NotNull class_1865> method_8119()
{
return getSerializerInstance();
}
@ExpectPlatform
public static class_1865 getSerializerInstance()
{
throw new AssertionError();
}
static boolean isPaintableShield(class_1792 item)
{
return item instanceof MedievalShieldItem && ((MedievalShieldItem)item).isPaintable();
}
static boolean wornWithCaparison(class_1792 item)
{
return item instanceof class_4059;
}
static boolean wornWithSurcoat(class_1792 item)
{
return item instanceof class_1738 && (EpicKnights.GENERAL_CONFIG.enableSurcoatRecipeForAllArmor || item instanceof ISurcoat) && ((class_1738) item).method_48398().method_48399().equals(class_1304.field_6174);
}
static boolean isApplicableForBanner(class_1792 item)
{
return isPaintableShield(item) || wornWithCaparison(item) || wornWithSurcoat(item);
}
}