上传合成样板将忽略编码玩家tag

This commit is contained in:
GaLi 2025-12-05 11:05:07 +08:00
parent 82f4d02fef
commit 57aa76abf8
3 changed files with 18 additions and 18 deletions

3
.gitignore vendored
View File

@ -27,4 +27,5 @@ repo
othermods
crashreport
.cursor
.cursor
/src/generated/resources/.cache

View File

@ -32,12 +32,9 @@ import net.neoforged.neoforge.event.server.ServerStoppedEvent;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
// The value here should match an entry in the META-INF/neoforge.mods.toml file
@Mod(ExtendedAEPlus.MODID)
public class ExtendedAEPlus {
// Define mod id in a common place for everything to reference
public static final String MODID = "extendedae_plus";
// Directly reference a slf4j logger
public static final Logger LOGGER = LogUtils.getLogger();
// 移除 MDK 示例注册改为使用实际模组的方块/物品/创造物品栏注册见 ModBlocksModItemsModCreativeTabs
@Nullable
@ -45,10 +42,7 @@ public class ExtendedAEPlus {
@Nullable
private static MinecraftServer storageManagerServer;
// The constructor for the mod class is the first code that is run when your mod is loaded.
// FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically.
public ExtendedAEPlus(IEventBus modEventBus, ModContainer modContainer) {
// Register the commonSetup method for modloading
modEventBus.addListener(this::commonSetup);
// 注册网络负载处理器NeoForge 1.21 新式 Payload API
modEventBus.addListener(ModNetwork::registerPayloadHandlers);
@ -60,13 +54,9 @@ public class ExtendedAEPlus {
ModItems.ITEMS.register(modEventBus);
ModBlockEntities.BLOCK_ENTITY_TYPES.register(modEventBus);
ModCreativeTabs.TABS.register(modEventBus);
// Register the Deferred Register to the mod event bus so menu types get registered
ModMenuTypes.MENUS.register(modEventBus);
EAPComponents.DR.register(modEventBus);
// Register ourselves for server and other game events we are interested in.
// Note that this is necessary if and only if we want *this* class (ExtendedAEPlus) to respond directly to events.
// Do not add this line if there are no @SubscribeEvent-annotated functions in this class, like onServerStarting() below.
NeoForge.EVENT_BUS.register(this);
NeoForge.EVENT_BUS.addListener(ExtendedAEPlus::onServerStarted);
NeoForge.EVENT_BUS.addListener(ExtendedAEPlus::onServerStopped);
@ -75,7 +65,6 @@ public class ExtendedAEPlus {
modContainer.registerConfig(ModConfig.Type.CLIENT, ModConfigs.CLIENT_SPEC, "extendedae_plus-client.toml");
modContainer.registerConfig(ModConfig.Type.SERVER, ModConfigs.SERVER_SPEC, "extendedae_plus-server.toml");
}
// 便捷 ResourceLocation 工具
public static ResourceLocation id(String path) {
return ResourceLocation.fromNamespaceAndPath(MODID, path);
@ -99,7 +88,6 @@ public class ExtendedAEPlus {
}
private void commonSetup(FMLCommonSetupEvent event) {
// Some common setup code
LOGGER.info("HELLO FROM COMMON SETUP");
// 示例日志避免引用不存在的模板 Config 字段
LOGGER.info("DIRT BLOCK >> {}", BuiltInRegistries.BLOCK.getKey(Blocks.DIRT));
@ -182,11 +170,8 @@ public class ExtendedAEPlus {
});
}
// You can use SubscribeEvent and let the Event Bus discover methods to call
@SubscribeEvent
public void onServerStarting(ServerStartingEvent event) {
// Do something when the server starts
LOGGER.info("HELLO from server starting");
}
}
}

View File

@ -23,11 +23,14 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.CustomData;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeType;
import net.neoforged.fml.loading.FMLPaths;
@ -577,6 +580,11 @@ public class ExtendedAEPatternUploadUtil {
private static boolean matrixContainsPattern(IGrid grid, ItemStack pattern) {
if (grid == null || pattern == null || pattern.isEmpty()) return false;
CustomData defaultData = CustomData.of(new CompoundTag());
ItemStack patternCopy = pattern.copy();
CompoundTag newTag= patternCopy.getOrDefault(DataComponents.CUSTOM_DATA,defaultData).copyTag();
newTag.remove("encodePlayer");
patternCopy.set(DataComponents.CUSTOM_DATA, CustomData.of(newTag));
try {
// 先检查提供外部插入视图的内部库存
List<InternalInventory> inventories = findAllMatrixPatternInventories(grid);
@ -584,7 +592,13 @@ public class ExtendedAEPatternUploadUtil {
if (inv == null) continue;
for (int i = 0; i < inv.size(); i++) {
ItemStack s = inv.getStackInSlot(i);
if (!s.isEmpty() && net.minecraft.world.item.ItemStack.isSameItemSameComponents(s, pattern)) {
ItemStack sCopy=s.copy();
CompoundTag sNewTag=sCopy.getOrDefault(DataComponents.CUSTOM_DATA,defaultData).copyTag();
sNewTag.remove("encodePlayer");
sCopy.set(DataComponents.CUSTOM_DATA, CustomData.of(sNewTag));
if (!sCopy.isEmpty() && ItemStack.isSameItemSameComponents(sCopy, patternCopy)) {
return true;
}
}