v2.5.6
This commit is contained in:
+13
-4966
File diff suppressed because it is too large
Load Diff
+9
-2
@@ -44,7 +44,7 @@ neoForge {
|
||||
dependencies {
|
||||
compileOnly "org.appliedenergistics:appliedenergistics2:19.2.17:api"
|
||||
compileOnly "org.appliedenergistics:appliedenergistics2:19.2.17" // 加这行保留!!让AE2内部类可编译
|
||||
compileOnly files('library/thaumcraft-0.2.2.95-port.229.jar') // 必须与整合包运行版本一致(0.2.2.95);.34 缺少 getRemainingItems/findMatchingArcaneRecipeEntry 等 API
|
||||
compileOnly files('library/thaumcraft-0.2.2.95-port.261.jar') // 必须与整合包运行版本一致(0.2.2.95);.34 缺少 getRemainingItems/findMatchingArcaneRecipeEntry 等 API
|
||||
compileOnly files('library/jei-1.21.1-neoforge-19.39.0.368.jar')
|
||||
compileOnly files('library/ae2jeiintegration-1.2.1.jar')
|
||||
compileOnly files('library/InventoryProfilesNext-neoforge-1.21.1-2.2.5.jar')
|
||||
@@ -65,6 +65,12 @@ def neoforgeRange = project.findProperty('neoforge_version_range') ?: '[21,)'
|
||||
def mcRange = project.findProperty('minecraft_version_range') ?: '[1.21.1,1.22)'
|
||||
|
||||
processResources {
|
||||
// expand 值必须声明为 task 输入,否则 modVersion 变化时 Gradle 判 UP-TO-DATE 跳过,
|
||||
// jar 内 mods.toml 会钉死在旧版本(2.4.32 固化事故根因)。
|
||||
inputs.properties([
|
||||
'version': modVersion, 'loader_version_range': loaderRange,
|
||||
'neoforge_version_range': neoforgeRange, 'minecraft_version_range': mcRange
|
||||
])
|
||||
filesMatching('META-INF/neoforge.mods.toml') {
|
||||
expand([
|
||||
'version': modVersion, 'loader_version_range': loaderRange,
|
||||
@@ -97,7 +103,8 @@ def gitVersion() {
|
||||
// 支持 "2.2" / "v2.2.0" / "2.2-3-gabc1234" / "abc1234"(无tag时)
|
||||
// 版本 = tag 的 X.Y + 提交数:tag 2.2 + 2 提交 → 2.2.2
|
||||
// find() 只匹配开头,忽略尾部 commit hash(-gabc1234)
|
||||
def m = describe =~ /^v?(\d+\.\d+)(?:\.\d+)?(?:-(\d+))?/
|
||||
// [vV] 兼容大小写标签前缀(V2.5 / v2.4)
|
||||
def m = describe =~ /^[vV]?(\d+\.\d+)(?:\.\d+)?(?:-(\d+))?/
|
||||
if (m.find()) {
|
||||
def xy = m.group(1) // 2.2
|
||||
def count = m.group(2) ? m.group(2) : '0' // tag 后提交数
|
||||
|
||||
@@ -24,8 +24,3 @@ org.gradle.configuration-cache=true
|
||||
minecraft_version_range=[1.21.1,1.22)
|
||||
neoforge_version_range=[21,)
|
||||
loader_version_range=[4,)
|
||||
systemProp.http.proxyHost=127.0.0.1
|
||||
systemProp.http.proxyPort=7890
|
||||
systemProp.https.proxyHost=127.0.0.1
|
||||
systemProp.https.proxyPort=7890
|
||||
systemProp.http.nonProxyHosts=localhost|127.*
|
||||
|
||||
@@ -8,10 +8,15 @@ import appeng.api.stacks.AEKeyType;
|
||||
import appeng.api.stacks.AEKeyTypesInternal;
|
||||
import appeng.api.upgrades.Upgrades;
|
||||
import appeng.client.gui.style.StyleManager;
|
||||
import appeng.core.definitions.AEBlocks;
|
||||
import appeng.core.definitions.AEItems;
|
||||
import appeng.core.definitions.AEParts;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.Items;
|
||||
import appeng.api.AECapabilities;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
|
||||
@@ -26,14 +31,22 @@ import thaumicenergistics.common.integration.appeng.AEssentiaKeyType;
|
||||
import thaumicenergistics.common.integration.appeng.ThEAppliedEnergistics;
|
||||
import thaumicenergistics.common.integration.tc.ThEThaumcraft;
|
||||
import thaumicenergistics.common.items.ItemGolemWirelessBackpack;
|
||||
import thaumicenergistics.common.items.WirelessArcaneCraftingTerminalMenuHost;
|
||||
import thaumicenergistics.common.parts.ArcaneCraftingTerminalPart;
|
||||
import thaumicenergistics.common.parts.EssentiaExportBusPart;
|
||||
import thaumicenergistics.common.parts.EssentiaImportBusPart;
|
||||
import thaumicenergistics.common.parts.EssentiaLevelEmitterPart;
|
||||
import thaumicenergistics.common.parts.EssentiaStorageBusPart;
|
||||
import thaumicenergistics.common.parts.EssentiaTerminalPart;
|
||||
import thaumicenergistics.common.parts.VisInterfacePart;
|
||||
import thaumicenergistics.init.*;
|
||||
import appeng.api.networking.GridServices;
|
||||
import appeng.blockentity.AEBaseBlockEntity;
|
||||
import appeng.items.tools.powered.WirelessTerminalItem;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.loading.FMLLoader;
|
||||
import net.neoforged.neoforge.registries.RegisterEvent;
|
||||
import thaumicenergistics.api.grid.IEssentiaGrid;
|
||||
import thaumicenergistics.client.ClientInit;
|
||||
import thaumicenergistics.common.blocks.ThEWrenchHandler;
|
||||
import thaumicenergistics.common.grid.EssentiaGridService;
|
||||
import thaumicenergistics.common.network.ThENetworking;
|
||||
|
||||
@Mod(ThaumicEnergistics.MODID)
|
||||
public final class ThaumicEnergistics {
|
||||
@@ -47,42 +60,28 @@ public final class ThaumicEnergistics {
|
||||
ModBlockEntities.REGISTRY.register(modBus);
|
||||
ModMenuTypes.REGISTRY.register(modBus);
|
||||
ModCreativeTab.REGISTRY.register(modBus);
|
||||
ModComponents.REGISTRY.register(modBus);
|
||||
modBus.addListener(this::registerScreens);
|
||||
modBus.addListener(this::commonSetup);
|
||||
modBus.addListener(this::registerKeyTypes);
|
||||
modBus.addListener(this::registerUpgrades);
|
||||
|
||||
if (net.neoforged.fml.loading.FMLLoader.getDist().isClient()) {
|
||||
modBus.addListener(thaumicenergistics.client.ClientInit::onClientSetup);
|
||||
if (FMLLoader.getDist().isClient()) {
|
||||
modBus.addListener(ClientInit::onClientSetup);
|
||||
}
|
||||
ThEAppliedEnergistics.init();
|
||||
|
||||
appeng.api.networking.GridServices.register(
|
||||
thaumicenergistics.api.grid.IEssentiaGrid.class,
|
||||
thaumicenergistics.common.grid.EssentiaGridService.class
|
||||
GridServices.register(
|
||||
IEssentiaGrid.class,
|
||||
EssentiaGridService.class
|
||||
);
|
||||
|
||||
thaumicenergistics.common.network.ThENetworking.init(modBus);
|
||||
ThENetworking.init(modBus);
|
||||
|
||||
thaumicenergistics.common.blocks.ThEWrenchHandler.register();
|
||||
ThEWrenchHandler.register();
|
||||
|
||||
modBus.addListener(this::registerCapabilities);
|
||||
|
||||
PartModels.registerModels(
|
||||
EssentiaImportBusPart.RL_BASE, EssentiaImportBusPart.RL_OFF,
|
||||
EssentiaImportBusPart.RL_HAS_CHANNEL, EssentiaImportBusPart.RL_ON
|
||||
);
|
||||
PartModels.registerModels(
|
||||
EssentiaExportBusPart.RL_BASE, EssentiaExportBusPart.RL_OFF,
|
||||
EssentiaExportBusPart.RL_HAS_CHANNEL, EssentiaExportBusPart.RL_ON
|
||||
);
|
||||
PartModels.registerModels(
|
||||
EssentiaStorageBusPart.RL_BASE, EssentiaStorageBusPart.RL_OFF,
|
||||
EssentiaStorageBusPart.RL_HAS_CHANNEL, EssentiaStorageBusPart.RL_ON
|
||||
);
|
||||
PartModels.registerModels(
|
||||
EssentiaTerminalPart.RL_BASE, EssentiaTerminalPart.RL_OFF, EssentiaTerminalPart.RL_ON
|
||||
);
|
||||
PartModels.registerModels(
|
||||
ArcaneCraftingTerminalPart.RL_BASE, ArcaneCraftingTerminalPart.RL_OFF,
|
||||
ArcaneCraftingTerminalPart.RL_HAS_CHANNEL, ArcaneCraftingTerminalPart.RL_ON
|
||||
@@ -102,9 +101,9 @@ public final class ThaumicEnergistics {
|
||||
}
|
||||
|
||||
private void commonSetup(FMLCommonSetupEvent event) {
|
||||
appeng.blockentity.AEBaseBlockEntity.registerBlockEntityItem(
|
||||
AEBaseBlockEntity.registerBlockEntityItem(
|
||||
ModBlockEntities.ESSENTIA_PROVIDER.get(), ModItems.ESSENTIA_PROVIDER_ITEM.get());
|
||||
appeng.blockentity.AEBaseBlockEntity.registerBlockEntityItem(
|
||||
AEBaseBlockEntity.registerBlockEntityItem(
|
||||
ModBlockEntities.INFUSION_PROVIDER.get(), ModItems.INFUSION_PROVIDER_ITEM.get());
|
||||
|
||||
event.enqueueWork(() -> {
|
||||
@@ -112,37 +111,61 @@ public final class ThaumicEnergistics {
|
||||
ThEThaumcraft.init();
|
||||
P2PTunnelAttunement.registerAttunementTag(ModItems.VIS_INTERFACE.get());
|
||||
GridLinkables.register(ModItems.GOLEM_WIFI_BACKPACK.get(), ItemGolemWirelessBackpack.LINKABLE_HANDLER);
|
||||
GridLinkables.register(ModItems.WIRELESS_ESSENTIA_TERMINAL.get(),
|
||||
appeng.items.tools.powered.WirelessTerminalItem.LINKABLE_HANDLER);
|
||||
// T-FIX-BATCH ①:无线访问点链接槽按 GridLinkables 表过滤(RestrictedInputSlot.GRID_LINKABLE_ITEM
|
||||
// → GridLinkables.get(item) != null),漏注册则终端放不进访问点槽位。
|
||||
GridLinkables.register(ModItems.WIRELESS_ARCANE_CRAFTING_TERMINAL.get(),
|
||||
WirelessTerminalItem.LINKABLE_HANDLER);
|
||||
});
|
||||
}
|
||||
|
||||
private void registerUpgrades(FMLCommonSetupEvent event) {
|
||||
event.enqueueWork(() -> {
|
||||
// 注:不传 group——带 group 会在卡 tooltip 中与 AE2 原版 IO 总线合并显示为
|
||||
// "ME Import/Export Bus"(同 group 跳过),ThE 设备名不显示。与存储总线一致,各自显示设备名。
|
||||
var importBusItem = ModItems.ESSENTIA_IMPORT_BUS.get();
|
||||
Upgrades.add(AEItems.FUZZY_CARD, importBusItem, 1);
|
||||
Upgrades.add(AEItems.REDSTONE_CARD, importBusItem, 1);
|
||||
Upgrades.add(AEItems.CAPACITY_CARD, importBusItem, 5);
|
||||
Upgrades.add(AEItems.SPEED_CARD, importBusItem, 4);
|
||||
Upgrades.add(AEItems.INVERTER_CARD, importBusItem, 1);
|
||||
|
||||
var exportBusItem = ModItems.ESSENTIA_EXPORT_BUS.get();
|
||||
Upgrades.add(AEItems.FUZZY_CARD, exportBusItem, 1);
|
||||
Upgrades.add(AEItems.REDSTONE_CARD, exportBusItem, 1);
|
||||
Upgrades.add(AEItems.CAPACITY_CARD, exportBusItem, 5);
|
||||
Upgrades.add(AEItems.SPEED_CARD, exportBusItem, 4);
|
||||
Upgrades.add(AEItems.CRAFTING_CARD, exportBusItem, 1);
|
||||
|
||||
var storageBusItem = ModItems.ESSENTIA_STORAGE_BUS.get();
|
||||
Upgrades.add(AEItems.FUZZY_CARD, storageBusItem, 1);
|
||||
Upgrades.add(AEItems.INVERTER_CARD, storageBusItem, 1);
|
||||
Upgrades.add(AEItems.CAPACITY_CARD, storageBusItem, 5);
|
||||
Upgrades.add(AEItems.VOID_CARD, storageBusItem, 1);
|
||||
|
||||
// 神秘装配台:加速卡(AEItems.SPEED_CARD = Acceleration Card,tooltip 名单 + 装配台升级槽可装——加快合成)
|
||||
Upgrades.add(AEItems.SPEED_CARD, ModItems.ARCANE_ASSEMBLER_ITEM.get(), 4);
|
||||
|
||||
// T-M1-006-①:源质访问卡关联 AE2 原版四宿主——
|
||||
// 使卡可被四宿主的升级卡槽容许插入,且卡 tooltip 的「Supported By」行非空。
|
||||
// 四宿主(清单口径):输入总线 / 输出总线 / 存储总线 / ME 接口。
|
||||
// ME 接口 = 1 个宿主概念、2 种形态(部件 AEParts.INTERFACE + 方块 AEBlocks.INTERFACE);
|
||||
// AE2 官方 InitUpgrades 对两形态都注册(InitUpgrades.java:44-47),漏方块形态会导致其无法插卡。
|
||||
var essentiaCard = ModItems.ESSENTIA_UPGRADE_CARD.get();
|
||||
Upgrades.add(essentiaCard, AEParts.IMPORT_BUS, 1);
|
||||
Upgrades.add(essentiaCard, AEParts.EXPORT_BUS, 1);
|
||||
Upgrades.add(essentiaCard, AEParts.STORAGE_BUS, 1);
|
||||
// MGMT-TOOLTIP:part/block 两形态翻译键不同但显示名相同("ME接口"),AE2 tooltip 去重按
|
||||
// 翻译键 Component 比较——须传官方组键合并(对齐 InitUpgrades.java:44-47 自家卡写法)。
|
||||
var interfaceGroup = GuiText.Interface.getTranslationKey();
|
||||
Upgrades.add(essentiaCard, AEParts.INTERFACE, 1, interfaceGroup);
|
||||
Upgrades.add(essentiaCard, AEBlocks.INTERFACE, 1, interfaceGroup);
|
||||
|
||||
// T-M1-003 P3:源质卡关联 AE2 原版样板供应器两形态(部件 + 方块)。
|
||||
// 卡槽本身由 mixins/ae2/provider/ 组注入(AppFlux 存在时由 AppFlux 提供);
|
||||
// 本注册只负责「让卡能插进该宿主的升级槽 + Supported By 行含供应器」。
|
||||
// 对齐 AE2 官方 InitUpgrades 对 interface 两形态成对注册的先例(InitUpgrades.java:44-47)。
|
||||
// MGMT-TOOLTIP:GuiText 无 PatternProvider 常量,取官方 CraftingInterface(显示文本
|
||||
// 即 "ME Pattern Provider"/"ME样板供应器",AE2 lang 双语实证)作组键。
|
||||
var patternProviderGroup = GuiText.CraftingInterface.getTranslationKey();
|
||||
Upgrades.add(essentiaCard, AEParts.PATTERN_PROVIDER, 1, patternProviderGroup);
|
||||
Upgrades.add(essentiaCard, AEBlocks.PATTERN_PROVIDER, 1, patternProviderGroup);
|
||||
|
||||
// T-M3-VISCARD-REV:vis 连接卡(升级卡)仅关联无线奥术合成终端——
|
||||
// 允许插入其升级槽(2 槽,AE2 无线终端白送),并在 tooltip「Supported By」行显示宿主。
|
||||
Upgrades.add(ModItems.VIS_CONNECTOR_CARD.get(), ModItems.WIRELESS_ARCANE_CRAFTING_TERMINAL.get(), 1);
|
||||
|
||||
// WTBRIDGE:量子桥卡准入适配(软依赖)——ae2wtlib 的 UpgradeHelper 只对注册进其
|
||||
// AddTerminalEvent 体系的终端映射卡表,我方 WACT 未注册(ItemWT 类层级硬绑死、单继承无解),
|
||||
// 故自行补一条 Upgrades.add 映射放行插入(AE2 升级槽准入 = Upgrades.getMaxInstallable)。
|
||||
if (ModList.get().isLoaded(WirelessArcaneCraftingTerminalMenuHost.AE2WTLIB_MODID)) {
|
||||
var bridgeCard = BuiltInRegistries.ITEM
|
||||
.getOptional(WirelessArcaneCraftingTerminalMenuHost.AE2WTLIB_QUANTUM_BRIDGE_CARD).orElse(null);
|
||||
if (bridgeCard != null && bridgeCard != Items.AIR) {
|
||||
Upgrades.add(bridgeCard, ModItems.WIRELESS_ARCANE_CRAFTING_TERMINAL.get(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
// T-M6-IMPL:概率加速卡关联概率之脑(白名单 + Supported By 行;
|
||||
// 实际装填走方块右键直插,上限 4 由 BE 记账)。
|
||||
Upgrades.add(ModItems.PROBABILITY_ACCELERATOR_CARD.get(), ModItems.BRAIN_OF_PROBABILITY_ITEM.get(), 4);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -150,44 +173,27 @@ public final class ThaumicEnergistics {
|
||||
event.register(ModMenuTypes.ESSENTIA_CELL_WORKBENCH.get(), GuiEssentiaCellWorkbench::new);
|
||||
event.register(ModMenuTypes.EVC.get(), GuiEssentiaVibrationChamber::new);
|
||||
event.register(ModMenuTypes.ARCANE_ASSEMBLER.get(), GuiArcaneAssembler::new);
|
||||
event.register(ModMenuTypes.ESSENTIA_TERMINAL.get(),
|
||||
(EssentiaTerminalMenu menu, Inventory inv, Component title)
|
||||
-> new GuiEssentiaTerminal(menu, inv, title,
|
||||
StyleManager.loadStyleDoc("/screens/terminals/terminal.json")));
|
||||
event.register(ModMenuTypes.WIRELESS_ESSENTIA_TERMINAL.get(),
|
||||
(EssentiaTerminalMenu menu, Inventory inv, Component title)
|
||||
-> new GuiEssentiaTerminal(menu, inv, title,
|
||||
StyleManager.loadStyleDoc("/screens/terminals/wireless_terminal.json")));
|
||||
event.register(ModMenuTypes.KNOWLEDGE_INSCRIBER.get(), GuiKnowledgeInscriber::new);
|
||||
event.register(ModMenuTypes.DISTILLATION_ENCODER.get(), GuiDistillationPatternEncoder::new);
|
||||
|
||||
event.register(ModMenuTypes.ESSENTIA_IMPORT_BUS.get(),
|
||||
(ContainerEssentiaImportBus menu, Inventory inv, Component title)
|
||||
-> new GuiEssentiaImportBus(menu, inv, title,
|
||||
StyleManager.loadStyleDoc("/screens/import_bus.json")));
|
||||
|
||||
event.register(ModMenuTypes.ESSENTIA_EXPORT_BUS.get(),
|
||||
(ContainerEssentiaExportBus menu, Inventory inv, Component title)
|
||||
-> new GuiEssentiaExportBus(menu, inv, title,
|
||||
StyleManager.loadStyleDoc("/screens/export_bus.json")));
|
||||
|
||||
event.register(ModMenuTypes.ESSENTIA_STORAGE_BUS.get(),
|
||||
(ContainerEssentiaStorageBus menu, Inventory inv, Component title)
|
||||
-> new GuiEssentiaStorageBus(menu, inv, title,
|
||||
StyleManager.loadStyleDoc("/screens/storage_bus.json")));
|
||||
|
||||
event.register(ModMenuTypes.ARCANE_CRAFTING_TERMINAL.get(),
|
||||
(ContainerArcaneCraftingTerminal menu, Inventory inv, Component title)
|
||||
-> new GuiArcaneCraftingTerminal(menu, inv, title,
|
||||
StyleManager.loadStyleDoc("/screens/arcane_crafting_terminal.json")));
|
||||
|
||||
// 无线奥术合成终端:复用同一屏幕类与样式(共用菜单类)
|
||||
event.register(ModMenuTypes.WIRELESS_ARCANE_CRAFTING_TERMINAL.get(),
|
||||
(ContainerArcaneCraftingTerminal menu, Inventory inv, Component title)
|
||||
-> new GuiArcaneCraftingTerminal(menu, inv, title,
|
||||
StyleManager.loadStyleDoc("/screens/arcane_crafting_terminal.json")));
|
||||
|
||||
event.register(ModMenuTypes.ESSENTIA_LEVEL_EMITTER.get(),
|
||||
(ContainerEssentiaLevelEmitter menu, Inventory inv, Component title)
|
||||
-> new GuiEssentiaLevelEmitter(menu, inv, title,
|
||||
StyleManager.loadStyleDoc("/screens/essentia_level_emitter.json")));
|
||||
}
|
||||
|
||||
private void registerKeyTypes(net.neoforged.neoforge.registries.RegisterEvent event) {
|
||||
private void registerKeyTypes(RegisterEvent event) {
|
||||
LOG.info("registerKeyTypes fired, registryKey={}", event.getRegistryKey());
|
||||
if (event.getRegistryKey() == AEKeyType.REGISTRY_KEY) {
|
||||
AEKeyTypesInternal.register(AEssentiaKeyType.INSTANCE);
|
||||
@@ -220,5 +226,10 @@ public final class ThaumicEnergistics {
|
||||
AECapabilities.IN_WORLD_GRID_NODE_HOST,
|
||||
ModBlockEntities.INFUSION_MONITOR.get(),
|
||||
(be, context) -> (appeng.api.networking.IInWorldGridNodeHost) be);
|
||||
// M6 概率之脑:ME 网络节点 capability(扣 cognitio/能量、周期 tick 依赖)
|
||||
event.registerBlockEntity(
|
||||
AECapabilities.IN_WORLD_GRID_NODE_HOST,
|
||||
ModBlockEntities.BRAIN_OF_PROBABILITY.get(),
|
||||
(be, context) -> (appeng.api.networking.IInWorldGridNodeHost) be);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
package thaumicenergistics.api;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import java.util.OptionalLong;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
/** 定义 ThaumicEnergistics 可交互的物品与方块实体。自 1.7.10 移植。 */
|
||||
public interface IThETransportPermissions {
|
||||
/** 注册一个方块实体类,支持抽取与注入。 */
|
||||
<T extends net.minecraft.world.level.block.entity.BlockEntity> boolean addTileToBoth(Class<T> tileClass, int capacity);
|
||||
<T extends BlockEntity> boolean addTileToBoth(Class<T> tileClass, int capacity);
|
||||
/** 注册一个仅支持抽取的方块实体。 */
|
||||
<T extends net.minecraft.world.level.block.entity.BlockEntity> boolean addTileToExtract(Class<T> tileClass, int capacity);
|
||||
<T extends BlockEntity> boolean addTileToExtract(Class<T> tileClass, int capacity);
|
||||
/** 注册一个仅支持注入的方块实体。 */
|
||||
<T extends net.minecraft.world.level.block.entity.BlockEntity> boolean addTileToInject(Class<T> tileClass, int capacity);
|
||||
<T extends BlockEntity> boolean addTileToInject(Class<T> tileClass, int capacity);
|
||||
/** 获取方块实体类已注册的容量;未注册返回空。 */
|
||||
OptionalLong getCapacityForTile(Class<? extends net.minecraft.world.level.block.entity.BlockEntity> tileClass);
|
||||
OptionalLong getCapacityForTile(Class<? extends BlockEntity> tileClass);
|
||||
/** 检查该方块实体是否允许抽取。 */
|
||||
boolean canExtract(net.minecraft.world.level.block.entity.BlockEntity tile);
|
||||
boolean canExtract(BlockEntity tile);
|
||||
/** 检查该方块实体是否允许注入。 */
|
||||
boolean canInject(net.minecraft.world.level.block.entity.BlockEntity tile);
|
||||
boolean canInject(BlockEntity tile);
|
||||
/** 注册一个带容量的容器物品类型。 */
|
||||
void addContainerItem(Class<? extends net.minecraft.world.item.Item> itemClass, int capacity, boolean canHoldPartial);
|
||||
void addContainerItem(Class<? extends Item> itemClass, int capacity, boolean canHoldPartial);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package thaumicenergistics.api.grid;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/** 合成请求宿主 —— 接收合成请求。移植自 1.7.10。 */
|
||||
public interface ICraftingIssuerHost {
|
||||
void launchCrafting(net.minecraft.resources.ResourceLocation aspectId, long amount);
|
||||
void launchCrafting(ResourceLocation aspectId, long amount);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package thaumicenergistics.api.grid;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/** 数字 vis 源——从 AE 网络提供 vis。移植自 1.7.10。 */
|
||||
public interface IDigiVisSource {
|
||||
int consumeVis(net.minecraft.resources.ResourceLocation aspectId, int amount);
|
||||
int consumeVis(ResourceLocation aspectId, int amount);
|
||||
boolean isActive();
|
||||
}
|
||||
|
||||
@@ -4,13 +4,14 @@ import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKeyType;
|
||||
import appeng.api.client.AEKeyRendering;
|
||||
|
||||
public final class ClientInit {
|
||||
private ClientInit() {}
|
||||
|
||||
public static void onClientSetup(FMLClientSetupEvent event) {
|
||||
event.enqueueWork(() -> {
|
||||
appeng.api.client.AEKeyRendering.register(
|
||||
AEKeyRendering.register(
|
||||
AEssentiaKeyType.INSTANCE,
|
||||
AEssentiaKey.class,
|
||||
new EssentiaKeyRenderHandler()
|
||||
|
||||
@@ -2,38 +2,40 @@ package thaumicenergistics.client;
|
||||
|
||||
import net.minecraft.client.model.geom.EntityModelSet;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
|
||||
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
|
||||
import thaumcraft.client.renderers.entity.LegacyGolemModel;
|
||||
import thaumcraft.client.renderers.entity.ThaumcraftGolemRenderer;
|
||||
import thaumcraft.common.entities.golem.ThaumcraftGolemEntity;
|
||||
import thaumcraft.common.registry.TCEntityTypes;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.client.render.layer.GolemBackpackLayer;
|
||||
import thaumicenergistics.client.render.model.GolemBackpackModel;
|
||||
import thaumicenergistics.client.render.RenderTileArcaneAssembler;
|
||||
import thaumicenergistics.client.render.RenderTileBrainOfProbability;
|
||||
import thaumicenergistics.client.render.RenderTileEVC;
|
||||
import thaumicenergistics.init.ModBlockEntities;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
import net.minecraft.client.model.geom.ModelLayerLocation;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/** 客户端渲染注册的事件处理器。 */
|
||||
@EventBusSubscriber(modid = ThaumicEnergistics.MODID, value = Dist.CLIENT)
|
||||
public final class ClientSetup {
|
||||
|
||||
/** 背包模型的 LayerDefinition 注册 key */
|
||||
public static final net.minecraft.client.model.geom.ModelLayerLocation GOLEM_BACKPACK_LAYER =
|
||||
new net.minecraft.client.model.geom.ModelLayerLocation(
|
||||
net.minecraft.resources.ResourceLocation.fromNamespaceAndPath(ThaumicEnergistics.MODID, "golem_backpack"),
|
||||
public static final ModelLayerLocation GOLEM_BACKPACK_LAYER =
|
||||
new ModelLayerLocation(
|
||||
ResourceLocation.fromNamespaceAndPath(ThaumicEnergistics.MODID, "golem_backpack"),
|
||||
"main");
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerBER(EntityRenderersEvent.RegisterRenderers event) {
|
||||
event.registerBlockEntityRenderer(ModBlockEntities.ARCANE_ASSEMBLER.get(), RenderTileArcaneAssembler::new);
|
||||
event.registerBlockEntityRenderer(ModBlockEntities.ESSENTIA_VIBRATION_CHAMBER.get(), RenderTileEVC::new);
|
||||
event.registerBlockEntityRenderer(ModBlockEntities.BRAIN_OF_PROBABILITY.get(), RenderTileBrainOfProbability::new);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -47,7 +49,7 @@ public final class ClientSetup {
|
||||
EntityRenderer<?> renderer = event.getRenderer(TCEntityTypes.GOLEM.get());
|
||||
if (renderer instanceof ThaumcraftGolemRenderer golemRenderer) {
|
||||
EntityModelSet modelSet = event.getEntityModels();
|
||||
net.minecraft.client.model.geom.ModelPart backpackPart = modelSet.bakeLayer(GOLEM_BACKPACK_LAYER);
|
||||
ModelPart backpackPart = modelSet.bakeLayer(GOLEM_BACKPACK_LAYER);
|
||||
GolemBackpackModel backpackModel = new GolemBackpackModel(backpackPart);
|
||||
golemRenderer.addLayer(new GolemBackpackLayer(golemRenderer, backpackModel));
|
||||
}
|
||||
@@ -55,28 +57,6 @@ public final class ClientSetup {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItemColors(RegisterColorHandlersEvent.Item event) {
|
||||
// 给源质终端物品着色:完全对齐 AEColor.TRANSPARENT.getVariantByTintIndex()
|
||||
event.register((stack, tintIndex) -> {
|
||||
return switch (tintIndex) {
|
||||
case 0 -> -1; // 不染色
|
||||
case 1 -> 0xFF5a479e; // Dark: 深紫色
|
||||
case 2 -> 0xFF915dcd; // Medium: 紫色
|
||||
case 3 -> 0xFFe2a3e3; // Bright: 淡紫色
|
||||
case 4 -> 0xFFb980d8; // Medium Bright: 中间紫
|
||||
default -> -1;
|
||||
};
|
||||
}, ModItems.ESSENTIA_TERMINAL_ITEM.get());
|
||||
|
||||
// 给无线源质终端物品着色(与源质终端部件相同的紫色)
|
||||
event.register((stack, tintIndex) -> {
|
||||
return switch (tintIndex) {
|
||||
case 0 -> -1;
|
||||
case 1 -> 0xFF5a479e;
|
||||
case 2 -> 0xFF915dcd;
|
||||
case 3 -> 0xFFe2a3e3;
|
||||
case 4 -> 0xFFb980d8;
|
||||
default -> -1;
|
||||
};
|
||||
}, ModItems.WIRELESS_ESSENTIA_TERMINAL.get());
|
||||
// T-M2-REMOVE:源质终端与无线源质终端已删除,原两段紫色着色注册随之移除。
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.client.gui.AspectGuiRenderer;
|
||||
@@ -13,8 +12,10 @@ import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import appeng.api.client.AEKeyRenderHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class EssentiaKeyRenderHandler implements appeng.api.client.AEKeyRenderHandler<AEssentiaKey> {
|
||||
public class EssentiaKeyRenderHandler implements AEKeyRenderHandler<AEssentiaKey> {
|
||||
|
||||
@Override
|
||||
public void drawInGui(Minecraft minecraft, GuiGraphics guiGraphics, int x, int y, AEssentiaKey stack) {
|
||||
@@ -41,7 +42,7 @@ public class EssentiaKeyRenderHandler implements appeng.api.client.AEKeyRenderHa
|
||||
public List<Component> getTooltip(AEssentiaKey stack) {
|
||||
List<Component> tooltip = new ArrayList<>();
|
||||
tooltip.add(stack.getDisplayName());
|
||||
tooltip.add(Component.literal(appeng.util.Platform.formatModName(stack.getModId())));
|
||||
tooltip.add(Component.literal(Platform.formatModName(stack.getModId())));
|
||||
return tooltip;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.client.event.ScreenEvent;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingSubmitResult;
|
||||
import appeng.client.gui.me.crafting.CraftConfirmScreen;
|
||||
import appeng.client.gui.me.crafting.CraftErrorScreen;
|
||||
import appeng.menu.me.crafting.CraftConfirmMenu;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package thaumicenergistics.client.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
import thaumcraft.client.renderers.blockentity.BrainJarBlockEntityRenderer;
|
||||
import thaumicenergistics.common.blocks.BrainOfProbabilityBlock;
|
||||
import thaumicenergistics.common.tiles.BrainOfProbabilityBlockEntity;
|
||||
|
||||
/**
|
||||
* 概率之脑罐腔内脑子的缓慢旋转渲染。脑子模型与贴图直接取自 TC 脑罐渲染器的公开静态组装
|
||||
* ({@link BrainJarBlockEntityRenderer#createBrain()} 与 brain2.png),不复制资产;姿态链与
|
||||
* 渲染类型逐条对齐 TC 官方 render(entityCutoutNoCull——cull 开启会因翻转姿态剔除全部可见面),
|
||||
* 仅旋转源改为 gameTime 驱动。
|
||||
*/
|
||||
public class RenderTileBrainOfProbability implements BlockEntityRenderer<BrainOfProbabilityBlockEntity> {
|
||||
|
||||
private static final ResourceLocation BRAIN_TEXTURE =
|
||||
ResourceLocation.fromNamespaceAndPath("thaumcraft", "textures/models/brain2.png");
|
||||
|
||||
private static final float BRAIN_SCALE = 0.4F;
|
||||
|
||||
private static final float BRAIN_LIFT = -0.8F;
|
||||
|
||||
private static final float BRAIN_DEGREES_PER_TICK = 0.25F;
|
||||
|
||||
private static final float BRAIN_TURN_TICKS = 1440.0F;
|
||||
|
||||
private final ModelPart brain;
|
||||
|
||||
public RenderTileBrainOfProbability(BlockEntityRendererProvider.Context context) {
|
||||
this.brain = BrainJarBlockEntityRenderer.createBrain();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(BrainOfProbabilityBlockEntity box, float partialTick, PoseStack poses,
|
||||
MultiBufferSource buffers, int light, int overlay) {
|
||||
// 脑在否以方块状态 JAR 为准(对齐 CE hasJar)——BE 的 brain ItemStack 字段不做网络同步,
|
||||
// 客户端读它恒为空会导致脑子只在存档重进后出现。
|
||||
if (!box.getBlockState().getValue(BrainOfProbabilityBlock.JAR)) {
|
||||
return;
|
||||
}
|
||||
Level level = box.getLevel();
|
||||
long gameTime = level == null ? 0L : level.getGameTime();
|
||||
float turn = ((gameTime % (long) BRAIN_TURN_TICKS) + partialTick) * BRAIN_DEGREES_PER_TICK;
|
||||
|
||||
poses.pushPose();
|
||||
poses.translate(0.5F, 0.01F, 0.5F);
|
||||
poses.mulPose(Axis.XP.rotationDegrees(180.0F));
|
||||
poses.translate(0.0F, BRAIN_LIFT, 0.0F);
|
||||
poses.mulPose(Axis.YP.rotationDegrees(turn));
|
||||
poses.mulPose(Axis.YP.rotationDegrees(-90.0F));
|
||||
poses.scale(BRAIN_SCALE, BRAIN_SCALE, BRAIN_SCALE);
|
||||
this.brain.render(
|
||||
poses, buffers.getBuffer(RenderType.entityCutoutNoCull(BRAIN_TEXTURE)), light, overlay);
|
||||
poses.popPose();
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import thaumcraft.common.entities.golem.ThaumcraftGolemEntity;
|
||||
import thaumicenergistics.client.render.model.GolemBackpackModel;
|
||||
import thaumicenergistics.common.entities.BackpackSkins;
|
||||
import thaumicenergistics.common.network.GolemBackpackClientData;
|
||||
import thaumicenergistics.common.network.GolemBackpackSyncPacket;
|
||||
|
||||
/**
|
||||
* 傀儡无线背包渲染层。
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.client.model.geom.builders.MeshDefinition;
|
||||
import net.minecraft.client.model.geom.builders.PartDefinition;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector4f;
|
||||
import com.mojang.math.Axis;
|
||||
|
||||
/**
|
||||
* 傀儡无线背包模型(简化版)。
|
||||
@@ -94,7 +95,7 @@ public class GolemBackpackModel {
|
||||
|
||||
poseStack.pushPose();
|
||||
|
||||
poseStack.mulPose(com.mojang.math.Axis.YP.rotationDegrees(pearlRotation));
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(pearlRotation));
|
||||
|
||||
poseStack.scale(pearlScale, pearlScale, pearlScale);
|
||||
|
||||
@@ -109,7 +110,7 @@ public class GolemBackpackModel {
|
||||
|
||||
// 前后两面(旋转 90°)
|
||||
poseStack.pushPose();
|
||||
poseStack.mulPose(com.mojang.math.Axis.YP.rotationDegrees(90));
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(90));
|
||||
poseStack.translate(-0.0955f, 0.275f, -0.045f - antennaWidth - faceDist);
|
||||
drawPearlFace(poseStack, buffer, light, overlay, maxU, minU, minV, maxV, red, green, blue, 0, 0, -1);
|
||||
poseStack.translate(0, 0, antennaWidth - twoFD);
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
package thaumicenergistics.common.blocks;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.ItemInteractionResult;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
|
||||
import thaumicenergistics.common.tiles.BrainOfProbabilityBlockEntity;
|
||||
import thaumcraft.common.registry.TCItems;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import thaumicenergistics.common.blocks.ThEBaseEntityBlock;
|
||||
import thaumicenergistics.init.ModBlocks;
|
||||
|
||||
/**
|
||||
* 概率之脑下格(M6,CE gacha_box 同构):BE 所在格。
|
||||
* 方块状态 = facing(屏幕朝向)× screen(五态屏)× jar(是否装脑);
|
||||
* 交互无 GUI:装脑 / 插加速卡 / 潜行取出,见 B3 批次。
|
||||
*/
|
||||
public class BrainOfProbabilityBlock extends ThEBaseEntityBlock {
|
||||
|
||||
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
|
||||
/** 五态屏:off=无脑 / on=有脑待机 / working=周期运转 / failed=白转后闪 / success=出货后闪。 */
|
||||
public static final EnumProperty<Screen> SCREEN = EnumProperty.create("screen", Screen.class);
|
||||
/** 镜像槽里的罐装脑(thaumcraft:brain_jar)。 */
|
||||
public static final BooleanProperty JAR = BooleanProperty.create("jar");
|
||||
|
||||
public BrainOfProbabilityBlock(Properties properties) {
|
||||
super(properties);
|
||||
this.registerDefaultState(this.stateDefinition.any()
|
||||
.setValue(FACING, Direction.NORTH)
|
||||
.setValue(SCREEN, Screen.OFF)
|
||||
.setValue(JAR, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING, SCREEN, JAR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return this.defaultBlockState()
|
||||
.setValue(FACING, context.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
|
||||
/** 放置成功后补齐上格(上格 STACKED=true,见 BrainOfProbabilityTopBlock)。 */
|
||||
@Override
|
||||
public void setPlacedBy(Level level, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
|
||||
level.setBlock(pos.above(), ModBlocks.BRAIN_OF_PROBABILITY_TOP.get()
|
||||
.defaultBlockState()
|
||||
.setValue(BrainOfProbabilityTopBlock.STACKED, true), 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new BrainOfProbabilityBlockEntity(pos, state);
|
||||
}
|
||||
|
||||
/** 五态屏枚举(CE Screen 同名同序)。 */
|
||||
public enum Screen implements StringRepresentable {
|
||||
OFF("off"),
|
||||
ON("on"),
|
||||
WORKING("working"),
|
||||
FAILED("failed"),
|
||||
SUCCESS("success");
|
||||
|
||||
private final String name;
|
||||
|
||||
Screen(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSerializedName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 交互(M6 语义:无 GUI 纯右键,CE BlockGachaBox.useItemOn 同构) =====
|
||||
|
||||
/** 手持物品右键:潜行→取出全部;脑→装入并记归属;加速卡→直插(上限 4)。 */
|
||||
@Override
|
||||
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos,
|
||||
Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
return interact(level, pos, state, player, stack);
|
||||
}
|
||||
|
||||
/** 空手右键:潜行→取出全部;普通→actionbar 状态反馈。 */
|
||||
@Override
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos,
|
||||
Player player, BlockHitResult hit) {
|
||||
ItemInteractionResult result = interact(level, pos, state, player, ItemStack.EMPTY);
|
||||
if (result == ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一交互入口;上格点击时由 Top 方块下借一格调用。
|
||||
* 顺序照 CE:潜行取出 → 无主脑认领 → 装脑 → 插卡。
|
||||
*/
|
||||
static ItemInteractionResult interact(Level level, BlockPos pos, BlockState state, Player player, ItemStack stack) {
|
||||
if (!(level.getBlockEntity(pos) instanceof BrainOfProbabilityBlockEntity brain)) {
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
}
|
||||
// 潜行取回:不管手上拿着什么,空手也得能操作
|
||||
if (player.isShiftKeyDown()) {
|
||||
if (!state.getValue(JAR)) {
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
}
|
||||
if (level.isClientSide) {
|
||||
return ItemInteractionResult.sidedSuccess(true);
|
||||
}
|
||||
if (!brain.mayTakeBrain(player)) {
|
||||
player.displayClientMessage(Component.translatable(
|
||||
"thaumicenergistics.brain_prob.bound_to_other",
|
||||
brain.ownerName() == null ? "" : brain.ownerName()), true);
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
// 先解绑:不管取出什么,下一颗脑归新主人
|
||||
brain.unbind();
|
||||
give(player, brain.takeBrain());
|
||||
for (ItemStack card : brain.takeCards()) {
|
||||
give(player, card);
|
||||
}
|
||||
player.displayClientMessage(
|
||||
Component.translatable("thaumicenergistics.brain_prob.ejected"), true);
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
// 槽里残留的无主脑(存档中断留下):点击的玩家一键认领
|
||||
if (brain.hasUnboundBrain()) {
|
||||
if (level.isClientSide) {
|
||||
return ItemInteractionResult.sidedSuccess(true);
|
||||
}
|
||||
brain.bind(player);
|
||||
player.displayClientMessage(Component.translatable(
|
||||
"thaumicenergistics.brain_prob.rebound", player.getName().getString()), true);
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
// 装脑:已装则拒收;空手跳过(T-M6-RECIPE-2:投入物改 thaumcraft 罐装脑)
|
||||
if (!stack.isEmpty() && !state.getValue(JAR) && stack.is(TCItems.BRAIN_JAR.get())) {
|
||||
if (level.isClientSide) {
|
||||
return ItemInteractionResult.sidedSuccess(true);
|
||||
}
|
||||
brain.addBrain(player, stack);
|
||||
player.displayClientMessage(Component.translatable(
|
||||
"thaumicenergistics.brain_prob.brain_inserted", player.getName().getString()), true);
|
||||
if (!player.getAbilities().instabuild) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
// 插加速卡:已满提示且不消耗
|
||||
if (!stack.isEmpty() && stack.is(ModItems.PROBABILITY_ACCELERATOR_CARD.get())) {
|
||||
if (level.isClientSide) {
|
||||
return ItemInteractionResult.sidedSuccess(true);
|
||||
}
|
||||
if (!brain.hasRoomForCard()) {
|
||||
player.displayClientMessage(
|
||||
Component.translatable("thaumicenergistics.brain_prob.cards_full"), true);
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
brain.addCard(stack);
|
||||
player.displayClientMessage(Component.translatable(
|
||||
"thaumicenergistics.brain_prob.card_inserted", brain.cardCount()), true);
|
||||
if (!player.getAbilities().instabuild) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
// 空手普通右键:状态反馈
|
||||
if (stack.isEmpty()) {
|
||||
if (level.isClientSide) {
|
||||
return ItemInteractionResult.sidedSuccess(true);
|
||||
}
|
||||
player.displayClientMessage(brain.buildStatus(), true);
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
}
|
||||
|
||||
/** 物品给玩家(背包满则落地),CE give 同款。 */
|
||||
private static void give(Player player, ItemStack stack) {
|
||||
if (!stack.isEmpty() && !player.getInventory().add(stack)) {
|
||||
player.drop(stack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package thaumicenergistics.common.blocks;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.ItemInteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
/**
|
||||
* 概率之脑上格(M6,CE aggregator 同构):纯形态格,无 BE、无交互;
|
||||
* 状态只表示它是否立在底座(下格)上。
|
||||
*/
|
||||
public class BrainOfProbabilityTopBlock extends Block {
|
||||
|
||||
public static final BooleanProperty STACKED = BooleanProperty.create("stacked");
|
||||
|
||||
public BrainOfProbabilityTopBlock(Properties properties) {
|
||||
super(properties);
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(STACKED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(STACKED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return this.defaultBlockState()
|
||||
.setValue(STACKED, isOnBody(context.getLevel(), context.getClickedPos()));
|
||||
}
|
||||
|
||||
/** 底座被拆时上格随之消散。 */
|
||||
@Override
|
||||
protected BlockState updateShape(BlockState state, Direction facing, BlockState neighborState,
|
||||
LevelAccessor level, BlockPos pos, BlockPos neighborPos) {
|
||||
if (facing == Direction.DOWN
|
||||
&& !(level.getBlockState(pos.below()).getBlock() instanceof BrainOfProbabilityBlock)) {
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
/** 上格破坏时掉落本格对应的上格物品(供恢复结构用)。 */
|
||||
@Override
|
||||
public java.util.List<ItemStack> getDrops(BlockState state, LootParams.Builder builder) {
|
||||
return java.util.List.of();
|
||||
}
|
||||
|
||||
private static boolean isOnBody(BlockGetter level, BlockPos pos) {
|
||||
return level.getBlockState(pos.below()).getBlock() instanceof BrainOfProbabilityBlock;
|
||||
}
|
||||
|
||||
/** 上格点击下借一格:全部交互交给底座处理。 */
|
||||
@Override
|
||||
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state,
|
||||
Level level, BlockPos pos,
|
||||
Player player,
|
||||
InteractionHand hand,
|
||||
BlockHitResult hit) {
|
||||
BlockPos bodyPos = pos.below();
|
||||
BlockState bodyState = level.getBlockState(bodyPos);
|
||||
if (bodyState.getBlock() instanceof BrainOfProbabilityBlock) {
|
||||
return BrainOfProbabilityBlock.interact(level, bodyPos, bodyState, player, stack);
|
||||
}
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level level,
|
||||
BlockPos pos, Player player,
|
||||
BlockHitResult hit) {
|
||||
BlockPos bodyPos = pos.below();
|
||||
BlockState bodyState = level.getBlockState(bodyPos);
|
||||
if (bodyState.getBlock() instanceof BrainOfProbabilityBlock) {
|
||||
ItemInteractionResult result =
|
||||
BrainOfProbabilityBlock.interact(level, bodyPos, bodyState, player, ItemStack.EMPTY);
|
||||
if (result == ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
/** 上格不遮挡底座交互面(与 CE aggregator 一致:模型本身不占满格)。 */
|
||||
@Override
|
||||
protected boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
|
||||
// CE 模型实际占位约在角落四柱与中部,给近乎全格碰撞以避免玩家穿模(宽松近似)
|
||||
return Block.box(1, 0, 1, 15, 16, 15);
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,9 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import thaumicenergistics.common.tiles.TileEssentiaProvider;
|
||||
import thaumicenergistics.common.tiles.TileEssentiaVibrationChamber;
|
||||
import thaumicenergistics.common.tiles.TileInfusionProvider;
|
||||
import thaumicenergistics.common.tiles.ThETileBase;
|
||||
import thaumicenergistics.init.ModBlockEntities;
|
||||
|
||||
public abstract class ThEBaseEntityBlock extends Block implements EntityBlock {
|
||||
protected ThEBaseEntityBlock(Properties p) { super(p); }
|
||||
@@ -30,10 +30,10 @@ public abstract class ThEBaseEntityBlock extends Block implements EntityBlock {
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
||||
if (level.isClientSide()) return null;
|
||||
if (type == thaumicenergistics.init.ModBlockEntities.ESSENTIA_PROVIDER.get()) {
|
||||
if (type == ModBlockEntities.ESSENTIA_PROVIDER.get()) {
|
||||
return createTicker((lvl, pos, st, be) -> ((TileEssentiaProvider) be).serverTick());
|
||||
}
|
||||
if (type == thaumicenergistics.init.ModBlockEntities.INFUSION_PROVIDER.get()) {
|
||||
if (type == ModBlockEntities.INFUSION_PROVIDER.get()) {
|
||||
return createTicker((lvl, pos, st, be) -> ((TileInfusionProvider) be).serverTick());
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import appeng.datagen.providers.tags.ConventionTags;
|
||||
|
||||
/**
|
||||
* AE2 扳手拆卸处理。AE2 的 WrenchHook 只处理 AEBaseBlockEntity,ThE 方块 BE 不走该路径;
|
||||
@@ -37,7 +38,7 @@ public final class ThEWrenchHandler {
|
||||
return;
|
||||
}
|
||||
var stack = player.getItemInHand(event.getHand());
|
||||
if (!player.isShiftKeyDown() || !stack.is(appeng.datagen.providers.tags.ConventionTags.WRENCH)) {
|
||||
if (!player.isShiftKeyDown() || !stack.is(ConventionTags.WRENCH)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,14 @@ import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.common.container.slot.ReadOnlySlot;
|
||||
import thaumicenergistics.common.tiles.TileArcaneAssembler;
|
||||
import thaumicenergistics.init.ModMenuTypes;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.Equipable;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
|
||||
/**
|
||||
* 奥术装配器 Container。
|
||||
@@ -166,7 +174,7 @@ public class ContainerArcaneAssembler extends AbstractContainerMenu {
|
||||
// ===== 3. 知识核心 (Tile.KCORE_SLOT = 0) =====
|
||||
addSlot(new SlotItemHandler(machineHandler, TileArcaneAssembler.KCORE_SLOT, KCORE_X, KCORE_Y) {
|
||||
@Override public boolean mayPlace(ItemStack stack) {
|
||||
return stack.is(thaumicenergistics.init.ModItems.KNOWLEDGE_CORE.get());
|
||||
return stack.is(ModItems.KNOWLEDGE_CORE.get());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -196,31 +204,31 @@ public class ContainerArcaneAssembler extends AbstractContainerMenu {
|
||||
for (int i = 0; i < ARMOR_COUNT; i++) {
|
||||
final int armorIdx = i;
|
||||
int invIdx = TileArcaneAssembler.ARMOR_SLOT_START + i;
|
||||
final net.minecraft.world.entity.EquipmentSlot eq = switch (i) {
|
||||
case 0 -> net.minecraft.world.entity.EquipmentSlot.HEAD;
|
||||
case 1 -> net.minecraft.world.entity.EquipmentSlot.CHEST;
|
||||
case 2 -> net.minecraft.world.entity.EquipmentSlot.LEGS;
|
||||
default -> net.minecraft.world.entity.EquipmentSlot.FEET;
|
||||
final EquipmentSlot eq = switch (i) {
|
||||
case 0 -> EquipmentSlot.HEAD;
|
||||
case 1 -> EquipmentSlot.CHEST;
|
||||
case 2 -> EquipmentSlot.LEGS;
|
||||
default -> EquipmentSlot.FEET;
|
||||
};
|
||||
// 空槽图标:原版头盔/胸甲/护腿/靴子(BLOCK_ATLAS 图集,同 WCWT 手动合成区做法)
|
||||
final net.minecraft.resources.ResourceLocation armorIcon = switch (i) {
|
||||
case 0 -> net.minecraft.world.inventory.InventoryMenu.EMPTY_ARMOR_SLOT_HELMET;
|
||||
case 1 -> net.minecraft.world.inventory.InventoryMenu.EMPTY_ARMOR_SLOT_CHESTPLATE;
|
||||
case 2 -> net.minecraft.world.inventory.InventoryMenu.EMPTY_ARMOR_SLOT_LEGGINGS;
|
||||
default -> net.minecraft.world.inventory.InventoryMenu.EMPTY_ARMOR_SLOT_BOOTS;
|
||||
final ResourceLocation armorIcon = switch (i) {
|
||||
case 0 -> InventoryMenu.EMPTY_ARMOR_SLOT_HELMET;
|
||||
case 1 -> InventoryMenu.EMPTY_ARMOR_SLOT_CHESTPLATE;
|
||||
case 2 -> InventoryMenu.EMPTY_ARMOR_SLOT_LEGGINGS;
|
||||
default -> InventoryMenu.EMPTY_ARMOR_SLOT_BOOTS;
|
||||
};
|
||||
addSlot(new SlotItemHandler(machineHandler, invIdx, ARMOR_X, ARMOR_Y + i * 18) {
|
||||
@Override public boolean mayPlace(ItemStack s) {
|
||||
if (s.getItem() instanceof IVisDiscountGear) return true;
|
||||
if (s.getItem() instanceof IWarpingGear) return true;
|
||||
if (s.getItem() instanceof net.minecraft.world.item.Equipable eqItem)
|
||||
if (s.getItem() instanceof Equipable eqItem)
|
||||
return eqItem.getEquipmentSlot() == eq;
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public com.mojang.datafixers.util.Pair<net.minecraft.resources.ResourceLocation, net.minecraft.resources.ResourceLocation> getNoItemIcon() {
|
||||
return com.mojang.datafixers.util.Pair.of(
|
||||
net.minecraft.world.inventory.InventoryMenu.BLOCK_ATLAS, armorIcon);
|
||||
public Pair<ResourceLocation, ResourceLocation> getNoItemIcon() {
|
||||
return Pair.of(
|
||||
InventoryMenu.BLOCK_ATLAS, armorIcon);
|
||||
}
|
||||
@Override public void setChanged() {
|
||||
super.setChanged();
|
||||
@@ -242,9 +250,9 @@ public class ContainerArcaneAssembler extends AbstractContainerMenu {
|
||||
}
|
||||
|
||||
private ItemStackHandler wrapMachineInventory() {
|
||||
final net.minecraft.world.SimpleContainer inv =
|
||||
final SimpleContainer inv =
|
||||
(assembler != null) ? assembler.getInternalInventory()
|
||||
: new net.minecraft.world.SimpleContainer(TileArcaneAssembler.SLOT_COUNT);
|
||||
: new SimpleContainer(TileArcaneAssembler.SLOT_COUNT);
|
||||
return new ItemStackHandler(inv.getContainerSize()) {
|
||||
@Override public int getSlots() { return inv.getContainerSize(); }
|
||||
@Override public ItemStack getStackInSlot(int slot) { return inv.getItem(slot); }
|
||||
@@ -288,14 +296,14 @@ public class ContainerArcaneAssembler extends AbstractContainerMenu {
|
||||
// 玩家背包 → 知识核心 → 护甲 → 速度卡 → 背包↔快捷栏
|
||||
boolean merged = false;
|
||||
|
||||
if (stack.is(thaumicenergistics.init.ModItems.KNOWLEDGE_CORE.get())) {
|
||||
if (stack.is(ModItems.KNOWLEDGE_CORE.get())) {
|
||||
merged = moveItemStackTo(stack, KCORE_IDX, KCORE_IDX + 1, false);
|
||||
}
|
||||
|
||||
if (!merged && (stack.getItem() instanceof IVisDiscountGear
|
||||
|| stack.getItem() instanceof IWarpingGear
|
||||
|| stack.getItem() instanceof net.minecraft.world.item.ArmorItem
|
||||
|| stack.getItem() instanceof net.minecraft.world.item.Equipable)) {
|
||||
|| stack.getItem() instanceof ArmorItem
|
||||
|| stack.getItem() instanceof Equipable)) {
|
||||
for (int a = 0; a < ARMOR_COUNT && !merged; a++) {
|
||||
Slot armorSlot = slots.get(ARMOR_START + a);
|
||||
if (armorSlot.mayPlace(stack) && !armorSlot.hasItem()) {
|
||||
|
||||
+51
-4
@@ -6,13 +6,11 @@ import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingInput;
|
||||
@@ -24,6 +22,7 @@ import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.stacks.AEItemKey;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.StorageHelper;
|
||||
import appeng.core.definitions.AEItems;
|
||||
import appeng.helpers.ICraftingGridMenu;
|
||||
import appeng.menu.SlotSemantics;
|
||||
import appeng.menu.guisync.GuiSync;
|
||||
@@ -34,17 +33,19 @@ import appeng.menu.slot.CraftingMatrixSlot;
|
||||
import appeng.me.storage.LinkStatusRespectingInventory;
|
||||
import appeng.util.inv.PlayerInternalInventory;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import thaumicenergistics.common.network.ArcaneTerminalClearC2SPacket;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.wands.WandCap;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import thaumcraft.common.items.TCFunctionalItems;
|
||||
import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager;
|
||||
import thaumcraft.common.vis.TCVisHelper;
|
||||
import thaumicenergistics.common.container.slot.ArcaneCraftingResultSlot;
|
||||
import thaumicenergistics.common.items.VisConnectorCardItem;
|
||||
import thaumicenergistics.common.items.WirelessArcaneCraftingTerminalMenuHost;
|
||||
import thaumicenergistics.common.parts.ArcaneCraftingTerminalPart;
|
||||
import thaumicenergistics.common.parts.ArcaneVisReplenish;
|
||||
import thaumicenergistics.init.ModMenuTypes;
|
||||
|
||||
public class ContainerArcaneCraftingTerminal extends MEStorageMenu implements ICraftingGridMenu {
|
||||
@@ -68,6 +69,28 @@ public class ContainerArcaneCraftingTerminal extends MEStorageMenu implements IC
|
||||
@Override
|
||||
public void broadcastChanges() {
|
||||
super.broadcastChanges();
|
||||
// 无线奥术合成终端(T-M3-VISCARD-REV):终端升级槽装有 vis 连接卡时自动充能——
|
||||
// 遍历所在网络全部要素中继接口(replenishAuto),无需频率/绑定;仅菜单打开期间驱动(D1)。
|
||||
if (!isClientSide()
|
||||
&& this.craftingInventoryHost instanceof WirelessArcaneCraftingTerminalMenuHost wirelessHost) {
|
||||
var upgrades = wirelessHost.getUpgrades();
|
||||
boolean hasVisCard = false;
|
||||
for (int i = 0; i < upgrades.size(); i++) {
|
||||
if (upgrades.getStackInSlot(i).getItem() instanceof VisConnectorCardItem) {
|
||||
hasVisCard = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasVisCard) {
|
||||
var node = wirelessHost.getActionableNode();
|
||||
var wandInv = wirelessHost.getSubInventory(ArcaneCraftingTerminalPart.INV_WAND);
|
||||
var wandStack = wandInv != null ? wandInv.getStackInSlot(0) : ItemStack.EMPTY;
|
||||
if (ArcaneVisReplenish.replenishAuto(
|
||||
node != null ? node.getGrid() : null, wandStack)) {
|
||||
wirelessHost.saveWandInv();
|
||||
}
|
||||
}
|
||||
}
|
||||
// vis 充能恢复后自动重算结果槽:结果槽空 + 奥术配方有效 + vis 已足够 → 重新显示产物。
|
||||
// 节流:仅"待恢复"状态每 10 tick 检查一次(findMatchingArcaneRecipe 只在满足时执行)
|
||||
var player = getPlayerInventory().player;
|
||||
@@ -136,6 +159,30 @@ public class ContainerArcaneCraftingTerminal extends MEStorageMenu implements IC
|
||||
}
|
||||
}, SlotSemantics.STORAGE);
|
||||
|
||||
// WTBRIDGE-SLOT:无线终端专属——量子缠绕奇点安装槽(桥卡链路第三环:奇点写入 UI)。
|
||||
// 有线部件宿主无此槽(instanceof 守卫);客户端/服务端 host 类型一致故槽集一致。
|
||||
// ae2wtlib 缺席时准入拦截(组件无处写回,防放入即丢);ae2 原生缠绕奇点直接编译引用。
|
||||
// 语义挂 AE2 原生 UPGRADE 组(注册顺序在基类 setupUpgrades 的升级卡槽之后)——右侧
|
||||
// 升级卡槽面板按 getSlots(UPGRADE) 挂单一 UpgradesPanel,奇点槽自动成为同面板第三格
|
||||
// (2 升级卡 + 1 奇点,一个整体)。注意:WACT host 非 IViewCellStorage,VIEW_CELL 组
|
||||
// 为空、其面板不挂载,槽挂该组将无人摆位;奇点槽仅语义归类,仍绑自有 singularityInv,
|
||||
// 升级库存读写(isInstalled 等)不受影响。
|
||||
if (this.craftingInventoryHost instanceof WirelessArcaneCraftingTerminalMenuHost wirelessHost) {
|
||||
var singularityInv = wirelessHost.getSubInventory(WirelessArcaneCraftingTerminalMenuHost.INV_SINGULARITY);
|
||||
this.addSlot(new AppEngSlot(singularityInv, 0) {
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return ModList.get().isLoaded(WirelessArcaneCraftingTerminalMenuHost.AE2WTLIB_MODID)
|
||||
&& stack.is(AEItems.QUANTUM_ENTANGLED_SINGULARITY.asItem());
|
||||
}
|
||||
}, SlotSemantics.UPGRADE);
|
||||
}
|
||||
|
||||
updateCurrentRecipeAndOutput(true);
|
||||
|
||||
registerClientAction(ACTION_CLEAR_TO_PLAYER, this::clearToPlayerInventory);
|
||||
|
||||
+10
-3
@@ -9,6 +9,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.neoforge.items.IItemHandler;
|
||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||
import net.neoforged.neoforge.items.ItemStackHandler;
|
||||
import net.neoforged.neoforge.items.SlotItemHandler;
|
||||
import appeng.api.upgrades.IUpgradeInventory;
|
||||
@@ -21,6 +22,7 @@ import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
import thaumicenergistics.common.items.ItemEssentiaCell;
|
||||
import thaumicenergistics.common.tiles.TileEssentiaCellWorkbench;
|
||||
import thaumicenergistics.init.ModMenuTypes;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
|
||||
/**
|
||||
* 源质元件工作台容器:cell 槽绑定到方块实体(持久化),并提供分区编辑操作。
|
||||
@@ -95,14 +97,19 @@ public class ContainerEssentiaCellWorkbench extends AbstractContainerMenu {
|
||||
return UpgradeInventories.empty();
|
||||
}
|
||||
|
||||
/** 把 AE2 InternalInventory(IUpgradeInventory)适配成 NeoForge IItemHandler,供 SlotItemHandler 使用。 */
|
||||
private static final class CellUpgradeHandler implements IItemHandler {
|
||||
/** 把 AE2 InternalInventory(IUpgradeInventory)适配成 NeoForge 可写句柄;SlotItemHandler.set 强转 Modifiable,缺它则客户端开 GUI 同步即 CCE。 */
|
||||
private static final class CellUpgradeHandler implements IItemHandlerModifiable {
|
||||
private final java.util.function.Supplier<IUpgradeInventory> supplier;
|
||||
|
||||
CellUpgradeHandler(java.util.function.Supplier<IUpgradeInventory> supplier) {
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStackInSlot(int slot, ItemStack stack) {
|
||||
supplier.get().setItemDirect(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
return supplier.get().size();
|
||||
@@ -135,7 +142,7 @@ public class ContainerEssentiaCellWorkbench extends AbstractContainerMenu {
|
||||
}
|
||||
|
||||
/** 客户端打开菜单用(IMenuTypeExtension 注册);workbench 为 null,分区操作走 C2S 到服务端。 */
|
||||
public ContainerEssentiaCellWorkbench(int id, Inventory inv, net.minecraft.network.RegistryFriendlyByteBuf buf) {
|
||||
public ContainerEssentiaCellWorkbench(int id, Inventory inv, RegistryFriendlyByteBuf buf) {
|
||||
this(id, inv);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.stacks.AEKey;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.KeyTypeSelection;
|
||||
import appeng.api.util.KeyTypeSelectionHost;
|
||||
import appeng.menu.SlotSemantics;
|
||||
import appeng.menu.guisync.GuiSync;
|
||||
import appeng.menu.implementations.UpgradeableMenu;
|
||||
import appeng.menu.interfaces.KeyTypeSelectionMenu;
|
||||
import appeng.menu.interfaces.KeyTypeSelectionMenu.SyncedKeyTypes;
|
||||
import appeng.menu.slot.FakeSlot;
|
||||
import thaumicenergistics.common.parts.EssentiaExportBusPart;
|
||||
import thaumicenergistics.init.ModMenuTypes;
|
||||
|
||||
public class ContainerEssentiaExportBus extends UpgradeableMenu<EssentiaExportBusPart>
|
||||
implements KeyTypeSelectionMenu {
|
||||
|
||||
@GuiSync(50)
|
||||
public long storedEnergy;
|
||||
|
||||
@GuiSync(51)
|
||||
public SyncedKeyTypes exportKeyTypes = new SyncedKeyTypes();
|
||||
|
||||
public ContainerEssentiaExportBus(int id, net.minecraft.world.entity.player.Inventory ip, EssentiaExportBusPart host) {
|
||||
super(ModMenuTypes.ESSENTIA_EXPORT_BUS.get(), id, ip, host);
|
||||
registerClientAction("clear", this::clear);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig() {
|
||||
var inv = getHost().getConfig().createMenuWrapper();
|
||||
for (int i = 0; i < 18; i++) {
|
||||
this.addSlot(new FakeSlot(inv, i), SlotSemantics.CONFIG);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(int idx) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadSettingsFromHost(IConfigManager cm) {
|
||||
if (cm.hasSetting(Settings.REDSTONE_CONTROLLED)) {
|
||||
this.setRedStoneMode(cm.getSetting(Settings.REDSTONE_CONTROLLED));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastChanges() {
|
||||
super.broadcastChanges();
|
||||
if (!isServerSide()) return;
|
||||
this.storedEnergy = getHost().getStoredEnergy();
|
||||
if (getHost() instanceof KeyTypeSelectionHost selectionHost) {
|
||||
var enabled = selectionHost.getKeyTypeSelection().enabled();
|
||||
if (!exportKeyTypes.keyTypes().equals(enabled)) {
|
||||
exportKeyTypes = new SyncedKeyTypes(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if (isClientSide()) {
|
||||
sendClientAction("clear");
|
||||
} else {
|
||||
getHost().getConfig().clear();
|
||||
}
|
||||
}
|
||||
|
||||
public AEKey getConfiguredKey(int slot) {
|
||||
return getHost().getConfig().getKey(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyTypeSelection getServerKeyTypeSelection() {
|
||||
return ((KeyTypeSelectionHost) getHost()).getKeyTypeSelection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SyncedKeyTypes getClientKeyTypeSelection() {
|
||||
return exportKeyTypes;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
|
||||
import appeng.api.util.KeyTypeSelectionHost;
|
||||
import appeng.core.definitions.AEItems;
|
||||
import appeng.menu.implementations.UpgradeableMenu;
|
||||
import appeng.menu.interfaces.KeyTypeSelectionMenu;
|
||||
import appeng.menu.interfaces.KeyTypeSelectionMenu.SyncedKeyTypes;
|
||||
import appeng.api.util.KeyTypeSelection;
|
||||
import thaumicenergistics.common.parts.EssentiaImportBusPart;
|
||||
|
||||
public class ContainerEssentiaImportBus extends UpgradeableMenu<EssentiaImportBusPart>
|
||||
implements KeyTypeSelectionMenu {
|
||||
|
||||
@appeng.menu.guisync.GuiSync(20)
|
||||
public SyncedKeyTypes importKeyTypes = new SyncedKeyTypes();
|
||||
|
||||
public ContainerEssentiaImportBus(MenuType<?> menuType, int id, Inventory ip, EssentiaImportBusPart host) {
|
||||
super(menuType, id, ip, host);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig() {
|
||||
addExpandableConfigSlots(getHost().getConfig(), 2, 9, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(int idx) {
|
||||
final int upgrades = getUpgrades().getInstalledUpgrades(AEItems.CAPACITY_CARD);
|
||||
return upgrades > idx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastChanges() {
|
||||
super.broadcastChanges();
|
||||
if (isServerSide()) {
|
||||
if (getHost() instanceof KeyTypeSelectionHost selectionHost) {
|
||||
var enabled = selectionHost.getKeyTypeSelection().enabled();
|
||||
if (!importKeyTypes.keyTypes().equals(enabled)) {
|
||||
importKeyTypes = new SyncedKeyTypes(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyTypeSelection getServerKeyTypeSelection() {
|
||||
return ((KeyTypeSelectionHost) getHost()).getKeyTypeSelection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SyncedKeyTypes getClientKeyTypeSelection() {
|
||||
return importKeyTypes;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package thaumicenergistics.common.container;
|
||||
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.stacks.AEKey;
|
||||
import appeng.api.util.IConfigManager;
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.stacks.AEKey;
|
||||
import appeng.api.stacks.GenericStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.definitions.AEItems;
|
||||
import appeng.menu.guisync.GuiSync;
|
||||
import appeng.menu.implementations.UpgradeableMenu;
|
||||
import thaumicenergistics.common.parts.EssentiaStorageBusPart;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 严格参照 AE2 StorageBusMenu。
|
||||
* 直接继承 UpgradeableMenu<EssentiaStorageBusPart>:getHost().getConfig()、getHost().getUpgrades()、getHost().getConfigManager()
|
||||
* 均来自 IOBusPart 原生实现,无需自行实现库存。
|
||||
*/
|
||||
public class ContainerEssentiaStorageBus extends UpgradeableMenu<EssentiaStorageBusPart> {
|
||||
|
||||
private static final String ACTION_CLEAR = "clear";
|
||||
private static final String ACTION_PARTITION = "partition";
|
||||
|
||||
@GuiSync(3)
|
||||
public AccessRestriction rwMode = AccessRestriction.READ_WRITE;
|
||||
@GuiSync(4)
|
||||
public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY;
|
||||
@GuiSync(7)
|
||||
public YesNo filterOnExtract = YesNo.YES;
|
||||
@GuiSync(8)
|
||||
public Component connectedTo;
|
||||
|
||||
public ContainerEssentiaStorageBus(MenuType<?> menuType, int id, Inventory ip, EssentiaStorageBusPart host) {
|
||||
super(menuType, id, ip, host);
|
||||
|
||||
registerClientAction(ACTION_CLEAR, this::clear);
|
||||
registerClientAction(ACTION_PARTITION, this::partition);
|
||||
|
||||
this.connectedTo = getConnectedDescription(host);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig() {
|
||||
// 2行固定实格 + 5行可选淡色虚格 = 63格,完全对齐 AE2 StorageBusMenu.setupConfig()
|
||||
addExpandableConfigSlots(getHost().getConfig(), 2, 9, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(int idx) {
|
||||
// 1张容量升级卡启用1行虚格(idx=第idx组可选行),和AE2一致
|
||||
final int upgrades = getUpgrades().getInstalledUpgrades(AEItems.CAPACITY_CARD);
|
||||
return upgrades > idx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastChanges() {
|
||||
super.broadcastChanges();
|
||||
this.connectedTo = getConnectedDescription(getHost());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadSettingsFromHost(IConfigManager cm) {
|
||||
this.setFuzzyMode(cm.getSetting(Settings.FUZZY_MODE));
|
||||
this.setReadWriteMode(cm.getSetting(Settings.ACCESS));
|
||||
this.setStorageFilter(cm.getSetting(Settings.STORAGE_FILTER));
|
||||
this.setFilterOnExtract(cm.getSetting(Settings.FILTER_ON_EXTRACT));
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if (isClientSide()) { sendClientAction(ACTION_CLEAR); return; }
|
||||
getHost().getConfig().clear();
|
||||
this.broadcastChanges();
|
||||
}
|
||||
|
||||
public void partition() {
|
||||
if (isClientSide()) { sendClientAction(ACTION_PARTITION); return; }
|
||||
var inv = getHost().getConfig();
|
||||
Iterator<AEKey> it = Collections.emptyIterator();
|
||||
|
||||
// ============= ✅ 修复3根因:IOBusPart 里没有叫 getInternalHandler() 的方法 =============
|
||||
// AE2 StorageBusPart extends IOBusPart implements IStorageProvider 自己加了 getInternalHandler
|
||||
// 我们的 EssentiaStorageBusPart 没有显式实现这个方法 → 反射软查,拿不到就跳过分区(不崩)
|
||||
Object storage = null;
|
||||
try {
|
||||
try {
|
||||
storage = getHost().getClass().getMethod("getInternalHandler").invoke(getHost());
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
storage = getHost().getClass().getMethod("getStorage").invoke(getHost());
|
||||
}
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
if (storage != null) {
|
||||
try {
|
||||
Object availableStacks = storage.getClass().getMethod("getAvailableStacks").invoke(storage);
|
||||
if (availableStacks instanceof Iterable<?> iter) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<AEKey> keyIt = ((Iterable<AEKey>) iter).iterator();
|
||||
it = keyIt;
|
||||
}
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
|
||||
inv.beginBatch();
|
||||
try {
|
||||
for (int x = 0; x < inv.size(); x++) {
|
||||
if (it.hasNext() && this.isSlotEnabled(x / 9 - 2)) {
|
||||
inv.setStack(x, new GenericStack(it.next(), 1));
|
||||
} else {
|
||||
inv.setStack(x, null);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
inv.endBatch();
|
||||
}
|
||||
this.broadcastChanges();
|
||||
}
|
||||
|
||||
public boolean supportsFuzzySearch() { return hasUpgrade(AEItems.FUZZY_CARD); }
|
||||
public AccessRestriction getReadWriteMode() { return this.rwMode; }
|
||||
private void setReadWriteMode(AccessRestriction v) { this.rwMode = v; }
|
||||
public StorageFilter getStorageFilter() { return this.storageFilter; }
|
||||
private void setStorageFilter(StorageFilter v) { this.storageFilter = v; }
|
||||
public YesNo getFilterOnExtract() { return this.filterOnExtract; }
|
||||
public void setFilterOnExtract(YesNo v) { this.filterOnExtract = v; }
|
||||
public Component getConnectedTo() { return connectedTo; }
|
||||
public FuzzyMode getFuzzyMode() { return this.fzMode; }
|
||||
|
||||
private static Component getConnectedDescription(EssentiaStorageBusPart p) {
|
||||
java.lang.reflect.Method m = METHOD_CACHE.computeIfAbsent(p.getClass(), c -> {
|
||||
try { return c.getMethod("getConnectedToDescription"); }
|
||||
catch (NoSuchMethodException e) { return NO_METHOD; }
|
||||
});
|
||||
if (m == NO_METHOD) return null;
|
||||
try {
|
||||
return (Component) m.invoke(p);
|
||||
} catch (Throwable t) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** 反射方法缓存哨兵:computeIfAbsent 返回非 null 才缓存(避免每次 getMethod)。 */
|
||||
private static final java.lang.reflect.Method NO_METHOD;
|
||||
|
||||
static {
|
||||
try {
|
||||
NO_METHOD = Object.class.getMethod("toString");
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/** 反射方法缓存:broadcastChanges 每 tick 调用 getConnectedDescription,避免每次 getMethod。 */
|
||||
private static final Map<Class<?>, java.lang.reflect.Method> METHOD_CACHE = new ConcurrentHashMap<>();
|
||||
}
|
||||
-1
@@ -2,7 +2,6 @@ package thaumicenergistics.common.container;
|
||||
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.neoforged.neoforge.items.ItemStackHandler;
|
||||
import net.neoforged.neoforge.items.SlotItemHandler;
|
||||
import thaumicenergistics.init.ModMenuTypes;
|
||||
|
||||
@@ -21,6 +21,7 @@ import thaumcraft.common.items.JarBlockItem;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
import thaumicenergistics.common.integration.tc.ThEEssentiaContainers;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
/**
|
||||
* 源质容器 ↔ ME 网络通用存取逻辑(服务端)。
|
||||
@@ -215,7 +216,7 @@ public final class EssentiaFillHelper {
|
||||
private static ItemStack filledPhialStack(String aspectTag) {
|
||||
ResourceLocation id = ResourceLocation.fromNamespaceAndPath(
|
||||
"thaumcraft", "phial_of_essentia_" + aspectTag);
|
||||
net.minecraft.world.item.Item item = BuiltInRegistries.ITEM.getOptional(id)
|
||||
Item item = BuiltInRegistries.ITEM.getOptional(id)
|
||||
.orElse(BuiltInRegistries.ITEM.get(
|
||||
ResourceLocation.fromNamespaceAndPath("thaumcraft", "glass_phial")));
|
||||
return new ItemStack(item);
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.menu.me.common.MEStorageMenu;
|
||||
|
||||
/**
|
||||
* 源质终端的菜单(有线端与无线端共用)。
|
||||
* <p>
|
||||
* 继承 AE2 原版 {@link MEStorageMenu} 的全部普通物品行为(左键/Shift+点击/拖拽均按普通物品处理)。
|
||||
* 源质的存入与取出统一由右键交互承担:
|
||||
* <ul>
|
||||
* <li>手持装有源质的罐子/安瓿 + 右键任意处 → 源质存入网络({@link EssentiaFillHelper#extractContainerContent})。</li>
|
||||
* <li>手持空罐/空安瓿 + 右键源质条目 → 从网络取出装罐({@link #fillContainerFromGrid})。</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class EssentiaTerminalMenu extends MEStorageMenu {
|
||||
|
||||
public EssentiaTerminalMenu(MenuType<?> menuType, int id, Inventory ip, ITerminalHost host) {
|
||||
super(menuType, id, ip, host);
|
||||
}
|
||||
|
||||
/**
|
||||
* 右键终端源质条目装罐:从网络提取源质,装入手持的源质罐子或玻璃安瓿。
|
||||
* 具体逻辑见 {@link EssentiaFillHelper#fillContainerFromGrid}。
|
||||
*
|
||||
* @param aspectId 源质 aspect 的 ResourceLocation
|
||||
* @return true = 处理成功(装罐/装安瓿),false = 无法处理
|
||||
*/
|
||||
public boolean fillContainerFromGrid(ResourceLocation aspectId) {
|
||||
if (isClientSide()) {
|
||||
return false;
|
||||
}
|
||||
var player = getPlayerInventory().player;
|
||||
var carried = getCarried();
|
||||
return EssentiaFillHelper.fillContainerFromGrid(
|
||||
this.storage, this.energySource, getActionSource(), player, carried, aspectId);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import net.minecraft.world.entity.player.Inventory;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.client.gui.widgets.ActionButton;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.menu.slot.AppEngCraftingSlot;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.client.gui.AspectGuiRenderer;
|
||||
import appeng.client.gui.me.common.MEStorageScreen;
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@ import net.minecraft.world.entity.player.Inventory;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.client.gui.AspectGuiRenderer;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class GuiDistillationPatternEncoder extends AbstractContainerScreen<ContainerDistillationPatternEncoder> {
|
||||
|
||||
@@ -54,7 +55,7 @@ public class GuiDistillationPatternEncoder extends AbstractContainerScreen<Conta
|
||||
// 按钮文字居中
|
||||
String s = this.getMessage().getString();
|
||||
if (!s.isEmpty()) {
|
||||
var font = net.minecraft.client.Minecraft.getInstance().font;
|
||||
var font = Minecraft.getInstance().font;
|
||||
int tw = font.width(s);
|
||||
g.drawString(font, s,
|
||||
this.getX() + (this.width - tw) / 2,
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.util.KeyTypeSelectionHost;
|
||||
import appeng.client.gui.implementations.UpgradeableScreen;
|
||||
import appeng.client.gui.style.ScreenStyle;
|
||||
import appeng.client.gui.widgets.KeyTypeSelectionButton;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.core.definitions.AEItems;
|
||||
import appeng.core.localization.GuiText;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
|
||||
public class GuiEssentiaExportBus extends UpgradeableScreen<ContainerEssentiaExportBus> {
|
||||
|
||||
private final SettingToggleButton<RedstoneMode> redstoneMode;
|
||||
private final SettingToggleButton<FuzzyMode> fuzzyMode;
|
||||
private final SettingToggleButton<YesNo> craftMode;
|
||||
private final SettingToggleButton<SchedulingMode> schedulingMode;
|
||||
|
||||
public GuiEssentiaExportBus(ContainerEssentiaExportBus menu, Inventory playerInventory,
|
||||
Component title, ScreenStyle style) {
|
||||
super(menu, playerInventory, title, style);
|
||||
|
||||
setTextContent("dialog_title", ModItems.ESSENTIA_EXPORT_BUS.get().getDescription());
|
||||
|
||||
if (menu.getHost() instanceof KeyTypeSelectionHost) {
|
||||
addToLeftToolbar(
|
||||
KeyTypeSelectionButton.create(this, menu.getHost(), GuiText.ConfigureImportedTypes.text()));
|
||||
}
|
||||
|
||||
this.redstoneMode = new ServerSettingToggleButton<>(Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
|
||||
addToLeftToolbar(this.redstoneMode);
|
||||
|
||||
this.fuzzyMode = new ServerSettingToggleButton<>(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
|
||||
addToLeftToolbar(this.fuzzyMode);
|
||||
|
||||
if (menu.getHost().getConfigManager().hasSetting(Settings.CRAFT_ONLY)) {
|
||||
this.craftMode = new ServerSettingToggleButton<>(Settings.CRAFT_ONLY, YesNo.NO);
|
||||
addToLeftToolbar(this.craftMode);
|
||||
} else {
|
||||
this.craftMode = null;
|
||||
}
|
||||
|
||||
if (menu.getHost().getConfigManager().hasSetting(Settings.SCHEDULING_MODE)) {
|
||||
this.schedulingMode = new ServerSettingToggleButton<>(Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT);
|
||||
addToLeftToolbar(this.schedulingMode);
|
||||
} else {
|
||||
this.schedulingMode = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateBeforeRender() {
|
||||
super.updateBeforeRender();
|
||||
this.redstoneMode.set(menu.getRedStoneMode());
|
||||
this.redstoneMode.setVisibility(menu.hasUpgrade(AEItems.REDSTONE_CARD));
|
||||
this.fuzzyMode.set(menu.getFuzzyMode());
|
||||
this.fuzzyMode.setVisibility(menu.hasUpgrade(AEItems.FUZZY_CARD));
|
||||
if (this.craftMode != null) {
|
||||
this.craftMode.set(menu.getCraftingMode());
|
||||
this.craftMode.setVisibility(menu.hasUpgrade(AEItems.CRAFTING_CARD));
|
||||
}
|
||||
if (this.schedulingMode != null) {
|
||||
this.schedulingMode.set(menu.getSchedulingMode());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.util.KeyTypeSelectionHost;
|
||||
import appeng.client.gui.implementations.UpgradeableScreen;
|
||||
import appeng.client.gui.style.ScreenStyle;
|
||||
import appeng.client.gui.widgets.KeyTypeSelectionButton;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.core.definitions.AEItems;
|
||||
import appeng.core.localization.GuiText;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
|
||||
public class GuiEssentiaImportBus extends UpgradeableScreen<ContainerEssentiaImportBus> {
|
||||
|
||||
private final SettingToggleButton<RedstoneMode> redstoneMode;
|
||||
private final SettingToggleButton<FuzzyMode> fuzzyMode;
|
||||
private final SettingToggleButton<YesNo> craftMode;
|
||||
|
||||
public GuiEssentiaImportBus(ContainerEssentiaImportBus menu, Inventory playerInventory,
|
||||
Component title, ScreenStyle style) {
|
||||
super(menu, playerInventory, title, style);
|
||||
|
||||
setTextContent("dialog_title", ModItems.ESSENTIA_IMPORT_BUS.get().getDescription());
|
||||
|
||||
if (menu.getHost() instanceof KeyTypeSelectionHost) {
|
||||
addToLeftToolbar(
|
||||
KeyTypeSelectionButton.create(this, menu.getHost(), GuiText.ConfigureImportedTypes.text()));
|
||||
}
|
||||
|
||||
this.redstoneMode = new ServerSettingToggleButton<>(Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
|
||||
addToLeftToolbar(this.redstoneMode);
|
||||
|
||||
this.fuzzyMode = new ServerSettingToggleButton<>(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
|
||||
addToLeftToolbar(this.fuzzyMode);
|
||||
|
||||
if (menu.getHost().getConfigManager().hasSetting(Settings.CRAFT_ONLY)) {
|
||||
this.craftMode = new ServerSettingToggleButton<>(Settings.CRAFT_ONLY, YesNo.NO);
|
||||
addToLeftToolbar(this.craftMode);
|
||||
} else {
|
||||
this.craftMode = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateBeforeRender() {
|
||||
super.updateBeforeRender();
|
||||
this.redstoneMode.set(menu.getRedStoneMode());
|
||||
this.redstoneMode.setVisibility(menu.hasUpgrade(AEItems.REDSTONE_CARD));
|
||||
this.fuzzyMode.set(menu.getFuzzyMode());
|
||||
this.fuzzyMode.setVisibility(menu.hasUpgrade(AEItems.FUZZY_CARD));
|
||||
if (this.craftMode != null) {
|
||||
this.craftMode.set(menu.getCraftingMode());
|
||||
this.craftMode.setVisibility(menu.hasUpgrade(AEItems.CRAFTING_CARD));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.client.gui.implementations.UpgradeableScreen;
|
||||
import appeng.client.gui.style.PaletteColor;
|
||||
import appeng.client.gui.style.ScreenStyle;
|
||||
import appeng.client.gui.widgets.ActionButton;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.core.definitions.AEItems;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.api.config.YesNo;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
|
||||
/**
|
||||
* 源质存储总线GUI。
|
||||
* 使用 AE2 原生 /screens/storage_bus.json(布局/工具栏/优先级按钮/尺寸完全一致),
|
||||
* 仅通过 setTextContent("dialog_title", ...) 覆盖标题为"源质存储总线"。
|
||||
*/
|
||||
public class GuiEssentiaStorageBus extends UpgradeableScreen<ContainerEssentiaStorageBus> {
|
||||
|
||||
private final SettingToggleButton<AccessRestriction> rwMode;
|
||||
private final SettingToggleButton<StorageFilter> storageFilter;
|
||||
private final SettingToggleButton<YesNo> filterOnExtract;
|
||||
private final SettingToggleButton<FuzzyMode> fuzzyMode;
|
||||
|
||||
public GuiEssentiaStorageBus(ContainerEssentiaStorageBus menu, Inventory playerInventory,
|
||||
Component title, ScreenStyle style) {
|
||||
super(menu, playerInventory, title, style);
|
||||
|
||||
// ✅ 覆盖JSON中的 dialog_title 文本(原本是 gui.ae2.StorageBus → "存储总线")
|
||||
setTextContent("dialog_title", ModItems.ESSENTIA_STORAGE_BUS.get().getDescription());
|
||||
|
||||
// 右上角优先级按钮(AE2原生JSON里定义了 openPriority widget)
|
||||
widgets.addOpenPriorityButton();
|
||||
|
||||
// 左侧工具栏:清空 / 分区(始终显示)
|
||||
addToLeftToolbar(new ActionButton(ActionItems.CLOSE, btn -> menu.clear()));
|
||||
addToLeftToolbar(new ActionButton(ActionItems.COG, btn -> menu.partition()));
|
||||
|
||||
// 存储过滤模式(始终显示)
|
||||
this.storageFilter = new ServerSettingToggleButton<>(Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
|
||||
this.addToLeftToolbar(this.storageFilter);
|
||||
|
||||
// 提取时应用过滤(始终显示)
|
||||
this.filterOnExtract = new ServerSettingToggleButton<>(Settings.FILTER_ON_EXTRACT, YesNo.YES);
|
||||
this.addToLeftToolbar(this.filterOnExtract);
|
||||
|
||||
// 模糊模式(需要模糊升级卡才显示)
|
||||
this.fuzzyMode = new ServerSettingToggleButton<>(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
|
||||
this.addToLeftToolbar(this.fuzzyMode);
|
||||
|
||||
// 读写访问模式(始终显示)
|
||||
this.rwMode = new ServerSettingToggleButton<>(Settings.ACCESS, AccessRestriction.READ_WRITE);
|
||||
this.addToLeftToolbar(this.rwMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateBeforeRender() {
|
||||
super.updateBeforeRender();
|
||||
this.storageFilter.set(this.menu.getStorageFilter());
|
||||
this.rwMode.set(this.menu.getReadWriteMode());
|
||||
this.filterOnExtract.set(this.menu.getFilterOnExtract());
|
||||
this.fuzzyMode.set(this.menu.getFuzzyMode());
|
||||
this.fuzzyMode.setVisibility(menu.hasUpgrade(AEItems.FUZZY_CARD));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(GuiGraphics guiGraphics, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
super.drawFG(guiGraphics, offsetX, offsetY, mouseX, mouseY);
|
||||
var poseStack = guiGraphics.pose();
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(10, 17, 0);
|
||||
poseStack.scale(0.6f, 0.6f, 1);
|
||||
int color = style.getColor(PaletteColor.DEFAULT_TEXT_COLOR).toARGB();
|
||||
if (menu.getConnectedTo() != null) {
|
||||
guiGraphics.drawString(font, GuiText.AttachedTo.text(menu.getConnectedTo()), 0, 0, color, false);
|
||||
} else {
|
||||
guiGraphics.drawString(font, GuiText.Unattached.text(), 0, 0, color, false);
|
||||
}
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import thaumicenergistics.common.integration.tc.ThEEssentiaContainers;
|
||||
|
||||
import appeng.client.gui.me.common.MEStorageScreen;
|
||||
import appeng.client.gui.style.ScreenStyle;
|
||||
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import thaumicenergistics.common.network.EssentiaTerminalDepositC2SPacket;
|
||||
import thaumicenergistics.common.network.EssentiaTerminalFillC2SPacket;
|
||||
|
||||
/**
|
||||
* 源质终端 GUI:在 AE2 通用终端基础上扩展右键交互。
|
||||
* <ul>
|
||||
* <li>Shift+右键玩家背包格:格内是源质容器 → 源质存入网络(空容器留原格)。</li>
|
||||
* <li>右键玩家物品栏/背包槽 → 放行(AE2 原版物品交互)。</li>
|
||||
* <li>右键网络区域(源质条目或空白),手持装有源质的罐子/安瓿 → 源质存入 ME 网络(空容器回背包)。</li>
|
||||
* <li>手持空罐/空安瓿 + 右键源质条目 → 从网络取出源质装罐/装安瓿。</li>
|
||||
* <li>左键仍是正常物品操作(不受影响)。</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class GuiEssentiaTerminal extends MEStorageScreen<EssentiaTerminalMenu> {
|
||||
|
||||
public GuiEssentiaTerminal(EssentiaTerminalMenu menu, Inventory playerInventory,
|
||||
Component title, ScreenStyle style) {
|
||||
super(menu, playerInventory, title, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double xCoord, double yCoord, int btn) {
|
||||
if (btn == 1) {
|
||||
var carried = this.menu.getCarried();
|
||||
boolean shiftDown = net.minecraft.client.gui.screens.inventory.AbstractContainerScreen.hasShiftDown();
|
||||
// 源质物品来源:优先菜单 carried;为空时回退玩家主手物品
|
||||
ItemStack sourceStack = !carried.isEmpty() ? carried
|
||||
: this.menu.getPlayerInventory().player.getMainHandItem();
|
||||
boolean isContainer = ThEEssentiaContainers.isEssentiaContainer(sourceStack);
|
||||
boolean containerHasEssentia = isContainer && ThEEssentiaContainers.hasEssentia(sourceStack);
|
||||
|
||||
// Shift+右键玩家物品栏/背包格:格内是源质容器 → 存入源质(空容器留原格)
|
||||
if (shiftDown && this.hoveredSlot != null && this.menu.isPlayerSideSlot(this.hoveredSlot)) {
|
||||
var slotStack = this.hoveredSlot.getItem();
|
||||
// 仅要素安瓿/要素罐子;天域之华等其余 IEssentiaContainerItem 一律放行
|
||||
if (ThEEssentiaContainers.isEssentiaContainer(slotStack)) {
|
||||
PacketDistributor.sendToServer(EssentiaTerminalDepositC2SPacket.fromSlot(
|
||||
this.menu.containerId, this.hoveredSlot.getSlotIndex(), slotStack));
|
||||
return true;
|
||||
}
|
||||
// 非源质容器 → 放行(AE2 原版 Shift+右键快速移动)
|
||||
return super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
// 普通右键点击玩家物品栏/背包槽 → 放行(AE2 原版物品交互)
|
||||
if (!shiftDown && this.hoveredSlot != null && this.menu.isPlayerSideSlot(this.hoveredSlot)) {
|
||||
return super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
// Shift+右键:手持源质容器(满或空)→ 拦截。满→存入源质;空→阻止被当普通物品放入网络
|
||||
if (shiftDown && isContainer) {
|
||||
if (containerHasEssentia) {
|
||||
this.menu.setCarried(net.minecraft.world.item.ItemStack.EMPTY);
|
||||
PacketDistributor.sendToServer(EssentiaTerminalDepositC2SPacket.fromClientStack(
|
||||
this.menu.containerId, sourceStack));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 普通右键网络区域:手持满容器 → 存入源质
|
||||
if (containerHasEssentia) {
|
||||
this.menu.setCarried(net.minecraft.world.item.ItemStack.EMPTY);
|
||||
PacketDistributor.sendToServer(EssentiaTerminalDepositC2SPacket.fromClientStack(
|
||||
this.menu.containerId, sourceStack));
|
||||
return true;
|
||||
}
|
||||
|
||||
// 手持空容器:右键源质条目 → 取出装罐;右键网络其他 → 拦截(防被放入网络)
|
||||
if (isContainer) {
|
||||
if (this.hoveredSlot instanceof appeng.client.gui.me.common.RepoSlot repoSlot) {
|
||||
var entry = repoSlot.getEntry();
|
||||
if (entry != null && entry.getWhat() instanceof thaumicenergistics.common.integration.appeng.AEssentiaKey key) {
|
||||
PacketDistributor.sendToServer(EssentiaTerminalFillC2SPacket.create(
|
||||
this.menu.containerId, key.getId(), sourceStack));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
/**
|
||||
* 知识记录仪 GUI。
|
||||
@@ -60,7 +61,7 @@ public class GuiKnowledgeInscriber extends AbstractContainerScreen<ContainerKnow
|
||||
// 按钮文字居中
|
||||
String s = this.getMessage().getString();
|
||||
if (!s.isEmpty()) {
|
||||
var font = net.minecraft.client.Minecraft.getInstance().font;
|
||||
var font = Minecraft.getInstance().font;
|
||||
int tw = font.width(s);
|
||||
g.drawString(font, s,
|
||||
this.getX() + (this.width - tw) / 2,
|
||||
|
||||
+18
-11
@@ -10,11 +10,18 @@ import appeng.api.storage.MEStorage;
|
||||
import appeng.helpers.ICraftingGridMenu;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.menu.slot.CraftingTermSlot;
|
||||
import appeng.util.inv.PlayerInternalInventory;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.items.TCFunctionalItems;
|
||||
import thaumicenergistics.common.container.ContainerArcaneCraftingTerminal;
|
||||
import appeng.api.stacks.AEItemKey;
|
||||
import appeng.api.storage.StorageHelper;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.CarriedItemInventory;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import thaumcraft.api.crafting.IArcaneRecipe;
|
||||
import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager;
|
||||
|
||||
/**
|
||||
* 奥术合成结果槽:继承 AE2 CraftingTermSlot 使客户端识别(shift/右键/space 合成自动生效),
|
||||
@@ -110,7 +117,7 @@ public class ArcaneCraftingResultSlot extends CraftingTermSlot {
|
||||
|
||||
// 用 Thaumcraft 奥术配方匹配(取配方对象以支持 retainIngredient 保留原料)
|
||||
var craftContainer = grid.toContainer();
|
||||
thaumcraft.api.crafting.IArcaneRecipe arcaneRecipe = thaumcraft.common.lib.crafting.ThaumcraftCraftingManager
|
||||
IArcaneRecipe arcaneRecipe = ThaumcraftCraftingManager
|
||||
.findMatchingArcaneRecipeEntry(craftContainer, who);
|
||||
if (arcaneRecipe == null) {
|
||||
return;
|
||||
@@ -121,7 +128,7 @@ public class ArcaneCraftingResultSlot extends CraftingTermSlot {
|
||||
}
|
||||
// 保留原料(retainIngredient,如元始珍珠):getRemainingItems 返回非空栈的槽位不消耗。
|
||||
// 对应 TC 奥术工作台行为——珍珠作为"催化"留在合成格,仅消耗构材与虚空金属锭。
|
||||
net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> remainders =
|
||||
NonNullList<net.minecraft.world.item.ItemStack> remainders =
|
||||
arcaneRecipe.getRemainingItems(craftContainer);
|
||||
|
||||
|
||||
@@ -132,10 +139,10 @@ public class ArcaneCraftingResultSlot extends CraftingTermSlot {
|
||||
target = new appeng.util.inv.PlayerInternalInventory(who.getInventory());
|
||||
maxTimesToCraft = (int) Math.floor((double) arcaneResult.getMaxStackSize() / (double) arcaneResult.getCount());
|
||||
if (action == InventoryAction.CRAFT_ALL) {
|
||||
maxTimesToCraft *= net.minecraft.world.entity.player.Inventory.INVENTORY_SIZE;
|
||||
maxTimesToCraft *= Inventory.INVENTORY_SIZE;
|
||||
}
|
||||
} else {
|
||||
target = new appeng.util.inv.CarriedItemInventory(getMenu());
|
||||
target = new CarriedItemInventory(getMenu());
|
||||
maxTimesToCraft = 1;
|
||||
}
|
||||
|
||||
@@ -159,7 +166,7 @@ public class ArcaneCraftingResultSlot extends CraftingTermSlot {
|
||||
break;
|
||||
}
|
||||
// 合成前检查奥术配方仍匹配
|
||||
ItemStack currentResult = thaumcraft.common.lib.crafting.ThaumcraftCraftingManager
|
||||
ItemStack currentResult = ThaumcraftCraftingManager
|
||||
.findMatchingArcaneRecipe(grid.toContainer(), who);
|
||||
if (currentResult.isEmpty()) {
|
||||
break;
|
||||
@@ -185,9 +192,9 @@ public class ArcaneCraftingResultSlot extends CraftingTermSlot {
|
||||
var currentItem = grid.getStackInSlot(slot);
|
||||
if (currentItem.getCount() < beforeItem.getCount()) {
|
||||
long needed = beforeItem.getCount() - currentItem.getCount();
|
||||
var key = appeng.api.stacks.AEItemKey.of(beforeItem);
|
||||
var key = AEItemKey.of(beforeItem);
|
||||
if (key != null) {
|
||||
long extracted = appeng.api.storage.StorageHelper.poweredExtraction(
|
||||
long extracted = StorageHelper.poweredExtraction(
|
||||
energySrc, storage, key, needed, mySrc);
|
||||
if (extracted > 0) {
|
||||
grid.setItemDirect(slot, beforeItem.copyWithCount(
|
||||
@@ -201,7 +208,7 @@ public class ArcaneCraftingResultSlot extends CraftingTermSlot {
|
||||
// 产物入目标
|
||||
var extra = target.addItems(arcaneResult.copy());
|
||||
if (!extra.isEmpty()) {
|
||||
appeng.util.Platform.spawnDrops(who.level(), who.blockPosition(), java.util.List.of(extra));
|
||||
Platform.spawnDrops(who.level(), who.blockPosition(), java.util.List.of(extra));
|
||||
break;
|
||||
}
|
||||
crafted++;
|
||||
@@ -246,9 +253,9 @@ public class ArcaneCraftingResultSlot extends CraftingTermSlot {
|
||||
var currentItem = grid.getStackInSlot(slot);
|
||||
if (currentItem.getCount() < beforeItem.getCount()) {
|
||||
long needed = beforeItem.getCount() - currentItem.getCount();
|
||||
var key = appeng.api.stacks.AEItemKey.of(beforeItem);
|
||||
var key = AEItemKey.of(beforeItem);
|
||||
if (key != null) {
|
||||
long extracted = appeng.api.storage.StorageHelper.poweredExtraction(
|
||||
long extracted = StorageHelper.poweredExtraction(
|
||||
energySrc, storage, key, needed, mySrc);
|
||||
if (extracted > 0) {
|
||||
grid.setItemDirect(slot, beforeItem.copyWithCount(
|
||||
|
||||
@@ -6,6 +6,8 @@ import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import appeng.items.parts.FacadeItem;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
/**
|
||||
* AE2 Facade → 背包皮肤映射。
|
||||
@@ -69,8 +71,8 @@ public final class FacadeToSkinMapping {
|
||||
|
||||
// 2) AE2 Facade 物品:尝试通过 IFacadeItem 接口获取纹理方块
|
||||
try {
|
||||
if (stack.getItem() instanceof appeng.items.parts.FacadeItem facadeItem) {
|
||||
net.minecraft.world.level.block.state.BlockState state = facadeItem.getTextureBlockState(stack);
|
||||
if (stack.getItem() instanceof FacadeItem facadeItem) {
|
||||
BlockState state = facadeItem.getTextureBlockState(stack);
|
||||
if (state != null) {
|
||||
return state.getBlock();
|
||||
}
|
||||
|
||||
@@ -19,11 +19,15 @@ import thaumcraft.common.entities.golem.ThaumcraftGolemEntity;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.items.ItemGolemWirelessBackpack;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
import appeng.api.ids.AEComponents;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import thaumcraft.common.items.GolemBellItem;
|
||||
import thaumicenergistics.common.network.GolemBackpackSyncPacket;
|
||||
|
||||
/**
|
||||
* 傀儡无线背包处理器:装备/拆卸/Facade 皮肤更换。
|
||||
* 对应 1.7.10 的 {@code WirelessGolemHandler} 中装备/Facade 交互部分。
|
||||
* 网络同步由 {@link thaumicenergistics.common.network.GolemBackpackSyncPacket} 处理。
|
||||
* 网络同步由 {@link GolemBackpackSyncPacket} 处理。
|
||||
*/
|
||||
@EventBusSubscriber(modid = ThaumicEnergistics.MODID)
|
||||
public final class GolemBackpackHandler {
|
||||
@@ -68,7 +72,7 @@ public final class GolemBackpackHandler {
|
||||
}
|
||||
|
||||
// 2) 手持 Golem 铃铛 + 蹲下 → 拆卸背包
|
||||
if (held.getItem() instanceof thaumcraft.common.items.GolemBellItem) {
|
||||
if (held.getItem() instanceof GolemBellItem) {
|
||||
if (event.getLevel().isClientSide()) {
|
||||
return;
|
||||
}
|
||||
@@ -135,7 +139,7 @@ public final class GolemBackpackHandler {
|
||||
}
|
||||
|
||||
ItemStack backpackStack = new ItemStack(ModItems.GOLEM_WIFI_BACKPACK.get());
|
||||
backpackStack.set(appeng.api.ids.AEComponents.WIRELESS_LINK_TARGET, linkedPos);
|
||||
backpackStack.set(AEComponents.WIRELESS_LINK_TARGET, linkedPos);
|
||||
golem.spawnAtLocation(backpackStack);
|
||||
|
||||
// 丢弃旧 Facade(如果有)
|
||||
@@ -252,7 +256,7 @@ public final class GolemBackpackHandler {
|
||||
* 保存 Facade 物品到 NBT。
|
||||
*/
|
||||
public static void setFacadeItem(ThaumcraftGolemEntity golem, ItemStack facade) {
|
||||
var encoded = (net.minecraft.nbt.CompoundTag) facade.save(golem.level().registryAccess());
|
||||
var encoded = (CompoundTag) facade.save(golem.level().registryAccess());
|
||||
golem.getPersistentData().put(NBT_KEY_FACADE, encoded);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
import thaumicenergistics.common.network.GolemBackpackSyncPacket;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import thaumcraft.api.aspects.IEssentiaContainerItem;
|
||||
|
||||
/**
|
||||
* 傀儡背包无线网络交互的 Tick 驱动 AI。
|
||||
@@ -258,7 +261,7 @@ public final class GolemBackpackTickHandler {
|
||||
ItemStack filter = golem.getFilter(slot);
|
||||
if (filter.isEmpty()) continue;
|
||||
|
||||
var fluidHandler = filter.getCapability(net.neoforged.neoforge.capabilities.Capabilities.FluidHandler.ITEM);
|
||||
var fluidHandler = filter.getCapability(Capabilities.FluidHandler.ITEM);
|
||||
if (fluidHandler == null) continue;
|
||||
|
||||
for (int tank = 0; tank < fluidHandler.getTanks(); tank++) {
|
||||
@@ -289,7 +292,7 @@ public final class GolemBackpackTickHandler {
|
||||
int amount = golem.essentiaAmount();
|
||||
|
||||
if (aspect != null && amount > 0) {
|
||||
net.minecraft.resources.ResourceLocation aspectId = TCReflection.getAspectId(aspect);
|
||||
ResourceLocation aspectId = TCReflection.getAspectId(aspect);
|
||||
int deposited = link.depositEssentia(aspectId, amount);
|
||||
if (deposited > 0) {
|
||||
int remaining = amount - deposited;
|
||||
@@ -303,12 +306,12 @@ public final class GolemBackpackTickHandler {
|
||||
ItemStack filter = golem.getFilter(slot);
|
||||
if (filter.isEmpty()) continue;
|
||||
|
||||
if (filter.getItem() instanceof thaumcraft.api.aspects.IEssentiaContainerItem containerItem) {
|
||||
if (filter.getItem() instanceof IEssentiaContainerItem containerItem) {
|
||||
AspectList aspectList = containerItem.getAspects(filter);
|
||||
if (aspectList == null || aspectList.size() == 0) continue;
|
||||
|
||||
for (Aspect filterAspect : aspectList.getAspects()) {
|
||||
net.minecraft.resources.ResourceLocation aspectId = TCReflection.getAspectId(filterAspect);
|
||||
ResourceLocation aspectId = TCReflection.getAspectId(filterAspect);
|
||||
int requestAmount = Math.min(golem.carryLimit(), WirelessAELinkGolem.getMaxEssentiaRate(golem));
|
||||
int extracted = link.extractEssentia(aspectId, requestAmount);
|
||||
if (extracted > 0) {
|
||||
|
||||
@@ -16,10 +16,11 @@ import appeng.blockentity.networking.WirelessAccessPointBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
import net.neoforged.neoforge.fluids.FluidStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.entities.golem.ThaumcraftGolemEntity;
|
||||
|
||||
import java.util.Set;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import thaumicenergistics.api.grid.IEssentiaGrid;
|
||||
|
||||
/**
|
||||
* 傀儡与 AE2 无线网络的连接桥。
|
||||
@@ -160,10 +161,10 @@ public class WirelessAELinkGolem {
|
||||
// ==================== 源质网络操作 ====================
|
||||
|
||||
@Nullable
|
||||
public thaumicenergistics.api.grid.IEssentiaGrid getEssentiaGrid() {
|
||||
public IEssentiaGrid getEssentiaGrid() {
|
||||
IGrid grid = getGrid();
|
||||
if (grid == null) return null;
|
||||
return grid.getService(thaumicenergistics.api.grid.IEssentiaGrid.class);
|
||||
return grid.getService(IEssentiaGrid.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +175,7 @@ public class WirelessAELinkGolem {
|
||||
* @return 实际提取的量
|
||||
*/
|
||||
public int extractEssentia(net.minecraft.resources.ResourceLocation aspectId, int maxAmount) {
|
||||
thaumicenergistics.api.grid.IEssentiaGrid essentiaGrid = getEssentiaGrid();
|
||||
IEssentiaGrid essentiaGrid = getEssentiaGrid();
|
||||
if (essentiaGrid == null) return 0;
|
||||
if (actionSource == null) return 0;
|
||||
|
||||
@@ -191,7 +192,7 @@ public class WirelessAELinkGolem {
|
||||
* @return 实际存入的量
|
||||
*/
|
||||
public int depositEssentia(net.minecraft.resources.ResourceLocation aspectId, int amount) {
|
||||
thaumicenergistics.api.grid.IEssentiaGrid essentiaGrid = getEssentiaGrid();
|
||||
IEssentiaGrid essentiaGrid = getEssentiaGrid();
|
||||
if (essentiaGrid == null) return 0;
|
||||
if (actionSource == null) return 0;
|
||||
|
||||
@@ -236,7 +237,7 @@ public class WirelessAELinkGolem {
|
||||
cachedAccessPoint = accessPoint;
|
||||
|
||||
// 创建 ActionSource:使用 AP 作为 MachineSource
|
||||
if (accessPoint instanceof appeng.api.networking.security.IActionHost actionHost) {
|
||||
if (accessPoint instanceof IActionHost actionHost) {
|
||||
actionSource = IActionSource.ofMachine(actionHost);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
package thaumicenergistics.common.parts;
|
||||
package thaumicenergistics.common.essentia.capability;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
@@ -23,6 +23,9 @@ import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
* 把相邻源质容器(要素罐子 / 奥术蒸馏器 / 荒古炼金炉 / 源质管道)包装成 {@link MEStorage},
|
||||
* 供源质存储总线通过 {@code IStorageProvider.mountInventories} 挂载到网络。
|
||||
* <p>
|
||||
* 源质「挂载存储」能力的实现载体:构造只依赖一个取相邻方块实体的 {@link Supplier},
|
||||
* 因此可被既有存储总线与后续升级卡挂载宿主复用,不绑定到具体总线实现。
|
||||
* <p>
|
||||
* 容器内容始终实时读取(不缓存),因此终端、子网、输入/输出总线看到的都是当前存量。
|
||||
*/
|
||||
public class EssentiaContainerStorage implements MEStorage {
|
||||
@@ -0,0 +1,113 @@
|
||||
package thaumicenergistics.common.essentia.capability;
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.IEssentiaTransport;
|
||||
import thaumicenergistics.api.storage.AspectStack;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
|
||||
/**
|
||||
* 源质搬运能力:把源质输入 / 输出总线的搬运核心算法抽取为无状态、可复用的操作,
|
||||
* 供既有三总线与后续「源质访问卡」共用(升级卡挂到 AE2 宿主后调用同一套逻辑)。
|
||||
* <p>
|
||||
* 本类只负责「一次搬运」的算法,不含 tick 调度、GUI、配置栏、能量结算等宿主相关逻辑;
|
||||
* 调用方自行提供速率、记能量账、持久化缓冲。依赖方向单向向下(AE2 / TC 集成层),
|
||||
* 不反向依赖菜单 / 客户端表现层。
|
||||
*/
|
||||
public final class EssentiaTransfer {
|
||||
|
||||
private EssentiaTransfer() {}
|
||||
|
||||
/**
|
||||
* 容器 → 网络 的搬运产物。
|
||||
*
|
||||
* @param moved 实际注入 AE 网络的源质量
|
||||
* @param leftover 已从容器抽出、但本网络装不下的源质(调用方须暂存重试,不得丢弃;无残留时为 {@link AspectStack#EMPTY})
|
||||
*/
|
||||
public record Pull(long moved, AspectStack leftover) {
|
||||
/** 无搬运(未抽到 / 网络拒收 / 参数非法)。 */
|
||||
public static final Pull NONE = new Pull(0, AspectStack.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从相邻源质容器抽取一次源质并入网(原源质输入总线逻辑,逐行等价)。
|
||||
* <p>
|
||||
* 顺序:非破坏性窥视 → 模拟入网测容量 → 定向抽取 → 实插;
|
||||
* 模拟与实插量不一致(例如挂载的容器存储无法模拟)时,把残留交回调用方缓冲重试。
|
||||
*
|
||||
* @param container 被抽取的源质容器(要素罐子 / 奥术蒸馏器 / 荒古炼金炉 / 源质管道)
|
||||
* @param grid 目标 ME 网络
|
||||
* @param source 操作源(入网记账用)
|
||||
* @param rate 单次最大搬运量
|
||||
* @return 搬运产物;无搬运时为 {@link Pull#NONE}
|
||||
*/
|
||||
public static Pull pull(@Nullable BlockEntity container, IGrid grid, IActionSource source, int rate) {
|
||||
if (container == null || rate <= 0) return Pull.NONE;
|
||||
|
||||
// 1) 非破坏性预检:先窥视容器能给什么(无源质直接退出)
|
||||
AspectStack available = TCReflection.peekEssentia(container, rate);
|
||||
if (available == null || available.isEmpty()) return Pull.NONE;
|
||||
AEssentiaKey key = AEssentiaKey.of(available.aspectId());
|
||||
if (key == null) return Pull.NONE;
|
||||
|
||||
// 2) 预检网络能接收多少;为 0(无源质存储 / 已满)则完全不抽取
|
||||
long acceptable = grid.getStorageService().getInventory().insert(
|
||||
key, available.amount(), Actionable.SIMULATE, source);
|
||||
if (acceptable <= 0) return Pull.NONE;
|
||||
|
||||
// 3) 定向抽取(取「容器能给」与「网络能收」的较小值)
|
||||
int toExtract = (int) Math.min(available.amount(), acceptable);
|
||||
AspectStack extracted = TCReflection.extractEssentia(container, available.aspectId(), toExtract);
|
||||
if (extracted == null || extracted.isEmpty()) return Pull.NONE;
|
||||
|
||||
// 4) 实插;模拟与实插不一致时残留交回调用方缓冲重试,绝不归还 / 丢弃
|
||||
long injected = grid.getStorageService().getInventory().insert(
|
||||
key, extracted.amount(), Actionable.MODULATE, source);
|
||||
AspectStack leftover = injected < extracted.amount()
|
||||
? new AspectStack(extracted.aspectId(), extracted.amount() - injected)
|
||||
: AspectStack.EMPTY;
|
||||
return new Pull(injected, leftover);
|
||||
}
|
||||
|
||||
/**
|
||||
* 网络 → 容器 的搬运:从网络定向抽取源质注入相邻容器(原源质输出总线逻辑,逐行等价)。
|
||||
* <p>
|
||||
* 注入失败或只注入了一部分时,未注入部分会回滚回网络,绝不凭空消失。
|
||||
*
|
||||
* @param container 接收源质的相邻方块(罐子 / 蒸馏器 / 荒古炼金炉,或 TC 源质管道)
|
||||
* @param accessSide 容器接收面的朝向(TC 管道 {@code addEssentia} 需要;可空)
|
||||
* @return 实际注入容器的源质量;0 表示本次无搬运(调用方据此判「无所作为」)
|
||||
*/
|
||||
public static long push(IGrid grid, IActionSource source, @Nullable AEssentiaKey key, long amount,
|
||||
@Nullable BlockEntity container, @Nullable Direction accessSide) {
|
||||
if (container == null || key == null || amount <= 0) return 0;
|
||||
|
||||
long extracted = grid.getStorageService().getInventory().extract(
|
||||
key, amount, Actionable.MODULATE, source);
|
||||
if (extracted <= 0) return 0;
|
||||
|
||||
// 先按 IAspectContainer 注入,失败再回退 TC 源质管道接口
|
||||
int injected = TCReflection.insertEssentia(container, new AspectStack(key.getId(), extracted));
|
||||
if (injected <= 0 && container instanceof IEssentiaTransport transport) {
|
||||
Aspect aspect = TCReflection.findAspectById(key.getId());
|
||||
if (aspect != null) {
|
||||
int want = (int) Math.min(extracted, Integer.MAX_VALUE);
|
||||
injected = transport.addEssentia(aspect, want, accessSide);
|
||||
}
|
||||
}
|
||||
if (injected < extracted) {
|
||||
// 退回未注入的部分
|
||||
grid.getStorageService().getInventory().insert(
|
||||
key, extracted - injected, Actionable.MODULATE, source);
|
||||
}
|
||||
return injected;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package thaumicenergistics.common.essentia.capability;
|
||||
|
||||
import thaumicenergistics.api.storage.AspectStack;
|
||||
import thaumicenergistics.mixins.ae2.bus.MixinIOBusPart;
|
||||
|
||||
/**
|
||||
* 卡路径(AE2 原版导入总线插卡)源质「抽取缓冲」的承载接口(鸭子接口,T-M1-007-⑦a 使用)。
|
||||
* <p>
|
||||
* 抽取顺序沿用 T-M1 批次对齐的原 ThE 导入总线(T-M2-REMOVE 已删):非破坏性窥视 → 模拟入网测容量 →
|
||||
* 定向抽取 → 实插。当「模拟能收」与「实插实际收到」不一致(例如网络里挂载的容器存储无法如实模拟)时,
|
||||
* 已从容器抽出但未入网的源质必须暂存重试,<b>绝不丢弃</b>。
|
||||
* <p>
|
||||
* 该状态由 {@code MixinIOBusPart} 注入到 AE2 原版
|
||||
* {@code IOBusPart}(导入/导出总线共用父类)上实现,随宿主自身 NBT 持久化。使用<b>独立 NBT 键</b>
|
||||
* (见 {@link #NBT_KEY_ASPECT}),不与宿主原有 NBT 键冲突。
|
||||
*/
|
||||
public interface EssentiaTransferBuffer {
|
||||
|
||||
/** 宿主 NBT 键:缓冲源质要素 id({@code StringTag})。 */
|
||||
String NBT_KEY_ASPECT = "ThECardBufferAspect";
|
||||
|
||||
/** 宿主 NBT 键:缓冲源质量({@code LongTag});键缺失或 ≤ 0 视为无缓冲。 */
|
||||
String NBT_KEY_AMOUNT = "ThECardBufferAmount";
|
||||
|
||||
/** 当前抽取缓冲(无缓冲时返回 {@link AspectStack#EMPTY})。 */
|
||||
AspectStack thE$getTransferBuffer();
|
||||
|
||||
/** 覆盖式写入抽取缓冲({@code null} 视为清空),并触发宿主落盘。 */
|
||||
void thE$setTransferBuffer(AspectStack buffer);
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
package thaumicenergistics.common.features;
|
||||
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import thaumcraft.api.ThaumcraftApi;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
@@ -20,6 +17,7 @@ import thaumcraft.common.vis.TCVisHelper;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.init.ModBlocks;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
|
||||
public final class RecipeRegistration {
|
||||
private RecipeRegistration() {}
|
||||
@@ -39,16 +37,14 @@ public final class RecipeRegistration {
|
||||
public static ShapedArcaneRecipe KNOWLEDGE_CORE_ITEM;
|
||||
public static ShapedArcaneRecipe FOCUS_AEWRENCH_RECIPE;
|
||||
public static ShapedArcaneRecipe GOLEM_WIFI_BACKPACK_RECIPE;
|
||||
public static ShapedArcaneRecipe ESSENTIA_IMPORT_BUS;
|
||||
public static ShapedArcaneRecipe ESSENTIA_EXPORT_BUS;
|
||||
public static ShapedArcaneRecipe ESSENTIA_STORAGE_BUS;
|
||||
public static ShapedArcaneRecipe KNOWLEDGE_INSCRIBER_BLOCK;
|
||||
public static ShapedArcaneRecipe DISTILLATION_ENCODER_BLOCK;
|
||||
// 奥术无序配方
|
||||
public static ShapelessArcaneRecipe DIFFUSION_CORE;
|
||||
public static ShapelessArcaneRecipe COALESCENCE_CORE;
|
||||
public static ShapelessArcaneRecipe ESSENTIA_LEVEL_EMITTER;
|
||||
public static ShapelessArcaneRecipe ESSENTIA_TERMINAL;
|
||||
/** 无线奥术合成终端(T-RESEARCH-B4:原 vanilla 无序改奥术无序,研究键挂自身节点)。 */
|
||||
public static ShapelessArcaneRecipe WIRELESS_ARCANE_CRAFTING_TERMINAL;
|
||||
public static ShapelessArcaneRecipe ARCANE_CRAFTING_TERMINAL;
|
||||
public static ShapelessArcaneRecipe VIS_INTERFACE;
|
||||
public static ShapelessArcaneRecipe ESSENTIA_VIBRATION_CHAMBER;
|
||||
@@ -56,6 +52,12 @@ public final class RecipeRegistration {
|
||||
public static ShapelessArcaneRecipe ESSENTIA_PROVIDER_CONNECTION;
|
||||
/** 源质无线绑定工具(无序奥术)。 */
|
||||
public static ShapelessArcaneRecipe WIRELESS_CONNECTOR;
|
||||
/** vis 连接卡(无序奥术,T-M3-RECIPE:无线奥术合成终端绑定用卡)。 */
|
||||
public static ShapelessArcaneRecipe VIS_CONNECTOR_CARD;
|
||||
/** 源质访问卡注魔(T-RESEARCH-B2:落字段供研究页引用)。 */
|
||||
public static InfusionRecipe ESSENTIA_UPGRADE_CARD;
|
||||
/** 概率之脑注魔(T-M6-RECIPE-2:照 CE gacha_box 移植到 port.261 物品体系,落字段供研究页引用)。 */
|
||||
public static InfusionRecipe GACHA_BOX;
|
||||
/** 赛特斯石英复制(坩埚炼金配方——研究页关联)。 */
|
||||
public static CrucibleRecipe CERTUS_DUPE_RECIPE;
|
||||
|
||||
@@ -161,38 +163,6 @@ public final class RecipeRegistration {
|
||||
'f', ae("fluix_crystal"),
|
||||
'C', ae("charger"));
|
||||
|
||||
ESSENTIA_IMPORT_BUS = ThaumcraftApi.addArcaneCraftingRecipe("ESSENTIABUSES", stack(ModItems.ESSENTIA_IMPORT_BUS),
|
||||
new AspectList().add(Aspect.FIRE, 2).add(Aspect.EARTH, 2).add(Aspect.WATER, 1),
|
||||
// 注意:TC ShapedArcaneRecipe 要求模式为矩形(各行等长),删 J 后必须补空格占位
|
||||
"JD ",
|
||||
"IFI",
|
||||
" ",
|
||||
'J', tc("jar_of_essentia"),
|
||||
'D', stack(ModItems.DIFFUSION_CORE),
|
||||
'I', new ItemStack(Items.IRON_INGOT, 1),
|
||||
'F', tc("essentia_filter"));
|
||||
|
||||
ESSENTIA_EXPORT_BUS = ThaumcraftApi.addArcaneCraftingRecipe("ESSENTIABUSES", stack(ModItems.ESSENTIA_EXPORT_BUS),
|
||||
new AspectList().add(Aspect.FIRE, 2).add(Aspect.EARTH, 2).add(Aspect.WATER, 1),
|
||||
"JC ",
|
||||
"IFI",
|
||||
" ",
|
||||
'J', tc("jar_of_essentia"),
|
||||
'C', stack(ModItems.COALESCENCE_CORE),
|
||||
'I', new ItemStack(Items.IRON_INGOT, 1),
|
||||
'F', tc("essentia_filter"));
|
||||
|
||||
ESSENTIA_STORAGE_BUS = ThaumcraftApi.addArcaneCraftingRecipe("ESSENTIABUSES", stack(ModItems.ESSENTIA_STORAGE_BUS),
|
||||
new AspectList().add(Aspect.EARTH, 3).add(Aspect.FIRE, 3).add(Aspect.WATER, 3),
|
||||
"DCF",
|
||||
"IGI",
|
||||
" ",
|
||||
'D', stack(ModItems.DIFFUSION_CORE),
|
||||
'C', stack(ModItems.COALESCENCE_CORE),
|
||||
'F', tc("essentia_filter"),
|
||||
'I', new ItemStack(Items.IRON_INGOT, 1),
|
||||
'G', ae("quartz_glass"));
|
||||
|
||||
KNOWLEDGE_INSCRIBER_BLOCK = ThaumcraftApi.addArcaneCraftingRecipe("KNOWLEDGEINSCRIBER", stack(ModBlocks.KNOWLEDGE_INSCRIBER),
|
||||
new AspectList().add(Aspect.WATER, 5).add(Aspect.EARTH, 5).add(Aspect.FIRE, 5).add(Aspect.AIR, 5).add(Aspect.ORDER, 5).add(Aspect.ENTROPY, 5),
|
||||
"ILI",
|
||||
@@ -236,23 +206,14 @@ public final class RecipeRegistration {
|
||||
tc("order_shard"),
|
||||
ae("formation_core"));
|
||||
|
||||
// 3. 原质等级发射器
|
||||
ESSENTIA_LEVEL_EMITTER = ThaumcraftApi.addShapelessArcaneCraftingRecipe("ESSENTIATERMINAL", new ItemStack(ModItems.ESSENTIA_LEVEL_EMITTER.get(), 1),
|
||||
// 3. 原质等级发射器(T-M2-REMOVE:注册键随源质终端节点删除迁 ESSENTIAACCESSCARD,配方页同步迁入访问卡节点)
|
||||
ESSENTIA_LEVEL_EMITTER = ThaumcraftApi.addShapelessArcaneCraftingRecipe("ESSENTIAACCESSCARD", new ItemStack(ModItems.ESSENTIA_LEVEL_EMITTER.get(), 1),
|
||||
new AspectList().add(Aspect.FIRE, 4),
|
||||
ae("calculation_processor"),
|
||||
new ItemStack(Items.REDSTONE_TORCH),
|
||||
tc("salis_mundus"));
|
||||
|
||||
// 4. 原质终端
|
||||
ESSENTIA_TERMINAL = ThaumcraftApi.addShapelessArcaneCraftingRecipe("ESSENTIATERMINAL", stack(ModItems.ESSENTIA_TERMINAL_ITEM),
|
||||
new AspectList().add(Aspect.WATER, 5).add(Aspect.ORDER, 2).add(Aspect.FIRE, 1),
|
||||
MONITORS,
|
||||
stack(ModItems.DIFFUSION_CORE),
|
||||
stack(ModItems.COALESCENCE_CORE),
|
||||
ae("logic_processor"),
|
||||
tc("vis_filter"));
|
||||
|
||||
// 5. 奥术合成终端
|
||||
// 4. 奥术合成终端
|
||||
ARCANE_CRAFTING_TERMINAL = ThaumcraftApi.addShapelessArcaneCraftingRecipe("ARCANECRAFTINGTERMINAL", stack(ModItems.ARCANE_CRAFTING_TERMINAL_ITEM),
|
||||
new AspectList().add(Aspect.AIR, 10).add(Aspect.EARTH, 10).add(Aspect.FIRE, 10).add(Aspect.WATER, 10).add(Aspect.ORDER, 10).add(Aspect.ENTROPY, 10),
|
||||
ae("terminal"),
|
||||
@@ -288,6 +249,24 @@ public final class RecipeRegistration {
|
||||
ae("certus_quartz_wrench"),
|
||||
tc("balanced_shard"));
|
||||
|
||||
// 10. vis 连接卡(T-RESEARCH-B4:VISCONNECTORCARD 节点已删,研究键融入无线奥术合成终端节点)
|
||||
VIS_CONNECTOR_CARD = ThaumcraftApi.addShapelessArcaneCraftingRecipe("WIRELESSARCANECRAFTINGTERMINAL",
|
||||
stack(ModItems.VIS_CONNECTOR_CARD),
|
||||
new AspectList().add(Aspect.AIR, 10).add(Aspect.ORDER, 20),
|
||||
ae("wireless_receiver"),
|
||||
ae("advanced_card"),
|
||||
stack(ModItems.COALESCENCE_CORE));
|
||||
|
||||
// 11. 无线奥术合成终端(T-RESEARCH-B4:vanilla 无序改奥术无序,物品组件不变)
|
||||
// 要素 20 aer + 10 ignis + 10 perditio(Aspect 常量映射:AIR/FIRE/ENTROPY);
|
||||
// 研究门槛 = WIRELESSARCANECRAFTINGTERMINAL,未解锁不可合成。
|
||||
WIRELESS_ARCANE_CRAFTING_TERMINAL = ThaumcraftApi.addShapelessArcaneCraftingRecipe("WIRELESSARCANECRAFTINGTERMINAL",
|
||||
stack(ModItems.WIRELESS_ARCANE_CRAFTING_TERMINAL),
|
||||
new AspectList().add(Aspect.AIR, 20).add(Aspect.FIRE, 10).add(Aspect.ENTROPY, 10),
|
||||
ae("wireless_receiver"),
|
||||
ae("dense_energy_cell"),
|
||||
stack(ModItems.ARCANE_CRAFTING_TERMINAL_ITEM));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -348,6 +327,49 @@ public final class RecipeRegistration {
|
||||
tc("goggles_revealing"),
|
||||
tc("salis_mundus"),
|
||||
tc("salis_mundus"));
|
||||
|
||||
// 5. 源质访问卡(T-M1-012:弃旧 shapeless,改注魔配方)
|
||||
// 落点为本方法(port.261 无注魔 datapack 序列化器,注魔唯一入口为代码 API)。
|
||||
// research="" 无研究门槛——注魔矩阵不消费 research;TCResearchManager.has 对空/空白键直接返回 true。
|
||||
// 中心 ae2:basic_card;组件 铁锭×2 + 神秘锭×2 + 世界盐×1 + 运算处理器×1 + 扩散核心×1(共 7 个,TC 上限 8)。
|
||||
// 要素 cognitio×16 / fabrico×16 / permutatio×8 / metallum×8 / praecantatio×8;不稳定度 2。
|
||||
//产物数量x4(T-M3-RECIPE:材料贵、用量大,产物 1 → 4)
|
||||
//研究键挂自身节点(T-RESEARCH-B2:原为空键无门槛)
|
||||
ESSENTIA_UPGRADE_CARD = ThaumcraftApi.addInfusionCraftingRecipe("ESSENTIAACCESSCARD", stack(ModItems.ESSENTIA_UPGRADE_CARD).copyWithCount(4),
|
||||
2, new AspectList().add(Aspect.MIND, 16).add(Aspect.CRAFT, 16).add(Aspect.EXCHANGE, 8).add(Aspect.METAL, 8).add(Aspect.MAGIC, 8),
|
||||
ae("basic_card"),
|
||||
new ItemStack(Items.IRON_INGOT, 1),
|
||||
new ItemStack(Items.IRON_INGOT, 1),
|
||||
tc("thaumium_ingot"),
|
||||
tc("thaumium_ingot"),
|
||||
tc("salis_mundus"),
|
||||
ae("calculation_processor"),
|
||||
stack(ModItems.DIFFUSION_CORE));
|
||||
|
||||
// 11. 概率之脑(T-M6-RECIPE-2:CE gacha_box 注魔配方移植)
|
||||
// 研究键 GACHABOX;不稳定度 8(CE 原值,全模最高——盒子本身就是一场赌博)。
|
||||
// 要素运行期取(port.261 无这些静态常量,M6 范式 Aspect.get):
|
||||
// 认知 32 / 置换 16 / 前行 16 / 运动 8 / 机械 8 / 秽 8。
|
||||
// catalyst=本仓知识核心;组件 8 件(TC 上限 8):认知灵光精粹(fixedAspect 物品,等价 CE 认知 vis 晶体)
|
||||
// + 扩散核心 + 秽灵光精粹(等价 CE crystal_vitium)+ AE2 形成核心 + AE2 运算处理器
|
||||
// + 神秘锭×2 + 世界盐。罐装脑不入组件——装脑走方块交互(CE 同款注释语义)。
|
||||
GACHA_BOX = ThaumcraftApi.addInfusionCraftingRecipe("GACHABOX", stack(ModBlocks.BRAIN_OF_PROBABILITY),
|
||||
8, new AspectList()
|
||||
.add(Aspect.get("cognitio"), 32)
|
||||
.add(Aspect.get("permutatio"), 16)
|
||||
.add(Aspect.get("praecantatio"), 16)
|
||||
.add(Aspect.get("motus"), 8)
|
||||
.add(Aspect.get("machina"), 8)
|
||||
.add(Aspect.get("vitium"), 8),
|
||||
stack(ModItems.KNOWLEDGE_CORE),
|
||||
tc("wisp_essence_cognitio"),
|
||||
stack(ModItems.DIFFUSION_CORE),
|
||||
tc("wisp_essence_vitium"),
|
||||
ae("formation_core"),
|
||||
ae("calculation_processor"),
|
||||
tc("thaumium_ingot"),
|
||||
tc("thaumium_ingot"),
|
||||
tc("salis_mundus"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,7 +393,7 @@ public final class RecipeRegistration {
|
||||
return scepter;
|
||||
}
|
||||
|
||||
private static ItemStack stack(java.util.function.Supplier<? extends net.minecraft.world.level.ItemLike> s) {
|
||||
private static ItemStack stack(java.util.function.Supplier<? extends ItemLike> s) {
|
||||
return new ItemStack(s.get());
|
||||
}
|
||||
private static ItemStack tc(String name) {
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.world.level.Level;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
|
||||
public final class AEssentiaKey extends AEKey {
|
||||
|
||||
@@ -52,8 +53,8 @@ public final class AEssentiaKey extends AEKey {
|
||||
protected Component computeDisplayName() {
|
||||
// 使用 TC 源质的实际显示名称(如 "Aer" / "风"),而非翻译键
|
||||
String tag = id.getPath();
|
||||
if (thaumcraft.api.aspects.Aspect.aspects != null) {
|
||||
for (thaumcraft.api.aspects.Aspect aspect : thaumcraft.api.aspects.Aspect.aspects.values()) {
|
||||
if (Aspect.aspects != null) {
|
||||
for (Aspect aspect : Aspect.aspects.values()) {
|
||||
if (aspect != null && aspect.getTag() != null && aspect.getTag().equalsIgnoreCase(tag)) {
|
||||
return aspect.displayName();
|
||||
}
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package thaumicenergistics.common.integration.appeng;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.essentia.EssentiaTransport;
|
||||
|
||||
/**
|
||||
* T-M2-001:ME 接口「源质对接逻辑」({@code InterfaceLogic})对外的桥接面。
|
||||
* <p>
|
||||
* <b>为什么需要这层接口</b>:TC 的寻址以<b>方块实体</b>为单
|
||||
* ({@code level.getBlockEntity(pos) instanceof EssentiaTransport}),
|
||||
* 而源质卡的网络 I/O(缓冲、记账、卡门控)实现在逻辑类 {@code InterfaceLogic} 上——二者在 Mixin 层无法
|
||||
* 互访私有成员,故以本接口作显式契约:{@code MixinInterfaceLogic} 实现之,
|
||||
* {@code MixinInterfaceBlockEntity} 经 {@code getInterfaceLogic()} 取得后调用。
|
||||
* <p>
|
||||
* <b>语义要点</b>:推入(外部 → 网络,进缓冲绝不丢弃)与拉取响应(<b>仅从缓存格 stock 槽取</b>,
|
||||
* 禁止直取网络)分列。广告的源质类型/数量一律取<b>缓存格</b>内容而非网络存量——这是与样板供应器
|
||||
* 的根本差异:接口不对外宣告网络源质,故不存在「管道无单抽走网络源质」的泄漏路径。
|
||||
* <p>
|
||||
* 方法一律以 {@code thE$} 前缀命名,避免污染混入目标的公共命名空间。
|
||||
*/
|
||||
public interface IEssentiaInterfaceLogic {
|
||||
|
||||
/** 源质能力是否激活(源质卡在装 + 已联网)。未激活时全部对外表现为惰性。 */
|
||||
boolean thE$essentiaActive();
|
||||
|
||||
/** 预检:网络当前还能接收多少源质(封顶于本卡速率)。须与 {@link #thE$acceptEssentia} 返回值严格一致。 */
|
||||
int thE$simulateAcceptEssentia(Aspect aspect, int amount);
|
||||
|
||||
/** 接收源质(进缓冲 + 尽力注入网络,残留留缓冲绝不丢弃),返回接收量。 */
|
||||
int thE$acceptEssentia(Aspect aspect, int amount);
|
||||
|
||||
/** 广告缓存格内首个非空源质要素(单要素契约);无则 null。 */
|
||||
Aspect thE$stockAspect();
|
||||
|
||||
/** 广告缓存格内指定要素的存量(跨槽累计)。 */
|
||||
int thE$stockAmount(Aspect aspect);
|
||||
|
||||
/** 预检:缓存格还能取出多少。须与 {@link #thE$takeFromStock} 返回值严格一致。 */
|
||||
int thE$simulateTakeFromStock(Aspect aspect, int amount);
|
||||
|
||||
/** 从缓存格取出源质(禁止直取网络),返回取出量。 */
|
||||
int thE$takeFromStock(Aspect aspect, int amount);
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package thaumicenergistics.common.integration.appeng;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.stacks.AEKey;
|
||||
import appeng.helpers.patternprovider.PatternProviderTarget;
|
||||
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
|
||||
/**
|
||||
* T-M2-002:{@link ThEEssentiaPushTarget} 与 AE2 原生 target 的<b>复合包装</b>。
|
||||
* <p>
|
||||
* <b>为什么需要包装</b>:极罕见的「双能力机器」(既有 item/fluid 外部存储能力,又是 TC 源质端点)
|
||||
* 场景下,原 target 非 null——此时不能整体顶替(物品/流体须照常走 AE2 原生链路),
|
||||
* 改为按 key 类型分流:源质键 → 源质落点,其余 → 原 target。
|
||||
* <p>
|
||||
* <b>为什么不在 mixin 包</b>:普通运行期类被注入体直接 new,Mixin 声明包内类
|
||||
* 禁止被普通代码引用(IllegalClassLoadError),故与 {@link ThEEssentiaPushTarget}
|
||||
* 一并落 AE2 集成包。
|
||||
*/
|
||||
public record ThECompositePushTarget(PatternProviderTarget originalTarget, PatternProviderTarget essentiaTarget)
|
||||
implements PatternProviderTarget {
|
||||
|
||||
@Override
|
||||
public long insert(AEKey what, long amount, Actionable type) {
|
||||
if (what instanceof AEssentiaKey) {
|
||||
return this.essentiaTarget.insert(what, amount, type);
|
||||
}
|
||||
return this.originalTarget.insert(what, amount, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsPatternInput(Set<AEKey> patternInputs) {
|
||||
// blocking 判定两侧并集:物品/流体交原 target(原生语义),源质交源质落点(广告查询)——
|
||||
// 两套键空间互不重叠,各自的 containsPatternInput 对异类键天然返 false
|
||||
return this.originalTarget.containsPatternInput(patternInputs)
|
||||
|| this.essentiaTarget.containsPatternInput(patternInputs);
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
package thaumicenergistics.common.integration.appeng;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.stacks.AEKey;
|
||||
import appeng.helpers.patternprovider.PatternProviderTarget;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.IAspectContainer;
|
||||
import thaumcraft.api.aspects.IEssentiaTransport;
|
||||
|
||||
import thaumicenergistics.common.essentia.capability.EssentiaTransfer;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
import thaumicenergistics.common.integration.tc.EssentiaConversionHelper;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
|
||||
/**
|
||||
* T-M2-002(P-A 裁决):样板供应器<b>订单驱动源质输出</b>的推送落点(纯输出侧)。
|
||||
* <p>
|
||||
* <b>为什么复用导出总线范式</b>:TC {@code IEssentiaTransport.simulateAddEssentia} 的 default
|
||||
* 实现恒返 0(字节码实证:iconst_0,仅管道/储罐/结晶器覆写),若按字面 simulate/add 配对,
|
||||
* 罐子/蒸馏器等大半 TC 容器会被误判「不可接收」。故本类与 {@link EssentiaTransfer#push} 同范式:
|
||||
* MODULATE 直接走导出总线落点(IAspectContainer 优先 + addEssentia 回退),
|
||||
* SIMULATE 采用<b>类型级近似</b>({@code simulateAddEssentia > 0},拉取式机器回退
|
||||
* {@code isConnectable && canInputFrom},容器类回退 {@code doesContainerAccept},
|
||||
* <b>不验余量</b>)——余量缺口由 AE2 原生 sendList 重试兜底,
|
||||
* 验收口径为「下单后源质最终到位」。
|
||||
* <p>
|
||||
* <b>为什么不在 mixin 包</b>:本类是普通运行期类(由注入体直接 new),Mixin 框架禁止
|
||||
* mixin 声明包内类被普通代码直接引用(IllegalClassLoadError),故落 AE2 集成包——
|
||||
* 与 {@code IEssentiaInterfaceLogic}(T-M2-001 桥接接口)同一分层先例。
|
||||
* <p>
|
||||
* <b>为什么不收物品/流体</b>:源质交互分工制约定供应器 = 纯输出侧的源质通道;
|
||||
* 物品/流体产物回收仍走 AE2 原生(机器推回供应器),源质落点只认 {@link AEssentiaKey}。
|
||||
*/
|
||||
public final class ThEEssentiaPushTarget implements PatternProviderTarget {
|
||||
|
||||
private final IGrid grid;
|
||||
private final IActionSource source;
|
||||
private final BlockEntity container;
|
||||
/** 容器接收面的朝向(TC 管道 addEssentia 回退路径需要)。 */
|
||||
private final Direction accessSide;
|
||||
|
||||
public ThEEssentiaPushTarget(IGrid grid, IActionSource source, BlockEntity container, Direction accessSide) {
|
||||
this.grid = grid;
|
||||
this.source = source;
|
||||
this.container = container;
|
||||
this.accessSide = accessSide;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long insert(AEKey what, long amount, Actionable type) {
|
||||
if (!(what instanceof AEssentiaKey key) || amount <= 0) {
|
||||
return 0; // 源质落点不收物品/流体(回收走 AE2 原生机器推回链路)
|
||||
}
|
||||
if (type == Actionable.SIMULATE) {
|
||||
// P-A 类型级近似:不验余量,只要容器「接受该类型」即放行推送;
|
||||
// 实际注入不足的部分由 pushPattern 的 addToSendList → sendStacksOut 原生重试
|
||||
return thE$typeAccepts(key) ? amount : 0;
|
||||
}
|
||||
// 与导出总线同款落点:IAspectContainer 优先 + addEssentia 回退;未注入部分退回网络,绝不丢料
|
||||
long injected = EssentiaTransfer.push(this.grid, this.source, key, amount, this.container, this.accessSide);
|
||||
if (injected > 0) {
|
||||
// 按实际搬运量 double 记账(禁止 (int) 截断),口径与导出总线 TRANSFER_POWER 一致
|
||||
this.grid.getEnergyService().extractAEPower(
|
||||
injected * EssentiaConversionHelper.AE_PER_ESSENTIA,
|
||||
Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
}
|
||||
return injected;
|
||||
}
|
||||
|
||||
/**
|
||||
* blocking 语义:仅当相邻机器对外广告了某个源质输入键(机内已有所需源质)时拦推。
|
||||
* 广告查询出自 {@link TCReflection#listEssentia};查询异常时<b>降级放行</b>(返 false),
|
||||
* 误推的余量由 sendList 兜底,不会丢料。
|
||||
*/
|
||||
@Override
|
||||
public boolean containsPatternInput(Set<AEKey> patternInputs) {
|
||||
try {
|
||||
for (var advertised : TCReflection.listEssentia(this.container)) {
|
||||
for (var key : patternInputs) {
|
||||
if (key instanceof AEssentiaKey essentiaKey
|
||||
&& advertised.aspectId().equals(essentiaKey.getId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// 遇阻降级:判不出就放行推送(记录于交付报告)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 类型级接收判定(P-A):{@code simulateAddEssentia > 0} 优先;拉取式机器(实现
|
||||
* transport 但不覆写 simulate——如神秘炼金塔 Thaumatorium,配方激活时 addEssentia
|
||||
* 实收)以机器自身 {@code isConnectable && canInputFrom} 作类型级放行;容器类回退
|
||||
* {@code IAspectContainer.doesContainerAccept}。不验余量;MODULATE 收 0 的空转
|
||||
* 由 AE2 sendList 原生重试兜底(不丢料)。
|
||||
*/
|
||||
private boolean thE$typeAccepts(AEssentiaKey key) {
|
||||
Aspect aspect = TCReflection.findAspectById(key.getId());
|
||||
if (aspect == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.container instanceof IEssentiaTransport transport
|
||||
&& (transport.simulateAddEssentia(aspect, 1, this.accessSide) > 0
|
||||
|| (transport.isConnectable(this.accessSide)
|
||||
&& transport.canInputFrom(this.accessSide)))) {
|
||||
return true;
|
||||
}
|
||||
return this.container instanceof IAspectContainer aspectContainer
|
||||
&& aspectContainer.doesContainerAccept(aspect);
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package thaumicenergistics.common.integration.jade;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import snownee.jade.api.BlockAccessor;
|
||||
import snownee.jade.api.IBlockComponentProvider;
|
||||
import snownee.jade.api.IServerDataProvider;
|
||||
import snownee.jade.api.ITooltip;
|
||||
import snownee.jade.api.config.IPluginConfig;
|
||||
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.tiles.BrainOfProbabilityBlockEntity;
|
||||
|
||||
/**
|
||||
* 概率之脑 Jade 显示(T-M6-GACHA-REV),两行:
|
||||
* <ol>
|
||||
* <li>「本轮奖励」:最近一次出货明细(要素本地化名 + 点数;无出货历史显示暂无)。</li>
|
||||
* <li>「下次抽奖」:当前周期剩余秒数(空闲显示 —)。</li>
|
||||
* </ol>
|
||||
* 服务端把 BE 持久化的 lastPayout 与 turnSeconds 写入 NBT,客户端渲染。
|
||||
*/
|
||||
public enum BrainOfProbabilityProvider implements IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
|
||||
INSTANCE;
|
||||
|
||||
private static final String KEY = "BrainProbPayout";
|
||||
private static final String TAG_TURN_REMAINING = "TurnRemaining";
|
||||
|
||||
@Override
|
||||
public ResourceLocation getUid() {
|
||||
return ResourceLocation.fromNamespaceAndPath(ThaumicEnergistics.MODID, "brain_of_probability");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendServerData(CompoundTag data, BlockAccessor accessor) {
|
||||
if (accessor.getBlockEntity() instanceof BrainOfProbabilityBlockEntity brain) {
|
||||
data.putInt(TAG_TURN_REMAINING, brain.turnSecondsRemaining());
|
||||
Map<String, Integer> payout = brain.lastPayout();
|
||||
if (!payout.isEmpty()) {
|
||||
ListTag saved = new ListTag();
|
||||
for (Map.Entry<String, Integer> entry : payout.entrySet()) {
|
||||
CompoundTag item = new CompoundTag();
|
||||
item.putString("tag", entry.getKey());
|
||||
item.putInt("points", entry.getValue());
|
||||
saved.add(item);
|
||||
}
|
||||
data.put(KEY, saved);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig config) {
|
||||
var serverData = accessor.getServerData();
|
||||
if (!serverData.contains(TAG_TURN_REMAINING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 行 1:本轮奖励(无出货历史 = 暂无)
|
||||
MutableComponent parts = Component.empty();
|
||||
boolean first = true;
|
||||
if (serverData.contains(KEY)) {
|
||||
ListTag saved = serverData.getList(KEY, Tag.TAG_COMPOUND);
|
||||
for (int i = 0; i < saved.size(); i++) {
|
||||
CompoundTag item = saved.getCompound(i);
|
||||
if (!first) {
|
||||
parts = parts.append(Component.translatable("thaumicenergistics.brain_prob.payout_sep"));
|
||||
}
|
||||
first = false;
|
||||
parts = parts.append(Component.translatable("tc.aspect." + item.getString("tag")))
|
||||
.append(Component.literal(" " + item.getInt("points")));
|
||||
}
|
||||
}
|
||||
Component payoutDisplay = first
|
||||
? Component.translatable("thaumicenergistics.jade.brain_prob.none")
|
||||
: parts;
|
||||
tooltip.add(Component.translatable("thaumicenergistics.jade.brain_prob.last_payout", payoutDisplay));
|
||||
|
||||
// 行 2:下次抽奖倒计时(空闲 = —)
|
||||
int remaining = serverData.getInt(TAG_TURN_REMAINING);
|
||||
Component countdown = remaining > 0
|
||||
? Component.literal(String.valueOf(remaining))
|
||||
: Component.literal("—");
|
||||
tooltip.add(Component.translatable("thaumicenergistics.jade.brain_prob.next_draw", countdown));
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import snownee.jade.api.IWailaClientRegistration;
|
||||
import snownee.jade.api.IWailaCommonRegistration;
|
||||
import snownee.jade.api.IWailaPlugin;
|
||||
import snownee.jade.api.WailaPlugin;
|
||||
import thaumicenergistics.common.tiles.BrainOfProbabilityBlockEntity;
|
||||
import thaumicenergistics.common.tiles.TileArcaneAssembler;
|
||||
import thaumicenergistics.common.tiles.TileEssentiaProvider;
|
||||
import thaumicenergistics.common.tiles.TileEssentiaVibrationChamber;
|
||||
@@ -24,6 +25,8 @@ public class ThEJadePlugin implements IWailaPlugin {
|
||||
registration.registerBlockDataProvider(InfusionProviderProvider.INSTANCE, TileEssentiaProvider.class);
|
||||
// 奥术装配器:网络状态 + 要素源状态
|
||||
registration.registerBlockDataProvider(AssemblerProvider.INSTANCE, TileArcaneAssembler.class);
|
||||
// 概率之脑:本轮奖励 + 下次抽奖倒计时
|
||||
registration.registerBlockDataProvider(BrainOfProbabilityProvider.INSTANCE, BrainOfProbabilityBlockEntity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,5 +45,9 @@ public class ThEJadePlugin implements IWailaPlugin {
|
||||
|
||||
Block assemblerBlock = ModBlocks.ARCANE_ASSEMBLER.get();
|
||||
registration.registerBlockComponent(AssemblerProvider.INSTANCE, assemblerBlock.getClass());
|
||||
|
||||
// 概率之脑:本轮奖励 + 下次抽奖倒计时
|
||||
Block brainBlock = ModBlocks.BRAIN_OF_PROBABILITY.get();
|
||||
registration.registerBlockComponent(BrainOfProbabilityProvider.INSTANCE, brainBlock.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* 奥术合成样板,存储在知识核心中。
|
||||
@@ -81,7 +82,7 @@ public class ArcaneCraftingPattern {
|
||||
}
|
||||
|
||||
/** 对应 TC 奥术配方的研究键;无研究要求/老数据时可能为 null。 */
|
||||
@org.jetbrains.annotations.Nullable
|
||||
@Nullable
|
||||
public String getResearch() {
|
||||
return research;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package thaumicenergistics.common.integration.tc;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import thaumicenergistics.api.storage.IAspectStack;
|
||||
import thaumicenergistics.api.storage.AspectStack;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,8 @@ import thaumcraft.api.research.ResearchCategories;
|
||||
import thaumcraft.api.research.ResearchItem;
|
||||
import thaumcraft.api.research.ResearchPage;
|
||||
import thaumcraft.common.research.TCResearchIndex;
|
||||
import net.minecraft.world.item.Items;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
|
||||
/**
|
||||
* 伪前置桩节点。在 ThE 的研究 tab 中创建一个占位节点,
|
||||
@@ -86,7 +88,7 @@ public class PseudoResearchItem extends ResearchItem {
|
||||
} else {
|
||||
// 最终备选:ThE 研究 tab 图标
|
||||
pseudo = new PseudoResearchItem(pseudoKey, category, column, row,
|
||||
ResourceLocation.fromNamespaceAndPath(thaumicenergistics.ThaumicEnergistics.MODID, "textures/research/tab_icon.png"),
|
||||
ResourceLocation.fromNamespaceAndPath(ThaumicEnergistics.MODID, "textures/research/tab_icon.png"),
|
||||
realKey, realCategory);
|
||||
}
|
||||
|
||||
@@ -108,7 +110,7 @@ public class PseudoResearchItem extends ResearchItem {
|
||||
ResourceLocation id = ResourceLocation.tryParse(itemId);
|
||||
if (id == null) return ItemStack.EMPTY;
|
||||
Item item = BuiltInRegistries.ITEM.get(id);
|
||||
return (item == null || item == net.minecraft.world.item.Items.AIR) ? ItemStack.EMPTY : new ItemStack(item);
|
||||
return (item == null || item == Items.AIR) ? ItemStack.EMPTY : new ItemStack(item);
|
||||
})
|
||||
.orElse(ItemStack.EMPTY);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -11,16 +11,14 @@ import thaumcraft.api.research.ResearchCategories;
|
||||
import thaumcraft.api.research.ResearchItem;
|
||||
import thaumcraft.api.research.ResearchPage;
|
||||
import thaumcraft.api.crafting.IArcaneRecipe;
|
||||
import thaumcraft.api.crafting.InfusionRecipe;
|
||||
import thaumcraft.api.crafting.CrucibleRecipe;
|
||||
import thaumcraft.common.research.TCResearchManager;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.features.RecipeRegistration;
|
||||
import thaumicenergistics.init.ModBlocks;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import appeng.core.definitions.AEItems;
|
||||
|
||||
/**
|
||||
* 神秘能源 魔导手册研究注册
|
||||
@@ -73,11 +71,9 @@ public final class ThEThaumcraft {
|
||||
registerEssentiaStorage();
|
||||
registerArcaneCraftingTerminal();
|
||||
registerVisInterface();
|
||||
registerEssentiaBuses();
|
||||
registerInfusionProvider();
|
||||
registerInfusionMonitor();
|
||||
registerEssentiaProvider();
|
||||
registerEssentiaTerminal();
|
||||
registerDigisentia();
|
||||
registerFocusAEWrench();
|
||||
registerCertusDupe();
|
||||
@@ -85,6 +81,11 @@ public final class ThEThaumcraft {
|
||||
registerDistillationEncoder();
|
||||
registerGolemWifiBackpack();
|
||||
|
||||
// T-RESEARCH-B2:M3~M6 新内容入树;T-RESEARCH-B4:删除重挂(WIRELESSESSENTIATERMINAL/VISCONNECTORCARD 节点已删)
|
||||
registerWirelessArcaneCraftingTerminal();
|
||||
registerEssentiaAccessCard();
|
||||
registerGachaBox();
|
||||
|
||||
LOG.info("ThaumicEnergistics research registered.");
|
||||
}
|
||||
|
||||
@@ -228,30 +229,16 @@ public final class ThEThaumcraft {
|
||||
.registerResearchItem();
|
||||
}
|
||||
|
||||
// ==================== 6. (-2,-2) ESSENTIABUSES 源质总线====================
|
||||
// 前置: DIGISENTIA(数字化源质) + TUBEFILTER(高级源质管道)
|
||||
private static void registerEssentiaBuses() {
|
||||
new ResearchItem("ESSENTIABUSES", TAB,
|
||||
new AspectList().add(Aspect.MECHANISM, 5).add(Aspect.EXCHANGE, 5).add(Aspect.MAGIC, 3),
|
||||
-2, -2, 2, new ItemStack(ModItems.ESSENTIA_IMPORT_BUS.get()))
|
||||
.setRound().setParents("DIGISENTIA", "PSEUDO_TUBEFILTER")
|
||||
.setPages(
|
||||
new ResearchPage("tc.research_text.ESSENTIABUSES.stage.1"),
|
||||
new ResearchPage(RecipeRegistration.ESSENTIA_IMPORT_BUS),
|
||||
new ResearchPage(RecipeRegistration.ESSENTIA_EXPORT_BUS),
|
||||
new ResearchPage(RecipeRegistration.ESSENTIA_STORAGE_BUS),
|
||||
new ResearchPage("tc.research_text.ESSENTIABUSES.stage.2"))
|
||||
.registerResearchItem();
|
||||
}
|
||||
// ==================== 6. 源质总线节点已删(T-RESEARCH-B4:ESSENTIAACCESSCARD 顶位继承) ====================
|
||||
|
||||
// ==================== 7. (-5,-2) INFUSIONPROVIDER 注魔供应器====================
|
||||
// 前置: ESSENTIABUSES(源质总线) + INFUSION(注魔) + MIRROR(魔镜)
|
||||
// 前置: ESSENTIAACCESSCARD(源质访问卡,T-RESEARCH-B4 顶位继承原源质总线) + INFUSION(注魔) + MIRROR(魔镜)
|
||||
private static void registerInfusionProvider() {
|
||||
new ResearchItem("INFUSIONPROVIDER", TAB,
|
||||
new AspectList().add(Aspect.MECHANISM, 10).add(Aspect.MAGIC, 10)
|
||||
.add(Aspect.ORDER, 8).add(Aspect.EXCHANGE, 5),
|
||||
-5, -2, 3, new ItemStack(ModItems.INFUSION_PROVIDER_ITEM.get()))
|
||||
.setRound().setParents("ESSENTIABUSES", "PSEUDO_INFUSION", "PSEUDO_MIRROR")
|
||||
.setRound().setParents("ESSENTIAACCESSCARD", "PSEUDO_INFUSION", "PSEUDO_MIRROR")
|
||||
.setPages(
|
||||
new ResearchPage("tc.research_text.INFUSIONPROVIDER.stage.1"),
|
||||
new ResearchPage(RecipeRegistration.INFUSION_PROVIDER),
|
||||
@@ -274,12 +261,12 @@ public final class ThEThaumcraft {
|
||||
}
|
||||
|
||||
// ==================== 8. (-2,-4) ESSENTIAPROVIDER 源质供应器====================
|
||||
// 前置: ESSENTIABUSES(源质总线)
|
||||
// 前置: ESSENTIAACCESSCARD(源质访问卡,T-RESEARCH-B4 顶位继承原源质总线)
|
||||
private static void registerEssentiaProvider() {
|
||||
new ResearchItem("ESSENTIAPROVIDER", TAB,
|
||||
new AspectList().add(Aspect.MECHANISM, 8).add(Aspect.MAGIC, 8).add(Aspect.EXCHANGE, 5),
|
||||
-2, -4, 3, new ItemStack(ModItems.ESSENTIA_PROVIDER_ITEM.get()))
|
||||
.setRound().setParents("ESSENTIABUSES")
|
||||
.setRound().setParents("ESSENTIAACCESSCARD")
|
||||
.setPages(
|
||||
// 源质供应器:介绍+用法 / 配方
|
||||
new ResearchPage("tc.research_text.ESSENTIAPROVIDER.stage.1"),
|
||||
@@ -293,20 +280,8 @@ public final class ThEThaumcraft {
|
||||
.registerResearchItem();
|
||||
}
|
||||
|
||||
// ==================== 9. (-1,-4) ESSENTIATERMINAL 源质终端====================
|
||||
// 前置: DIGISENTIA(数字化源质)
|
||||
private static void registerEssentiaTerminal() {
|
||||
new ResearchItem("ESSENTIATERMINAL", TAB,
|
||||
new AspectList().add(Aspect.MAGIC, 5).add(Aspect.ORDER, 3).add(Aspect.MIND, 3),
|
||||
-1, -4, 2, new ItemStack(ModItems.ESSENTIA_TERMINAL_ITEM.get()))
|
||||
.setRound().setParents("DIGISENTIA")
|
||||
.setPages(
|
||||
new ResearchPage("tc.research_text.ESSENTIATERMINAL.stage.1"),
|
||||
new ResearchPage(RecipeRegistration.ESSENTIA_TERMINAL),
|
||||
new ResearchPage(RecipeRegistration.ESSENTIA_LEVEL_EMITTER),
|
||||
new ResearchPage("tc.research_text.ESSENTIATERMINAL.stage.2"))
|
||||
.registerResearchItem();
|
||||
}
|
||||
// ==================== 9. (-1,-4) ESSENTIATERMINAL 源质终端已删(T-M2-REMOVE) ====================
|
||||
// 节点无后继(全仓 grep 实证);ESSENTIA_LEVEL_EMITTER 配方键与配方页已迁 ESSENTIAACCESSCARD(裁定 A)
|
||||
|
||||
// ==================== 10. (0,-2) DIGISENTIA 数字化源质====================
|
||||
// 前置: BASEENERGISTICS(基础能源学) + DISTILESSENTIA(要素蒸馏)
|
||||
@@ -341,7 +316,7 @@ public final class ThEThaumcraft {
|
||||
private static void registerCertusDupe() {
|
||||
new ResearchItem("CERTUS_DUPE", TAB,
|
||||
new AspectList().add(Aspect.CRYSTAL, 5).add(Aspect.MAGIC, 5).add(Aspect.EXCHANGE, 5),
|
||||
-5, -5, 2, new ItemStack(appeng.core.definitions.AEItems.CERTUS_QUARTZ_CRYSTAL.asItem()))
|
||||
-5, -5, 2, new ItemStack(AEItems.CERTUS_QUARTZ_CRYSTAL.asItem()))
|
||||
.setRound().setParents("PSEUDO_ALCHEMICALDUPLICATION").setParentsHidden("BASEENERGISTICS")
|
||||
.setPages(
|
||||
new ResearchPage("tc.research_text.CERTUS_DUPE"),
|
||||
@@ -363,12 +338,12 @@ public final class ThEThaumcraft {
|
||||
}
|
||||
|
||||
// ==================== 15. (-4,-4) DISTILLATIONENCODER 蒸馏编码台====================
|
||||
// 前置: ESSENTIABUSES
|
||||
// 前置: ESSENTIAACCESSCARD(源质访问卡,T-RESEARCH-B4 顶位继承原源质总线)
|
||||
private static void registerDistillationEncoder() {
|
||||
new ResearchItem("DISTILLATIONENCODER", TAB,
|
||||
new AspectList().add(Aspect.MECHANISM, 5).add(Aspect.ORDER, 5).add(Aspect.ENTROPY, 5),
|
||||
-4, -4, 3, new ItemStack(ModItems.DISTILLATION_ENCODER_ITEM.get()))
|
||||
.setRound().setParents("ESSENTIABUSES")
|
||||
.setRound().setParents("ESSENTIAACCESSCARD")
|
||||
.setPages(
|
||||
new ResearchPage("tc.research_text.DISTILLATIONENCODER"),
|
||||
new ResearchPage(RecipeRegistration.DISTILLATION_ENCODER_BLOCK))
|
||||
@@ -388,4 +363,55 @@ public final class ThEThaumcraft {
|
||||
.registerResearchItem();
|
||||
}
|
||||
|
||||
// ==================== T-RESEARCH-B2:M3~M6 新增节点(纯新增) ====================
|
||||
// T-RESEARCH-B4:WIRELESSESSENTIATERMINAL 节点已删;T-M2-REMOVE:无线源质终端本体与配方一并删除
|
||||
|
||||
// ==================== 18. (3,-2) WIRELESSARCANECRAFTINGTERMINAL 无线奥术合成终端====================
|
||||
// 前置: ARCANECRAFTINGTERMINAL(奥术合成终端)
|
||||
private static void registerWirelessArcaneCraftingTerminal() {
|
||||
new ResearchItem("WIRELESSARCANECRAFTINGTERMINAL", TAB,
|
||||
new AspectList().add(Aspect.CRAFT, 8).add(Aspect.MAGIC, 8).add(Aspect.MECHANISM, 5),
|
||||
3, -2, 2, new ItemStack(ModItems.WIRELESS_ARCANE_CRAFTING_TERMINAL.get()))
|
||||
.setRound().setParents("ARCANECRAFTINGTERMINAL")
|
||||
.setPages(
|
||||
new ResearchPage("tc.research_text.WIRELESSARCANECRAFTINGTERMINAL.stage.1"),
|
||||
new ResearchPage(RecipeRegistration.WIRELESS_ARCANE_CRAFTING_TERMINAL),
|
||||
new ResearchPage("tc.research_text.WIRELESSARCANECRAFTINGTERMINAL.stage.2"))
|
||||
.registerResearchItem();
|
||||
}
|
||||
|
||||
// ==================== 21. (-2,-2) ESSENTIAACCESSCARD 源质访问卡====================
|
||||
// T-RESEARCH-B4:顶位继承原源质总线(用户拍板「继承它的关系包括前置、后继」)
|
||||
// T-M2-REMOVE:三总线删除后,ESSENTIA_LEVEL_EMITTER 配方注册键与配方页迁入本节点(裁定 A)。
|
||||
// 坐标 = 原 ESSENTIABUSES (-2,-2);前置 = 原 ESSENTIABUSES 前置(DIGISENTIA + PSEUDO_TUBEFILTER),
|
||||
// 原 PSEUDO_INFUSION/PSEUDO_MIRROR 前置丢弃;原 ESSENTIABUSES 三后继(INFUSIONPROVIDER/
|
||||
// ESSENTIAPROVIDER/DISTILLATIONENCODER)与三总线配方键已改挂本节点。
|
||||
private static void registerEssentiaAccessCard() {
|
||||
new ResearchItem("ESSENTIAACCESSCARD", TAB,
|
||||
new AspectList().add(Aspect.MIND, 5).add(Aspect.EXCHANGE, 5).add(Aspect.MAGIC, 3),
|
||||
-2, -2, 2, new ItemStack(ModItems.ESSENTIA_UPGRADE_CARD.get()))
|
||||
.setRound().setParents("DIGISENTIA", "PSEUDO_TUBEFILTER")
|
||||
.setPages(
|
||||
new ResearchPage("tc.research_text.ESSENTIAACCESSCARD"),
|
||||
new ResearchPage(RecipeRegistration.ESSENTIA_UPGRADE_CARD),
|
||||
new ResearchPage(RecipeRegistration.ESSENTIA_LEVEL_EMITTER))
|
||||
.registerResearchItem();
|
||||
}
|
||||
|
||||
// ==================== 22. (-1,-4) GACHABOX 概率之脑====================
|
||||
// 前置: DIGISENTIA(数字化源质);裁决:不加伪前置。
|
||||
// T-M6-RECIPE-2:配方页改挂注魔配方(catalyst=知识核心,罐装脑走方块交互不入配方)
|
||||
// 用户指令:节点移至原源质终端旧址(源质谐振仓 (1,-4) 左边)。
|
||||
private static void registerGachaBox() {
|
||||
new ResearchItem("GACHABOX", TAB,
|
||||
new AspectList().add(Aspect.MIND, 8).add(Aspect.ENTROPY, 5).add(Aspect.MAGIC, 5),
|
||||
-1, -4, 3, new ItemStack(ModItems.BRAIN_OF_PROBABILITY_ITEM.get()))
|
||||
.setRound().setParents("DIGISENTIA")
|
||||
.setPages(
|
||||
new ResearchPage("tc.research_text.GACHABOX.stage.1"),
|
||||
new ResearchPage(RecipeRegistration.GACHA_BOX),
|
||||
new ResearchPage("tc.research_text.GACHABOX.stage.2"))
|
||||
.registerResearchItem();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
|
||||
import java.util.List;
|
||||
import appeng.api.stacks.AEKey;
|
||||
|
||||
public class ItemEssentiaCell extends Item implements IBasicCellItem {
|
||||
|
||||
@@ -81,7 +82,7 @@ public class ItemEssentiaCell extends Item implements IBasicCellItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, appeng.api.stacks.AEKey requestedAddition) {
|
||||
public boolean isBlackListed(ItemStack cellItem, AEKey requestedAddition) {
|
||||
if (requestedAddition instanceof thaumicenergistics.common.integration.appeng.AEssentiaKey) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package thaumicenergistics.common.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
|
||||
import appeng.items.materials.UpgradeCardItem;
|
||||
|
||||
/**
|
||||
* 源质访问卡。
|
||||
*
|
||||
* <p>本卡沿用 AE2 标准升级卡基类 {@link UpgradeCardItem}。AE2 的工厂函数
|
||||
* {@code appeng.api.upgrades.Upgrades.createUpgradeCardItem(Item.Properties)} 的实现即为
|
||||
* {@code return new UpgradeCardItem(p);}(AE2 19.2.17 源码 {@code Upgrades.java:134-136}),
|
||||
* 继承 {@link UpgradeCardItem} 与走该工厂函数在 AE2 侧行为完全等价,同样满足
|
||||
* {@code Upgrades.isUpgradeCardItem(...)} 的升级卡判定,并保留基类固定的「Supported By」提示行机制。
|
||||
*
|
||||
* <p>差异点:基类的 {@code appendHoverText} 只渲染「Supported By」行,无扩展点;本清单要求额外显示一行
|
||||
* 本模组自定义能力描述,故在此覆写 {@code appendHoverText}——先调用父类(保留升级卡判定与 Supported By 机制),
|
||||
* 再追加自定义描述行。
|
||||
*
|
||||
* <p>T-M1-005 范围内**不做** {@code Upgrades.add} 宿主关联;因此「Supported By」行此时为空属预期。
|
||||
*/
|
||||
public class ItemEssentiaUpgradeCard extends UpgradeCardItem {
|
||||
|
||||
/** 基础能力描述行(语言文件键)。 */
|
||||
private static final String DESC_KEY = "tooltip.thaumicenergistics.essentia_upgrade_card.desc";
|
||||
|
||||
public ItemEssentiaUpgradeCard(Item.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> lines, TooltipFlag flag) {
|
||||
super.appendHoverText(stack, context, lines, flag);
|
||||
lines.add(Component.translatable(DESC_KEY));
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,8 @@ import thaumcraft.common.items.TCFunctionalItems;
|
||||
import thaumcraft.common.vis.TCVisHelper;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
|
||||
public class ItemFocusAEWrench extends TCFunctionalItems.FocusItem {
|
||||
|
||||
@@ -79,8 +81,8 @@ public class ItemFocusAEWrench extends TCFunctionalItems.FocusItem {
|
||||
if (item instanceof TCFunctionalItems.WandCastingItem wand) {
|
||||
if (!level.isClientSide && wand.installFocus(other, stack, player)) {
|
||||
level.playSound(null, player.blockPosition(),
|
||||
net.minecraft.sounds.SoundEvents.ITEM_FRAME_ADD_ITEM,
|
||||
net.minecraft.sounds.SoundSource.PLAYERS, 0.45f, 1.2f);
|
||||
SoundEvents.ITEM_FRAME_ADD_ITEM,
|
||||
SoundSource.PLAYERS, 0.45f, 1.2f);
|
||||
}
|
||||
return InteractionResultHolder.sidedSuccess(stack, level.isClientSide);
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package thaumicenergistics.common.items;
|
||||
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.PartHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import thaumicenergistics.common.parts.EssentiaExportBusPart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PartItemEssentiaExportBus extends Item implements IPartItem<EssentiaExportBusPart> {
|
||||
|
||||
public static PartItemEssentiaExportBus create() {
|
||||
return new PartItemEssentiaExportBus(new Item.Properties().stacksTo(64));
|
||||
}
|
||||
|
||||
public PartItemEssentiaExportBus(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
return PartHelper.usePartItem(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<EssentiaExportBusPart> getPartClass() {
|
||||
return EssentiaExportBusPart.class;
|
||||
}
|
||||
|
||||
// 传 this:本类实现了 IPartItem<EssentiaExportBusPart>
|
||||
@Override
|
||||
public EssentiaExportBusPart createPart() {
|
||||
return new EssentiaExportBusPart(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable Item.TooltipContext context,
|
||||
List<Component> tooltip, TooltipFlag flag) {
|
||||
super.appendHoverText(stack, context, tooltip, flag);
|
||||
tooltip.add(Component.translatable("tooltip.thaumicenergistics.essentia_export_bus.desc"));
|
||||
tooltip.add(Component.translatable("tooltip.thaumicenergistics.essentia_export_bus.hint"));
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package thaumicenergistics.common.items;
|
||||
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.PartHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import thaumicenergistics.common.parts.EssentiaImportBusPart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PartItemEssentiaImportBus extends Item implements IPartItem<EssentiaImportBusPart> {
|
||||
|
||||
public static PartItemEssentiaImportBus create() {
|
||||
return new PartItemEssentiaImportBus(new Item.Properties().stacksTo(64));
|
||||
}
|
||||
|
||||
public PartItemEssentiaImportBus(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
return PartHelper.usePartItem(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<EssentiaImportBusPart> getPartClass() {
|
||||
return EssentiaImportBusPart.class;
|
||||
}
|
||||
|
||||
// 构造器要求 IPartItem<?> partItem,传 this 即可
|
||||
@Override
|
||||
public EssentiaImportBusPart createPart() {
|
||||
return new EssentiaImportBusPart(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable Item.TooltipContext context,
|
||||
List<Component> tooltip, TooltipFlag flag) {
|
||||
super.appendHoverText(stack, context, tooltip, flag);
|
||||
tooltip.add(Component.translatable("tooltip.thaumicenergistics.essentia_import_bus.desc"));
|
||||
tooltip.add(Component.translatable("tooltip.thaumicenergistics.essentia_import_bus.hint"));
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package thaumicenergistics.common.items;
|
||||
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.PartHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import thaumicenergistics.common.parts.EssentiaStorageBusPart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PartItemEssentiaStorageBus extends Item implements IPartItem<EssentiaStorageBusPart> {
|
||||
|
||||
public static PartItemEssentiaStorageBus create() {
|
||||
return new PartItemEssentiaStorageBus(new Item.Properties().stacksTo(64));
|
||||
}
|
||||
|
||||
public PartItemEssentiaStorageBus(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
return PartHelper.usePartItem(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<EssentiaStorageBusPart> getPartClass() {
|
||||
return EssentiaStorageBusPart.class;
|
||||
}
|
||||
|
||||
// 传 this:本类实现了 IPartItem<EssentiaStorageBusPart>
|
||||
@Override
|
||||
public EssentiaStorageBusPart createPart() {
|
||||
return new EssentiaStorageBusPart(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable Item.TooltipContext context,
|
||||
List<Component> tooltip, TooltipFlag flag) {
|
||||
super.appendHoverText(stack, context, tooltip, flag);
|
||||
tooltip.add(Component.translatable("tooltip.thaumicenergistics.essentia_storage_bus.desc"));
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package thaumicenergistics.common.items;
|
||||
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.PartHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import thaumicenergistics.common.parts.EssentiaTerminalPart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PartItemEssentiaTerminal extends Item implements IPartItem<EssentiaTerminalPart> {
|
||||
|
||||
public PartItemEssentiaTerminal(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
return PartHelper.usePartItem(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<EssentiaTerminalPart> getPartClass() {
|
||||
return EssentiaTerminalPart.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EssentiaTerminalPart createPart() {
|
||||
return new EssentiaTerminalPart(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable TooltipContext context,
|
||||
List<Component> tooltip, TooltipFlag flag) {
|
||||
super.appendHoverText(stack, context, tooltip, flag);
|
||||
tooltip.add(Component.translatable("tooltip.thaumicenergistics.essentia_terminal.desc"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package thaumicenergistics.common.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
|
||||
import appeng.items.materials.UpgradeCardItem;
|
||||
|
||||
/**
|
||||
* 概率加速卡(M6):手持右键概率之脑直接插入(上限 4 张),缩短产出周期。
|
||||
* 沿用 AE2 升级卡基类(Supported By 机制白送),宿主白名单见主类 Upgrades.add。
|
||||
*/
|
||||
public class ProbabilityAcceleratorCardItem extends UpgradeCardItem {
|
||||
|
||||
private static final String DESC_KEY = "tooltip.thaumicenergistics.probability_accelerator_card.desc";
|
||||
|
||||
public ProbabilityAcceleratorCardItem(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> lines, TooltipFlag flag) {
|
||||
super.appendHoverText(stack, context, lines, flag);
|
||||
lines.add(Component.translatable(DESC_KEY));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package thaumicenergistics.common.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
|
||||
import appeng.items.materials.UpgradeCardItem;
|
||||
|
||||
/**
|
||||
* vis 连接卡(T-M3-VISCARD-REV:升级卡化)——插入无线奥术合成终端的升级槽后,
|
||||
* 终端自动连接所在 ME 网络的要素中继接口为菜单内法杖补 vis。
|
||||
* 沿用 AE2 升级卡基类(Supported By 机制白送),升级槽白名单见主类 Upgrades.add。
|
||||
*/
|
||||
public class VisConnectorCardItem extends UpgradeCardItem {
|
||||
|
||||
private static final String DESC_KEY = "tooltip.thaumicenergistics.vis_connector_card.desc";
|
||||
|
||||
public VisConnectorCardItem(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> lines, TooltipFlag flag) {
|
||||
super.appendHoverText(stack, context, lines, flag);
|
||||
lines.add(Component.translatable(DESC_KEY));
|
||||
}
|
||||
}
|
||||
+10
-9
@@ -6,25 +6,26 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
import appeng.helpers.WirelessTerminalMenuHost;
|
||||
import appeng.items.tools.powered.WirelessTerminalItem;
|
||||
import appeng.menu.locator.ItemMenuHostLocator;
|
||||
|
||||
/**
|
||||
* 无线源质终端物品。继承 AE2 的WirelessTerminalItem
|
||||
* 右键使用时打开仅显示源质的 AE2 无线终端 GUI。
|
||||
*/
|
||||
public class WirelessEssentiaTerminalItem extends WirelessTerminalItem {
|
||||
|
||||
public WirelessEssentiaTerminalItem(DoubleSupplier powerCapacity, Properties props) {
|
||||
/**
|
||||
* 无线奥术合成终端物品:绑定/能量/安全复用 AE2 无线终端基类,
|
||||
* 菜单复用有线奥术合成终端 {@code ContainerArcaneCraftingTerminal}(vis 记账单套)。
|
||||
*/
|
||||
public class WirelessArcaneCraftingTerminalItem extends WirelessTerminalItem {
|
||||
|
||||
public WirelessArcaneCraftingTerminalItem(DoubleSupplier powerCapacity, Properties props) {
|
||||
super(powerCapacity, props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuType<?> getMenuType() {
|
||||
return thaumicenergistics.init.ModMenuTypes.WIRELESS_ESSENTIA_TERMINAL.get();
|
||||
return thaumicenergistics.init.ModMenuTypes.WIRELESS_ARCANE_CRAFTING_TERMINAL.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,7 +34,7 @@ public class WirelessEssentiaTerminalItem extends WirelessTerminalItem {
|
||||
Player player,
|
||||
ItemMenuHostLocator locator,
|
||||
@Nullable BlockHitResult hitResult) {
|
||||
return new WirelessEssentiaTerminalMenuHost(
|
||||
return new WirelessArcaneCraftingTerminalMenuHost(
|
||||
this,
|
||||
player,
|
||||
locator,
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
package thaumicenergistics.common.items;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.core.component.DataComponentType;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.component.ItemContainerContents;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.features.Locatables;
|
||||
import appeng.api.ids.AEComponents;
|
||||
import appeng.api.inventories.ISegmentedInventory;
|
||||
import appeng.api.inventories.InternalInventory;
|
||||
import appeng.api.storage.ILinkStatus;
|
||||
import appeng.helpers.WirelessTerminalMenuHost;
|
||||
import appeng.menu.ISubMenu;
|
||||
import appeng.menu.locator.ItemMenuHostLocator;
|
||||
import appeng.util.inv.AppEngInternalInventory;
|
||||
import appeng.util.inv.InternalInventoryHost;
|
||||
|
||||
import net.neoforged.fml.ModList;
|
||||
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.parts.ArcaneCraftingTerminalPart;
|
||||
import thaumicenergistics.init.ModComponents;
|
||||
|
||||
/**
|
||||
* 无线奥术合成终端的 MenuHost:复刻 AE2 官方 {@code WirelessCraftingTerminalMenuHost} 范式,
|
||||
* 合成格/法杖槽持久化进物品组件(关菜单或存背包不丢料)。
|
||||
* 子库存 id 复用有线部件常量,{@code ContainerArcaneCraftingTerminal} 无需改动即可识别本宿主。
|
||||
* <p>
|
||||
* WTBRIDGE:量子桥卡联动为何复刻而非引用——ae2wtlib 桥卡逻辑在其自有
|
||||
* {@code WTMenuHost}(类层级硬绑定其 {@code ItemWT}),软依赖 + Java 单继承下无法继承复用,
|
||||
* 故在本类覆写 {@code updateLinkStatus}/{@code getLinkStatus} 复刻其公开 API 语义。
|
||||
*/
|
||||
public class WirelessArcaneCraftingTerminalMenuHost
|
||||
extends WirelessTerminalMenuHost<WirelessArcaneCraftingTerminalItem>
|
||||
implements ISegmentedInventory {
|
||||
|
||||
// ==================== WTBRIDGE 软依赖常量(id 来源:ae2wtlib 19.5.1,升级对齐点) ====================
|
||||
/** 量子桥卡物品 id(ae2wtlib AE2wtlibItems.QUANTUM_BRIDGE_CARD 注册名)。 */
|
||||
public static final ResourceLocation AE2WTLIB_QUANTUM_BRIDGE_CARD =
|
||||
ResourceLocation.fromNamespaceAndPath("ae2wtlib", "quantum_bridge_card");
|
||||
/** 奇点组件类型注册名(ae2wtlib AE2wtlibComponents register("singularity",...),挂在终端 ItemStack 上)。 */
|
||||
public static final ResourceLocation AE2WTLIB_SINGULARITY_COMPONENT =
|
||||
ResourceLocation.fromNamespaceAndPath("ae2wtlib", "singularity");
|
||||
/** ae2wtlib modid(ModList 守护用)。 */
|
||||
public static final String AE2WTLIB_MODID = "ae2wtlib";
|
||||
/** WTBRIDGE-SLOT:奇点子库存寻址 id(getSubInventory 用,本模组命名空间)。 */
|
||||
public static final ResourceLocation INV_SINGULARITY =
|
||||
ResourceLocation.fromNamespaceAndPath(ThaumicEnergistics.MODID, "wact_singularity");
|
||||
|
||||
private final AppEngInternalInventory craftingGrid;
|
||||
private final AppEngInternalInventory wandInv;
|
||||
/** WTBRIDGE-SLOT:量子缠绕奇点槽(1 格),槽变即整包写回 ae2wtlib:singularity 组件。 */
|
||||
private final AppEngInternalInventory singularityInv;
|
||||
/** 桥卡链路当前是否有效(本类自有状态:AE2 基类 linkStatus 字段 private 不可直改)。 */
|
||||
private boolean quantumBridgeLinked;
|
||||
|
||||
public WirelessArcaneCraftingTerminalMenuHost(
|
||||
WirelessArcaneCraftingTerminalItem item,
|
||||
Player player,
|
||||
ItemMenuHostLocator locator,
|
||||
BiConsumer<Player, ISubMenu> returnToMainMenu) {
|
||||
super(item, player, locator, returnToMainMenu);
|
||||
this.craftingGrid = createPersistedInv(player, this.getItemStack(), 9, AEComponents.CRAFTING_INV);
|
||||
this.wandInv = createPersistedInv(player, this.getItemStack(), 1, ModComponents.WAND_INV.get());
|
||||
this.singularityInv = createSingularityInv(player, this.getItemStack());
|
||||
}
|
||||
|
||||
/**
|
||||
* WTBRIDGE-SLOT:奇点子库存——ae2wtlib 语义中奇点装在终端 ItemStack 的
|
||||
* {@code ae2wtlib:singularity} 组件(值 = 奇点 ItemStack)上,槽变即整包写回;
|
||||
* 组件类型经注册表软查,ae2wtlib 缺席时跳过读写(准入同时拦截,物品进不来不会丢)。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private AppEngInternalInventory createSingularityInv(Player player, ItemStack stack) {
|
||||
var inv = new AppEngInternalInventory(new InternalInventoryHost() {
|
||||
@Override
|
||||
public void saveChangedInventory(AppEngInternalInventory changed) {
|
||||
var type = BuiltInRegistries.DATA_COMPONENT_TYPE
|
||||
.getOptional(AE2WTLIB_SINGULARITY_COMPONENT).orElse(null);
|
||||
if (type != null) {
|
||||
stack.set((DataComponentType<ItemStack>) type, changed.getStackInSlot(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClientSide() {
|
||||
return player.level().isClientSide();
|
||||
}
|
||||
}, 1);
|
||||
var type = BuiltInRegistries.DATA_COMPONENT_TYPE
|
||||
.getOptional(AE2WTLIB_SINGULARITY_COMPONENT).orElse(null);
|
||||
if (type != null) {
|
||||
ItemStack persisted = stack.getOrDefault((DataComponentType<ItemStack>) type, ItemStack.EMPTY);
|
||||
if (!persisted.isEmpty()) {
|
||||
inv.setItemDirect(0, persisted);
|
||||
}
|
||||
}
|
||||
return inv;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public InternalInventory getSubInventory(ResourceLocation id) {
|
||||
if (id.equals(ArcaneCraftingTerminalPart.INV_CRAFTING)) {
|
||||
return craftingGrid;
|
||||
} else if (id.equals(ArcaneCraftingTerminalPart.INV_WAND)) {
|
||||
return wandInv;
|
||||
} else if (id.equals(INV_SINGULARITY)) {
|
||||
return singularityInv;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 法杖槽内容写回终端物品组件(直改法杖 stack 组件不触发库存回调,充能后由菜单显式调用)。 */
|
||||
public void saveWandInv() {
|
||||
this.getItemStack().set(ModComponents.WAND_INV.get(), this.wandInv.toItemContainerContents());
|
||||
}
|
||||
|
||||
// ==================== WTBRIDGE:量子桥卡生效逻辑(照抄 ae2wtlib isQuantumLinked 语义) ====================
|
||||
|
||||
/**
|
||||
* 桥卡链路有效时强制 connected(跨维/无限距离);否则逐字节回落 AE2 原生状态。
|
||||
*/
|
||||
@Override
|
||||
public ILinkStatus getLinkStatus() {
|
||||
if (this.quantumBridgeLinked) {
|
||||
return ILinkStatus.ofConnected();
|
||||
}
|
||||
return super.getLinkStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* 先判桥卡链路(有效且有余能 → connected),否则完整回落 AE2 原生判定(访问点/范围/电量)。
|
||||
*/
|
||||
@Override
|
||||
protected void updateLinkStatus() {
|
||||
this.quantumBridgeLinked = false;
|
||||
if (isQuantumLinkedViaBridgeCard() && consumeIdlePower(Actionable.SIMULATE)) {
|
||||
this.quantumBridgeLinked = true;
|
||||
return;
|
||||
}
|
||||
super.updateLinkStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复刻 ae2wtlib {@code WTMenuHost.isQuantumLinked}:卡在槽 → 奇点组件 → 频率查桥。
|
||||
* 全程零 ae2wtlib 编译引用(注册表软查 + AE2 公开 API),ae2wtlib 缺席时恒 false。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean isQuantumLinkedViaBridgeCard() {
|
||||
if (!ModList.get().isLoaded(AE2WTLIB_MODID)) {
|
||||
return false;
|
||||
}
|
||||
// 1. 桥卡物品软查 + 是否已装入 WACT 升级槽(AE2 标准 IUpgradeInventory,准入映射见 ThaumicEnergistics)
|
||||
var card = BuiltInRegistries.ITEM.getOptional(AE2WTLIB_QUANTUM_BRIDGE_CARD).orElse(null);
|
||||
if (card == null || card == Items.AIR) {
|
||||
return false;
|
||||
}
|
||||
if (!this.getItem().getUpgrades(this.getItemStack()).isInstalled(card)) {
|
||||
return false;
|
||||
}
|
||||
// 2. 奇点组件类型软查(ae2wtlib 注册于 BuiltInRegistries.DATA_COMPONENT_TYPE)
|
||||
var type = BuiltInRegistries.DATA_COMPONENT_TYPE.getOptional(AE2WTLIB_SINGULARITY_COMPONENT).orElse(null);
|
||||
if (type == null) {
|
||||
return false;
|
||||
}
|
||||
ItemStack singularity = this.getItemStack().getOrDefault((DataComponentType<ItemStack>) type, ItemStack.EMPTY);
|
||||
if (singularity.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
// 3. 缠绕奇点频率(AE2 公开组件)→ Locatables 查桥(对齐 ae2wtlib findQuantumBridge 的 ±freq 语义)
|
||||
Long freq = singularity.get(AEComponents.ENTANGLED_SINGULARITY_ID);
|
||||
if (freq == null) {
|
||||
return false;
|
||||
}
|
||||
var level = this.getPlayer().level();
|
||||
var bridges = Locatables.quantumNetworkBridges();
|
||||
return bridges.get(level, freq) != null || bridges.get(level, -freq) != null;
|
||||
}
|
||||
|
||||
/** 官方 createCraftingInv 推广版:子库存读写进指定物品组件。 */
|
||||
private static AppEngInternalInventory createPersistedInv(Player player, ItemStack stack, int size,
|
||||
DataComponentType<ItemContainerContents> component) {
|
||||
var inv = new AppEngInternalInventory(new InternalInventoryHost() {
|
||||
@Override
|
||||
public void saveChangedInventory(AppEngInternalInventory changed) {
|
||||
stack.set(component, changed.toItemContainerContents());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClientSide() {
|
||||
return player.level().isClientSide();
|
||||
}
|
||||
}, size);
|
||||
inv.fromItemContainerContents(stack.getOrDefault(component, ItemContainerContents.EMPTY));
|
||||
return inv;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import thaumicenergistics.common.tiles.TileEssentiaProvider;
|
||||
import thaumicenergistics.common.tiles.TileEssentiaProviderConnection;
|
||||
import thaumicenergistics.init.ModBlocks;
|
||||
import net.minecraft.world.item.component.CustomData;
|
||||
|
||||
/**
|
||||
* 源质无线绑定工具:
|
||||
@@ -31,11 +31,11 @@ public class WirelessConnectorItem extends Item {
|
||||
}
|
||||
|
||||
private static CompoundTag getSelectionTag(ItemStack stack) {
|
||||
return stack.getOrDefault(DataComponents.CUSTOM_DATA, net.minecraft.world.item.component.CustomData.EMPTY).copyTag();
|
||||
return stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).copyTag();
|
||||
}
|
||||
|
||||
private static void setSelectionTag(ItemStack stack, CompoundTag tag) {
|
||||
stack.set(DataComponents.CUSTOM_DATA, net.minecraft.world.item.component.CustomData.of(tag));
|
||||
stack.set(DataComponents.CUSTOM_DATA, CustomData.of(tag));
|
||||
}
|
||||
|
||||
private static void clearSelection(ItemStack stack) {
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package thaumicenergistics.common.items;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import appeng.api.util.KeyTypeSelection;
|
||||
import appeng.helpers.WirelessTerminalMenuHost;
|
||||
import appeng.menu.ISubMenu;
|
||||
import appeng.menu.locator.ItemMenuHostLocator;
|
||||
|
||||
/**
|
||||
* 无线源质终端的 MenuHost:继承 AE2 WirelessTerminalMenuHost,覆盖 getKeyTypeSelection()
|
||||
* 仅允许源质类型(其余 WAP 连接/电力/存储复用父类)。
|
||||
*/
|
||||
public class WirelessEssentiaTerminalMenuHost
|
||||
extends WirelessTerminalMenuHost<WirelessEssentiaTerminalItem> {
|
||||
|
||||
public WirelessEssentiaTerminalMenuHost(
|
||||
WirelessEssentiaTerminalItem item,
|
||||
Player player,
|
||||
ItemMenuHostLocator locator,
|
||||
BiConsumer<Player, ISubMenu> returnToMainMenu) {
|
||||
super(item, player, locator, returnToMainMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅允许源质类型,禁止物品和流体(与 EssentiaTerminalPart 一致)。
|
||||
*/
|
||||
@Override
|
||||
public KeyTypeSelection getKeyTypeSelection() {
|
||||
return new KeyTypeSelection(
|
||||
() -> {},
|
||||
keyType -> keyType == thaumicenergistics.common.integration.appeng.AEssentiaKeyType.INSTANCE);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.container.ContainerEssentiaCellWorkbench;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
/**
|
||||
* 客户端→服务端 网络包:源质元件工作台分区操作。
|
||||
@@ -89,7 +90,7 @@ public record CellWorkbenchC2SPacket(
|
||||
boolean changed;
|
||||
switch (this.action) {
|
||||
case ACTION_REQUEST -> {
|
||||
if (ctx.player() instanceof net.minecraft.server.level.ServerPlayer sp) {
|
||||
if (ctx.player() instanceof ServerPlayer sp) {
|
||||
CellWorkbenchSyncPacket.sendToClient(sp, menu.getPartitionAspects());
|
||||
}
|
||||
return;
|
||||
@@ -108,7 +109,7 @@ public record CellWorkbenchC2SPacket(
|
||||
default -> changed = false;
|
||||
}
|
||||
if (changed) {
|
||||
if (ctx.player() instanceof net.minecraft.server.level.ServerPlayer sp) {
|
||||
if (ctx.player() instanceof ServerPlayer sp) {
|
||||
CellWorkbenchSyncPacket.sendToClient(sp, menu.getPartitionAspects());
|
||||
}
|
||||
}
|
||||
|
||||
+12
-8
@@ -6,6 +6,10 @@ import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import appeng.menu.me.common.MEStorageMenu;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import thaumicenergistics.common.container.EssentiaFillHelper;
|
||||
import thaumicenergistics.common.container.ThEEssentiaMenuAccess;
|
||||
|
||||
/**
|
||||
* 客户端→服务端:源质容器存入 ME 网络。
|
||||
@@ -15,7 +19,7 @@ import thaumicenergistics.ThaumicEnergistics;
|
||||
* </ul>
|
||||
*/
|
||||
public record EssentiaTerminalDepositC2SPacket(int containerId, int slotIndex,
|
||||
net.minecraft.world.item.ItemStack sourceStack) implements CustomPacketPayload {
|
||||
ItemStack sourceStack) implements CustomPacketPayload {
|
||||
|
||||
public static final Type<EssentiaTerminalDepositC2SPacket> TYPE =
|
||||
new Type<>(ThaumicEnergistics.id("essentia_terminal_deposit"));
|
||||
@@ -24,17 +28,17 @@ public record EssentiaTerminalDepositC2SPacket(int containerId, int slotIndex,
|
||||
StreamCodec.composite(
|
||||
ByteBufCodecs.VAR_INT, EssentiaTerminalDepositC2SPacket::containerId,
|
||||
ByteBufCodecs.VAR_INT, EssentiaTerminalDepositC2SPacket::slotIndex,
|
||||
net.minecraft.world.item.ItemStack.OPTIONAL_STREAM_CODEC, EssentiaTerminalDepositC2SPacket::sourceStack,
|
||||
ItemStack.OPTIONAL_STREAM_CODEC, EssentiaTerminalDepositC2SPacket::sourceStack,
|
||||
EssentiaTerminalDepositC2SPacket::new
|
||||
);
|
||||
|
||||
/** 手持源质物品存入(客户端可能持有在 carried 或主手)。 */
|
||||
public static EssentiaTerminalDepositC2SPacket fromClientStack(int containerId, net.minecraft.world.item.ItemStack stack) {
|
||||
public static EssentiaTerminalDepositC2SPacket fromClientStack(int containerId, ItemStack stack) {
|
||||
return new EssentiaTerminalDepositC2SPacket(containerId, -1, stack.copy());
|
||||
}
|
||||
|
||||
/** 从玩家背包格存入(Shift+右键背包格)。 */
|
||||
public static EssentiaTerminalDepositC2SPacket fromSlot(int containerId, int slotIndex, net.minecraft.world.item.ItemStack stack) {
|
||||
public static EssentiaTerminalDepositC2SPacket fromSlot(int containerId, int slotIndex, ItemStack stack) {
|
||||
return new EssentiaTerminalDepositC2SPacket(containerId, slotIndex, stack.copy());
|
||||
}
|
||||
|
||||
@@ -47,15 +51,15 @@ public record EssentiaTerminalDepositC2SPacket(int containerId, int slotIndex,
|
||||
ctx.enqueueWork(() -> {
|
||||
// 任意 ME 终端菜单都支持:源质容器右键 → 源质存入网络
|
||||
if (ctx.player().containerMenu.containerId == this.containerId
|
||||
&& ctx.player().containerMenu instanceof appeng.menu.me.common.MEStorageMenu menu
|
||||
&& menu instanceof thaumicenergistics.common.container.ThEEssentiaMenuAccess acc) {
|
||||
&& ctx.player().containerMenu instanceof MEStorageMenu menu
|
||||
&& menu instanceof ThEEssentiaMenuAccess acc) {
|
||||
var player = menu.getPlayerInventory().player;
|
||||
// 源质物品:优先包携带的 sourceStack(客户端真实来源);否则回退菜单 carried/主手
|
||||
var source = !this.sourceStack.isEmpty() ? this.sourceStack
|
||||
: (!menu.getCarried().isEmpty() ? menu.getCarried()
|
||||
: player.getMainHandItem());
|
||||
if (!source.isEmpty()) {
|
||||
var result = thaumicenergistics.common.container.EssentiaFillHelper.extractContainerContent(
|
||||
var result = EssentiaFillHelper.extractContainerContent(
|
||||
acc.thE_getStorage(), acc.thE_getEnergySource(),
|
||||
menu.getActionSource(), source);
|
||||
if (result != null) {
|
||||
@@ -64,7 +68,7 @@ public record EssentiaTerminalDepositC2SPacket(int containerId, int slotIndex,
|
||||
player.getInventory().setItem(this.slotIndex, result);
|
||||
} else {
|
||||
// 手持:清空 carried,空容器放回玩家背包(不留 carried,防被 AE2 自动放入网络)
|
||||
menu.setCarried(net.minecraft.world.item.ItemStack.EMPTY);
|
||||
menu.setCarried(ItemStack.EMPTY);
|
||||
if (!result.isEmpty()) {
|
||||
if (!player.getInventory().add(result)) {
|
||||
player.drop(result, false);
|
||||
|
||||
@@ -8,6 +8,9 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import appeng.menu.me.common.MEStorageMenu;
|
||||
import thaumicenergistics.common.container.EssentiaFillHelper;
|
||||
import thaumicenergistics.common.container.ThEEssentiaMenuAccess;
|
||||
|
||||
/**
|
||||
* 客户端→服务端:源质终端右键源质条目装罐。
|
||||
@@ -43,8 +46,8 @@ public record EssentiaTerminalFillC2SPacket(int containerId, ResourceLocation as
|
||||
ctx.enqueueWork(() -> {
|
||||
// 通用化:任意 ME 终端菜单都支持右键源质条目装罐(源质终端/奥术合成终端/AE2 ME 终端等)
|
||||
if (ctx.player().containerMenu.containerId == this.containerId
|
||||
&& ctx.player().containerMenu instanceof appeng.menu.me.common.MEStorageMenu menu
|
||||
&& menu instanceof thaumicenergistics.common.container.ThEEssentiaMenuAccess acc) {
|
||||
&& ctx.player().containerMenu instanceof MEStorageMenu menu
|
||||
&& menu instanceof ThEEssentiaMenuAccess acc) {
|
||||
var player = menu.getPlayerInventory().player;
|
||||
// ⚠ 必须用玩家真实栈(carried/主手)而非包里的拷贝:装罐会原地消耗空安瓿(shrink)
|
||||
// 或修改罐子内容(setAspects)。若用 sourceStack(拷贝),消耗/修改不落真实物品——
|
||||
@@ -53,7 +56,7 @@ public record EssentiaTerminalFillC2SPacket(int containerId, ResourceLocation as
|
||||
var source = !menu.getCarried().isEmpty() ? menu.getCarried()
|
||||
: (!player.getMainHandItem().isEmpty() ? player.getMainHandItem()
|
||||
: this.sourceStack);
|
||||
thaumicenergistics.common.container.EssentiaFillHelper.fillContainerFromGrid(
|
||||
EssentiaFillHelper.fillContainerFromGrid(
|
||||
acc.thE_getStorage(), acc.thE_getEnergySource(),
|
||||
menu.getActionSource(), player, source, this.aspectId);
|
||||
menu.broadcastChanges();
|
||||
|
||||
@@ -7,12 +7,13 @@ import thaumcraft.common.entities.golem.ThaumcraftGolemEntity;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import thaumicenergistics.client.render.layer.GolemBackpackLayer;
|
||||
|
||||
/**
|
||||
* 客户端侧缓存:存储每个傀儡的背包连接状态和皮肤。
|
||||
*
|
||||
* 由 {@link GolemBackpackSyncPacket#handleOnClient} 写入,
|
||||
* 由 {@link thaumicenergistics.client.render.layer.GolemBackpackLayer} 读取。
|
||||
* 由 {@link GolemBackpackLayer} 读取。
|
||||
*
|
||||
* 使用 WeakHashMap 以避免实体被 GC 后内存泄漏。
|
||||
*
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.entities.BackpackSkins;
|
||||
|
||||
+3
-2
@@ -7,6 +7,7 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.container.ContainerKnowledgeInscriber;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
|
||||
/**
|
||||
* 客户端→服务端 网络包:同步知识记录仪合成网格中某个幽灵槽的内容。
|
||||
@@ -27,8 +28,8 @@ public record KnowledgeInscriberGhostSlotPacket(
|
||||
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, KnowledgeInscriberGhostSlotPacket> STREAM_CODEC =
|
||||
StreamCodec.composite(
|
||||
net.minecraft.network.codec.ByteBufCodecs.VAR_INT, KnowledgeInscriberGhostSlotPacket::containerId,
|
||||
net.minecraft.network.codec.ByteBufCodecs.VAR_INT, KnowledgeInscriberGhostSlotPacket::slotIndex,
|
||||
ByteBufCodecs.VAR_INT, KnowledgeInscriberGhostSlotPacket::containerId,
|
||||
ByteBufCodecs.VAR_INT, KnowledgeInscriberGhostSlotPacket::slotIndex,
|
||||
ItemStack.OPTIONAL_STREAM_CODEC, KnowledgeInscriberGhostSlotPacket::stack,
|
||||
KnowledgeInscriberGhostSlotPacket::new
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package thaumicenergistics.common.network;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
|
||||
@@ -14,7 +14,6 @@ import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.api.ids.AEComponents;
|
||||
import appeng.api.inventories.InternalInventory;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
@@ -23,17 +22,12 @@ import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.service.P2PService;
|
||||
import appeng.menu.locator.MenuLocators;
|
||||
import appeng.menu.MenuOpener;
|
||||
import appeng.menu.locator.MenuLocators;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.parts.p2p.P2PTunnelPart;
|
||||
import appeng.parts.reporting.AbstractTerminalPart;
|
||||
import appeng.util.inv.AppEngInternalInventory;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.items.TCFunctionalItems;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
import thaumicenergistics.init.ModMenuTypes;
|
||||
|
||||
public class ArcaneCraftingTerminalPart extends AbstractTerminalPart implements IGridTickable {
|
||||
@@ -58,8 +52,6 @@ public class ArcaneCraftingTerminalPart extends AbstractTerminalPart implements
|
||||
|
||||
/** 充能间隔:每 tick 抽取一次。与 TC 能量节点池子每 tick 重置的频率、原版充能中继一致;无需放大。 */
|
||||
private static final int VIS_REPLENISH_INTERVAL = 1;
|
||||
/** 每 tick 每要素最大充能 cV,与原版奥术工作台充能中继(MagicWorkbenchCharger)一致(5 cV/tick = 1 vis/s)。 */
|
||||
private static final int MAX_CVIS_PER_TICK = 5;
|
||||
private static final String NBT_KEY_VIS_SOURCE_FREQ = "visSourceFreq";
|
||||
|
||||
/** 内存卡设定的 vis 源 P2P 频率;0 = 未设置(不自动充能)。 */
|
||||
@@ -124,45 +116,8 @@ public class ArcaneCraftingTerminalPart extends AbstractTerminalPart implements
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
|
||||
if (visSourceFreq == 0) {
|
||||
return TickRateModulation.SAME;
|
||||
}
|
||||
ItemStack wandStack = wandInv.getStackInSlot(0);
|
||||
if (wandStack.isEmpty() || !(wandStack.getItem() instanceof TCFunctionalItems.WandCastingItem wand)) {
|
||||
return TickRateModulation.SAME;
|
||||
}
|
||||
IGrid grid = node.getGrid();
|
||||
if (grid == null) {
|
||||
return TickRateModulation.SAME;
|
||||
}
|
||||
P2PService p2p = P2PService.get(grid);
|
||||
if (p2p == null) {
|
||||
return TickRateModulation.SAME;
|
||||
}
|
||||
P2PTunnelPart<?> input = p2p.getInput(visSourceFreq);
|
||||
if (!(input instanceof VisInterfacePart visSource)) {
|
||||
return TickRateModulation.SAME;
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
int maxVis = wand.getMaxVis(wandStack);
|
||||
for (Aspect primal : Aspect.getPrimalAspects()) {
|
||||
int needed = maxVis - wand.getVis(wandStack, primal);
|
||||
if (needed <= 0) {
|
||||
continue;
|
||||
}
|
||||
ResourceLocation id = TCReflection.getAspectId(primal);
|
||||
if (id == null) {
|
||||
continue;
|
||||
}
|
||||
// 每 tick 申请真实量(与池子每 tick 重置对齐),充入真实量,vis 守恒
|
||||
int got = visSource.consumeVis(id, Math.min(MAX_CVIS_PER_TICK, needed));
|
||||
if (got > 0) {
|
||||
wand.addRealVis(wandStack, primal, got, true);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
// 充能体抽至 ArcaneVisReplenish 单套实现(无线终端菜单打开期间共用,T-M3-IMPL D1),行为零变化
|
||||
if (ArcaneVisReplenish.replenish(node.getGrid(), visSourceFreq, wandInv.getStackInSlot(0))) {
|
||||
// 法杖 vis 存储在 ItemStack NBT,手动标记保存
|
||||
getHost().markForSave();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package thaumicenergistics.common.parts;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.me.service.P2PService;
|
||||
import appeng.parts.p2p.P2PTunnelPart;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.items.TCFunctionalItems;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
|
||||
/**
|
||||
* 法杖 vis 充能逻辑单套实现(共享核心充能循环):
|
||||
* 有线部件 IGridTickable 经 P2P 频率定位({@link #replenish},行为零变化);
|
||||
* 无线终端升级卡自动模式遍历网络全部要素中继接口({@link #replenishAuto},T-M3-VISCARD-REV)。
|
||||
*/
|
||||
public final class ArcaneVisReplenish {
|
||||
|
||||
/** 每 tick 每要素最大充能 cV,与原版奥术工作台充能中继(MagicWorkbenchCharger)一致(5 cV/tick = 1 vis/s)。 */
|
||||
private static final int MAX_CVIS_PER_TICK = 5;
|
||||
|
||||
private ArcaneVisReplenish() {}
|
||||
|
||||
/**
|
||||
* 有线路径:按 P2P 频率定位要素中继接口后充能。
|
||||
*
|
||||
* @return 是否发生了充能(调用方据此标记保存)
|
||||
*/
|
||||
public static boolean replenish(IGrid grid, short visSourceFreq, ItemStack wandStack) {
|
||||
if (grid == null || visSourceFreq == 0) {
|
||||
return false;
|
||||
}
|
||||
P2PService p2p = P2PService.get(grid);
|
||||
if (p2p == null) {
|
||||
return false;
|
||||
}
|
||||
P2PTunnelPart<?> input = p2p.getInput(visSourceFreq);
|
||||
if (!(input instanceof VisInterfacePart visSource)) {
|
||||
return false;
|
||||
}
|
||||
return chargeFrom(visSource, wandStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无线自动路径(vis 连接卡升级卡):遍历网络内全部要素中继接口逐个尝试充能,
|
||||
* 多接口自动切换;无接口/无 vis 时静默。
|
||||
*
|
||||
* @return 是否发生了充能(调用方据此标记保存)
|
||||
*/
|
||||
public static boolean replenishAuto(IGrid grid, ItemStack wandStack) {
|
||||
if (grid == null || wandStack.isEmpty()
|
||||
|| !(wandStack.getItem() instanceof TCFunctionalItems.WandCastingItem)) {
|
||||
return false;
|
||||
}
|
||||
boolean changed = false;
|
||||
for (VisInterfacePart visSource : grid.getMachines(VisInterfacePart.class)) {
|
||||
if (chargeFrom(visSource, wandStack)) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/** 共享核心充能循环:从单个要素中继接口为法杖补 vis;每 tick 申请真实量(与池子每 tick 重置对齐),vis 守恒。 */
|
||||
private static boolean chargeFrom(VisInterfacePart visSource, ItemStack wandStack) {
|
||||
if (wandStack.isEmpty() || !(wandStack.getItem() instanceof TCFunctionalItems.WandCastingItem wand)) {
|
||||
return false;
|
||||
}
|
||||
boolean changed = false;
|
||||
int maxVis = wand.getMaxVis(wandStack);
|
||||
for (Aspect primal : Aspect.getPrimalAspects()) {
|
||||
int needed = maxVis - wand.getVis(wandStack, primal);
|
||||
if (needed <= 0) {
|
||||
continue;
|
||||
}
|
||||
ResourceLocation id = TCReflection.getAspectId(primal);
|
||||
if (id == null) {
|
||||
continue;
|
||||
}
|
||||
int got = visSource.consumeVis(id, Math.min(MAX_CVIS_PER_TICK, needed));
|
||||
if (got > 0) {
|
||||
wand.addRealVis(wandStack, primal, got, true);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
package thaumicenergistics.common.parts;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.stacks.GenericStack;
|
||||
import appeng.api.util.IConfigManagerBuilder;
|
||||
import appeng.api.util.KeyTypeSelection;
|
||||
import appeng.api.util.KeyTypeSelectionHost;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.parts.automation.IOBusPart;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.IEssentiaTransport;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.api.storage.AspectStack;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKeyType;
|
||||
import thaumicenergistics.common.integration.tc.EssentiaConversionHelper;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
import thaumicenergistics.init.ModMenuTypes;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class EssentiaExportBusPart extends IOBusPart
|
||||
implements KeyTypeSelectionHost {
|
||||
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_BASE =
|
||||
ThaumicEnergistics.id("parts/essentia_export_bus_base");
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_OFF =
|
||||
ThaumicEnergistics.id("parts/essentia_export_bus_off");
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_HAS_CHANNEL =
|
||||
ThaumicEnergistics.id("parts/essentia_export_bus_has_channel");
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_ON =
|
||||
ThaumicEnergistics.id("parts/essentia_export_bus_on");
|
||||
|
||||
public static final PartModel MODEL_OFF = new PartModel(RL_BASE, RL_OFF);
|
||||
public static final PartModel MODEL_HAS_CHANNEL = new PartModel(RL_BASE, RL_HAS_CHANNEL);
|
||||
public static final PartModel MODEL_ON = new PartModel(RL_BASE, RL_ON);
|
||||
|
||||
private static final double IDLE_POWER = 0.5;
|
||||
private static final double TRANSFER_POWER = EssentiaConversionHelper.AE_PER_ESSENTIA;
|
||||
|
||||
private boolean isWorkingFlag = false;
|
||||
|
||||
private final KeyTypeSelection keyTypeSelection = new KeyTypeSelection(
|
||||
selection -> { },
|
||||
keyType -> keyType == AEssentiaKeyType.INSTANCE);
|
||||
|
||||
private long storedEnergy = 0;
|
||||
|
||||
/**
|
||||
* 单次导出量 = 基础速率 8 × 每 tick 操作次数(受加速卡影响)。
|
||||
* AE2 加速卡语义:0卡=1、1卡=8、2卡=32、3卡=64、4卡=96(getOperationsPerTick)。
|
||||
*/
|
||||
private long getExportRate() {
|
||||
return 8L * Math.max(1, getOperationsPerTick());
|
||||
}
|
||||
|
||||
public EssentiaExportBusPart(IPartItem<?> partItem) {
|
||||
super(TickRates.ExportBus, Set.of(AEssentiaKeyType.INSTANCE), partItem);
|
||||
this.getMainNode().setIdlePowerUsage(IDLE_POWER);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerSettings(IConfigManagerBuilder builder) {
|
||||
super.registerSettings(builder);
|
||||
builder.registerSetting(Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch) {
|
||||
bch.addBox(4, 4, 12, 12, 12, 14);
|
||||
bch.addBox(5, 5, 14, 11, 11, 15);
|
||||
bch.addBox(6, 6, 15, 10, 10, 16);
|
||||
bch.addBox(6, 6, 11, 10, 10, 12);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels() {
|
||||
if (isWorkingFlag) return MODEL_ON;
|
||||
if (getMainNode() != null && getMainNode().isOnline()) return MODEL_HAS_CHANNEL;
|
||||
return MODEL_OFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doBusWork(IGrid grid) {
|
||||
this.isWorkingFlag = false;
|
||||
|
||||
Direction side = this.getSide();
|
||||
if (side == null) return false;
|
||||
BlockPos adjacentPos = this.getBlockEntity().getBlockPos().relative(side);
|
||||
Level levelRaw = this.getLevel();
|
||||
if (!(levelRaw instanceof ServerLevel level)) return false;
|
||||
if (!level.isLoaded(adjacentPos)) return false;
|
||||
BlockEntity adjacentBE = level.getBlockEntity(adjacentPos);
|
||||
if (adjacentBE == null) return false;
|
||||
|
||||
// 从 ConfigInventory 获取要导出的源质类型
|
||||
var configInv = getConfig();
|
||||
AEssentiaKey key = null;
|
||||
for (int i = 0; i < configInv.size(); i++) {
|
||||
var stack = configInv.getStack(i);
|
||||
if (stack != null && stack.what() instanceof AEssentiaKey ek) {
|
||||
key = ek;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (key == null) return false;
|
||||
|
||||
long extracted = grid.getStorageService().getInventory().extract(
|
||||
key, getExportRate(), Actionable.MODULATE, IActionSource.ofMachine(this));
|
||||
if (extracted <= 0) return false;
|
||||
|
||||
// 尝试注入到相邻方块:先 IAspectContainer,再回退到 IEssentiaTransport
|
||||
int injected = TCReflection.insertEssentia(adjacentBE, new AspectStack(key.getId(), extracted));
|
||||
if (injected <= 0 && adjacentBE instanceof IEssentiaTransport transport) {
|
||||
Aspect aspect = TCReflection.findAspectById(key.getId());
|
||||
if (aspect != null) {
|
||||
int want = (int) Math.min(extracted, Integer.MAX_VALUE);
|
||||
injected = transport.addEssentia(aspect, want, side.getOpposite());
|
||||
}
|
||||
}
|
||||
if (injected < extracted) {
|
||||
// 退回未注入的部分
|
||||
grid.getStorageService().getInventory().insert(
|
||||
key, extracted - injected, Actionable.MODULATE, IActionSource.ofMachine(this));
|
||||
}
|
||||
|
||||
if (injected > 0) {
|
||||
this.storedEnergy = injected * (int) TRANSFER_POWER;
|
||||
this.isWorkingFlag = true;
|
||||
}
|
||||
return injected > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundTag extra, HolderLookup.Provider registries) {
|
||||
super.readFromNBT(extra, registries);
|
||||
this.keyTypeSelection.readFromNBT(extra, registries);
|
||||
this.storedEnergy = extra.getLong("storedEnergy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundTag extra, HolderLookup.Provider registries) {
|
||||
super.writeToNBT(extra, registries);
|
||||
this.keyTypeSelection.writeToNBT(extra);
|
||||
extra.putLong("storedEnergy", this.storedEnergy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MenuType<?> getMenuType() {
|
||||
return ModMenuTypes.ESSENTIA_EXPORT_BUS.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpgradeSlots() { return 4; }
|
||||
|
||||
@Override
|
||||
public KeyTypeSelection getKeyTypeSelection() {
|
||||
return this.keyTypeSelection;
|
||||
}
|
||||
|
||||
public long getStoredEnergy() {
|
||||
return storedEnergy;
|
||||
}
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
package thaumicenergistics.common.parts;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.stacks.GenericStack;
|
||||
import appeng.api.util.IConfigManagerBuilder;
|
||||
import appeng.api.util.KeyTypeSelection;
|
||||
import appeng.api.util.KeyTypeSelectionHost;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.parts.automation.IOBusPart;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.api.storage.AspectStack;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKeyType;
|
||||
import thaumicenergistics.common.integration.tc.EssentiaConversionHelper;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
import thaumicenergistics.init.ModMenuTypes;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class EssentiaImportBusPart extends IOBusPart
|
||||
implements KeyTypeSelectionHost {
|
||||
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_BASE =
|
||||
ThaumicEnergistics.id("parts/essentia_import_bus_base");
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_OFF =
|
||||
ThaumicEnergistics.id("parts/essentia_import_bus_off");
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_HAS_CHANNEL =
|
||||
ThaumicEnergistics.id("parts/essentia_import_bus_has_channel");
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_ON =
|
||||
ThaumicEnergistics.id("parts/essentia_import_bus_on");
|
||||
|
||||
public static final PartModel MODEL_OFF = new PartModel(RL_BASE, RL_OFF);
|
||||
public static final PartModel MODEL_HAS_CHANNEL = new PartModel(RL_BASE, RL_HAS_CHANNEL);
|
||||
public static final PartModel MODEL_ON = new PartModel(RL_BASE, RL_ON);
|
||||
|
||||
private static final int TRANSFER_RATE = 8;
|
||||
private static final double IDLE_POWER = 0.5;
|
||||
private static final double TRANSFER_POWER = EssentiaConversionHelper.AE_PER_ESSENTIA;
|
||||
|
||||
private static final String NBT_BUFFER_ASPECT = "ThEBufferAspect";
|
||||
private static final String NBT_BUFFER_AMOUNT = "ThEBufferAmount";
|
||||
|
||||
private boolean isWorkingFlag = false;
|
||||
|
||||
/**
|
||||
* 待注入 AE 网络的源质缓冲(随总线 NBT 持久化)。
|
||||
* <p>
|
||||
* 网络装不下(无源质存储 / 已满 / 模拟与实插不一致)时源质留在这里重试,
|
||||
* 绝不丢弃;缓冲非空期间也不再从容器抽取,避免"吸走却存不下"。
|
||||
*/
|
||||
private AspectStack buffer = AspectStack.EMPTY;
|
||||
|
||||
/**
|
||||
* 单次传输量 = 基础速率 × 每 tick 操作次数(受加速卡影响)。
|
||||
* AE2 加速卡语义:0卡=1、1卡=8、2卡=32、3卡=64、4卡=96(getOperationsPerTick)。
|
||||
*/
|
||||
private int getTransferRate() {
|
||||
return TRANSFER_RATE * Math.max(1, getOperationsPerTick());
|
||||
}
|
||||
|
||||
private final KeyTypeSelection keyTypeSelection = new KeyTypeSelection(
|
||||
selection -> { },
|
||||
keyType -> keyType == AEssentiaKeyType.INSTANCE);
|
||||
|
||||
public EssentiaImportBusPart(IPartItem<?> partItem) {
|
||||
super(TickRates.ImportBus, Set.of(AEssentiaKeyType.INSTANCE), partItem);
|
||||
this.getMainNode().setIdlePowerUsage(IDLE_POWER);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerSettings(IConfigManagerBuilder builder) {
|
||||
super.registerSettings(builder);
|
||||
builder.registerSetting(Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch) {
|
||||
bch.addBox(6, 6, 11, 10, 10, 13);
|
||||
bch.addBox(5, 5, 13, 11, 11, 14);
|
||||
bch.addBox(4, 4, 14, 12, 12, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels() {
|
||||
if (isWorkingFlag) return MODEL_ON;
|
||||
if (getMainNode() != null && getMainNode().isOnline()) return MODEL_HAS_CHANNEL;
|
||||
return MODEL_OFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doBusWork(IGrid grid) {
|
||||
this.isWorkingFlag = false;
|
||||
|
||||
// 1) 先冲缓冲:网络有空间时把上次暂存的源质注入
|
||||
boolean worked = flushBuffer(grid);
|
||||
|
||||
Direction side = this.getSide();
|
||||
if (side == null) return worked;
|
||||
BlockPos adjacentPos = this.getBlockEntity().getBlockPos().relative(side);
|
||||
Level levelRaw = this.getLevel();
|
||||
if (!(levelRaw instanceof ServerLevel level)) return worked;
|
||||
if (!level.isLoaded(adjacentPos)) return worked;
|
||||
BlockEntity adjacentBE = level.getBlockEntity(adjacentPos);
|
||||
if (adjacentBE == null) return worked;
|
||||
|
||||
// 2) 缓冲仍有剩余 = 网络装不下 → 不再从容器抽取(源质留在原容器里)
|
||||
if (!this.buffer.isEmpty()) return worked;
|
||||
|
||||
// 3) 预检 1:先窥视容器能给什么(非破坏性)。无源质直接退出。
|
||||
int rate = getTransferRate();
|
||||
AspectStack available = TCReflection.peekEssentia(adjacentBE, rate);
|
||||
if (available == null || available.isEmpty()) return worked;
|
||||
AEssentiaKey key = AEssentiaKey.of(available.aspectId());
|
||||
if (key == null) return worked;
|
||||
|
||||
// 4) 预检 2:网络能接收多少。为 0(无源质存储/已满)则完全不抽取。
|
||||
long acceptable = grid.getStorageService().getInventory().insert(
|
||||
key, available.amount(), Actionable.SIMULATE, IActionSource.ofMachine(this));
|
||||
if (acceptable <= 0) return worked;
|
||||
|
||||
int toExtract = (int) Math.min(available.amount(), acceptable);
|
||||
AspectStack extracted = TCReflection.extractEssentia(adjacentBE, available.aspectId(), toExtract);
|
||||
if (extracted == null || extracted.isEmpty()) return worked;
|
||||
|
||||
long injected = this.injectToNetwork(grid, extracted);
|
||||
if (injected < extracted.amount()) {
|
||||
// 模拟与实插不一致(例如挂载的容器存储无法模拟)→ 剩余留在缓冲里重试,绝不归还/丢弃
|
||||
this.buffer = new AspectStack(extracted.aspectId(), extracted.amount() - injected);
|
||||
markForSave();
|
||||
}
|
||||
|
||||
double powerCost = injected * TRANSFER_POWER;
|
||||
grid.getEnergyService().extractAEPower(powerCost, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
|
||||
this.isWorkingFlag = injected > 0 || worked;
|
||||
return injected > 0 || worked;
|
||||
}
|
||||
|
||||
/** 把缓冲里的源质注入网络。@return 本次是否注入了任意数量 */
|
||||
private boolean flushBuffer(IGrid grid) {
|
||||
if (this.buffer.isEmpty()) return false;
|
||||
long injected = this.injectToNetwork(grid, this.buffer);
|
||||
if (injected <= 0) return false;
|
||||
long left = this.buffer.amount() - injected;
|
||||
this.buffer = left > 0 ? new AspectStack(this.buffer.aspectId(), left) : AspectStack.EMPTY;
|
||||
markForSave();
|
||||
this.isWorkingFlag = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void markForSave() {
|
||||
if (getHost() != null) {
|
||||
getHost().markForSave();
|
||||
}
|
||||
}
|
||||
|
||||
private long injectToNetwork(IGrid grid, AspectStack stack) {
|
||||
AEssentiaKey key = AEssentiaKey.of(stack.aspectId());
|
||||
if (key == null) return 0;
|
||||
return grid.getStorageService().getInventory().insert(
|
||||
key, stack.amount(), Actionable.MODULATE,
|
||||
IActionSource.ofMachine(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundTag extra, HolderLookup.Provider registries) {
|
||||
super.readFromNBT(extra, registries);
|
||||
this.keyTypeSelection.readFromNBT(extra, registries);
|
||||
this.buffer = AspectStack.EMPTY;
|
||||
if (extra.contains(NBT_BUFFER_ASPECT) && extra.getLong(NBT_BUFFER_AMOUNT) > 0) {
|
||||
ResourceLocation id = ResourceLocation.tryParse(extra.getString(NBT_BUFFER_ASPECT));
|
||||
if (id != null) {
|
||||
this.buffer = new AspectStack(id, extra.getLong(NBT_BUFFER_AMOUNT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundTag extra, HolderLookup.Provider registries) {
|
||||
super.writeToNBT(extra, registries);
|
||||
this.keyTypeSelection.writeToNBT(extra);
|
||||
if (!this.buffer.isEmpty()) {
|
||||
extra.putString(NBT_BUFFER_ASPECT, this.buffer.aspectId().toString());
|
||||
extra.putLong(NBT_BUFFER_AMOUNT, this.buffer.amount());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MenuType<?> getMenuType() {
|
||||
return ModMenuTypes.ESSENTIA_IMPORT_BUS.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpgradeSlots() { return 4; }
|
||||
|
||||
@Override
|
||||
public KeyTypeSelection getKeyTypeSelection() {
|
||||
return this.keyTypeSelection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,11 @@ import java.util.Set;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.particles.DustParticleOptions;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.crafting.IPatternDetails;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IStackWatcher;
|
||||
@@ -37,6 +35,7 @@ import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKeyType;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
import thaumicenergistics.init.ModMenuTypes;
|
||||
import appeng.api.stacks.GenericStack;
|
||||
|
||||
/**
|
||||
* 源质发信器:与 AE2 原版 StorageLevelEmitterPart 逻辑一致,
|
||||
@@ -291,7 +290,7 @@ public class EssentiaLevelEmitterPart extends AbstractLevelEmitterPart
|
||||
} else {
|
||||
ResourceLocation id = TCReflection.getAspectId(aspect);
|
||||
if (id != null) {
|
||||
config.setStack(0, new appeng.api.stacks.GenericStack(AEssentiaKey.of(id), 1));
|
||||
config.setStack(0, new GenericStack(AEssentiaKey.of(id), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,197 +0,0 @@
|
||||
package thaumicenergistics.common.parts;
|
||||
|
||||
import appeng.api.AECapabilities;
|
||||
import appeng.api.networking.IGridNodeListener;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.IStorageMounts;
|
||||
import appeng.api.storage.IStorageProvider;
|
||||
import appeng.api.storage.MEStorage;
|
||||
import appeng.api.util.KeyTypeSelection;
|
||||
import appeng.api.util.KeyTypeSelectionHost;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.parts.automation.IOBusPart;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKeyType;
|
||||
import thaumicenergistics.init.ModMenuTypes;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 源质存储总线:把相邻的源质容器(要素罐子 / 奥术蒸馏器 / 荒古炼金炉 / 源质管道)
|
||||
* 或相邻方块自身暴露的 {@code MEStorage}(例如子网接口)挂载为网络存储,
|
||||
* 使终端与子网能读写该容器。
|
||||
* <p>
|
||||
* 实现方式与 AE2 原版存储总线一致({@link IStorageProvider#mountInventories}),
|
||||
* 不主动搬运源质。旧实现按输入总线逻辑把容器抽干再插入网络、且忽略插入返回值,
|
||||
* 导致网络塞不下时源质凭空消失——已移除。
|
||||
*/
|
||||
public class EssentiaStorageBusPart extends IOBusPart
|
||||
implements IStorageProvider, KeyTypeSelectionHost {
|
||||
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_BASE =
|
||||
ThaumicEnergistics.id("parts/essentia_storage_bus_base");
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_OFF =
|
||||
ThaumicEnergistics.id("parts/essentia_storage_bus_off");
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_HAS_CHANNEL =
|
||||
ThaumicEnergistics.id("parts/essentia_storage_bus_has_channel");
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_ON =
|
||||
ThaumicEnergistics.id("parts/essentia_storage_bus_on");
|
||||
|
||||
public static final PartModel MODEL_OFF = new PartModel(RL_BASE, RL_OFF);
|
||||
public static final PartModel MODEL_HAS_CHANNEL = new PartModel(RL_BASE, RL_HAS_CHANNEL);
|
||||
public static final PartModel MODEL_ON = new PartModel(RL_BASE, RL_ON);
|
||||
|
||||
private static final double IDLE_POWER = 1.0;
|
||||
private boolean isWorkingFlag = false;
|
||||
|
||||
/** 相邻源质容器的 MEStorage 视图(惰性创建,内部实时解析方块实体)。 */
|
||||
private EssentiaContainerStorage containerStorage;
|
||||
private Component storageDescription;
|
||||
|
||||
private final KeyTypeSelection keyTypeSelection = new KeyTypeSelection(
|
||||
selection -> { },
|
||||
keyType -> keyType == AEssentiaKeyType.INSTANCE);
|
||||
|
||||
public EssentiaStorageBusPart(IPartItem<?> partItem) {
|
||||
super(TickRates.StorageBus, Set.of(AEssentiaKeyType.INSTANCE), partItem);
|
||||
this.getMainNode().setIdlePowerUsage(IDLE_POWER);
|
||||
// 注册为存储提供者,网络挂载时会调用 mountInventories(与 AE2 原版存储总线一致)
|
||||
this.getMainNode().addService(IStorageProvider.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch) {
|
||||
bch.addBox(5, 5, 12, 11, 11, 14);
|
||||
bch.addBox(2, 2, 14, 14, 14, 15);
|
||||
bch.addBox(3, 3, 15, 13, 13, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels() {
|
||||
if (isWorkingFlag) return MODEL_ON;
|
||||
if (getMainNode() != null && getMainNode().isOnline()) return MODEL_HAS_CHANNEL;
|
||||
return MODEL_OFF;
|
||||
}
|
||||
|
||||
/** 存储总线不做搬运工作:容器由 {@link #mountInventories} 挂载为网络存储。
|
||||
* 这里只做状态指示(相邻容器有源质 → 亮工作灯)。 */
|
||||
@Override
|
||||
protected boolean doBusWork(appeng.api.networking.IGrid grid) {
|
||||
BlockEntity adjacent = getAdjacentBlockEntity();
|
||||
this.isWorkingFlag = adjacent != null
|
||||
&& thaumicenergistics.common.integration.tc.TCReflection.peekEssentia(adjacent, 1) != null;
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===== IStorageProvider:把相邻存储挂载到网络 =====
|
||||
|
||||
@Override
|
||||
public void mountInventories(IStorageMounts mounts) {
|
||||
BlockPos adjacentPos = getAdjacentPos();
|
||||
if (adjacentPos == null) return;
|
||||
Level level = getLevel();
|
||||
if (!(level instanceof ServerLevel serverLevel) || !serverLevel.isLoaded(adjacentPos)) return;
|
||||
|
||||
// 1) 相邻方块自身暴露 MEStorage(子网接口等)→ 直接挂载,使终端/子网可访问
|
||||
Direction side = this.getSide();
|
||||
MEStorage external = serverLevel.getCapability(AECapabilities.ME_STORAGE, adjacentPos,
|
||||
side != null ? side.getOpposite() : null);
|
||||
if (external != null) {
|
||||
mounts.mount(external, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// 2) 否则把相邻源质容器(罐子/蒸馏器/荒古炼金炉/管道)包装成 MEStorage 挂载
|
||||
mounts.mount(getContainerStorage(), 0);
|
||||
}
|
||||
|
||||
private EssentiaContainerStorage getContainerStorage() {
|
||||
if (containerStorage == null) {
|
||||
if (storageDescription == null) {
|
||||
storageDescription = Component.translatable("item.thaumicenergistics.essentia_storage_bus");
|
||||
}
|
||||
containerStorage = new EssentiaContainerStorage(this::getAdjacentBlockEntity, storageDescription);
|
||||
}
|
||||
return containerStorage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private BlockPos getAdjacentPos() {
|
||||
Direction side = this.getSide();
|
||||
if (side == null || this.getBlockEntity() == null) return null;
|
||||
return this.getBlockEntity().getBlockPos().relative(side);
|
||||
}
|
||||
|
||||
/** 实时解析相邻方块实体(容器可能被替换/移除,挂载视图每次调用重新读取)。 */
|
||||
@Nullable
|
||||
private BlockEntity getAdjacentBlockEntity() {
|
||||
BlockPos pos = getAdjacentPos();
|
||||
Level level = getLevel();
|
||||
if (pos == null || level == null || !level.isLoaded(pos)) return null;
|
||||
return level.getBlockEntity(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld() {
|
||||
super.addToWorld();
|
||||
IStorageProvider.requestUpdate(this.getMainNode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged(net.minecraft.world.level.BlockGetter level, BlockPos pos, BlockPos neighbor) {
|
||||
super.onNeighborChanged(level, pos, neighbor);
|
||||
// 相邻方块变化 → 重新挂载(子网接口 ↔ 源质容器的切换)
|
||||
IStorageProvider.requestUpdate(this.getMainNode());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMainNodeStateChanged(IGridNodeListener.State state) {
|
||||
super.onMainNodeStateChanged(state);
|
||||
IStorageProvider.requestUpdate(this.getMainNode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyTypeSelection getKeyTypeSelection() {
|
||||
return this.keyTypeSelection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundTag extra, HolderLookup.Provider registries) {
|
||||
super.readFromNBT(extra, registries);
|
||||
this.keyTypeSelection.readFromNBT(extra, registries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundTag extra, HolderLookup.Provider registries) {
|
||||
super.writeToNBT(extra, registries);
|
||||
this.keyTypeSelection.writeToNBT(extra);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MenuType<?> getMenuType() {
|
||||
return ModMenuTypes.ESSENTIA_STORAGE_BUS.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpgradeSlots() { return 4; }
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package thaumicenergistics.common.parts;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.util.KeyTypeSelection;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.parts.reporting.AbstractTerminalPart;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKeyType;
|
||||
|
||||
public class EssentiaTerminalPart extends AbstractTerminalPart {
|
||||
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_BASE = ThaumicEnergistics.id("parts/essentia_terminal_base");
|
||||
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_OFF = ThaumicEnergistics.id("parts/essentia_terminal_off");
|
||||
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_HAS_CHANNEL = ThaumicEnergistics.id("parts/essentia_terminal_has_channel");
|
||||
|
||||
@PartModels
|
||||
public static final ResourceLocation RL_ON = ThaumicEnergistics.id("parts/essentia_terminal_on");
|
||||
|
||||
public static final IPartModel MODELS_OFF = new PartModel(RL_BASE, RL_OFF, MODEL_STATUS_OFF);
|
||||
public static final IPartModel MODELS_ON = new PartModel(RL_BASE, RL_ON, MODEL_STATUS_ON);
|
||||
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(RL_BASE, RL_ON, MODEL_STATUS_HAS_CHANNEL);
|
||||
|
||||
/**
|
||||
* 自定义 KeyTypeSelection:只允许源质类型,禁止物品和流体。
|
||||
* 父类 AbstractTerminalPart 的 private 字段 keyTypeSelection 是 keyType -> true(全类型),
|
||||
* 这里通过覆盖 getKeyTypeSelection() 返回本实例,使 MEStorageMenu 只看到源质。
|
||||
*/
|
||||
private final KeyTypeSelection essentiaOnlyKeyTypeSelection = new KeyTypeSelection(
|
||||
this::saveChanges,
|
||||
keyType -> keyType == AEssentiaKeyType.INSTANCE);
|
||||
|
||||
public EssentiaTerminalPart(IPartItem<?> partItem) {
|
||||
super(partItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels() {
|
||||
return this.selectModel(MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuType<?> getMenuType(Player player) {
|
||||
return thaumicenergistics.init.ModMenuTypes.ESSENTIA_TERMINAL.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onUseWithoutItem(Player player, Vec3 pos) {
|
||||
if (!super.onUseWithoutItem(player, pos) && !player.level().isClientSide) {
|
||||
appeng.menu.MenuOpener.open(getMenuType(player), player,
|
||||
appeng.menu.locator.MenuLocators.forPart(this));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回自定义的 KeyTypeSelection,只包含 AEssentiaKeyType。
|
||||
* MEStorageMenu.broadcastChanges() 通过此接口获取可用类型,GUI 据此过滤显示。
|
||||
*/
|
||||
@Override
|
||||
public KeyTypeSelection getKeyTypeSelection() {
|
||||
return this.essentiaOnlyKeyTypeSelection;
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆盖 NBT 读取:父类先读(更新父类 private 字段),然后本类用自己的实例再读。
|
||||
* 父类 private 字段会被忽略,因为 getKeyTypeSelection() 返回本类实例。
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(CompoundTag data, HolderLookup.Provider registries) {
|
||||
super.readFromNBT(data, registries);
|
||||
this.essentiaOnlyKeyTypeSelection.readFromNBT(data, registries);
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆盖 NBT 写入:父类先写(写入父类 private 字段的全类型),然后本类用自己的实例覆盖。
|
||||
* writeToNBT 使用 tag.put("enabledKeyTypes", ...),后写入覆盖先写入,最终只保存源质类型。
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(CompoundTag data, HolderLookup.Provider registries) {
|
||||
super.writeToNBT(data, registries);
|
||||
this.essentiaOnlyKeyTypeSelection.writeToNBT(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,710 @@
|
||||
package thaumicenergistics.common.tiles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.GridHelper;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.IGridNodeListener;
|
||||
import appeng.api.networking.IManagedGridNode;
|
||||
import appeng.api.networking.IInWorldGridNodeHost;
|
||||
import appeng.api.networking.energy.IEnergyService;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IStorageService;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.stacks.AEKey;
|
||||
import appeng.api.storage.MEStorage;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.research.TCResearchManager;
|
||||
|
||||
import thaumicenergistics.common.blocks.BrainOfProbabilityBlock;
|
||||
import thaumicenergistics.common.blocks.BrainOfProbabilityTopBlock;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
import thaumicenergistics.init.ModBlockEntities;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
|
||||
/**
|
||||
* 概率之脑 BE(M6):网格节点 + 每秒一次的周期 tick。
|
||||
* 脑槽、4 张加速卡、绑定宿主、进行中的转动与屏幕闪烁都在此记账;
|
||||
* 数值语义照 CE(GachaOdds/GachaTurn),能源直扣 ME 网络(500 AE/周期),
|
||||
* 燃料 cognitio 从 ME 源质存储扣取(2/周期),产出经 TCResearchManager.addAspectPool 落入宿主认知要素池。
|
||||
*/
|
||||
public class BrainOfProbabilityBlockEntity extends ThETileBase
|
||||
implements IInWorldGridNodeHost, IActionHost, IGridTickable {
|
||||
|
||||
/** 转动按秒走,每秒醒一次。 */
|
||||
private static final int TICKS_PER_SECOND = 20;
|
||||
/** 每周期 ME 能量消耗(CE GachaPower AE_PER_TURN=500 定稿)。 */
|
||||
public static final double AE_PER_TURN = 500.0;
|
||||
/** 每周期 cognitio 燃料(CE 同值)。 */
|
||||
public static final int COGNITIO_PER_TURN = 2;
|
||||
/** 加速卡上限(CE 同值)。 */
|
||||
public static final int MAX_CARDS = 4;
|
||||
/** 结果在屏幕上停留秒数(CE FLASH_SECONDS=2)。 */
|
||||
private static final int FLASH_SECONDS = 2;
|
||||
|
||||
// ===== 骰子数值(CE GachaOdds 定稿,用户可调) =====
|
||||
/** 最快的一次转动,也是赔率最好的一次。 */
|
||||
public static final int MIN_SECONDS = 30;
|
||||
/** 无加速卡时最慢的转动。 */
|
||||
public static final int LONGEST_SECONDS = 180;
|
||||
/** 每张加速卡把最长转动缩短的秒数。 */
|
||||
public static final int SECONDS_PER_CARD = 25;
|
||||
/** 加速卡最多把最长转动压到的秒数(第五张起不再变化)。 */
|
||||
public static final int LONGEST_WITH_CARDS = 80;
|
||||
/** 最快转动的给奖赔率。 */
|
||||
public static final double CHANCE_AT_MIN_SECONDS = 0.75;
|
||||
/** 最慢转动的给奖赔率。 */
|
||||
public static final double CHANCE_AT_LONGEST_SECONDS = 0.45;
|
||||
/** 给奖转动抽取次数下限。 */
|
||||
public static final int MIN_DRAWS = 5;
|
||||
/** 给奖转动抽取次数上限。 */
|
||||
public static final int MAX_DRAWS = 7;
|
||||
/** 单次抽取点数上限(1~3)。 */
|
||||
public static final int MAX_POINTS_PER_DRAW = 3;
|
||||
|
||||
private final IManagedGridNode mainNode;
|
||||
private final IActionSource actionSource;
|
||||
|
||||
private final IGridNodeListener<BrainOfProbabilityBlockEntity> nodeListener = new IGridNodeListener<>() {
|
||||
@Override
|
||||
public void onSaveChanges(BrainOfProbabilityBlockEntity owner, IGridNode node) {
|
||||
owner.setChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChanged(BrainOfProbabilityBlockEntity owner, IGridNode node, State state) {
|
||||
if (state == State.POWER) {
|
||||
owner.isActive = owner.mainNode.isActive();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===== 内容物与状态 =====
|
||||
private ItemStack brain = ItemStack.EMPTY;
|
||||
private final ItemStack[] cards = new ItemStack[MAX_CARDS];
|
||||
/** 绑定宿主(放入脑的玩家);null = 未认领。 */
|
||||
@Nullable
|
||||
private UUID owner;
|
||||
private String ownerName = "";
|
||||
/** 进行中转动的剩余秒数;0 = 空闲。 */
|
||||
private int turnSeconds;
|
||||
/** 本次转动是否为给奖类。 */
|
||||
private boolean turnPays;
|
||||
/** 结果闪屏剩余秒数(不入存档)。 */
|
||||
private int flashSeconds;
|
||||
private boolean flashPaid;
|
||||
/** 最近一次出货明细(要素 tag → 点数,保序);空 = 尚无出货记录。NBT 持久化,Jade 展示用。 */
|
||||
private final LinkedHashMap<String, Integer> lastPayout = new LinkedHashMap<>();
|
||||
|
||||
public BrainOfProbabilityBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(ModBlockEntities.BRAIN_OF_PROBABILITY.get(), pos, state);
|
||||
Arrays.fill(this.cards, ItemStack.EMPTY);
|
||||
mainNode = GridHelper.createManagedNode(this, nodeListener)
|
||||
.setVisualRepresentation(ModItems.BRAIN_OF_PROBABILITY_ITEM.get())
|
||||
.setInWorldNode(true)
|
||||
.setTagName("probability_brain")
|
||||
.setFlags(GridFlags.REQUIRE_CHANNEL)
|
||||
.setExposedOnSides(EnumSet.allOf(Direction.class))
|
||||
.addService(IGridTickable.class, this);
|
||||
mainNode.setIdlePowerUsage(0.0);
|
||||
actionSource = IActionSource.ofMachine(this);
|
||||
}
|
||||
|
||||
// ===== 生命周期 =====
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
if (level != null && !level.isClientSide()) {
|
||||
mainNode.create(level, getBlockPos());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemoved() {
|
||||
super.setRemoved();
|
||||
if (mainNode != null) mainNode.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBreakBlock() {
|
||||
super.onBreakBlock();
|
||||
if (level != null && !level.isClientSide) {
|
||||
dropContents();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IGridNode getGridNode(Direction dir) {
|
||||
return mainNode.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IGridNode getActionableNode() {
|
||||
return mainNode.getNode();
|
||||
}
|
||||
|
||||
// ===== 周期主循环(CE BlockEntityGachaBox.tickingRequest 同构) =====
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node) {
|
||||
return new TickingRequest(TICKS_PER_SECOND, TICKS_PER_SECOND, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLast) {
|
||||
if (!(level instanceof ServerLevel server)) {
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
// 结果停留片刻,否则下一次转动会盖掉玩家还没看到的闪光
|
||||
if (flashSeconds > 0) {
|
||||
flashSeconds--;
|
||||
showScreen(flashPaid ? BrainOfProbabilityBlock.Screen.SUCCESS : BrainOfProbabilityBlock.Screen.FAILED);
|
||||
return TickRateModulation.SAME;
|
||||
}
|
||||
WaitReason wait = waitReason(server);
|
||||
if (wait != null) {
|
||||
showScreen(wait.blankScreen() ? BrainOfProbabilityBlock.Screen.OFF : BrainOfProbabilityBlock.Screen.ON);
|
||||
return TickRateModulation.SAME;
|
||||
}
|
||||
showScreen(BrainOfProbabilityBlock.Screen.WORKING);
|
||||
if (turnSeconds <= 0) {
|
||||
beginTurn(server);
|
||||
return TickRateModulation.SAME;
|
||||
}
|
||||
turnSeconds--;
|
||||
setChanged();
|
||||
if (turnSeconds <= 0) {
|
||||
finishTurn(server);
|
||||
}
|
||||
return TickRateModulation.SAME;
|
||||
}
|
||||
|
||||
/** 第一个挡路的条件;null 表示可以转。 */
|
||||
private @Nullable WaitReason waitReason(ServerLevel server) {
|
||||
WaitReason setup = setupReason(server);
|
||||
if (setup != null) {
|
||||
return setup;
|
||||
}
|
||||
// 进行中的转动已经付过费,这里只查下一次的燃料
|
||||
if (turnSeconds > 0) {
|
||||
return null;
|
||||
}
|
||||
if (!canPayEnergy()) {
|
||||
return WaitReason.NO_POWER;
|
||||
}
|
||||
if (!hasCognitioFuel()) {
|
||||
return WaitReason.NO_ESSENTIA;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 装置自身缺什么;缺一项就没东西可转。 */
|
||||
private @Nullable WaitReason setupReason(ServerLevel server) {
|
||||
if (!structureComplete()) {
|
||||
return WaitReason.NO_STRUCTURE;
|
||||
}
|
||||
if (!hasBrain()) {
|
||||
return WaitReason.NO_BRAIN;
|
||||
}
|
||||
if (!isBound()) {
|
||||
return WaitReason.UNBOUND_BRAIN;
|
||||
}
|
||||
if (!mainNode.isActive()) {
|
||||
return WaitReason.NO_CHANNEL;
|
||||
}
|
||||
// 宿主不在线就等着,不把产出存起来
|
||||
if (ownerPlayer(server) == null) {
|
||||
return WaitReason.OWNER_OFFLINE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 能量直扣 ME 网络:500 AE/周期,SIMULATE 预检。 */
|
||||
private boolean canPayEnergy() {
|
||||
IGrid grid = mainNode.getGrid();
|
||||
if (grid == null) {
|
||||
return false;
|
||||
}
|
||||
IEnergyService energy = grid.getEnergyService();
|
||||
return energy.extractAEPower(AE_PER_TURN, Actionable.SIMULATE, PowerMultiplier.ONE) >= AE_PER_TURN;
|
||||
}
|
||||
|
||||
/** cognitio 燃料预检:ME 源质存储须有 2 点可扣。 */
|
||||
private boolean hasCognitioFuel() {
|
||||
IGrid grid = mainNode.getGrid();
|
||||
AEKey cog = cognitioKey();
|
||||
if (grid == null || cog == null) {
|
||||
return false;
|
||||
}
|
||||
IStorageService storage = grid.getService(IStorageService.class);
|
||||
if (storage == null) {
|
||||
return false;
|
||||
}
|
||||
return storage.getInventory().extract(cog, COGNITIO_PER_TURN, Actionable.SIMULATE, actionSource) >= COGNITIO_PER_TURN;
|
||||
}
|
||||
|
||||
/** 一次抽取同时定下时长和赔率,付过费才开转。 */
|
||||
private void beginTurn(ServerLevel server) {
|
||||
Turn drawn = roll(server.getRandom(), cardCount());
|
||||
if (!payForTurn()) {
|
||||
return;
|
||||
}
|
||||
this.turnSeconds = drawn.seconds();
|
||||
this.turnPays = drawn.pays();
|
||||
setChanged();
|
||||
}
|
||||
|
||||
/** 扣 2 点 cognitio 加 500 AE 电力;付不出就不开转。 */
|
||||
private boolean payForTurn() {
|
||||
IGrid grid = mainNode.getGrid();
|
||||
AEKey cog = cognitioKey();
|
||||
if (grid == null || cog == null) {
|
||||
return false;
|
||||
}
|
||||
IStorageService storage = grid.getService(IStorageService.class);
|
||||
if (storage == null) {
|
||||
return false;
|
||||
}
|
||||
MEStorage inventory = storage.getInventory();
|
||||
IEnergyService energy = grid.getEnergyService();
|
||||
// 能量 SIMULATE(double 记账,禁截断)
|
||||
if (energy.extractAEPower(AE_PER_TURN, Actionable.SIMULATE, PowerMultiplier.ONE) < AE_PER_TURN) {
|
||||
return false;
|
||||
}
|
||||
// 燃料 SIMULATE → MODULATE(竞态兜底:不足则退回已扣部分)
|
||||
if (inventory.extract(cog, COGNITIO_PER_TURN, Actionable.SIMULATE, actionSource) < COGNITIO_PER_TURN) {
|
||||
return false;
|
||||
}
|
||||
long got = inventory.extract(cog, COGNITIO_PER_TURN, Actionable.MODULATE, actionSource);
|
||||
if (got < COGNITIO_PER_TURN) {
|
||||
if (got > 0) {
|
||||
inventory.insert(cog, got, Actionable.MODULATE, actionSource);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
energy.extractAEPower(AE_PER_TURN, Actionable.MODULATE, PowerMultiplier.ONE);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 转动结束:闪屏 2 秒;给奖转动结算产出;白转清空出货记录(Jade 回显「暂无」)。 */
|
||||
private void finishTurn(ServerLevel server) {
|
||||
this.flashSeconds = FLASH_SECONDS;
|
||||
this.flashPaid = this.turnPays;
|
||||
boolean paid = this.turnPays;
|
||||
this.turnPays = false;
|
||||
setChanged();
|
||||
if (!paid) {
|
||||
// 白转:清掉上次成功出货的 Jade 残留(T-M6-JADE-FIX)
|
||||
this.lastPayout.clear();
|
||||
setChanged();
|
||||
return;
|
||||
}
|
||||
ServerPlayer bound = ownerPlayer(server);
|
||||
if (bound == null) {
|
||||
return;
|
||||
}
|
||||
payout(bound);
|
||||
}
|
||||
|
||||
/**
|
||||
* 产出结算(T-M6-GACHA-REV,用户拍板):掷中后从候选池随机挑 5~7 个不重复要素、
|
||||
* 每要素 1~3 点,逐要素入池。候选池 = 全部元始要素 + 投放者已发现的复合要素
|
||||
* (未发现复合要素不进池,防剧透);候选池不足时有多少给多少,至少 1 类也发。
|
||||
* 不保底认知——认知只当燃料(payForTurn 零触碰);出货率公式(payoutChance)零触碰。
|
||||
* port.261 实证:addAspectPool 为 per-aspect Map 键控(aspectPool 返回 Map<Aspect,Integer>),
|
||||
* 任意 Aspect 实例均合法持久化。
|
||||
*/
|
||||
private void payout(ServerPlayer bound) {
|
||||
RandomSource random = bound.getRandom();
|
||||
int draws = MIN_DRAWS + random.nextInt(MAX_DRAWS - MIN_DRAWS + 1);
|
||||
List<Aspect> pool = candidatePool(bound);
|
||||
// 候选池不足 5~7 时有多少给多少;空池(理论不可达:元始要素至少 6)无事发生
|
||||
int kinds = Math.min(draws, pool.size());
|
||||
if (kinds <= 0) {
|
||||
return;
|
||||
}
|
||||
// 部分 Fisher-Yates:只洗前 kinds 个(RandomSource 非 java.util.Random,不能走 Collections.shuffle)
|
||||
for (int i = 0; i < kinds; i++) {
|
||||
int j = i + random.nextInt(pool.size() - i);
|
||||
Aspect tmp = pool.get(i);
|
||||
pool.set(i, pool.get(j));
|
||||
pool.set(j, tmp);
|
||||
}
|
||||
int totalPoints = 0;
|
||||
LinkedHashMap<String, Integer> detail = new LinkedHashMap<>();
|
||||
for (int i = 0; i < kinds; i++) {
|
||||
Aspect aspect = pool.get(i);
|
||||
int points = 1 + random.nextInt(MAX_POINTS_PER_DRAW);
|
||||
TCResearchManager.addAspectPool(bound, aspect, points);
|
||||
detail.put(aspect.getTag(), points);
|
||||
totalPoints += points;
|
||||
}
|
||||
this.lastPayout.clear();
|
||||
this.lastPayout.putAll(detail);
|
||||
setChanged();
|
||||
bound.displayClientMessage(payoutMessage(detail.size(), totalPoints, detail), true);
|
||||
}
|
||||
|
||||
/** 出货候选池:全部元始要素 + 投放者已发现的复合要素(防剧透)。 */
|
||||
private static List<Aspect> candidatePool(ServerPlayer bound) {
|
||||
List<Aspect> pool = new ArrayList<>(Aspect.getPrimalAspects());
|
||||
for (Aspect aspect : TCResearchManager.discoveredAspects(bound)) {
|
||||
if (!aspect.isPrimal() && !pool.contains(aspect)) {
|
||||
pool.add(aspect);
|
||||
}
|
||||
}
|
||||
return pool;
|
||||
}
|
||||
|
||||
/** actionbar 明细:「本轮研究收获:秩序 3、火 1(共 2 类 4 点)」。 */
|
||||
private static Component payoutMessage(int kinds, int totalPoints, Map<String, Integer> detail) {
|
||||
Component sep = Component.translatable("thaumicenergistics.brain_prob.payout_sep");
|
||||
MutableComponent parts = Component.empty();
|
||||
boolean first = true;
|
||||
for (Map.Entry<String, Integer> entry : detail.entrySet()) {
|
||||
if (!first) {
|
||||
parts = parts.append(sep);
|
||||
}
|
||||
first = false;
|
||||
parts = parts.append(Component.translatable("tc.aspect." + entry.getKey()))
|
||||
.append(Component.literal(" " + entry.getValue()));
|
||||
}
|
||||
return Component.translatable("thaumicenergistics.brain_prob.payout_detail",
|
||||
parts, kinds, totalPoints);
|
||||
}
|
||||
|
||||
// ===== 骰子(CE GachaOdds 同构) =====
|
||||
|
||||
/** 装这么多张卡时可能掷出的最长转动。 */
|
||||
private static int longestSeconds(int cards) {
|
||||
return Math.max(LONGEST_WITH_CARDS, LONGEST_SECONDS - SECONDS_PER_CARD * cards);
|
||||
}
|
||||
|
||||
/** 这个时长的转动给奖的赔率,只看时长。 */
|
||||
private static double payoutChance(int seconds) {
|
||||
double along = (double) (seconds - MIN_SECONDS) / (LONGEST_SECONDS - MIN_SECONDS);
|
||||
return CHANCE_AT_MIN_SECONDS + (CHANCE_AT_LONGEST_SECONDS - CHANCE_AT_MIN_SECONDS) * along;
|
||||
}
|
||||
|
||||
/** 掷出的一次转动:跑多少秒,给不给奖。 */
|
||||
private record Turn(int seconds, boolean pays) {}
|
||||
|
||||
/** 一次抽取定下两半:落到的时长决定这次转动的赔率。 */
|
||||
private Turn roll(RandomSource random, int cards) {
|
||||
int seconds = MIN_SECONDS + random.nextInt(longestSeconds(cards) - MIN_SECONDS + 1);
|
||||
return new Turn(seconds, random.nextDouble() < payoutChance(seconds));
|
||||
}
|
||||
|
||||
/** 箱子为什么停着不动:blankScreen = 该修装置(死屏),其余为待机屏。 */
|
||||
private enum WaitReason {
|
||||
NO_STRUCTURE, NO_BRAIN, UNBOUND_BRAIN, NO_CHANNEL, OWNER_OFFLINE, NO_POWER, NO_ESSENTIA;
|
||||
|
||||
boolean blankScreen() {
|
||||
return this == NO_STRUCTURE || this == NO_CHANNEL;
|
||||
}
|
||||
}
|
||||
|
||||
/** 方面 tag → AEssentiaKey(运行期查找,cognitio 无静态常量,vitium 同款范式)。 */
|
||||
private static AEKey cognitioKey() {
|
||||
Aspect aspect = Aspect.get("cognitio");
|
||||
if (aspect == null) {
|
||||
return null;
|
||||
}
|
||||
var id = TCReflection.getAspectId(aspect);
|
||||
return id == null ? null : AEssentiaKey.of(id);
|
||||
}
|
||||
|
||||
// ===== 状态查询 =====
|
||||
|
||||
/** 最近一次出货明细(要素 tag → 点数,只读视图;Jade「本轮奖励」展示)。 */
|
||||
public Map<String, Integer> lastPayout() {
|
||||
return Collections.unmodifiableMap(lastPayout);
|
||||
}
|
||||
|
||||
/** 进行中转动的剩余秒数;空闲为 0(Jade「下次抽奖」倒计时)。 */
|
||||
public int turnSecondsRemaining() {
|
||||
return Math.max(0, turnSeconds);
|
||||
}
|
||||
|
||||
public boolean hasBrain() {
|
||||
return !brain.isEmpty();
|
||||
}
|
||||
|
||||
public int cardCount() {
|
||||
int count = 0;
|
||||
for (ItemStack card : cards) {
|
||||
if (!card.isEmpty()) count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public boolean hasRoomForCard() {
|
||||
return cardCount() < MAX_CARDS;
|
||||
}
|
||||
|
||||
/** 上半部分(形态格)立在底座上才算结构完整。 */
|
||||
public boolean structureComplete() {
|
||||
if (level == null) {
|
||||
return false;
|
||||
}
|
||||
return level.getBlockState(getBlockPos().above()).getBlock() instanceof BrainOfProbabilityTopBlock;
|
||||
}
|
||||
|
||||
public boolean isBound() {
|
||||
return owner != null;
|
||||
}
|
||||
|
||||
/** 脑在槽里却无人认领:存档中断留下的,点一下即可认领。 */
|
||||
public boolean hasUnboundBrain() {
|
||||
return hasBrain() && !isBound();
|
||||
}
|
||||
|
||||
/** 能否取回脑:绑定者本人;无主脑谁都可以。 */
|
||||
public boolean mayTakeBrain(Player player) {
|
||||
return owner == null || owner.equals(player.getUUID());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String ownerName() {
|
||||
return owner == null ? null : ownerName;
|
||||
}
|
||||
|
||||
/** 绑定的在线且在世宿主;离线或死亡返回 null(§G.1:任一不成立本周期不执行,离线不消耗,不存产出)。 */
|
||||
@Nullable
|
||||
ServerPlayer ownerPlayer(ServerLevel server) {
|
||||
if (owner == null) {
|
||||
return null;
|
||||
}
|
||||
return server.getPlayerByUUID(owner) instanceof ServerPlayer bound && bound.isAlive() ? bound : null;
|
||||
}
|
||||
|
||||
// ===== 装填与取出(B3 批次由方块层调用) =====
|
||||
|
||||
/** 放入一颗罐装脑(thaumcraft:brain_jar)并绑定宿主;作废上一任宿主的转动。 */
|
||||
public void addBrain(Player player, ItemStack held) {
|
||||
this.brain = held.copyWithCount(1);
|
||||
bind(player);
|
||||
syncJarState();
|
||||
}
|
||||
|
||||
/** 无主脑认领:一次点击修复存档中断状态。 */
|
||||
public void bind(Player player) {
|
||||
this.owner = player.getUUID();
|
||||
this.ownerName = player.getName().getString();
|
||||
resetTurn();
|
||||
setChanged();
|
||||
}
|
||||
|
||||
/** 解绑(取出脑时):转动作废不保存。 */
|
||||
public void unbind() {
|
||||
this.owner = null;
|
||||
this.ownerName = "";
|
||||
resetTurn();
|
||||
setChanged();
|
||||
}
|
||||
|
||||
/** 取出脑(调用方已校验 mayTakeBrain)。 */
|
||||
public ItemStack takeBrain() {
|
||||
ItemStack taken = this.brain.copy();
|
||||
this.brain = ItemStack.EMPTY;
|
||||
syncJarState();
|
||||
return taken;
|
||||
}
|
||||
|
||||
/** 放入一张加速卡;已满返回 false。 */
|
||||
public boolean addCard(ItemStack held) {
|
||||
for (int slot = 0; slot < MAX_CARDS; slot++) {
|
||||
if (cards[slot].isEmpty()) {
|
||||
cards[slot] = held.copyWithCount(1);
|
||||
setChanged();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 取出全部加速卡(顺序无关)。 */
|
||||
public List<ItemStack> takeCards() {
|
||||
List<ItemStack> taken = new ArrayList<>(MAX_CARDS);
|
||||
for (int slot = 0; slot < MAX_CARDS; slot++) {
|
||||
if (!cards[slot].isEmpty()) {
|
||||
taken.add(cards[slot]);
|
||||
cards[slot] = ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
if (!taken.isEmpty()) {
|
||||
setChanged();
|
||||
}
|
||||
return taken;
|
||||
}
|
||||
|
||||
/** 破坏方块时倾倒全部内容物。 */
|
||||
public void dropContents() {
|
||||
if (level == null) {
|
||||
return;
|
||||
}
|
||||
spill(takeBrain());
|
||||
for (ItemStack card : takeCards()) {
|
||||
spill(card);
|
||||
}
|
||||
}
|
||||
|
||||
private void spill(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Containers.dropItemStack(level,
|
||||
worldPosition.getX() + 0.5, worldPosition.getY() + 0.5, worldPosition.getZ() + 0.5,
|
||||
stack);
|
||||
}
|
||||
|
||||
/** 转动进行中/闪屏状态复位(装填/解绑时调用)。 */
|
||||
public void resetTurn() {
|
||||
this.turnSeconds = 0;
|
||||
this.turnPays = false;
|
||||
this.flashSeconds = 0;
|
||||
this.flashPaid = false;
|
||||
setChanged();
|
||||
}
|
||||
|
||||
/** jar 方块状态跟随脑槽走(客户端渲染依赖)。 */
|
||||
private void syncJarState() {
|
||||
if (level == null || level.isClientSide || isRemoved()) {
|
||||
return;
|
||||
}
|
||||
BlockState live = level.getBlockState(worldPosition);
|
||||
boolean present = hasBrain();
|
||||
if (live.getBlock() instanceof BrainOfProbabilityBlock && live.getValue(BrainOfProbabilityBlock.JAR) != present) {
|
||||
level.setBlock(worldPosition, live.setValue(BrainOfProbabilityBlock.JAR, present), 3);
|
||||
}
|
||||
}
|
||||
|
||||
/** 五态屏落盘并同步客户端(方块状态自带同步)。 */
|
||||
void showScreen(BrainOfProbabilityBlock.Screen screen) {
|
||||
if (level == null || level.isClientSide) {
|
||||
return;
|
||||
}
|
||||
BlockState state = getBlockState();
|
||||
if (state.getBlock() instanceof BrainOfProbabilityBlock
|
||||
&& state.getValue(BrainOfProbabilityBlock.SCREEN) != screen) {
|
||||
level.setBlockAndUpdate(worldPosition, state.setValue(BrainOfProbabilityBlock.SCREEN, screen));
|
||||
}
|
||||
}
|
||||
|
||||
/** 空手右键状态反馈(actionbar 单行)。 */
|
||||
public net.minecraft.network.chat.Component buildStatus() {
|
||||
net.minecraft.network.chat.Component state;
|
||||
if (!hasBrain()) {
|
||||
state = Component.translatable("thaumicenergistics.brain_prob.status.idle");
|
||||
} else if (turnSeconds > 0) {
|
||||
state = Component.translatable("thaumicenergistics.brain_prob.status.working", turnSeconds);
|
||||
} else {
|
||||
state = Component.translatable("thaumicenergistics.brain_prob.status.waiting");
|
||||
}
|
||||
net.minecraft.network.chat.Component ownerDisplay = isBound()
|
||||
? Component.literal(ownerName)
|
||||
: Component.translatable("thaumicenergistics.brain_prob.status.unbound");
|
||||
return Component.translatable("thaumicenergistics.brain_prob.status", state, cardCount(), ownerDisplay);
|
||||
}
|
||||
|
||||
// ===== NBT =====
|
||||
|
||||
@Override
|
||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||
super.loadAdditional(tag, registries);
|
||||
mainNode.loadFromNBT(tag);
|
||||
|
||||
this.brain = ItemStack.parseOptional(registries, tag.getCompound("Brain"));
|
||||
ListTag savedCards = tag.getList("Cards", Tag.TAG_COMPOUND);
|
||||
for (int slot = 0; slot < MAX_CARDS; slot++) {
|
||||
this.cards[slot] = slot < savedCards.size()
|
||||
? ItemStack.parseOptional(registries, savedCards.getCompound(slot))
|
||||
: ItemStack.EMPTY;
|
||||
}
|
||||
this.owner = tag.hasUUID("Owner") ? tag.getUUID("Owner") : null;
|
||||
this.ownerName = tag.getString("OwnerName");
|
||||
this.turnSeconds = Math.max(0, tag.getInt("TurnSeconds"));
|
||||
this.turnPays = tag.getBoolean("TurnPays");
|
||||
this.flashSeconds = 0;
|
||||
this.flashPaid = false;
|
||||
// 最近一次出货明细读回(无键保持空 = 尚无出货记录)
|
||||
this.lastPayout.clear();
|
||||
ListTag savedPayout = tag.getList("LastPayout", Tag.TAG_COMPOUND);
|
||||
for (int i = 0; i < savedPayout.size(); i++) {
|
||||
CompoundTag item = savedPayout.getCompound(i);
|
||||
String aspectTag = item.getString("tag");
|
||||
if (!aspectTag.isEmpty() && Aspect.getAspect(aspectTag) != null) {
|
||||
this.lastPayout.put(aspectTag, item.getInt("points"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||
super.saveAdditional(tag, registries);
|
||||
mainNode.saveToNBT(tag);
|
||||
if (!brain.isEmpty()) {
|
||||
tag.put("Brain", brain.saveOptional(registries));
|
||||
}
|
||||
ListTag savedCards = new ListTag();
|
||||
for (ItemStack card : cards) {
|
||||
savedCards.add(card.saveOptional(registries));
|
||||
}
|
||||
tag.put("Cards", savedCards);
|
||||
if (owner != null) {
|
||||
tag.putUUID("Owner", owner);
|
||||
tag.putString("OwnerName", ownerName);
|
||||
}
|
||||
if (turnSeconds > 0) {
|
||||
tag.putInt("TurnSeconds", turnSeconds);
|
||||
tag.putBoolean("TurnPays", turnPays);
|
||||
}
|
||||
// 最近一次出货明细(Jade「本轮奖励」展示,重启保留)
|
||||
if (!lastPayout.isEmpty()) {
|
||||
ListTag savedPayout = new ListTag();
|
||||
for (Map.Entry<String, Integer> entry : lastPayout.entrySet()) {
|
||||
CompoundTag item = new CompoundTag();
|
||||
item.putString("tag", entry.getKey());
|
||||
item.putInt("points", entry.getValue());
|
||||
savedPayout.add(item);
|
||||
}
|
||||
tag.put("LastPayout", savedPayout);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import thaumcraft.api.ThaumcraftApi;
|
||||
import thaumcraft.api.crafting.InfusionRecipe;
|
||||
|
||||
/**
|
||||
* 注魔风险计算:扫描附近的注魔矩阵,按 5 档风险显示。
|
||||
@@ -164,8 +166,8 @@ public final class InfusionRiskCalculator {
|
||||
}
|
||||
}
|
||||
// 找匹配配方(忽略研究:直接比对中央 + 组件,不调 matches 以免研究门禁)
|
||||
for (Object o : thaumcraft.api.ThaumcraftApi.getCraftingRecipes()) {
|
||||
if (!(o instanceof thaumcraft.api.crafting.InfusionRecipe recipe)) continue;
|
||||
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
|
||||
if (!(o instanceof InfusionRecipe recipe)) continue;
|
||||
if (!recipe.getRecipeInput().is(central.getItem())) continue;
|
||||
// 简化:中央物品匹配即采用其基础不稳定(组件精确匹配留给 craftingStart 处理)
|
||||
return recipe.instability(central);
|
||||
|
||||
@@ -7,14 +7,17 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
|
||||
@@ -50,12 +53,22 @@ import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.crafting.IArcaneRecipe;
|
||||
|
||||
import thaumicenergistics.api.grid.IEssentiaGrid;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.integration.tc.ArcaneCraftingPattern;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
import thaumicenergistics.common.inventory.HandlerKnowledgeCore;
|
||||
import thaumicenergistics.init.ModBlockEntities;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
import appeng.api.ids.AEComponents;
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.me.service.P2PService;
|
||||
import appeng.parts.p2p.P2PTunnelPart;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import thaumicenergistics.common.network.AssemblerPreviewSyncPacket;
|
||||
import thaumicenergistics.common.parts.VisInterfacePart;
|
||||
|
||||
public class TileArcaneAssembler extends ThETileBase
|
||||
implements IInWorldGridNodeHost, IActionHost, IGridTickable, ICraftingProvider, ICraftingMachine {
|
||||
@@ -271,12 +284,12 @@ public class TileArcaneAssembler extends ThETileBase
|
||||
return;
|
||||
}
|
||||
|
||||
appeng.me.service.P2PService p2p = appeng.me.service.P2PService.get(grid);
|
||||
P2PService p2p = P2PService.get(grid);
|
||||
if (p2p == null) {
|
||||
return;
|
||||
}
|
||||
appeng.parts.p2p.P2PTunnelPart<?> input = p2p.getInput(visSourceFreq);
|
||||
if (!(input instanceof thaumicenergistics.common.parts.VisInterfacePart visSource)) {
|
||||
P2PTunnelPart<?> input = p2p.getInput(visSourceFreq);
|
||||
if (!(input instanceof VisInterfacePart visSource)) {
|
||||
return; // 频率设了但找不到 vis_interface P2P 输入 → 不抽
|
||||
}
|
||||
|
||||
@@ -314,7 +327,7 @@ public class TileArcaneAssembler extends ThETileBase
|
||||
if (currentResult.isEmpty()) {
|
||||
isCrafting = false;
|
||||
previewGrid = emptyPreviewGrid();
|
||||
thaumicenergistics.common.network.AssemblerPreviewSyncPacket.send(this, false);
|
||||
AssemblerPreviewSyncPacket.send(this, false);
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
@@ -372,7 +385,7 @@ public class TileArcaneAssembler extends ThETileBase
|
||||
internalInventory.setItem(TARGET_SLOT, ItemStack.EMPTY);
|
||||
setChanged();
|
||||
markForUpdate();
|
||||
thaumicenergistics.common.network.AssemblerPreviewSyncPacket.send(this, false);
|
||||
AssemblerPreviewSyncPacket.send(this, false);
|
||||
|
||||
return TickRateModulation.URGENT;
|
||||
}
|
||||
@@ -426,7 +439,7 @@ public class TileArcaneAssembler extends ThETileBase
|
||||
List<ItemStack> pearls = new ArrayList<>();
|
||||
if (previewGrid == null) return pearls;
|
||||
for (ItemStack stack : previewGrid) {
|
||||
if (!stack.isEmpty() && stack.getItem() == net.minecraft.core.registries.BuiltInRegistries.ITEM.get(PRIMORDIAL_PEARL_ID)) {
|
||||
if (!stack.isEmpty() && stack.getItem() == BuiltInRegistries.ITEM.get(PRIMORDIAL_PEARL_ID)) {
|
||||
pearls.add(stack.copy());
|
||||
}
|
||||
}
|
||||
@@ -504,18 +517,41 @@ public class TileArcaneAssembler extends ThETileBase
|
||||
ItemStack[] ingredients = acp.getIngredients();
|
||||
|
||||
List<GenericStack> inputs = new ArrayList<>();
|
||||
List<GenericStack[]> alternatives = new ArrayList<>();
|
||||
if (ingredients != null) {
|
||||
for (ItemStack ing : ingredients) {
|
||||
if (ing == null || ing.isEmpty()) continue;
|
||||
AEItemKey key = AEItemKey.of(ing);
|
||||
if (key != null) {
|
||||
inputs.add(new GenericStack(key, ing.getCount()));
|
||||
alternatives.add(expandTagAlternates(ing));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ArcaneAssemblerPattern(AEItemKey.of(result), null, aspects, result, inputs,
|
||||
acp.getResearch(), acp.getIngredients());
|
||||
acp.getResearch(), acp.getIngredients(), alternatives);
|
||||
}
|
||||
|
||||
/**
|
||||
* 样板编码把通配具象化成了编码时的单一变体(如 wisp_essence_ordo),AE2 自动合成时网络里
|
||||
* 若是另一变体(wisp_essence_aer)即报材料不足——手工奥术合成走 tag 匹配没这问题。
|
||||
* 此处把属于本模组自定义通配 tag(wisp_essences/monitors 等)的格子展开为 tag 全部物品,
|
||||
* 作为样板输入的备选变体;只认本模组命名空间,避免把 forge 等通用 tag 成员全卷进来。
|
||||
*/
|
||||
private static GenericStack[] expandTagAlternates(ItemStack ing) {
|
||||
for (TagKey<Item> tag : ing.getItemHolder().tags().toList()) {
|
||||
if (!tag.location().getNamespace().equals(ThaumicEnergistics.MODID)) continue;
|
||||
var named = BuiltInRegistries.ITEM.getTag(tag);
|
||||
if (named.isEmpty()) continue;
|
||||
List<GenericStack> alts = new ArrayList<>();
|
||||
for (Holder<Item> holder : named.get()) {
|
||||
AEItemKey key = AEItemKey.of(holder.value());
|
||||
if (key != null) alts.add(new GenericStack(key, ing.getCount()));
|
||||
}
|
||||
if (alts.size() > 1) return alts.toArray(new GenericStack[0]);
|
||||
}
|
||||
return new GenericStack[]{new GenericStack(AEItemKey.of(ing), ing.getCount())};
|
||||
}
|
||||
|
||||
private boolean beginCrafting(ArcaneAssemblerPattern arcanePattern) {
|
||||
@@ -540,7 +576,7 @@ public class TileArcaneAssembler extends ThETileBase
|
||||
this.internalInventory.setItem(TARGET_SLOT, result.copy());
|
||||
setChanged();
|
||||
markForUpdate();
|
||||
thaumicenergistics.common.network.AssemblerPreviewSyncPacket.send(this, true);
|
||||
AssemblerPreviewSyncPacket.send(this, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -554,7 +590,7 @@ public class TileArcaneAssembler extends ThETileBase
|
||||
ItemStack icon = new ItemStack(thaumicenergistics.init.ModItems.ARCANE_ASSEMBLER_ITEM.get());
|
||||
return new PatternContainerGroup(
|
||||
AEItemKey.of(icon),
|
||||
net.minecraft.network.chat.Component.translatable("block.thaumicenergistics.arcane_assembler"),
|
||||
Component.translatable("block.thaumicenergistics.arcane_assembler"),
|
||||
List.of()
|
||||
);
|
||||
}
|
||||
@@ -603,25 +639,25 @@ public class TileArcaneAssembler extends ThETileBase
|
||||
* 复刻 1.7.10 onMemoryCardActivate,但用 P2P 频率替代 DigiVisSourceData 位置(适配 neo vis_interface P2P)。
|
||||
* 卡上有 EXPORTED_P2P_FREQUENCY → 存频率;空白卡 → 清空;其它 → 无效。
|
||||
*/
|
||||
public void onMemoryCardActivate(net.minecraft.world.entity.player.Player player,
|
||||
appeng.api.implementations.items.IMemoryCard memoryCard,
|
||||
public void onMemoryCardActivate(Player player,
|
||||
IMemoryCard memoryCard,
|
||||
net.minecraft.world.item.ItemStack heldItem) {
|
||||
Short freq = heldItem.get(appeng.api.ids.AEComponents.EXPORTED_P2P_FREQUENCY);
|
||||
Short freq = heldItem.get(AEComponents.EXPORTED_P2P_FREQUENCY);
|
||||
if (freq != null) {
|
||||
// 卡上带 P2P 频率(从 vis_interface shift+右键复制来的)→ 设为 vis 源
|
||||
this.visSourceFreq = freq;
|
||||
this.setChanged();
|
||||
memoryCard.notifyUser(player, appeng.api.implementations.items.MemoryCardMessages.SETTINGS_LOADED);
|
||||
} else if (heldItem.get(appeng.api.ids.AEComponents.EXPORTED_SETTINGS_SOURCE) == null) {
|
||||
memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_LOADED);
|
||||
} else if (heldItem.get(AEComponents.EXPORTED_SETTINGS_SOURCE) == null) {
|
||||
// 空白卡 → 清空 vis 源
|
||||
if (this.visSourceFreq != 0) {
|
||||
this.visSourceFreq = 0;
|
||||
this.setChanged();
|
||||
}
|
||||
memoryCard.notifyUser(player, appeng.api.implementations.items.MemoryCardMessages.SETTINGS_CLEARED);
|
||||
memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_CLEARED);
|
||||
} else {
|
||||
// 卡上有其它配置(非 P2P 频率)→ 不兼容
|
||||
memoryCard.notifyUser(player, appeng.api.implementations.items.MemoryCardMessages.INVALID_MACHINE);
|
||||
memoryCard.notifyUser(player, MemoryCardMessages.INVALID_MACHINE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,18 +852,25 @@ public class TileArcaneAssembler extends ThETileBase
|
||||
public ArcaneAssemblerPattern(AEItemKey definition, IArcaneRecipe recipe,
|
||||
AspectList aspects, ItemStack resultStack,
|
||||
List<GenericStack> inputStacks) {
|
||||
this(definition, recipe, aspects, resultStack, inputStacks, null, null);
|
||||
this(definition, recipe, aspects, resultStack, inputStacks, null, null, null);
|
||||
}
|
||||
|
||||
public ArcaneAssemblerPattern(AEItemKey definition, IArcaneRecipe recipe,
|
||||
AspectList aspects, ItemStack resultStack,
|
||||
List<GenericStack> inputStacks, String research) {
|
||||
this(definition, recipe, aspects, resultStack, inputStacks, research, null);
|
||||
this(definition, recipe, aspects, resultStack, inputStacks, research, null, null);
|
||||
}
|
||||
|
||||
public ArcaneAssemblerPattern(AEItemKey definition, IArcaneRecipe recipe,
|
||||
AspectList aspects, ItemStack resultStack,
|
||||
List<GenericStack> inputStacks, String research, ItemStack[] grid) {
|
||||
this(definition, recipe, aspects, resultStack, inputStacks, research, grid, null);
|
||||
}
|
||||
|
||||
public ArcaneAssemblerPattern(AEItemKey definition, IArcaneRecipe recipe,
|
||||
AspectList aspects, ItemStack resultStack,
|
||||
List<GenericStack> inputStacks, String research, ItemStack[] grid,
|
||||
List<GenericStack[]> inputAlternatives) {
|
||||
this.definition = definition;
|
||||
this.recipe = recipe;
|
||||
this.aspects = aspects;
|
||||
@@ -837,10 +880,15 @@ public class TileArcaneAssembler extends ThETileBase
|
||||
this.inputs = new IInput[inputStacks.size()];
|
||||
for (int i = 0; i < inputStacks.size(); i++) {
|
||||
GenericStack stack = inputStacks.get(i);
|
||||
// 通配变体组(tag 展开结果);null/单元素退化为精确匹配(与旧行为一致)
|
||||
GenericStack[] alts = (inputAlternatives != null && i < inputAlternatives.size()
|
||||
&& inputAlternatives.get(i) != null)
|
||||
? inputAlternatives.get(i)
|
||||
: new GenericStack[]{stack};
|
||||
this.inputs[i] = new IInput() {
|
||||
@Override
|
||||
public GenericStack[] getPossibleInputs() {
|
||||
return new GenericStack[]{stack};
|
||||
return alts;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -850,9 +898,13 @@ public class TileArcaneAssembler extends ThETileBase
|
||||
|
||||
@Override
|
||||
public boolean isValid(AEKey input, Level level) {
|
||||
return input instanceof AEItemKey itemKey
|
||||
&& stack.what() instanceof AEItemKey stackKey
|
||||
&& itemKey.equals(stackKey);
|
||||
if (!(input instanceof AEItemKey itemKey)) return false;
|
||||
for (GenericStack alt : alts) {
|
||||
if (alt.what() instanceof AEItemKey altKey && altKey.equals(itemKey)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -862,7 +914,7 @@ public class TileArcaneAssembler extends ThETileBase
|
||||
// 规划端据此按"每次 1 单"顺序模拟、执行端把珍珠计入 CPU waitingFor,
|
||||
// 机器合成完成把珍珠退回网络后 CPU 自动捕获续下一单——1 颗珍珠可连续多单。
|
||||
if (what instanceof AEItemKey itemKey
|
||||
&& itemKey.getItem() == net.minecraft.core.registries.BuiltInRegistries.ITEM.get(PRIMORDIAL_PEARL_ID)) {
|
||||
&& itemKey.getItem() == BuiltInRegistries.ITEM.get(PRIMORDIAL_PEARL_ID)) {
|
||||
return what;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package thaumicenergistics.common.tiles;
|
||||
|
||||
import appeng.core.definitions.AEItems;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
@@ -13,6 +13,11 @@ import thaumicenergistics.init.ModBlockEntities;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.LongTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
||||
public class TileEssentiaProvider extends TileProviderBase implements IEssentiaTransport, EssentiaTransport {
|
||||
|
||||
@@ -291,22 +296,22 @@ public class TileEssentiaProvider extends TileProviderBase implements IEssentiaT
|
||||
// ===== NBT =====
|
||||
|
||||
@Override
|
||||
protected void saveAdditional(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries) {
|
||||
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||
super.saveAdditional(tag, registries);
|
||||
net.minecraft.nbt.ListTag list = new net.minecraft.nbt.ListTag();
|
||||
ListTag list = new ListTag();
|
||||
for (BlockPos pos : linkedReceivers) {
|
||||
list.add(net.minecraft.nbt.LongTag.valueOf(pos.asLong()));
|
||||
list.add(LongTag.valueOf(pos.asLong()));
|
||||
}
|
||||
tag.put("LinkedReceivers", list);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadAdditional(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries) {
|
||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||
super.loadAdditional(tag, registries);
|
||||
linkedReceivers.clear();
|
||||
if (tag.contains("LinkedReceivers")) {
|
||||
for (net.minecraft.nbt.Tag t : tag.getList("LinkedReceivers", net.minecraft.nbt.Tag.TAG_LONG)) {
|
||||
linkedReceivers.add(BlockPos.of(((net.minecraft.nbt.LongTag) t).getAsLong()));
|
||||
for (Tag t : tag.getList("LinkedReceivers", Tag.TAG_LONG)) {
|
||||
linkedReceivers.add(BlockPos.of(((LongTag) t).getAsLong()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import thaumcraft.api.aspects.IEssentiaTransport;
|
||||
import thaumcraft.common.essentia.EssentiaTransport;
|
||||
import thaumicenergistics.init.ModBlockEntities;
|
||||
import thaumicenergistics.init.ModBlocks;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
/**
|
||||
* 源质无线接收器:通过无线连接器与源质供应器建立连接后,
|
||||
@@ -43,7 +44,7 @@ public class TileEssentiaProviderConnection extends BlockEntity implements IEsse
|
||||
private static final int PIPE_SCAN_RANGE = 16;
|
||||
|
||||
/** 服务端 tick:周期校验连接 + 主动沿模拟管道拉取源质(蒸馏器/罐/管道不主动推,需接收器拉)。 */
|
||||
public static void serverTick(net.minecraft.world.level.Level level, BlockPos pos, BlockState state, TileEssentiaProviderConnection be) {
|
||||
public static void serverTick(Level level, BlockPos pos, BlockState state, TileEssentiaProviderConnection be) {
|
||||
if (level.isClientSide()) return;
|
||||
if (be.linkedProviderPos != null && ++be.linkCheckCounter >= 40) {
|
||||
be.linkCheckCounter = 0;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package thaumicenergistics.common.tiles;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -30,11 +29,10 @@ import appeng.api.util.AECableType;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.IEssentiaTransport;
|
||||
import thaumcraft.common.essentia.EssentiaTransport;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.api.grid.IEssentiaGrid;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
import thaumicenergistics.init.ModBlockEntities;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
|
||||
public class TileEssentiaVibrationChamber extends ThETileBase implements IInWorldGridNodeHost, IGridTickable, IEssentiaTransport, EssentiaTransport {
|
||||
|
||||
@@ -72,7 +70,7 @@ public class TileEssentiaVibrationChamber extends ThETileBase implements IInWorl
|
||||
public TileEssentiaVibrationChamber(BlockPos pos, BlockState state) {
|
||||
super(ModBlockEntities.ESSENTIA_VIBRATION_CHAMBER.get(), pos, state);
|
||||
mainNode = GridHelper.createManagedNode(this, nodeListener)
|
||||
.setVisualRepresentation(thaumicenergistics.init.ModItems.ESSENTIA_VIBRATION_CHAMBER_ITEM.get())
|
||||
.setVisualRepresentation(ModItems.ESSENTIA_VIBRATION_CHAMBER_ITEM.get())
|
||||
.setInWorldNode(true)
|
||||
.setTagName("proxy")
|
||||
.setFlags(GridFlags.REQUIRE_CHANNEL)
|
||||
|
||||
@@ -16,24 +16,25 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.neoforged.neoforge.common.extensions.IPlayerExtension;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.GridHelper;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.IGridNodeListener;
|
||||
import appeng.api.networking.IManagedGridNode;
|
||||
import appeng.api.networking.IInWorldGridNodeHost;
|
||||
import appeng.api.util.AECableType;
|
||||
import net.minecraft.world.item.Items;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.init.ModBlockEntities;
|
||||
import thaumicenergistics.init.ModBlocks;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import thaumcraft.common.blockentities.InfusionMatrixBlockEntity;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
|
||||
/**
|
||||
* 注魔监视器(灵气观测器)方块实体。
|
||||
@@ -76,6 +77,11 @@ public class TileInfusionMonitor extends ThETileBase implements IInWorldGridNode
|
||||
/** 上次扫描到的祭坛注魔中状态(翻转时强制立即重算风险,抓住注魔启动瞬间的高不稳定度)。 */
|
||||
private boolean cachedCrafting = false;
|
||||
|
||||
// ===== M4:注魔结束红石脉冲 =====
|
||||
/** 脉冲剩余时长(tick)。仅运行期内存,不持久化——重载不回放(边界语义①)。 */
|
||||
private static final int PULSE_DURATION = 40; // 2 秒,裁决 #5
|
||||
private int pulseTicks = 0;
|
||||
|
||||
/** 区块卸载/方块移除中:禁止 setBlock / markForUpdate(卸载时改方块状态会触发区块重载,停服保存死循环)。 */
|
||||
private boolean unloading = false;
|
||||
|
||||
@@ -114,7 +120,7 @@ public class TileInfusionMonitor extends ThETileBase implements IInWorldGridNode
|
||||
public TileInfusionMonitor(BlockPos pos, BlockState state) {
|
||||
super(ModBlockEntities.INFUSION_MONITOR.get(), pos, state);
|
||||
this.mainNode = GridHelper.createManagedNode(this, nodeListener)
|
||||
.setVisualRepresentation(thaumicenergistics.init.ModItems.INFUSION_MONITOR_ITEM.get())
|
||||
.setVisualRepresentation(ModItems.INFUSION_MONITOR_ITEM.get())
|
||||
.setInWorldNode(true)
|
||||
.setTagName("proxy")
|
||||
.setFlags(GridFlags.REQUIRE_CHANNEL)
|
||||
@@ -167,6 +173,15 @@ public class TileInfusionMonitor extends ThETileBase implements IInWorldGridNode
|
||||
|
||||
public static void tick(Level level, BlockPos pos, BlockState state, TileInfusionMonitor be) {
|
||||
if (level.isClientSide()) return;
|
||||
// M4 脉冲计时:递减到 0 自动复位;counter 为 0 但方块仍为激活态(掉线重启残留)→ 自愈复位
|
||||
if (be.pulseTicks > 0) {
|
||||
be.pulseTicks--;
|
||||
if (be.pulseTicks == 0) {
|
||||
be.updatePulseState(false);
|
||||
}
|
||||
} else if (state.getValue(ModBlocks.PULSE)) {
|
||||
be.updatePulseState(false);
|
||||
}
|
||||
// 无祭坛缓存时全量扫描退避到 SCAN_MISS_INTERVAL(否则每 10 tick 扫 9800 次 getBlockEntity,
|
||||
// 附近没建祭坛时也持续 ~70us/t)
|
||||
int interval = be.matrixPos == null ? SCAN_MISS_INTERVAL : SCAN_INTERVAL;
|
||||
@@ -187,9 +202,16 @@ public class TileInfusionMonitor extends ThETileBase implements IInWorldGridNode
|
||||
boolean craftingChanged = false;
|
||||
// 快速路径:缓存矩阵仍在 → 跳过全量扫描
|
||||
if (found != null) {
|
||||
if (level.getBlockEntity(found) instanceof thaumcraft.common.blockentities.InfusionMatrixBlockEntity matrix) {
|
||||
if (level.getBlockEntity(found) instanceof InfusionMatrixBlockEntity matrix) {
|
||||
boolean crafting = matrix.crafting();
|
||||
craftingChanged = crafting != cachedCrafting;
|
||||
// M4:忙碌→空闲跳变 = 注魔结束(成功/失败均触发;TC port.261 无完成事件,
|
||||
// 故挂既有探测循环做下降沿检测,零额外扫描)。
|
||||
// cachedCrafting 仅运行期内存 → 重载后从 false 起步,不会把已结束的旧注魔补发脉冲(边界语义①);
|
||||
// 每个 BE 独立检测,多观测器覆盖同一矩阵各自脉冲(边界语义②)。
|
||||
if (craftingChanged && cachedCrafting && !crafting) {
|
||||
startPulse();
|
||||
}
|
||||
cachedCrafting = crafting;
|
||||
} else {
|
||||
found = null; // 缓存失效 → 走全量扫描
|
||||
@@ -208,7 +230,7 @@ public class TileInfusionMonitor extends ThETileBase implements IInWorldGridNode
|
||||
riskCounter += SCAN_INTERVAL;
|
||||
if (riskCounter >= RISK_INTERVAL || !cachedRisk.found() || craftingChanged) {
|
||||
riskCounter = 0;
|
||||
if (level.getBlockEntity(found) instanceof thaumcraft.common.blockentities.InfusionMatrixBlockEntity matrix) {
|
||||
if (level.getBlockEntity(found) instanceof InfusionMatrixBlockEntity matrix) {
|
||||
newRisk = InfusionRiskCalculator.computeRisk(level,
|
||||
new InfusionRiskCalculator.InfusionMatrixInfo(found, matrix));
|
||||
} else {
|
||||
@@ -228,6 +250,27 @@ public class TileInfusionMonitor extends ThETileBase implements IInWorldGridNode
|
||||
}
|
||||
}
|
||||
|
||||
// ===== M4:注魔结束红石脉冲 =====
|
||||
|
||||
/** 触发单次脉冲:置激活态并计时,PULSE_DURATION tick 后由 tick 自动复位。 */
|
||||
private void startPulse() {
|
||||
this.pulseTicks = PULSE_DURATION;
|
||||
updatePulseState(true);
|
||||
}
|
||||
|
||||
/** 写 PULSE 方块状态(与 updateNetworkState 同款防护:卸载/移除中禁止 setBlock)。 */
|
||||
private void updatePulseState(boolean pulsing) {
|
||||
if (level == null || level.isClientSide() || unloading || isRemoved()) return;
|
||||
BlockState st = getBlockState();
|
||||
if (st.getValue(ModBlocks.PULSE) != pulsing) {
|
||||
level.setBlock(worldPosition, st.setValue(ModBlocks.PULSE, pulsing), 3);
|
||||
BlockEntity be = level.getBlockEntity(worldPosition);
|
||||
if (be != null && be != this) {
|
||||
be.setChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 网格节点 / 状态同步 =====
|
||||
|
||||
private void updateNetworkState() {
|
||||
@@ -306,7 +349,7 @@ public class TileInfusionMonitor extends ThETileBase implements IInWorldGridNode
|
||||
if (bubble == null || level == null) return;
|
||||
try {
|
||||
if (READ_NBT_METHOD == null) {
|
||||
READ_NBT_METHOD = net.minecraft.world.entity.Entity.class
|
||||
READ_NBT_METHOD = Entity.class
|
||||
.getDeclaredMethod("readAdditionalSaveData", CompoundTag.class);
|
||||
READ_NBT_METHOD.setAccessible(true);
|
||||
}
|
||||
@@ -478,8 +521,8 @@ public class TileInfusionMonitor extends ThETileBase implements IInWorldGridNode
|
||||
|
||||
public static boolean isThaumonomicon(ItemStack stack) {
|
||||
if (stack.isEmpty()) return false;
|
||||
return stack.is(net.minecraft.core.registries.BuiltInRegistries.ITEM.get(
|
||||
net.minecraft.resources.ResourceLocation.fromNamespaceAndPath("thaumcraft", "thaumonomicon")));
|
||||
return stack.is(BuiltInRegistries.ITEM.get(
|
||||
ResourceLocation.fromNamespaceAndPath("thaumcraft", "thaumonomicon")));
|
||||
}
|
||||
|
||||
// ===== 访问器 =====
|
||||
|
||||
@@ -7,6 +7,8 @@ import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.tiles.*;
|
||||
import thaumicenergistics.common.integration.tc.VisProviderProxy;
|
||||
import java.util.function.Supplier;
|
||||
import thaumicenergistics.common.parts.VisInterfacePart;
|
||||
import thaumicenergistics.common.tiles.BrainOfProbabilityBlockEntity;
|
||||
|
||||
public final class ModBlockEntities {
|
||||
private ModBlockEntities() {}
|
||||
@@ -45,13 +47,19 @@ public final class ModBlockEntities {
|
||||
REGISTRY.register("infusion_monitor",
|
||||
() -> BlockEntityType.Builder.of(TileInfusionMonitor::new, ModBlocks.INFUSION_MONITOR.get()).build(null));
|
||||
|
||||
/** M6:概率之脑(仅下格持有 BE)。 */
|
||||
public static final Supplier<BlockEntityType<BrainOfProbabilityBlockEntity>> BRAIN_OF_PROBABILITY =
|
||||
REGISTRY.register("brain_of_probability",
|
||||
() -> BlockEntityType.Builder.of(BrainOfProbabilityBlockEntity::new,
|
||||
ModBlocks.BRAIN_OF_PROBABILITY.get()).build(null));
|
||||
|
||||
public static final Supplier<BlockEntityType<TileEssentiaProviderConnection>> ESSENTIA_PROVIDER_CONNECTION =
|
||||
REGISTRY.register("essentia_provider_connection",
|
||||
() -> BlockEntityType.Builder.of(TileEssentiaProviderConnection::new, ModBlocks.ESSENTIA_PROVIDER_CONNECTION.get()).build(null));
|
||||
|
||||
/**
|
||||
* 虚拟的 Thaumcraft vis 源,供 vis 接口的提供端使用。
|
||||
* 不作为真实方块放置;由 {@link thaumicenergistics.common.parts.VisInterfacePart}
|
||||
* 不作为真实方块放置;由 {@link VisInterfacePart}
|
||||
* 在运行时构造并注入到 VisNetHandler。
|
||||
*/
|
||||
public static final Supplier<BlockEntityType<VisProviderProxy>> VIS_PROVIDER_PROXY =
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package thaumicenergistics.init;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.SimpleMenuProvider;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
@@ -12,11 +11,40 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.neoforge.registries.DeferredBlock;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.blocks.BrainOfProbabilityBlock;
|
||||
import thaumicenergistics.common.blocks.BrainOfProbabilityTopBlock;
|
||||
import thaumicenergistics.common.blocks.OrientableEntityBlock;
|
||||
import thaumicenergistics.common.blocks.ThEBaseEntityBlock;
|
||||
import thaumicenergistics.common.tiles.*;
|
||||
import thaumicenergistics.init.ModItems;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.ItemInteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.neoforged.neoforge.common.extensions.IPlayerExtension;
|
||||
import thaumicenergistics.common.container.ContainerArcaneAssembler;
|
||||
import thaumicenergistics.common.container.ContainerDistillationPatternEncoder;
|
||||
import thaumicenergistics.common.container.ContainerEssentiaCellWorkbench;
|
||||
import thaumicenergistics.common.container.ContainerKnowledgeInscriber;
|
||||
|
||||
public final class ModBlocks {
|
||||
private ModBlocks() {}
|
||||
@@ -25,97 +53,97 @@ public final class ModBlocks {
|
||||
/** 装配器专用:noOcclusion——玻璃方块不被视为不透明,相邻方块(如冰/半透明)接触面不被剔除,透明玻璃后可正常看到后方方块。 */
|
||||
private static final BlockBehaviour.Properties PA = P.noOcclusion();
|
||||
|
||||
public static final DeferredBlock<Block> ESSENTIA_PROVIDER = REGISTRY.register("essentia_provider", () -> new ThEBaseEntityBlock(P) { public net.minecraft.world.level.block.entity.BlockEntity newBlockEntity(BlockPos pos, BlockState st) { return new TileEssentiaProvider(pos, st); } });
|
||||
public static final DeferredBlock<Block> INFUSION_PROVIDER = REGISTRY.register("infusion_provider", () -> new ThEBaseEntityBlock(P) { public net.minecraft.world.level.block.entity.BlockEntity newBlockEntity(BlockPos pos, BlockState st) { return new TileInfusionProvider(pos, st); } });
|
||||
public static final DeferredBlock<Block> ESSENTIA_PROVIDER = REGISTRY.register("essentia_provider", () -> new ThEBaseEntityBlock(P) { public BlockEntity newBlockEntity(BlockPos pos, BlockState st) { return new TileEssentiaProvider(pos, st); } });
|
||||
public static final DeferredBlock<Block> INFUSION_PROVIDER = REGISTRY.register("infusion_provider", () -> new ThEBaseEntityBlock(P) { public BlockEntity newBlockEntity(BlockPos pos, BlockState st) { return new TileInfusionProvider(pos, st); } });
|
||||
public static final DeferredBlock<Block> ARCANE_ASSEMBLER = REGISTRY.register("arcane_assembler", () -> new ThEBaseEntityBlock(PA) {
|
||||
public net.minecraft.world.level.block.entity.BlockEntity newBlockEntity(BlockPos pos, BlockState st) { return new TileArcaneAssembler(pos, st); }
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState st) { return new TileArcaneAssembler(pos, st); }
|
||||
@Override
|
||||
protected net.minecraft.world.ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, BlockState state, net.minecraft.world.level.Level level, BlockPos pos, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.BlockHitResult hit) {
|
||||
protected ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
// 手持 AE2 内存卡:交给装配器处理(读 P2P 频率设 vis 源 / 清空),不打开 GUI。
|
||||
// 1.21 方块 useItemOn 先于物品 useOn,返回 sidedSuccess 消费交互(也阻止内存卡自身 shift 清空)。
|
||||
if (stack.getItem() instanceof appeng.api.implementations.items.IMemoryCard memoryCard
|
||||
if (stack.getItem() instanceof IMemoryCard memoryCard
|
||||
&& level.getBlockEntity(pos) instanceof TileArcaneAssembler tile) {
|
||||
if (!level.isClientSide) {
|
||||
tile.onMemoryCardActivate(player, memoryCard, stack);
|
||||
}
|
||||
return net.minecraft.world.ItemInteractionResult.sidedSuccess(level.isClientSide());
|
||||
return ItemInteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
if (!level.isClientSide) {
|
||||
((net.neoforged.neoforge.common.extensions.IPlayerExtension) player)
|
||||
((IPlayerExtension) player)
|
||||
.openMenu(state.getMenuProvider(level, pos), pos);
|
||||
}
|
||||
return net.minecraft.world.ItemInteractionResult.SUCCESS;
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
@Override
|
||||
protected net.minecraft.world.MenuProvider getMenuProvider(BlockState state, net.minecraft.world.level.Level level, BlockPos pos) {
|
||||
protected net.minecraft.world.MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) {
|
||||
TileArcaneAssembler tile = (TileArcaneAssembler) level.getBlockEntity(pos);
|
||||
return new SimpleMenuProvider(
|
||||
(id, inv, p) -> new thaumicenergistics.common.container.ContainerArcaneAssembler(id, inv, tile),
|
||||
(id, inv, p) -> new ContainerArcaneAssembler(id, inv, tile),
|
||||
Component.translatable("block.thaumicenergistics.arcane_assembler"));
|
||||
}
|
||||
});
|
||||
public static final DeferredBlock<Block> ESSENTIA_VIBRATION_CHAMBER = REGISTRY.register("essentia_vibration_chamber", () -> new OrientableEntityBlock(P) { public net.minecraft.world.level.block.entity.BlockEntity newBlockEntity(BlockPos pos, BlockState st) { return new TileEssentiaVibrationChamber(pos, st); } });
|
||||
public static final DeferredBlock<Block> ESSENTIA_VIBRATION_CHAMBER = REGISTRY.register("essentia_vibration_chamber", () -> new OrientableEntityBlock(P) { public BlockEntity newBlockEntity(BlockPos pos, BlockState st) { return new TileEssentiaVibrationChamber(pos, st); } });
|
||||
public static final DeferredBlock<Block> KNOWLEDGE_INSCRIBER = REGISTRY.register("knowledge_inscriber", () -> new ThEBaseEntityBlock(P) {
|
||||
public net.minecraft.world.level.block.entity.BlockEntity newBlockEntity(BlockPos pos, BlockState st) { return new TileKnowledgeInscriber(pos, st); }
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState st) { return new TileKnowledgeInscriber(pos, st); }
|
||||
@Override
|
||||
protected void createBlockStateDefinition(net.minecraft.world.level.block.state.StateDefinition.Builder<Block, BlockState> builder) {
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(OrientableEntityBlock.FACING);
|
||||
}
|
||||
@Override
|
||||
public BlockState getStateForPlacement(net.minecraft.world.item.context.BlockPlaceContext context) {
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return this.defaultBlockState().setValue(OrientableEntityBlock.FACING, context.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
@Override
|
||||
protected net.minecraft.world.ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, BlockState state, net.minecraft.world.level.Level level, BlockPos pos, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.BlockHitResult hit) {
|
||||
protected ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!level.isClientSide) player.openMenu(state.getMenuProvider(level, pos));
|
||||
return net.minecraft.world.ItemInteractionResult.SUCCESS;
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
@Override
|
||||
protected net.minecraft.world.MenuProvider getMenuProvider(BlockState state, net.minecraft.world.level.Level level, BlockPos pos) {
|
||||
protected net.minecraft.world.MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) {
|
||||
TileKnowledgeInscriber tile = (TileKnowledgeInscriber) level.getBlockEntity(pos);
|
||||
return new SimpleMenuProvider(
|
||||
(id, inv, p) -> new thaumicenergistics.common.container.ContainerKnowledgeInscriber(id, inv, tile),
|
||||
(id, inv, p) -> new ContainerKnowledgeInscriber(id, inv, tile),
|
||||
Component.translatable("block.thaumicenergistics.knowledge_inscriber"));
|
||||
}
|
||||
});
|
||||
public static final DeferredBlock<Block> DISTILLATION_ENCODER = REGISTRY.register("distillation_encoder", () -> new ThEBaseEntityBlock(P) {
|
||||
public net.minecraft.world.level.block.entity.BlockEntity newBlockEntity(BlockPos pos, BlockState st) { return new TileDistillationPatternEncoder(pos, st); }
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState st) { return new TileDistillationPatternEncoder(pos, st); }
|
||||
@Override
|
||||
protected void createBlockStateDefinition(net.minecraft.world.level.block.state.StateDefinition.Builder<Block, BlockState> builder) {
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(OrientableEntityBlock.FACING);
|
||||
}
|
||||
@Override
|
||||
public BlockState getStateForPlacement(net.minecraft.world.item.context.BlockPlaceContext context) {
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return this.defaultBlockState().setValue(OrientableEntityBlock.FACING, context.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
@Override
|
||||
protected net.minecraft.world.ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, BlockState state, net.minecraft.world.level.Level level, BlockPos pos, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.BlockHitResult hit) {
|
||||
protected ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!level.isClientSide) player.openMenu(state.getMenuProvider(level, pos));
|
||||
return net.minecraft.world.ItemInteractionResult.SUCCESS;
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
@Override
|
||||
protected net.minecraft.world.MenuProvider getMenuProvider(BlockState state, net.minecraft.world.level.Level level, BlockPos pos) {
|
||||
protected net.minecraft.world.MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) {
|
||||
TileDistillationPatternEncoder tile = (TileDistillationPatternEncoder) level.getBlockEntity(pos);
|
||||
return new SimpleMenuProvider(
|
||||
(id, inv, p) -> new thaumicenergistics.common.container.ContainerDistillationPatternEncoder(id, inv, tile),
|
||||
(id, inv, p) -> new ContainerDistillationPatternEncoder(id, inv, tile),
|
||||
Component.translatable("block.thaumicenergistics.distillation_encoder"));
|
||||
}
|
||||
});
|
||||
public static final DeferredBlock<Block> ESSENTIA_CELL_WORKBENCH = REGISTRY.register("essentia_cell_workbench", () -> new ThEBaseEntityBlock(P) {
|
||||
@Override
|
||||
public net.minecraft.world.level.block.entity.BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new TileEssentiaCellWorkbench(pos, state);
|
||||
}
|
||||
@Override
|
||||
protected net.minecraft.world.ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, BlockState state, net.minecraft.world.level.Level level, BlockPos pos, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.BlockHitResult hit) {
|
||||
protected ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!level.isClientSide) player.openMenu(state.getMenuProvider(level, pos));
|
||||
return net.minecraft.world.ItemInteractionResult.SUCCESS;
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
@Override
|
||||
protected net.minecraft.world.MenuProvider getMenuProvider(BlockState state, net.minecraft.world.level.Level level, BlockPos pos) {
|
||||
net.minecraft.world.level.block.entity.BlockEntity be = level.getBlockEntity(pos);
|
||||
protected net.minecraft.world.MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) {
|
||||
BlockEntity be = level.getBlockEntity(pos);
|
||||
if (be instanceof TileEssentiaCellWorkbench workbench) {
|
||||
return new SimpleMenuProvider((id, inv, p) -> new thaumicenergistics.common.container.ContainerEssentiaCellWorkbench(id, inv, workbench),
|
||||
return new SimpleMenuProvider((id, inv, p) -> new ContainerEssentiaCellWorkbench(id, inv, workbench),
|
||||
Component.translatable("block.thaumicenergistics.essentia_cell_workbench"));
|
||||
}
|
||||
return null;
|
||||
@@ -125,23 +153,27 @@ public final class ModBlocks {
|
||||
// ==================== 注魔监视器(灵气观测器) ====================
|
||||
|
||||
/** 是否放入魔导手册。 */
|
||||
public static final net.minecraft.world.level.block.state.properties.BooleanProperty BOOK =
|
||||
net.minecraft.world.level.block.state.properties.BooleanProperty.create("book");
|
||||
public static final BooleanProperty BOOK =
|
||||
BooleanProperty.create("book");
|
||||
/** 是否连接 AE 网络。 */
|
||||
public static final net.minecraft.world.level.block.state.properties.BooleanProperty NETWORK =
|
||||
net.minecraft.world.level.block.state.properties.BooleanProperty.create("network");
|
||||
public static final BooleanProperty NETWORK =
|
||||
BooleanProperty.create("network");
|
||||
|
||||
/** M4:注魔结束红石脉冲激活态(单次脉冲 40 tick 后自动复位;模型不引用此属性,纯红石信号)。 */
|
||||
public static final BooleanProperty PULSE =
|
||||
BooleanProperty.create("pulse");
|
||||
|
||||
/**
|
||||
* 注魔监视器:4 态(off / off+book / off+book+on / off+Jade),blockstate 用 multipart 合并模型。
|
||||
*/
|
||||
public static final DeferredBlock<Block> INFUSION_MONITOR = REGISTRY.register("infusion_monitor", () -> new ThEBaseEntityBlock(P) {
|
||||
@Override
|
||||
public net.minecraft.world.level.block.entity.BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new TileInfusionMonitor(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends net.minecraft.world.level.block.entity.BlockEntity> net.minecraft.world.level.block.entity.BlockEntityTicker<T> getTicker(net.minecraft.world.level.Level level, BlockState state, net.minecraft.world.level.block.entity.BlockEntityType<T> type) {
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
||||
if (level.isClientSide()) return null;
|
||||
if (type == ModBlockEntities.INFUSION_MONITOR.get()) {
|
||||
return (lvl, pos, st, be) -> TileInfusionMonitor.tick(lvl, pos, st, (TileInfusionMonitor) be);
|
||||
@@ -150,81 +182,102 @@ public final class ModBlocks {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(net.minecraft.world.level.block.state.StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(BOOK, NETWORK, FACING);
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(BOOK, NETWORK, FACING, PULSE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(net.minecraft.world.item.context.BlockPlaceContext context) {
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
// 放置时始终朝向放置者
|
||||
return this.defaultBlockState()
|
||||
.setValue(FACING, context.getHorizontalDirection().getOpposite())
|
||||
.setValue(BOOK, false)
|
||||
.setValue(NETWORK, false);
|
||||
.setValue(NETWORK, false)
|
||||
.setValue(PULSE, false);
|
||||
}
|
||||
|
||||
// ===== M4:注魔结束红石脉冲(五面输出,T-M4-SIGNAL-REV) =====
|
||||
// FACING = 放置时朝向放置者(正面=贴注魔矩阵面,典型安装时朝上);除正面外五面(4 侧面+底部)输出恒 15。
|
||||
|
||||
@Override
|
||||
protected boolean isSignalSource(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected net.minecraft.world.ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, BlockState state, net.minecraft.world.level.Level level, BlockPos pos, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.BlockHitResult hit) {
|
||||
protected int getSignal(BlockState state, BlockGetter level, BlockPos pos, Direction side) {
|
||||
// 除正面外五面出信号(side = 信号流出面);正面恒 0
|
||||
return state.getValue(PULSE) && side != state.getValue(FACING) ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDirectSignal(BlockState state, BlockGetter level, BlockPos pos, Direction side) {
|
||||
// 与 getSignal 一致(红石线/比较器惯例,见 LeverBlock 同款双覆写)
|
||||
return state.getValue(PULSE) && side != state.getValue(FACING) ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (level.getBlockEntity(pos) instanceof TileInfusionMonitor monitor) {
|
||||
// 手持魔导手册 → 直接放入(返回 SUCCESS 拦截,避免魔导手册自身 use 打开界面)
|
||||
if (TileInfusionMonitor.isThaumonomicon(stack)) {
|
||||
if (!level.isClientSide) {
|
||||
monitor.placeBook(player, stack);
|
||||
}
|
||||
return net.minecraft.world.ItemInteractionResult.sidedSuccess(level.isClientSide());
|
||||
return ItemInteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
// Shift+右键(非手册物品)→ 取回手册
|
||||
if (player.isShiftKeyDown()) {
|
||||
if (!level.isClientSide) {
|
||||
monitor.retrieveBook(player);
|
||||
}
|
||||
return net.minecraft.world.ItemInteractionResult.sidedSuccess(level.isClientSide());
|
||||
return ItemInteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
// 普通右键(非手册/非Shift)→ 聊天框显示风险描述
|
||||
if (!level.isClientSide) {
|
||||
monitor.showDescriptionInChat(player);
|
||||
}
|
||||
return net.minecraft.world.ItemInteractionResult.sidedSuccess(level.isClientSide());
|
||||
return ItemInteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
return net.minecraft.world.ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
}
|
||||
|
||||
// 空手右键(1.21 走 useWithoutItem):Shift+空手 → 取回手册;普通空手右键 → 聊天框显示描述
|
||||
@Override
|
||||
protected net.minecraft.world.InteractionResult useWithoutItem(BlockState state, net.minecraft.world.level.Level level, BlockPos pos, net.minecraft.world.entity.player.Player player, net.minecraft.world.phys.BlockHitResult hit) {
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hit) {
|
||||
if (level.getBlockEntity(pos) instanceof TileInfusionMonitor monitor) {
|
||||
if (player.isShiftKeyDown()) {
|
||||
if (!level.isClientSide) {
|
||||
monitor.retrieveBook(player);
|
||||
}
|
||||
return net.minecraft.world.InteractionResult.sidedSuccess(level.isClientSide());
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
if (!level.isClientSide) {
|
||||
monitor.showDescriptionInChat(player);
|
||||
}
|
||||
return net.minecraft.world.InteractionResult.sidedSuccess(level.isClientSide());
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
return net.minecraft.world.InteractionResult.PASS;
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.phys.shapes.VoxelShape getShape(BlockState state, net.minecraft.world.level.BlockGetter level, BlockPos pos, net.minecraft.world.phys.shapes.CollisionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
|
||||
// 底座(高 0.25)+ 上部塔架(0.25~0.8)
|
||||
return net.minecraft.world.phys.shapes.Shapes.or(
|
||||
net.minecraft.world.phys.shapes.Shapes.box(0.0, 0.0, 0.0, 1.0, 0.25, 1.0),
|
||||
net.minecraft.world.phys.shapes.Shapes.box(0.15, 0.25, 0.15, 0.85, 0.8, 0.85));
|
||||
return Shapes.or(
|
||||
Shapes.box(0.0, 0.0, 0.0, 1.0, 0.25, 1.0),
|
||||
Shapes.box(0.15, 0.25, 0.15, 0.85, 0.8, 0.85));
|
||||
}
|
||||
});
|
||||
|
||||
// ==================== Alkusure86 玩偶(Fumo) ====================
|
||||
|
||||
/** 水平朝向(韵魔观测器共用)。 */
|
||||
public static final net.minecraft.world.level.block.state.properties.DirectionProperty FACING =
|
||||
net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
||||
public static final DirectionProperty FACING =
|
||||
BlockStateProperties.HORIZONTAL_FACING;
|
||||
|
||||
// 姿态变体:0 = alkusure86fumo(默认坐姿),1 = a999csfumo。
|
||||
public static final net.minecraft.world.level.block.state.properties.BooleanProperty VARIANT =
|
||||
net.minecraft.world.level.block.state.properties.BooleanProperty.create("variant");
|
||||
public static final BooleanProperty VARIANT =
|
||||
BooleanProperty.create("variant");
|
||||
|
||||
// 玩偶专用:低硬度 → 空手可快速挖掘(装饰物)。
|
||||
private static final BlockBehaviour.Properties PD =
|
||||
@@ -234,12 +287,12 @@ public final class ModBlocks {
|
||||
// 右键切换姿态;Shift+右键拿起方块到手。
|
||||
public static final DeferredBlock<Block> ALKUSURE86_FUMO = REGISTRY.register("alkusure86fumo", () -> new Block(PD) {
|
||||
@Override
|
||||
protected void createBlockStateDefinition(net.minecraft.world.level.block.state.StateDefinition.Builder<Block, BlockState> builder) {
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING, VARIANT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(net.minecraft.world.item.context.BlockPlaceContext context) {
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
// 默认坐姿(variant=0),面向放置者
|
||||
return this.defaultBlockState()
|
||||
.setValue(FACING, context.getHorizontalDirection().getOpposite())
|
||||
@@ -247,53 +300,53 @@ public final class ModBlocks {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected net.minecraft.world.ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, BlockState state, net.minecraft.world.level.Level level, BlockPos pos, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.BlockHitResult hit) {
|
||||
protected ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (player.isShiftKeyDown()) {
|
||||
// Shift+右键:拿起方块到手(或背包)
|
||||
pickUp(level, pos, player);
|
||||
return net.minecraft.world.ItemInteractionResult.sidedSuccess(level.isClientSide());
|
||||
return ItemInteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
// 右键:切换姿态
|
||||
if (!level.isClientSide) {
|
||||
level.setBlock(pos, state.setValue(VARIANT, !state.getValue(VARIANT)), 3);
|
||||
}
|
||||
return net.minecraft.world.ItemInteractionResult.sidedSuccess(level.isClientSide());
|
||||
return ItemInteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
|
||||
// 空手右键(1.21 走 useWithoutItem):Shift+空手拿起;右键切换姿态
|
||||
@Override
|
||||
protected net.minecraft.world.InteractionResult useWithoutItem(BlockState state, net.minecraft.world.level.Level level, BlockPos pos, net.minecraft.world.entity.player.Player player, net.minecraft.world.phys.BlockHitResult hit) {
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hit) {
|
||||
if (player.isShiftKeyDown()) {
|
||||
pickUp(level, pos, player);
|
||||
return net.minecraft.world.InteractionResult.sidedSuccess(level.isClientSide());
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
if (!level.isClientSide) {
|
||||
level.setBlock(pos, state.setValue(VARIANT, !state.getValue(VARIANT)), 3);
|
||||
}
|
||||
return net.minecraft.world.InteractionResult.sidedSuccess(level.isClientSide());
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
|
||||
// Shift+右键拿起:移除方块,物品进主手(空手时)或背包。
|
||||
private void pickUp(net.minecraft.world.level.Level level, BlockPos pos, net.minecraft.world.entity.player.Player player) {
|
||||
private void pickUp(Level level, BlockPos pos, Player player) {
|
||||
if (level.isClientSide) return;
|
||||
ItemStack item = new ItemStack(ModItems.ALKUSURE86_FUMO_ITEM.get());
|
||||
if (player.getMainHandItem().isEmpty()) {
|
||||
player.setItemInHand(net.minecraft.world.InteractionHand.MAIN_HAND, item);
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, item);
|
||||
} else if (!player.getInventory().add(item)) {
|
||||
net.minecraft.world.Containers.dropItemStack(level, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, item);
|
||||
Containers.dropItemStack(level, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, item);
|
||||
}
|
||||
level.removeBlock(pos, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.phys.shapes.VoxelShape getShape(BlockState state, net.minecraft.world.level.BlockGetter level, BlockPos pos, net.minecraft.world.phys.shapes.CollisionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
|
||||
// 玩偶整体占位:坐姿高度约 12 格单位(0.75 格),宽约 8(0.5 格)
|
||||
return net.minecraft.world.phys.shapes.Shapes.box(0.25, 0.0, 0.25, 0.75, 0.75, 0.75);
|
||||
return Shapes.box(0.25, 0.0, 0.25, 0.75, 0.75, 0.75);
|
||||
}
|
||||
|
||||
// 纯 Block 无战利品表 → 必须覆写 getDrops,否则挖掘不掉落
|
||||
@Override
|
||||
public java.util.List<ItemStack> getDrops(BlockState state, net.minecraft.world.level.storage.loot.LootParams.Builder builder) {
|
||||
public java.util.List<ItemStack> getDrops(BlockState state, LootParams.Builder builder) {
|
||||
return java.util.List.of(new ItemStack(ModItems.ALKUSURE86_FUMO_ITEM.get()));
|
||||
}
|
||||
});
|
||||
@@ -301,12 +354,12 @@ public final class ModBlocks {
|
||||
// ==================== 源质无线接收器 ====================
|
||||
|
||||
/** 是否已连接源质供应器(off/on 模型切换)。 */
|
||||
public static final net.minecraft.world.level.block.state.properties.BooleanProperty CONNECTED =
|
||||
net.minecraft.world.level.block.state.properties.BooleanProperty.create("connected");
|
||||
public static final BooleanProperty CONNECTED =
|
||||
BooleanProperty.create("connected");
|
||||
|
||||
/** 接收器六向贴放(贴墙/立地/挂顶)。 */
|
||||
public static final net.minecraft.world.level.block.state.properties.DirectionProperty FACING_ALL =
|
||||
net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING;
|
||||
public static final DirectionProperty FACING_ALL =
|
||||
BlockStateProperties.FACING;
|
||||
|
||||
/** 接收器专用:低硬度 → 镐子可快速挖掘。 */
|
||||
private static final BlockBehaviour.Properties PC =
|
||||
@@ -314,12 +367,12 @@ public final class ModBlocks {
|
||||
|
||||
public static final DeferredBlock<Block> ESSENTIA_PROVIDER_CONNECTION = REGISTRY.register("essentia_provider_connection", () -> new ThEBaseEntityBlock(PC) {
|
||||
@Override
|
||||
public net.minecraft.world.level.block.entity.BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new TileEssentiaProviderConnection(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends net.minecraft.world.level.block.entity.BlockEntity> net.minecraft.world.level.block.entity.BlockEntityTicker<T> getTicker(net.minecraft.world.level.Level level, BlockState state, net.minecraft.world.level.block.entity.BlockEntityType<T> type) {
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
||||
if (!level.isClientSide() && type == ModBlockEntities.ESSENTIA_PROVIDER_CONNECTION.get()) {
|
||||
return (lvl, pos, st, be) -> TileEssentiaProviderConnection.serverTick(lvl, pos, st, (TileEssentiaProviderConnection) be);
|
||||
}
|
||||
@@ -327,12 +380,12 @@ public final class ModBlocks {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(net.minecraft.world.level.block.state.StateDefinition.Builder<Block, BlockState> builder) {
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(CONNECTED, FACING_ALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(net.minecraft.world.item.context.BlockPlaceContext context) {
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
// 正面朝外 = 点击面的方向(贴墙/立地/挂顶)
|
||||
return this.defaultBlockState()
|
||||
.setValue(FACING_ALL, context.getClickedFace())
|
||||
@@ -340,21 +393,29 @@ public final class ModBlocks {
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.phys.shapes.VoxelShape getShape(BlockState state, net.minecraft.world.level.BlockGetter level, BlockPos pos, net.minecraft.world.phys.shapes.CollisionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
|
||||
// 薄碰撞箱(贴墙/立地/挂顶),不遮挡光线;UP=立地(底部) DOWN=挂顶(顶部)
|
||||
return switch (state.getValue(FACING_ALL)) {
|
||||
case NORTH -> net.minecraft.world.phys.shapes.Shapes.box(0.25, 0.25, 0.75, 0.75, 0.75, 1.0);
|
||||
case SOUTH -> net.minecraft.world.phys.shapes.Shapes.box(0.25, 0.25, 0.0, 0.75, 0.75, 0.25);
|
||||
case EAST -> net.minecraft.world.phys.shapes.Shapes.box(0.0, 0.25, 0.25, 0.25, 0.75, 0.75);
|
||||
case WEST -> net.minecraft.world.phys.shapes.Shapes.box(0.75, 0.25, 0.25, 1.0, 0.75, 0.75);
|
||||
case UP -> net.minecraft.world.phys.shapes.Shapes.box(0.25, 0.0, 0.25, 0.75, 0.25, 0.75); // 立地:碰撞箱在底部
|
||||
case DOWN -> net.minecraft.world.phys.shapes.Shapes.box(0.25, 0.75, 0.25, 0.75, 1.0, 0.75); // 挂顶:碰撞箱在顶部
|
||||
case NORTH -> Shapes.box(0.25, 0.25, 0.75, 0.75, 0.75, 1.0);
|
||||
case SOUTH -> Shapes.box(0.25, 0.25, 0.0, 0.75, 0.75, 0.25);
|
||||
case EAST -> Shapes.box(0.0, 0.25, 0.25, 0.25, 0.75, 0.75);
|
||||
case WEST -> Shapes.box(0.75, 0.25, 0.25, 1.0, 0.75, 0.75);
|
||||
case UP -> Shapes.box(0.25, 0.0, 0.25, 0.75, 0.25, 0.75); // 立地:碰撞箱在底部
|
||||
case DOWN -> Shapes.box(0.25, 0.75, 0.25, 0.75, 1.0, 0.75); // 挂顶:碰撞箱在顶部
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightBlock(BlockState state, net.minecraft.world.level.BlockGetter level, BlockPos pos) {
|
||||
public int getLightBlock(BlockState state, BlockGetter level, BlockPos pos) {
|
||||
return 0; // 不遮挡光线
|
||||
}
|
||||
});
|
||||
|
||||
// ==================== M6:概率之脑(两格,CE gacha_box 同构) ====================
|
||||
|
||||
public static final DeferredBlock<Block> BRAIN_OF_PROBABILITY =
|
||||
REGISTRY.register("brain_of_probability", () -> new BrainOfProbabilityBlock(P));
|
||||
/** 上格形态方块:无 BE、无交互、不进创造栏、无掉落。 */
|
||||
public static final DeferredBlock<Block> BRAIN_OF_PROBABILITY_TOP =
|
||||
REGISTRY.register("brain_of_probability_top", () -> new BrainOfProbabilityTopBlock(P));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package thaumicenergistics.init;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.core.component.DataComponentType;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.item.component.ItemContainerContents;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
|
||||
/**
|
||||
* 物品数据组件注册:无线终端子库存的物品级持久化。
|
||||
* 对齐 AE2 {@code AEComponents.CRAFTING_INV} 范式(关菜单/存背包不丢内容)。
|
||||
*/
|
||||
public final class ModComponents {
|
||||
private ModComponents() {}
|
||||
|
||||
public static final DeferredRegister<DataComponentType<?>> REGISTRY =
|
||||
DeferredRegister.create(Registries.DATA_COMPONENT_TYPE, ThaumicEnergistics.MODID);
|
||||
|
||||
/** 无线奥术合成终端的法杖槽内容。 */
|
||||
public static final Supplier<DataComponentType<ItemContainerContents>> WAND_INV =
|
||||
REGISTRY.register("wand_inv", () -> DataComponentType.<ItemContainerContents>builder()
|
||||
.persistent(ItemContainerContents.CODEC)
|
||||
.networkSynchronized(ItemContainerContents.STREAM_CODEC)
|
||||
.build());
|
||||
}
|
||||
@@ -5,11 +5,7 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
import appeng.api.stacks.GenericStack;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -29,9 +25,8 @@ public final class ModCreativeTab {
|
||||
output.accept(ModItems.COALESCENCE_CORE.get()); output.accept(ModItems.DIFFUSION_CORE.get());
|
||||
output.accept(ModItems.KNOWLEDGE_CORE.get());
|
||||
output.accept(ModItems.FOCUS_AEWRENCH.get()); output.accept(ModItems.GOLEM_WIFI_BACKPACK.get());
|
||||
output.accept(ModItems.WIRELESS_ESSENTIA_TERMINAL.get());
|
||||
output.accept(ModItems.ESSENTIA_IMPORT_BUS.get()); output.accept(ModItems.ESSENTIA_EXPORT_BUS.get());
|
||||
output.accept(ModItems.ESSENTIA_STORAGE_BUS.get()); output.accept(ModItems.ESSENTIA_TERMINAL_ITEM.get());
|
||||
output.accept(ModItems.WIRELESS_ARCANE_CRAFTING_TERMINAL.get());
|
||||
output.accept(ModItems.VIS_CONNECTOR_CARD.get());
|
||||
output.accept(ModItems.ARCANE_CRAFTING_TERMINAL_ITEM.get()); output.accept(ModItems.ESSENTIA_LEVEL_EMITTER.get());
|
||||
output.accept(ModItems.VIS_INTERFACE.get());
|
||||
output.accept(ModItems.ESSENTIA_PROVIDER_ITEM.get()); output.accept(ModItems.INFUSION_PROVIDER_ITEM.get());
|
||||
@@ -40,6 +35,9 @@ public final class ModCreativeTab {
|
||||
output.accept(ModItems.DISTILLATION_ENCODER_ITEM.get());
|
||||
output.accept(ModItems.INFUSION_MONITOR_ITEM.get());
|
||||
output.accept(ModItems.ESSENTIA_PROVIDER_CONNECTION_ITEM.get()); output.accept(ModItems.WIRELESS_CONNECTOR.get());
|
||||
output.accept(ModItems.ESSENTIA_UPGRADE_CARD.get());
|
||||
output.accept(ModItems.PROBABILITY_ACCELERATOR_CARD.get());
|
||||
output.accept(ModItems.BRAIN_OF_PROBABILITY_ITEM.get());
|
||||
// 玩偶不进创造物品栏:需 /give @p thaumicenergistics:alkusure86fumo 手动获取
|
||||
// output.accept(ModItems.ALKUSURE86_FUMO_ITEM.get());
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import net.neoforged.neoforge.registries.DeferredItem;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.items.*;
|
||||
import appeng.core.AEConfig;
|
||||
import thaumicenergistics.common.items.WirelessConnectorItem;
|
||||
|
||||
public final class ModItems {
|
||||
private ModItems() {}
|
||||
@@ -27,38 +29,17 @@ public final class ModItems {
|
||||
() -> new Item(new Item.Properties().stacksTo(1)));
|
||||
public static final DeferredItem<ItemFocusAEWrench> FOCUS_AEWRENCH = REGISTRY.register("focus_aewrench",
|
||||
() -> new ItemFocusAEWrench());
|
||||
public static final DeferredItem<WirelessEssentiaTerminalItem> WIRELESS_ESSENTIA_TERMINAL = REGISTRY.register(
|
||||
"wireless_essentia_terminal",
|
||||
() -> new WirelessEssentiaTerminalItem(
|
||||
appeng.core.AEConfig.instance().getWirelessTerminalBattery(),
|
||||
public static final DeferredItem<WirelessArcaneCraftingTerminalItem> WIRELESS_ARCANE_CRAFTING_TERMINAL =
|
||||
REGISTRY.register("wireless_arcane_crafting_terminal",
|
||||
() -> new WirelessArcaneCraftingTerminalItem(
|
||||
AEConfig.instance().getWirelessTerminalBattery(),
|
||||
new Item.Properties().stacksTo(1)));
|
||||
public static final DeferredItem<VisConnectorCardItem> VIS_CONNECTOR_CARD = REGISTRY.register(
|
||||
"vis_connector_card",
|
||||
() -> new VisConnectorCardItem(new Item.Properties().stacksTo(1)));
|
||||
public static final DeferredItem<ItemGolemWirelessBackpack> GOLEM_WIFI_BACKPACK = REGISTRY.register("golem_wifi_backpack",
|
||||
ItemGolemWirelessBackpack::new);
|
||||
|
||||
public static final DeferredItem<PartItemEssentiaImportBus> ESSENTIA_IMPORT_BUS =
|
||||
REGISTRY.register(
|
||||
"essentia_import_bus",
|
||||
() -> new PartItemEssentiaImportBus(new Item.Properties().stacksTo(64))
|
||||
);
|
||||
|
||||
public static final DeferredItem<PartItemEssentiaExportBus> ESSENTIA_EXPORT_BUS =
|
||||
REGISTRY.register(
|
||||
"essentia_export_bus",
|
||||
() -> new PartItemEssentiaExportBus(new Item.Properties().stacksTo(64))
|
||||
);
|
||||
|
||||
public static final DeferredItem<PartItemEssentiaStorageBus> ESSENTIA_STORAGE_BUS =
|
||||
REGISTRY.register(
|
||||
"essentia_storage_bus",
|
||||
() -> new PartItemEssentiaStorageBus(new Item.Properties().stacksTo(64))
|
||||
);
|
||||
|
||||
public static final DeferredItem<PartItemEssentiaTerminal> ESSENTIA_TERMINAL_ITEM =
|
||||
REGISTRY.register(
|
||||
"essentia_terminal",
|
||||
() -> new PartItemEssentiaTerminal(new Item.Properties().stacksTo(64))
|
||||
);
|
||||
|
||||
public static final DeferredItem<PartItemArcaneCraftingTerminal> ARCANE_CRAFTING_TERMINAL_ITEM =
|
||||
REGISTRY.register("arcane_crafting_terminal",
|
||||
() -> new PartItemArcaneCraftingTerminal(new Item.Properties().stacksTo(64)));
|
||||
@@ -83,8 +64,25 @@ public final class ModItems {
|
||||
public static final DeferredItem<BlockItem> ESSENTIA_PROVIDER_CONNECTION_ITEM =
|
||||
REGISTRY.registerSimpleBlockItem(ModBlocks.ESSENTIA_PROVIDER_CONNECTION);
|
||||
|
||||
/** M6:概率加速卡(手持右键概率之脑直插,上限 4)。 */
|
||||
public static final DeferredItem<ProbabilityAcceleratorCardItem> PROBABILITY_ACCELERATOR_CARD =
|
||||
REGISTRY.register("probability_accelerator_card",
|
||||
() -> new ProbabilityAcceleratorCardItem(new Item.Properties().stacksTo(16)));
|
||||
|
||||
public static final DeferredItem<BlockItem> BRAIN_OF_PROBABILITY_ITEM =
|
||||
REGISTRY.registerSimpleBlockItem(ModBlocks.BRAIN_OF_PROBABILITY);
|
||||
public static final DeferredItem<BlockItem> BRAIN_OF_PROBABILITY_TOP_ITEM =
|
||||
REGISTRY.registerSimpleBlockItem(ModBlocks.BRAIN_OF_PROBABILITY_TOP);
|
||||
|
||||
/** 无线连接器:右键接收器选中,再右键源质供应器建立连接。 */
|
||||
public static final DeferredItem<net.minecraft.world.item.Item> WIRELESS_CONNECTOR =
|
||||
REGISTRY.register("wireless_connector",
|
||||
() -> new thaumicenergistics.common.items.WirelessConnectorItem(new net.minecraft.world.item.Item.Properties()));
|
||||
() -> new WirelessConnectorItem(new net.minecraft.world.item.Item.Properties()));
|
||||
|
||||
/**
|
||||
* 源质访问卡:插入 AE2 原版输入/输出/存储总线与 ME 接口后,使其获得源质能力。
|
||||
* 走 AE2 升级卡基类 {@link thaumicenergistics.common.items.ItemEssentiaUpgradeCard}(= AE2 工厂函数等价物)。
|
||||
*/
|
||||
public static final DeferredItem<Item> ESSENTIA_UPGRADE_CARD = REGISTRY.register("essentia_upgrade_card",
|
||||
() -> new ItemEssentiaUpgradeCard(new Item.Properties()));
|
||||
}
|
||||
@@ -10,10 +10,7 @@ import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.container.*;
|
||||
import thaumicenergistics.common.parts.EssentiaExportBusPart;
|
||||
import thaumicenergistics.common.parts.EssentiaImportBusPart;
|
||||
import thaumicenergistics.common.parts.EssentiaLevelEmitterPart;
|
||||
import thaumicenergistics.common.parts.EssentiaStorageBusPart;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -28,43 +25,20 @@ public final class ModMenuTypes {
|
||||
REGISTRY.register("essentia_vibration_chamber", () -> IMenuTypeExtension.create(ContainerEssentiaVibrationChamber::new));
|
||||
public static final Supplier<MenuType<ContainerArcaneAssembler>> ARCANE_ASSEMBLER =
|
||||
REGISTRY.register("arcane_assembler", () -> IMenuTypeExtension.create(ContainerArcaneAssembler::new));
|
||||
/** 源质终端菜单:有线段(挂在线缆上的终端部件)。 */
|
||||
public static final Supplier<MenuType<EssentiaTerminalMenu>> ESSENTIA_TERMINAL =
|
||||
REGISTRY.register("essentia_terminal", () ->
|
||||
MenuTypeBuilder.create(EssentiaTerminalMenu::new, ITerminalHost.class)
|
||||
.buildUnregistered(ThaumicEnergistics.id("essentia_terminal")));
|
||||
/** 源质终端菜单:无线段(手持无线源质终端)。 */
|
||||
public static final Supplier<MenuType<EssentiaTerminalMenu>> WIRELESS_ESSENTIA_TERMINAL =
|
||||
REGISTRY.register("wireless_essentia_terminal", () ->
|
||||
MenuTypeBuilder.create(EssentiaTerminalMenu::new, IPortableTerminal.class)
|
||||
.buildUnregistered(ThaumicEnergistics.id("wireless_essentia_terminal")));
|
||||
public static final Supplier<MenuType<ContainerKnowledgeInscriber>> KNOWLEDGE_INSCRIBER =
|
||||
REGISTRY.register("knowledge_inscriber", () -> IMenuTypeExtension.create(ContainerKnowledgeInscriber::new));
|
||||
public static final Supplier<MenuType<ContainerDistillationPatternEncoder>> DISTILLATION_ENCODER =
|
||||
REGISTRY.register("distillation_encoder", () -> IMenuTypeExtension.create(ContainerDistillationPatternEncoder::new));
|
||||
|
||||
public static final Supplier<MenuType<ContainerEssentiaImportBus>> ESSENTIA_IMPORT_BUS =
|
||||
REGISTRY.register("essentia_import_bus", () ->
|
||||
MenuTypeBuilder.create(ContainerEssentiaImportBus::new, EssentiaImportBusPart.class)
|
||||
.withMenuTitle(host -> host.getName() != null ? host.getName() : Component.empty())
|
||||
.buildUnregistered(ThaumicEnergistics.id("essentia_import_bus")));
|
||||
|
||||
public static final Supplier<MenuType<ContainerEssentiaExportBus>> ESSENTIA_EXPORT_BUS =
|
||||
REGISTRY.register("essentia_export_bus", () ->
|
||||
MenuTypeBuilder.create(ContainerEssentiaExportBus::new, EssentiaExportBusPart.class)
|
||||
.withMenuTitle(host -> host.getName() != null ? host.getName() : Component.empty())
|
||||
.buildUnregistered(ThaumicEnergistics.id("essentia_export_bus")));
|
||||
|
||||
public static final Supplier<MenuType<ContainerEssentiaStorageBus>> ESSENTIA_STORAGE_BUS =
|
||||
REGISTRY.register("essentia_storage_bus", () ->
|
||||
MenuTypeBuilder.create(ContainerEssentiaStorageBus::new, EssentiaStorageBusPart.class)
|
||||
.withMenuTitle(host -> host.getName() != null ? host.getName() : Component.empty())
|
||||
.buildUnregistered(ThaumicEnergistics.id("essentia_storage_bus")));
|
||||
|
||||
public static final Supplier<MenuType<ContainerArcaneCraftingTerminal>> ARCANE_CRAFTING_TERMINAL =
|
||||
REGISTRY.register("arcane_crafting_terminal", () ->
|
||||
MenuTypeBuilder.create(ContainerArcaneCraftingTerminal::new, ITerminalHost.class)
|
||||
.buildUnregistered(ThaumicEnergistics.id("arcane_crafting_terminal")));
|
||||
/** 无线奥术合成终端菜单:复用有线菜单类,仅换 host 类型(手持无线终端,同 wireless_essentia_terminal 先例)。 */
|
||||
public static final Supplier<MenuType<ContainerArcaneCraftingTerminal>> WIRELESS_ARCANE_CRAFTING_TERMINAL =
|
||||
REGISTRY.register("wireless_arcane_crafting_terminal", () ->
|
||||
MenuTypeBuilder.create(ContainerArcaneCraftingTerminal::new, IPortableTerminal.class)
|
||||
.buildUnregistered(ThaumicEnergistics.id("wireless_arcane_crafting_terminal")));
|
||||
|
||||
public static final Supplier<MenuType<ContainerEssentiaLevelEmitter>> ESSENTIA_LEVEL_EMITTER =
|
||||
REGISTRY.register("essentia_level_emitter", () ->
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import mezz.jei.api.constants.RecipeTypes;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferInfo;
|
||||
|
||||
import appeng.menu.SlotSemantics;
|
||||
import thaumicenergistics.common.container.ContainerArcaneCraftingTerminal;
|
||||
import thaumicenergistics.init.ModMenuTypes;
|
||||
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import thaumicenergistics.common.container.ContainerKnowledgeInscriber;
|
||||
import thaumicenergistics.common.container.slot.GhostSlot;
|
||||
import thaumicenergistics.common.network.KnowledgeInscriberGhostSlotPacket;
|
||||
import thaumicenergistics.init.ModMenuTypes;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
/**
|
||||
* 知识记录仪 JEI 奥术配方 "+" 一键放置:
|
||||
@@ -56,7 +57,7 @@ public class KnowledgeInscriberArcaneRecipeTransfer
|
||||
ContainerKnowledgeInscriber menu,
|
||||
JeiArcaneRecipe recipe,
|
||||
mezz.jei.api.gui.ingredient.IRecipeSlotsView display,
|
||||
net.minecraft.world.entity.player.Player player,
|
||||
Player player,
|
||||
boolean maxTransfer,
|
||||
boolean doTransfer) {
|
||||
// 预览:始终可转移(ghost 槽不消耗物品)
|
||||
|
||||
+3
-2
@@ -14,6 +14,7 @@ import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import thaumicenergistics.common.container.GuiKnowledgeInscriber;
|
||||
import thaumicenergistics.common.container.slot.GhostSlot;
|
||||
import thaumicenergistics.common.network.KnowledgeInscriberGhostSlotPacket;
|
||||
import thaumicenergistics.common.container.ContainerKnowledgeInscriber;
|
||||
|
||||
/**
|
||||
* 知识记录仪 JEI 拖拽:从 JEI 拉取物品到 3×3 合成网格(ghost 槽)。
|
||||
@@ -44,10 +45,10 @@ public class KnowledgeInscriberGhostIngredientHandler
|
||||
ItemStack s = stack.copyWithCount(1);
|
||||
ghostSlot.set(s);
|
||||
// 与手动点击一致:客户端刷新产物计算 + C2S 同步服务端
|
||||
if (gui.getMenu() instanceof thaumicenergistics.common.container.ContainerKnowledgeInscriber menu) {
|
||||
if (gui.getMenu() instanceof ContainerKnowledgeInscriber menu) {
|
||||
menu.onCraftingChangedClient();
|
||||
}
|
||||
int gridIndex = gui.getMenu() instanceof thaumicenergistics.common.container.ContainerKnowledgeInscriber m
|
||||
int gridIndex = gui.getMenu() instanceof ContainerKnowledgeInscriber m
|
||||
? m.getGhostGridIndex(ghostSlot) : -1;
|
||||
PacketDistributor.sendToServer(
|
||||
new KnowledgeInscriberGhostSlotPacket(gui.getMenu().containerId, gridIndex, s));
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
package thaumicenergistics.integration.jei;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.renderer.Rect2i;
|
||||
|
||||
import mezz.jei.api.gui.builder.IClickableIngredientFactory;
|
||||
import mezz.jei.api.gui.handlers.IGuiContainerHandler;
|
||||
import mezz.jei.api.runtime.IClickableIngredient;
|
||||
|
||||
import appeng.api.stacks.AEItemKey;
|
||||
import appeng.api.stacks.AEKey;
|
||||
import appeng.api.stacks.GenericStack;
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.StackWithBounds;
|
||||
import appeng.core.definitions.AEItems;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
|
||||
/**
|
||||
* AE 界面(源质终端等)的 JEI GuiContainerHandler:
|
||||
* 悬停仓库中的源质条目时,返回 {@link AspectIngredient} 作为可点击成分,
|
||||
* 使 JEI 的 A 键收藏/配方查看能正确显示源质图标与名称。
|
||||
* <p>
|
||||
* 背景:源质是非物品/流体 AEKey,repo 中显示为 WrappedGenericStack 物品。
|
||||
* 若不提供转换,JEI 收藏会退化为"包裹通用堆栈"(无图标、名字丢失)。
|
||||
* 本处理不依赖 AE2-JEI-Integration 是否存在,ThE 自带即可生效。
|
||||
*/
|
||||
public class ThEEssentiaGuiHandler implements IGuiContainerHandler<AEBaseScreen<?>> {
|
||||
|
||||
@Override
|
||||
public Optional<? extends IClickableIngredient<?>> getClickableIngredientUnderMouse(
|
||||
IClickableIngredientFactory factory, AEBaseScreen<?> screen, double mouseX, double mouseY) {
|
||||
StackWithBounds stackWithBounds = screen.getStackUnderMouse(mouseX, mouseY);
|
||||
if (stackWithBounds == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
AEssentiaKey key = unwrapEssentiaKey(stackWithBounds.stack());
|
||||
if (key == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
// AEssentiaKey id = thaumcraft:<tag> → Aspect
|
||||
Aspect aspect = Aspect.getAspect(key.getId().getPath());
|
||||
if (aspect == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
return factory.createBuilder(AspectIngredientType.INSTANCE, new AspectIngredient(aspect))
|
||||
.buildWithArea(stackWithBounds.bounds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Rect2i> getGuiExtraAreas(AEBaseScreen<?> screen) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 GenericStack 中解析源质 key,兼容两种形式:
|
||||
* <ul>
|
||||
* <li>直接 {@link AEssentiaKey}(StackWithBounds.fromSlot 已 unwrap 的形式)</li>
|
||||
* <li>{@code WrappedGenericStack} 物品包裹的形式(unwrap 失败/直接拿到物品的形式)</li>
|
||||
* </ul>
|
||||
*/
|
||||
private static AEssentiaKey unwrapEssentiaKey(GenericStack stack) {
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
AEKey what = stack.what();
|
||||
if (what instanceof AEssentiaKey essentiaKey) {
|
||||
return essentiaKey;
|
||||
}
|
||||
if (what instanceof AEItemKey itemKey) {
|
||||
var itemStack = itemKey.toStack();
|
||||
if (AEItems.WRAPPED_GENERIC_STACK.is(itemStack)) {
|
||||
var unwrapped = GenericStack.unwrapItemStack(itemStack);
|
||||
if (unwrapped != null && unwrapped.what() instanceof AEssentiaKey wrappedKey) {
|
||||
return wrappedKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,9 @@ import mezz.jei.api.ingredients.ITypedIngredient;
|
||||
import appeng.api.stacks.GenericStack;
|
||||
import appeng.menu.AEBaseMenu;
|
||||
import appeng.menu.slot.FakeSlot;
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import thaumicenergistics.common.integration.appeng.AEssentiaKey;
|
||||
import thaumicenergistics.common.integration.tc.TCReflection;
|
||||
|
||||
/**
|
||||
* 处理从 JEI 拖拽到 AE2 Screen 的筛选槽。
|
||||
@@ -26,7 +29,7 @@ public class ThEGhostIngredientHandler implements IGhostIngredientHandler<Screen
|
||||
public <I> List<Target<I>> getTargetsTyped(Screen screen, ITypedIngredient<I> ingredient, boolean doStart) {
|
||||
List<Target<I>> targets = new ArrayList<>();
|
||||
|
||||
if (!(screen instanceof appeng.client.gui.AEBaseScreen<?> aeScreen)) {
|
||||
if (!(screen instanceof AEBaseScreen<?> aeScreen)) {
|
||||
return targets;
|
||||
}
|
||||
|
||||
@@ -76,9 +79,9 @@ public class ThEGhostIngredientHandler implements IGhostIngredientHandler<Screen
|
||||
|
||||
if (ingredient instanceof AspectIngredient ai && ai.aspect() != null) {
|
||||
// AspectIngredient → WrappedGenericStack ItemStack
|
||||
var aspectId = thaumicenergistics.common.integration.tc.TCReflection.getAspectId(ai.aspect());
|
||||
var aspectId = TCReflection.getAspectId(ai.aspect());
|
||||
if (aspectId != null) {
|
||||
var key = thaumicenergistics.common.integration.appeng.AEssentiaKey.of(aspectId);
|
||||
var key = AEssentiaKey.of(aspectId);
|
||||
targetStack = GenericStack.wrapInItemStack(key, 0);
|
||||
}
|
||||
} else if (ingredient instanceof ItemStack stack) {
|
||||
@@ -89,7 +92,9 @@ public class ThEGhostIngredientHandler implements IGhostIngredientHandler<Screen
|
||||
}
|
||||
|
||||
if (!targetStack.isEmpty()) {
|
||||
fakeSlot.set(targetStack);
|
||||
// 走 AE2 原生 SET_FILTER 路径(InventoryActionPacket,服务端执行);
|
||||
// 不能用 FakeSlot#set(纯客户端直写,服务端不同步 → 无效写入)。
|
||||
fakeSlot.setFilterTo(targetStack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user