mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
修复锻造配方后处理器如果保留custom_data组件会写入错误的自定义物品ID的问题
This commit is contained in:
@@ -19,10 +19,7 @@ import net.momirealms.craftengine.core.util.*;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@@ -158,6 +155,7 @@ public class CustomSmithingTransformRecipe<T> extends AbstractedFixedResultRecip
|
|||||||
private T createSmithingResult(Item<T> base, T result) {
|
private T createSmithingResult(Item<T> base, T result) {
|
||||||
Item<T> wrappedResult = (Item<T>) CraftEngine.instance().itemManager().wrap(result);
|
Item<T> wrappedResult = (Item<T>) CraftEngine.instance().itemManager().wrap(result);
|
||||||
Item<T> finalResult = wrappedResult;
|
Item<T> finalResult = wrappedResult;
|
||||||
|
Optional<Key> customId = finalResult.customId(); // 修复在保留custom_data组件的时候意外保留前物品的id
|
||||||
if (this.mergeComponents) {
|
if (this.mergeComponents) {
|
||||||
finalResult = base.mergeCopy(wrappedResult);
|
finalResult = base.mergeCopy(wrappedResult);
|
||||||
}
|
}
|
||||||
@@ -166,6 +164,9 @@ public class CustomSmithingTransformRecipe<T> extends AbstractedFixedResultRecip
|
|||||||
processor.accept(base, wrappedResult, finalResult);
|
processor.accept(base, wrappedResult, finalResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (customId.isPresent()) {
|
||||||
|
finalResult.customId(customId.get());
|
||||||
|
}
|
||||||
return finalResult.getItem();
|
return finalResult.getItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user