mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 09:59:20 +00:00
Trim通过测试
This commit is contained in:
@@ -402,7 +402,7 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
|
||||
public Item<ItemStack> applyTrim(Item<ItemStack> base, Item<ItemStack> addition, Item<ItemStack> template, Key pattern) {
|
||||
Optional<?> optionalMaterial = FastNMS.INSTANCE.method$TrimMaterials$getFromIngredient(addition.getLiteralObject());
|
||||
Optional<?> optionalPattern = VersionHelper.isOrAbove1_21_5() ?
|
||||
FastNMS.INSTANCE.method$Registry$getHolderByResourceLocation(FastNMS.INSTANCE.method$RegistryAccess$lookupOrThrow(FastNMS.INSTANCE.registryAccess(), MRegistries.TRIM_MATERIAL), KeyUtils.toResourceLocation(pattern)) :
|
||||
FastNMS.INSTANCE.method$Registry$getHolderByResourceLocation(FastNMS.INSTANCE.method$RegistryAccess$lookupOrThrow(FastNMS.INSTANCE.registryAccess(), MRegistries.TRIM_PATTERN), KeyUtils.toResourceLocation(pattern)) :
|
||||
FastNMS.INSTANCE.method$TrimPatterns$getFromTemplate(template.getLiteralObject());
|
||||
if (optionalMaterial.isPresent() && optionalPattern.isPresent()) {
|
||||
Object armorTrim = FastNMS.INSTANCE.constructor$ArmorTrim(optionalMaterial.get(), optionalPattern.get());
|
||||
@@ -427,12 +427,13 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
|
||||
newItem.setExactComponent(ComponentKeys.TRIM, armorTrim);
|
||||
} else {
|
||||
try {
|
||||
CoreReflections.method$ArmorTrim$setTrim.invoke(null, FastNMS.INSTANCE.registryAccess(), base.getLiteralObject(), armorTrim);
|
||||
CoreReflections.method$ArmorTrim$setTrim.invoke(null, FastNMS.INSTANCE.registryAccess(), newItem.getLiteralObject(), armorTrim);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
this.plugin.logger().warn("Failed to set armor trim", e);
|
||||
return this.emptyItem;
|
||||
}
|
||||
}
|
||||
return newItem;
|
||||
}
|
||||
return this.emptyItem;
|
||||
}
|
||||
|
||||
@@ -965,7 +965,7 @@ public class BukkitRecipeManager extends AbstractRecipeManager<ItemStack> {
|
||||
toMinecraftIngredient(recipe.template()),
|
||||
toMinecraftIngredient(recipe.base()),
|
||||
toMinecraftIngredient(recipe.addition()),
|
||||
FastNMS.INSTANCE.method$Registry$getHolderByResourceLocation(registry, KeyUtils.toResourceLocation(recipe.pattern()))
|
||||
FastNMS.INSTANCE.method$Registry$getHolderByResourceLocation(registry, KeyUtils.toResourceLocation(recipe.pattern())).orElseThrow(() -> new RuntimeException("Pattern " + recipe.pattern() + " doesn't exist."))
|
||||
);
|
||||
} else if (VersionHelper.isOrAbove1_21_2()) {
|
||||
return CoreReflections.constructor$SmithingTrimRecipe.newInstance(
|
||||
|
||||
@@ -2305,6 +2305,8 @@ public final class CoreReflections {
|
||||
public static final Constructor<?> constructor$SmithingTrimRecipe = requireNonNull(
|
||||
VersionHelper.isOrAbove1_21_5() ?
|
||||
ReflectionUtils.getConstructor(clazz$SmithingTrimRecipe, clazz$Ingredient, clazz$Ingredient, clazz$Ingredient, clazz$Holder) :
|
||||
VersionHelper.isOrAbove1_21_2() ?
|
||||
ReflectionUtils.getConstructor(clazz$SmithingTrimRecipe, Optional.class, Optional.class, Optional.class) :
|
||||
VersionHelper.isOrAbove1_20_2() ?
|
||||
ReflectionUtils.getConstructor(clazz$SmithingTrimRecipe, clazz$Ingredient, clazz$Ingredient, clazz$Ingredient) :
|
||||
ReflectionUtils.getConstructor(clazz$SmithingTrimRecipe, clazz$ResourceLocation, clazz$Ingredient, clazz$Ingredient, clazz$Ingredient)
|
||||
@@ -3787,7 +3789,7 @@ public final class CoreReflections {
|
||||
public static final Class<?> clazz$ArmorTrim = requireNonNull(
|
||||
ReflectionUtils.getClazz(
|
||||
VersionHelper.isOrAbove1_21_2() ?
|
||||
BukkitReflectionUtils.assembleCBClass("world.item.equipment.trim.ArmorTrim") :
|
||||
BukkitReflectionUtils.assembleMCClass("world.item.equipment.trim.ArmorTrim") :
|
||||
BukkitReflectionUtils.assembleMCClass("world.item.armortrim.ArmorTrim")
|
||||
)
|
||||
);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class CustomSmithingTrimRecipe<T> implements Recipe<T> {
|
||||
@Override
|
||||
public T assemble(RecipeInput input, ItemBuildContext context) {
|
||||
SmithingInput<T> smithingInput = (SmithingInput<T>) input;
|
||||
Item<T> processed = (Item<T>) CraftEngine.instance().itemManager().applyTrim((Item<Object>) smithingInput.base(), (Item<Object>) smithingInput.addition(), (Item<Object>) smithingInput.template(), this.pattern);
|
||||
Item<T> processed = (Item<T>) CraftEngine.instance().itemManager().applyTrim((Item<Object>) smithingInput.base().item(), (Item<Object>) smithingInput.addition().item(), (Item<Object>) smithingInput.template().item(), this.pattern);
|
||||
return processed.getItem();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user